plugin_slug = $plugin->get_plugin_slug(); // Add the options page require_once( plugin_dir_path( __FILE__ ) . 'includes/settings.php' ); // Add the menu item. add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) ); // Add an action link pointing to the options page. $plugin_basename = plugin_basename( plugin_dir_path( realpath( dirname( __FILE__ ) ) ) . 'add-post-type-instructions.php' ); add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) ); // Fire functions add_action( 'admin_print_styles', array( $this, 'is_edit_page' ) ); add_action( 'edit_form_top', array( $this, 'add_content_above_title' ) ); add_action( 'edit_form_after_title', array( $this, 'add_content_above_editor' ) ); add_filter( 'default_content', array( $this, 'change_editor_content' ) ); add_action( 'admin_head', array( $this, 'change_publish_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_author_metabox_content' ) ); add_filter( 'admin_post_thumbnail_html', array( $this, 'change_thumbnail_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_excerpt_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_trackbacks_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_customfields_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_comments_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_discussion_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_revisions_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_pageattributes_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_categories_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_tags_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_postformats_metabox_content' ) ); add_action( 'admin_head', array( $this, 'change_slug_metabox_content' ) ); } /** * Return an instance of this class. * * @since 1.0 * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if ( null == self::$instance ) { self::$instance = new self; } return self::$instance; } /** * Register the administration menu for this plugin into the WordPress Dashboard menu. * * @since 1.0 */ public function add_plugin_admin_menu() { /* * Add a settings page for this plugin to the Settings menu. * * NOTE: Alternative menu locations are available via WordPress administration menu functions. * * Administration Menus: http://codex.wordpress.org/Administration_Menus * */ $this->plugin_screen_hook_suffix = add_options_page( __( 'Post Type Instructions', $this->plugin_slug ), __( 'Post Type Instructions', $this->plugin_slug ), 'manage_options', $this->plugin_slug, array( $this, 'display_plugin_admin_page' ) ); } /** * Render the settings page for this plugin. * * @since 1.0 */ public function display_plugin_admin_page() { include_once( 'views/admin.php' ); } /** * Add settings action link to the plugins page. * * @since 1.0 */ public function add_action_links( $links ) { return array_merge( array( 'settings' => '' . __( 'Settings' ) . '' ), $links ); } /** * Get post type * * @since 1.0 */ public function get_post_type() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { if ( isset( $_REQUEST['post_id'] ) ) { $post = get_post( $_REQUEST['post_id'] ); return $post->post_type; } } $screen = get_current_screen(); return $screen->post_type; } // end get_post_type /** * enqueue styles * * @since 1.0.2 */ public function is_edit_page($new_edit = null){ global $current_screen; // Makes the $current_screen object available if ($current_screen && ($current_screen->base == "edit" || $current_screen->base == "post")) { wp_enqueue_style('apti-style', plugins_url( '/css/apti.css', __FILE__ ) ); } } // end is_edit_page /** * Add content above title * * @since 2.1 */ public function add_content_above_title() { $post_type = $this->get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['top_check'] ) && ! empty( $options['top_check'] ) ) { if ( isset( $options['top'] ) && ! empty( $options['top'] ) ) { $top = $options['top']; echo '
' . $options['publish'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['author_check'] ) && ! empty( $options['author_check'] ) ) { if ( isset( $options['author'] ) && ! empty( $options['author'] ) ) { $author = ''; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['thumbnail_check'] ) && ! empty( $options['thumbnail_check'] ) ) { if ( isset( $options['thumbnail'] ) && ! empty( $options['thumbnail'] ) ) { $thumbnail = '' . $options['thumbnail'] . '
'; $content = $thumbnail . $content; } } return $content; } // end change_thumbnail_metabox_content /** * Change excerpt metabox content * * @since 1.0.2 */ public function change_excerpt_metabox_content() { $post_type = $this->get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['excerpt_check'] ) && ! empty( $options['excerpt_check'] ) ) { if ( isset( $options['excerpt'] ) && ! empty( $options['excerpt'] ) ) { $excerpt = '' . $options['excerpt'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['trackbacks_check'] ) && ! empty( $options['trackbacks_check'] ) ) { if ( isset( $options['trackbacks'] ) && ! empty( $options['trackbacks'] ) ) { $trackbacks = '' . $options['trackbacks'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['customfields_check'] ) && ! empty( $options['customfields_check'] ) ) { if ( isset( $options['customfields'] ) && ! empty( $options['customfields'] ) ) { $customfields = '' . $options['customfields'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['comments_check'] ) && ! empty( $options['comments_check'] ) ) { if ( isset( $options['comments'] ) && ! empty( $options['comments'] ) ) { $comments = '' . $options['comments'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['discussion_check'] ) && ! empty( $options['discussion_check'] ) ) { if ( isset( $options['discussion'] ) && ! empty( $options['discussion'] ) ) { $discussion = '' . $options['discussion'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['revisions_check'] ) && ! empty( $options['revisions_check'] ) ) { if ( isset( $options['revisions'] ) && ! empty( $options['revisions'] ) ) { $revisions = '' . $options['revisions'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['pageattributes_check'] ) && ! empty( $options['pageattributes_check'] ) ) { if ( isset( $options['pageattributes'] ) && ! empty( $options['pageattributes'] ) ) { $pageattributes = '' . $options['pageattributes'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['categories_check'] ) && ! empty( $options['categories_check'] ) ) { if ( isset( $options['categories'] ) && ! empty( $options['categories'] ) ) { $categories = '' . $options['categories'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['tags_check'] ) && ! empty( $options['tags_check'] ) ) { if ( isset( $options['tags'] ) && ! empty( $options['tags'] ) ) { $tags = ''; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['postformats_check'] ) && ! empty( $options['postformats_check'] ) ) { if ( isset( $options['postformats'] ) && ! empty( $options['postformats'] ) ) { $postformats = '' . $options['postformats'] . '
'; ?> get_post_type(); $options = get_option( $this->plugin_slug . '_' . $post_type ); if ( isset( $options['slug_check'] ) && ! empty( $options['slug_check'] ) ) { if ( isset( $options['slug'] ) && ! empty( $options['slug'] ) ) { $slug = '' . $options['slug'] . '
'; ?>