plugin_slug; $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); } /** * NOTE: Actions are points in the execution of a page or process * lifecycle that WordPress fires. * * WordPress Actions: http://codex.wordpress.org/Plugin_API#Actions * Action Reference: http://codex.wordpress.org/Plugin_API/Action_Reference * * @since 1.0.0 */ public function archive_control_custom_admin_style_scripts() { wp_register_style( 'archive_control_admin_css', plugin_dir_url( __FILE__ ) . '/css/admin-style.css', false, '1.0' ); wp_enqueue_style( 'archive_control_admin_css' ); wp_register_script( 'archive_control_admin_js', plugin_dir_url( __FILE__ ) . '/js/admin-scripts.js', 'jquery', '1.0', true ); wp_enqueue_script( 'archive_control_admin_js' ); } public function archive_control_action_link( $links ) { $mylinks = array( '' . __('Settings', 'archive-control') . '', ); return array_merge( $links, $mylinks ); } public function archive_control_menu() { add_options_page( __('Archive Control', 'archive-control'), __('Archive Control', 'archive-control'), 'manage_options', 'archive-control.php', array($this,'archive_control_options') ); $archive_control_options = get_option('archive_control_options'); if ($archive_control_options) { foreach($archive_control_options as $post_type => $options) { if ($options['title'] == 'custom' || $options['before'] == 'textarea' || $options['after'] == 'textarea') { if ($post_type == 'post') { $parent_slug = 'edit.php'; } else { $parent_slug = 'edit.php?post_type=' . $post_type; } add_submenu_page( $parent_slug, __('Edit Archive Page', 'archive-control'), __('Edit Archive Page', 'archive-control'), 'edit_posts', 'edit-archive-' . $post_type, array($this,'archive_control_edit_page_callback') ); } //has before or after value } } } public function archive_control_settings() { register_setting( 'archive-control-options-group', 'archive_control_options' ); $archive_control_options = get_option('archive_control_options'); if ($archive_control_options) { foreach($archive_control_options as $post_type => $options) { register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_title' ); register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_before' ); register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_after' ); } } } public function archive_control_edit_page_callback() { $screen = get_current_screen(); $current_post_type = $screen->post_type; $archive_control_options = get_option('archive_control_options'); $archive_control_cpt_title = get_option('archive_control_' . $current_post_type . '_title'); $archive_control_cpt_before = get_option('archive_control_' . $current_post_type . '_before'); $archive_control_cpt_after = get_option('archive_control_' . $current_post_type . '_after'); if ($screen->post_type == '' && $screen->parent_file == 'edit.php') { $current_post_type = 'post'; } $current_post_type_object = get_post_type_object($current_post_type); $current_post_type_options = $archive_control_options[$current_post_type]; ?>

label); ?>

'archive_control_' . $current_post_type . '_before', 'textarea_rows' => 10 );?>

'archive_control_' . $current_post_type . '_after', 'textarea_rows' => 10 );?>

Found a bug or have a feature request? Let us know on the WordPress plugin directory, or send a pull request with GitHub.

true, '_builtin' => false ); $post_types = get_post_types($args, 'objects' ); $archive_control_options = get_option('archive_control_options'); foreach ($post_types as $post_type ) { if($post_type->has_archive) { $edit_url = get_admin_url() . 'edit.php?post_type=' . $post_type->name . '&page=edit-archive-' . $post_type->name; ?>

label; ?>

name]['title'] == 'default' || $archive_control_options[$post_type->name]['title'] == null) { echo " style='display:none;'"; } ?>>name]['title'] == 'custom') { ?>
name]['before'] !== 'textarea' || $archive_control_options[$post_type->name]['before-placement'] !== 'automatic') { echo " style='display:none;'"; } ?>>name]['before'] == 'textarea') { ?>
name]['before'] !== 'textarea' || $archive_control_options[$post_type->name]['before-placement'] !== 'function') { echo " style='display:none;'"; } ?>>name]['before'] == 'textarea') { ?>
name]['after'] !== 'textarea' || $archive_control_options[$post_type->name]['after-placement'] !== 'automatic') { echo " style='display:none;'"; } ?>>name]['after'] == 'textarea') { ?>
name]['after'] !== 'textarea' || $archive_control_options[$post_type->name]['after-placement'] !== 'function') { echo " style='display:none;'"; } ?>>name]['after'] == 'textarea') { ?>
name]['orderby'] !== 'meta_value' && $archive_control_options[$post_type->name]['orderby'] !== 'meta_value_num') { echo " style='display:none;'"; } ?>/>
name]['pagination'] !== 'custom') { echo " style='display:none;'"; } ?>/>

