/** * Set default values * * @return array * @since 1.0.0 */ public function init() { $config = YIT_Config::load(); return array( 10 => array( 'id' => 'popup_news_url', 'type' => 'text', 'name' => __('Newsletter subscribe URL', 'yit'), 'desc' => __( 'The Newsletter subscribe url', 'yit' ), 'std' => '', ), 20 => array( 'id' => 'popup_news_email', 'type' => 'text', 'name' => __( 'Email "name"', 'yit' ), 'desc' => __( 'The attribute "name" of the email address field.<br><small>( NOTE: Mailchimp needs this attribute "EMAIL" uppercased )</small>', 'yit' ), 'std' => 'email', ), 30 => array( 'id' => 'popup_email_icon', 'type' => 'selecticon', 'name' => __('Email icon', 'yit'), 'desc' => __( 'Select an email icon', 'yit' ), 'options' => $config['awesome_icons'], 'std' => "icon-envelope", ), 40 => array( 'id' => 'popup_news_email_label', 'type' => 'text', 'name' => __( 'Email field label', 'yit' ), 'desc' => '', 'std' => __( 'Enter your mail address...', 'yit' ), ), 50 => array( 'id' => 'popup_submit_text', 'type' => 'text', 'name' => __( 'Submit button label', 'yit' ), 'desc' => __( 'Submit button label', 'yit' ), 'std' => 'ADD ME TO MAILING LIST', ), 60 => array( 'id' => 'popup_hidden_fields', 'type' => 'text', 'name' => __('Hidden fields', 'yit'), 'desc' => __( 'Type here all hidden fields names and values in serializate way. Example: <strong>name1=value1&name2=value2</strong>.', 'yit' ), 'std' => '', ), 70 => array( 'id' => 'popup_method', 'type' => 'select', 'name' => __( 'Request method', 'yit' ), 'desc' => __( 'The attribute "method" of the form.', 'yit' ), 'options' => array( 'post' => __('POST', 'yit'), 'get' => __('GET', 'yit') ), 'std' => "post", ), ); }
function form( $instance ) { /* Impostazioni di default del widget */ $defaults = array( 'title' => '', 'link' => '', 'icon_img' => '', 'more_text' => ' | ' . __( 'more →', 'yit' ), 'img_url' => '' ); $config = YIT_Config::load(); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <p> <label> <strong><?php _e( 'Title', 'yit' ) ?>:</strong><br /> <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" /> </label> </p> <p> <label> <strong><?php _e( 'Link', 'yit' ) ?>:</strong><br /> <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $instance['link']; ?>" /> </label> </p> <p> <?php _e( 'Icon', 'yit' ) ?>: <select id="<?php echo $this->get_field_id( 'icon_img' ); ?>" name="<?php echo $this->get_field_name( 'icon_img' ); ?>"> <option value="0"></option> <?php foreach ( $config['awesome_icons'] as $id_icon => $icon ) echo '<option value="'.$id_icon.'"'.selected( $id_icon, $instance['icon_img'], false ).'>'.$icon.'</option>'; ?> </select> <br /> <?php _e( 'or upload your icon:', 'yit' ) ?> <input type="text" id="<?php echo $this->get_field_id( 'img_url' ); ?>" name="<?php echo $this->get_field_name( 'img_url' ); ?>" value="<?php echo $instance['img_url']; ?>" /> <a href="#" id="<?php echo $this->id ?>-upload-button" class="upload-image button-secondary">Upload</a> </p> <p> <label> <strong><?php _e( 'More text', 'yit' ) ?>:</strong><br /> <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'more_text' ); ?>" name="<?php echo $this->get_field_name( 'more_text' ); ?>" value="<?php echo $instance['more_text']; ?>" /> </label> </p> <?php }
/** * Load and print the correspondent field type. * * @param @field * @return string */ public static function display( $value, $dep ) { $config = YIT_Config::load(); $area = isset($value['area']) ? $value['area'] : 'body'; $bg = yit_get_option( $value['id'] ); ob_start(); ?> <div id="<?php echo $value['id_container'] ?>" <?php if($dep): ?>data-field="<?php echo $dep['field'] ?>" data-dep="<?php echo $dep['dep'] ?>" data-value="<?php echo $dep['value'] ?>" <?php endif ?>class="yit_options rm_option rm_input rm_select rm_bg-preview"> <div class="option"> <label for="<?php echo $value['id'] ?>"><?php echo $value['name'] ?></label> <div class="select_wrapper" style="margin-right: 30px"> <select name="<?php yit_field_name( $value['id'] ); ?>[image]" id="<?php echo $value['id'] ?>_image"> <option value=""><?php _e( 'Select a background', 'yit' ) ?></option> <?php foreach ( $config[ $area . '_backgrounds'] as $val => $option ): ?> <option value="<?php echo $val ?>"<?php selected( $bg['image'], $val ) ?>><?php echo $option; ?></option> <?php endforeach; ?> </select> </div> <div id="<?php echo $value['id'] ?>_color_container" class="colorpicker_container"><div style="background-color: <?php echo $bg['color'] ?>"></div></div> <input type="text" name="<?php yit_field_name( $value['id'] ) ?>[color]" id="<?php echo $value['id'] ?>_color" style="width:90px" value="<?php echo $bg['color'] ?>" /> <div class="clear"></div> <div class="bg-preview" id="<?php echo $value['id'] ?>_preview"><div style="background: <?php echo $bg['color']; if($bg['image'] != 'custom'): ?> url('<?php echo $bg['image'] ?>') 50% 0<?php endif ?>"></div></div> </div> <div class="description"> <?php echo $value['desc'] ?> <?php printf( __( '(Default: %s)', 'yit' ), ( !empty( $value['std']['image'] ) ? $value['std']['image'] . ', ' : '' ) . $value['std']['color'] ) ?> </div> <div class="clear"></div> </div> <?php return ob_get_clean(); }
/** * Print the update page * * @return void * @since 1.0.0 */ public function display_page() { $config = YIT_Config::load(); $name = $config['theme']['name']; yit_get_template('admin/panel/notifier.php', $config['theme']); }
function form($instance) { /* Impostazioni di default del widget */ $defaults = array('title' => 'Featured Projects', 'icon' => 'comment', 'project_n_items' => 5, 'project_fx' => 'slide', 'project_timeout_fx' => 8000, 'project_speed_fx' => 300, 'project_post_type' => 'portfolio'); $config = YIT_Config::load(); $yit_easings = $config['easings']; $yit_cycle_fxs = $config['cycle_fx']; $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Title: <input type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_post_type'); ?> ">Portfolio: <select id="<?php echo $this->get_field_id('project_post_type'); ?> " name="<?php echo $this->get_field_name('project_post_type'); ?> "> <?php $portfolios = yit_portfolios(); ?> <?php foreach ($portfolios as $portfolio) { ?> <option value="<?php echo $portfolio->ID; ?> "<?php if ($portfolio->ID == $instance['project_post_type']) { ?> selected="selected"<?php } ?> ><?php echo $portfolio->post_title ? $portfolio->post_title : 'Portfolio ID: ' . $portfolio->ID; ?> </option> <?php } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_n_items'); ?> ">Items: <select id="<?php echo $this->get_field_id('project_n_items'); ?> " name="<?php echo $this->get_field_name('project_n_items'); ?> "> <?php for ($i = 1; $i <= 20; $i++) { $select = ''; if ($instance['project_n_items'] == $i) { $select = ' selected="selected"'; } echo "<option value=\"{$i}\"{$select}>{$i}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_fx'); ?> ">Effect Slider: <select id="<?php echo $this->get_field_id('project_fx'); ?> " name="<?php echo $this->get_field_name('project_fx'); ?> "> <?php foreach (array('slide', 'fade') as $fx) { $select = ''; if ($instance['project_fx'] == $fx) { $select = ' selected="selected"'; } echo "<option value=\"{$fx}\"{$select}>{$fx}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_timeout_fx'); ?> ">Timeout (ms): <input type="text" id="<?php echo $this->get_field_id('project_timeout_fx'); ?> " name="<?php echo $this->get_field_name('project_timeout_fx'); ?> " value="<?php echo $instance['project_timeout_fx']; ?> " size="4" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_speed_fx'); ?> ">Speed Animation (ms): <input type="text" id="<?php echo $this->get_field_id('project_speed_fx'); ?> " name="<?php echo $this->get_field_name('project_speed_fx'); ?> " value="<?php echo $instance['project_speed_fx']; ?> " size="4" /> </label> </p> <?php }
/** * Get CSS style of button to show in Color select menu * */ public function get_awesome_icons() { $config = YIT_Config::load(); return $config['awesome_icons']; }
function form($instance) { global $icons_name, $yiw_cycle_fxs, $yiw_easings; /* Impostazioni di default del widget */ $defaults = array('title' => 'Testimonials', 'excerpt_length' => 55, 'test_n_items' => 5, 'test_fx' => 'scrollLeft', 'test_easing_fx' => FALSE, 'test_timeout_fx' => 8000, 'test_speed_fx' => 300); $yit_categories = get_categories('hide_empty=1&orderby=name'); $wp_cats = array(); $yit_config = YIT_Config::load(); foreach ($yit_categories as $category_list) { $wp_cats[$category_list->category_nicename] = $category_list->cat_name; } $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Title: <input type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('excerpt_length'); ?> ">Text lenght: <input type="text" id="<?php echo $this->get_field_id('excerpt_length'); ?> " name="<?php echo $this->get_field_name('excerpt_length'); ?> " value="<?php echo $instance['excerpt_length']; ?> " class="widefat" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('test_n_items'); ?> ">Items: <select id="<?php echo $this->get_field_id('test_n_items'); ?> " name="<?php echo $this->get_field_name('test_n_items'); ?> "> <?php for ($i = 1; $i <= 20; $i++) { $select = ''; if ($instance['test_n_items'] == $i) { $select = ' selected="selected"'; } echo "<option value=\"{$i}\"{$select}>{$i}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('test_fx'); ?> ">Effect Slider: <select id="<?php echo $this->get_field_id('test_fx'); ?> " name="<?php echo $this->get_field_name('test_fx'); ?> "> <?php foreach (array('slide', 'fade') as $fx) { $select = ''; if ($instance['test_fx'] == $fx) { $select = ' selected="selected"'; } echo "<option value=\"{$fx}\"{$select}>{$fx}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('test_timeout_fx'); ?> ">Timeout effect (ms): <input type="text" id="<?php echo $this->get_field_id('test_timeout_fx'); ?> " name="<?php echo $this->get_field_name('test_timeout_fx'); ?> " value="<?php echo $instance['test_timeout_fx']; ?> " size="4" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('test_speed_fx'); ?> ">Speed Animation (ms): <input type="text" id="<?php echo $this->get_field_id('test_speed_fx'); ?> " name="<?php echo $this->get_field_name('test_speed_fx'); ?> " value="<?php echo $instance['test_speed_fx']; ?> " size="4" /> </label> </p> <?php }
/** * Load and print the correspondent field type. * * @param @field * @return string */ public static function display($value, $dep) { $config = YIT_Config::load(); $area = isset($value['area']) ? $value['area'] : 'body'; $bg = yit_get_option($value['id']); ob_start(); ?> <div id="<?php echo $value['id_container']; ?> " <?php if ($dep) { ?> data-field="<?php echo $dep['field']; ?> " data-dep="<?php echo $dep['dep']; ?> " data-value="<?php echo $dep['value']; ?> " <?php } ?> class="yit_options rm_option rm_input rm_select rm_bg-preview"> <div class="option"> <label for="<?php echo $value['id']; ?> "><?php echo $value['name']; ?> </label> <div class="select_wrapper" style="margin-right: 30px"> <select name="<?php yit_field_name($value['id']); ?> [image]" id="<?php echo $value['id']; ?> _image"> <option value=""><?php _e('Select a background', 'yit'); ?> </option> <?php foreach ($config[$area . '_backgrounds'] as $val => $option) { ?> <option value="<?php echo $val; ?> "<?php selected($bg['image'], $val); ?> ><?php echo $option; ?> </option> <?php } ?> </select> </div> <div id="<?php echo $value['id']; ?> _color_container" class="colorpicker_container"><div style="background-color: <?php echo $bg['color']; ?> "></div></div> <input type="text" name="<?php yit_field_name($value['id']); ?> [color]" id="<?php echo $value['id']; ?> _color" style="width:90px" value="<?php echo $bg['color']; ?> " /> <div class="clear"></div> <div class="bg-preview" id="<?php echo $value['id']; ?> _preview"><div style="background: <?php echo $bg['color']; ?> url('<?php echo $bg['image'] != 'custom' ? $bg['image'] : ''; ?> ') 50% 0"></div></div> </div> <div class="description"> <?php echo $value['desc']; ?> <?php printf(__('(Default: %s)', 'yit'), (!empty($value['std']['image']) ? $value['std']['image'] . ', ' : '') . $value['std']['color']); ?> </div> <div class="clear"></div> </div> <script type="text/javascript"> jQuery(document).ready( function( $ ) { var preview = "#<?php echo $value['id']; ?> _preview div"; if( $('#<?php echo $value['id']; ?> _image').val() == 'custom' || $('#<?php echo $value['id']; ?> _image').val() == '' ) { $(preview).hide(); } $('#<?php echo $value['id']; ?> _image').change(function(){ if( $(this).val() == 'custom' || $('#<?php echo $value['id']; ?> _image').val() == '' ) { $(preview).hide(); } else { $(preview).css('background-image', 'url('+$( 'option:selected', this).val()+')').show(); } }); $('#<?php echo $value['id']; ?> _color_container').ColorPicker({ color: '<?php echo $bg['color']; ?> ', onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; }, onHide: function (colpkr) { $(colpkr).fadeOut(500); return false; }, onChange: function (hsb, hex, rgb) { $('#<?php echo $value['id']; ?> _color_container div').css('backgroundColor', '#' + hex); $( '#<?php echo $value['id']; ?> _color_container' ).next( 'input' ).attr( 'value', '#' + hex ); $(preview).css('backgroundColor', '#' + hex); } }); }); </script> <?php return ob_get_clean(); }
/** * Load and print the correspondent field type. * * @param @field * @return string */ public static function display($value, $dep) { $config = YIT_Config::load(); $icon_value = maybe_unserialize(yit_get_option($value['id'], $value['std'])); if (!is_array($icon_value)) { $icon_value = array('icon' => $icon_value, 'custom' => ''); } $explode_std = isset($value['std']['icon']) ? explode('-', $value['std']['icon']) : array(); ob_start(); ?> <div id="<?php echo $value['id_container']; ?> " <?php if ($dep) { ?> data-field="<?php echo $dep['field']; ?> " data-dep="<?php echo $dep['dep']; ?> " data-value="<?php echo $dep['value']; ?> " <?php } ?> class="yit_options rm_option rm_input rm_text"> <div class="option"> <label for="<?php echo $value['id']; ?> "><?php echo $value['name']; ?> </label> <div class="select_wrapper"> <select name="<?php yit_field_name($value['id']); ?> [icon]" id="<?php echo $value['id']; ?> "> <?php foreach ($config['awesome_icons'] as $val => $option) { ?> <option value="<?php echo $val; ?> "<?php selected($icon_value['icon'], $val); ?> ><?php echo $option; ?> </option> <?php } ?> </select> </div> <div class="icon-preview"><span class="<?php echo $icon_value['icon']; ?> "></span></div> <?php if (isset($value['upload']) && $value['upload']) { ?> <div class="clearboth"></div> <div class="upload-button"> <?php _e('or upload your own icon:', 'yit'); ?> <input type="text" style="width:200px;" id="<?php echo $value['id']; ?> _custom" name="<?php yit_field_name($value['id']); ?> [custom]" value="<?php if (isset($icon_value['custom'])) { echo $icon_value['custom']; } ?> " /> <a href="#" class="button-secondary" id="<?php echo $value['id']; ?> _upload_button"><?php _e('Upload', 'yit'); ?> </a> </div> <?php } ?> </div> <div class="description"> <?php echo $value['desc']; ?> <?php printf(__('(Default: %s)', 'yit'), ucfirst(end($explode_std))); ?> </div> <div class="clear"></div> </div> <script type="text/javascript"> jQuery(document).ready( function( $ ) { $( '#<?php echo $value['id']; ?> _icon' ).attr( 'class', $( '#<?php echo $value['id']; ?> ' ).val() ); $( '#<?php echo $value['id']; ?> ' ).change( function() { $( '#<?php echo $value['id']; ?> _icon' ).removeAttr( 'class' ); $( '#<?php echo $value['id']; ?> _icon' ).attr( 'class', $( this ).val() ); $(this).parents('.yit_options').find('.icon-preview span').attr( 'class', $( this ).val() ); }); $('#<?php echo $value['id']; ?> _upload_button').live('click', function(){ var yit_this_object = $(this).prev(); tb_show('', 'media-upload.php?post_id=0&type=image&TB_iframe=true'); window.send_to_editor = function(html) { imgurl = $('img', html).attr('src'); yit_this_object.val(imgurl); tb_remove(); } return false; }); }); </script> <?php return ob_get_clean(); }
/** * Set default values * * @return array * @since 1.0.0 */ public function init() { $config = YIT_Config::load(); return array(10 => array('id' => 'popup_news_url', 'type' => 'text', 'name' => __('URL', 'yit'), 'desc' => __('Newsletter url', 'yit'), 'std' => ''), 20 => array('id' => 'popup_news_email', 'type' => 'text', 'name' => __('E-mail', 'yit'), 'desc' => __('E-mail field name', 'yit'), 'std' => 'email'), 30 => array('id' => 'popup_email_icon', 'type' => 'selecticon', 'name' => __('Email icon', 'yit'), 'desc' => __('Select an email icon', 'yit'), 'options' => $config['awesome_icons'], 'std' => "icon-envelope"), 40 => array('id' => 'popup_news_email_label', 'type' => 'text', 'name' => __('E-mail label', 'yit'), 'desc' => __('E-mail field label', 'yit'), 'std' => __('Enter your mail address...', 'yit')), 50 => array('id' => 'popup_submit_text', 'type' => 'text', 'name' => __('Submit text', 'yit'), 'desc' => __('Submit button text', 'yit'), 'std' => 'ADD ME TO MAILING LIST'), 60 => array('id' => 'popup_hidden_fields', 'type' => 'text', 'name' => __('Hidden fields', 'yit'), 'desc' => __('Newsletter hidden fiel. (usage: name1=value1&name2=value2")', 'yit'), 'std' => ''), 70 => array('id' => 'popup_method', 'type' => 'select', 'name' => __('Method', 'yit'), 'desc' => __('Want to use a a popup?', 'yit'), 'options' => array('post' => __('POST', 'yit'), 'get' => __('GET', 'yit')), 'std' => "post")); }
/** * Load all options from the database and load them in $this->db_options * * @since 1.0.0 * @return null */ protected function _loadDatabaseOptions() { $config = YIT_Config::load(); $options = get_option($this->option_name, array()); // if there aren't any options in the database, load the standard values if (empty($options)) { $options = $this->_loadDefaultOptions(); } $this->db_options = $options; }