function enlightenment_grid_loop_select_template($args, $echo = true) { $templates = enlightenment_grid_loop_templates(); $defaults = array('class' => '', 'id' => '', 'options' => $templates, 'description' => ''); $args = wp_parse_args($args, $defaults); $args['multiple'] = false; $output = enlightenment_select_box($args, false); ob_start(); ?> <script> jQuery(document).ready(function($) { $('.select-template').change(function() { window.location = '<?php echo admin_url('themes.php?page=' . current_theme_supports('enlightenment-theme-settings', 'menu_slug') . '&tab=grid_loop&template='); ?> '+$(this).val(); }); }); </script> <?php $output .= ob_get_clean(); if (!$echo) { return $output; } echo $output; }
function enlightenment_page_design_form($post) { wp_nonce_field('enlightenment_page_design_form', 'enlightenment_page_design_form_nonce'); echo enlightenment_open_tag('p'); global $wp_post_types; enlightenment_select_box(array('name' => 'enlightenment_page_design', 'value' => '' != get_post_meta($post->ID, '_enlightenment_page_design', true) ? get_post_meta($post->ID, '_enlightenment_page_design', true) : enlightenment_theme_option('page_design'), 'options' => array('boxed' => 'Boxed', 'full-screen' => 'Full Screen'))); echo enlightenment_close_tag('p'); }
function enlightenment_select_post_format($args, $echo = true) { $defaults = array('class' => '', 'id' => '', 'options' => enlightenment_post_formats(), 'description' => ''); $args = wp_parse_args($args, $defaults); $args['multiple'] = false; $output = enlightenment_select_box($args, false); if (!$echo) { return $output; } echo $output; }
function enlightenment_grid_loop_select_template($args, $echo = true) { $templates = enlightenment_grid_loop_templates(); $defaults = array('class' => '', 'id' => '', 'options' => $templates, 'description' => ''); $args = wp_parse_args($args, $defaults); $args['multiple'] = false; $output = enlightenment_select_box($args, false); if (!$echo) { return $output; } echo $output; }
function enlightenment_font_options($args, $echo = true) { $defaults = array('class' => '', 'id' => '', 'description' => ''); $args = wp_parse_args($args, $defaults); if (!isset($args['name']) || empty($args['name'])) { _doing_it_wrong(__FUNCTION__, __('Please specify a name attribute for your font options.', 'enlightenment'), ''); return; } $fonts = enlightenment_available_fonts(); $font_family_args = array('name' => $args['name'] . '_font_family', 'class' => 'font_family' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_family' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_family' : '', 'options' => array()); foreach ($fonts as $name => $font) { // $font_family_args['options'][$name] = ( isset( $font['family'] ) ? str_replace( '"', '', $font['family'] ) : $name ) . ', ' . $font['category']; $font_family_args['options'][$name] = str_replace('"', '', $font['family']) . ', ' . $font['category']; } $font_size_args = array('name' => $args['name'] . '_font_size', 'class' => 'font_size' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_size' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_size' : '', 'options' => array()); $min_font_size = apply_filters('enlightenment_min_font_size', 10); $max_font_size = apply_filters('enlightenment_max_font_size', 48); $font_size_inc = apply_filters('enlightenment_font_size_inc', 1); $font_size_unit = apply_filters('enlightenment_font_size_unit', 'px'); for ($i = $min_font_size; $i <= $max_font_size; $i = $i + $font_size_inc) { $font_size_args['options'][$i] = intval($i) . ' ' . esc_attr($font_size_unit); } $font_style_args = array('name' => $args['name'] . '_font_style', 'class' => 'font_style' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_style' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_style' : '', 'options' => enlightenment_font_styles()); $color_picker_args = array('name' => $args['name'] . '_font_color', 'class' => 'font_color' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_color' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_color' : ''); $output = enlightenment_open_tag('fieldset', 'font-options'); $output .= enlightenment_select_box($font_family_args, false); $output .= enlightenment_select_box($font_size_args, false); $output .= enlightenment_select_box($font_style_args, false); $output .= enlightenment_color_picker($color_picker_args, false); $output .= enlightenment_close_tag('fieldset'); $output .= empty($args['description']) ? '' : '<p class="description">' . strip_tags($args['description'], '<a><abbr><img>') . '</p>'; $output = apply_filters('enlightenment_font_options', $output, $args); if (!$echo) { return $output; } echo $output; }
function enlightenment_select_template($args, $echo = true) { $templates = enlightenment_templates(); foreach ($templates as $name => $template) { $templates[$name] = $template['name']; } $defaults = array('class' => '', 'id' => '', 'options' => $templates, 'description' => ''); $args = wp_parse_args($args, $defaults); $args['multiple'] = false; $output = enlightenment_select_box($args, false); if (!$echo) { return $output; } echo $output; }
function enlightenment_edit_sidebar_location($args, $echo = true) { $defaults = array('class' => '', 'id' => '', 'value' => '', 'description' => ''); $args = wp_parse_args($args, $defaults); $args = apply_filters('enlightenment_edit_sidebar_location_args', $args); $args['multiple'] = false; $args['options'] = array('' => __('[None]', 'enlightenment')); global $wp_registered_sidebars; // var_dump($wp_registered_sidebars); foreach ($wp_registered_sidebars as $sidebar => $atts) { $args['options'][$sidebar] = $atts['name']; } $output = enlightenment_select_box($args, false); $output = apply_filters('enlightenment_edit_sidebar_location', $output, $args); if (!$echo) { return $output; } echo $output; }
/** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { $defaults = array('title' => '', 'tagline' => '', 'type' => 'list', 'grid' => 'onecol', 'query' => 'sticky_posts', 'post_type' => 'post', 'p' => null, 'page_id' => null, 'pages' => array(), 'images' => array(), 'author' => null, 'taxonomy' => 'category', 'term' => null, 'posts_per_page' => 5, 'leading_posts' => 1, 'link_to_archive' => false, 'link_to_archive_label' => __('See all posts →', 'enlightenment')); $instance = wp_parse_args($instance, $defaults); echo enlightenment_open_tag('p'); enlightenment_text_input(array('label' => __('Title:', 'enlightenment'), 'name' => $this->get_field_name('title'), 'class' => 'widefat', 'id' => $this->get_field_id('title'), 'value' => $instance['title'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p'); enlightenment_textarea(array('label' => __('Tagline:', 'enlightenment'), 'name' => $this->get_field_name('tagline'), 'class' => 'widefat', 'id' => $this->get_field_id('tagline'), 'value' => $instance['tagline'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'type'); $options = array('list' => __('List', 'enlightenment'), 'gallery' => __('Gallery', 'enlightenment'), 'slider' => __('Slider', 'enlightenment'), 'carousel' => __('Carousel', 'enlightenment')); enlightenment_select_box(array('label' => __('Type:', 'enlightenment'), 'name' => $this->get_field_name('type'), 'class' => 'widefat', 'id' => $this->get_field_id('type'), 'options' => $options, 'value' => $instance['type'])); echo enlightenment_close_tag('p'); if (current_theme_supports('enlightenment-grid-loop')) { echo enlightenment_open_tag('p', 'grid'); $options = array(); foreach (enlightenment_grid_columns() as $grid => $atts) { $options[$grid] = $atts['name']; } enlightenment_select_box(array('label' => __('Grid:', 'enlightenment'), 'name' => $this->get_field_name('grid'), 'class' => 'widefat', 'id' => $this->get_field_id('grid'), 'options' => $options, 'value' => $instance['grid'])); echo enlightenment_close_tag('p'); } echo enlightenment_open_tag('p', 'query'); $queries = enlightenment_custom_queries(); $options = array(); foreach ($queries as $query => $atts) { $options[$query] = $atts['name']; } enlightenment_select_box(array('label' => __('Query:', 'enlightenment'), 'name' => $this->get_field_name('query'), 'class' => 'widefat', 'id' => $this->get_field_id('query'), 'options' => $options, 'value' => $instance['query'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'post-types' . ('post_type_archive' == $instance['query'] || 'post_type' == $instance['query'] ? ' show' : '')); $options = array(); $post_types = enlightenment_custom_post_types(); foreach ($post_types as $post_type => $atts) { $options[$post_type] = $atts['name']; } enlightenment_select_box(array('label' => __('Post Type:', 'enlightenment'), 'name' => $this->get_field_name('post_type'), 'class' => 'widefat', 'id' => $this->get_field_id('post_type'), 'options' => $options, 'value' => $instance['post_type'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'post-type' . ('post_type' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('post_type' => esc_attr($instance['post_type']), 'posts_per_page' => -1)); $options = array(); foreach ($posts as $post) { $options[$post->ID] = get_the_title($post->ID); } enlightenment_select_box(array('label' => __('Post:', 'enlightenment'), 'name' => $this->get_field_name('p'), 'class' => 'widefat', 'id' => $this->get_field_id('p'), 'options' => $options, 'value' => $instance['p'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'page' . ('page' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'page')); $options = array(); foreach ($posts as $post) { $options[$post->ID] = get_the_title($post->ID); } enlightenment_select_box(array('label' => __('Page:', 'enlightenment'), 'name' => $this->get_field_name('page_id'), 'class' => 'widefat', 'id' => $this->get_field_id('page_id'), 'options' => $options, 'value' => $instance['page_id'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('div', 'pages' . ('pages' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'page')); $boxes = array(); $i = 0; foreach ($posts as $post) { $boxes[$i] = array(); $boxes[$i]['label'] = get_the_title($post->ID); $boxes[$i]['name'] = $this->get_field_name('pages') . '[' . $post->ID . ']'; $boxes[$i]['checked'] = in_array($post->ID, $instance['pages']); $i++; } echo '<label>' . __('Select Pages:', 'enlightenment') . '</label><br />'; echo enlightenment_open_tag('div', 'pages-inner'); enlightenment_checkboxes(array('boxes' => $boxes, 'value' => $instance['p'])); echo enlightenment_close_tag('div'); echo enlightenment_close_tag('div'); echo enlightenment_open_tag('p', 'image-gallery' . ('gallery' == $instance['query'] ? ' show' : '')); enlightenment_upload_media(array('name' => $this->get_field_name('images'), 'upload_button_text' => __('Choose Images', 'enlightenment'), 'uploader_title' => __('Insert Images', 'enlightenment'), 'uploader_button_text' => __('Select', 'enlightenment'), 'remove_button_text' => '', 'mime_type' => 'image', 'multiple' => true, 'thumbnail' => null, 'value' => implode(',', $instance['images']))); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'author' . ('author' == $instance['query'] ? ' show' : '')); $authors = get_users(array('who' => 'authors')); $options = array(); foreach ($authors as $author) { $options[$author->ID] = $author->display_name; } enlightenment_select_box(array('label' => __('Select Author:', 'enlightenment'), 'name' => $this->get_field_name('author'), 'class' => 'widefat', 'id' => $this->get_field_id('author'), 'options' => $options, 'value' => $instance['author'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'taxonomy' . ('taxonomy' == $instance['query'] ? ' show' : '')); $taxonomies = get_taxonomies(array('public' => true), 'objects'); $options = array(); foreach ($taxonomies as $name => $taxonomy) { if ('post_format' == $name) { $taxonomy->labels->singular_name = __('Post Format', 'enlightenment'); } $options[$name] = $taxonomy->labels->singular_name; } enlightenment_select_box(array('label' => __('Taxonomy:', 'enlightenment'), 'name' => $this->get_field_name('taxonomy'), 'class' => 'widefat', 'id' => $this->get_field_id('taxonomy'), 'options' => $options, 'value' => $instance['taxonomy'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'term' . ('taxonomy' == $instance['query'] ? ' show' : '')); $terms = get_terms($instance['taxonomy']); $options = array(); foreach ($terms as $term) { $options[$term->slug] = $term->name; } enlightenment_select_box(array('label' => __('Term:', 'enlightenment'), 'name' => $this->get_field_name('term'), 'class' => 'widefat', 'id' => $this->get_field_id('term'), 'options' => $options, 'value' => $instance['term'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'posts-count' . ('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query'] ? ' show' : '')); enlightenment_text_input(array('label' => __('Total number of entries:', 'enlightenment'), 'name' => $this->get_field_name('posts_per_page'), 'id' => $this->get_field_id('posts_per_page'), 'value' => $instance['posts_per_page'], 'size' => 3)); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'lead-posts' . ('slider' != $instance['type'] && 'carousel' != $instance['type'] && ('sticky_posts' == $instance['query'] || 'post_type_archive' == $instance['query'] || 'pages' == $instance['query'] || 'gallery' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query']) ? ' show' : '')); enlightenment_text_input(array('label' => __('Number of leading entries:', 'enlightenment'), 'name' => $this->get_field_name('leading_posts'), 'id' => $this->get_field_id('leading_posts'), 'value' => $instance['leading_posts'], 'size' => 3)); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'archive-link' . ('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query'] ? ' show' : '')); enlightenment_checkbox(array('label' => __('Show Link to Archive', 'enlightenment'), 'name' => $this->get_field_name('link_to_archive'), 'id' => $this->get_field_id('link_to_archive'), 'checked' => $instance['link_to_archive'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'archive-link-label' . (('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query']) && $instance['link_to_archive'] ? ' show' : '')); enlightenment_text_input(array('label' => __('Link to Archive Label:', 'enlightenment'), 'name' => $this->get_field_name('link_to_archive_label'), 'class' => 'widefat', 'id' => $this->get_field_id('link_to_archive_label'), 'value' => $instance['link_to_archive_label'])); echo enlightenment_close_tag('p'); ?> <script> jQuery(document).ready(function($) { $('.type select').change(function() { var container = $(this).closest('.widget-content'); var val = $(this).val(); if(val == 'slider' || val == 'carousel') $('.lead-posts', container).hide(); else { var query = $('.query select', container).val(); if(query == 'post_type' || query == 'page') $('.lead-posts', container).hide(); else $('.lead-posts', container).show(); } }); $('.query select').change(function() { var container = $(this).closest('.widget-content'); var val = $(this).val(); var type = $('.type select', container).val(); if(val == 'sticky_posts') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'post_type_archive') { $('.post-types', container).show(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } else if(val == 'post_type') { $('.post-types', container).show(); $('.post-type', container).show(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); $('.lead-posts', container).hide(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'page') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).show(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); $('.lead-posts', container).hide(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'pages') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).show(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'gallery') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).show(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'author') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).show(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } else if(val == 'taxonomy') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).show(); $('.term', container).show(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } }); $('.post-types select').change(function() { var container = $(this).closest('.widget-content'); var data = { action: 'enlightenment_ajax_get_post_types', post_type: $('.post-types select', container).val(), name: '<?php echo $this->get_field_name('p'); ?> ', id: '<?php echo $this->get_field_id('p'); ?> ', value: '<?php echo $instance['p']; ?> ', } $.post(ajaxurl, data, function(r) { var html = document.createElement( 'div' ); $(html).html(r); $('.post-type select', container).html($('select', $(html)).html()); }); }); $('.taxonomy select').change(function() { var container = $(this).closest('.widget-content'); var data = { action: 'enlightenment_ajax_get_terms', taxonomy: $('.taxonomy select', container).val(), name: '<?php echo $this->get_field_name('term'); ?> ', id: '<?php echo $this->get_field_id('term'); ?> ', value: '<?php echo $instance['term']; ?> ', } $.post(ajaxurl, data, function(r) { var html = document.createElement( 'div' ); $(html).html(r); $('.term', container).remove(); $('.taxonomy', container).after($(html).html()); }); }); $('.archive-link input').each(function() { var container = $(this).closest('.widget-content'); var query = $('.query select', container).val(); if( query == 'post_type_archive' || query == 'author' || query == 'taxonomy' ) { if($(this).is(':checked')) $('.archive-link-label', container).show(); else $('.archive-link-label', container).hide(); } }); $('.archive-link input').change(function() { var container = $(this).closest('.widget-content'); if($(this).is(':checked')) $('.archive-link-label', container).show(); else $('.archive-link-label', container).hide(); }); }); </script> <?php }