示例#1
0
    /**
     * Generator popup form
     */
    public static function popup()
    {
        // Get cache
        $output = get_transient('cherry_shortcodes/generator/popup');
        if ($output && CHERRY_SHORTCODES_ENABLE_CACHE) {
            echo $output;
        } else {
            ob_start();
            ?>
		<div id="cherry-generator-wrap" style="display:none">
			<div id="cherry-generator">
				<div id="cherry-generator-header">
					<input type="text" name="cherry_generator_search" id="cherry-generator-search" value="" placeholder="<?php 
            _e('Search for shortcodes', 'cherry-shortcodes');
            ?>
" />
					<div id="cherry-generator-filter">
						<strong><?php 
            _e('Filter by type', 'cherry-shortcodes');
            ?>
</strong>
						<?php 
            foreach ((array) Cherry_Shortcodes_Data::groups() as $group => $label) {
                echo '<a href="#" data-filter="' . $group . '">' . $label . '</a>';
            }
            ?>
					</div>
					<div id="cherry-generator-choices" class="cherry-generator-clearfix">
						<?php 
            // Choices loop
            foreach ((array) Cherry_Shortcodes_Data::shortcodes() as $name => $shortcode) {
                $icon = isset($shortcode['icon']) ? $shortcode['icon'] : 'puzzle-piece';
                $shortcode['name'] = isset($shortcode['name']) ? $shortcode['name'] : $name;
                echo '<span data-name="' . $shortcode['name'] . '" data-shortcode="' . $name . '" title="' . esc_attr($shortcode['desc']) . '" data-desc="' . esc_attr($shortcode['desc']) . '" data-group="' . $shortcode['group'] . '">' . Cherry_Shortcodes_Tools::icon($icon) . $shortcode['name'] . '</span>' . "\n";
            }
            ?>
					</div>
				</div>
				<div id="cherry-generator-settings"></div>
				<input type="hidden" name="cherry-generator-selected" id="cherry-generator-selected" value="<?php 
            echo plugins_url('', CHERRY_SHORTCODES_FILE);
            ?>
" />
				<input type="hidden" name="cherry-compatibility-mode-prefix" id="cherry-compatibility-mode-prefix" value="<?php 
            echo CHERRY_SHORTCODES_PREFIX;
            ?>
" />
				<div id="cherry-generator-result" style="display:none"></div>
			</div>
		</div>
	<?php 
            $output = ob_get_contents();
            set_transient('cherry_shortcodes/generator/popup', $output, 2 * DAY_IN_SECONDS);
            ob_end_clean();
            echo $output;
        }
    }