Closed carasmo closed 7 years ago
The usage looks more or less correct. This will cause other defaults to be lost though so I'd recommend using an array_merge to merge your defaults with the existing defaults.
One thing to consider is what you are trying to achieve with this filter. What it will do is allow the default settings to be altered when you use the "reset" button. It doesn't override the settings though.
If you are trying to do that you will need to use one of the genesis option filters.
Yes, on reset, not to control the user's settings otherwise. I did the first OP and that didn't work, and now the following and that also doesn't work. It's very odd:
function foo_simple_social_share_defaults( $default_settings ) {
$args = array(
'general_size' => 'large',
'general_appearance' => 'filled',
'general_post' => 0,
'general_show_archive' => 1,
'general_position' => 'off',
);
$default_settings = array_merge( $args, $default_settings );
return $default_settings;
}
add_filter( 'genesis_simple_share_defaults', 'foo_simple_social_share_defaults' );
My best guess would be that the "apply_filters" is being added too late. I just tested this
add_filter( 'genesis_simple_share_defaults', 'my_genesis_simple_share_defaults' );
function my_genesis_simple_share_defaults( $defaults ) {
$defaults = array_merge( $defaults, array(
'general_size' => 'small',
'general_appearance' => 'filled',
'general_position' => 'before_content',
'general_post' => 1,
'googlePlus' => 0,
'facebook' => 1,
'twitter' => 0,
'pinterest' => 0,
'linkedin' => 1,
'stumbleupon' => 0,
) );
return $defaults;
}
It worked perfectly on my test site. You will need to make sure any filters are added before the genesis_init action this plugin uses.
add_action( 'genesis_init', 'genesis_simple_share_init', 99 );
Added your code (except 'tall' for general_size) to the Genesis Sample on a clean install and doesn't work. Oh well.
I'm trying to make defaults settings with the 'genesis_simple_share_defaults' filter, but it doesn't work.