plugin = admin_content_lables(); $this->wp_hooks(); } /** * Hook into WordPress. * * @since 1.0.0 * @access public * @return void */ protected function wp_hooks() { add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) ); add_action( 'post_submitbox_misc_actions', array( $this, 'admin_label_form' ) ); add_action( 'save_post', array( $this, 'save_label_meta' ), 10, 2 ); } /** * Enqueue admin scripts and styles. * * @since 1.0.0 * @access public * @return void */ public function load_admin_scripts( $hook ) { if ( 'post-new.php' === $hook || 'post.php' === $hook ) { wp_enqueue_script( 'admin-content-labels', ADMIN_CONLAB_URL . 'js/admin-content-labels.js', array( 'jquery' ), ADMIN_CONLAB_VERSION, true ); } } /** * Display an input field to allow users to add a content admin label. * * @since 1.0.0 * @access public * @return void */ public function admin_label_form() { $post_type_object = get_post_type_object( get_post_type() ); // Bail if the current user doesn't have permission to edit the current post. if ( ! current_user_can( $post_type_object->cap->edit_post, get_the_ID() ) ) { return; } $label = $this->plugin->has_admin_label() ? $this->plugin->get_admin_label() : ''; ?>