. */ if(!class_exists(advert_manager)){ class advert_manager{ function add_options(){ $myplug = add_options_page('Advert Manager by isitesolution.com','Advert Manager','administrator',basename(__FILE__),array('advert_manager',advertmanaging)); add_action( "admin_print_scripts-$myplug", array('advert_manager',my_admin_scripts) ); add_action( "admin_print_styles-$myplug", array('advert_manager',my_admin_styles) ); } function advertmanaging(){ echo '
'; screen_icon(); echo '

Advert Manager

'; echo '
'; ?>
Upload Advert Here







note: instead of image your can insert javascript or text for your advert here...




get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_title!=''"); echo ''; ?>


get_results("SELECT * FROM wp_advertmanage_joseph_db"); foreach ($s as $key=>$post) : echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; endforeach; ?>
No Advert Title Shown on post/page title URL(website) Image Preview Description Status Options/Actions
'.($key+1).''.$post->post_title.''.$post->advert_text.''.$post->advert_url.''.$post->advert_description.''.$post->status.' Delete '.($post->status=='Active'?'Deactive':'Activate').'
'; } function my_admin_scripts(){ //$p = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)).'/'; wp_register_script('my-jquery', WP_PLUGIN_URL.'/advert-manager/js/jquery-1.3.2.js'); wp_register_script('my-upload', WP_PLUGIN_URL.'/advert-manager/js/ajaxupload.3.5.js'); wp_register_script('my-uploader', WP_PLUGIN_URL.'/advert-manager/js/jsuploading.js'); wp_enqueue_script('my-jquery'); wp_enqueue_script('my-upload'); wp_enqueue_script('my-uploader'); } function my_admin_styles(){ wp_register_style('my-style', WP_PLUGIN_URL.'/advert-manager/css/style.css'); wp_enqueue_style('my-style'); } function advert_install(){ global $wpdb; $table_name = $wpdb->prefix . "advertmanage_joseph_db"; if($wpdb->get_var("SHOW tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, time bigint(11) DEFAULT '0' NOT NULL, post_title text NOT NULL, advert_text text NOT NULL, advert_url text NOT NULL, advert_img text NOT NULL, advert_description text NOT NULL, status text NOT NULL, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } } } $new = new advert_manager; add_action("admin_menu", array($new,'add_options')); //add_action('admin_print_scripts', array($new, 'my_admin_scripts')); //add_action('admin_print_styles', array($new, 'my_admin_styles')); register_activation_hook(__FILE__,array($new, 'advert_install')); function get_adverthere(){ global $post; global $wpdb; $g = get_bloginfo( template_url ); $t = WP_PLUGIN_URL.'/advert-manager/uploads'; $tit = get_the_title(); $imgset = $wpdb->get_results("SELECT * FROM wp_advertmanage_joseph_db WHERE post_title='$tit' ORDER BY id ASC LIMIT 1", ARRAY_A); if($imgset==NULL){ return $t.'/images/default-ads.jpg'; }else{ foreach ($imgset as $val) : //return $post->advert_img; $advr = $val; endforeach; return $advr; } //return $advr; }