Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Just use "image widget" Plugin************************************************************************************
- <!-- Insert into sidebar.php -->
- //It's conditional widget---------------------------------------------------------------------------
- <?php $options=get_option('plugin_options'); ?>
- <?php
- if($options['home_page_ads']>=1) {
- ?>
- <div id="home_ad_1" class="advert" style="background: transparent url(<?php bloginfo('stylesheet_directory'); ?>/_images/ad_box.gif) no-repeat;">
- <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('home_ad_1')) : else : ?>
- <div class="pre-widget">
- <p> </p>
- <p> </p>
- </div>
- <?php endif; ?>
- </div>
- <?php } ?>
- <!-- Insert into style.css -->
- .widget-area .advert {
- margin: 0 auto 20px auto;
- width: 284px;
- height: 166px;
- padding: 7px 0 0 5px;
- }
- <?php
- //Only for dashboard setting panel-----------------------------------------------------------------------------------------
- // Insert a menu item in the admin menu called "Advertisements"
- add_action('admin_menu', 'create_theme_options_page');
- function create_theme_options_page() {
- add_options_page('Advertisements', 'Advertisements', 'administrator', __FILE__, 'build_options_page');
- }
- // Builds the Advertisements page
- function build_options_page() {
- ?>
- <div id="theme-options-wrap">
- <div class="icon32" id="icon-tools"> <br /> </div>
- <h2>Advertisements</h2>
- <p>Set the number of ads in the sidebar.</p>
- <form method="post" action="options.php">
- <?php settings_fields('plugin_options'); ?>
- <?php do_settings_sections(__FILE__); ?>
- <p class="submit">
- <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
- </p>
- </form>
- </div>
- <?php
- }
- // Initializes the sections of the page when the Dashboard boots up
- add_action('admin_init', 'register_and_build_fields');
- function register_and_build_fields() {
- register_setting('plugin_options', 'plugin_options', 'validate_setting');
- add_settings_section('main_section', '', 'section_cb', __FILE__);
- add_settings_field('home_page_ads', 'Page Ads:', 'home_page_ads_setting', __FILE__, 'main_section');
- }
- // Ensures that the correct options are chosen
- function validate_setting($plugin_options) {
- return $plugin_options;
- }
- function section_cb() {}
- // Sets up the select menus
- function home_page_ads_setting() {
- $options = get_option('plugin_options');
- $items = array('0','1','2','3');
- echo "<select name='plugin_options[home_page_ads]' style='width:50px;' />";
- foreach($items as $item) {
- $selected = ( $options['home_page_ads'] === $item ) ? 'selected="selected"' : '' ;
- echo "<option value='$item' $selected > $item </option>";
- };
- echo '</select>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement