* @copyright (c) 2013, OnePress Ltd * * @package core * @since 1.0.0 */ /** * The page Basic Settings. * * @since 1.0.0 */ class OPanda_StatsSettings extends OPanda_Settings { public $id = 'stats'; /** * Sets notices. * * @since 1.0.0 * @return void */ public function init() { if ( isset( $_GET['onp_table_cleared'] )) { $this->success = __('The data has been successfully cleared.', 'bizpanda'); } } /** * Shows the header html of the settings screen. * * @since 1.0.0 * @return void */ public function header() { ?>

'separator' ); $options[] = array( 'type' => 'checkbox', 'way' => 'buttons', 'name' => 'google_analytics', 'title' => __( 'Google Analytics', 'bizpanda' ), 'hint' => __( 'If set On, the plugin will generate events for the Google Analytics when the content is unlocked.
Note: before enabling this feature, please make sure that your website contains the Google Analytics tracker code.', 'bizpanda' ) ); $options[] = array( 'type' => 'html', 'html' => array($this, 'statsHtml') ); $options[] = array( 'type' => 'checkbox', 'way' => 'buttons', 'name' => 'tracking', 'title' => __( 'Collecting Stats', 'bizpanda' ), 'hint' => __( 'Turns on collecting the statistical data for reports.', 'bizpanda' ) ); $options[] = array( 'type' => 'separator' ); return $options; } /** * Render the html block on how much the statistics data takes places. * * @sinve 1.0.0 * @return void */ public function statsHtml() { global $wpdb; $dataSizeInBytes = $wpdb->get_var( "SELECT round(data_length + index_length) as 'size_in_bytes' FROM information_schema.TABLES WHERE " . "table_schema = '" . DB_NAME . "' AND table_name = '{$wpdb->prefix}opanda_stats_v2'"); $count = $wpdb->get_var("SELECT COUNT(*) AS n FROM {$wpdb->prefix}opanda_stats_v2"); $humanDataSize = factory_325_get_human_filesize( $dataSizeInBytes ); ?>

empty.', 'bizpanda' ), $humanDataSize ); ?> %s on your server', 'bizpanda' ), $humanDataSize ); ?>

confirm(array( 'title' => __('Are you sure that you want to clear the current statistical data?', 'bizpanda'), 'description' => __('All the statistical data will be removed.', 'bizpanda'), 'actions' => array( 'onp_confirm' => array( 'class' => 'btn btn-danger', 'title' => __("Yes, I'm sure", 'bizpanda'), 'url' => $this->getActionUrl('clearStatsData', array( 'onp_confirmed' => true )) ), 'onp_cancel' => array( 'class' => 'btn btn-default', 'title' => __("No, return back", 'bizpanda'), 'url' => $this->getActionUrl('index') ), ) )); } global $wpdb; $wpdb->query("DELETE FROM {$wpdb->prefix}opanda_stats_v2"); $lockers = get_posts(array( 'post_type' => OPANDA_POST_TYPE )); foreach( $lockers as $locker ) { delete_post_meta($locker->ID, 'opanda_imperessions'); delete_post_meta($locker->ID, 'opanda_unlocks'); } return $this->redirectToAction('index', array('onp_table_cleared' => true)); } /** * Shows the html block with a confirmation dialog. * * @sinve 1.0.0 * @return void */ public function confirm( $data ) { ?>