adsns_get_options(); } function adsns_get_options() { } // Number of views ads on a home page function adsns_home_postviews() { $options = get_option( 'adsns_sets' ); // Get an array of ad settings if( is_home() ) { $options['num_show'] += $options['max_homepostads']; // Counting views update_option( 'adsns_sets', $options ); } } // Number of views ads on a single page function adsns_single_postviews() { $options = get_option( 'adsns_sets' ); if( is_single() ) { $options['num_show']++; update_option( 'adsns_sets', $options ); } } // Number of views footer ads function adsns_footer_postviews() { $options = get_option( 'adsns_sets' ); if( !is_feed() ) { $options['num_show']++; update_option( 'adsns_sets', $options ); } } // Number of posts on home page function adsns_post_count( $content ) { global $adsns_count; $adsns_count++; return $content; } // Show ads after post on a single page function adsns_end_post_ad( $content ) { $codd = get_option( 'adsns_sets' ); // Get an array of ad settings $codd['code'] = stripslashes( $codd['code'] ); $this->adsns_donate(); // Calling a donate function if ( ! is_feed() && is_single() ) { // Checking if we are on a single page $content.= '
' . $codd['code'] . '
'; // Adding an ad code on page } return $content; } // Show ads after comment form function adsns_end_comment_ad() { $codd = get_option( 'adsns_sets' ); $codd['code'] = stripslashes( $codd['code'] ); $this->adsns_donate(); if( ! is_feed() ) { echo '
' . $codd['code'] . '
'; } } // Show ads after post on home page function adsns_end_home_post_ad( $content ) { global $adsns_count; $codd = get_option( 'adsns_sets' ); // Get an array of ad settings $codd['code'] = stripslashes( $codd['code'] ); while ($count <= $max_ads) { $count+=$options['max_homepostads']; // number of shows ads $current_count=$count; // backup current number of shows ads $count=$max_ads+1; // set count value out of range $this->adsns_donate(); // Calling a donate function if( ! is_feed() && is_home() && $adsns_count <= $codd['max_homepostads'] ) { $content.= '
' . $codd['code'] . '
'; } } $count=$current_count; // restore count value return $content; } // Show ads in footer function adsns_end_footer_ad() { $codd = get_option( 'adsns_sets' ); $codd['code'] = stripslashes( $codd['code'] ); $this->adsns_donate(); if( ! is_feed() ) { echo ''; } } // Add 'BWS Plugins' menu at the left side in administer panel function adsns_add_admin_menu() { add_menu_page( 'BWS Plugins', 'BWS Plugins', 'manage_options', 'bws_plugins', 'bws_add_menu_render', plugins_url( "images/px.png", __FILE__ ), 1001 ); add_submenu_page( 'bws_plugins', __( 'AdSense Options', 'adsense'), __( 'AdSense', 'adsense' ), 'manage_options', "adsense-plugin.php", array( $this, 'adsns_settings_page' ) ); } // Add a link for settings page function adsns_plugin_action_links( $links, $file ) { global $this_adsns_plugin; if ( $file == $this_adsns_plugin ){ $settings_link = '' . __( 'Settings', 'adsense' ) . ''; array_unshift( $links, $settings_link ); } return $links; } function adsns_register_plugin_links($links, $file) { global $this_adsns_plugin; if ($file == $this_adsns_plugin) { $links[] = '' . __( 'Settings', 'adsense' ) . ''; $links[] = '' . __( 'FAQ', 'adsense' ) . ''; $links[] = '' . __( 'Support', 'adsense' ) . ''; } return $links; } // Creating a default options for showing ads. Starts on plugin activation. function adsns_activate() { $new_options = array( 'num_show' => '0', 'donate' => '0', 'max_ads' => '3', 'max_homepostads' => '1', 'clientid' => '', 'donate_id' => '1662250046693311', 'adtypeselect' => 'text', 'donate_width' => '', 'donate_height' => '', 'default' => '468x60', 'image_only' => '', 'link_unit' => '', 'adtype' => 'adunit', 'corner_style' => 'none', 'border' => '#FFFFFF', 'title' => '#0000FF', 'background' => '#FFFFFF', 'text' => '#000000', 'url' => '#008000', 'palette' => 'Default Google pallete', 'position' => 'homepostend', 'code2' => '', 'code' => ' ' ); add_option( 'adsns_sets', $new_options ); } // Donate settings function adsns_donate() { $options = get_option( 'adsns_sets' ); if ( $options['donate'] > 0 ) { $don = intval( 100/$options['donate'] ); // Calculating number of donate ads for showing if ( $options['num_show'] % $don == 0) { // Checking if now showing ad must be a donate ad $dimensions = explode( "x", $options['default'] ); // Calculating dimensions of ad block $options['donate_width'] = $dimensions[0]; // Width $options['donate_height'] = $dimensions[1]; // Height $don_code = ''; $options['code'] = $don_code; update_option( 'adsns_sets', $options ); } else $options['code'] = $options['code2']; update_option( 'adsns_sets', $options ); } } // Function fo deactivation function adsns_deactivate() { } // Saving settings function adsns_settings_page() { $options = get_option( 'adsns_sets' ); echo '

