/**
  * Blockquote shortcode callback
  *
  * @param  array  $atts    shortcode attributes
  * @param  string $content shortcode content
  * @param  string $code    shortcode name
  * @return string          output html
  */
 public static function dispatch($atts, $content, $code)
 {
     extract(shortcode_atts(array('layout' => 'slider', 'cat' => '', 'ids' => '', 'autorotate' => false), $atts));
     $query = array('post_type' => 'testimonials', 'orderby' => 'menu_order', 'order' => 'DESC', 'posts_per_page' => -1);
     if (!empty($cat)) {
         $query['tax_query'] = array(array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => explode(',', $cat)));
     }
     if ($ids && $ids != 'null') {
         $query['post__in'] = explode(',', $ids);
     }
     $q = new WP_Query($query);
     $output = '';
     if ($layout == 'slider') {
         $slides = array();
         while ($q->have_posts()) {
             $q->the_post();
             $slides[] = array('type' => 'html', 'html' => self::format());
         }
         $output = wpv_shortcode_slider(array('pager' => true, 'controls' => false, 'auto' => wpv_sanitize_bool($autorotate)), json_encode($slides), 'slider');
     } else {
         $output .= '<div class="blockquote-list">';
         while ($q->have_posts()) {
             $q->the_post();
             $output .= self::format();
         }
         $output .= '</div>';
     }
     wp_reset_postdata();
     return $output;
 }
예제 #2
0
function wpv_post_meta_default($meta, $global, $post_id = null)
{
    if (is_null($post_id)) {
        $post_id = wpv_get_the_ID();
    }
    $global = wpv_sanitize_bool(wpv_get_option($global));
    $local = wpv_sanitize_bool(wpv_post_meta($post_id, $meta, true));
    $local_raw = wpv_post_meta($post_id, $meta);
    if ($local === 'default' || empty($local_raw)) {
        return $global;
    }
    return $local;
}
예제 #3
0
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['count'] = (int) $new_instance['count'];
     $instance['show_avatar'] = wpv_sanitize_bool($new_instance['show_avatar']);
     $instance['show_post_count'] = wpv_sanitize_bool($new_instance['show_post_count']);
     for ($i = 1; $i <= $instance['count']; $i++) {
         $instance['author_id'][$i] = strip_tags($new_instance["author_id_{$i}"]);
         $instance['author_desc'][$i] = strip_tags($new_instance["author_desc_{$i}"]);
     }
     return $instance;
 }
예제 #4
0
 /**
  * Blog shortcode callback
  *
  * @param  array  $atts    shortcode attributes
  * @param  string $content shortcode content
  * @param  string $code    shortcode name
  * @return string          output html
  */
 public static function shortcode($atts, $content = null, $code = 'blog')
 {
     global $wp_filter;
     extract(shortcode_atts(array('count' => 3, 'column' => 1, 'cat' => '', 'posts' => '', 'image' => 'true', 'show_content' => false, 'nopaging' => true, 'paged' => '', 'width' => 'full', 'layout' => 'normal', 'post__not_in' => ''), $atts));
     $show_content = wpv_sanitize_bool($show_content);
     $nopaging = wpv_sanitize_bool($nopaging);
     $news = in_array($layout, array('scroll-x', 'small', 'masonry'));
     $scrollable = $news && $layout === 'scroll-x';
     $query = array('posts_per_page' => (int) $count, 'post_type' => 'post');
     if ($paged) {
         $query['paged'] = $paged;
     }
     if (!empty($cat)) {
         $query['category__in'] = is_array($cat) ? $cat : explode(',', $cat);
     }
     if ($posts) {
         $query['post__in'] = explode(',', $posts);
     }
     if ($nopaging) {
         $query['paged'] = 1;
     } else {
         $query['paged'] = get_query_var('paged') ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1);
     }
     if (!empty($post__not_in)) {
         $query['post__not_in'] = explode(',', $post__not_in);
     }
     if (!$news) {
         $column = 1;
     }
     $called_from_shortcode = true;
     $column = (int) $column;
     if ($column > 1) {
         $denominator = array('', '', 'half', 'third', 'fourth', 'fifth', 'sixth');
         $width = 'one_' . $denominator[$column];
     }
     ob_start();
     query_posts($query);
     if ($scrollable) {
         include locate_template(array('templates/blog-scrollable.php'));
     } else {
         include locate_template(array('loop.php'));
     }
     $output = ob_get_contents();
     ob_end_clean();
     wp_reset_query();
     wp_reset_postdata();
     return $output;
 }
 public static function shortcode($atts, $content = null, $code)
 {
     extract(shortcode_atts(array('count' => 1, 'cat' => '', 'pagination' => false), $atts));
     $pagination = wpv_sanitize_bool($pagination);
     $query = array('post_type' => 'wpv_sermon', 'posts_per_page' => (int) $count);
     if ($pagination) {
         $query['paged'] = get_query_var('paged') > 1 ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1);
     }
     if (!empty($cat) && !ctype_space($cat[0])) {
         $query['tax_query'] = array(array('taxonomy' => 'wpv_sermons_category', 'field' => 'slug', 'terms' => explode(',', $cat)));
     }
     $query = new WP_Query($query);
     ob_start();
     include locate_template("templates/sermons/loop.php");
     return ob_get_clean();
 }
