예제 #1
0
 public static function cheatsheet($field, $config)
 {
     // Prepare print button
     $print = '<div><a href="javascript:;" id="mom-su-cheatsheet-print" class="mom-su-cheatsheet-switch button button-primary button-large">' . __('Printable version', 'theme') . '</a><div id="mom-su-cheatsheet-print-head"><h1>' . __('Shortcodes Ultimate', 'theme') . ': ' . __('Cheatsheet', 'theme') . '</h1><a href="javascript:;" class="mom-su-cheatsheet-switch">&larr; ' . __('Back to Dashboard', 'theme') . '</a></div></div>';
     // Prepare table array
     $table = array();
     // Table start
     $table[] = '<table><tr><th style="width:20%;">' . __('Shortcode', 'theme') . '</th><th style="width:50%">' . __('Attributes', 'theme') . '</th><th style="width:30%">' . __('Example code', 'theme') . '</th></tr>';
     // Loop through shortcodes
     foreach ((array) mom_su_Data::shortcodes() as $name => $shortcode) {
         // Prepare vars
         $icon = isset($shortcode['icon']) ? $shortcode['icon'] : 'puzzle-piece';
         $shortcode['name'] = isset($shortcode['name']) ? $shortcode['name'] : $name;
         $attributes = array();
         $example = array();
         $icons = 'icon: music, icon: envelope &hellip; <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank">' . __('full list', 'theme') . '</a>';
         // Loop through attributes
         if (is_array($shortcode['atts'])) {
             foreach ($shortcode['atts'] as $id => $data) {
                 // Prepare default value
                 $default = isset($data['default']) && $data['default'] !== '' ? '<p><em>' . __('Default value', 'theme') . ':</em> ' . $data['default'] . '</p>' : '';
                 // Check type is set
                 if (empty($data['type'])) {
                     $data['type'] = 'text';
                 }
                 // Switch attribute types
                 switch ($data['type']) {
                     // Select
                     case 'select':
                         $value = implode(', ', array_keys($data['values']));
                         break;
                         // Slider and number
                     // Slider and number
                     case 'slider':
                     case 'number':
                         $value = $data['min'] . '&hellip;' . $data['max'];
                         break;
                         // Bool
                     // Bool
                     case 'bool':
                         $value = 'yes | no';
                         break;
                         // Icon
                     // Icon
                     case 'icon':
                         $value = $icons;
                         break;
                         // Color
                     // Color
                     case 'color':
                         $value = __('#RGB and rgba() colors');
                         break;
                         // Default value
                     // Default value
                     default:
                         $value = $data['default'];
                         break;
                 }
                 // Check empty value
                 if ($value === '') {
                     $value = __('Any text value', 'theme');
                 }
                 // Extra CSS class
                 if ($id === 'class') {
                     $value = __('Any custom CSS classes', 'theme');
                 }
                 // Add attribute
                 $attributes[] = '<div class="mom-su-shortcode-attribute"><strong>' . $data['name'] . ' <em>&ndash; ' . $id . '</em></strong><p><em>' . __('Possible values', 'theme') . ':</em> ' . $value . '</p>' . $default . '</div>';
                 // Add attribute to the example code
                 $example[] = $id . '="' . $data['default'] . '"';
             }
         }
         // Prepare example code
         $example = '[%prefix_' . $name . ' ' . implode(' ', $example) . ']';
         // Prepare content value
         if (empty($shortcode['content'])) {
             $shortcode['content'] = '';
         }
         // Add wrapping code
         if ($shortcode['type'] === 'wrap') {
             $example .= esc_textarea($shortcode['content']) . '[/%prefix_' . $name . ']';
         }
         // Change compatibility prefix
         $example = str_replace(array('%prefix_', '__'), mom_su_cmpt(), $example);
         // Shortcode
         $table[] = '<td>' . '<span class="mom-su-shortcode-icon">' . mom_su_Tools::icon($icon) . '</span>' . $shortcode['name'] . '<br/><em class="mom-su-shortcode-desc">' . $shortcode['desc'] . '</em></td>';
         // Attributes
         $table[] = '<td>' . implode('', $attributes) . '</td>';
         // Example code
         $table[] = '<td><code contenteditable="true">' . $example . '</code></td></tr>';
     }
     // Table end
     $table[] = '</table>';
     // Query assets
     mom_su_query_asset('css', array('font-awesome', 'mom-su-cheatsheet'));
     mom_su_query_asset('js', array('jquery', 'mom-su-options-page'));
     // Return output
     return '<div id="mom-su-cheatsheet-screen">' . $print . implode('', $table) . '</div>';
 }