is_main_query() ){ if (is_archive()) { // print "
";
					// print_r($query);
					// print "
"; $archive_control_options = get_option('archive_control_options'); foreach($archive_control_options as $post_type => $options) { if (is_post_type_archive($post_type)) { if ($options['order'] !== 'default' && $options['order'] !== null) { $query->set( 'order', $options['order'] ); } //has order value if ($options['orderby'] !== 'default' && $options['orderby'] !== null) { $query->set( 'orderby', $options['orderby'] ); if ($options['orderby'] == 'meta_value' || $options['orderby'] == 'meta_value_num') { if ($options['meta_key'] !== null) { $query->set( 'meta_key', $options['meta_key'] ); } //has meta_key value } //meta_key value is needed } //has orderby value if ($options['pagination'] !== 'default' && $options['pagination'] !== null) { if ($options['pagination'] == 'custom') { if ($options['posts_per_page'] !== null) { $query->set( 'posts_per_page', $options['posts_per_page'] ); } } if ($options['pagination'] == 'none') { $query->set( 'posts_per_page', -1 ); } } //has pagination value } //is_post_type_artchive } //foreach } // is_archive } //is_main_query } //is not admin return; } public static function archive_control_top_content($placement = 'function'){ if (is_archive()) { $archive_control_options = get_option('archive_control_options'); foreach($archive_control_options as $post_type => $options) { if (is_post_type_archive($post_type)) { if ($options['before'] == 'textarea' && $options['before-placement'] == $placement) { $paged = get_query_var( 'paged', 0); if($options['before-pages'] == 'all-pages' || ($options['before-pages'] == 'first' && $paged == 0)) { $archive_control_cpt_before = get_option('archive_control_' . $post_type . '_before'); if ($archive_control_cpt_before) { echo "
"; echo "
"; echo apply_filters( 'the_content', $archive_control_cpt_before ); echo "
"; echo "
"; } //if has after content }//handle page all/first options } //has after value } //is_post_type_artchive } //foreach } // is_archive } public function archive_control_loop_start( $query ){ if( $query->is_main_query() ){ $this->archive_control_top_content('automatic'); } //is_main_query } public static function archive_control_bottom_content($placement = 'function'){ if (is_archive()) { $archive_control_options = get_option('archive_control_options'); foreach($archive_control_options as $post_type => $options) { if (is_post_type_archive($post_type)) { if ($options['after'] == 'textarea' && $options['after-placement'] == $placement) { $paged = get_query_var( 'paged', 0); if($options['after-pages'] == 'all-pages' || ($options['after-pages'] == 'first' && $paged == 0)) { $archive_control_cpt_after = get_option('archive_control_' . $post_type . '_after'); if ($archive_control_cpt_after) { echo "
"; echo "
"; echo apply_filters( 'the_content', $archive_control_cpt_after ); echo "
"; echo "
"; }//if has after content } //handle page all/first options } //has after value } //is_post_type_archive } //foreach } // is_archive } public function archive_control_loop_end( $query ){ if( $query->is_main_query() ){ $this->archive_control_bottom_content('automatic'); } //is_main_query } public function archive_control_title_filter($title) { if (is_archive()) { $archive_control_options = get_option('archive_control_options'); foreach($archive_control_options as $post_type => $options) { if (is_post_type_archive($post_type)) { if ($options['title'] == 'custom') { $archive_control_cpt_title = get_option('archive_control_' . $post_type . '_title'); if ($archive_control_cpt_title) { $title = $archive_control_cpt_title; } //has title } //custom title setting if ($options['title'] == 'no-labels') { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = '' . get_the_author() . ''; } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } } //custom title set } //is_post_type_artchive } //foreach } // is_archive return $title; } } if ( ! function_exists( 'the_archive_top_content' ) ) { function the_archive_top_content() { Archive_Control::archive_control_top_content(); } } if ( ! function_exists( 'the_archive_bottom_content' ) ) { function the_archive_bottom_content() { Archive_Control::archive_control_bottom_content(); } }