'version' ) ); define( 'BPRO_DATA_LIGHT_VERSION', $bpro_data_light_plugin_data['version'] ); define( 'BPRO_DATA_LIGHT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'BPRO_DATA_LIGHT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); unset( $bpro_data_light_plugin_data ); /** * Activation: remember the day (the starting stock is dated with it) and ask for the first, full calculation. * No table is created - BPro Light keeps its data in transients. */ function bpro_data_light_activate() { if ( ! get_option( 'bpro_data_light_activated_at' ) ) { add_option( 'bpro_data_light_activated_at', current_time( 'mysql' ), '', false ); } $state = get_option( 'bpro_data_light_state', array() ); $state = is_array( $state ) ? $state : array(); update_option( 'bpro_data_light_state', array_merge( array( 'queue' => array(), 'last_updated' => 0, 'running' => false, ), $state, array( 'full' => true, 'page' => 0, ) ), false ); if ( ! wp_next_scheduled( 'bpro_data_light_sync' ) ) { wp_schedule_single_event( time() + 15, 'bpro_data_light_sync' ); } } /** * Deactivation: stop the scheduled update. The calculated data stays (it expires on its own). */ function bpro_data_light_deactivate() { wp_clear_scheduled_hook( 'bpro_data_light_sync' ); } register_activation_hook( __FILE__, 'bpro_data_light_activate' ); register_deactivation_hook( __FILE__, 'bpro_data_light_deactivate' ); /** * Whether the plugin's compatibility notices may be shown on the current admin screen: * only to users who can manage plugins, and only on the Plugins screen, so they never * spread over the rest of the dashboard. * * @return bool */ function bpro_data_light_can_show_notice() { if ( ! current_user_can( 'activate_plugins' ) || ! function_exists( 'get_current_screen' ) ) { return false; } $screen = get_current_screen(); return $screen && 'plugins' === $screen->id; } /** * Admin notice when WooCommerce is missing. */ function bpro_data_light_missing_woocommerce_notice() { if ( ! bpro_data_light_can_show_notice() ) { return; } echo '
'; esc_html_e( 'BPro Data Light requires WooCommerce to be installed and active.', 'bpro-data-light' ); echo '
'; esc_html_e( 'BPro Data Light is paused because the full WC BPro Data plugin is active. Both add a "BPro" report to WooCommerce Analytics - deactivate one of them.', 'bpro-data-light' ); echo '