WC_Admin_Addons::get_section_data()public staticWC 1.0

Deprecated from version 5.9.0. It is no longer supported and can be removed in future releases. Use d in In-App Marketplace instead.

Get section content for the addons screen.

Method of the class: WC_Admin_Addons{}

Hooks from the method

Return

Array.

Usage

$result = WC_Admin_Addons::get_section_data( $section_id );
$section_id(string) (required)
Required section ID.

Changelog

Deprecated since 5.9.0 No longer used in In-App Marketplace

WC_Admin_Addons::get_section_data() code WC 8.7.0

public static function get_section_data( $section_id ) {
	$section      = self::get_section( $section_id );
	$section_data = '';

	if ( ! empty( $section->endpoint ) ) {
		$section_data = get_transient( 'wc_addons_section_' . $section_id );
		if ( false === $section_data ) {
			$raw_section = wp_safe_remote_get(
				esc_url_raw( $section->endpoint ),
				array(
					'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ),
				)
			);

			if ( ! is_wp_error( $raw_section ) ) {
				$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );

				if ( ! empty( $section_data->products ) ) {
					set_transient( 'wc_addons_section_' . $section_id, $section_data, WEEK_IN_SECONDS );
				}
			}
		}
	}

	return apply_filters( 'woocommerce_addons_section_data', $section_data->products, $section_id );
}