首页 文章

Wordpress NextGen从编辑页面删除“设置NextGEN特色图像”

提问于
浏览
1

我正在为一些画廊使用NextGen,并注意到自从加载此插件后,在精选图像元框下的编辑页面区域中,现在有一个“设置NextGEN特色图像”的链接 . 我不想混淆用户(通过两个“设置特色图像”链接,所以我想删除NextGEN选项,只留下一个默认WP链接来设置特色图像 .

我找到了关于如何更改标准WordPress "Set Featured Image" Meta Box文本的教程,但没有关于如何删除NextGEN链接的内容,(我确实找到了添加插件以删除它的帖子:http://wordpress.org/support/topic/remove-set-nextgen-featured-image

但是,我想在我的functions.php文件中删除它(不使用插件) .

我在functions.php文件中尝试了以下内容:

remove_meta_box
remove_filter
remove_action

但我不是100%肯定我需要使用(目前还没有工作) .

将此功能添加到页面编辑区域的文件是:https://github.com/mneuhaus/foo/blob/master/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/lib/post-thumbnail.php .

我意识到我只会注释掉这个产生链接的文件中的文本,但如果我更新了插件,它将被覆盖 .

任何帮助或建议都非常感谢!谢谢 .

1 回答

  • 1

    如果您没有/需要为特色图片元框自定义任何内容,您只需删除 all 过滤器:

    function so_23984689_remove_nextgen_post_thumbnail_html() {
    
        remove_all_filters( 'admin_post_thumbnail_html' );
    }
    
    add_action( 'do_meta_boxes', 'so_23984689_remove_nextgen_post_thumbnail_html' );
    

    如果您要保留任何其他过滤器,则必须遍历过滤器数组并删除相应的元素:

    function so_23984689_remove_nextgen_post_thumbnail_html() {
    
        global $wp_filter;
    
        if ( ! isset( $wp_filter[ 'admin_post_thumbnail_html' ] ) ) {
            return;
        }
    
        foreach ( $wp_filter[ 'admin_post_thumbnail_html' ] as $priority => $filters ) {
            foreach ( $filters as $id => $filter ) {
                if (
                    isset( $filter[ 'function' ] )
                    && is_object( $filter[ 'function' ][ 0 ] )
                    && $filter[ 'function' ][ 0 ] instanceof nggPostThumbnail
                ) {
                    unset( $wp_filter[ 'admin_post_thumbnail_html' ][ $priority ][ $id ] );
                }
            }
        }
    }
    
    add_action( 'do_meta_boxes', 'so_23984689_remove_nextgen_post_thumbnail_html' );
    

相关问题