redirection icon indicating copy to clipboard operation
redirection copied to clipboard

red_default_options filter not working on new multisite websites

Open jg314 opened this issue 5 years ago • 1 comments

Summary

We have a multisite network where we'd like to start using the Redirection plugin. In order to save us some time and avoid manual mistakes, we'd love to reset the default settings through code. We attempted to do this using the red_default_options filter, but it isn't working for us.

Actual Behavior

We've added code that hooks into the red_default_options filter, but the settings we merged don't appear to be used.

Steps to reproduce

To replicate this follow these steps:

  1. Install the Redirection plugin on a multisite network and Network Activate the plugin.
  2. Add the following code into a plugin that's already been Network Activated.
/**
 * Modify the default settings for the Redirection plugin.
 *
 * @param array $defaults The default Redirection settings.
 * @return array The updated defaults with our changes.
 */
function wi_set_redirection_default_options( $defaults ) {

	$updated_defaults = array(
		'monitor_post'    => 1, // Monitor posts for changes
		'monitor_types'   => array( 'post', 'page', 'custom_post_type_1' ),
		'expire_redirect' => -1,
		'expire_404'      => -1,
		'redirect_cache'  => 168, // 1 week
		'ip_logging'      => 0,
		'last_group_id'   => 1,
		'flag_case'       => 1,
		'flag_trailing'   => 1,
	);

	$merged_defaults = array_merge( $defaults, $updated_defaults );

	return $merged_defaults;
}
add_filter( 'red_default_options', 'wi_set_redirection_default_options', 10 );
  1. Walk through the setup process on one of the subsites. The defaults provided through the filter don't appear to be used.

Environment

  • WordPress 5.2.4
  • Redirection version 4.4.2
  • Browser: Chrome version 78

Please let me know if there are any other details I can provide to be helpful here. Thanks.

jg314 avatar Oct 23 '19 14:10 jg314

Sorry for the delay in responding. I'm unable to reproduce this. Are you sure the filter is being defined before it is called? It's just a filter and there's no special handling of it in Redirection.

johngodley avatar Jul 13 '22 13:07 johngodley