예제 #6
0
 /**
  * Portfolio shortcode callback
  *
  * @param  array  $atts    shortcode attributes
  * @param  string $content shortcode content
  * @param  string $code    shortcode name
  * @return string          output html
  */
 public static function shortcode($atts, $content = null, $code = 'portfolio')
 {
     global $post;
     extract(shortcode_atts(array('column' => 4, 'cat' => '', 'ids' => '', 'max' => 4, 'height' => 400, 'title' => 'overlay', 'desc' => 'false', 'more' => 'button text', 'nopaging' => 'false', 'group' => 'true', 'layout' => 'static', 'post__not_in' => '', 'engine' => 'isotope', 'class' => '', 'fancy_page' => false), $atts));
     $moreText = $more;
     $more = !empty($moreText);
     $cat = empty($cat) ? array() : (is_array($cat) ? $cat : explode(',', $cat));
     $desc = wpv_sanitize_bool($desc);
     // number of columns - get the css class
     $column = intval($column);
     // get the overall portfolio width
     $central_width = wpv_get_central_column_width();
     $column_width = intval($central_width / $column);
     $size = array($central_width, $height);
     // set the width of a column (without blank space)
     if ($column > 1) {
         $size[0] = round($central_width * (1 - 0.02 * ($column - 1)) / $column);
     }
     $sortable = $layout === 'fit-rows' || $layout === 'masonry' ? $layout : '';
     $paging_preference = !empty($sortable) ? 'paged' : null;
     $scrollable = $layout === 'scrollable';
     if ($scrollable) {
         $nopaging = 'true';
     }
     $rel_group = 'portfolio_' . rand(1, 1000);
     //for lightbox group
     $old_column = isset($GLOBALS['wpv_portfolio_column']) ? $GLOBALS['wpv_portfolio_column'] : null;
     $GLOBALS['wpv_portfolio_column'] = $column;
     $query = array('post_type' => 'portfolio', 'orderby' => array('menu_order' => 'ASC', 'date' => 'DESC'), 'posts_per_page' => $max, 'paged' => $nopaging === 'false' ? get_query_var('paged') > 1 ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1) : 1);
     if (!empty($cat) && !empty($cat[0])) {
         $query['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat));
     }
     if ($ids && $ids != 'null') {
         $query['post__in'] = explode(',', $ids);
     }
     if (!empty($post__not_in)) {
         $query['post__not_in'] = explode(',', $post__not_in);
     }
     query_posts($query);
     ob_start();
     include locate_template('templates/portfolio/loop.php');
     $GLOBALS['wpv_portfolio_column'] = $old_column;
     wp_reset_query();
     return ob_get_clean();
 }
