public function get_markup() { $data = $this->properties_to_array(); $data['action'] = home_url('/'); $data['iconClass'] = $data['label'] == '__image__' ? 'icon' : 'text'; return upfront_get_template('usearch', $data, dirname(dirname(__FILE__)) . '/tpl/usearch.html'); }
/** * Template fetching method. * The appropriate element template property is checked first and used if present. * Otherwise, we load up stuff from theme template if present, or fall back to default. * @param string $slug Raw slug for template resolution * @param array $data Raw data (element properties) * @return string Template contents */ public static function get_template($slug, $data = array()) { $slug = self::_get_normalized_slug($slug); $data_key = self::_slug_to_part_key($slug); if (!empty($data) && isset($data[$data_key])) { return $data[$data_key]; } return upfront_get_template("posts-{$slug}", $data, dirname(dirname(__FILE__)) . '/tpl/parts/posts-' . $slug . '.php'); }
public static function get_page_markup($display = 'title', $post_id = 0) { global $post; $post = get_post($post_id); setup_postdata($post); $data = upfront_get_template('this-page-' . $display, array('post' => $post), dirname(dirname(__FILE__)) . '/tpl/this-page-' . $display . '.php'); wp_reset_postdata(); return $data; }
public function get_markup() { $data = $this->properties_to_array(); if ($data['when_clicked'] == 'show_larger_image') { //wp_enqueue_style('magnific'); upfront_add_element_style('magnific', array('/scripts/magnific-popup/magnific-popup.css', false)); //wp_enqueue_script('magnific'); upfront_add_element_script('magnific', array('/scripts/magnific-popup/magnific-popup.min.js', false)); } $data['url'] = $data['when_clicked'] == 'do_nothing' ? false : $data['image_link']; $data['wrapper_id'] = str_replace('image-object-', 'wrapper-', $data['element_id']); $data['wrapper_id'] = 'hello_up'; if ($data['stretch']) { $data['imgWidth'] = '100%'; } else { $data['imgWidth'] = ''; } if ($data['vstretch']) { $data['marginTop'] = 0; } $data['gifImage'] = isset($data['gifImage']) && $data['gifImage'] ? ' uimage-gif' : ''; $data['gifLeft'] = $data['gifImage'] && $data['position']['left'] > 0 ? -$data['position']['left'] . 'px' : 0; $data['gifTop'] = -$data['position']['top'] . 'px'; //Don't let the caption be bigger than the image $data['captionData'] = array('top' => $data['vstretch'] ? 0 : -$data['position']['top'] . 'px', 'left' => $data['stretch'] ? 0 : -$data['position']['left'] . 'px', 'width' => $data['stretch'] ? '100%' : $data['size']['width'] . 'px', 'height' => $data['vstretch'] ? '100%' : $data['size']['height'] . 'px', 'bottom' => $data['vstretch'] ? '100%' : $data['element_size']['height'] + $data['position']['top'] - $data['size']['height'] . 'px'); $data['cover_caption'] = $data['caption_position'] != 'below_image'; // array_search($data['caption_alignment'], array('fill', 'fill_bottom', 'fill_middle')) !== FALSE; $data['placeholder_class'] = !empty($data['src']) ? '' : 'uimage-placeholder'; if ($data['caption_position'] === 'below_image') { $data['captionBackground'] = false; } if (!isset($data['link_target'])) { $data['link_target'] = false; } // Initialize array member to prevent notices // We could really go with wp_parge_args here... $markup = '<div>' . upfront_get_template('uimage', $data, dirname(dirname(__FILE__)) . '/tpl/image.html') . '</div>'; if ($data['when_clicked'] == 'image') { //Lightbox //wp_enqueue_style('magnific'); upfront_add_element_style('magnific', array('/scripts/magnific-popup/magnific-popup.css', false)); //wp_enqueue_script('magnific');//Front script upfront_add_element_script('magnific', array('/scripts/magnific-popup/magnific-popup.min.js', false)); upfront_add_element_script('uimage', array('js/uimage-front.js', dirname(__FILE__))); // $magnific_options = array('type' => 'image', 'delegate' => 'a'); $markup .= ' <script type="text/javascript"> if(typeof ugallery == "undefined") uimages = []; uimages["' . $data['element_id'] . '"] = ' . json_encode($magnific_options) . '; </script> '; } return $markup; }
public function get_markup() { // This data is passed on to the template to precompile template $data = $this->properties_to_array(); $data['wrapper_id'] = str_replace('youtube-object-', 'wrapper-', $data['element_id']); $markup = upfront_get_template('uyoutube', $data, dirname(dirname(__FILE__)) . '/tpl/youtube.html'); // upfront_add_element_style('upfront_youtube', array('css/uyoutube.css', dirname(__FILE__))); upfront_add_element_script('upfront_youtube', array('js/uyoutube-front.js', dirname(__FILE__))); return $markup; }
public function get_markup() { // This data is passed on to the template to precompile template $data = $this->properties_to_array(); $data['preset'] = isset($data['preset']) ? $data['preset'] : 'default'; $data['wrapper_id'] = str_replace('uaccordion-object-', 'wrapper-', $data['element_id']); $markup = upfront_get_template('uaccordion', $data, dirname(dirname(__FILE__)) . '/tpl/uaccordion.html'); // upfront_add_element_style('uaccordion_style', array('css/uaccordion.css', dirname(__FILE__))); upfront_add_element_script('uaccordion_script', array('js/uaccordion-front.js', dirname(__FILE__))); return $markup; }
public function get_markup() { // This data is passed on to the template to precompile template $data = $this->properties_to_array(); // Ensure tab title foreach ($data['tabs'] as $index => $tab) { $ttl = trim(str_replace("\n", '', $tab['title'])); if (empty($ttl)) { $tab['title'] = 'Tab ' . ($index + 1); $data['tabs'][$index] = $tab; } } if (!$data['preset']) { $data['preset'] = 'default'; } $data['wrapper_id'] = str_replace('utabs-object-', 'wrapper-', $data['element_id']); $markup = upfront_get_template('utabs', $data, dirname(dirname(__FILE__)) . '/tpl/utabs.html'); // upfront_add_element_style('upfront_tabs', array('css/utabs.css', dirname(__FILE__))); upfront_add_element_script('upfront_tabs', array('js/utabs-front.js', dirname(__FILE__))); return $markup; }
public function get_markup() { $data = $this->properties_to_array(); $slides = array(); foreach ($data['slides'] as $slide) { $slides[] = array_merge(self::slide_defaults(), $slide); } $data['slides'] = $slides; $data['rotate'] = sizeof($data['rotate']); $data['dots'] = array_search($data['controls'], array('dots', 'both')) !== false; $data['arrows'] = array_search($data['controls'], array('arrows', 'both')) !== false; $data['slidesLength'] = sizeof($slides); $side_style = $data['primaryStyle'] == 'side'; $data['imageWidth'] = $side_style ? floor($data['rightImageWidth'] / $data['rightWidth'] * 100) . '%' : '100%'; $data['textWidth'] = $side_style ? floor(($data['rightWidth'] - $data['rightImageWidth']) / $data['rightWidth'] * 100) . '%' : '100%'; $data['imageHeight'] = sizeof($slides) ? $slides[0]['cropSize']['height'] : 0; $data['production'] = true; $data['startingSlide'] = 0; $markup = upfront_get_template('uslider', $data, dirname(dirname(__FILE__)) . '/tpls/uslider.html'); return $markup; }
public function add_js_defaults($data) { $post_types = get_post_types(array('public' => true), 'objects'); $labels = get_terms('media_label', array('hide_empty' => false)); $labels_names = array(); $labels_ids = array(); foreach ($labels as $label) { if (!is_object($label)) { continue; } $labels_ids[$label->term_id] = array('id' => $label->term_id, 'text' => $label->name); $labels_names[$label->name] = array('id' => $label->term_id, 'text' => $label->name); } // Sanitize post type objects array foreach ($post_types as $ptidx => $ptype) { if (empty($ptype->register_meta_box_cb)) { continue; } $ptype->register_meta_box_cb = false; $post_types[$ptidx] = $ptype; } // Whatever we need in the post types array, I am fairly sure metabox callback is *NOT* one of those things... $data['ugallery'] = array('defaults' => self::default_properties(), 'imageDefaults' => self::image_defaults(), 'template' => upfront_get_template_url('ugallery', upfront_element_url('tpl/ugallery.html', dirname(__FILE__))), 'lightboxTpl' => upfront_get_template('lightbox', array(), dirname(dirname(__FILE__)) . '/tpl/lightbox.html'), 'postTypes' => $post_types, 'grids' => array(), 'label_names' => $labels_names, 'label_ids' => $labels_ids, 'themeDefaults' => apply_filters('upfront_gallery_defaults', array())); return $data; }
public function get_markup() { $data = array(); $data['id'] = $this->_get_property('element_id'); $button_presets = get_option('upfront_' . get_stylesheet() . '_button_presets'); $button_presets = apply_filters('upfront_get_button_presets', $button_presets, array('json' => true)); $presets = json_decode($button_presets, true); $preset = false; $markup = ""; if (is_array($presets)) { foreach ($presets as $item) { if ($item['id'] == $this->_get_property('currentpreset')) { $preset = $item; break; } } } $ufc = Upfront_UFC::init(); $data['content'] = $this->_get_property('content'); if ($data['content'] == '') { $default_properties = $this->default_properties(); $data['content'] = $default_properties['content']; } $data['href'] = $this->_get_property('href'); $data['align'] = $this->_get_property('align'); $data['style_static'] = "border: " . $preset['borderwidth'] . "px " . $preset['bordertype'] . " " . $ufc->process_colors($preset['bordercolor']) . "; " . "border-radius: " . $preset['borderradius1'] . "px " . $preset['borderradius2'] . "px " . $preset['borderradius4'] . "px " . $preset['borderradius3'] . "px; " . "background-color: " . $ufc->process_colors($preset['bgcolor']) . "; " . "font-size: " . $preset['fontsize'] . "px; " . "font-family: " . $preset['fontface'] . "; " . "color: " . $ufc->process_colors($preset['color']) . "; " . "transition: all " . $preset['hov_duration'] . "s " . $preset['hov_transition'] . "; "; $data['style_hover'] = ''; if (isset($preset['hov_borderwidth'])) { $data['style_hover'] = $data['style_hover'] . 'border-width: ' . $preset['hov_borderwidth'] . 'px; '; } if (isset($preset['hov_bordertype'])) { $data['style_hover'] = $data['style_hover'] . 'border-style: ' . $preset['hov_bordertype'] . '; '; } if (isset($preset['hov_bordercolor'])) { $data['style_hover'] = $data['style_hover'] . 'border-color: ' . $ufc->process_colors($preset['hov_bordercolor']) . '; '; } if (isset($preset['hov_borderradius1'])) { $data['style_hover'] = $data['style_hover'] . 'border-top-left-radius: ' . $preset['hov_borderradius1'] . 'px; '; } if (isset($preset['hov_borderradius2'])) { $data['style_hover'] = $data['style_hover'] . 'border-top-right-radius: ' . $preset['hov_borderradius2'] . 'px; '; } if (isset($preset['hov_borderradius3'])) { $data['style_hover'] = $data['style_hover'] . 'border-bottom-right-radius: ' . $preset['hov_borderradius3'] . 'px; '; } if (isset($preset['hov_borderradius4'])) { $data['style_hover'] = $data['style_hover'] . 'border-bottom-left-radius: ' . $preset['hov_borderradius4'] . 'px; '; } if (isset($preset['hov_bgcolor'])) { $data['style_hover'] = $data['style_hover'] . 'background-color: ' . $ufc->process_colors($preset['hov_bgcolor']) . '; '; } if (isset($preset['hov_fontsize'])) { $data['style_hover'] = $data['style_hover'] . 'font-size: ' . $preset['hov_fontsize'] . 'px; '; } if (isset($preset['hov_fontface'])) { $data['style_hover'] = $data['style_hover'] . 'font-family: ' . $preset['hov_fontsize'] . '; '; } if (isset($preset['hov_color'])) { $data['style_hover'] = $data['style_hover'] . 'color: ' . $ufc->process_colors($preset['hov_color']) . '; '; } $data['linkTarget'] = strpos($data['href'], '#') === 0 || strpos($data['href'], 'mailto:') === 0 ? '_self' : $this->_get_property('linkTarget'); /* $data['style_hover'] = "border: ".$preset['hov_borderwidth']."px ".$preset['hov_bordertype']." ".$preset['hov_bordercolor']."; "."border-radius: ".$preset['hov_borderradius1']."px ".$preset['hov_borderradius2']."px ".$preset['hov_borderradius4']."px ".$preset['hov_borderradius3']."px; "."background-color: ".$preset['hov_bgcolor']."; "."font-size: ".$preset['hov_fontsize']."px; "."font-family: ".$preset['hov_fontface']."; "."color: ".$preset['hov_color']."; "; */ $markup = upfront_get_template('ubutton', $data, dirname(dirname(__FILE__)) . '/tpl/ubutton.php.html'); return $markup; }
/** * Parses the PHP file output to a variable */ private function get_template($templatename, $args = array()) { return upfront_get_template('ucontact', $args, dirname(dirname(__FILE__)) . '/templates/ucontact.html'); }
public static function post_template($this_post, $properties = array(), $layoutData = false, $archive = false) { $post_data = self::prepare_post($this_post); $excerpt = false; $layout_type = $archive ? 'archive' : 'single'; $post_type = $this_post->post_type; $layout_id = $this_post->ID; if ($archive) { $layout_id = str_replace('uposts-object-', '', $properties['element_id']); } if (!$layoutData) { $layoutData = self::find_postlayout($layout_type, $post_type, $layout_id); } else { $excerpt = $properties['content_type'] == 'excerpt'; } //?true:false; $templates = self::find_partTemplates($layout_type, $post_type, $layout_id); $options = !empty($layoutData['partOptions']) ? $layoutData['partOptions'] : array(); $layout = array('wrappers' => $layoutData['postLayout'], 'wrappersLength' => sizeof($layoutData['postLayout']), 'extraClasses' => array(), 'attributes' => array()); if (!empty($layout['wrappers']) && is_array($layout['wrappers'])) { foreach ($layout['wrappers'] as $i => $w) { $layout['wrappers'][$i]['objectsLength'] = sizeof($w['objects']); foreach ($w['objects'] as $k => $o) { $opts = !empty($options[$o['slug']]) ? $options[$o['slug']] : array(); // This is for the layout $opts['excerpt'] = $excerpt; $tpl = !empty($templates[$o['slug']]) ? $templates[$o['slug']] : false; $markups = self::get_post_part($o['slug'], $opts, $tpl, $properties); $layout['wrappers'][$i]['objects'][$k]['markup'] = !empty($markups['tpl']) ? $markups['tpl'] : false; $layout['extraClasses'][$o['slug']] = isset($opts['extraClasses']) ? $opts['extraClasses'] : ''; $part_style_class = self::_part_style_class($options, $o["slug"]); $layout['extraClasses'][$o['slug']] .= $part_style_class; if (!empty($markups['classes'])) { $layout['extraClasses'][$o['slug']] .= ' ' . join(' ', $markups['classes']); } $attributes = ''; if (isset($opts['attributes'])) { foreach ($opts['attributes'] as $key => $value) { $attributes .= $key . '="' . $value . '" '; } } $layout['attributes'][$o['slug']] = $attributes; } } } $data = upfront_get_template('content', $layout, get_template_directory() . '/scripts/upfront/templates/content.html'); self::restore_post($post_data); return $data; }
private static function _get_trigger_markup($icon = false, $trigger_label = '') { $tpl = !empty($icon) ? 'icon' : 'link'; return upfront_get_template("login-trigger-{$tpl}", array('label' => $trigger_label), dirname(dirname(__FILE__)) . "/tpl/trigger-{$tpl}.php"); }
public static function list_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; echo upfront_get_template('upfront-comment-list', array('comment' => $comment, 'args' => $args, 'depth' => $depth), upfront_element_dir('templates/upfront-comment-list.php', __DIR__)); }