*/ class Advanced_Page_Visit_Counter_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name ; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version ; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Advanced_Page_Visit_Counter_Loader as all of the hooks are defined * in that particular class. * * The Advanced_Page_Visit_Counter_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ if ( isset( $_GET['page'] ) && $_GET['page'] === APVC_DASHBOARD_PAGE_SLUG ) { /* Core CSS */ wp_enqueue_style( APVC_ASSETS_PREFIX . 'core', plugin_dir_url( __FILE__ ) . 'assets/vendor/css/core.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'default', plugin_dir_url( __FILE__ ) . 'assets/vendor/css/rtl/theme-default.css', array(), $this->version, 'all' ); /* Icons. Uncomment required icon fonts */ wp_enqueue_style( APVC_ASSETS_PREFIX . 'boxicons', plugin_dir_url( __FILE__ ) . 'assets/vendor/fonts/boxicons.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'fontawesome', plugin_dir_url( __FILE__ ) . 'assets/vendor/fonts/fontawesome.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'sweetalert2', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/sweetalert2/sweetalert2.css', array(), $this->version, 'all' ); if ( APVC_Admin_Helpers::check_section( 'apvc-settings' ) || APVC_Admin_Helpers::check_section( 'apvc-shortcode-generator' ) || APVC_Admin_Helpers::check_section( 'apvc-export-wizard' ) ) { /* Vendors CSS */ wp_enqueue_style( APVC_ASSETS_PREFIX . 'typeahead', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/typeahead-js/typeahead.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'tagify', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/tagify/tagify.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'pickr', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/pickr/pickr-themes.css', array(), $this->version, 'all' ); wp_enqueue_style( APVC_ASSETS_PREFIX . 'select2', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/select2/select2.css', array(), $this->version, 'all' ); } wp_enqueue_style( APVC_ASSETS_PREFIX . 'bootstrap-daterangepicker', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'assets/css/advanced-page-visit-counter-admin.css', array(), $this->version, 'all' ); } } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Advanced_Page_Visit_Counter_Loader as all of the hooks are defined * in that particular class. * * The Advanced_Page_Visit_Counter_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ if ( isset( $_GET['page'] ) && $_GET['page'] === APVC_DASHBOARD_PAGE_SLUG ) { wp_enqueue_script( 'jquery' ); /* Helpers */ // wp_enqueue_script( APVC_ASSETS_PREFIX . 'helpers', plugin_dir_url( __FILE__ ) . 'assets/vendor/js/helpers.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'config', plugin_dir_url( __FILE__ ) . 'assets/js/config.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'popper', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/popper/popper.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'bootstrap', plugin_dir_url( __FILE__ ) . 'assets/vendor/js/bootstrap.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'hammer', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/hammer/hammer.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'typeahead', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/typeahead-js/typeahead.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'chartjs', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/chartjs/chartjs.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'sweetalert2', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/sweetalert2/sweetalert2.js', array( 'jquery' ), $this->version, true ); if ( APVC_Admin_Helpers::check_section( 'apvc-settings' ) || APVC_Admin_Helpers::check_section( 'apvc-shortcode-generator' ) || APVC_Admin_Helpers::check_section( 'apvc-export-wizard' ) ) { wp_enqueue_script( APVC_ASSETS_PREFIX . 'select2', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/select2/select2.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'tagify', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/tagify/tagify.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'pickr', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/pickr/pickr.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'apvc-pickr', plugin_dir_url( __FILE__ ) . 'assets/js/apvc-color-picker.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'apvc-settings', plugin_dir_url( __FILE__ ) . 'assets/js/apvc-settings.js', array( 'jquery' ), $this->version, true ); } wp_enqueue_script( APVC_ASSETS_PREFIX . 'moment', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/moment/moment.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( APVC_ASSETS_PREFIX . 'bootstrap-daterangepicker', plugin_dir_url( __FILE__ ) . 'assets/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js', array( 'jquery' ), $this->version, true ); wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'assets/js/advanced-page-visit-counter-admin.js', array( 'jquery' ), $this->version, true ); $localised_vars = array( 'apvcWPnonce' => wp_create_nonce( 'apvc_nonce' ), 'dashboard_rest_url' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/dashboard_stats', 'get_reports_stats_with_range' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/get_reports_stats_with_range', 'reports_page_rest_url' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/reports_stats', 'reports_det_page_rest_url' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/reports_det_stats', 'refer_refresh_url' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/refer_refresh_url', 'generate_shortcode' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/generate_shortcode', 'save_shortcode' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/save_shortcode', 'delete_shortcode' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/delete_shortcode', 'get_starting_count' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/get_starting_count', 'set_starting_count' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/set_starting_count', 'reset_everything' => get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/reset_everything', 'view_more_data' => __( 'View more details', 'apvc' ), 'dashboard_link' => APVC_DASHBOARD_PAGE_LINK, 'lb_visitors' => __( 'Visitors', 'apvc' ), 'lb_views' => __( 'Views', 'apvc' ), 'lb_sessions' => __( 'User Sessions', 'apvc' ), 'lb_city' => __( 'City:', 'apvc' ), 'lb_state' => __( 'State:', 'apvc' ), 'lb_country' => __( 'Country:', 'apvc' ), 'sh_saved' => __( 'Shortcode saved successfully.', 'apvc' ), 'set_starting_count_str' => __( 'Set Starting Count.', 'apvc' ), 'reset_delete_warning_title' => __( 'Delete all data?', 'apvc' ), 'reset_delete_warning_text' => __( 'You are about to delete all stats associated with Advanced Page Visit Counter. This includes all views, referrers, users, and user sessions.', 'apvc' ), 'reset_delete_warning_conf_text' => __( 'Yes, delete all data!', 'apvc' ), 'reset_delete_success_title' => __( 'Deleted!', 'apvc' ), 'reset_delete_success_text' => __( 'Your all data(This includes all views, referrers, users, and user sessions) has been deleted.', 'apvc' ), ); if ( APVC_Helper_Functions::apvc_is_pro() ) { $localised_vars['str_thirty_min_chart'] = array( __( 'now', 'apvc' ), __( '-1 min', 'apvc' ), __( '-2 min', 'apvc' ), __( '-3 min', 'apvc' ), __( '-4 min', 'apvc' ), __( '-5 min', 'apvc' ), __( '-6 min', 'apvc' ), __( '-7 min', 'apvc' ), __( '-8 min', 'apvc' ), __( '-9 min', 'apvc' ), __( '-10 min', 'apvc' ), __( '-11 min', 'apvc' ), __( '-12 min', 'apvc' ), __( '-13 min', 'apvc' ), __( '-14 min', 'apvc' ), __( '-15 min', 'apvc' ), __( '-16 min', 'apvc' ), __( '-17 min', 'apvc' ), __( '-18 min', 'apvc' ), __( '-19 min', 'apvc' ), __( '-20 min', 'apvc' ), __( '-21 min', 'apvc' ), __( '-22 min', 'apvc' ), __( '-23 min', 'apvc' ), __( '-24 min', 'apvc' ), __( '-25 min', 'apvc' ), __( '-26 min', 'apvc' ), __( '-27 min', 'apvc' ), __( '-28 min', 'apvc' ), __( '-29 min', 'apvc' ) ); $localised_vars['str_no_views_five_mins'] = __( 'No page views in last 5 minutes.', 'apvc' ); $localised_vars['get_realtime_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/realtime_stats_refresh'; $localised_vars['get_thirty_minutes_states'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/thirty_minutes_states_refresh'; $localised_vars['get_realtime_pages_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/realtime_pages_list_stats'; $localised_vars['get_realtime_referrer_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/realtime_referrer_list_stats'; $localised_vars['get_realtime_countries_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/realtime_countries_list_stats'; $localised_vars['get_realtime_campaigns_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/realtime_campaigns_list_stats'; $localised_vars['create_campaign'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/create_campaign'; $localised_vars['delete_campaign'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/delete_campaign'; $localised_vars['refresh_wc_stats'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/refresh_wc_stats'; $localised_vars['export_create'] = get_rest_url() . 'apvc/' . APVC_REST_VERSION . '/export_create'; } wp_localize_script( $this->plugin_name, 'APVC_ADMIN', $localised_vars ); wp_localize_script( APVC_ASSETS_PREFIX . 'premium', 'APVC_ADMIN_PRE', $localised_vars ); } } public function apvc_download_geo_files() { $geo_database = new APVC_Geo_Database(); $geo_database->maybe_dispatch_download_job(); } public function apvc_filter_connect_message_on_update( $message, $user_first_name, $product_title, $user_login, $site_link, $freemius_link ) { // Add the heading HTML. $plugin_name = 'Advanced Page Visit Counter'; $title = '

' . \sprintf( \esc_html__( 'We hope you love %1$s', 'apvc' ), $plugin_name ) . '

'; $html = ''; // Add the introduction HTML. $html .= '

'; $html .= \sprintf( \esc_html__( 'Hi, %1$s! This is an invitation to help the %2$s community.', 'apvc' ), $user_first_name, $plugin_name ); $html .= ''; $html .= \sprintf( \esc_html__( 'If you opt-in, some data about your usage of %2$s will be shared with us', 'apvc' ), $user_first_name, $plugin_name ); $html .= ''; $html .= \sprintf( \esc_html__( ' so we can improve %2$s. We will also share some helpful info on using the plugin so you can get the most out of your sites analytics.', 'apvc' ), $user_first_name, $plugin_name ); $html .= '

'; $html .= '

'; $html .= \sprintf( \esc_html__( 'And if you skip this, that\'s okay! %1$s will still work just fine.', 'apvc' ), $plugin_name ); $html .= '

'; return $title . $html; } public function plugin_action_links( $plugin_links ) { $settings_link = '' . \esc_html__( 'Dashboard', 'apvc' ) . ''; // Add the link to the start of the array \array_unshift( $plugin_links, $settings_link ); return $plugin_links; } }