slaFFik
6/13/2014 - 1:54 PM

Fix for BuddyPress and NextGen Gallery

Fix for BuddyPress and NextGen Gallery

<?php
function ovi_kill_anonymous_hooks(){
    ovi_remove_anonymous_object_filter(
        'wp_footer',
        'C_Photocrati_Resource_Manager',
        'print_marker'
    );
}
add_action('wp_footer', 'ovi_kill_anonymous_hooks', -2);

/**
 * Remove an anonymous object filter.
 *
 * @param  string $tag    Hook name.
 * @param  string $class  Class name
 * @param  string $method Method name
 * @return void
 */
function ovi_remove_anonymous_object_filter( $tag, $class, $method ) {
    $filters = $GLOBALS['wp_filter'][ $tag ];

    if ( empty ( $filters ) ) {
        return;
    }

    foreach ( $filters as $priority => $filter ) {
        foreach ( $filter as $identifier => $function ) {
            if ( is_array( $function)
                and is_a( $function['function'][0], $class )
                and $method === $function['function'][1]
            ) {
                remove_filter(
                    $tag,
                    array ( $function['function'][0], $method ),
                    $priority
                );
                 remove_action(
                    $tag,
                    array ( $function['function'][0], $method ),
                    $priority
                );
            }
        }
    }
}

define('NGG_DISABLE_RESOURCE_MANAGER', true);