query($wpdb->prepare("UPDATE {$wpdb->prefix}ad_buttons SET ad_active = 0 WHERE id = %d",$ad_button)); } elseif($ad_button_action == 'activate' && wp_verify_nonce( $_GET['_abnonce'], 'activate' )) { $ol_flash = "Ad Button $ad_button has been activated."; $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}ad_buttons SET ad_active = 1 WHERE id = %d",$ad_button)); } elseif($ad_button_action == 'delete' && wp_verify_nonce( $_GET['_abnonce'], 'delete' )) { $ol_flash = "Ad Button $ad_button has been deleted."; $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}ad_buttons SET ad_active = 2 WHERE id = %d",$ad_button)); } elseif($ad_button_action == 'edit' && wp_verify_nonce( $_GET['_abnonce'], 'edit' )) { $ab_formfunc= 'edit'; $this_ad = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}ad_buttons WHERE id = %d",$ad_button)); $ab_img = $this_ad->ad_picture; $ab_link = $this_ad->ad_link; $ab_txt = $this_ad->ad_text; $ab_views = $this_ad->ad_views; $ab_clicks = $this_ad->ad_clicks; $ab_pos = $this_ad->ad_pos; $ab_adbut = $this_ad->id; } else { print 'Sorry, your nonce did not verify.'; exit; } } } } $widget_adbuttons_cfg = get_option('widget_adbuttons_cfg'); // check if the form has been submitted and validate input if( $_SERVER['REQUEST_METHOD'] == 'POST' && current_user_can( 'manage_options' )){ if ( ! isset( $_POST['_abupd'] ) || ! wp_verify_nonce( $_POST['_abupd'], 'update-ad' )) { print 'Sorry, your nonce did not verify.'; exit; } else { // process form data if(!empty($_POST['ab_img']) || !empty($_POST['ab_link']) || !empty($_POST['ab_txt'])) { if (!empty($_POST['ab_img'])) { $ab_img = $htp.str_replace($htps, "", str_replace($htp, "", esc_url($_POST['ab_img']))); } if (!empty($_POST['ab_link'])) { if(substr($_POST['ab_link'], 0, 7) == $htp){ $ab_link = esc_url($_POST['ab_link']); }elseif(substr($_POST['ab_link'], 0, 8) == $htps){ $ab_link = esc_url($_POST['ab_link']); }else{ $ab_link = esc_url($htp.$_POST['ab_link']); } } if (!empty($_POST['ab_adbut'])) { $ad_button = intval( $_POST['ab_adbut'] ); } if (!empty($_POST['ab_txt'])) { $ab_txt = sanitize_text_field( $_POST['ab_txt'] ); } if (!empty($_POST['ab_formfunc'])) { $ab_formfunc = sanitize_text_field( $_POST['ab_formfunc'] ); } if (!empty($_POST['ab_views'])) { $ab_views = intval( $_POST['ab_views'] ); } if (!empty($_POST['ab_clicks'])) { $ab_clicks = intval( $_POST['ab_clicks'] ); } if (!empty($_POST['ab_pos'])) { $ab_pos = intval( $_POST['ab_pos'] ); } if($ab_img == $htp || $ab_img == ''){ $ab_img_err = 'Please fill in the link to your image file'; } if($ab_link == $htp || $ab_link == ''){ $ab_link_err = 'Please fill in the target link for your ad'; } if($ab_img_err == '' && $ab_link_err == ''){ // everything looks good, lets write to the database if($ab_formfunc=='add'){ $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}ad_buttons (ad_picture, ad_link, ad_text, ad_active, ad_views, ad_clicks, ad_pos) VALUES ( %s, %s, %s, 0, %d, %d, %d )", $ab_img, $ab_link, $ab_txt, $ab_views, $ab_clicks, $ab_pos)); $ol_flash = 'Your Ad Button has been created!'; $ab_img = $htp; $ab_link = $htp; $ab_txt = ''; $ab_img_err = ''; $ab_link_err= ''; }elseif($ab_formfunc=='edit'){ $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}ad_buttons SET ad_picture = %s, ad_link = %s, ad_text = %s, ad_views = %d, ad_clicks = %d, ad_pos = %d WHERE id = %d", $ab_img, $ab_link, $ab_txt, $ab_views, $ab_clicks, $ab_pos, $ad_button)); $ol_flash = "Ad Button $ad_button has been updated."; } } } } ?>

' . esc_html($ol_flash) . '

'; ?>

Ad Buttons ad management

Edit Ad Button"; }else{ echo "

Create new Ad Button

";} } ?>

Ad Button Image '.esc_html($ab_txt).'';}?>
Ad Button Link
Ad Button Text
Ad position change the order of the ads, a higher number means the ad will move down in the list
Counters views
clicks
This only resets the views and clicks seen on this screen. Detailed view and click information is stored elsewhere. Viewing detailed statistics is being worked on and will be incorporated into a future release.

" />

Active Ad Buttons

get_results("SELECT * FROM "."{$wpdb->prefix}ad_buttons WHERE ad_active = 1"); foreach($results as $result){ if($result->ad_views){ $ad_ctr = round((($result->ad_clicks / $result->ad_views) * 100 ), 2); }else{ $ad_ctr = 0; } echo ' '; } ?>
Ad ID Ad Button Ad Text Ad Views Ad Clicks CTR Action
'.esc_html($result->id).' '.esc_html($result->ad_text).' '.esc_html($result->ad_text).' '.esc_html($result->ad_views).' '.esc_html($result->ad_clicks).' '.esc_html($ad_ctr).'%

Inactive Ad Buttons

get_results("SELECT * FROM {$wpdb->prefix}ad_buttons WHERE ad_active = 0"); foreach($results as $result){ if($result->ad_views){ $ad_ctr = round((($result->ad_clicks / $result->ad_views) * 100 ), 2); }else{ $ad_ctr = 0; } echo ' '; } ?>
Ad ID Ad Button Ad Text Ad Views Ad Clicks CTR Action
'.esc_html($result->id).' '.esc_html($result->ad_text).' '.esc_html($result->ad_text).' '.esc_html($result->ad_views).' '.esc_html($result->ad_clicks).' '.esc_html($ad_ctr).'%