| @@ -20,8 +20,13 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | protected $boxzilla; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | + * @var ReviewNotice | |
| 25 | + */ | |
| 26 | + protected $review_notice; | |
| 27 | + | |
| 28 | + /** | |
| 24 | 29 | * @param Plugin $plugin |
| 25 | 30 | * @param Boxzilla $boxzilla |
| 26 | 31 | */ |
| 27 | 32 | public function __construct( Plugin $plugin, Boxzilla $boxzilla ) { |
| @@ -26,8 +31,9 @@ | ||
| 26 | 31 | */ |
| 27 | 32 | public function __construct( Plugin $plugin, Boxzilla $boxzilla ) { |
| 28 | 33 | $this->plugin = $plugin; |
| 29 | 34 | $this->boxzilla = $boxzilla; |
| 35 | + $this->review_notice = new ReviewNotice(); | |
| 30 | 36 | } |
| 31 | 37 | |
| 32 | 38 | /** |
| 33 | 39 | * Initialise the all admin related stuff |
| @@ -47,16 +53,42 @@ | ||
| 47 | 53 | */ |
| 48 | 54 | protected function add_hooks() { |
| 49 | 55 | add_action( 'admin_init', array( $this, 'lazy_add_hooks' ) ); |
| 50 | 56 | add_action( 'admin_init', array( $this, 'register' ) ); |
| 57 | + add_action( 'init', array( $this, 'listen_for_actions' ) ); | |
| 51 | 58 | add_action( 'admin_menu', array( $this, 'menu' ) ); |
| 52 | 59 | add_action( 'admin_notices', array( $this, 'notices' ) ); |
| 53 | 60 | add_action( 'save_post_boxzilla-box', array( $this, 'save_box_options' ), 20, 2 ); |
| 54 | 61 | add_action( 'trashed_post', array( $this, 'flush_rules' ) ); |
| 55 | 62 | add_action( 'untrashed_post', array( $this, 'flush_rules' ) ); |
| 63 | + | |
| 64 | + $this->review_notice->add_hooks(); | |
| 56 | 65 | } |
| 57 | 66 | |
| 58 | 67 | /** |
| 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 | + /** | |
| 59 | 91 | * All logic for admin notices lives here. |
| 60 | 92 | */ |
| 61 | 93 | public function notices() { |
| 62 | 94 | global $pagenow, |
| @@ -102,14 +134,10 @@ | ||
| 102 | 134 | add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) ); |
| 103 | 135 | add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
| 104 | 136 | add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_init' ) ); |
| 105 | 137 | add_filter( 'manage_edit-boxzilla-box_columns', array( $this, 'post_type_column_titles' ) ); |
| 106 | - add_action( 'manage_boxzilla-box_posts_custom_column', array( | |
| 107 | - $this, | |
| 108 | - 'post_type_column_content' | |
| 109 | - ), 10, 2 ); | |
| 138 | + add_action( 'manage_boxzilla-box_posts_custom_column', array( $this, 'post_type_column_content' ), 10, 2 ); | |
| 110 | 139 | add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
| 111 | - | |
| 112 | 140 | |
| 113 | 141 | if ( $pagenow === 'plugins.php' ) { |
| 114 | 142 | add_filter( 'plugin_action_links', array( $this, 'add_plugin_settings_link' ), 10, 2 ); |
| 115 | 143 | add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 ); |