Last active
January 25, 2016 07:17
-
-
Save anhskohbo/7034b734c67fc89f2bcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allow Visual Composer update via TGM. | |
*/ | |
function _allow_vc_update_via_tgm() { | |
global $pagenow; | |
if ( 'themes.php' === $pagenow && isset( $_GET['page'] ) && 'tgmpa-install-plugins' === $_GET['page'] ) { | |
wp_rm_filter( 'upgrader_pre_download', array( 'Vc_Updater', 'preUpgradeFilter' ) ); | |
} | |
} | |
add_action( 'admin_init', '_allow_vc_update_via_tgm' ); | |
if ( ! function_exists( 'wp_rm_filter' ) ) : | |
/** | |
* Removes a function from a specified filter hook. | |
* | |
* @param string $tag The filter hook to which the function to be removed is hooked. | |
* @param callable $remove The name of the function which should be removed. | |
* @param int $priority Optional. The priority of the function. Default 10. | |
* @return bool | |
*/ | |
function wp_rm_filter( $tag, $remove, $priority = 10 ) { | |
global $wp_filter; | |
if ( ! is_array( $remove ) ) { | |
return remove_filter( $tag, $remove, $priority ); | |
} | |
// Extract class and method name. | |
list( $class, $method ) = $remove; | |
if ( isset( $wp_filter[ $tag ][ $priority ] ) ) { | |
$k =& $wp_filter[ $tag ][ $priority ]; | |
foreach ( $k as $id => $filter ) { | |
if ( isset( $filter['function'] ) && is_array( $filter['function'] ) ) { | |
if ( is_a( $filter['function'][0], $class ) && $method === $filter['function'][1] ) { | |
unset( $k[ $id ] ); | |
return true; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment