WC_Admin_Addons::get_sections
Get sections for the addons screen
Method of the class: WC_Admin_Addons{}
Hooks from the method
Returns
Array. of objects
Usage
$result = WC_Admin_Addons::get_sections();
WC_Admin_Addons::get_sections() WC Admin Addons::get sections code WC 10.4.3
public static function get_sections() {
$locale = get_user_locale();
$addon_sections = self::get_locale_data_from_transient( 'wc_addons_sections', $locale );
if ( false === ( $addon_sections ) ) {
$parameter_string = '?' . http_build_query( array( 'locale' => get_user_locale() ) );
$raw_sections = wp_safe_remote_get(
'https://woocommerce.com/wp-json/wccom-extensions/1.0/categories' . $parameter_string,
array(
'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ),
)
);
if ( ! is_wp_error( $raw_sections ) ) {
$addon_sections = json_decode( wp_remote_retrieve_body( $raw_sections ) );
if ( $addon_sections ) {
self::set_locale_data_in_transient( 'wc_addons_sections', $addon_sections, $locale, WEEK_IN_SECONDS );
}
}
}
return apply_filters( 'woocommerce_addons_sections', $addon_sections );
}