public function mpce_cherry4_shortcode_atts() { if (!class_exists('Cherry_Shortcodes_Data') || !class_exists('MPCEShortcode')) { return; } $shortcodes = Cherry_Shortcodes_Data::shortcodes(); foreach ($shortcodes as $id => $data) { $shortcode_atts_filter = new MotoPress_Cherry4_Shortcode_Atts_Filter_Old($id); add_filter('shortcode_atts_' . $id, array($shortcode_atts_filter, 'shortcode_atts_common_filter'), 10, 3); } }
if (isset($_GET['norename'])) { ?> <div id="message_" class="updated_ templater-updated_"><?php _e('File with the same name already exists.', 'cherry-shortcodes-templater'); ?> </div> <?php } ?> <div class="cherry-row"> <div class="cherry-column-1"> <div id="nav-container" class="box-primary_"> <?php if (class_exists('Cherry_Shortcodes_Data')) { $registered_shortcodes = (array) Cherry_Shortcodes_Data::shortcodes(); } else { $registered_shortcodes = apply_filters('cherry_templater/data/shortcodes', array()); } $_count = 0; foreach ($default_templates as $tag => $locations) { if (!isset($registered_shortcodes[$tag])) { continue; } ?> <h3><?php echo esc_html($tag); ?> </h3> <div class="item item-<?php
/** * Register shortcodes. * * @since 1.0.0 */ public function register() { foreach ((array) Cherry_Shortcodes_Data::shortcodes() as $id => $data) { if (isset($data['function']) && is_callable($data['function'])) { $func = $data['function']; } elseif (is_callable(array('Cherry_Shortcodes_Handler', $id))) { $func = array('Cherry_Shortcodes_Handler', $id); } elseif (is_callable(array('Cherry_Shortcodes_Handler', CHERRY_SHORTCODES_PREFIX . $id))) { $func = array('Cherry_Shortcodes_Handler', CHERRY_SHORTCODES_PREFIX . $id); } else { continue; } // Register shortcode. add_shortcode(CHERRY_SHORTCODES_PREFIX . $id, $func); } /** * Adds a fallback-compatibility after renaming shortcodes. * * @since 1.0.2 * @see https://github.com/CherryFramework/cherry-shortcodes/issues/1 */ add_shortcode(CHERRY_SHORTCODES_PREFIX . 'paralax_image', array('Cherry_Shortcodes_Handler', 'parallax_image')); add_shortcode(CHERRY_SHORTCODES_PREFIX . 'paralax_html_video', array('Cherry_Shortcodes_Handler', 'parallax_html_video')); // Class Cherry API JS require_once CHERRY_SHORTCODES_DIR . 'inc/class-cherry-api-js.php'; }
/** * Process AJAX request */ public static function settings() { self::access(); // Param check if (empty($_REQUEST['shortcode'])) { wp_die(__('Shortcode not specified', 'cherry-shortcodes')); } // Get cache $output = get_transient('cherry_shortcodes/generator/settings/' . sanitize_text_field($_REQUEST['shortcode'])); if ($output && CHERRY_SHORTCODES_ENABLE_CACHE) { echo $output; } else { // Request queried shortcode $shortcode = Cherry_Shortcodes_Data::shortcodes(sanitize_key($_REQUEST['shortcode'])); // Prepare actions $actions = apply_filters('cherry_shortcodes/generator/actions', array('insert' => '<a href="javascript:void(0);" class="button button-primary button-large cherry-generator-insert"><i class="fa fa-check"></i> ' . __('Insert shortcode', 'cherry-shortcodes') . '</a>', 'preview' => '<a href="javascript:void(0);" class="button button-large cherry-generator-toggle-preview"><i class="fa fa-eye"></i> ' . __('Live preview', 'cherry-shortcodes') . '</a>')); // Shortcode header $return = '<div id="cherry-generator-breadcrumbs">'; $return .= apply_filters('cherry_shortcodes/generator/breadcrumbs', '<a href="javascript:void(0);" class="cherry-generator-home" title="' . __('Click to return to the shortcodes list', 'cherry-shortcodes') . '">' . __('All shortcodes', 'cherry-shortcodes') . '</a> → <span>' . $shortcode['name'] . '</span> <small class="alignright">' . $shortcode['desc'] . '</small><div class="cherry-generator-clear"></div>'); $return .= '</div>'; // Shortcode note if (isset($shortcode['note']) || isset($shortcode['example'])) { $return .= '<div class="cherry-generator-note"><i class="fa fa-info-circle"></i><div class="cherry-generator-note-content">'; if (isset($shortcode['note'])) { $return .= wpautop($shortcode['note']); } if (isset($shortcode['example'])) { $return .= wpautop('<a href="' . admin_url('admin.php?page=cherry-shortcodes-examples&example=' . $shortcode['example']) . '" target="_blank">' . __('Examples of use', 'cherry-shortcodes') . ' →</a>'); } $return .= '</div></div>'; } // Shortcode has atts if (isset($shortcode['atts']) && count($shortcode['atts'])) { // Loop through shortcode parameters $counter = 0; $left_container = ''; $right_container = ''; $half = ceil(count($shortcode['atts']) / 2); foreach ($shortcode['atts'] as $attr_name => $attr_info) { // Prepare default value. $item = ''; $default = (string) isset($attr_info['default']) ? $attr_info['default'] : ''; $attr_info['name'] = isset($attr_info['name']) ? $attr_info['name'] : $attr_name; $item .= '<div class="cherry-generator-attr-container" data-default="' . esc_attr($default) . '">'; $item .= '<h5>' . $attr_info['name'] . '</h5>'; // Create field types. if (!isset($attr_info['type']) && isset($attr_info['values']) && is_array($attr_info['values']) && count($attr_info['values'])) { $attr_info['type'] = 'select'; } elseif (!isset($attr_info['type'])) { $attr_info['type'] = 'text'; } if (is_callable(array('Cherry_Shortcodes_Generator_Views', $attr_info['type']))) { $item .= call_user_func(array('Cherry_Shortcodes_Generator_Views', $attr_info['type']), $attr_name, $attr_info); } elseif (isset($attr_info['callback']) && is_callable($attr_info['callback'])) { $item .= call_user_func($attr_info['callback'], $attr_name, $attr_info); } if (isset($attr_info['desc'])) { $item .= '<div class="cherry-generator-attr-desc">' . str_replace(array('<b%value>', '<b_>'), '<b class="cherry-generator-set-value" title="' . __('Click to set this value', 'cherry-shortcodes') . '">', $attr_info['desc']) . '</div>'; } $item .= '</div>'; $counter < $half ? $left_container .= $item : ($right_container .= $item); $counter++; } } $return .= '<div class="cherry-generator-attr-left-container">' . $left_container . '</div>'; $return .= '<div class="cherry-generator-attr-right-container">' . $right_container . '</div>'; $return .= '<div class="cherry-generator-clear"></div>'; // Single shortcode (not closed) if ($shortcode['type'] == 'single') { $return .= '<input type="hidden" name="cherry-generator-content" id="cherry-generator-content" value="false" />'; } else { // Prepare shortcode content $shortcode['content'] = isset($shortcode['content']) ? $shortcode['content'] : ''; $return .= '<div class="cherry-generator-attr-container"><h5>' . __('Content', 'cherry-shortcodes') . '</h5><textarea name="cherry-generator-content" id="cherry-generator-content" rows="5">' . esc_attr(str_replace(array('%prefix_', '__'), CHERRY_SHORTCODES_PREFIX, $shortcode['content'])) . '</textarea></div>'; } $return .= '<div id="cherry-generator-preview"></div>'; $return .= '<div class="cherry-generator-actions cherry-generator-clearfix">' . implode(' ', array_values($actions)) . '</div>'; set_transient('cherry_shortcodes/generator/settings/' . sanitize_text_field($_REQUEST['shortcode']), $return, 2 * DAY_IN_SECONDS); echo $return; } exit; }
public function mpce_custom_cherry_shortcodes_library_extend($motopressCELibrary) { if (!class_exists('Cherry_Shortcodes_Data') || !class_exists('MPCE_Cherry4')) { return; } $shortcodes = Cherry_Shortcodes_Data::shortcodes(); $grid_shortcodes = array('row', 'row_inner', 'col', 'col_inner'); $prefix = CHERRY_SHORTCODES_PREFIX; foreach ($grid_shortcodes as $shortcode) { $mp_object =& $motopressCELibrary->getObject($prefix . $shortcode); foreach ($mp_object->parameters['bg_type']['list'] as $bg_type_key => $bg_type_label) { $mpce_cherry4 = MPCE_Cherry4::instance(); $mp_object_new_parameters = $mpce_cherry4->cherry_attributes_to_parameters($this->get_bg_type($bg_type_key)); foreach ($mp_object_new_parameters as $parameter_key => &$parameter_value) { $parameter_value['dependency'] = array('parameter' => 'bg_type', 'value' => $bg_type_key); } $mp_object->parameters = array_merge($mp_object->parameters, $mp_object_new_parameters); } } }