/** * Load our version of FEE on a frontend Social Paper page. * * We're running this on 'pre_get_posts' since this is when we've determined * that we're on a Social Paper page. */ function cacsp_wp_fee_frontend_load() { if (false === cacsp_is_page() && false === Social_Paper::$is_new) { return; } if (!class_exists('CACSP_FEE')) { cacsp_wp_fee_load(); // do not run FEE's 'wp' routine remove_anonymous_object_filter('wp', 'FEE', 'wp'); } }
/** * Disable Inline Comments on various pages. * * Currently disabled on: * - BuddyPress pages * - Social Paper archive page */ function cacsp_ic_disable() { $disable = false; if (function_exists('is_buddypress') && true === is_buddypress() || true === cacsp_is_archive()) { $disable = true; } if (is_singular('cacsp_paper') && 'auto-draft' === get_post_status()) { $disable = true; } if (false === $disable) { return; } /** * Since IC runs their code on 'init', we have to remove each hook * individually on 'wp' ('bp_ready') using our utility function, * {@link remove_anonymous_object_filter()} to do so. * * @see initialize_incom_wp() * @see initialize_incom_comments() */ remove_anonymous_object_filter('wp_enqueue_scripts', 'INCOM_WordPress', 'incom_enqueue_scripts'); remove_anonymous_object_filter('wp_footer', 'INCOM_WordPress', 'load_incom'); remove_anonymous_object_filter('wp_enqueue_scripts', 'INCOM_WordPress', 'load_incom_style'); remove_anonymous_object_filter('wp_head', 'INCOM_WordPress', 'load_custom_css'); remove_anonymous_object_filter('wp_footer', 'INCOM_Comments', 'generateCommentsAndForm'); }
public function removeUWAnalytics() { // var_dump($GLOBALS['wp_filter']); if (!function_exists('remove_anonymous_object_filter')) { /** * Remove an anonymous object filter. * * @param string $tag Hook name. * @param string $class Class name * @param string $method Method name * @return void * http://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object */ function 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_anonymous_object_filter('wp_head', 'UW_Analytics', 'loadscript'); remove_anonymous_object_filter('wp_enqueue_scripts', 'UW_Analytics', 'script'); }