'. esc_html__('Upgrade To Premium', 'ads-for-wp').'', 'manage_options', 'adsforwp_data_premium', array($this, 'adsforwp_premium_interface_render') ); } } public function adsforwp_premium_interface_render(){ wp_redirect( 'https://structured-data-for-wp.com/pricing/' ); exit; } public function adsforwp_admin_analytics_interface_render(){ // Authentication if ( ! current_user_can( 'manage_options' ) ) { return; } $all_ads_post = adsforwp_get_ad_ids(); $total_ads_impression = 0; $total_ads_clicks = 0; if($all_ads_post){ foreach($all_ads_post as $ad_id){ $ad_impression_count = get_post_meta($ad_id, $key='ad_impression_count', true ); $ad_clicks_count = get_post_meta($ad_id, $key='ad_clicks', true ); $total_ads_impression = ((int)$total_ads_impression+ (int)$ad_impression_count); $total_ads_clicks = ((int)$total_ads_clicks+(int)$ad_clicks_count); } } $tab = adsforwp_get_tab('all', array('mobile','desktop', 'amp', 'tablets')); $start_date_val = strtotime( 'now' );//strtotime( '-1 month' ); $end_date_val = strtotime( 'now' ); $start_date = date( 'Y-m-d', $start_date_val ); $end_date = date( 'Y-m-d', $end_date_val ); $_differ = 'today'; if(isset($_REQUEST['view_data'])){ if ( ! isset( $_GET['adsforwp_analytics_report_nonce'] ) ){ return; } if ( !wp_verify_nonce( $_GET['adsforwp_analytics_report_nonce'], 'adsforwp_analytics_report_data' ) ){ return; } $_differ = $_REQUEST['view_data']; } $ad_id_param = null; if(isset($_REQUEST['ad_id'])){ $ad_id_param = $_REQUEST['ad_id']; } if ( $_differ ) { if ( $_differ == 'last_7_days' ) { $start_date = date( 'Y-m-d', strtotime( '-7 days' ) ); }elseif ( $_differ == 'last_14_days' ) { $start_date = date( 'Y-m-d', strtotime( '-14 days' ) ); }elseif ( $_differ == 'last_30_days' ) { $start_date = date( 'Y-m-d', strtotime( '-1 month' ) ); }elseif ( $_differ == 'this_month' ) { $start_date = date('Y-m-01') ; }elseif ( $_differ == 'last_month' ) { $start_date = date('Y-m-01', strtotime('-1 month') ); $end_date = date('Y-m-t', strtotime('-1 month') ); }elseif ( $_differ == 'last_3_months' ) { $start_date = date('Y-m-01', strtotime('-3 month') ); $end_date = date('Y-m-t', strtotime('-1 month') ); }elseif ( $_differ == 'last_6_months' ) { $start_date = date('Y-m-01', strtotime('-6 month') ); $end_date = date('Y-m-t', strtotime('-1 month') ); }elseif ( $_differ == 'last_year' ) { $start_date = date('Y-m-01', strtotime('-1 year') ); $end_date = date('Y-m-t', strtotime('-1 month') ); } } $date1 = date_create( $start_date ); $date2 = date_create( $end_date ); $diff = date_diff( $date2, $date1 ); $compare_start_date = strtotime( $start_date . $diff->format( '%R%a days' ) ); $compare_start_date = date( 'Y-m-d', $compare_start_date ); $compare_end_date = $start_date; $settingOpt = get_option('adsforwp_analytics'); $dashboard_profile_ID = $settingOpt['profile_for_dashboard']; if($dashboard_profile_ID!=''){ $allinfo = adsforwp_show_default_overall_dashboard($dashboard_profile_ID,$start_date,$end_date, $compare_start_date, $compare_end_date); } //ADS Click & impressions $overallStats = array(); $datediff = strtotime($end_date) - strtotime($start_date); $date_different = round($datediff / (60 * 60 * 24)); if($date_different == 0){ $overallStats = adsforwp_get_ad_stats('fetchAllBy', $ad_id_param ,strtotime(date('y-m-d'))); }else{ $periods = new DatePeriod( new DateTime($start_date), new DateInterval('P1D'), new DateTime($end_date) ); foreach ($periods as $key => $value) { $optionDetails = adsforwp_get_ad_stats('fetchAllBy', $ad_id_param ,strtotime($value->format('Y-m-d'))); if($optionDetails){ foreach ($optionDetails as $key => $value) { if(isset($overallStats[$key]['impression'])){ $overallStats[$key]['impression'] = $value['impression']; }else{ @$overallStats[$key]['impression'] += $value['impression']; } if(isset($overallStats[$key]['click'])){ $overallStats[$key]['click'] += $value['click']; }else{ @$overallStats[$key]['click'] += $value['click']; } }//Device foreach closed }//If closed }//Foreach closed } //ALL $allDeviceAds = array("impression" => 0, "click"=>0); if($overallStats){ foreach ($overallStats as $key => $value) { $allDeviceAds['click'] += $value['click']; $allDeviceAds['impression'] += $value['impression']; } } $overallStats['all'] = $allDeviceAds; ?>