Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #19910, comment 24

03/21/2012 07:45:36 PM (6 years ago)


  • Ticket #19910, comment 24

    initial v1  
    1 This may be more observation and be a result of coder error but I found the following to cause the Customization > Navigation to not produce the results you would expect:
    2 {{{
    3 if ( ! function_exists( 'register_my_menu' ) ) {
    4     function register_my_menu() {
    5             register_nav_menu( 'top-menu', __( 'Top Menu', 'my-textdomain' ) );
    6     }
    7 }
    8 add_action( 'init', 'register_my_menu' );
    9 }}}
    10 This will produce the expected menu drop down(s) under Appearance > Menu but in the Customization > Navigation it returns there are "0" menus.
     1Replying to [comment:23 nacin]:
     2> It's not being executed, only defined, and it is quite small.
    12 Simply replacing the above with the following will produce the correct expected output:
    13 {{{ register_nav_menu( 'top-menu', __( 'Top Menu', 'my-textdomain' ) ); }}}
     4Right. It just adds a tiny bit of memory on every hit to the front-end and a tiny bit on every `function_exists()` call. There already are quite a few functions in wp-includes that are defined but cannot be used, was only hoping we won't be adding more.
    15 To note (if relevant) this is wrapped in:
    16 {{{ add_action( 'after_setup_theme', 'my_theme_setup' ); }}}
     6> Probably because the handlers for Plupload is not exactly a well-formed API.
    18 Also, the above examples are taken from the code used in my current themes' menu structure.
     8Plupload is a relatively "young" JS library and the APIs are changing quite a bit from release to release. Proxying the settings seems less desirable than simply including the settings object as outputted from wp_plupload_default_settings() and letting plugins add the hook names/IDs for their HTML.
     10Also the current integration for the "main" uploader is mostly hard-coded. Was hoping to move it to the new API but that can wait for 3.5 :)