Hi,
It’s not that easy as the options assignment happens in plugin class constructor.
What you can do however is to detect the PVC activation using this: https://codex.ww.wp.xz.cn/Plugin_API/Action_Reference/activated_plugin
And update the PVC post_views_counter_settings_display option.
Regards,
Bartosz / dfactory team
Seems like a solution.
Could you please provide some more details, how to update the post_views_counter_settings_display option? It’s a serialized array, and I’m afraid to mess it up.
Thanks a lot!
It would be something like this, but you have to test it:
/**
* Hook into activated_plugin action.
*
* @param string $plugin
*/
function custom_pvc_activation_action( $plugin ) {
// check if PVC constant is defined,use it to get PVC path anc compare to activated plugin
if( defined( 'POST_VIEWS_COUNTER_PATH' ) && $plugin == plugin_basename( POST_VIEWS_COUNTER_PATH . 'post-views-counter.php' ) ) {
// get display options
$display_options = get_option( 'post_views_counter_settings_display' );
// set position value
$display_options['position'] = 'manual';
// update options
update_option( 'post_views_counter_settings_display', $display_options );
}
}
add_action( 'activated_plugin', 'custom_pvc_activation_action' );
I’ve just tested it, and it’s working fine. Thanks a lot!