function aesop_shortcodes_blob() { $codes = aesop_shortcodes(); $blob = array(); foreach ($codes as $slug => $shortcode) { $return = ''; // Shortcode has atts if (count($shortcode['atts']) && $shortcode['atts']) { foreach ($shortcode['atts'] as $attr_name => $attr_info) { $prefix = isset($attr_info['prefix']) ? sprintf('<span class="aesop-option-prefix">%s</span>', $attr_info['prefix']) : null; $return .= '<p class="aesop-' . $slug . '-' . $attr_name . '">'; $return .= '<label for="aesop-generator-attr-' . $attr_name . '">' . $attr_info['desc'] . '</label>'; $return .= '<small class="aesop-option-desc">' . $attr_info['tip'] . '</small>'; // Select if (isset($attr_info['values'])) { $return .= '<select name="' . $attr_name . '" id="aesop-generator-attr-' . $attr_name . '" class="aesop-generator-attr">'; $i = 0; foreach ($attr_info['values'] as $attr_value) { $attr_value_selected = $attr_info['default'] == $attr_value ? ' selected="selected"' : ''; $return .= '<option value="' . $attr_info['values'][$i]['value'] . '" ' . $attr_value_selected . '>' . $attr_info['values'][$i]['name'] . '</option>'; $i++; } $return .= '</select>'; } else { $attr_field_type = isset($attr_info['type']) ? $attr_info['type'] : 'text'; // image upload if ('media_upload' == $attr_info['type']) { $return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="" id="aesop-generator-attr-' . $attr_name . '" class="aesop-generator-attr aesop-generator-attr-' . $attr_field_type . '" />'; $return .= '<input id="aesop-upload-img" type="button" class="button button-primary button-large" value="Select Media"/>'; } elseif ('color' == $attr_info['type']) { $return .= '<input type="color" name="' . $attr_name . '" value="' . $attr_info['default'] . '" id="aesop-generator-attr-' . $attr_name . '" class="aesop-generator-attr aesop-generator-attr-' . $attr_field_type . '" />'; } elseif ('text_area' == $attr_info['type']) { $return .= '<textarea type="' . $attr_field_type . '" name="' . $attr_name . '" value="" id="aesop-generator-attr-' . $attr_name . '" class="aesop-generator-attr aesop-generator-attr-' . $attr_field_type . '" />' . $prefix . ''; } else { $return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="" id="aesop-generator-attr-' . $attr_name . '" class="aesop-generator-attr aesop-generator-attr-' . $attr_field_type . '" />' . $prefix . ''; } } //end if $return .= '</p>'; } //end foreach } //end if // Single shortcode (not closed) if ('single' == $shortcode['type']) { $return .= '<input type="hidden" name="aesop-generator-content" id="aesop-generator-content" value="false" />'; } else { $return .= '<p><label>' . __('Content', 'aesop-core') . '</label><textarea type="text" name="aesop-generator-content" id="aesop-generator-content" value="' . $shortcode['content'] . '" /></p>'; } $return .= '<p class="aesop-buttoninsert-wrap"><a href="#" id="aesop-generator-insert"><span class="aesop-generator-button-insert">' . __('Insert Component', 'aesop-core') . '</span><span class="aesop-generator-button-update">' . __('Update Component', 'aesop-core') . '</span></a></p> '; $return .= '<input type="hidden" name="aesop-generator-result" id="aesop-generator-result" value="" />'; $blob[$slug] = $return; } //end foreach return $blob; }
/** * Draw the component generator * * @since 1.0.0 */ public function generator_popup() { global $pagenow; $aesop_generator_includes_pages = apply_filters('aesop_generator_loads_on', array('post.php', 'edit.php', 'post-new.php', 'index.php')); if (in_array($pagenow, $aesop_generator_includes_pages)) { ?> <div id="aesop-generator-wrap"> <div id="aesop-generator" class="aesop-generator-inner-wrap"> <a class="media-modal-close aesop-close-modal" href="#"><span class="media-modal-icon"><span class="screen-reader-text">Close media panel</span></span></a> <div id="aesop-generator-shell"> <div class="aesop-select-wrap fix aesop-generator-left"> <select name="aesop-select" class="aesop-generator" id="aesop-generator-select"> <?php foreach (aesop_shortcodes() as $name => $shortcode) { ?> <option value="<?php echo $name; ?> "><?php echo str_replace('_', ' ', strtoupper($name)); ?> </option> <?php } ?> </select> <?php if (!defined('AI_CORE_WATERMARK')) { echo self::messages(); } ?> </div> <div id="aesop-generator-settings-outer" class="aesop-generator-right"> <div id="aesop-generator-settings"> <div class="aesop-generator-empty"> <h2><?php _e('Select a story component.', 'aesop-core'); ?> </h2> </div> </div> </div> <input type="hidden" name="aesop-generator-url" id="aesop-generator-url" value="<?php echo AI_CORE_URL; ?> "/> <input type="hidden" name="aesop-compatibility-mode-prefix" id="aesop-compatibility-mode-prefix" value="aesop_"/> </div> </div> </div> <?php } //end if }
/** * Draw out the settings field based on the shortcodes array with options foudn in Lasso Story Engine * This was mostly backported from lasso story engine and modified to allow for non lasso shortcodes and components * * @since 1.0 */ function lasso_editor_options_blob() { $codes = function_exists('aesop_shortcodes') ? aesop_shortcodes() : apply_filters('lasso_custom_options', ''); $galleries = function_exists('lasso_editor_galleries_exist') && lasso_editor_galleries_exist() ? 'has-galleries' : 'creating-gallery'; $nonce = wp_create_nonce('lasso_gallery'); $blob = array(); if (empty($codes)) { return; } foreach ($codes as $slug => $shortcode) { $return = ''; // Shortcode has atts if (count($shortcode['atts']) && $shortcode['atts']) { foreach ($shortcode['atts'] as $attr_name => $attr_info) { $prefix = isset($attr_info['prefix']) ? sprintf('<span class="lasso-option-prefix">%s</span>', $attr_info['prefix']) : null; $return .= '<form id="lasso--component-settings-form" class="' . $galleries . '" method="post">'; $return .= '<p data-option="' . $attr_name . '" class="lasso-option lasso-' . $slug . '-' . $attr_name . '">'; $return .= '<label for="lasso-generator-attr-' . $attr_name . '">' . $attr_info['desc'] . '</label>'; $return .= '<small class="lasso-option-desc">' . $attr_info['tip'] . '</small>'; // Select if (isset($attr_info['values'])) { $return .= '<select name="' . $attr_name . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr">'; $i = 0; foreach ($attr_info['values'] as $attr_value) { $attr_value_selected = $attr_info['default'] == $attr_value ? ' selected="selected"' : ''; $return .= '<option value="' . $attr_info['values'][$i]['value'] . '" ' . $attr_value_selected . '>' . $attr_info['values'][$i]['name'] . '</option>'; $i++; } $return .= '</select>'; } else { $attr_field_type = isset($attr_info['type']) ? $attr_info['type'] : 'text'; // image upload if ('media_upload' == $attr_info['type']) { $return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="' . $attr_info['default'] . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-' . $attr_field_type . '" />'; $return .= '<a href="#" id="lasso-upload-img" class="lasso-option-button" /></a>'; } elseif ('color' == $attr_info['type']) { $return .= '<input type="color" name="' . $attr_name . '" value="' . $attr_info['default'] . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-' . $attr_field_type . '" />'; } elseif ('text_area' == $attr_info['type']) { $return .= '<textarea name="' . $attr_name . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-' . $attr_field_type . '" placeholder="' . $attr_info['default'] . '" /></textarea>' . $prefix . ''; } else { $return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="' . $attr_info['default'] . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-' . $attr_field_type . '" />' . $prefix . ''; } } $return .= '</p>'; } } /////////////////////////// // START GALLERY AND MAP FRONT END STUFFS /////////////////////////// if (isset($shortcode['front']) && true == $shortcode['front']) { if ('gallery' == $shortcode['front_type']) { $return .= lasso_gallery_editor_module(); } } /////////////////////////// // END GALLERY AND MAP FRONT END STUFFS /////////////////////////// // Single shortcode (not closed) if ('single' == $shortcode['type']) { $return .= '<input type="hidden" name="lasso-generator-content" id="lasso-generator-content" value="false" />'; } else { $return .= '<p data-option="content" class="lasso-option lasso-c-comp-text"><label>' . __('Content', 'lasso') . '</label><textarea type="text" name="lasso-generator-content" id="lasso-generator-content" value="' . $shortcode['content'] . '" /></textarea></p>'; } $return .= '<p class="lasso-buttoninsert-wrap"><a href="#" class="lasso-generator-cancel" id="lasso--sidebar__close">Cancel </a><input type="submit" id="lasso-generator-insert" value="Save Settings"></p>'; $return .= '<input class="component_type" type="hidden" name="component_type" value="">'; $return .= '<input type="hidden" name="unique" value="">'; $return .= '<input type="hidden" name="nonce" id="lasso-generator-nonce" value="' . $nonce . '" />'; $return .= '</form>'; $blob[$slug] = $return; } return $blob; }