Options || Tutorials Version: 1.0.4 Author: Rhino Liêm Author URI: http://www.liemmp.com */ // Reg widget class custom_ads_sidebar { function display() { global $post; if( get_post_meta($post->ID, 'custom_ads_sidebar', true) ){ echo '' . get_post_meta($post->ID, 'custom_ads_sidebar', $single = true) .''; } else{ echo ""; echo ""; echo ""; } } } register_sidebar_widget('Custom Ads', array('custom_ads_sidebar', 'display')); // End Reg widget // Post custom ads $new_meta_boxes = array( "custom_ads_sidebar" => array( "name" => "custom_ads_sidebar", "std" => "", "title" => "Put your ads code", "description" => "Put your html code for your ads to display in single post.
Note: Don't worrry if your code will be not appear here. They will display in sidebar, where you put widget.") ); function new_meta_boxes() { global $post, $new_meta_boxes; foreach($new_meta_boxes as $meta_box) { $meta_box_value = get_post_meta($post->ID, $meta_box['name'], true); if($meta_box_value == "") $meta_box_value = $meta_box['std']; echo''; echo''; echo'
'; echo'

'; echo'You should use HTML code like that:
'; echo'Image ads: <a href="http://www.your-ads-url.com"><img src="http://www.your-ads-url.com/your-ads-folder/your-ads.jpg"></a>
'; echo'Texlink ads: <a href="http://www.your-ads-url.com">Text link ads</a>
'; } } function create_meta_box() { global $theme_name; if ( function_exists('add_meta_box') ) { add_meta_box( 'new-meta-boxes', 'Custom Ads Code box', 'new_meta_boxes', 'post', 'normal', 'high' ); } } function save_postdata( $post_id ) { global $post, $new_meta_boxes; foreach($new_meta_boxes as $meta_box) { // Verify if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) { return $post_id; } if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id )) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id )) return $post_id; } $data = $_POST[$meta_box['name']]; if(get_post_meta($post_id, $meta_box['name']) == "") add_post_meta($post_id, $meta_box['name'], $data, true); elseif($data != get_post_meta($post_id, $meta_box['name'], true)) update_post_meta($post_id, $meta_box['name'], $data); elseif($data == "") delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true)); } } add_action('admin_menu', 'create_meta_box'); add_action('save_post', 'save_postdata'); // Post custom ads function adssidebar_admin_menu(){ if (function_exists('add_submenu_page') ) { add_submenu_page('plugins.php', __('Custom Ads widget'), __('Custom Ads widget'),'manage_options' , 'adssidebar-options','adssidebar_options'); } } function adssidebar_imageandlink(){ $adside_image_default = "/wp-content/plugins/custom-ads-sidebar/image/custom-ads-sidebar.jpg"; if(get_option('adssidebar_adside_image')==false){ add_option('adssidebar_adside_image',$adside_image_default); } $adside_image=get_option('adssidebar_adside_image'); $adside_image = explode(',',$adside_image); $adside_link_default = ""; if(get_option('adssidebar_adside_link')==false){ add_option('adssidebar_adside_link',$adside_link_default); } $adside_link=get_option('adssidebar_adside_link'); $adside_link = explode(',',$adside_link); $adside_width_default = "200"; if(get_option('adssidebar_adside_width')==false){ add_option('adssidebar_adside_width',$adside_width_default); } $adside_width=get_option('adssidebar_adside_width'); $adside_width = explode(',',$adside_width); $adside_height_default = "100"; if(get_option('adssidebar_adside_height')==false){ add_option('adssidebar_adside_height',$adside_height_default); } $adside_height=get_option('adssidebar_adside_height'); $adside_height = explode(',',$adside_height); } function adssidebar_options(){ if ( isset($_POST['submit']) ) { if ( function_exists('current_user_can') && !current_user_can('manage_options') ){ die(__('Are you admin?')); } update_option('adssidebar_adside_image', $_POST['adssidebar_adside_image']); update_option('adssidebar_adside_link', $_POST['adssidebar_adside_link']); update_option('adssidebar_adside_width', $_POST['adssidebar_adside_width']); update_option('adssidebar_adside_height', $_POST['adssidebar_adside_height']); } if ( !empty($_POST)) : ?>

Custom Ads widget

This plugin will be power when intergate with Ads in Right Bottom plugin

How it work

This plugin help admin post ads to sidebar in single post.
In each single post, admin could put different code to display different ads.
For example: In a topic you write about travel service, you could display travel ads such as hotel, restaurant, tour...
by adding ads directly in single post edit page. To display your ads, please add html code to field when editting post.

How to display ads

Step 1: drag Custom Ads widget to your Sidebar




Step 2: Add your custom ads (HTML code) in single post edit page




Step 3: Update your post and view in front end.
Congratulation! Your ads will be displayed.

NOTE: For unavailable ads post

In some post you don not have ads to display, please custom your default ads here:

Default Ads url


(include http://)

Image Ads url


(include http:// - .jpg, .gif....)

Image width


(Pixels of image, only number please!)

Image height


(Pixels of image, only number please!)



If you find this plugin useful, please rate at wordpress plugin dir or send me a cup of coffee


If you have any question or idea, please tell me know in this plugin page