• Heya!

    A few years back, you helped me put together this simple plugin we can activate on some sites in our network to disable More Privacy Options for the site.

    With the latest update, the plugin no longer works. It looks like it’s because it simply creates a “new DS_More_Privacy_Options” without assigning it to a variable. Here’s our current little plugin:

    global $ds_more_privacy_options;
    remove_action('template_redirect', array(&$ds_more_privacy_options, 'ds_users_authenticator'));
    
    remove_filter( 'login_url', 'ds_my_login_page_redirect' );

    I’m wondering if you you can see an easy way to restore this plugin’s functionality without changing More Privacy Options at all, or have any other suggestions.

    Cheers!

Viewing 1 replies (of 1 total)
  • Plugin Author David Sader

    (@dsader)

    Sorry about that. Here is another method for removing filters/actions from WordPress plugins in external classes.

    https://wordpress.stackexchange.com/questions/36013/remove-action-or-remove-filter-with-external-classes

    function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ){
    	global $wp_filter;
    	
    	// Check for filter and specific priority (default 10)
    	if( ! isset( $wp_filter[ $tag ][ $priority ] ) || ! is_array( $wp_filter[ $tag ][ $priority ] ) ) return FALSE;
    	
    	// Check each filter with specified priority
    	foreach( (array) $wp_filter[ $tag ][ $priority ] as $filter_id => $filter ) {
    		
    		// Filter should always be an array - array( $this, 'method' ), if not goto next
    		if( ! isset( $filter['function'] ) || ! is_array( $filter['function'] ) ) continue;
    		
    		// If first value in array is not an object, it can't be a class
    		if( ! is_object( $filter['function'][0] ) ) continue;
    		
    		// If class name does not match the class we're looking for, goto next
    		if( get_class( $filter['function'][0] ) !== $class_name ) continue;
    		
    		// Yay we found our filter
    		if( $filter['function'][1] === $method_name ) {
    			
    			// Now let's remove it from the array
    			unset( $wp_filter[ $tag ][ $priority ][ $filter_id ] );
    			
    			// and if it was the only filter in that priority, unset that priority
    			if( empty($wp_filter[ $tag ][ $priority ]) ) unset($wp_filter[ $tag ][ $priority ]);
    			
    			// and if the only filter for that tag, set the tag to an empty array
    			if( empty($wp_filter[ $tag ]) ) $wp_filter[ $tag ] = array();
    			
    			// Remove this filter from merged_filters (specifies if filters have been sorted)
    			unset($GLOBALS['merged_filters'][ $tag ]);
    			
    			return TRUE;
    		}
    	}
    	return FALSE;
    }
    
    add_action('plugins_loaded','ds_more_privacy_options_deactivate',10);
    	function ds_more_privacy_options_deactivate() {
    		remove_class_filter( 'template_redirect', 'DS_More_Privacy_Options', 'ds_users_authenticator', 10 );
    	}
    
    • This reply was modified 8 years, 5 months ago by David Sader.
Viewing 1 replies (of 1 total)
  • The topic ‘Small Plugin to Override on a Single Site’ is closed to new replies.