<?php /** * Delivers the HTML for editor dialogs through wp_ajax. * * Editor dialogs api. * * * * @since 0.8.1 * @package wp-ui * @subpackage editor-dialogs **/ global $wpui_skins_list; $wpui_skins_list = wpui_get_skins_list(); add_action('admin_footer', 'wpui_editor_container_inputs'); function wpui_editor_container_inputs() { global $pagenow; $wpui_editor_script_pages = apply_filters('wpui_editor_script_pages', array('post-new.php', 'page-new.php', 'post.php', 'page.php')); if (in_array(basename($_SERVER['PHP_SELF']), $wpui_editor_script_pages) && (current_user_can('edit_posts') && current_user_can('edit_pages'))) { $wpuiMNonce = wp_create_nonce('wpui_editor_ajax_dialog_nonce'); $wpuiPNonce = wp_create_nonce('wpui-editor-post-nonce'); $wpuiTNonce = wp_create_nonce('wpui-editor-tax-nonce'); ?> <div style="display:none; !important" id="wpui-editor-dialog"></div> <div style="display:none; !important" id="_wpui-editor-dialog"> <input type="hidden" id="wpui-editor-main-nonce" value="<?php echo $wpuiMNonce; ?> " />
function form($instance) { $defaults = array('title' => 'WP UI Widget', 'type' => 'tabs', 'number' => 4, 'style' => 'default'); $instance = wp_parse_args((array) $instance, $defaults); ?> <div class="wpui-base-widget-options"> <!-- .wpui-widget-input-group --> <div class="wpui-widget-input-group"> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e("Title"); ?> </label> <input id="<?php echo $this->get_field_id('title'); ?> " size="10" class="widefat" name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " style="width:auto;" /> </div> <!-- /.wpui-widget-input-group --> <?php // Type of widget. ?> <!-- .wpui-widget-input-group --> <div class="wpui-widget-input-group"> <label for="<?php echo $this->get_field_id('type'); ?> "><?php _e("Type"); ?> </label> <select name="<?php echo $this->get_field_name('type'); ?> " id="<?php echo $this->get_field_id('type'); ?> "> <option value="tabs" <?php selected($instance['type'], 'tabs'); ?> >Tabs</option> <option value="accordion" <?php selected($instance['type'], 'accordion'); ?> >Accordion</option> <option value="spoiler" <?php selected($instance['type'], 'spoiler'); ?> >Spoilers</option> </select> </div> <!-- /.wpui-widget-input-group --> <?php // Number of pages. ?> <!-- .wpui-widget-input-group --> <div class="wpui-widget-input-group"> <label for="<?php echo $this->get_field_id('number'); ?> "><?php _e("Number", 'wp-ui'); ?> </label> <select id="<?php echo $this->get_field_id('number'); ?> " name="<?php echo $this->get_field_name('number'); ?> "> <?php for ($a = 2; $a < 10; $a++) { ?> <option value="<?php echo $a; ?> " <?php selected($instance['number'], $a); ?> ><?php echo $a; ?> </option> <?php } ?> </select> </div> <!-- /.wpui-widget-input-group --> <?php // Skins. $skins_list = wpui_get_skins_list(); ?> <!-- .wpui-widget-input-group --> <div class="wpui-widget-input-group"> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e("Style", 'wp-ui'); ?> </label> <select id="<?php echo $this->get_field_id('style'); ?> " name="<?php echo $this->get_field_name('style'); ?> "> <option value="default">Default</option> <?php foreach ($skins_list as $skin => $name) { if (stristr($skin, 'startoptgroup')) { echo '<optgroup label="' . $name . '">'; } else { if (stristr($skin, 'endoptgroup')) { echo '</optgroup>'; } else { $sel = $instance['style'] == $skin ? ' selected="selected"' : ''; echo '<option value="' . $skin . '"' . $sel . '>' . $name . '</option>'; } } } ?> </select> </div> <!-- /.wpui-widget-input-group --> <!-- .wpui-widget-input-group --> <div class="wpui-widget-input-group"> <label for="<?php echo $this->get_field_id('arguments'); ?> ">Additional Arguments for the main shortcode</label><input type="text" class="widefat" name="<?php echo $this->get_field_name('arguments'); ?> " value="<?php echo $instance['arguments']; ?> " id="<?php echo $this->get_field_id('arguments'); ?> " > </div> <!-- /.wpui-widget-input-group --> </div><!-- /.wpui-base-widget-options --> <?php }
<?php require_once dirname(__FILE__) . '/admin-options.php'; $wpui_options = get_option('wpUI_options'); $wpui_skins_list_pre = wpui_get_skins_list(); global $wpui_options_list; // $wpui_option_page->set_sections($sects); $wpui_options_list = array('enable_tabs' => array('id' => 'enable_tabs', 'title' => __('Tabs', 'wp-ui'), 'desc' => __('Enable', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'enable_accordion' => array('id' => 'enable_accordion', 'title' => __('Accordions', 'wp-ui'), 'desc' => __('Enable', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'enable_spoilers' => array('id' => 'enable_spoilers', 'title' => __('Enable Collapsibles', 'wp-ui'), 'desc' => __('Enable', 'wp-ui'), 'type' => 'checkbox', 'section' => 'general'), 'enable_dialogs' => array('id' => 'enable_dialogs', 'title' => __('Dialogs', 'wp-ui'), 'desc' => __('Enable', 'wp-ui'), 'type' => 'checkbox', 'section' => 'general'), 'enable_quicktags_buttons' => array('id' => 'enable_quicktags_buttons', 'title' => __('HTML editor buttons', 'wp-ui'), 'desc' => __('Enable', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'topnav' => array('id' => 'topnav', 'title' => __('Top next/previous links', 'wp-ui'), 'desc' => __('Enable top navigation on tabs.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'general'), 'bottomnav' => array('id' => 'bottomnav', 'title' => __('Bottom next/previous links', 'wp-ui'), 'desc' => __('Enable bottom navigation on tabs.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'general'), 'enable_tinymce_menu' => array('id' => 'enable_tinymce_menu', 'title' => __('TinyMCE menu', 'wp-ui'), 'desc' => __('Enable.', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'enableWidgets' => array('id' => 'enable_widgets', 'title' => __('WP Widgets', 'wp-ui'), 'desc' => __('Enable wordpress widgets.', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'enableCacheWi' => array('id' => 'enable_cache', 'title' => __('Cache images and scripts', 'wp-ui'), 'desc' => __('Uncheck to disable the cache feature for thumbnail images and scripts. ', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'), 'load_all_styless' => array('id' => 'load_all_styles', 'title' => __('Load Multiple Styles', 'wp-ui'), 'desc' => sprintf(__('Load multiple css3 styles. %1$s Select your styles %2$s', 'wp-ui'), '<a href="#" id="wpui-combine-css3-files" class="button-secondary">', '</a>'), 'type' => 'checkbox', 'section' => 'style'), 'selected_styles' => array('id' => 'selected_styles', 'title' => __('Style selection', 'wp-ui'), 'desc' => __('Select styles you want to load.', 'wp-ui'), 'section' => 'style', 'type' => 'textarea', 'textarea_size' => array('cols' => '10', 'rows' => '5', 'autocomplete' => 'off')), 'tabstyle' => array('id' => 'tab_scheme', 'title' => __('Default style<br /><small>All widgets</small>', 'wp-ui'), 'desc' => __('Select a <u>default</u> style. Shortcode argument "style" overrides.<br /> ex. <code>[wptabs style="wpui-quark"]</code>', 'wp-ui'), 'type' => 'select', 'section' => 'style', 'choices' => $wpui_skins_list_pre, 'extras' => '' . __('Preview ', 'wp-ui') . '<a id="wpui_styles_preview" href="" class="button-secondary">' . __('WP UI CSS3 Styles', 'wp-ui') . '</a> <a id="jqui_styles_preview" href="#" class="button-secondary">' . __('jQuery UI themes', 'wp-ui') . '</a>'), 'jqui_custom' => array('id' => 'jqui_custom_themes', 'title' => __('jQuery UI custom themes<br /><small>Manage Custom themes. Not sure? <a target="_blank" href="http://kav.in/wp-ui-using-jquery-ui-custom-themes/">follow this guide</a>.</small>'), 'desc' => '<div id="jqui_theme_list" ></div><a href="#" class="button-secondary" title="' . __('This will scan the directory wp-ui under uploads for themes.', 'wp-ui') . '" id="jqui_scan_uploads">' . __('Scan Uploads', 'wp-ui') . '</a> <a href="#" class="button-secondary" id="jqui_add_theme">' . __('Add a theme/style', 'wp-ui') . '</a>', 'type' => 'textarea', 'section' => 'style', 'textarea_size' => array('cols' => '60', 'rows' => '5', 'autocomplete' => 'off')), 'custom_styles' => array('id' => 'custom_css', 'title' => __('Custom CSS', 'wp-ui'), 'desc' => __('Enter additional css rules here, taking care on the CSS syntax.', 'wp-ui'), 'type' => 'textarea', 'section' => 'style', 'textarea_size' => array('cols' => '60', 'rows' => '10')), 'dialog_wid' => array("id" => 'dialog_width', 'title' => __('Dialog Width', 'wp-ui'), 'desc' => __('Default width of dialogs with the suffix', 'wp-ui') . '( px | em | % )', 'type' => 'text', 'section' => 'style'), 'tabsfx' => array('id' => 'tabsfx', 'title' => __('Tabs effects', 'wp-ui'), 'desc' => __('Tabs show effect.', 'wp-ui'), 'type' => 'select', 'section' => 'effects', 'choices' => array('none' => 'None', 'slideDown' => 'Slide down', 'fadeIn' => 'Fade In')), 'fxSpeed' => array('id' => 'fx_speed', 'title' => __('Effect speed', 'wp-ui'), 'desc' => __("Enter the animation speed. Larger number - slow, smaller number - quick. Example - 200, 600, 900, 'fast', 'slow'.", 'wp-ui'), 'type' => 'text', 'section' => 'effects'), 'tabsrotate' => array('id' => 'tabs_rotate', 'title' => __('Tabs rotation', 'wp-ui'), 'desc' => __('Behavior on auto rotation. Rotation can be enabled with shortcode attribute "rotate". Example : ', 'wp-ui') . '<code>[wptabs rotate="6000"]</code> or <code>[wptabs rotate="6s"]</code>', 'type' => 'select', 'section' => 'effects', 'choices' => array('disable' => __('None', 'wp-ui'), 'always' => __('Keep rotating', 'wp-ui'), 'stop' => __('Stop on Click', 'wp-ui'))), 'tabz_event' => array('id' => 'tabs_event', 'title' => __('Tabs trigger event', 'wp-ui'), 'desc' => __('Open Tabs on click or mouseover.', 'wp-ui'), 'type' => 'select', 'section' => 'effects', 'choices' => array('click' => __('Click', 'wp-ui'), 'mouseover' => __('Mouseover', 'wp-ui'))), 'collapsible_tabbies' => array('id' => 'collapsible_tabs', 'title' => __('Collapsible Tabs', 'wp-ui'), 'desc' => __('Enable all panels in a tabset to be collapsed.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'effects'), 'accord_event' => array('id' => 'accord_event', 'title' => __('Accordion trigger event', 'wp-ui'), 'desc' => __('Open accordion on click or mouseover.', 'wp-ui'), 'type' => 'select', 'section' => 'effects', 'choices' => array('click' => __('Click', 'wp-ui'), 'mouseover' => __('Mouseover', 'wp-ui'))), 'accordion_autoheight' => array('id' => 'accord_autoheight', 'title' => __('Accordion auto height', 'wp-ui'), 'desc' => __('Uniform accordion panel height.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'effects'), 'collapsible_accordions' => array('id' => 'accord_collapsible', 'title' => __('Collapsible Accordions', 'wp-ui'), 'desc' => __('Enable all sections of accordion to be closed, and at load.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'effects'), 'accord_Easing' => array('id' => 'accord_easing', 'title' => __('Easing for the Accordion', 'wp-ui'), 'desc' => __('Optional : easing effect on accordion animation', 'wp-ui'), 'section' => 'effects', 'type' => 'select', 'choices' => array("false" => "disable", "linear" => "linear", "swing" => "swing", "easeInQuad" => "easeInQuad", "easeOutQuad" => "easeOutQuad", "easeInOutQuad" => "easeInOutQuad", "easeInCubic" => "easeInCubic", "easeOutCubic" => "easeOutCubic", "easeInOutCubic" => "easeInOutCubic", "easeInQuart" => "easeInQuart", "easeOutQuart" => "easeOutQuart", "easeInOutQuart" => "easeInOutQuart", "easeInQuint" => "easeInQuint", "easeOutQuint" => "easeOutQuint", "easeInOutQuint" => "easeInOutQuint", "easeInSine" => "easeInSine", "easeOutSine" => "easeOutSine", "easeInOutSine" => "easeInOutSine", "easeInExpo" => "easeInExpo", "easeOutExpo" => "easeOutExpo", "easeInOutExpo" => "easeInOutExpo", "easeInCirc" => "easeInCirc", "easeOutCirc" => "easeOutCirc", "easeInOutCirc" => "easeInOutCirc", "easeInElastic" => "easeInElastic", "easeOutElastic" => "easeOutElastic", "easeInOutElastic" => "easeInOutElastic", "easeInBack" => "easeInBack", "easeOutBack" => "easeOutBack", "easeInOutBack" => "easeInOutBack", "easeInBounce" => "easeInBounce", "easeOutBounce" => "easeOutBounce", "easeInOutBounce" => "easeInOutBounce")), 'mousewheel_tabs' => array('id' => 'mouse_wheel_tabs', 'title' => __('Tabs mousewheel navigation', 'wp-ui'), 'desc' => __('Scroll and switch between tabs.', 'wp-ui'), 'section' => 'effects', 'type' => 'select', 'choices' => array("false" => "disable", "list" => "On List", "panels" => "On Panels")), 'tab_nav_prev' => array('id' => 'tab_nav_prev_text', 'title' => __('Previous tab - button text<br /><small>Tabs Navigation</small>', 'wp-ui'), 'desc' => __('Tabs previous button. Default is "Previous".', 'wp-ui'), 'section' => 'text', 'type' => 'text'), 'tab_nav_next' => array('id' => 'tab_nav_next_text', 'title' => __('Next tab - button text<br /><small>Tabs Navigation</small>', 'wp-ui'), 'desc' => __('Tabs Next button. Default is "Next". ', 'wp-ui'), 'section' => 'text', 'type' => 'text'), 'showtext' => array('id' => 'spoiler_show_text', 'title' => __('Closed WP Spoiler text', 'wp-ui'), 'desc' => __('Displayed on hovering over collapsed spoiler\'s header. Leave blank to disable.', 'wp-ui'), 'section' => 'text', 'type' => 'textarea', 'textarea_size' => array('cols' => '60', 'rows' => '2')), 'hidetext' => array('id' => 'spoiler_hide_text', 'title' => __('Open WP spoiler text', 'wp-ui'), 'desc' => __('Displayed on hovering over header on open spoiler.', 'wp-ui'), 'section' => 'text', 'type' => 'textarea', 'textarea_size' => array('cols' => '60', 'rows' => '2')), 'bleeding_edge' => array('id' => 'bleeding_edge', 'title' => __('Old version', 'wp-ui'), 'desc' => __('Use old scripts instead of the rewritten API.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'advanced'), 'jquery_include' => array('id' => 'jquery_disabled', 'title' => __('Donot load the jQuery copy', 'wp-ui'), 'desc' => __('Check this box to prevent loading jQuery & UI libs from Google CDN. <br /> <br />Please note: Recent versions of jQuery and jQuery UI javascript libraries are required for the functionality of WP UI. This Plugin\'s components might <b>not</b> work as expected with the older versions of jQuery and UI.', 'wp-ui'), 'type' => 'checkbox', 'section' => 'advanced'), 'script_cond' => array('id' => 'script_conditionals', 'title' => __('Conditional script load logic', 'wp-ui'), 'desc' => __('Use <a href="http://codex.wordpress.org/Conditional_Tags" title="Learn more on Wordpress conditional tags on Codex" target="_blank">wordpress conditional tags</a> to load limit/prevent scripts from loading. <font style="" <br><strong>Examples</strong> - <br><ul style="list-style: disc inside none"> <li>To load only on single pages, input <code>is_single()</code>, similarly <code>is_front_page()</code> to load only on frontpage.</li> <li><code>!is_page()</code> disables it on all pages.</li><li>Use <code>||</code> (or) or <code>&&</code> operators to define a complex conditional clause. <code>is_single() && is_page( \'about\' ) && in_category( array( 1,2,3 ) ) </li></ul>', 'wp-ui'), 'type' => 'textarea', 'section' => 'advanced', 'textarea_size' => array('cols' => '60', 'rows' => '2')), "scripts_adv" => array('id' => 'load_scripts_on_demand', 'title' => __('Demand load scripts', 'wp-ui'), 'desc' => __('Load needed components on demand. With jQuery. This scripts are significantly newer versions than the regular ones.'), 'type' => 'checkbox', 'section' => 'advanced'), "cookies" => array('id' => 'use_cookies', 'title' => __('Use cookies for tabs', 'wp-ui'), 'desc' => __('WP UI makes use of cookies to remember the state of the selected tabs. Click here to disable the behavior. jQuery cookie plugin by Klaus Hartl.'), 'type' => 'checkbox', 'section' => 'advanced'), "link_hist" => array('id' => 'linking_history', 'title' => __('Linking and History', 'wp-ui'), 'desc' => __('Uncheck here to disable history and linking. jQuery BBQ plugin by Ben Alman.'), 'type' => 'checkbox', 'section' => 'advanced'), 'doc_write_fix' => array('id' => 'docwrite_fix', 'title' => __('Blank page fix<br /><small>document.write issue</small>', 'wp-ui'), 'desc' => __('Enable to fix the blank page issue that results when including other scripts within tabs/accordion<br> <small>Known scripts : Twitter profile widget, e-commerce widgets. </small>', 'wp-ui'), 'type' => 'checkbox', 'section' => 'advanced'), 'relative_timez' => array('id' => 'relative_times', 'title' => __('Relative time', 'wp-ui'), 'desc' => __('Display relative time on posts retrieved by WP UI.', 'wp-ui') . '<code>Example : 9 days ago.</code>', 'type' => 'checkbox', 'section' => 'posts'), 'excerpt_length' => array('id' => 'excerpt_length', 'title' => __('Default excerpt length', 'wp-ui'), 'desc' => __('Maximum limit for the excerpts. Default is upto the ', 'wp-ui') . ' <code><!--more--></code>', 'type' => 'text', 'section' => 'posts'), 'postss_widgets' => array('id' => 'post_widget', 'type' => 'multiple', 'title' => __('Post widget', 'wp-ui'), 'desc' => __('Popular/Recent/Random/Related posts can be shown at end of each post.', 'wp-ui'), 'section' => 'posts', 'fields' => array(array('idkey' => 'title', 'type' => 'textinput', 'desc' => '', 'text_length' => '40', 'enclose' => array('before' => 'Title : ', 'after' => '<br /><br />')), array('idkey' => 'type', 'type' => 'select', 'desc' => __('Type of posts shown', 'wp-ui'), 'choices' => array("popular" => __("Popular", 'wp-ui'), "recent" => __("Recent", 'wp-ui'), "related" => __('Related', 'wp-ui'), "random" => __('Random', 'wp-ui')), 'enclose' => array('before' => ' Type', 'after' => '')), array('idkey' => 'number', 'type' => 'textinput', 'desc' => 'Number', 'text_length' => '3', 'enclose' => array('before' => ' Number of posts', 'after' => '')), array('idkey' => 'per_row', 'type' => 'select', 'desc' => 'Per row', 'choices' => array(2 => ' 2 ', 3 => ' 3 ', 4 => ' 4 '), 'enclose' => array('before' => ' Per row', 'after' => '')))), 'post_widgets_image' => array('id' => 'post_default_thumbnail', 'title' => __('Default thumbnail image', 'wp-ui'), 'desc' => __('The default image in case, post thumbnail is not available.', 'wp-ui'), 'type' => 'multiple', 'section' => 'posts', 'fields' => array(array('idkey' => 'url', 'type' => 'media-upload', 'desc' => '', 'text_length' => 18, 'enclose' => array('before' => 'Upload a file or select one<br />', 'after' => ' ')), array('idkey' => 'width', 'type' => 'textinput', 'text_length' => '3', 'desc' => '', 'enclose' => array('before' => 'Width : ', 'after' => ' ')), array('idkey' => 'height', 'type' => 'textinput', 'text_length' => '3', 'desc' => '', 'enclose' => array('before' => 'Height : ', 'after' => '<br />')))), 'title_templateu' => array('id' => 'title_template', 'title' => __('Title template', 'wp-ui') . '<br /><small>' . __('Tabs/accordion/spoiler title template.', 'wp-ui') . '</small>', 'desc' => __('Modify the template structure here. Use the variables within curled brackets. Click the top-right [help] link->Posts for reference.'), 'type' => 'textarea', 'section' => 'posts', 'textarea_size' => array('cols' => '60', 'rows' => '1', 'autocomplete' => 'off')), 'post_template_one' => array('id' => 'post_template_1', 'title' => __('Template 1', 'wp-ui') . '<br /><small>' . __('Usually the default for the Tabs and accordions on posts/feeds', 'wp-ui') . '</small>', 'desc' => __('Modify the template structure here. Use the variables within curled brackets. Click the top-right help link->Posts for reference.'), 'type' => 'textarea', 'section' => 'posts', 'textarea_size' => array('cols' => '60', 'rows' => '10', 'autocomplete' => 'off')), 'post_template_two' => array('id' => 'post_template_2', 'title' => __('Template 2', 'wp-ui') . '<br /><small>' . __('Usually the default for spoilers and dialogs', 'wp-ui') . '</small>', 'desc' => __('Modify the template structure here. Use the variables within curled brackets.'), 'type' => 'textarea', 'section' => 'posts', 'textarea_size' => array('cols' => '60', 'rows' => '10', 'autocomplete' => 'off')), 'miscellaneous' => array('id' => 'misc_options', 'title' => __('Other options', 'wp-ui'), 'desc' => __('Newline separated options', 'wp-ui'), 'type' => 'textarea', 'section' => 'advanced', 'textarea_size' => array('cols' => '50', 'rows' => '5', 'autocomplete' => 'off'))); if (!wpui_less_33()) { $wpui_options_list['wpui_tour'] = array('id' => 'tour', 'title' => __('View Tour', 'wp-ui'), 'desc' => __('View editor page tour to learn more about WP UI.', 'wp-ui'), 'section' => 'general', 'type' => 'checkbox'); } /** * Like preg_grep wildcard search, but this searches keys. */ function preg_grep_keys($pattern, $array) { if (!is_array($array)) { return; } $results = preg_grep($pattern, array_keys($array)); if (empty($results)) { return false; } $resultArr = array(); foreach ($results as $result) { $resultArr[$result] = $array[$result]; } return $resultArr; } // end function preg_grep_keys /**
function form($instance) { $defaults = array('title' => '', 'type' => 'cat', 'wid_type' => 'tabs', 'selected' => '', 'names' => '', 'template' => 1, 'style' => 'default'); $instance = wp_parse_args((array) $instance, $defaults); ?> <div class="wpui-left-block"> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e("Title"); ?> :</label> <input id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </p> <p> <select id="<?php echo $this->get_field_id('wid_type'); ?> " name="<?php echo $this->get_field_name('wid_type'); ?> "> <option value="tabs" <?php selected($instance['wid_type'], 'tabs'); ?> >Tabs</option> <option value="accordion"<?php selected($instance['wid_type'], 'accordion'); ?> >Accordion</option> </select> </p> <p> <?php $skins_list = wpui_get_skins_list(); ?> <select id="<?php echo $this->get_field_name('style'); ?> " name="<?php echo $this->get_field_id('style'); ?> "> <option value="default">Default</option> <?php foreach ($skins_list as $skin => $name) { if (stristr($skin, 'startoptgroup')) { echo '<optgroup label="' . $name . '">'; } else { if (stristr($skin, 'endoptgroup')) { echo '</optgroup>'; } else { if ($instance['style'] == $skin) { $sel = ' selected="selected"'; } echo '<option value="' . $skin . '"' . $sel . '>' . $name . '</option>'; } } } ?> </select> </p> <p> <label for="<?php echo $this->get_field_name('template'); ?> ">Template no.</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('template'); ?> " name="<?php echo $this->get_field_name('template'); ?> " value="<?php echo $instance['template']; ?> "/> </p> </div> <div class="wpui-search-posts wpui-right-block"> <input type="text" length="10" id="wpui-search-field" name="wpui-search-field" value="" class="widefat" /> <select class="wpui-search-type" id="<?php echo $this->get_field_id('type'); ?> " name="<?php echo $this->get_field_name('type'); ?> " value="<?php echo $instance['type']; ?> "> <option value="cat" <?php selected($instance['type'], 'cat'); ?> >Categories</option> <option value="tag" <?php selected($instance['type'], 'tag'); ?> >Tag</option> <option value="recent" <?php selected($instance['type'], 'recent'); ?> >Recent</option> <option value="popular" <?php selected($instance['type'], 'popular'); ?> >Popular</option> <option value="random" <?php selected($instance['type'], 'random'); ?> >Random</option> </select> <input type="text" id="wpui-search-number" class="widefat" name="wpui-search-number" style="width : 30px;" value="5" /> <?php $wpuiTNonce = wp_create_nonce('wpui-editor-tax-nonce'); ?> <input type="hidden" id="wpui-editor-tax-nonce" value="<?php echo $wpuiTNonce; ?> "> <input type="text" class="wpui-selected" id="<?php echo $this->get_field_id('selected'); ?> " name="<?php echo $this->get_field_name('selected'); ?> " value="<?php echo $instance['selected']; ?> "/> <input type="button" id="wpui-fake-submit" value="Search" class="button-secondary" style="width : 280px; border-radius : 3px; margin:5px 0;" /> <div class="wpui-search-results"> <ul class="wpui-search-results-list"><li>Type your query and search.</li></ul> </div> <label for="<?php echo $this->get_field_name('names'); ?> ">Names for the tabs, separated by commas. This should match the number of posts selected. </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('names'); ?> " name="<?php echo $this->get_field_name('names'); ?> " value="<?php echo $instance['names']; ?> " /> </div> <div style="clear : both;"></div> <style type="text/css"> div.wpui-left-block {float: left;width : 150px;padding : 10px;} div.wpui-right-block { float: right; width : 310px; padding : 10px; clear : right;} #wpui-search-field { width : 170px; } .wpui-search-results { background : #FFF; border : 1px solid #DFDFDF; height : 185px; margin : 0 5px 5px; overflow : auto; position : relative; overflow : auto;} .wpui-search-results ul.wpui-search-results-list { list-style : none;} .wpui-search-results ul.wpui-search-results-list li { border-bottom: 1px solid #F1F1F1; padding : 4px 6px; position : relative; cursor : pointer; margin-bottom : 0;} .wpui-search-results ul.wpui-search-results-list li.selected { background : #DDD; font-weight : bold !important; } .wpui-search-results ul.wpui-search-results-list li a { text-decoration : none; color : #777; text-shadow: 0 1px 0 #FFF; display : block; width : 300px; overflow : hide;} span.info { position : absolute; top : 0; right : 0; height: 100%; padding : 4px; } </style> <script type="text/javascript"> var wpuiGetPosts = function( el ) { var searchTerm = jQuery( el ).closest( '#wpui-search-field' ).val(), searchType=jQuery( el ).siblings( 'select.wpui-search-type' ).val(), searchNum = jQuery( el ).closest( '#wpui-search-number' ).val(), wpuiQuery; searchNum = searchNum || 5; if ( searchTerm == '' || searchType == '' ) return false; wpuiQuery = { action : 'wpui_query_meta', search : searchTerm, type : searchType, number : searchNum, _ajax_tax_nonce : jQuery( '#wpui-editor-tax-nonce' ).val() } jQuery.post( ajaxurl, wpuiQuery, function( data ) { jQuery( el ).next('div.wpui-search-results') .find( 'ul' ).html(data); thisVal = ''; jQuery( el ).next('div.wpui-search-results') .find( 'ul li' ) .unbind( 'click' ) .bind( 'click', function() { if ( jQuery( this ).hasClass( 'no-select') ) return false; thisVal = jQuery(this).find('a').attr('rel').replace( /(post|cat|tag)\-/, ''); jQuery( this ).toggleClass( 'selected' ); thisVal += ','; alSel = jQuery( el ).prev().val(); if ( alSel.match( thisVal ) ) alSel = alSel.replace( thisVal, '' ); else alSel += thisVal; jQuery( el ).prev().val( alSel ); return false; }); }); }; jQuery( function() { jQuery( '#wpui-fake-submit' ).live( 'click', function( e ) { wpuiGetPosts( this ); return false; }); jQuery( 'select.wpui-search-type' ).bind('change', function() { jQuery( this ).siblings( '.wpui-selected' ).val(''); jQuery( this ).siblings('input#wpui-fake-submit').click(); }); }); </script> <?php }
function form($instance) { $defaults = array('title' => '', 'type' => 'cat', 'wid_type' => 'tabs', 'selected' => '', 'names' => '', 'template' => 1, 'number' => 5, 'style' => 'default'); $instance = wp_parse_args((array) $instance, $defaults); ?> <div class="wpui-left-block"> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e("Title"); ?> :</label> <input id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </p> <p> <label for="<?php echo $this->get_field_id('wid_type'); ?> " title="Type of widget">Type</label> <select id="<?php echo $this->get_field_id('wid_type'); ?> " name="<?php echo $this->get_field_name('wid_type'); ?> "> <option value="tabs" <?php selected($instance['wid_type'], 'tabs'); ?> >Tabs</option> <option value="accordion"<?php selected($instance['wid_type'], 'accordion'); ?> >Accordion</option> </select> </p> <p> <label for="<?php echo $this->get_field_name('style'); ?> " title="Styling for this widget. Default is the one selected on the options page.">Style</label> <?php $skins_list = wpui_get_skins_list(); ?> <select id="<?php echo $this->get_field_name('style'); ?> " name="<?php echo $this->get_field_id('style'); ?> "> <option value="default">Default</option> <?php foreach ($skins_list as $skin => $name) { if (stristr($skin, 'startoptgroup')) { echo '<optgroup label="' . $name . '">'; } else { if (stristr($skin, 'endoptgroup')) { echo '</optgroup>'; } else { if ($instance['style'] == $skin) { $sel = ' selected="selected"'; } echo '<option value="' . $skin . '"' . $sel . '>' . $name . '</option>'; } } } ?> </select> </p> <p> <label title="Found on Options page -> Posts -> Template no." for="<?php echo $this->get_field_name('template'); ?> ">Template no.</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('template'); ?> " name="<?php echo $this->get_field_name('template'); ?> " value="<?php echo $instance['template']; ?> "/> </p> <p> <label title="Please don't alter this, unless you are sure. This will be the selected Taxonomy items separated with commas." for="<?php echo $this->get_field_name('selected'); ?> ">Currently Selected</label> <input type="text" class="widefat wpui-selected" id="<?php echo $this->get_field_id('selected'); ?> " name="<?php echo $this->get_field_name('selected'); ?> " value="<?php echo $instance['selected']; ?> "/> </p> <!-- <h3>Usage</h3> <ol> <li>Select the taxonomy - Category / tag ,or by type - Recent/Popular/Random posts.</li> <li>Click search and the categories or tags will be displayed in the list.</li> <li>Click on any of the list item to toggle selection.</li> <li>Optional : Enter the title of tabs or accordions, separated with commas ( but no spaces ) in the last box.</li> <li>Click save, and check the frontpage.</li> </ol> --> </div> <div class="wpui-search-posts wpui-right-block"> <label>Search term, type and number to display</label> <input type="text" length="10" id="wpui-search-field" name="wpui-search-field" value="" class="widefat" /> <select class="wpui-search-type" id="<?php echo $this->get_field_id('type'); ?> " name="<?php echo $this->get_field_name('type'); ?> " value="<?php echo $instance['type']; ?> "> <option value="cat" <?php selected($instance['type'], 'cat'); ?> >Categories</option> <option value="tag" <?php selected($instance['type'], 'tag'); ?> >Tag</option> <option value="recent" <?php selected($instance['type'], 'recent'); ?> >Recent</option> <option value="popular" <?php selected($instance['type'], 'popular'); ?> >Popular</option> <option value="random" <?php selected($instance['type'], 'random'); ?> >Random</option> </select> <!-- <input type="text" id="wpui-search-number" class="widefat" name="wpui-search-number" style="width : 30px;" value="5" /> --> <input type="text" id="<?php echo $this->get_field_id('number'); ?> " class="widefat" name="<?php echo $this->get_field_name('number'); ?> " style="width : 30px;" value="<?php echo $instance['number']; ?> " /> <?php $wpuiTNonce = wp_create_nonce('wpui-editor-tax-nonce'); ?> <input type="hidden" id="wpui-editor-tax-nonce" value="<?php echo $wpuiTNonce; ?> "> <input type="button" id="wpui-fake-submit" value="Search" class="button-secondary" style="width : 280px; border-radius : 3px; margin:5px 0;" /> <div class="wpui-search-results"> <ul class="wpui-search-results-list"><li>Type your query and search.</li></ul> </div> <label for="<?php echo $this->get_field_name('names'); ?> ">Names for the tabs, separated by commas. This should match the number of posts selected. </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('names'); ?> " name="<?php echo $this->get_field_name('names'); ?> " value="<?php echo $instance['names']; ?> " /> </div> <div style="clear : both;"></div> <style type="text/css"> div.wpui-left-block {float: left;width : 150px;padding : 10px;} div.wpui-right-block { float: right; width : 310px; padding : 10px; clear : right;} #wpui-search-field { width : 170px; } .wpui-search-results { background : #FFF; border : 1px solid #DFDFDF; height : 185px; margin : 0 5px 5px; overflow : auto; position : relative; overflow : auto;} .wpui-search-results ul.wpui-search-results-list { list-style : none;} .wpui-search-results ul.wpui-search-results-list li { border-bottom: 1px solid #F1F1F1; padding : 4px 6px; position : relative; cursor : pointer; margin-bottom : 0;} .wpui-search-results ul.wpui-search-results-list li.selected { background : #DDD; font-weight : bold !important; } .wpui-search-results ul.wpui-search-results-list li a { text-decoration : none; color : #777; text-shadow: 0 1px 0 #FFF; display : block; width : 300px; overflow : hide;} span.info { position : absolute; top : 0; right : 0; height: 100%; padding : 4px; } </style> <script type="text/javascript"> jQuery.fn.wpuiGetPosts = function( ) { var base = this; return base.each(function() { var $base = jQuery( this ), searchTerm = $base.closest( '#wpui-search-field' ), searchType = $base.siblings( 'select.wpui-search-type' ), searchNum = $base.closest( '#<?php echo $this->get_field_id("number"); ?> ' ), searchSel = $base.parent().prev().find( '.wpui-selected' ), prevSels, wpuiQuery, ajaxFunc ; searchNum = searchNum || 5; if ( searchTerm == '' || searchType == '' ) return false; function ajaxFunc( ) { wpuiQuery = { action : 'wpui_query_meta', search : searchTerm.val(), type : searchType.val(), number : searchNum.val(), _ajax_tax_nonce : jQuery( '#wpui-editor-tax-nonce' ).val() }; jQuery.post( ajaxurl, wpuiQuery, function( data ) { $base.next('div.wpui-search-results') .find( 'ul' ).html(data); if ( searchSel.val() != '' ) { prevSels = searchSel.val().split(','); for ( i=0; i < prevSels.length; i++ ) { $base.next('div.wpui-search-results') .find( 'ul li a[rel=' + searchType.val() + '-' + prevSels[i] + ']' ) .parent() .addClass('selected'); } } thisVal = ''; $base.next('div.wpui-search-results') .find( 'ul li' ) .unbind( 'click' ) .bind( 'click', function() { if ( jQuery( this ).hasClass( 'no-select') ) return false; thisVal = jQuery(this).find('a').attr('rel').replace( /(post|cat|tag)\-/, ''); jQuery( this ).toggleClass( 'selected' ); thisVal += ','; alSel = searchSel.val(); if ( alSel.match( thisVal ) ) alSel = alSel.replace( thisVal, '' ); else alSel += thisVal; searchSel.val( alSel ); return false; }); }); }; ajaxFunc( this ); $base.bind( 'click', function( e ) { ajaxFunc(); return false; }); $base.siblings( 'select.wpui-search-type' ).bind('change', function() { searchSel.val(''); ajaxFunc(); }); }); }; jQuery( function() { jQuery( '#widgets-right #wpui-fake-submit' ).wpuiGetPosts(); }); </script><?php }
<script src="<?php echo wpui_url(); ?> /js/wpui-styles-demo.js" type="text/javascript"></script> <script type="text/javascript"> if ( typeof wpuiJQ == 'undefined' ) { var wpuiJQ = jQuery.noConflict(); } // if ( typeof jQuery.fn.wpuiThemeSwitcher != 'undefined' ) { setTimeout(function () { jQuery( '#wpui-theme-switcher-trigger' ) .wpuiThemeSwitcher( <?php echo json_encode(wpui_get_skins_list()); ?> ); }, 200); // } var wpui_submit_form = function() { var win = window.dialogArguments || opener || parent || top; parent.jQuery( '#tab_scheme' ).val( document.forms[ 0 ].wpui_selected_style.value ); parent.jQuery.fn.colorbox.close(); parent.document.forms[ 0 ].submit(); return false; };