예제 #7
0
 private function display($query, $show_comment = false)
 {
     $show_comment = wpv_sanitize_bool($show_comment);
     $archive_query = new WP_Query($query);
     $output = '';
     global $post;
     while ($archive_query->have_posts()) {
         $archive_query->the_post();
         $title = get_the_title();
         if (!empty($title)) {
             $output .= "<li>\n\t\t\t\t\t\t<a href='" . get_permalink() . "' rel='bookmark' title='" . sprintf(__('Permanent Link to %s', 'honeymoon'), esc_attr($title)) . "'>" . strip_tags($title) . "</a>" . ($show_comment ? " (" . get_comments_number() . ")" : "");
             if ($post->post_type == 'page') {
                 $output .= $this->page_level(-1, get_the_ID());
             }
             $output .= "</li>";
         }
     }
     wp_reset_query();
     return '<ul>' . $output . '</ul>';
 }
예제 #8
0
    /**
     * Column shortcode callback
     *
     * @param  array  $atts    shortcode attributes
     * @param  string $content shortcode content
     * @param  string $code    shortcode name
     * @return string          output html
     */
    public static function dispatch($atts, $content, $code)
    {
        extract(shortcode_atts(array('animation' => 'none', 'background_attachment' => 'scroll', 'background_color' => '', 'background_image' => '', 'background_position' => '', 'background_repeat' => '', 'background_size' => '', 'background_video' => '', 'class' => '', 'extended' => 'false', 'extended_padding' => 'true', 'last' => 'false', 'more_link' => '', 'more_text' => '', 'parallax_bg' => 'disabled', 'parallax_bg_inertia' => '1', 'title' => '', 'title_type' => 'single', 'vertical_padding_bottom' => '0', 'vertical_padding_top' => '0', 'width' => '1/1', 'div_atts' => '', 'left_border' => 'transparent', 'id' => ''), $atts));
        if (!preg_match('/column_\\d+/', $code)) {
            $class .= ' wpv-first-level';
        }
        $GLOBALS['wpv_column_stack'][] = $width;
        $GLOBALS['wpv_last_column_title'] = $title;
        if ($parallax_bg !== 'disabled') {
            $class .= ' parallax-bg';
            $div_atts .= ' data-parallax-method="' . esc_attr($parallax_bg) . '" data-parallax-inertia="' . esc_attr($parallax_bg_inertia) . '"';
            $background_position = 'center top';
            $background_attachment = 'fixed';
        }
        $has_price = strpos($content, '[price') !== false;
        $has_vertical_tabs = preg_match('/\\[tabs.+layout="vertical"/s', $content);
        $width = str_replace('/', '-', $width);
        $title = !empty($title) && !$has_vertical_tabs ? apply_filters('wpv_column_title', $title, $title_type) : '';
        $extended = wpv_sanitize_bool($extended);
        $last = wpv_sanitize_bool($last);
        $first = !$last;
        $id = empty($id) ? 'wpv-column-' . md5(uniqid()) : $id;
        if ($width === '1-1') {
            $first = true;
            $last = true;
        }
        if ($width !== '1-1' || WpvTemplates::get_layout() !== 'full') {
            $extended = false;
        }
        $result = '';
        $result_before = $result_after = $content_before = $content_after = '';
        if (self::$in_row > self::$last_row) {
            $rowclass = $has_price ? 'has-price' : '';
            $class .= ' first';
            $result .= '<div class="row ' . $rowclass . '">';
            self::$last_row = self::$in_row;
        }
        if (!empty($background_image)) {
            $background_image = "\n\t\t\t\tbackground: url('{$background_image}') {$background_repeat} {$background_position};\n\t\t\t\tbackground-size: {$background_size};\n\t\t\t\tbackground-attachment: {$background_attachment};\n\t\t\t";
        }
        $inner_style = '';
        $l = new WpvLessc();
        $l->importDir = '.';
        $l->setFormatter("compressed");
        if (!empty($background_color) && $background_color !== 'transparent') {
            $color = wpv_sanitize_accent($background_color);
            $inner_style .= $l->compile("\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) >= @treshold ) {\n\t\t\t\t\tcolor: darken(@bgcolor, @diff);\n\t\t\t\t}\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) < @treshold ) {\n\t\t\t\t\tcolor: lighten(@bgcolor, @diff);\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) when (iscolor(@bgcolor)) {\n\t\t\t\t\tbackground-color: @bgcolor;\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) {}\n\n\t\t\t\t#{$id} {\n\t\t\t\t\tp,\n\t\t\t\t\tem,\n\t\t\t\t\t.column-title,\n\t\t\t\t\t.sep-text h2.regular-title-wrapper,\n\t\t\t\t\t.text-divider-double,\n\t\t\t\t\t.sep-text .sep-text-line,\n\t\t\t\t\t.sep,\n\t\t\t\t\t.sep-2,\n\t\t\t\t\t.sep-3 {\n\t\t\t\t\t\t.readable-color({$color});\n\t\t\t\t\t}\n\n\t\t\t\t\t&:before {\n\t\t\t\t\t\t.safe-bg({$left_border});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t");
            $background_color = "background-color:" . wpv_sanitize_accent($background_color) . ";";
        } else {
            $background_color = '';
        }
        if (!empty($left_border) && $left_border !== 'transparent') {
            $inner_style .= $l->compile("\n\t\t\t\t.safe-bg(@bgcolor) when (iscolor(@bgcolor)) {\n\t\t\t\t\tbackground-color: @bgcolor;\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) {}\n\n\t\t\t\t#{$id} {\n\t\t\t\t\t&:before {\n\t\t\t\t\t\t.safe-bg({$left_border});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t");
        }
        if (!empty($inner_style)) {
            $content_before .= '<style>' . $inner_style . '</style>';
        }
        if (!empty($more_link) && !empty($more_text) && !$extended) {
            $class .= ' has-more-button';
            $more_link = esc_attr($more_link);
            $content_after .= "<a href='{$more_link}' title='" . esc_attr($more_text) . "' class='column-read-more-btn'>{$more_text}</a>";
        }
        if (!empty($background_video) && !WpvMobileDetect::getInstance()->isMobile()) {
            $type = wp_check_filetype($background_video, wp_get_mime_types());
            $content_before .= '<div class="wpv-video-bg">
				<video autoplay loop preload="metadata" width="100%" class="wpv-background-video" style="width:100%">
					<source type="' . $type['type'] . '" src="' . $background_video . '"></source>
				</video>
			</div><div class="wpv-video-bg-content">';
            $content_after .= '</div>';
            $class .= ' has-video-bg';
            wp_enqueue_style('wp-mediaelement');
            wp_enqueue_script('wp-mediaelement');
        }
        if (!empty($background_image) || !empty($background_color) && $background_color !== 'transparent') {
            $class .= ' has-background';
        }
        if ((int) $vertical_padding_top < 0) {
            $div_atts .= ' data-padding-top="' . (int) $vertical_padding_top . '"';
        }
        if ((int) $vertical_padding_bottom < 0) {
            $div_atts .= ' data-padding-bottom="' . (int) $vertical_padding_bottom . '"';
        }
        $vertical_padding_top = max(0, (int) $vertical_padding_top) . 'px';
        $vertical_padding_bottom = max(0, (int) $vertical_padding_bottom) . 'px';
        $style = 'style="' . $background_image . $background_color . 'padding-top:' . $vertical_padding_top . ';padding-bottom:' . $vertical_padding_bottom . '"';
        $class .= $extended ? ' extended' : ' unextended';
        if ($left_border != 'transparent') {
            $class .= ' left-border';
        }
        if ($animation !== 'none' && $parallax_bg == 'disabled') {
            $class .= ' animation-' . $animation . ' animated-active';
        }
        if ($extended_padding === 'false') {
            $class .= ' no-extended-padding';
        }
        if ($extended) {
            $content_before = '<div class="extended-column-inner">' . $content_before;
            $content_after .= '</div>';
        }
        $result .= '<div class="wpv-grid grid-' . $width . ' ' . $class . '" ' . $style . ' id="' . $id . '" ' . $div_atts . '>' . $content_before . $title . self::content($content) . $content_after . '</div>';
        if ($last) {
            self::$last_row--;
            $result .= '</div>';
        }
        array_pop($GLOBALS['wpv_column_stack']);
        return $result_before . $result . $result_after;
    }