/** * Saves shortcode options (currently disable | enable ). * * @since 1.0.0 */ public function save_shortcode_options() { global $render_sc_table_disabled; $shortcodes = render_get_disabled_shortcodes(); if (isset($_REQUEST['action']) && isset($_REQUEST['shortcodes'])) { $_shortcodes = array(); if (is_array($_REQUEST['shortcodes'])) { foreach ($_REQUEST['shortcodes'] as $shortcode) { $_shortcodes[] = $shortcode; } } else { $_shortcodes[] = $_REQUEST['shortcodes']; } if ($this->current_action() === 'disable') { $shortcodes = array_merge($shortcodes, $_shortcodes); } elseif ($this->current_action() === 'enable') { $shortcodes = array_diff($shortcodes, $_shortcodes); } update_option('render_disabled_shortcodes', array_unique($shortcodes)); } if (!empty($shortcodes)) { $render_sc_table_disabled = array_unique($shortcodes); } }
/** * Removes all shortcodes disabled through Render on the front-end. * * @hooked init 10 * * @since 1.0.0 */ public function remove_disabled_shortcodes() { foreach (render_get_disabled_shortcodes() as $code) { $this->remove_shortcode($code); } }
/** * Renders shortcodes in the TinyMCE. * * This is the AJAX callback for rendering shortcodes to be previewed in the TinyMCE editor. * * @since 1.0.0 */ public static function render_shortcodes() { global $render_shortcode_data, $Render, $content; define('RENDER_TINYMCE', true); $render_shortcode_data = $_POST['shortcode_data']; $content = stripslashes($_POST['content']); // Remove any disabled shortcodes foreach (render_get_disabled_shortcodes() as $code) { $Render->remove_shortcode($code); } /** * Allows hooking into the tinymce AJAX rendering call. * * Plugins may find this useful to globalize data for their tinymce shortcode callback. * * @hooked $this->render_ajax() 1 * * @since 1.0.0 */ do_action('render_tinymce_ajax'); /** * Log out for TinyMCE display purposes. * * @since 1.0.0 */ if (apply_filters('render_tinyme_logged_out', false)) { render_tinyme_log_out(); } $pattern = get_shortcode_regex(); $content = render_strip_paragraphs_around_shortcodes($content); $content = preg_replace_callback("/{$pattern}/s", array(__CLASS__, '_replace_shortcodes'), $content); echo $content; die; }
/** * Outputs the Render Modal HTML. * * @since 1.0.0 * @access private * * @global Render $Render The main Render object. */ public static function _modal_output() { global $Render; foreach (render_get_disabled_shortcodes() as $code) { $Render->remove_shortcode($code); } // Sort alphabetically by title. uasort($Render->shortcodes, function ($a, $b) { return strcmp($a['title'], $b['title']); }); // Gets all categories in use $used_categories = render_get_shortcode_used_categories(); ?> <div id="render-modal-backdrop"></div> <div id="render-modal-wrap" style="display: none;"> <div class="render-modal-title"> <span class="render-modal-logo"></span> <button type="button" class="render-modal-close"> <span class="screen-reader-text"><?php _e('Close', 'Render'); ?> </span> </button> </div> <div class="render-modal-body"> <div class="render-modal-search"> <input type="text" name="render-modal-search" placeholder="<?php _e('Search by name, description, code, category, or source', 'Render'); ?> "/> <span class="dashicons dashicons-search"></span> <div class="render-modal-invalidsearch" style="display: none;"> <?php _e('Sorry, but you can\'t search for that.', 'Render'); ?> </div> </div> <div class="render-modal-categories"> <div class="render-modal-categories-left dashicons dashicons-arrow-left-alt2"></div> <ul> <?php if (!empty($used_categories)) { ?> <?php $i = 0; foreach ($used_categories as $category_ID => $category) { $i++; ?> <li data-category="<?php echo $category_ID; ?> " class="<?php echo $i === 1 ? 'active' : ''; ?> "> <span class="dashicons <?php echo $category['icon']; ?> "></span> <br/> <?php echo $category['label']; ?> </li> <?php } ?> <?php } ?> </ul> <div class="render-modal-categories-right dashicons dashicons-arrow-right-alt2"></div> </div> <div class="render-modal-shortcodes-container"> <ul class="render-modal-shortcodes accordion-container"> <?php if (!empty($Render->shortcodes)) { ?> <?php foreach ($Render->shortcodes as $code => $shortcode) { $wrapping = isset($shortcode['wrapping']) && $shortcode['wrapping'] ? true : false; /** * Allows the filtering of the list of atts for the current shortcode. * * @since 1.0.0 */ $shortcode['atts'] = apply_filters('render_att_pre_loop', $shortcode['atts'], $code, $shortcode); if ($shortcode['noDisplay']) { continue; } // TODO Construct data in similar fashion to .att-row ?> <li data-category="<?php echo isset($shortcode['category']) ? $shortcode['category'] : 'other'; ?> " data-code="<?php echo $code; ?> " data-title="<?php echo $shortcode['title']; ?> " data-source="<?php echo $shortcode['source']; ?> " data-tags="<?php echo $shortcode['tags']; ?> " class="render-modal-shortcode <?php echo !empty($shortcode['atts']) ? 'accordion-section' : ''; ?> <?php echo $shortcode['wrapping'] ? 'wrapping' : ''; ?> <?php echo isset($shortcode['render']['nested']['child']) ? 'nested-parent' : ''; ?> "> <div class="<?php echo !empty($shortcode['atts']) ? 'accordion-section' : 'render-modal-sc'; ?> -title"> <div class="render-modal-shortcode-title"> <?php echo $shortcode['title']; ?> <br/> <span class="render-modal-shortcode-source"> <?php echo $shortcode['source']; ?> </span> </div> <div class="render-modal-shortcode-description"> <?php echo $shortcode['description'] ? $shortcode['description'] : __('No description available.', 'Render'); ?> </div> <div style="clear: both; display: table;"></div> </div> <?php if (!empty($shortcode['atts'])) { ?> <div class="accordion-section-content render-modal-atts"> <div class="render-modal-shortcode-toolbar"> <div class="render-modal-shortcode-toolbar-tools"> <div class="render-modal-shortcode-toolbar-restore"> <div class="render-modal-shortcode-toolbar-button-restore"> <?php _e('Restore Shortcode', 'Render'); ?> </div> </div> </div> <div class="render-modal-shortcode-toolbar-toggle dashicons dashicons-arrow-down-alt2"></div> </div> <div class="render-modal-shortcode-atts"> <?php self::_atts_loop($shortcode['atts'], $advanced = false, $wrapping, $code); ?> <?php // Figure out if any of the attributes belong to the advanced section $advanced = false; foreach ($shortcode['atts'] as $att) { if ($advanced = $att['advanced']) { break; } } if ($advanced) { ?> <a href="#" class="render-modal-att-section-break render-modal-show-advanced-atts hidden"> <span class="show-text"> <?php _e('Show advanced options', 'Render'); ?> <span class="dashicons dashicons-arrow-down"></span> </span> <span class="hide-text" style="display: none;"> <?php _e('Hide advanced options', 'Render'); ?> <span class="dashicons dashicons-arrow-up"></span> </span> </a> <div class="render-modal-advanced-atts" style="display: none;"> <?php self::_atts_loop($shortcode['atts'], $advanced = true, $wrapping, $code); ?> </div> <?php } ?> </div> </div> <?php } ?> </li> <?php } ?> <?php } ?> </ul> <div class="render-modal-shortcodes-spinner spinner"></div> </div> </div> <div class="render-modal-footer"> <div class="render-modal-cancel"> <a class="submitdelete deletion" href="#"><?php _e('Cancel', 'Render'); ?> </a> </div> <div class="render-modal-update"> <div id="render-modal-submit"> <p class="render-modal-submit-text-add" style="top: 0;"><?php // Needed for initial animation ?> <?php _e('Add Shortcode', 'Render'); ?> </p> <br/> <p class="render-modal-submit-text-modify"> <?php _e('Modify Current Shortcode', 'Render'); ?> </p> <br/> <p class="render-modal-submit-text-change"> <?php _e('Change To New Shortcode', 'Render'); ?> </p> </div> <div id="render-modal-remove" class="button-secondary button-red delete" style="display: none;"> <?php _e('Remove Current Shortcode', 'Render'); ?> </div> <?php do_action('render_modal_action_area'); ?> </div> </div> </div> <?php }