Using add_filter inside another class

The reason you see the default value is that you are adding the filter after the filter has been applied, which results in the default value being used. The filter is applied when the object is constructed, which I’m assuming is before admin_init. If it’s after admin_init it won’t work either, but that’s because the … Read more

Add Archive Page Template via Plugin

WordPress has a template_include filter which you can use. // Add a filter to ‘template_include’ hook add_filter( ‘template_include’, ‘wpse_force_template’ ); function wpse_force_template( $template ) { // If the current url is an archive of any kind if( is_archive() ) { // Set this to the template file inside your plugin folder $template = WP_PLUGIN_DIR .”https://wordpress.stackexchange.com/”. … Read more

How exactly does Bad Behavior plugin work?

Bad Behavior does two things: It checks the HTTP request and sees if it is as per the standard or not. Usually spammers don’t write their scripts so well as to be fully compliant with the HTTP standard. Bad Behavior can make out poorly scripted HTTP requests from properly scripted ones (which would be sent … Read more