1 <?php
2 3 4 5 6 7 8 9
10
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 if ( ! class_exists( 'WC_Admin_Addons' ) ) :
14
15 16 17
18 class WC_Admin_Addons {
19
20 21 22
23 public function output() {
24
25 if ( false === ( $addons = get_transient( 'woocommerce_addons_data' ) ) ) {
26 $addons_json = wp_remote_get( 'http://d3t0oesq8995hv.cloudfront.net/woocommerce-addons.json', array( 'user-agent' => 'WooCommerce Addons Page' ) );
27 if ( ! is_wp_error( $addons_json ) ) {
28 $addons = json_decode( wp_remote_retrieve_body( $addons_json ) );
29 if ( $addons ) {
30 set_transient( 'woocommerce_addons_data', $addons, 60*60*24*7 );
31 }
32 }
33 }
34
35 $view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : '';
36
37 include_once( 'views/html-admin-page-addons.php' );
38 }
39 }
40
41 endif;
42
43 return new WC_Admin_Addons();