| @@ -20,13 +20,8 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | protected $boxzilla; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * @var ReviewNotice | |
| 25 | - */ | |
| 26 | - protected $review_notice; | |
| 27 | - | |
| 28 | - /** | |
| 29 | 24 | * @param Plugin $plugin |
| 30 | 25 | * @param Boxzilla $boxzilla |
| 31 | 26 | */ |
| 32 | 27 | public function __construct( Plugin $plugin, Boxzilla $boxzilla ) { |
| @@ -31,9 +26,8 @@ | ||
| 31 | 26 | */ |
| 32 | 27 | public function __construct( Plugin $plugin, Boxzilla $boxzilla ) { |
| 33 | 28 | $this->plugin = $plugin; |
| 34 | 29 | $this->boxzilla = $boxzilla; |
| 35 | - $this->review_notice = new ReviewNotice(); | |
| 36 | 30 | } |
| 37 | 31 | |
| 38 | 32 | /** |
| 39 | 33 | * Initialise the all admin related stuff |
| @@ -53,42 +47,16 @@ | ||
| 53 | 47 | */ |
| 54 | 48 | protected function add_hooks() { |
| 55 | 49 | add_action( 'admin_init', array( $this, 'lazy_add_hooks' ) ); |
| 56 | 50 | add_action( 'admin_init', array( $this, 'register' ) ); |
| 57 | - add_action( 'init', array( $this, 'listen_for_actions' ) ); | |
| 58 | 51 | add_action( 'admin_menu', array( $this, 'menu' ) ); |
| 59 | 52 | add_action( 'admin_notices', array( $this, 'notices' ) ); |
| 60 | 53 | add_action( 'save_post_boxzilla-box', array( $this, 'save_box_options' ), 20, 2 ); |
| 61 | 54 | add_action( 'trashed_post', array( $this, 'flush_rules' ) ); |
| 62 | 55 | add_action( 'untrashed_post', array( $this, 'flush_rules' ) ); |
| 63 | - | |
| 64 | - $this->review_notice->add_hooks(); | |
| 65 | 56 | } |
| 66 | 57 | |
| 67 | 58 | /** |
| 68 | - * Listen for admin actions. | |
| 69 | - */ | |
| 70 | - public function listen_for_actions() { | |
| 71 | - | |
| 72 | - // triggered? | |
| 73 | - $vars = array_merge( $_POST, $_GET ); | |
| 74 | - if( empty( $vars['_boxzilla_admin_action'] ) ) { | |
| 75 | - return false; | |
| 76 | - } | |
| 77 | - | |
| 78 | - // authorized? | |
| 79 | - if( ! current_user_can( 'edit_posts' ) ) { | |
| 80 | - return false; | |
| 81 | - } | |
| 82 | - | |
| 83 | - // fire action | |
| 84 | - $action = $vars['_boxzilla_admin_action']; | |
| 85 | - do_action( 'boxzilla_admin_' . $action ); | |
| 86 | - | |
| 87 | - return true; | |
| 88 | - } | |
| 89 | - | |
| 90 | - /** | |
| 91 | 59 | * All logic for admin notices lives here. |
| 92 | 60 | */ |
| 93 | 61 | public function notices() { |
| 94 | 62 | global $pagenow, |
| @@ -134,11 +102,15 @@ | ||
| 134 | 102 | add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) ); |
| 135 | 103 | add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
| 136 | 104 | add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_init' ) ); |
| 137 | 105 | add_filter( 'manage_edit-boxzilla-box_columns', array( $this, 'post_type_column_titles' ) ); |
| 138 | - add_action( 'manage_boxzilla-box_posts_custom_column', array( $this, 'post_type_column_content' ), 10, 2 ); | |
| 106 | + add_action( 'manage_boxzilla-box_posts_custom_column', array( | |
| 107 | + $this, | |
| 108 | + 'post_type_column_content' | |
| 109 | + ), 10, 2 ); | |
| 139 | 110 | add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
| 140 | 111 | |
| 112 | + | |
| 141 | 113 | if ( $pagenow === 'plugins.php' ) { |
| 142 | 114 | add_filter( 'plugin_action_links', array( $this, 'add_plugin_settings_link' ), 10, 2 ); |
| 143 | 115 | add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 ); |
| 144 | 116 | } |
| @@ -236,9 +208,9 @@ | ||
| 236 | 208 | /** |
| 237 | 209 | * Shows the extensions page |
| 238 | 210 | */ |
| 239 | 211 | public function show_extensions_page() { |
| 240 | - $extensions = $this->fetch_extensions(); | |
| 212 | + $extensions = $this->fetch_extensions(); | |
| 241 | 213 | require __DIR__ . '/views/extensions.php'; |
| 242 | 214 | } |
| 243 | 215 | |
| 244 | 216 | /** |
| @@ -600,9 +572,8 @@ | ||
| 600 | 572 | $opts['cookie']['dismissed'] = absint( $opts['cookie']['dismissed'] ); |
| 601 | 573 | $opts['trigger'] = sanitize_text_field( $opts['trigger'] ); |
| 602 | 574 | $opts['trigger_percentage'] = absint( $opts['trigger_percentage'] ); |
| 603 | 575 | $opts['trigger_element'] = sanitize_text_field( $opts['trigger_element'] ); |
| 604 | - $opts['screen_size_condition']['value'] = intval( $opts['screen_size_condition']['value'] ); | |
| 605 | 576 | |
| 606 | 577 | return $opts; |
| 607 | 578 | } |
| 608 | 579 | |
| @@ -694,13 +665,14 @@ | ||
| 694 | 665 | * |
| 695 | 666 | * @return array |
| 696 | 667 | */ |
| 697 | 668 | protected function fetch_extensions() { |
| 698 | - | |
| 669 | + | |
| 699 | 670 | $extensions = get_transient( 'boxzilla_remote_extensions' ); |
| 700 | 671 | if ( $extensions ) { |
| 701 | 672 | return $extensions; |
| 702 | 673 | } |
| 674 | + | |
| 703 | 675 | $request = wp_remote_get( 'https://api.boxzillaplugin.com/v1/plugins' ); |
| 704 | 676 | |
| 705 | 677 | if ( is_wp_error( $request ) ) { |
| 706 | 678 | return array(); |