plugin_slug = $plugin->get_plugin_slug(); // Add settings page add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_print_styles', array( $this, 'is_settings_page' ) ); } /** * 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; } /** * enqueue styles * * @param string $content HTML string * * @since 1.1 */ public function is_settings_page(){ wp_enqueue_style('apti-settings-style', plugins_url( '../css/apti-settings.css', __FILE__ ) ); } // end is_settings_page /** * Registering the Sections, Fields, and Settings. * * This function is registered with the 'admin_init' hook. */ public function admin_init() { $plugin = add_post_type_instructions::get_instance(); $post_types = $plugin->supported_post_types(); $defaults = array( // order defined by Parameters reference at http://codex.wordpress.org/Function_Reference/post_type_supports 'top' => '', 'instruction' => '', 'editor' => '', 'publish' => '', 'author' => '', 'thumbnail' => '', 'excerpt' => '', 'trackbacks' => '', 'custom-fields' => '', 'comments' => '', 'discussion' => '', 'revisions' => '', 'page-attributes' => '', 'categories' => '', 'tags' => '', 'post-formats' => '', 'slug' => '', ); foreach ( $post_types as $pt ) { $post_object = get_post_type_object( $pt ); $section = $this->plugin_slug . '_' . $pt; if ( false == get_option( $section ) ) { add_option( $section, apply_filters( $section . '_default_settings', $defaults ) ); } $args = array( $section, get_option( $section ) ); add_settings_section( $pt, sprintf( __( 'Set instructional content for all %s', $this->plugin_slug ), $post_object->labels->name ), '', $section ); if ( post_type_supports( $pt, 'title' )) { add_settings_field( 'top_check', __( 'Above Title Field:', $this->plugin_slug ), array( $this, 'top_check_callback' ), $section, $pt, $args ); add_settings_field( 'top', __( '', $this->plugin_slug ), array( $this, 'top_callback' ), $section, $pt, $args ); } add_settings_field( 'instruction_check', __( 'Above WYSIWYG Editor:', $this->plugin_slug ), array( $this, 'instruction_check_callback' ), $section, $pt, $args ); add_settings_field( 'instruction', __( '', $this->plugin_slug ), array( $this, 'instruction_callback' ), $section, $pt, $args ); if ( post_type_supports( $pt, 'editor' )) { add_settings_field( 'editor_check', __( 'WYSIWYG Content:', $this->plugin_slug ), array( $this, 'editor_check_callback' ), $section, $pt, $args ); add_settings_field( 'editor', __( '', $this->plugin_slug ), array( $this, 'editor_callback' ), $section, $pt, $args ); } add_settings_field( 'publish_check', __( 'Publish Metabox:', $this->plugin_slug ), array( $this, 'publish_check_callback' ), $section, $pt, $args ); add_settings_field( 'publish', __( '', $this->plugin_slug ), array( $this, 'publish_callback' ), $section, $pt, $args ); if ( post_type_supports( $pt, 'author' )) { add_settings_field( 'author_check', __( 'Author Metabox:', $this->plugin_slug ), array( $this, 'author_check_callback' ), $section, $pt, $args ); add_settings_field( 'author', __( '', $this->plugin_slug ), array( $this, 'author_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'thumbnail' )) { add_settings_field( 'thumbnail_check', __( 'Featured Image Metabox:', $this->plugin_slug ), array( $this, 'thumbnail_check_callback' ), $section, $pt, $args ); add_settings_field( 'thumbnail', __( '', $this->plugin_slug ), array( $this, 'thumbnail_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'excerpt' )) { add_settings_field( 'excerpt_check', __( 'Excerpt Metabox:', $this->plugin_slug ), array( $this, 'excerpt_check_callback' ), $section, $pt, $args ); add_settings_field( 'excerpt', __( '', $this->plugin_slug ), array( $this, 'excerpt_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'trackbacks' )) { add_settings_field( 'trackbacks_check', __( 'Trackbacks Metabox:', $this->plugin_slug ), array( $this, 'trackbacks_check_callback' ), $section, $pt, $args ); add_settings_field( 'trackbacks', __( '', $this->plugin_slug ), array( $this, 'trackbacks_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'custom-fields' )) { add_settings_field( 'customfields_check', __( 'Custom Fields Metabox:', $this->plugin_slug ), array( $this, 'customfields_check_callback' ), $section, $pt, $args ); add_settings_field( 'customfields', __( '', $this->plugin_slug ), array( $this, 'customfields_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'comments' )) { add_settings_field( 'comments_check', __( 'Comments Metabox:', $this->plugin_slug ), array( $this, 'comments_check_callback' ), $section, $pt, $args ); add_settings_field( 'comments', __( '', $this->plugin_slug ), array( $this, 'comments_callback' ), $section, $pt, $args ); add_settings_field( 'discussion_check', __( 'Discussion Metabox:', $this->plugin_slug ), array( $this, 'discussion_check_callback' ), $section, $pt, $args ); add_settings_field( 'discussion', __( '', $this->plugin_slug ), array( $this, 'discussion_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'revisions' )) { add_settings_field( 'revisions_check', __( 'Revisions Metabox:', $this->plugin_slug ), array( $this, 'revisions_check_callback' ), $section, $pt, $args ); add_settings_field( 'revisions', __( '', $this->plugin_slug ), array( $this, 'revisions_callback' ), $section, $pt, $args ); } if ( post_type_supports( $pt, 'page-attributes' )) { add_settings_field( 'pageattributes_check', __( 'Page Attributes Metabox:', $this->plugin_slug ), array( $this, 'pageattributes_check_callback' ), $section, $pt, $args ); add_settings_field( 'pageattributes', __( '', $this->plugin_slug ), array( $this, 'pageattributes_callback' ), $section, $pt, $args ); } if ( !($pt == 'page') ) { if ( is_object_in_taxonomy( $pt, 'category' ) ) { add_settings_field( 'categories_check', __( 'Categories Metabox:', $this->plugin_slug ), array( $this, 'categories_check_callback' ), $section, $pt, $args ); add_settings_field( 'categories', __( '', $this->plugin_slug ), array( $this, 'categories_callback' ), $section, $pt, $args ); } if ( is_object_in_taxonomy( $pt, 'post_tag' ) ) { add_settings_field( 'tags_check', __( 'Tags Metabox:', $this->plugin_slug ), array( $this, 'tags_check_callback' ), $section, $pt, $args ); add_settings_field( 'tags', __( '', $this->plugin_slug ), array( $this, 'tags_callback' ), $section, $pt, $args ); } // custom taxonomies if ( post_type_supports( $pt, 'post-formats' )) { add_settings_field( 'postformats_check', __( 'Post Format Metabox:', $this->plugin_slug ), array( $this, 'postformats_check_callback' ), $section, $pt, $args ); add_settings_field( 'postformats', __( '', $this->plugin_slug ), array( $this, 'postformats_callback' ), $section, $pt, $args ); } } add_settings_field( 'slug_check', __( 'Slug Metabox:', $this->plugin_slug ), array( $this, 'slug_check_callback' ), $section, $pt, $args ); add_settings_field( 'slug', __( '', $this->plugin_slug ), array( $this, 'slug_callback' ), $section, $pt, $args ); register_setting( $section, $section ); } } // end admin_init public function top_check_callback( $args ) { $output = $args[0].'[top_check]'; $value = isset( $args[1]['top_check'] ) ? $args[1]['top_check'] : ''; $checkhtml = ''; $checkhtml .= ''; echo $checkhtml; } // end top_check_callback public function top_callback( $args ) { $output = $args[0].'[top]'; $value = isset( $args[1]['top'] ) ? $args[1]['top'] : ''; $html = '
'; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end instruction_check_callback public function instruction_callback( $args ) { $output = $args[0].'[instruction]'; $value = isset( $args[1]['instruction'] ) ? $args[1]['instruction'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end editor_check_callback public function editor_callback( $args ) { $output = $args[0].'[editor]'; $value = isset( $args[1]['editor'] ) ? $args[1]['editor'] : ''; $id = 'textarea_one'; $settings = array( 'textarea_name' => $output, 'textarea_rows' => '10' ); wp_editor( $value, $id, $settings ); } // end editor_callback public function publish_check_callback( $args ) { $output = $args[0].'[publish_check]'; $value = isset( $args[1]['publish_check'] ) ? $args[1]['publish_check'] : ''; $checkhtml = ''; $checkhtml .= ''; echo $checkhtml; } // end publish_check_callback public function publish_callback( $args ) { $output = $args[0].'[publish]'; $value = isset( $args[1]['publish'] ) ? $args[1]['publish'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end author_check_callback public function author_callback( $args ) { $output = $args[0].'[author]'; $value = isset( $args[1]['author'] ) ? $args[1]['author'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end thumbnail_check_callback public function thumbnail_callback( $args ) { $output = $args[0].'[thumbnail]'; $value = isset( $args[1]['thumbnail'] ) ? $args[1]['thumbnail'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end excerpt_check_callback public function excerpt_callback( $args ) { $output = $args[0].'[excerpt]'; $value = isset( $args[1]['excerpt'] ) ? $args[1]['excerpt'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end trackbacks_check_callback public function trackbacks_callback( $args ) { $output = $args[0].'[trackbacks]'; $value = isset( $args[1]['trackbacks'] ) ? $args[1]['trackbacks'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end customfields_check_callback public function customfields_callback( $args ) { $output = $args[0].'[customfields]'; $value = isset( $args[1]['customfields'] ) ? $args[1]['customfields'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end comments_check_callback public function comments_callback( $args ) { $output = $args[0].'[comments]'; $value = isset( $args[1]['comments'] ) ? $args[1]['comments'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end discussion_check_callback public function discussion_callback( $args ) { $output = $args[0].'[discussion]'; $value = isset( $args[1]['discussion'] ) ? $args[1]['discussion'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end revisions_check_callback public function revisions_callback( $args ) { $output = $args[0].'[revisions]'; $value = isset( $args[1]['revisions'] ) ? $args[1]['revisions'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end pageattributes_check_callback public function pageattributes_callback( $args ) { $output = $args[0].'[pageattributes]'; $value = isset( $args[1]['pageattributes'] ) ? $args[1]['pageattributes'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end categories_check_callback public function categories_callback( $args ) { $output = $args[0].'[categories]'; $value = isset( $args[1]['categories'] ) ? $args[1]['categories'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end tags_check_callback public function tags_callback( $args ) { $output = $args[0].'[tags]'; $value = isset( $args[1]['tags'] ) ? $args[1]['tags'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end postformats_check_callback public function postformats_callback( $args ) { $output = $args[0].'[postformats]'; $value = isset( $args[1]['postformats'] ) ? $args[1]['postformats'] : ''; $html = ''; echo $html; ?> '; $checkhtml .= ''; echo $checkhtml; } // end slug_check_callback public function slug_callback( $args ) { $output = $args[0].'[slug]'; $value = isset( $args[1]['slug'] ) ? $args[1]['slug'] : ''; $html = ''; echo $html; ?>