/** * Retrieve a `border` interface element. * * @since 1.0.0 * @param int|string $id Element ID. * @param array $field Element arguments. * @return string HTML-markup for `border` element. */ public static function border($id, $field) { $defaults = $field['default'] === 'none' ? array('0', 'solid', '#000000') : explode(' ', str_replace('px', '', $field['default'])); $borders = Cherry_Shortcodes_Tools::select(array('options' => Cherry_Shortcodes_Data::borders(), 'class' => 'cherry-generator-bp-style', 'selected' => $defaults[1])); $return = '<div class="cherry-generator-border-picker"><span class="cherry-generator-border-picker-field"><input type="number" min="-1000" max="1000" step="1" value="' . $defaults[0] . '" class="cherry-generator-bp-width" /><small>' . __('Border width', 'cherry-shortcodes') . ' (px)</small></span><span class="cherry-generator-border-picker-field">' . $borders . '<small>' . __('Border style', 'cherry-shortcodes') . '</small></span><span class="cherry-generator-border-picker-field cherry-generator-border-picker-color"><input type="text" value="' . $defaults[2] . '" class="cherry-generator-border-picker-color-value" /><small>' . __('Border color', 'cherry-shortcodes') . '</small></span><input type="hidden" name="' . $id . '" value="' . esc_attr($field['default']) . '" id="cherry-generator-attr-' . $id . '" class="cherry-generator-attr" /></div>'; return $return; }
public static function icons() { $icons = array(); if (is_callable(array('Cherry_Shortcodes_Data', 'icons'))) { foreach ((array) Cherry_Shortcodes_Data::icons() as $icon) { $icons[] = '<i class="' . $icon . '" title="' . $icon . '"></i>'; } } return implode('', $icons); }
private function cherry_attributes_to_parameters($atts, $params = null, $shortcode = '') { if ($params == NULL) { $params = array(); } if (is_array($atts) && count($atts)) { foreach ($atts as $att_id => $att) { $param = array(); $type = isset($att['type']) ? $att['type'] : ''; switch ($type) { case 'select': $param['type'] = isset($att['multiple']) && $att['multiple'] == TRUE ? 'select-multiple' : 'select'; $param['label'] = $att['name']; $param['default'] = $att['default']; $param['list'] = $att['values']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; break; case 'responsive': $responsive_sizes = array('_xs', '_sm', '_md', '_lg'); foreach ($responsive_sizes as $size) { // skip size_md while we set it visually if ($att_id . $size == 'size_md') { continue; } $params[$att_id . $size] = array('type' => 'text', 'label' => $att['name'] . $size, 'default' => 'none', 'description' => $this->responsive_size_to_label($size)); } break; case 'color': $param['type'] = 'color-picker'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; //$param['default'] = $att['default']; break; case 'slider': $param['type'] = 'slider'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; $param['default'] = $att['default']; $param['min'] = $att['min']; $param['max'] = $att['max']; break; case 'number': $param['type'] = 'spinner'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; $param['default'] = $att['default']; $param['min'] = $att['min']; $param['max'] = $att['max']; break; case 'bool': $param['type'] = 'radio-buttons'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; $param['default'] = $att['default']; $param['list'] = array('yes' => __('Yes'), 'no' => __('No')); break; case 'upload': $param['type'] = 'media'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; $param['default'] = $att['default']; break; case 'icon': $param['type'] = 'icon-picker'; $param['label'] = $att['name']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; $param['default'] = ''; //delete_transient('mpce-cherry-icons-list'); $icons_list = get_transient('mpce-cherry-icons-list'); if ($icons_list == FALSE) { $icons = Cherry_Shortcodes_Data::icons(); $icons_list = array('none' => array('class' => 'fa', 'label' => '')); foreach ($icons as $icon) { $icons_list['icon:' . $icon] = array('label' => str_replace('fa fa-', '', $icon), 'class' => $icon); } //asort($icons_list); $expiration = 60 * 60; // one hour set_transient('mpce-cherry-icons-list', $icons_list, $expiration); } $param['list'] = $icons_list; /*echo "<pre>"; var_export($param); exit;*/ break; default: $param['type'] = 'text'; if ($att_id == 'url') { $param['type'] = 'link'; } $param['label'] = $att['name']; $param['default'] = $att['default']; $param['description'] = empty($att['desc']) ? '' : $att['desc']; } // Cherry Shortcodes Templater if ($att_id == 'template' && class_exists('Cherry_Shortcode_Editor') && strlen($shortcode)) { $templates = Cherry_Shortcode_Editor::dirlist($shortcode); if ($templates && !empty($templates)) { $param['list'] = $templates; } } if (count($param)) { $params[$att_id] = $param; } } } return $params; }
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
/** * 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; }
/** * 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'; }
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); } } }