' . $this->page_title . '

'; if ( isset( $_POST['adsns_update'] ) ) { ### if click on Save Changes button if ( strlen( $_POST['client_id'] ) > 0 ) { echo "

".__("Options saved.", 'adsense')."

"; if ( isset( $_POST['client_id'] ) ) { ## client $options['clientid'] = $_POST['client_id']; } if ( isset( $_POST['mycode'] ) ) { ## ad code $id = $_POST['mycode']; if ( strlen($id)>0 ) { $options['code'] = $id; $options['code2'] = $id; } } if ( isset( $_POST['homeAds'] ) ) { ## select $options['max_homepostads'] = $_POST['homeAds']; } if ( isset( $_POST['adtypeselect'] ) ) { ## adtypeselect $options['adtypeselect'] = $_POST['adtypeselect']; } if ( isset( $_POST['default'] ) ) { ## format $options['default'] = $_POST['default']; } if ( isset( $_POST['image_only'] ) ) { ## format $options['image_only'] = $_POST['image_only']; } if ( isset( $_POST['link_unit'] ) ) { ## format $options['link_unit'] = $_POST['link_unit']; } if ( isset( $_POST['adtype'] ) ) { ## adtype $options['adtype'] = $_POST['adtype']; } if ( isset( $_POST['corner_style'] ) ) { ## corner_style $options['corner_style'] = $_POST['corner_style']; } if ( isset( $_POST['pallete'] ) ) { ## pallete $options['pallete'] = $_POST['pallete']; } if ( isset( $_POST['border'] ) ) { ## border $options['border'] = $_POST['border']; } if ( isset( $_POST['title'] ) ) { ## title $options['title'] = $_POST['title']; } if ( isset( $_POST['background'] ) ) { ## background $options['background'] = $_POST['background']; } if ( isset( $_POST['text'] ) ) { ## text $options['text'] = $_POST['text']; } if ( isset( $_POST['url'] ) ) { ## url $options['url'] = $_POST['url']; } if ( isset( $_POST['position'] ) ) { ## position $options['position'] = $_POST['position']; } if ( isset( $_POST['donate'] ) ) { ## donate $options['donate'] = $_POST['donate']; } update_option( 'adsns_sets', $options ); } else echo "

".__("Please enter your Publisher ID.", 'adsense')."

"; } // Click on Save Changes button end $this->adsns_view_options_page(); echo '
'; } // Admin interface of plugin function adsns_view_options_page() { $options = get_option( 'adsns_sets' ); ?>






.ads { position: relative; text-align: center; } EOF; } } // class ?>