Remove action from plugin

时间:2018-09-15 作者:Garrosh

我正在尝试删除中的操作edit_user_profile 来自插件。但我不知道怎么做,这是插件中的add\\u操作:https://github.com/jaredatch/Basic-User-Avatars/blob/master/init.php

/**
 * Initialize all the things
 *
 * @since 1.0.0
 */
public function __construct() {
    // Text domain
    $this->load_textdomain();
    // Actions
    add_action( \'admin_init\',                array( $this, \'admin_init\'               )        );
    add_action( \'show_user_profile\',         array( $this, \'edit_user_profile\'        )        );
    add_action( \'edit_user_profile\',         array( $this, \'edit_user_profile\'        )        );
    add_action( \'personal_options_update\',   array( $this, \'edit_user_profile_update\' )        );
    add_action( \'edit_user_profile_update\',  array( $this, \'edit_user_profile_update\' )        );
    add_action( \'bbp_user_edit_after_about\', array( $this, \'bbpress_user_profile\'     )        );
    // Shortcode
    add_shortcode( \'basic-user-avatars\',     array( $this, \'shortcode\'                )        );
    // Filters
    add_filter( \'get_avatar\',                array( $this, \'get_avatar\'               ), 10, 5 );
    add_filter( \'avatar_defaults\',           array( $this, \'avatar_defaults\'          )        );
}
/**
 * Loads the plugin language files.
 *
 * @since 1.0.1
 */
public function load_textdomain() {
    $domain = \'basic-user-avatars\';
    $locale = apply_filters( \'plugin_locale\', get_locale(), $domain );
    load_textdomain( $domain, WP_LANG_DIR . \'/\' . $domain . \'/\' . $domain . \'-\' . $locale . \'.mo\' );
    load_plugin_textdomain( $domain, false, dirname( plugin_basename( __FILE__ ) ) . \'/languages/\' );
}
谢谢:)

1 个回复
SO网友:Hans

您可以尝试:

add_action( \'plugins_loaded\', function() {
    global $basic_user_avatars;
    remove_action( \'edit_user_profile\', array( &$basic_user_avatars, \'edit_user_profile\' ) );
});
您需要确保在初始化另一个插件后执行此操作,因此plugins_loaded 行动

结束