Plugin Directory

Changeset 851163


Ignore:
Timestamp:
02/04/2014 10:37:40 AM (12 years ago)
Author:
dharmapoudel
Message:

custom post type support added

Location:
page-specific-menu-items
Files:
2 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • page-specific-menu-items/trunk/page-specific-menu-items.php

    r850425 r851163  
    44 * Plugin URI: http://www.wordpress.org/plugins
    55 * Description: This plugin allows you to select menu items page wise.
    6  * Version: 1.3.2
     6 * Version: 1.4
    77 * Author: Dharma Poudel (@rogercomred)
    88 * Author URI: https://www.twitter.com/rogercomred
    9  * Text Domain: psmi-menu-items
     9 * Text Domain: page-specific-menu-items
    1010 * Domain Path: /l10n
    1111 */
    1212 
    1313//define some constants
    14 if (!defined('PSMI_TEXTDOMAIN'))    define('PSMI_TEXTDOMAIN', 'psmi-menu-items');
     14if (!defined('PSMI_TEXTDOMAIN'))    define('PSMI_TEXTDOMAIN', 'page-specific-menu-items');
    1515 
    1616if(!class_exists('Page_Specific_Menu_Items')) {
     
    4848                add_action( 'admin_init', array( $this, 'psmi_init' ));
    4949                add_action( 'admin_init', array( $this, 'psmi_page_init' ));
    50                 add_action( 'admin_init', array( $this, 'psmi_add_meta_box' ));
     50                add_action( 'add_meta_boxes', array( $this, 'psmi_add_meta_box' ));
    5151                add_action( 'admin_menu', array( $this, 'psmi_add_page' ) );
    5252                add_action( 'save_post', array( $this, 'psmi_save_menuitems') );
     
    6767        **/
    6868        public static function psmi_install() {
    69             // do nothing
     69            // do nothing for now
    7070        }
    7171
     
    7676        **/
    7777        public static function psmi_uninstall() {
    78             delete_option('psmi_defaults');
     78            // do nothing for now
     79            //delete_option('psmi_defaults');
    7980        }
    8081
     
    165166            add_settings_field(
    166167                'psmi-posttype-checkbox', // ID
    167                 ' ', // Title
     168                __('Select Post Type', PSMI_TEXTDOMAIN), // Title
    168169                array( $this, 'psmi_posttype_checkbox_cb' ), // Callback
    169170                'psmi-setting-admin', // Page
     
    177178        **/
    178179        public function psmi_posttype_checkbox_cb() {
    179             if($this->psmi_defaults['post_type'] ){
    180                 foreach($this->psmi_defaults['post_type'] as $post_types)
    181                     echo "<input type='hidden' name='psmi_defaults[post_type][]' value='$post_types' />";
    182             }
     180            $args = array( 'public'   => true,  '_builtin' => false );
     181            $custom_post_types = array_merge(array('post', 'page'), array_values(get_post_types($args, 'names')));
     182            echo '<ul>';
     183            foreach($custom_post_types as $cpt => $name){
     184                $checked = (!empty($this->psmi_defaults['post_type']) && $this->psmi_defaults['post_type'][0]!='' && in_array($name, $this->psmi_defaults['post_type'])) ? 'checked="checked"' :  '';
     185               
     186                echo '<li><input type="checkbox" style="margin:1px 5px 0;" '.$checked.' name="psmi_defaults[post_type][]" value="'.$name.'" />'. $name .'</li>';
     187            }
     188            echo '</ul>';
    183189        }
    184190
     
    189195        **/
    190196        public function psmi_print_section_text() {
    191             echo __('Select which menu you want to use :', PSMI_TEXTDOMAIN);
     197            //echo __('Select which menu you want to use :', PSMI_TEXTDOMAIN);
    192198        }
    193199       
     
    200206            $all_menus = wp_get_nav_menus();
    201207            if($all_menus){
    202                 echo "<select id='psmi_select_menu' name='psmi_defaults[menu_id]' >";
     208                echo "<select style='min-width:120px;' id='psmi_select_menu' name='psmi_defaults[menu_id]' >";
    203209                $selected = ('' == $this->psmi_defaults['menu_id'])? 'selected="selected"' : '' ;
    204210                echo "<option value='' {$selected} >".__('Select Menu', PSMI_TEXTDOMAIN)."</options>";
     
    248254            if ($menu_items) {
    249255           
    250                 _e("<p>Select menu items to hide in this page.</p>", PSMI_TEXTDOMAIN);
     256                _e("<p>Select menu items to hide in this page. Top level menu items are marked bold.</p>", PSMI_TEXTDOMAIN);
    251257               
    252258                $currentpage_items =get_post_meta($post->ID, PSMI_TEXTDOMAIN.'_currentpage_items', true);
  • page-specific-menu-items/trunk/readme.txt

    r850425 r851163  
    33Requires at least: 3.5
    44Tested up to: 3.8
    5 Stable tag: 1.3.2
     5Stable tag: 1.4
    66License: GPLv3
    77Contributors: dharmapoudel
     
    4242== Changelog ==
    4343
     44= 1.4 (2014-2-4) =
     45* Added support for custom post types
     46
    4447= 1.3 (2014-2-3) =
    4548* Fixed the warning on plugin install
Note: See TracChangeset for help on using the changeset viewer.