コード例 #1
0
    function form($instance)
    {
        $defaults = array('title' => '', 'num_banners' => '', 'timer' => '4000', 'caption_position' => 'bottom', 'use_image_tag' => false, 'transition' => 'none', 'group' => '', 'show_pager_icons' => false, 'pause_on_hover' => false, 'link_entire_banner' => false, 'open_link_in_new_window' => false, 'show_caption' => true, 'show_cta_button' => true, 'banner_height' => 'auto', 'banner_height_px' => '', 'banner_width' => '100_percent', 'banner_width_px' => '', 'auto_height' => '', 'prev_next' => '', 'paused' => '');
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = $instance['title'];
        $num_banners = $instance['num_banners'];
        $transition = $instance['transition'];
        $group = $instance['group'];
        $caption_position = $instance['caption_position'];
        $use_image_tag = $instance['use_image_tag'];
        $show_pager_icons = $instance['show_pager_icons'];
        $timer = $instance['timer'];
        $pause_on_hover = $instance['pause_on_hover'];
        $use_image_tag = $instance['use_image_tag'];
        $link_entire_banner = $instance['link_entire_banner'];
        $open_link_in_new_window = $instance['open_link_in_new_window'];
        $show_caption = $instance['show_caption'];
        $show_cta_button = $instance['show_cta_button'];
        $default_banner_width = get_option('custom_banners_default_width', '');
        $default_banner_height = get_option('custom_banners_default_height', '');
        $banner_height = $instance['banner_height'];
        $banner_height_px = intval($instance['banner_height_px']) > 0 ? intval($instance['banner_height_px']) : $default_banner_height;
        $banner_width = $instance['banner_width'];
        $banner_width_px = intval($instance['banner_width_px']) > 0 ? intval($instance['banner_width_px']) : $default_banner_width;
        $auto_height = isset($instance['auto_height']) ? $instance['auto_height'] : '';
        $prev_next = isset($instance['prev_next']) ? $instance['prev_next'] : '';
        $paused = isset($instance['paused']) ? $instance['paused'] : '';
        $cycle_transitions = $this->get_cycle_transitions();
        $ip = isValidCBKey();
        if (!isValidCBKey()) {
            //echo '<p><a href="http://goldplugins.com/our-plugins/custom-banners/" target="_blank">Upgrade</a> to Custom Banners Pro today to unlock this widget and more cool features!</p>';
        }
        ?>
		<div class="gp_widget_form_wrapper">
			<p>
				<label for="<?php 
        echo $this->get_field_id('title');
        ?>
">Widget Title:</label><br />
				<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />
			</p>
						
						
			<p>
				<label for="<?php 
        echo $this->get_field_id('caption_position');
        ?>
">Caption Position:</label>
				<select id="<?php 
        echo $this->get_field_id('caption_position');
        ?>
" name="<?php 
        echo $this->get_field_name('caption_position');
        ?>
">
					<option value="left"  <?php 
        if ($caption_position == "left") {
            ?>
 selected="SELECTED" <?php 
        }
        ?>
>Left</option>
					<option value="right"  <?php 
        if ($caption_position == "right") {
            ?>
 selected="SELECTED" <?php 
        }
        ?>
>Right</option>
					<option value="top"  <?php 
        if ($caption_position == "top") {
            ?>
 selected="SELECTED" <?php 
        }
        ?>
>Top</option>
					<option value="bottom"  <?php 
        if ($caption_position == "bottom") {
            ?>
 selected="SELECTED" <?php 
        }
        ?>
>Bottom</option>
				</select>
			</p>
					
			<fieldset class="radio_text_input">
				<legend>Height:</legend> &nbsp;
				<div class="bikeshed bikeshed_radio">								
					<div class="radio_wrapper">
						<p class="radio_option"><label><input class="tog" name="<?php 
        echo $this->get_field_name('banner_height');
        ?>
" type="radio" value="auto" <?php 
        if ($banner_height == 'auto') {
            ?>
checked <?php 
        }
        ?>
> Auto</label></p>
						<p class="radio_option"><label><input class="tog" name="<?php 
        echo $this->get_field_name('banner_height');
        ?>
" type="radio" value="specify" <?php 
        if ($banner_height == 'specify') {
            ?>
checked="checked" <?php 
        }
        ?>
> Specify: <input name="<?php 
        echo $this->get_field_name('banner_height_px');
        ?>
" type="text" value="<?php 
        echo $banner_height_px;
        ?>
"></label></p>
					</div>
				</div>
			</fieldset>

			<fieldset class="radio_text_input">
				<legend>Width:</legend> &nbsp;
				<div class="bikeshed bikeshed_radio">								
					<div class="radio_wrapper">
						<p class="radio_option"><label><input class="tog" name="<?php 
        echo $this->get_field_name('banner_width');
        ?>
" type="radio" value="auto" <?php 
        if ($banner_width == 'auto') {
            ?>
checked="checked"<?php 
        }
        ?>
 > Auto</label></p>
						<p class="radio_option"><label><input class="tog" name="<?php 
        echo $this->get_field_name('banner_width');
        ?>
" type="radio" value="100_percent" <?php 
        if ($banner_width == '100_percent') {
            ?>
checked="checked"<?php 
        }
        ?>
 > 100%</label></p>
						<p class="radio_option"><label><input class="tog" name="<?php 
        echo $this->get_field_name('banner_width');
        ?>
" type="radio" value="specify" <?php 
        if ($banner_width == 'specify') {
            ?>
checked="checked"<?php 
        }
        ?>
 > Specify: <input name="<?php 
        echo $this->get_field_name('banner_width_px');
        ?>
" type="text" value="<?php 
        echo $banner_width_px;
        ?>
"></label></p>
					</div>
				</div>
			</fieldset>
									
			
					
			<fieldset class="radio_text_input">
				<legend>Select Banners To Display:</legend> &nbsp;
				<div class="bikeshed_radio">		
					<p>
						<label for="<?php 
        echo $this->get_field_id('group');
        ?>
">Banner Group:</label>
						<select id="<?php 
        echo $this->get_field_id('group');
        ?>
" name="<?php 
        echo $this->get_field_name('group');
        ?>
">			
							<?php 
        $categories = get_terms('banner_groups');
        foreach ($categories as $category) {
            ?>
							<option value="<?php 
            echo $category->slug;
            ?>
" <?php 
            if ($group == $category->slug) {
                ?>
 selected="SELECTED" <?php 
            }
            ?>
><?php 
            echo $category->name;
            ?>
</option>
							<?php 
        }
        ?>
							<option value="" <?php 
        if ($group == "") {
            ?>
 selected="SELECTED" <?php 
        }
        ?>
>All Categories</option>
						</select>
					</p>
					<p>
						<label for="<?php 
        echo $this->get_field_id('num_banners');
        ?>
">Number of Banners To Display:</label><input class="widefat" id="<?php 
        echo $this->get_field_id('num_banners');
        ?>
" name="<?php 
        echo $this->get_field_name('num_banners');
        ?>
" type="text" value="<?php 
        echo esc_attr($num_banners);
        ?>
" />
					</p>
					<p class="description">Tip: leave this field empty to display all of your banners</p>
					
				</div>
			</fieldset>
						
			<fieldset class="radio_text_input">
				<legend>Slideshow Options:</legend> &nbsp;
				<div class="bikeshed_radio">
					<p>
						<label for="<?php 
        echo $this->get_field_id('transition');
        ?>
">Transition:</label>
						<select name="<?php 
        echo $this->get_field_name('transition');
        ?>
" id="<?php 
        echo $this->get_field_id('transition');
        ?>
">	
							<optgroup label="Free Options">
							<?php 
        foreach ($cycle_transitions as $key => $transition_options) {
            ?>
								<?php 
            if ($transition_options['pro'] == true) {
                continue;
            }
            ?>
 
								<option value="<?php 
            echo $key;
            ?>
" <?php 
            if ($transition == $key) {
                echo 'selected="SELECTED"';
            }
            ?>
><?php 
            echo htmlentities($transition_options['label']);
            ?>
</option>
							<?php 
        }
        ?>
							</optgroup>
							<?php 
        if ($ip) {
            ?>
							<optgroup label="Pro Options">
							<?php 
        } else {
            ?>
							<optgroup label="Pro Options (Upgrade To Unlock!)" disabled="disabled">
							<?php 
        }
        ?>
							<?php 
        foreach ($cycle_transitions as $key => $transition_options) {
            ?>
								<?php 
            if ($transition_options['pro'] == false) {
                continue;
            }
            ?>
 
								<option value="<?php 
            echo $key;
            ?>
" <?php 
            if ($transition == $key) {
                echo 'selected="SELECTED"';
            }
            ?>
 <?php 
            if (!$ip) {
                echo 'disabled="disabled"';
            }
            ?>
><?php 
            echo htmlentities($transition_options['label']);
            ?>
</option>
							<?php 
        }
        ?>
							</optgroup>
						</select>
						<?php 
        if (!$ip) {
            ?>
						<br />
						<em><a target="_blank" href="http://goldplugins.com/our-plugins/custom-banners/upgrade-to-custom-banners-pro/?utm_source=wp_widgets&utm_campaign=widget_transitions">Upgrade To Unlock All Transitions!</a></em>
						<?php 
        }
        ?>
					</p>
					<p>
						<label for="<?php 
        echo $this->get_field_id('timer');
        ?>
">Time Between Transitions:</label>
						<select id="<?php 
        echo $this->get_field_id('timer');
        ?>
" name="<?php 
        echo $this->get_field_name('timer');
        ?>
">
							<?php 
        foreach (range(1, 60) as $t) {
            ?>
							<?php 
            $my_val = $t . '000';
            ?>
							<option value="<?php 
            echo $my_val;
            ?>
"  <?php 
            if ($timer == $my_val) {
                ?>
 selected="SELECTED" <?php 
            }
            ?>
><?php 
            echo $t;
            ?>
 second<?php 
            if ($t > 1) {
                echo 's';
            }
            ?>
</option>
							<?php 
        }
        ?>
						</select>
					</p>					
					<!--<p class="description">The time between transitions.  Please Note: 1000 = 1 second.</p>-->
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('pause_on_hover');
        ?>
" name="<?php 
        echo $this->get_field_name('pause_on_hover');
        ?>
" type="checkbox" value="true" <?php 
        if ($pause_on_hover) {
            ?>
checked="CHECKED"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('pause_on_hover');
        ?>
">Pause Slideshow on Hover</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('auto_height');
        ?>
" name="<?php 
        echo $this->get_field_name('auto_height');
        ?>
" type="checkbox" value="1" <?php 
        if ($auto_height) {
            ?>
checked="CHECKED"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('auto_height');
        ?>
">Auto-Adjust Height To Fit Each Banner</label>
						<br/>
					</p>	
					<p class="description after_checkbox"><em>If checked, the height of the slideshow will be adjusted to the height of each slide.</em></p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('show_pager_icons');
        ?>
" name="<?php 
        echo $this->get_field_name('show_pager_icons');
        ?>
" type="checkbox" value="1" <?php 
        if ($show_pager_icons) {
            ?>
checked="CHECKED"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('show_pager_icons');
        ?>
">Show Pager Icons</label>
					</p>	
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('prev_next');
        ?>
" name="<?php 
        echo $this->get_field_name('prev_next');
        ?>
" type="checkbox" value="1" <?php 
        if ($prev_next) {
            ?>
checked="CHECKED"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('prev_next');
        ?>
">Show Previous and Next Buttons</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('paused');
        ?>
" name="<?php 
        echo $this->get_field_name('paused');
        ?>
" type="checkbox" value="1" <?php 
        if ($paused) {
            ?>
checked="CHECKED"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('paused');
        ?>
">Disable Auto Transition</label>
					</p>	
					<p class="description after_checkbox"><em>If checked, the slideshow will only transition to the next slide when manually triggered (i.e., via the Pager Icons or Previous/Next buttons)</em></p>			
				</div>
			</fieldset>
			<fieldset class="radio_text_input">
				<legend>Advanced Options:</legend> &nbsp;
				<div class="bikeshed bikeshed_radio">
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('show_caption');
        ?>
" name="<?php 
        echo $this->get_field_name('show_caption');
        ?>
" type="checkbox" value="1" <?php 
        if ($show_caption) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('show_caption');
        ?>
">Show Caption Box</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('show_cta_button');
        ?>
" name="<?php 
        echo $this->get_field_name('show_cta_button');
        ?>
" type="checkbox" value="1" <?php 
        if ($show_cta_button) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('show_cta_button');
        ?>
">Show Button</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('link_entire_banner');
        ?>
" name="<?php 
        echo $this->get_field_name('link_entire_banner');
        ?>
" type="checkbox" value="1" <?php 
        if ($link_entire_banner) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('link_entire_banner');
        ?>
">Link Entire Banner</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('open_link_in_new_window');
        ?>
" name="<?php 
        echo $this->get_field_name('open_link_in_new_window');
        ?>
" type="checkbox" value="1" <?php 
        if ($open_link_in_new_window) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('open_link_in_new_window');
        ?>
">Open Links In New Window</label>
					</p>
					<p>
						<input class="widefat" id="<?php 
        echo $this->get_field_id('use_image_tag');
        ?>
" name="<?php 
        echo $this->get_field_name('use_image_tag');
        ?>
" type="checkbox" value="1" <?php 
        if ($use_image_tag) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
						<label for="<?php 
        echo $this->get_field_id('use_image_tag');
        ?>
">Use Image Tag</label>
					</p>
				</div>
			</fieldset>
		</div>
		<?php 
    }
コード例 #2
0
    function style_settings_page()
    {
        $this->settings_page_top();
        $disabled = !isValidCBKey();
        ?>
<form method="post" action="options.php" class="gp_settings_form">
			<?php 
        if (!isValidCBKey()) {
            ?>
			<div class="custom_banners_not_registered">
				<h3>Custom Banners Pro Required To Use These Features</h3>
				<p>Custom Banners Pro is required to use these features. The options below will become instantly available once you have registered and activated your plugin. <br /><br /><a class="button" href="http://goldplugins.com/our-plugins/custom-banners/upgrade-to-custom-banners-pro/?utm_campaign=registration&utm_source=custom_banners_settings" target="_blank">Click Here To Upgrade To Pro</a> <br /> <br /><em>You'll receive your API keys as soon as you complete your payment, instantly unlocking these features and more!</em></p>
			</div>
			<?php 
        }
        ?>
			<?php 
        settings_fields('custom-banners-style-settings-group');
        ?>
			<h3>Style Options</h3>
			<p>Use these options to adjust the style of your caption and your call to action buttons.</p>
			<fieldset>
				<legend>Caption Background</legend>				
				<table class="form-table">
					<?php 
        $this->color_input('custom_banners_caption_background_color', 'Background Color', '#000000', $disabled);
        $this->text_input('custom_banners_caption_background_opacity', 'Background Opacity (percentage)', '', '70', $disabled);
        ?>
				</table>
			</fieldset>
			
			<fieldset>
				<legend>Caption Text</legend>
				<table class="form-table">
					<?php 
        $this->typography_input('custom_banners_caption_*', 'Caption Font', 'Please note: these settings can be overridden for each banner by using the Visual Editor.', '', '', '', '#ffffff', $disabled);
        ?>
				</table>
			</fieldset>
						
			<fieldset>
				<legend>Call To Action (CTA) Button</legend>
				<table class="form-table">
					<?php 
        $this->typography_input('custom_banners_cta_button_*', 'Font', '', '', '', '', '', $disabled);
        $this->color_input('custom_banners_cta_background_color', 'Background Color', '#ffa500', $disabled);
        $this->color_input('custom_banners_cta_border_color', 'Border Color', '#ff8c00', $disabled);
        $this->text_input('custom_banners_cta_border_radius', 'Border Radius', '', '5', $disabled);
        ?>
				</table>
			</fieldset>
	
			<p class="submit">
				<input type="submit" class="button-primary" value="<?php 
        _e('Save Changes');
        ?>
" />
			</p>
		</form>
		</div><?php 
    }
コード例 #3
0
ファイル: custom-banners.php プロジェクト: gasbriones/bacare
 function build_typography_css($prefix)
 {
     $css_rule_template = ' %s: %s;';
     $output = '';
     if (!isValidCBKey()) {
         return $output;
     }
     /* 
      * Font Family
      */
     $option_val = get_option($prefix . 'font_family', '');
     if (!empty($option_val)) {
         // strip off 'google:' prefix if needed
         $option_val = str_replace('google:', '', $option_val);
         // wrap font family name in quotes
         $option_val = '\'' . $option_val . '\'';
         $output .= sprintf($css_rule_template, 'font-family', $option_val);
     }
     /* 
      * Font Size
      */
     $option_val = get_option($prefix . 'font_size', '');
     if (!empty($option_val)) {
         // append 'px' if needed
         if (is_numeric($option_val)) {
             $option_val .= 'px';
         }
         $output .= sprintf($css_rule_template, 'font-size', $option_val);
     }
     /* 
      * Font Color
      */
     $option_val = get_option($prefix . 'font_color', '');
     if (!empty($option_val)) {
         $output .= sprintf($css_rule_template, 'color', $option_val);
     }
     /* 
      * Font Style - add font-style and font-weight rules
      * NOTE: in this special case, we are adding 2 rules!
      */
     $option_val = get_option($prefix . 'font_style', '');
     // Convert the value to 2 CSS rules, font-style and font-weight
     // NOTE: we lowercase the value before comparison, for simplification
     switch (strtolower($option_val)) {
         case 'regular':
             // not bold not italic
             $output .= sprintf($css_rule_template, 'font-style', 'normal');
             $output .= sprintf($css_rule_template, 'font-weight', 'normal');
             break;
         case 'bold':
             // bold, but not italic
             $output .= sprintf($css_rule_template, 'font-style', 'normal');
             $output .= sprintf($css_rule_template, 'font-weight', 'bold');
             break;
         case 'italic':
             // italic, but not bold
             $output .= sprintf($css_rule_template, 'font-style', 'italic');
             $output .= sprintf($css_rule_template, 'font-weight', 'normal');
             break;
         case 'bold italic':
             // bold and italic
             $output .= sprintf($css_rule_template, 'font-style', 'italic');
             $output .= sprintf($css_rule_template, 'font-weight', 'bold');
             break;
         default:
             // empty string or other invalid value, ignore and move on
             break;
     }
     // return the completed CSS string
     return trim($output);
 }
コード例 #4
0
<h3>Pro Registration</h3>			
<?php 
if (isValidCBKey()) {
    ?>
	
<p class="custom_banners_registered">Your plugin is succesfully registered and activated. Thank you!</p>
<?php 
} else {
    ?>
<p class="custom_banners_not_registered">Custom Banners Pro is not activated. You will not be able to use the Pro features until you activate the plugin. <br /><br /><a class="button" href="http://goldplugins.com/our-plugins/custom-banners/upgrade-to-custom-banners-pro/?utm_campaign=registration&utm_source=custom_banners_settings" target="_blank">Click Here To Upgrade To Pro</a> <br /> <br /><em>You'll unlock powerful new features including advanced styling options and JavaScript transitions for your slideshows.</em></p>
<p>Please enter your email address and API key to activate Custom Banners Pro. </p>
<?php 
}
?>
	
<?php 
if (!isValidMSCBKey()) {
    ?>
<table class="form-table">
	<tr valign="top">
		<th scope="row"><label for="custom_banners_registered_name">Email Address</label></th>
		<td><input type="text" name="custom_banners_registered_name" id="custom_banners_registered_name" value="<?php 
    echo get_option('custom_banners_registered_name');
    ?>
"  style="width: 250px" />
		<p class="description">This is the e-mail address that you used when you purchased the plugin.</p>
		</td>
	</tr>
</table>

<table class="form-table" style="display: none;">