예제 #2
0
    /**
     * Generator popup form
     */
    public static function popup()
    {
        // Get cache
        delete_transient('mom_su/generator/popup');
        $output = get_transient('mom_su/generator/popup');
        if ($output && mom_su_ENABLE_CACHE) {
            echo $output;
        } else {
            ob_start();
            $tools = apply_filters('mom_su/generator/tools', array('<a href="' . admin_url('admin.php?page=mom-shortcodes-ultimate') . '#tab-1" target="_blank" title="' . __('Settings', 'framework') . '">' . __('Plugin settings', 'framework') . '</a>', '<a href="http://gndev.info/mom-shortcodes-ultimate/" target="_blank" title="' . __('Plugin homepage', 'framework') . '">' . __('Plugin homepage', 'framework') . '</a>', '<a href="http://wordpress.org/support/plugin/mom-shortcodes-ultimate/" target="_blank" title="' . __('Support forums', 'framework') . '">' . __('Support forums', 'framework') . '</a>'));
            // Add add-ons links
            if (!mom_su_addon_active('maker') || !mom_su_addon_active('skins') || !mom_su_addon_active('extra')) {
                $tools[] = '<a href="' . admin_url('admin.php?page=mom-shortcodes-ultimate-addons') . '" target="_blank" title="' . __('Add-ons', 'framework') . '" class="mom-su-add-ons">' . __('Add-ons', 'framework') . '</a>';
            }
            ?>
		<div id="mom-su-generator-wrap" style="display:none">
			<div id="mom-su-generator">
				<div id="mom-su-generator-header">
					<input type="text" name="mom_su_generator_search" id="mom-su-generator-search" value="" placeholder="<?php 
            _e('Search for shortcodes', 'framework');
            ?>
" />
					<div id="mom-su-generator-filter">
						<strong><?php 
            _e('Filter by type', 'framework');
            ?>
</strong>
						<?php 
            foreach ((array) mom_su_Data::groups() as $group => $label) {
                echo '<a href="#" data-filter="' . $group . '">' . $label . '</a>';
            }
            ?>
					</div>
					<div id="mom-su-generator-choices" class="mom-su-generator-clearfix">
						<?php 
            // Choices loop
            foreach ((array) mom_su_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'] . '">' . mom_su_Tools::icon($icon) . $shortcode['name'] . '</span>' . "\n";
            }
            ?>
					</div>
				</div>
				<div id="mom-su-generator-settings"></div>
				<input type="hidden" name="mom-su-generator-selected" id="mom-su-generator-selected" value="<?php 
            echo plugins_url('', mom_su_PLUGIN_FILE);
            ?>
" />
				<input type="hidden" name="mom-su-generator-url" id="mom-su-generator-url" value="<?php 
            echo plugins_url('', mom_su_PLUGIN_FILE);
            ?>
" />
				<input type="hidden" name="mom-su-compatibility-mode-prefix" id="mom-su-compatibility-mode-prefix" value="<?php 
            echo mom_su_compatibility_mode_prefix();
            ?>
" />
				<div id="mom-su-generator-result" style="display:none"></div>
			</div>
		</div>
	<?php 
            $output = ob_get_contents();
            set_transient('mom_su/generator/popup', $output, 2 * DAY_IN_SECONDS);
            ob_end_clean();
            echo $output;
        }
    }