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

时间:2014-06-01 21:29:42

标签: php wordpress nextgen-gallery

我在某些画廊中使用了NextGen,并注意到自从加载此插件后,在精选图像元框下的编辑页面区域中,现在有一个指向"设置NextGEN特色图像的链接"。我不想让用户感到困惑(通过设置两个"设置特色图片和#34;链接,所以我想删除NextGEN选项,只留下一个默认WP链接来设置特色图片。

我找到了有关如何更改标准WordPress文本的教程,并设置了特色图片" 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 个答案:

答案 0 :(得分: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' );
相关问题