| Current Path : /home/ereika83/www/wp-content/plugins/genesis-club-pro/classes/ |
| Current File : /home/ereika83/www/wp-content/plugins/genesis-club-pro/classes/class-bar-widgets.php |
<?php
class Genesis_Club_Bar_Widget extends Genesis_Club_Widget {
private $bar;
private $tips = array(
'enabled' => array('heading' => 'Enable Default Bar', 'tip' => 'Click to enable this Top Bar on the home page, archives, posts, etc. If not enabled then any settings below are ignored and top bar widgets will be displayed'),
'full_message' => array('heading' => 'Full Message', 'tip' => 'Enter the full message you want to display. This can be HTML so can have a link or a button. This message will be displayed on all sizes of device if you leave the following fields blank.'),
'laptop_message' => array('heading' => 'Laptop Message', 'tip' => 'Enter the message you want to display on laptop devices - device width is between 800 and 1024 px. Leave blank to use the full message.'),
'tablet_message' => array('heading' => 'Tablet Message', 'tip' => 'Enter the message you want to display on tablets - device width is between 480 and 800 px. Leave blank to use the full message or the laptop size message if you have specified one.'),
'short_message' => array('heading' => 'Mobile Message', 'tip' => 'Enter the message you want to display on mobile devices under a width of 480px. This could be short message probably no more than 20 characters or maybe just a button with some text on it. Leave blank to use the full message, the laptop size message or the tablet size message if you have specified one.'),
'font_color' => array('heading' => 'Font Color', 'tip' => 'Enter the color of the font text.'),
'background' => array('heading' => 'Background', 'tip' => 'Enter the background for the bar. This can be a simple color, or a background image. For example, #FED444 url(http://images.site.com/bg.jpg) no-repeat fixed center top'),
'show_timeout'=> array('heading' => 'Delay to Show The Bar', 'tip' => 'Enter the number of seconds to wait before displaying the bar. Leave blank or set to zero if you want the bar to load immediately'),
'hide_timeout' => array('heading' => 'Delay to Hide The Bar', 'tip' => 'Enter the number of seconds to wait before hiding the bar. Leave blank or set to zero to have the bar remain visible.'),
'bounce' => array('heading' => 'Bounce', 'tip' => 'Click to have the bar bounce on being displayed to attract attention.'),
'shadow' => array('heading' => 'Shadow', 'tip' => 'Click to add a shadow under the bar.'),
'opener' => array('heading' => 'Opener Tab', 'tip' => 'Here you can choose have a Tab/Button on the right hand side on the bar that can be used to open the bar. This also adds a button on the bar to close it.'),
'location' => array('heading' => 'HTML Element', 'tip' => 'Leave the default setting of body unless your theme has a fixed header in which case enter the fixed element to which you want to attach the bar.'),
'position' => array('heading' => 'Position', 'tip' => 'Locate the bar at the top or the bottom of your chosen element.'),
);
function __construct() {
$widget_ops = array('description' => __('Adds a different top bar on pages where you do not want the default Top Bar', GENESIS_CLUB_DOMAIN) );
$control_ops = array('width' => 360, 'height' => 480);
parent::__construct('genesis-club-bar', __('Genesis Club Top Bar', GENESIS_CLUB_DOMAIN), $widget_ops, $control_ops);
$this->bar = $this->plugin->get_module('bar');
$this->set_defaults($this->bar->get_defaults());
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
}
function enqueue_scripts() {
if ($this->is_widget_instance_active()) $this->bar->enqueue_scripts(true);
}
function widget( $args, $instance ) {
$this->bar->add_bar($instance);
}
function update( $new_instance, $old_instance ) {
$instance = $this->update_instance( $new_instance, $old_instance );
$instance['full_message'] = esc_html(trim($new_instance['full_message']));
$instance['laptop_message'] = esc_html(trim($new_instance['laptop_message']));
$instance['tablet_message'] = esc_html(trim($new_instance['tablet_message']));
$instance['short_message'] = esc_html(trim($new_instance['short_message']));
$instance['font_color'] = strtoupper(trim($new_instance['font_color']));
$instance['background'] = trim($new_instance['background']);
$instance['shadow'] = !empty($new_instance['shadow']);
$instance['bounce'] = !empty($new_instance['bounce']);
$instance['opener'] = !empty($new_instance['opener']);
$instance['show_timeout'] = $new_instance['show_timeout'];
$instance['hide_timeout'] = $new_instance['hide_timeout'];
$instance['location'] = $new_instance['location'];
$instance['position'] = $new_instance['position'];
return $instance;
}
function form( $instance ) {
$this->form_init ($instance, $this->tips);
print('<p style="font-size:smaller">The settings you enter here in the widget will override any default messages you have set up on the Genesis Club Pro <em>Bar Menu</em>.</p>');
print('<h4>Messages</h4>');
$this->print_form_field('full_message', 'text', array(), array('class' => 'widefat' ));
$this->print_form_field('laptop_message', 'text', array(), array('class' => 'widefat'));
$this->print_form_field('tablet_message', 'text', array(), array('class' => 'widefat'));
$this->print_form_field('short_message', 'text', array(), array('class' => 'widefat'));
print('<h4>Colors</h4>');
$this->print_form_field('background', 'text', array(), array('size' => 20 ));
$this->print_form_field('font_color', 'text', array(), array('size' => 8 , 'class' => 'color-picker'));
print('<h4>Timing</h4>');
$this->print_form_field('show_timeout', 'text', array(), array('size' => 3, 'suffix' => 'seconds'));
$this->print_form_field('hide_timeout', 'text', array(), array('size' => 3, 'suffix' => 'seconds'));
print('<h4>Effects</h4>');
$this->print_form_field('bounce', 'checkbox');
$this->print_form_field('shadow', 'checkbox');
$this->print_form_field('opener', 'checkbox');
print('<h4>Location</h4>');
$this->print_form_field('location', 'text', array(), array('size' => 20));
$this->print_form_field('position', 'radio', array('top' => 'Top', 'bottom' => 'Bottom'));
print('<h4>Widget Presence</h4>');
print('<p style="font-size:smaller">You can control on which pages this widget appears using a plugin such as <em>Widget Logic</em> or <em>Content Aware Sidebars</em> or the Widget Visibility feature in <em>Jetpack</em></p>');
}
}