Plugin Directory

Changeset 1152065


Ignore:
Timestamp:
05/03/2015 05:02:46 AM (11 years ago)
Author:
silence
Message:

version 1.1 fix walker error

Location:
silencesoft-disable-menu-items
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • silencesoft-disable-menu-items/trunk/lang/sil_disable-en_EN.po

    r693417 r1152065  
    33"Project-Id-Version: Silencesoft Disable Menu Items 1.0\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2013-04-02 11:47-0500\n"
    6 "PO-Revision-Date: 2013-04-02 11:47-0500\n"
     5"POT-Creation-Date: 2015-05-02 23:04-0500\n"
     6"PO-Revision-Date: 2015-05-02 23:04-0500\n"
    77"Last-Translator: Byron H <bh@silencesoft.co>\n"
    88"Language-Team: Silencesoft <bh@silencesoft.co>\n"
    9 "Language: \n"
     9"Language: en_US\n"
    1010"MIME-Version: 1.0\n"
    1111"Content-Type: text/plain; charset=UTF-8\n"
     
    1313"X-Poedit-KeywordsList: _e;__\n"
    1414"X-Poedit-Basepath: ../\n"
    15 "X-Poedit-Language: English\n"
    16 "X-Poedit-Country: UNITED STATES\n"
    1715"X-Poedit-SourceCharset: utf-8\n"
     16"X-Generator: Poedit 1.7.5\n"
    1817"X-Poedit-SearchPath-0: .\n"
    1918
    20 #: tocka-nav-menu-walker.php:47
    21 msgid "Disable"
     19#: sil-disable-menu-items.php:76
     20msgid "Disable menu item"
    2221msgstr ""
    23 
  • silencesoft-disable-menu-items/trunk/lang/sil_disable-es_ES.po

    r693417 r1152065  
    33"Project-Id-Version: Silencesoft Disable Menu Items 1.0\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2013-04-02 11:47-0500\n"
    6 "PO-Revision-Date: 2013-04-02 11:49-0500\n"
     5"POT-Creation-Date: 2015-05-02 23:04-0500\n"
     6"PO-Revision-Date: 2015-05-02 23:04-0500\n"
    77"Last-Translator: Byron H <bh@silencesoft.co>\n"
    88"Language-Team: Silencesoft <bh@silencesoft.co>\n"
    9 "Language: \n"
     9"Language: es_ES\n"
    1010"MIME-Version: 1.0\n"
    1111"Content-Type: text/plain; charset=UTF-8\n"
     
    1313"X-Poedit-KeywordsList: _e;__\n"
    1414"X-Poedit-Basepath: ../\n"
    15 "X-Poedit-Language: Spanish\n"
    16 "X-Poedit-Country: SPAIN\n"
    1715"X-Poedit-SourceCharset: utf-8\n"
     16"X-Generator: Poedit 1.7.5\n"
    1817"X-Poedit-SearchPath-0: .\n"
    1918
    20 #: tocka-nav-menu-walker.php:47
    21 msgid "Disable"
    22 msgstr "Deshabilitar"
    23 
     19#: sil-disable-menu-items.php:76
     20msgid "Disable menu item"
     21msgstr "Deshabilitar ítem de menú"
  • silencesoft-disable-menu-items/trunk/readme.txt

    r693417 r1152065  
    22by: Byron Herrera - bh at silencesoft dot co
    33Contributors: silence
    4 Donate link: http://www.silencesoft.co/
     4Donate link: http://www.silencesoft.pw/
    55Tags: menu, disable, hide, menu items
    66Requires at least: 3.0.1
    7 Tested up to: 3.5
    8 Stable tag: 1.0
     7Tested up to: 4.1
     8Stable tag: 1.1
    99License: WTFPL
    1010License URI: http://www.wtfpl.net/txt/copying/
     
    2929In every menu item will be a new option "Disable", use it.
    3030
     31== FAQ ==
     32
     33= 1. Is this plugin compatible with another menu Walkers? =
     34
     35Wordpress has not a filter to hook custom fields on menus as explained
     36here:
     37https://wordpress.org/plugins/nav-menu-roles/faq/#conflict
     38Version 1.1 of this plugin implements the fix proposed to work with
     39another plugins.
     40
    3141== Screenshots ==
    3242
    33 1. Mofifying a menu item
     431. Modifying a menu item
    3444
    3545== Changelog ==
     
    3848* First release.
    3949
     50= 1.1 =
     51* Added support for action wp_nav_menu_item_custom_fields to fix Walker
     52Conflict.
     53
  • silencesoft-disable-menu-items/trunk/sil-disable-menu-items.php

    r701914 r1152065  
    33 * Plugin Name: Silencesoft Disable Menu Items
    44 * Description: Allow to enable/disable menu items
    5  * Version: 1.0
     5 * Version: 1.1
    66 * Plugin URI: http://silencesoft.co
    77 * Author: Byron Herrera
     
    2929 **/
    3030
     31// don't load directly
     32if ( !function_exists( 'is_admin' ) ) {
     33    header( 'Status: 403 Forbidden' );
     34    header( 'HTTP/1.1 403 Forbidden' );
     35    exit();
     36}
     37
     38
    3139if ( !class_exists( "Sil_Disable_Items_Plugin" ) ):
    3240
     
    3846     */
    3947    function __construct() {
    40         add_action( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
     48        add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ),10, 1 );
    4149        add_action( 'wp_update_nav_menu_item', array( $this, 'sil_disable_update_nav_menu_item' ), 10, 3 );
    4250        add_filter( 'wp_nav_menu_objects', array( $this, 'sil_nav_menu_items' ) );
    4351        add_action('plugins_loaded', array( $this, 'sil_plugin_init') );
     52        // fix for Walker
     53        add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'sil_custom_fields' ), 10, 4 );
    4454    }
    4555
     
    6272    }
    6373
    64    
     74    function sil_custom_fields( $item_id, $item, $depth, $args ) {
     75        $test_val = esc_attr( get_post_meta( $item_id, 'sil_disable_menu_item_test_val', TRUE ) );
     76        $test_val = ($test_val == "1")?" checked='checked'":'';
     77        print "<div class='field-disable description-wide'><input type='checkbox' ".$test_val." value='1' name='sil_disable_menu_item_test_val_".$item_id."' /><span class='description'>".__('Disable menu item', 'sil_disable')."</span></div>";
     78    }
     79
    6580    /**
    6681     * Save post meta. Menu items are just posts of type "menu_item".
     
    7691            update_post_meta( $menu_item_id, 'sil_disable_menu_item_test_val', $_POST[ "sil_disable_menu_item_test_val_$menu_item_id" ] );
    7792        } else {
    78             #mfmfmf("DEL");
    7993            delete_post_meta( $menu_item_id, 'sil_disable_menu_item_test_val' );
    8094        }
     
    88102            $dis = get_post_meta( $item->ID, 'sil_disable_menu_item_test_val' , true);
    89103            if ($dis != "1")
    90             $new_items[] = $item;
     104                $new_items[] = $item;
    91105           
    92106        }
  • silencesoft-disable-menu-items/trunk/tocka-nav-menu-walker.php

    r693417 r1152065  
    4242        $test_val = esc_attr( get_post_meta( $menu_item_id, 'sil_disable_menu_item_test_val', TRUE ) );
    4343        $test_val = ($test_val == "1")?" checked='checked'":'';
     44
     45        // fix for walker conflict
     46        ob_start();
     47        do_action( 'wp_nav_menu_item_custom_fields', $id, $item, $depth, $args );
     48        $fields = ob_get_clean();
    4449       
    4550        // by means of phpQuery magic, inject a new input field
    4651        $_li->find( '.field-link-target' )
    47             ->before(  "<p><input type='checkbox' ".$test_val." value='1' name='sil_disable_menu_item_test_val_$menu_item_id' />".__('Disable', 'sil_disable')."</p>" );
     52            ->before($fields);
     53
     54        // ->before(  "<div class='field-disable description-wide'><input type='checkbox' ".$test_val." value='1' name='sil_disable_menu_item_test_val_$menu_item_id' /><span class='description'>".__('Disable menu item', 'sil_disable')."</span></div>" )
    4855       
    4956        // swap the $output
Note: See TracChangeset for help on using the changeset viewer.