'', 'cjt_size' => '300x250', 'cjt_type' => 'text', 'cjt_channel' => '', 'cjt_color_border' => '000000', 'cjt_color_bg' => '0000FF', 'cjt_color_link' => 'FFFFFF', 'cjt_color_text' => '000000', 'cjt_color_url' => '008000', 'cjt_corners' => 'rc:10' ); update_option ('cjt_defaults', $cjt_defaults_array); } function display_adsense_made_easy($cjt_publisher, $cjt_size, $cjt_type, $cjt_channel, $cjt_color_border, $cjt_color_bg, $cjt_color_link, $cjt_color_text, $cjt_color_url, $cjt_corners) { //seperate the w and h from size where size is 111x222 $cjt_width = substr($cjt_size, 0, 3); $cjt_height = substr($cjt_size, 4, 3); $cjt_script_adsense = ""; //link Unit if ($cjt_height == 15) { $cjt_ad_format_suf = '_0ads_al'; $cjt_script_adsense = ' '; //AD Unit } else { $cjt_ad_format_suf = '_as'; $cjt_script_adsense = ' '; } return $cjt_script_adsense; } class cjt_adsense_made_easy extends WP_Widget { /*contstructor initializes the widget*/ function cjt_adsense_made_easy() { $widget_options = array( 'classname' => 'cjt_adsense_made_easy', 'description' => __('Simple and easy Google Adsense Widget') ); // Call the parent class WP_Widget parent::WP_Widget('cjt_adsense_made_easy', 'Adsense Made Easy', $widget_options); } /*Displays info in the sidebar*/ function widget($args, $instance) { extract( $args, EXTR_SKIP ); /*if not saved in widget admin panel use DEFAULTS*/ $cjt_publisher = ( get_option('cjt_publisher') ) ? ( get_option('cjt_publisher') ) : ''; $cjt_size = ( get_option('cjt_size') ) ? ( get_option('cjt_size') ) : '300x250'; $cjt_type = ( get_option('cjt_type') ) ? ( get_option('cjt_type') ) : 'text'; $cjt_channel = ( get_option('cjt_channel') ) ? ( get_option('cjt_channel') ) : ''; $cjt_color_border = ( get_option('cjt_color_border') ) ? ( get_option('cjt_color_border') ) : '000000'; $cjt_color_bg = ( get_option('cjt_color_bg') ) ? ( get_option('cjt_color_bg') ) : '0000FF'; $cjt_color_link = ( get_option('cjt_color_link') ) ? ( get_option('cjt_color_link') ) : 'FFFFFF'; $cjt_color_text = ( get_option('cjt_color_text') ) ? ( get_option('cjt_color_text') ) : '000000'; $cjt_color_url = ( get_option('cjt_color_url') ) ? ( get_option('cjt_color_url') ) : '008000'; $cjt_corners = ( get_option('cjt_corners') ) ? ( get_option('cjt_corners') ) : 'rc:10'; //wp function that add html code for plugin/theme compatibility echo $before_widget; echo $before_title . $after_title; //show on website echo display_adsense_made_easy($cjt_publisher, $cjt_size, $cjt_type, $cjt_channel, $cjt_color_border, $cjt_color_bg, $cjt_color_link, $cjt_color_text, $cjt_color_url, $cjt_corners); //wp function echo $after_widget; } /*Save new information*/ function update($new_instance, $old_instance) { $instance = $old_instance; $instance['cjt_publisher'] = strip_tags( $new_instance['cjt_publisher'] ); $instance['cjt_size'] = strip_tags( $new_instance['cjt_size'] ); $instance['cjt_type'] = strip_tags( $new_instance['cjt_type'] ); $instance['cjt_channel'] = strip_tags( $new_instance['cjt_channel'] ); $instance['cjt_color_border'] = strip_tags( $new_instance['cjt_color_border'] ); $instance['cjt_color_bg'] = strip_tags( $new_instance['cjt_color_bg'] ); $instance['cjt_color_link'] = strip_tags( $new_instance['cjt_color_link'] ); $instance['cjt_color_text'] = strip_tags( $new_instance['cjt_color_text'] ); $instance['cjt_color_url'] = strip_tags( $new_instance['cjt_color_url'] ); $instance['cjt_corners'] = strip_tags( $new_instance['cjt_corners'] ); return $instance; } /*Displays widget in admin widget section*/ function form($instance) { //create form defaults $cjt_defaults = array( 'cjt_publisher' => '', 'cjt_size' => '300x250', 'cjt_type' => 'text', 'cjt_channel' => '', 'cjt_color_border' => '000000', 'cjt_color_bg' => '0000FF', 'cjt_color_link' => 'FFFFFF', 'cjt_color_text' => '000000', 'cjt_color_url' => '008000', 'cjt_corners' => 'rc:10' ); $instance = wp_parse_args( (array) $instance, $cjt_defaults ); $cjt_publisher = $instance['cjt_publisher']; $cjt_size = $instance['cjt_size']; $cjt_type = $instance['cjt_type']; $cjt_channel = $instance['cjt_channel']; $cjt_color_border = $instance['cjt_color_border']; $cjt_color_bg = $instance['cjt_color_bg']; $cjt_color_link = $instance['cjt_color_link']; $cjt_color_text = $instance['cjt_color_text']; $cjt_color_url = $instance['cjt_color_url']; $cjt_corners = $instance['cjt_corners']; //INCLUDE FORM LAYOUT if (file_exists (dirname (__FILE__).'/cjt_widget_form.php')) { include (dirname (__FILE__).'/cjt_widget_form.php'); } else { echo '' ; _e("Error locating the widget admin page!\nEnsure cjt_widget_form.php exists, or reinstall the plugin.") ; echo '' ; } }/*End of form function*/ }/*Ends WP_Widget Class*/ /*register widget */ function cjt_adsense_made_easy_init() { register_widget('cjt_adsense_made_easy'); } //register settings--registers variables to database function cjt_register_options() { register_setting( 'cjt_adsense_made_easy_vars', 'cjt_publisher' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_size' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_type' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_channel' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_color_border' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_color_bg' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_color_link' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_color_text' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_color_url' ); register_setting( 'cjt_adsense_made_easy_vars', 'cjt_corners' ); } // INCLUDE ADMIN PAGE if (file_exists (dirname (__FILE__).'/cjt_admin.php')) { include (dirname (__FILE__).'/cjt_admin.php'); } else { echo '' ; _e("Error locating the admin page!\nEnsure cjt_admin.php exists, or reinstall the plugin.") ; echo '' ; } //Adds Option panel function cjt_adsense_made_easy_submenu() { add_options_page('Adsense Made Easy Default Options', 'Adsense Made Easy', 'administrator', __FILE__, 'cjt_adsense_made_easy_settings_page'); } //Add Action hooks /*adds widget to panel*/ add_action('widgets_init', 'cjt_adsense_made_easy_init'); //add submenu panel add_action('admin_menu', 'cjt_adsense_made_easy_submenu'); //initialize the options when admin page laoded add_action('admin_init', 'cjt_register_options'); ?>