WP3.4.2添加自定義欄目按鈕失效的解決方法

字號:


    很多童鞋發(fā)現(xiàn)升級到WordPress 3.4.2 版后,添加自定義欄目按鈕失效,這可能是WP所有版本中最明顯的BUG,瘋狂升級的結(jié)果。
    雖然官方對此BUG未作出響應(yīng),不過非官方的修復(fù)方法已有人給出,你可以不必等待版本升級,先使用該插件臨時解決該問題。
    插件下載地址:http://wordpress.org/extend/plugins/hotfix/
    上傳空間插件目錄并啟用即可。
    或者將下面代碼添加到主題的functions模版中
    <?php
    /*
    Plugin Name: Fix Custom Fields in WP 3.4.2
    Version: 0.1
    Plugin URI: http://core.trac.wordpress.org/ticket/21829
    Description: Implements a workaround for adding and updating custom fields in WordPress 3.4.2.
    Author: Sergey Biryukov
    Author URI: http://profiles.wordpress.org/sergeybiryukov/
    */
    function fix_custom_fields_in_wp342() {
    global $wp_version, $hook_suffix;
    if ( '3.4.2' == $wp_version && in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) : ?>
    <script type="text/javascript">
    jQuery(document).delegate( '#addmetasub, #updatemeta', 'hover focus', function() {
    jQuery(this).attr('id', 'meta-add-submit');
    });
    </script>
    <?php
    endif;
    }
    add_action( 'admin_print_footer_scripts', 'fix_custom_fields_in_wp342' );
    ?>