. */ /* Stop direct call */ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) die(__('Sorry, you don't have direct access to this page.')); /* attach JavaScript file for textarea resizing */ function ae_js_sheet() { wp_enqueue_script('ta-expander-script', plugins_url('ta-expander.js', __FILE__), array('jquery'), '2.0', true); } add_action('admin_print_scripts-widgets.php', 'ae_js_sheet'); //Additional links on the plugin page add_filter('plugin_row_meta', 'ae_register_links',10,2); function ae_register_links($links, $file) { $base = plugin_basename(__FILE__); if ($file == $base) { $links[] = ''.__('FAQ', 'adseasy').''; $links[] = ''.__('Donate', 'adseasy').''; } return $links; } add_filter( 'plugin_action_links', 'ae_plugin_action_links', 10, 2 ); function ae_plugin_action_links( $links, $file ) { $base = plugin_basename(__FILE__); if ($file == $base) array_unshift($links, ''.__('Settings', 'adseasy').''); return $links; } /** * * Getting the Adsense Tags in the defined areas of the code and create hooks for other plugins * */ if (!defined('AE_AD_TAGS')) : $ae_options = get_option('ae_options'); define('AE_AD_TAGS', $ae_options['use_google_tags']); endif; if (AE_AD_TAGS == 1) : add_action( 'wp_head', 'ae_header', 1000); add_action( 'loop_start', 'ae_loop_start'); add_action( 'get_sidebar', 'ae_sidebar'); add_action( 'dynamic_sidebar', 'ae_sidebar'); add_action( 'wp_footer', 'ae_footer'); add_action( 'wp_footer', 'ae_end_tag', 1000); // hooks for other plugins add_action( 'google_start_tag', 'ae_start_tag'); add_action( 'google_ignore_tag', 'ae_ignore_tag'); add_action( 'google_end_tag', 'ae_end_tag'); // adding short code add_shortcode( 'ae_ignore_tag', 'ae_wrap_ignore'); // get the tinymce plugin include_once('tinymce/tinymce.php'); endif; /** * * Getting the Adsense Tags in the defined areas of the code and create hooks for other plugins * */ // Header function ae_header() { $ae_options = get_option('ae_options'); echo "\r\n"; if ($ae_options['ae_header'] == '1') do_action('google_start_tag'); else do_action('google_ignore_tag'); } function ae_loop_start() { global $ba_tag; $ae_options = get_option('ae_options'); if ($ae_options['ae_loop'] == '1' && $ba_tag == 'ignore') : do_action('google_end_tag'); do_action('google_start_tag'); endif; if ($ae_options['ae_loop'] == false && $ba_tag == 'start') : do_action('google_end_tag'); do_action('google_ignore_tag'); endif; } function ae_sidebar() { global $ba_tag; $ae_options = get_option('ae_options'); if ($ae_options['ae_sidebar'] == '1' && $ba_tag == 'ignore') : do_action('google_end_tag'); do_action('google_start_tag'); endif; if ($ae_options['ae_sidebar'] == false && $ba_tag == 'start') : do_action('google_end_tag'); do_action('google_ignore_tag'); endif; } function ae_footer() { global $ba_tag; $ae_options = get_option('ae_options'); if ($ae_options['ae_footer'] == '1' && $ba_tag == 'ignore') : do_action('google_end_tag'); do_action('google_start_tag'); endif; if ($ae_options['ae_footer'] == false && $ba_tag == 'start') : do_action('google_end_tag'); do_action('google_ignore_tag'); endif; } // Hook functions function ae_start_tag() { global $ba_tag; $eol = "\r\n"; echo ''.$eol; $ba_tag = 'start'; } function ae_ignore_tag() { global $ba_tag; $eol = "\r\n"; echo ''.$eol; $ba_tag = 'ignore'; } function ae_end_tag() { global $ba_tag; $eol = "\r\n"; echo $eol.''.$eol; $ba_tag = 'end'; } /** * * shortcode for the ignore tags * */ function ae_wrap_ignore($atts, $content = null){ $eol = "\r\n"; return $eol.''.$eol.''.$eol.do_shortcode($content).$eol.''.$eol.''.$eol; } /** * * Extending the widget class * */ class Ads_Easy_Widget extends WP_Widget { function Ads_Easy_Widget() { $widget_opts = array( 'description' => __('You can show ads in your sidebars and other widgetareas with this widget. Define, on what kind of pages they will show up.', 'adseasy') ); $control_opts = array( 'width' => 400 ); parent::WP_Widget(false, $name = 'Ads Easy', $widget_opts, $control_opts); } function form($instance) { $defaults = array( 'homepage' => true, 'category' => true ); $instance = wp_parse_args( (array) $instance, $defaults ); $title = esc_attr($instance['title']); $name = esc_attr($instance['name']); $adblock = $instance['adblock']; $style=esc_attr($instance['style']); $homepage=esc_attr($instance['homepage']); $frontpage=esc_attr($instance['frontpage']); $page=esc_attr($instance['page']); $category=esc_attr($instance['category']); $single=esc_attr($instance['single']); $date=esc_attr($instance['date']); $tag=esc_attr($instance['tag']); $attachment=esc_attr($instance['attachment']); $taxonomy=esc_attr($instance['taxonomy']); $author=esc_attr($instance['author']); $search=esc_attr($instance['search']); $not_found=esc_attr($instance['not_found']); $logged_in=esc_attr($instance['logged_in']); ?>












'; $ae_after_widget=''; } echo $ae_before_widget; if ( $title ) { echo $before_title . $title . $after_title; } /* This is the actual function of the plugin, it fills the sidebar with the customized excerpts */ echo $instance['adblock']; echo $ae_after_widget; }}} } add_action('widgets_init', create_function('', 'return register_widget("Ads_Easy_Widget");')); // import laguage files load_plugin_textdomain('adseasy', false , basename(dirname(__FILE__)).'/languages'); /** * * init * */ add_action('admin_init', 'ads_easy_init'); function ads_easy_init() { register_setting( 'ae_options', 'ae_options', 'ae_validate' ); add_settings_section('ads_easy_google', __('Use the Google AdSense Tags', 'adseasy'), 'ae_display_use_google', 'ae_use_adsense'); add_settings_field('use_google_tags', 'Tags:', 'ae_display_tags', 'ae_use_adsense', 'ads_easy_google', array(' '.__('Check to use the Google AdSense Tags', 'adseasy'))); add_settings_section('ads_easy_settings', __('What to wrap in the tags', 'adseasy'), 'ae_display_choices', 'ae_check_fields'); add_settings_field('ae_header', 'Header:', 'ae_display_header', 'ae_check_fields', 'ads_easy_settings', array(' '.__('Check to include the header', 'adseasy'))); add_settings_field('ae_loop', 'Loop:', 'ae_display_loop', 'ae_check_fields', 'ads_easy_settings', array(' '.__('Check to include the loop', 'adseasy'))); add_settings_field('ae_sidebar', 'Sidebar(s):', 'ae_display_sidebar', 'ae_check_fields', 'ads_easy_settings', array(' '.__('Check to include the sidebar(s)', 'adseasy'))); add_settings_field('ae_footer', 'Footer:', 'ae_display_footer', 'ae_check_fields', 'ads_easy_settings', array(' '.__('Check to include the footer', 'adseasy'))); } function ae_display_use_google() { echo '

'.__('To activate the use of the tags, check the box. The other boxes are there for the specific parts of the code.', 'adseasy').'

'; } function ae_display_choices() { echo '

'.__('Unchecked means, that the ignore tag is placed instead of the start tag. E.g. if you have ads from someone else than Google in the header, it might make sense to ignore it while if you have widgets in the footer, you definitely should include those.', 'adseasy').'

'; echo '

'.__('There will be a button in the editor to mark sections of your text, that you want to have ignored by Google Adsense.', 'adseasy').'

'; } function ae_display_tags($lable) { $ae_options = get_option('ae_options'); echo ""; } function ae_display_header($lable) { $ae_options = get_option('ae_options'); echo ""; } function ae_display_loop($lable) { $ae_options = get_option('ae_options'); echo ""; } function ae_display_sidebar($lable) { $ae_options = get_option('ae_options'); echo ""; } function ae_display_footer($lable) { $ae_options = get_option('ae_options'); echo ""; } // Adding the options register_activation_hook( __FILE__, 'ae_set_option' ); function ae_set_option() { add_option('ae_options', $ae_options); } // Deleting the options register_deactivation_hook( __FILE__, 'ae_unset_option' ); function ae_unset_option() { delete_option('ae_options'); } // Installing options page add_action('admin_menu', 'ae_admin_menu'); function ae_admin_menu() { add_plugins_page('Ads Easy', 'Ads Easy', 'administrator', 'ads-easy-settings', 'ae_options_page'); } // Calling the options page function ae_options_page() { ?>

Ads Easy