private function createShortcodeHandler(Shortcode $shortcode) { return function ($userAttrs) use($shortcode) { $resolvedAttrs = \shortcode_atts($shortcode->getDefaultAttributes(), $userAttrs); $context = new ShortcodeContext($userAttrs, $resolvedAttrs); return $shortcode->render($context); }; }
function LoadShortcode($atts) { $shortcode = new Shortcode(); ob_start(); $shortcode->plugin_sedici($atts); $res = ob_get_contents(); ob_clean(); return $res; }
/** * Hooks */ private function hooks() { // frontend only if (!is_admin()) { // breadcrumbs $breadcrumbs = new Breadcrumbs(); add_action('wp', array($breadcrumbs, 'handleHooks')); // setup shortcode on frontend $shortcode = new Shortcode(); $shortcode->setup(); } // setup product link $productLink = new MetaBox(); $productLink->add_hooks(); }
public static function add_head_shortcode() { $forges = Shortcode::get_shortcodes(); $list_shortcodes = array(); $res = array(); foreach ($forges as $forge) { $list_shortcodes[] = $forge->get_title(); // Check if some treatment is necessary for filepicker fields $forge->check_fields_files(); $res[$forge->get_title()] = array('name' => $forge->get_name(), 'is_immediat' => $forge->is_immediat(), 'shortcode' => $forge->get_shortcode(), 'fields' => $forge->get_fields()); } $res = empty($list_shortcodes) ? '{}' : json_encode($res); // Delete string for function() onclick on filepicker $res = str_replace(array('"__', '__"'), '', $res); $list = empty($list_shortcodes) ? '[]' : json_encode($list_shortcodes); ?> <script type="text/javascript"> var list_morepress_shortcodes = <?php echo $list; ?> ; var morepress_shortcodes = <?php echo $res; ?> ; </script> <?php }
/** * Init */ public function __construct() { /** Ajax pagination for property_overview */ add_action("wp_ajax_wpp_property_overview_pagination", array($this, "ajax_handler")); add_action("wp_ajax_nopriv_wpp_property_overview_pagination", array($this, "ajax_handler")); $custom_attributes = ud_get_wp_property('property_stats', array()); $image_sizes = array('' => __('No Image', ud_get_wp_property('domain'))); foreach (get_intermediate_image_sizes() as $name) { $sizes = \WPP_F::image_sizes($name); if (!$sizes) { continue; } $image_sizes[$name] = $name . ' (' . $sizes['width'] . 'x' . $sizes['height'] . 'px)'; } $sort_by = array('post_date' => sprintf(__('Post Date (%s)', ud_get_wp_property('domain')), 'post_date'), 'post_modified' => sprintf(__('Modified Date (%s)', ud_get_wp_property('domain')), 'post_modified'), 'random' => sprintf(__('Random (%s)', ud_get_wp_property('domain')), 'random'), 'menu_order' => sprintf(__('Menu Order (%s)', ud_get_wp_property('domain')), 'menu_order')); $sortable_atts = ud_get_wp_property('sortable_attributes', array()); if (!empty($sortable_atts) && is_array($sortable_atts)) { foreach ($sortable_atts as $attr) { if (array_key_exists($attr, $custom_attributes)) { $sort_by[$attr] = $custom_attributes[$attr] . ' (' . $attr . ')'; } } } $options = array('id' => 'property_overview', 'params' => array('property_id' => array('name' => __('Property ID', ud_get_wp_property()->domain), 'description' => __('If not empty, result will show particular property, which ID is set.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'post_parent' => array('name' => sprintf(__('Parent %s', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('If not empty, result will show children of particular property, which ID is set. You can use dynamic attributes instead of ID such as %1$s or %2$s.<br/>%1$s - to list all the listings that are a child of the current %3$s.<br/>%2$s - to list all listings that are children of the same parent (i.e. siblings) of the current %3$s', ud_get_wp_property('domain')), '<b>post_id</b>', '<b>post_parent</b>', \WPP_F::property_label()), 'type' => 'text', 'default' => ''), 'property_type' => array('name' => sprintf(__('%s Type', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('The list of %s types to be included. If no type checked, all available %s will be shown.', ud_get_wp_property('domain')), \WPP_F::property_label(), \WPP_F::property_label('plural')), 'type' => 'multi_checkbox', 'options' => ud_get_wp_property('property_types')), 'featured' => array('name' => sprintf(__('Show only Featured %s', ud_get_wp_property('domain')), \WPP_F::property_label('plural')), 'type' => 'checkbox'), 'custom_query' => array('name' => __('Custom Query by Attributes Values', ud_get_wp_property()->domain), 'description' => sprintf(__('Setup your custom query by providing values for specific attributes. Empty values will be ignored. Example:<br/>- to list only %1$s which have minimum 2 and maximum 4 bedrooms, you should set <b>2-4</b> value for your Bedrooms attribute.<br/>- to list only %1$s which have 1 or 3 bathrooms, you should set <b>1,3</b> value for your Batrooms attribute.', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'custom_attributes', 'options' => $custom_attributes), 'show_children' => array('name' => __('Show Children', ud_get_wp_property()->domain), 'description' => sprintf(__('Switches children %s displaying.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'child_properties_title' => array('name' => sprintf(__('Child %s Title', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'description' => sprintf(__('Title for Child %s section.', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'type' => 'text', 'default' => __('Floor plans at location:', ud_get_wp_property()->domain)), 'fancybox_preview' => array('name' => __('Fancybox Preview', ud_get_wp_property()->domain), 'description' => __('Use fancybox preview.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'bottom_pagination_flag' => array('name' => __('Bottom Pagination', ud_get_wp_property()->domain), 'description' => __('Show Bottom Pagination.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'thumbnail_size' => array('name' => __('Thumbnail Size', ud_get_wp_property()->domain), 'description' => __('Show image with specific image size', ud_get_wp_property()->domain), 'type' => 'select', 'options' => $image_sizes, 'default' => 'thumbnail'), 'sort_by_text' => array('name' => __('Sort By Text', ud_get_wp_property()->domain), 'description' => __('Renames "Sort By:" text.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => __('Sort By', ud_get_wp_property()->domain)), 'sort_by' => array('name' => __('Sort By', ud_get_wp_property()->domain), 'description' => sprintf(__('Sets sorting by sortable attribute or %s.', ud_get_wp_property()->domain), 'post_date, menu_order, random'), 'type' => 'select', 'options' => $sort_by, 'default' => 'post_date'), 'sort_order' => array('name' => __('Sort Order', ud_get_wp_property()->domain), 'description' => __('Sort Order', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('DESC' => 'DESC', 'ASC' => 'ASC'), 'default' => 'DESC'), 'template' => array('name' => __('Template', ud_get_wp_property()->domain), 'description' => sprintf(__('Sets layout using PHP template name. Your custom template should be stored in your theme\'s root directory. Example:<br/>if your custom template is called %s, the value of template must be %s.', ud_get_wp_property('domain')), '<b>property-overview-grid.php</b>', '<b>grid</b>'), 'type' => 'text'), 'sorter_type' => array('name' => __('Sorter Type', ud_get_wp_property()->domain), 'description' => __('Sorter Type', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('none' => __('None', ud_get_wp_property()->domain), 'buttons' => __('Buttons', ud_get_wp_property()->domain), 'dropdown' => __('Dropdown', ud_get_wp_property()->domain)), 'default' => 'buttons'), 'sorter' => array('name' => __('Sorter', ud_get_wp_property()->domain), 'description' => __('Show Sort UI', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'on'), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Show Pagination', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'on'), 'pagination_type' => array('name' => __('Pagination Type', ud_get_wp_property()->domain), 'description' => __('Determine pagination UI', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('slider' => __('slider', ud_get_wp_property()->domain), 'numeric' => __('numeric', ud_get_wp_property()->domain)), 'default' => ud_get_wp_property('configuration.property_overview.pagination_type') ? ud_get_wp_property('configuration.property_overview.pagination_type') : 'slider'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => sprintf(__('%s quantity per page.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'number', 'default' => 10), 'starting_row' => array('name' => __('Starting Row', ud_get_wp_property()->domain), 'description' => __('Sets starting row.', ud_get_wp_property()->domain), 'type' => 'number', 'default' => 0), 'detail_button' => array('name' => __('Detail Button', ud_get_wp_property()->domain), 'description' => __('Name of Detail Button. Button will not be shown if the value is empty.', ud_get_wp_property()->domain), 'type' => 'text'), 'hide_count' => array('name' => __('Hide Count', ud_get_wp_property()->domain), 'description' => __('Hide the "10 found." text.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'in_new_window' => array('name' => __('In new window?', ud_get_wp_property()->domain), 'description' => __('Open links in new window.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'strict_search' => array('name' => __('Strict Search', ud_get_wp_property()->domain), 'description' => __('Provides strict search', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false')), 'description' => sprintf(__('Renders %s Attributes', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
public function testUsingFacade() { Shortcode::register('foo', function () { return 'bar'; }); $this->assertEquals('foo', Shortcode::compile('foo')); }
public function register($attr, $content = null, $name = null) { $content = \Shortcode::compile($content); $attr['class'] = 'section ' . str_replace('"', '', isset($attr['class']) ? $attr['class'] : ''); $hr = isset($attr['hr']) ? $attr['hr'] : null; if ($hr) { unset($attr['hr']); $content .= '<hr class="half-rule">'; } return '<div ' . \Html::attributes($attr) . '>' . $content . '</div>'; }
/** * init */ public function __construct() { $taxonomies = array(); $_taxonomies = ud_get_wp_property('taxonomies', array()); if (!empty($_taxonomies) && is_array($_taxonomies)) { foreach ($_taxonomies as $k => $v) { $taxonomies[$k] = !empty($v['label']) ? $v['label'] : $k; } } $options = array('id' => 'property_terms', 'params' => array('property_id' => array('name' => sprintf(__('%s ID', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('If not empty, result will show particular %s, which ID is set.', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'text', 'default' => ''), 'taxonomy' => array('name' => __('Taxonomy', ud_get_wp_property()->domain), 'description' => sprintf(__('Renders %s terms of particular taxonomy', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'select', 'options' => $taxonomies)), 'description' => sprintf(__('Renders %s Terms for specific taxonomy', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
/** * Init */ public function __construct() { $attributes = ud_get_wp_property('property_stats', array()); /* $hidden_attributes = ud_get_wp_property( 'hidden_frontend_attributes', array() ); foreach( $attributes as $k => $v ) { if( in_array( $k, $hidden_attributes ) ) { unset( $attributes[$k] ); } } //*/ $options = array('id' => 'property_attributes', 'params' => array('sort_by_groups' => array('name' => __('Sort by groups', ud_get_wp_property()->domain), 'description' => __('Sort attributes by groups or not', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain))), 'display' => array('name' => __('Display', ud_get_wp_property()->domain), 'description' => __('The way of displaying attributes', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('list' => __('Simple List', ud_get_wp_property()->domain), 'dl_list' => __('Definitions List', ud_get_wp_property()->domain), 'plain_list' => __('Plain List', ud_get_wp_property()->domain), 'detail' => __('Detailed List', ud_get_wp_property()->domain))), 'show_true_as_image' => array('name' => __('Show "True" as image', ud_get_wp_property()->domain), 'description' => __('Display boolean attributes like checkbox image.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'make_link' => array('name' => __('Make link', ud_get_wp_property()->domain), 'description' => __('Make URLs into clickable links', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain))), 'hide_false' => array('name' => __('Hide false', ud_get_wp_property()->domain), 'description' => __('Hide attributes with false value', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'return_blank' => array('name' => __('Return Blank', ud_get_wp_property()->domain), 'description' => __('Omit blank values or not.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'include' => array('name' => __('Include', ud_get_wp_property()->domain), 'description' => __('The list of attributes to be included. If no attribute checked, all available attributes will be shown.', ud_get_wp_property()->domain), 'type' => 'multi_checkbox', 'options' => $attributes), 'exclude' => array('name' => __('Exclude', ud_get_wp_property()->domain), 'description' => __('The list of attributes which will not be shown.', ud_get_wp_property()->domain), 'type' => 'multi_checkbox', 'options' => $attributes)), 'description' => sprintf(__('Renders %s Attributes List', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
/** * Bootstrap any application services. * * @return void */ public function boot() { setlocale(LC_ALL, 'ru_RU.UTF-8'); Carbon::setLocale(config('app.locale')); \Shortcode::register('slider', '\\App\\Shortcode\\Slider'); \Shortcode::register('section', '\\App\\Shortcode\\Section'); \Shortcode::register('iframe', '\\App\\Shortcode\\Iframe'); \Shortcode::register('timeline', '\\App\\Shortcode\\Timeline'); if (\DB::getDoctrineSchemaManager()->tablesExist('options')) { Option::observe(new OptionObserver()); if (Option::has('vk-user-token')) { Vk::setAccessToken(Option::get('vk-user-token')); } } }
/** * Register service provider, Twig extensions, and alias facade. */ public function boot() { // Service provider App::register('\\Sensory5\\Shortcode\\Classes\\ServiceProvider'); // Register alias $alias = AliasLoader::getInstance(); $alias->alias('Shortcode', '\\Sensory5\\Shortcode\\Classes\\Facade'); // Enable shortcodes on all pages if requested if (Settings::get('enable_on_render', false)) { Event::listen('cms.page.postprocess', function ($controller, $url, $page, $dataHolder) { // Only parse strings, so that we don't interrupt // ajax responses that are in object or array form if (is_string($dataHolder->content)) { $dataHolder->content = \Shortcode::parse($dataHolder->content); } }); } }
public static function parse($viewName = '', $viewData = array(), $timeLive = 10) { $path = self::getPath() . $viewName . '.php'; if (!file_exists($path)) { return false; } $pathMd5 = md5($path); if (!Cache::hasKey('templates/' . $pathMd5, $timeLive, '.php')) { $fileData = file_get_contents($path); $fileData = Shortcode::loadInTemplate($fileData); $fileData = Shortcode::toHTML($fileData); $fileData = Shortcode::load($fileData); // $fileMd5=md5($fileData); Cache::saveKey('templates/' . $pathMd5, $fileData, '.php'); } $path = ROOT_PATH . 'application/caches/templates/'; self::setPath($path); self::make($pathMd5, $viewData); self::resetPath(); }
/** * Register shortcode UI using Shortcake. * * @param \Syllables\Shortcode $shortcode Shortcode object. * * @uses \add_action() * @uses \esc_url() * @uses \shortcode_ui_register_for_shortcode() */ function register_ui(Shortcode $shortcode) { if (!function_exists('shortcode_ui_register_for_shortcode')) { return; } $ui = $shortcode->get_ui(); if (empty($ui)) { return; } \shortcode_ui_register_for_shortcode($shortcode->get_tag(), $ui); \add_action('shortcode_ui_after_do_shortcode', function ($tag) use($shortcode) { if (stripos($tag, '[' . $shortcode->get_tag()) === false) { return; } $styles = filter_assets('styles', $shortcode->get_styles(), $tag); foreach ($styles as $style) { printf('<link rel="stylesheet" href="%s">', \esc_url($style)); } $scripts = filter_assets('scripts', $shortcode->get_styles(), $tag); foreach ($scripts as $script) { printf('<script type="text/javascript" src="%s">', \esc_url($script)); } }); }
if (isset($src)) { $src = $src; } else { $src = ''; } // return return '<iframe width="' . $width . '" height="' . $height . '" src="//www.dailymotion.com/embed/video/' . $src . '" frameborder="0" allowfullscreen></iframe>'; }); // Add Shortcode {Vimeo width='560' height='315' src='144239829'} Shortcode::add('Vimeo', function ($attributes) { // Extract attributes extract($attributes); // src if (isset($width)) { $width = $width; } else { $width = '560'; } if (isset($height)) { $height = $height; } else { $height = '315'; } if (isset($src)) { $src = $src; } else { $src = ''; } // return return '<iframe width="' . $width . '" height="' . $height . '" src="//player.vimeo.com/video/' . $src . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; });
Shortcode::add('thumb', function ($attributes, $content) { // Получаем переметры extract($attributes); $content = trim($content); // Если есть контент (картинка) — работаем if ($content) { $imgResized = $content; // Если есть размер — работаем if (isset($size)) { // Задаём папку для обработанных картинок. $uploadDir = isset($folder) ? $folder : '/storage/images/thumb/'; $imageDir = $uploadDir . $size . '/'; $dir = ROOT_DIR . $imageDir; // Создаём папку при необходимости if (!is_dir($dir)) { @mkdir($dir, 0755, true); @chmod($dir, 0755); } if (!chmod($dir, 0755)) { @chmod($dir, 0755); } // Определяемся с методами ресайза if (isset($method)) { switch ($method) { case 'exact': $method = 'exact'; break; case 'portrait': $method = 'portrait'; break; case 'landscape': $method = 'landscape'; break; case 'crop': $method = 'crop'; break; default: $method = 'auto'; break; } } else { $method = 'auto'; } // Определяемся с качеством картинки на выходе $quality = isset($quality) ? (string) $quality : '100'; // Обрезаем текущий домен $urlShort = str_ireplace(Url::getBase(), '', $content); // Проверяем источник каринки $isRemote = preg_match('~^http(s)?://~', $urlShort) ? true : false; // Присваиваем переменной значение картинки (в т.ч. если это внешняя картинка) $imgResized = $urlShort; // Если не внешняя картинка — подставляем корневю дирректорию, чтоб ресайзер понял что ему дают. if (!$isRemote) { $imgResized = ROOT_DIR . $urlShort; } // Разделяем высоту и ширину $imgSize = explode('x', $size); // Если указана только одна величина - присваиваем второй первую, будет квадрат для exact, auto и crop, иначе класс ресайза жестоко тупит, ожидая вторую переменную. if (count($imgSize) == '1') { $imgSize[1] = $imgSize[0]; } // Определяем имя файла $fileName = $size . '_' . $method . '_' . strtolower(basename($imgResized)); // Если картинки нет в папке обработанных картинок — создадим её if (!file_exists($dir . $fileName)) { // Подключаем класс ресайза if (!class_exists('resize')) { require_once PLUGINS_PATH . '/thumb/classes/resize.php'; } // Изменяем размер $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $method); // Сохраняем картинку в заданную папку $resizeImg->saveImage($dir . $fileName, $quality); } $imgResized = Url::getBase() . $imageDir . $fileName; } $title = isset($title) ? $title : ''; $alt = isset($alt) ? $alt : ''; $class = isset($class) ? $class . ' popup-image' : 'popup-image'; $gallery = isset($gallery) ? '-gallery' : ''; $imageLink = '<a class="' . $class . $gallery . '" href="' . $content . '" title="' . $title . '"><img src="' . $imgResized . '" alt="' . $alt . '"></a>'; return $imageLink; } return ''; });
/** * init */ public function __construct() { $options = array('id' => 'list_attachments', 'params' => array('type' => array('name' => __('Type', ud_get_wp_property()->domain), 'description' => __('Comma-separated list of file extensions that should be included in the list', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'sort_order' => array('name' => __('Sort Order', ud_get_wp_property()->domain), 'description' => __('Indicate whether the list should be sorted in ascending or descending order.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('ASC' => 'ASC', 'DESC' => 'DESC'), 'default' => 'ASC'), 'groupby' => array('name' => __('Group By', ud_get_wp_property()->domain), 'description' => sprintf(__('If you would like the list split into specific groups, you can indicate any of the WordPress post object parameters as the value of this %s. For instance, you can use a common <b>%s</b> for your attachments to organize them into groups. In that case, you would use <b>%s</b> as the <b>%s</b> parameter for this shortcode or widget.', ud_get_wp_property()->domain), \WPP_F::property_label(), 'description', 'post_content', 'groupby'), 'type' => 'text', 'default' => ''), 'opening' => array('name' => __('Opening List', ud_get_wp_property()->domain), 'description' => __('Any HTML code you want to appear before the list begins opening - the opening tag(s) for the list.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => '<ul class="attachment-list wpp_attachment_list">'), 'closing' => array('name' => __('CLosing List', ud_get_wp_property()->domain), 'description' => __('The closing tag(s) for the list.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => '</ul>'), 'before_item' => array('name' => __('Before Item', ud_get_wp_property()->domain), 'description' => __('The opening tag(s) for each item of the list.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => '<li>'), 'after_item' => array('name' => __('After Item', ud_get_wp_property()->domain), 'description' => __('The closing tag(s) for each item of the list.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => '</li>')), 'description' => sprintf(__('Used to display attachments of a %s, can also be used in a post. Ported over from List Attachments Shortcode plugin. If plugin exists, the WP-Property version of shortcode is not loaded.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '') { if (isset($post['content'])) { $post['content'] = Shortcode::toBBCode($post['content']); $post['content'] = String::encode(strip_tags($post['content'], '<p><br>')); } if (is_numeric($listID)) { $catid = $listID; unset($listID); $listID = array($catid); } $listIDs = "'" . implode("','", $listID) . "'"; $keyNames = array_keys($post); $total = count($post); $setUpdates = ''; for ($i = 0; $i < $total; $i++) { $keyName = $keyNames[$i]; $setUpdates .= "{$keyName}='{$post[$keyName]}', "; } $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2); $whereQuery = isset($whereQuery[5]) ? $whereQuery : "requestid in ({$listIDs})"; $addWhere = isset($addWhere[5]) ? $addWhere : ""; Database::query("update " . Database::getPrefix() . "request_payments set {$setUpdates} where {$whereQuery} {$addWhere}"); if (!($error = Database::hasError())) { return true; } return false; }
Shortcode::add('Shop_user', 'Shipcart::customer'); /* * Description : Total items * ShortCode : {Shop_total} * Template: templates/total.tpl */ Shortcode::add('Shop_total', 'Shipcart::total'); /* * Description : Category section * ShortCode : {Shop_section title="" image="" url="" description=""} * Template: templates/section.tpl */ Shortcode::add('Shop_section', 'Shipcart::section'); /* * Description : * ShortCode : {Shop_product_detail id="" title="" url="" image="" description=""} * Template: templates/item_info.tpl * */ Shortcode::add('Shop_product', 'Shipcart::item_info'); /* * Description : Details of product * ShortCode : * {Shop_product_detail id="" title="" url="" image="" description=""} * include title {$title} * content * {/Shop_product_detail} * Template: templates/item_detail.tpl */ Shortcode::add('Shop_product_detail', 'Shipcart::item_detail');
/** * Init */ public function __construct() { $options = array('id' => 'property_attribute', 'params' => array('attribute' => array('type' => 'text', 'name' => __('Attribute', ud_get_wp_property()->domain), 'description' => __('Renders single attribute data', ud_get_wp_property()->domain), 'default' => ''), 'before' => array('type' => 'text', 'name' => __('Before', ud_get_wp_property()->domain), 'description' => __('Before attribute', ud_get_wp_property()->domain), 'default' => ''), 'after' => array('type' => 'text', 'name' => __('After', ud_get_wp_property()->domain), 'description' => __('After attribute', ud_get_wp_property()->domain), 'default' => ''), 'if_empty' => array('type' => 'text', 'name' => __('If Empty', ud_get_wp_property()->domain), 'description' => __('What to show if attribute is empty', ud_get_wp_property()->domain), 'default' => ''), 'do_not_format' => array('type' => 'text', 'name' => __('Do not format', ud_get_wp_property()->domain), 'description' => __('Uh?', ud_get_wp_property()->domain), 'default' => ''), 'make_terms_links' => array('type' => 'select', 'name' => __('Make links of terms', ud_get_wp_property()->domain), 'description' => __('Make links of terms', ud_get_wp_property()->domain), 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'separator' => array('type' => 'text', 'name' => __('Separator', ud_get_wp_property()->domain), 'description' => __('Separator', ud_get_wp_property()->domain), 'default' => ' '), 'strip_tags' => array('type' => 'text', 'name' => __('Strip Tags', ud_get_wp_property()->domain), 'description' => __('Strip tags', ud_get_wp_property()->domain), 'default' => '')), 'description' => sprintf(__('Renders %s Attribute', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
public function test_parse_url() { $this->assertEquals('apple.com', Shortcode::parse_url('//apple.com/foo', PHP_URL_HOST)); $this->assertEquals('/foo', Shortcode::parse_url('//apple.com/foo', PHP_URL_PATH)); $this->assertEquals(array('host' => 'apple.com', 'path' => '/foo'), Shortcode::parse_url('//apple.com/foo')); }
/** * Init */ public function __construct() { $options = array('id' => 'property_search', 'params' => array('searchable_attributes' => array('name' => __('Searchable Attributes', ud_get_wp_property()->domain), 'description' => __('CSV attributes list', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'searchable_property_types' => array('name' => sprintf(__('Searchable %s Types', ud_get_wp_property()->domain), \WPP_F::property_label()), 'description' => __('CSV types list', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Use pagination?', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('Yes', ud_get_wp_property()->domain), 'off' => __('No', ud_get_wp_property()->domain)), 'default' => 'on'), 'group_attributes' => array('name' => __('Group Attributes', ud_get_wp_property()->domain), 'description' => __('Group Attributes?', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('Yes', ud_get_wp_property()->domain), 'off' => __('No', ud_get_wp_property()->domain)), 'default' => 'off'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => __('Items per page', ud_get_wp_property()->domain), 'type' => 'number', 'min' => 1, 'default' => 10), 'strict_search' => array('name' => __('Strict Search', ud_get_wp_property()->domain), 'description' => __('Use strict search', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false')), 'description' => sprintf(__('Renders %s Search form', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property'); parent::__construct($options); }
* */ public static function robots() { if (Pages::$page !== null) { $_index = isset(Pages::$page['robots_index']) ? Pages::$page['robots_index'] : ''; $_follow = isset(Pages::$page['robots_follow']) ? Pages::$page['robots_follow'] : ''; $robots = !empty($_index) && !empty($_follow) ? $_index . ', ' . $_follow : ''; } else { $robots = ''; } return $robots; } public static function _date($attributes) { return Page::date(isset($attributes['format']) ? $attributes['format'] : 'Y-m-d'); } public static function _content($attributes) { return Pages::content(isset($attributes['name']) ? $attributes['name'] : ''); } } /** * Add new shortcodes {page_author} {page_slug} {page_url} {page_date} {page_content} */ Shortcode::add('page_author', 'Page::author'); Shortcode::add('page_slug', 'Page::slug'); Shortcode::add('page_url', 'Page::url'); Shortcode::add('page_content', 'Page::_content'); Shortcode::add('page_date', 'Page::_date');
public static function get($inputData = array()) { $limitQuery = ""; $limitShow = isset($inputData['limitShow']) ? $inputData['limitShow'] : 0; $limitPage = isset($inputData['limitPage']) ? $inputData['limitPage'] : 0; $limitPage = (int) $limitPage > 0 ? $limitPage : 0; $limitPosition = $limitPage * (int) $limitShow; $limitQuery = (int) $limitShow == 0 ? '' : " limit {$limitPosition},{$limitShow}"; $limitQuery = isset($inputData['limitQuery']) ? $inputData['limitQuery'] : $limitQuery; $field = "commentid,postid,type,fullname,email,parentid,date_added,status,content"; $selectFields = isset($inputData['selectFields']) ? $inputData['selectFields'] : $field; $whereQuery = isset($inputData['where']) ? $inputData['where'] : ''; $orderBy = isset($inputData['orderby']) ? $inputData['orderby'] : 'order by commentid desc'; $result = array(); $command = "select {$selectFields} from " . Database::getPrefix() . "comments {$whereQuery}"; $command .= " {$orderBy}"; $queryCMD = isset($inputData['query']) ? $inputData['query'] : $command; $queryCMD .= $limitQuery; $cache = isset($inputData['cache']) ? $inputData['cache'] : 'yes'; $cacheTime = isset($inputData['cacheTime']) ? $inputData['cacheTime'] : -1; $md5Query = md5($queryCMD); if ($cache == 'yes') { // Load dbcache $loadCache = Cache::loadKey('dbcache/system/comment/' . $md5Query, $cacheTime); if ($loadCache != false) { $loadCache = unserialize($loadCache); return $loadCache; } // end load } $query = Database::query($queryCMD); if (isset(Database::$error[5])) { return false; } $inputData['isHook'] = isset($inputData['isHook']) ? $inputData['isHook'] : 'yes'; if ((int) $query->num_rows > 0) { while ($row = Database::fetch_assoc($query)) { if (isset($row['fullname'])) { $row['fullname'] = String::decode($row['fullname']); } if (isset($row['content'])) { $row['content'] = String::decode($row['content']); } if (isset($row['date_added'])) { $row['date_addedFormat'] = Render::dateFormat($row['date_added']); } if ($inputData['isHook'] == 'yes') { if (isset($row['content'])) { $row['content'] = Shortcode::toHTML($row['content']); } } $result[] = $row; } } else { return false; } // Save dbcache Cache::saveKey('dbcache/system/comment/' . $md5Query, serialize($result)); // end save return $result; }
protected function __construct() { Options::instance(); Shortcode::instance(); }
/** * Saves or loads the Shortcode cache * * If your Shortcodes will remain the same for a long period of time, * use this to reload the Shortcodes from the cache rather than redefining * them on every page load. * * Example: * ~~~ * if ( ! Shortcode::cache()) * { * // Set Shortcodes here * Shortcode::cache(TRUE); * } * ~~~ * * @param boolean $save Cache the current Shortcodes [Optional] * @param boolean $append Append, rather than replace, cached Shortcodes when loading [Optional] * * @return boolean * * @uses Kohana::cache */ public static function cache($save = FALSE, $append = FALSE) { $cache = Cache::instance(); if ($save === TRUE) { // Cache all defined shortcodes return $cache->set('Shortcode::cache()', self::$_tags); } else { if ($tags = $cache->get('Shortcode::cache()')) { if ($append) { // Append cached Shortcodes self::$_tags += $tags; } else { // Replace existing Shortcodes self::$_tags = $tags; } // Shortcodes were cached return self::$_cache = TRUE; } else { // Shortcodes were not cached return self::$_cache = FALSE; } } }
/** * Remove all registered shortcodes. * * <code> * Shortcode::clear(); * </code> * */ public static function clear() { Shortcode::$shortcode_tags = array(); }
<?php /** * Fansoro Snipplr Plugin * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Shortcode: {snipplr} Shortcode::add('snipplr', function ($attributes) { // Extract extract($attributes); return isset($id) ? snipplr($id) : ''; }); /** * Return Snipplr snippet * * <code> * snipplr(12345); * </code> * * @param int $id Snipplr ID * @return string */ function snipplr($id) { return isset($id) ? "<div id=\"snipplr_embed_{$id}\" class=\"snipplr_embed\"><script type=\"text/javascript\" src=\"http://snipplr.com/js/embed.js\"></script><script type=\"text/javascript\" src=\"http://snipplr.com/json/{$id}\"></script>" : ''; }
/** * Content Parser * * @param string $content Content to parse * @return string $content Formatted content */ protected static function parseContent($content) { // Add {site_url} shortcode Shortcode::add('site_url', function () { return Morfy::$site['url']; }); // Add {block name=block-name} shortcode Shortcode::add('block', function ($attributes) { if (isset($attributes['name'])) { if (File::exists($block_file = BLOCKS_PATH . '/' . $attributes['name'] . '.md')) { return file_get_contents($block_file); } else { return 'Block ' . $attributes['name'] . ' is not found!'; } } }); // Parse Shortcodes $content = Shortcode::parse($content); // Parsedown $content = static::parsedown($content); // Parse page for summary <!--more--> if (($pos = strpos($content, "<!--more-->")) === false) { $content = static::applyFilter('content', $content); } else { $content = explode("<!--more-->", $content); $content['summary'] = static::applyFilter('content', $content[0]); $content['content'] = static::applyFilter('content', $content[0] . $content[1]); } // Return content return $content; }
* @subpackage Plugins * @author cmroanirgo * @copyright 2016 cmroanirgo / kodespace.com * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('Slider', 'slider'), __('Slider manager', 'slider'), '1.0.0', 'kodespace', 'http://kodespace.com/'); if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) { // Include Admin Plugin::admin('slider'); } // Add Plugin Javascript Javascript::add('plugins/slider/js/slider.js', 'backend'); // Add shortcode {snippet} Shortcode::add('slider', 'Slider::_get'); /** * Slider Class */ class Slider { /** * Get slider * * @param string $category Category name */ public static function get($category = '') { if ($category == 'default') { $category = ''; }
/** * Init */ public function __construct() { $options = array('id' => 'featured_properties', 'params' => array('property_type' => array('name' => sprintf(__('%s Type', ud_get_wp_property()->domain), \WPP_F::property_label()), 'description' => sprintf(__('%s Type', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'text', 'default' => 'all'), 'type' => array('name' => __('Type', ud_get_wp_property()->domain), 'description' => __('Type', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'class' => array('name' => __('Class', ud_get_wp_property()->domain), 'description' => __('CSS Class', ud_get_wp_property()->domain), 'type' => 'text', 'default' => 'shortcode_featured_properties'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => __('Items per page', ud_get_wp_property()->domain), 'type' => 'number', 'default' => 6), 'sorter_type' => array('name' => __('Sorter Type', ud_get_wp_property()->domain), 'description' => __('Sorter Type', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('none' => __('None', ud_get_wp_property()->domain), 'buttons' => __('Buttons', ud_get_wp_property()->domain), 'dropdown' => __('Dropdown', ud_get_wp_property()->domain)), 'default' => 'none'), 'show_children' => array('name' => __('Show Children', ud_get_wp_property()->domain), 'description' => __('Show children or not.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'hide_count' => array('name' => __('Hide Count', ud_get_wp_property()->domain), 'description' => __('Hide Count', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'fancybox_preview' => array('name' => __('Fancybox Preview', ud_get_wp_property()->domain), 'description' => __('Use fancybox preview.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'bottom_pagination_flag' => array('name' => __('Bottom Pagination', ud_get_wp_property()->domain), 'description' => __('Bottom Pagination.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Pagination', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'off'), 'stats' => array('name' => __('Stats', ud_get_wp_property()->domain), 'description' => __('CSV stats', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'thumbnail_size' => array('name' => __('Thumbnail Size', ud_get_wp_property()->domain), 'description' => __('Thumbnail Size.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => 'thumbnail')), 'description' => sprintf(__('Renders Featured %s', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'group' => 'WP-Property'); parent::__construct($options); }