' . esc_html__( 'Two copies of the useClick.io plugin are active. Deactivate and delete the older one under Plugins.', 'useclick' ) . '

'; } } ); return; } define( 'USECLICK_VERSION', '1.5.0' ); define( 'USECLICK_PLUGIN_FILE', __FILE__ ); define( 'USECLICK_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'USECLICK_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* * Endpoints. Both can be overridden in wp-config.php (for example to point at a * staging server) or with the `useclick_api_base_url` / `useclick_tracker_url` filters. * The API key can also be set in wp-config.php with define( 'USECLICK_API_KEY', 'uc_live_...' ); * then it is never stored in the database. */ if ( ! defined( 'USECLICK_API_BASE_URL' ) ) { define( 'USECLICK_API_BASE_URL', 'https://useclick.io/api/v1' ); } if ( ! defined( 'USECLICK_TRACKER_URL' ) ) { define( 'USECLICK_TRACKER_URL', 'https://useclick.io/analytics.js' ); } if ( ! defined( 'USECLICK_APP_URL' ) ) { define( 'USECLICK_APP_URL', 'https://useclick.io' ); } require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-api.php'; require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-admin.php'; require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-settings.php'; require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-analytics.php'; require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-posts.php'; require_once USECLICK_PLUGIN_DIR . 'includes/class-useclick-site-health.php'; /** * The UseClick.io API key: the USECLICK_API_KEY constant if defined, otherwise the saved option. * * @return string */ function useclick_get_api_key() { if ( defined( 'USECLICK_API_KEY' ) && '' !== (string) USECLICK_API_KEY ) { return (string) USECLICK_API_KEY; } return (string) get_option( 'useclick_api_key', '' ); } /** * A page of the plugin's guide on useclick.io (https://useclick.io/docs/wordpress-plugin). * * @param string $section Optional heading anchor, e.g. 'get-your-api-key'. * @return string */ function useclick_docs_url( $section = '' ) { return USECLICK_APP_URL . '/docs/wordpress-plugin' . ( '' !== $section ? '#' . $section : '' ); } /** * Boot the plugin. */ function useclick_bootstrap() { useclick_maybe_upgrade(); UseClick_Analytics::init(); UseClick_Posts::init(); UseClick_Site_Health::init(); if ( is_admin() ) { UseClick_Admin::init(); UseClick_Settings::init(); } } add_action( 'plugins_loaded', 'useclick_bootstrap' ); /** * One-time changes when the plugin is updated. * * 1.5.0: reporting bot visits from the server became opt-in. Sites that had it on by default * in 1.4.0 have it switched off and see a notice on the Website analytics screen. */ function useclick_maybe_upgrade() { $installed = (string) get_option( 'useclick_version', '' ); if ( USECLICK_VERSION === $installed ) { return; } if ( '' === $installed || version_compare( $installed, '1.5.0', '<' ) ) { // New installs and anything older than 1.5.0 (versions before 1.5.0 stored no version). if ( get_option( UseClick_Analytics::OPT_ENABLED, false ) && get_option( UseClick_Analytics::OPT_TRACK_BOTS, true ) ) { update_option( 'useclick_notice_bots_opt_in', true, false ); } update_option( UseClick_Analytics::OPT_TRACK_BOTS, 0 ); } UseClick_Analytics::schedule_events(); delete_transient( 'useclick_bot_tokens' ); // Replaced by an autoloaded option in 1.5.0. update_option( 'useclick_version', USECLICK_VERSION ); } /** * Activation: register options without autoloading the API key on every request. */ function useclick_activate() { add_option( 'useclick_api_key', '', '', false ); UseClick_Analytics::schedule_events(); } register_activation_hook( __FILE__, 'useclick_activate' ); /** * Deactivation: stop the scheduled jobs and send any queued bot visits. */ function useclick_deactivate() { UseClick_Analytics::flush_bot_queue(); UseClick_Analytics::unschedule_events(); } register_deactivation_hook( __FILE__, 'useclick_deactivate' );