1

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

我找到了有关如何更改标准 WordPress“设置特色图像”元框文本的教程,但没有关于如何删除 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 。

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

非常感谢任何帮助或建议!谢谢你。

4

1 回答 1

1

如果您没有/不需要为特色图像元框定制任何内容,您可以简单地删除所有过滤器:

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' );
于 2014-07-24T21:53:18.620 回答