'Large Leaderboard (970x90)', '728x90' => 'Leaderboard (728x90)', '468x60' => 'Banner (468x60)', '336x280' => 'Large Rectangle (336x280)', '320x100' => 'Large Mobile Banner (320x100)', '320x50' => 'Mobile Banner (320x50)', '300x600' => 'Large Skyscraper (300x600)', '300x250' => 'Medium Rectangle (300x250)', '250x250' => 'Square (250x250)', '234x60' => 'Half Banner (234x60)', '200x200' => 'Small Square (200x200)', '180x150' => 'Small Rectangle (180x150)', '160x600' => 'Wide Skyscraper (160x600)', '125x125' => 'Button (125x125)', '120x600' => 'Skyscraper (120x600)', '120x240' => 'Vertical Banner (120x240)', # Google Adsense Link Unit Sizes '728x15' => 'Displays 4 links (728x15)', '468x15' => 'Displays 4 links (468x15)', '200x90' => 'Displays 3 links (200x90)', '180x90' => 'Displays 3 links (180x90)', '160x90' => 'Displays 3 links (160x90)', '120x90' => 'Displays 3 links (120x90)', ); if(!class_exists('AmazingAds')) { class AmazingAds { var $adsizes; //constants const CAPABILITY = 'manage_options'; const VERSION = '0.0.1'; const VERSION_FIELD_NAME = 'amAdsmanager_var'; const post_type ="amAdsMananger"; //Constructer public function __construct() { global $adsizes; $this->adsizes =$adsizes; //action hooks add_action( 'admin_init', array( &$this,'init_admin') ); add_action( 'after_setup_theme', array( &$this, 'setup_amAds' ) ); add_action('widgets_init',array(&$this,'amads_widget')); add_action( 'manage_posts_custom_column', array( &$this, 'posts_custom_column' ), 10, 2 ); add_action( 'save_post', array( &$this,'update_custom_meta_fields' ) ); add_action( 'add_meta_boxes', array( &$this, 'add_custom_box' ) ); add_action('admin_head',array(&$this,'getamadsData')); add_action('init',array(&$this,'front_style')); //filters add_filter( 'manage_amadsmananger_posts_columns', array( &$this, 'add_custom_columns' ) ); add_filter('post_updated_messages', array( &$this, 'amadsmananger_updated_messages' ) ); add_filter( "mce_external_plugins", array( &$this, 'amads_add_tinymce_plugin' ) ); add_filter( 'mce_buttons', array( &$this, 'amads_register_my_tc_button' ) ); // shortcodes add_shortcode( 'amads', array( &$this, 'amads_shortcode' ) ); } // setup custom post type public function setup_amAds(){ //CUSTOM POST TYPES $amAd_labels = array( 'name' => _x('All Ads', 'post type general name'), 'singular_name' => _x('All Ads', 'post type singular name'), 'add_new' => _x('Add New Ads', 'amAds'), 'add_new_item' => __('Add New Ads'), 'edit_item' => __('Edit Ads'), 'new_item' => __('New Ads'), 'all_items' => __('All Ads'), 'view_item' => __('View Ads'), 'search_items' => __('Search Ads'), 'not_found' => __('No Ads found'), 'not_found_in_trash' => __('No Tracks found in Trash'), 'parent_item_colon' => '', 'menu_name' => 'Amazing Ads Manager' ); $amAd_args = array( 'labels' => $amAd_labels, 'public' => false, 'show_ui' => true, 'show_in_menu' => true, 'has_archive' => true, 'hierarchical' => false, 'menu_icon' => plugins_url('/assets/images/icon.png', __FILE__ ), 'supports' => array('title', 'custom_fields'), 'register_meta_box_vo' => array(&$this, 'add_meta_boxes') ); register_post_type( self::post_type, $amAd_args ); } //initialize from style public function front_style(){ if(is_admin()){ wp_enqueue_style('amads-admin-style', plugins_url('/assets/css/amads.css', __FILE__)); } else { wp_enqueue_style('amads-admin-style', plugins_url('/assets/css/amads-front.css', __FILE__)); } } // initialize admin public function init_admin() { // Localize wp version global $wp_version; if(version_compare($wp_version, '3.5', '<')) { $params['wp_version']="wp_ver3_5_low"; } if(version_compare($wp_version, '3.5', '>=')) { $params['wp_version']="wp_ver3_5_up"; } wp_localize_script('jquery', 'amAds', $params ); } //add filter to ensure the text Ad message is displayed when user updates an Ad public function amadsmananger_updated_messages( $messages ) { global $post, $post_ID; $messages['amadsmananger'] = array( 0 => '', // Unused. Messages start at index 1. 1 => 'Ad updated', 2 => 'Custom field updated.', 3 => 'Custom field deleted.', 4 => 'Ad updated.', /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf('Ad restored to revision from %s', wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => 'Ad published. ' , 7 => 'Ad saved.', 8 => 'Ad submitted. ', 10 => 'Ad draft updated. ', ); return $messages; } //create custom column shortcode public function add_custom_columns( $defaults ) { unset($defaults['date'],$defaults['thumbnail']); $defaults['amads_shortcode'] = 'Shortcode'; $defaults['date'] = 'Date'; return $defaults; } // enqueue script for amads public function enqueue_script(){ wp_enqueue_script('amads-admin-js', plugins_url('/assets/js/amads.js', __FILE__)); if(function_exists( 'wp_enqueue_media' )){ wp_enqueue_media(); }else{ wp_enqueue_style('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); } } //add meta box in the "Add New Ads" page public function add_custom_box() { global $pagenow,$typenow; if ( $typenow=='amadsmananger' ) { $this->enqueue_script(); } add_meta_box('amads-meta-box', 'Ads Manager Option', array( &$this, 'create_meta_box'), 'amadsmananger', 'normal', 'high'); } // create Custom meta boxes public function create_meta_box(){ global $post; $custom_fields = get_post_custom($post->ID); if(!isset($custom_fields['ad_sizes'][0])){ $custom_fields['ad_sizes'][0]=""; } if(!isset($custom_fields['ad_type'][0])){ $custom_fields['ad_type'][0]=""; } if(!isset($custom_fields['amads_link'][0])){ $custom_fields['amads_link'][0]=""; } if(!isset($custom_fields['amads_image'][0])){ $custom_fields['amads_image'][0]=""; } if(!isset($custom_fields['amads_codes'][0])){ $custom_fields['amads_codes'][0]=""; } ?>