Example #1
0
 function prefix($clone_id = false)
 {
     if (pl_has_editor() && isset($this->meta['clone'])) {
         $prefix = sprintf('.section-%s[data-clone="%s"]', $this->id, $this->meta['clone']);
     } elseif ($clone_id && $clone_id != '') {
         $prefix = sprintf('.section-%s.clone_%s', $this->id, $clone_id);
     } else {
         $prefix = '';
     }
     return $prefix;
 }
Example #2
0
 /**
  *
  * @TODO document
  *
  */
 function pagelines_show_content($post = null)
 {
     // For Hook Parsing
     if (is_admin()) {
         return true;
     }
     // show on single post pages only
     if (is_page() || is_single()) {
         return true;
     } elseif (pl_has_editor() && $this->section->opt('show_content')) {
         return true;
     } elseif (is_home() && pl_setting('content_blog')) {
         return true;
     } elseif (is_search() && pl_setting('content_search')) {
         return true;
     } elseif (is_category() && pl_setting('content_category')) {
         return true;
     } elseif (!is_category() && is_archive() && pl_setting('content_archive')) {
         return true;
     } else {
         return false;
     }
 }
Example #3
0
/**
 * Add pages to main settings area.
 *
 * @since 2.2
 *
 * @param $args Array as input.
 * @param string $name Name of page.
 * @param string $title Title of page.
 * @param string $path Function use to get page contents.
 * @param array $array Array containing page page of settings.
 * @param string $type Type of page.
 * @param string $raw Send raw HTML straight to the page.
 * @param string $layout Layout type.
 * @param string $icon URI for page icon.
 * @param int $postion Position to insert into main menu.
 * @return array $optionarray
 */
function pl_add_options_page($args)
{
    if (pl_has_editor()) {
        global $pagelines_add_settings_panel;
        $d = array('name' => 'No Name', 'icon' => 'icon-edit', 'pos' => 10, 'opts' => array());
        if (!isset($args['opts']) && isset($args['array'])) {
            $args['opts'] = $args['array'];
        }
        if (!isset($args['pos']) && isset($args['position'])) {
            $args['pos'] = $args['position'];
        }
        $a = wp_parse_args($args, $d);
        $id = pl_create_id($a['name']);
        // make sure its not set elsewhere. Navbar was already set, and we were writing twice
        if (!isset($pagelines_add_settings_panel[$id])) {
            $pagelines_add_settings_panel[$id] = $a;
        }
    }
}
 function section_template()
 {
     if (function_exists('pl_has_editor') && pl_has_editor()) {
         $clone_id = $this->get_the_id();
     }
     global $post;
     $orderby = $this->opt('tps_post_orderby') ? $this->opt('tps_post_orderby') : 'date';
     $sorting = $this->opt('tps_post_sort') ? $this->opt('tps_post_sort') : 'DESC';
     $bgsize = $this->opt('tps_background_size') ? $this->opt('tps_background_size') : 'cover';
     $bgsize = sprintf('-webkit-background-size: %1$s; -moz-background-size: %1$s; -o-background-size: %1$s; background-size: %1$s;', $bgsize);
     $bgposition = $this->opt('tps_background_position') ? $this->opt('tps_background_position') : 'center';
     $size = $this->opt('tps_sizes') ? $this->opt('tps_sizes') : 'aspect-thumb';
     if (!in_array($size, get_intermediate_image_sizes())) {
         $size = 'full';
     }
     $total = $this->opt('tps_total') ? $this->opt('tps_total') : 10;
     $sliderheight = $this->opt('tps_slider_height') ? $this->opt('tps_slider_height') : '300';
     $sliderheight = preg_replace('/[^0-9]/', '', $sliderheight);
     $sliderheight = $sliderheight ? $sliderheight : '300';
     $sliderheight = sprintf('%spx', $sliderheight);
     $trayposition = $this->opt('tps_tray_position') ? $this->opt('tps_tray_position') : 'right';
     $trayoverflow = $this->opt('tps_tray_overflow') ? $this->opt('tps_tray_overflow') : 'auto';
     $fimageposition = $trayposition == 'right' ? 'left' : 'right';
     $traycols = $this->opt('tps_tray_cols') ? $this->opt('tps_tray_cols') : 4;
     $fimagecols = 12 - $traycols;
     $trayimageclass = $this->opt('tps_tray_custom_class') ? '' : 'pl-imageframe';
     $trayimagemetakey = $this->opt('tps_tray_image_meta_key') ? $this->opt('tps_tray_image_meta_key') : '';
     $trayimagefallback = $this->opt('tps_tray_image_fallback') ? $this->opt('tps_tray_image_fallback') : '';
     $titletag = $this->opt('tps_title_tag') ? $this->opt('tps_title_tag') : 'h5';
     $titlemetakey = $this->opt('tps_title_meta_key') ? $this->opt('tps_title_meta_key') : '';
     $excerptmetakey = $this->opt('tps_excerpt_meta_key') ? $this->opt('tps_excerpt_meta_key') : '';
     $titleoff = $this->opt('tps_title_off') ? $this->opt('tps_title_off') : '';
     $titlelimit = $this->opt('tps_title_limit');
     if ($titlelimit != '' && $titlelimit == 0) {
         $titlelimit = 'no';
     } elseif ($titlelimit) {
         $titlelimit = $titlelimit;
     } else {
         $titlelimit = 10;
     }
     $excerptoff = $this->opt('tps_excerpt_off') ? $this->opt('tps_excerpt_off') : '';
     $excerptlimit = $this->opt('tps_excerpt_limit');
     if ($excerptlimit != '' && $excerptlimit == 0) {
         $excerptlimit = 'no';
     } elseif ($excerptlimit) {
         $excerptlimit = $excerptlimit;
     } else {
         $excerptlimit = 15;
     }
     $morelinkoff = $this->opt('tps_more_link_off') ? $this->opt('tps_more_link_off') : '';
     $morelinktext = $this->opt('tps_more_link_text') ? $this->opt('tps_more_link_text') : 'More <i class="fa fa-caret-right"></i>';
     $the_query = array('post_type' => $this->tps_get_post_type(), 'orderby' => $orderby, 'order' => $sorting, 'posts_per_page' => $total);
     //if( $this->opt('tps_require_featured_image') ){
     $the_query['meta_key'] = '_thumbnail_id';
     //}
     if ($this->tps_get_term_ids()) {
         $the_query['tax_query'] = array(array('taxonomy' => $this->tps_get_taxonomy(), 'field' => 'id', 'terms' => $this->tps_get_term_ids()));
     } elseif ($this->tps_get_taxonomy()) {
         $the_query['tax_query'] = array(array('taxonomy' => $this->tps_get_taxonomy(), 'field' => 'id', 'terms' => $this->tps_alltermids()));
     } else {
     }
     $needmetakey = $this->opt('tps_filter_meta_key');
     $needmetavalue = $this->opt('tps_filter_meta_value');
     if (isset($needmetakey) && $needmetakey != '' && isset($needmetavalue) && $needmetavalue != '') {
         $the_query['meta_key'] = $needmetakey;
         $the_query['meta_value'] = $needmetavalue;
     }
     $posts = get_posts($the_query);
     if (!empty($posts)) {
         setup_postdata($post);
         $output = sprintf('<div id="tps-wrap-%s" class="tps-wrap flexslider">', $clone_id);
         $output .= sprintf('<ul class="tps-items slides" style="max-height: %s;">', $sliderheight);
         foreach ($posts as $post) {
             setup_postdata($post);
             $output .= '<li class="row row-closed tps-item">';
             $link = get_permalink($post->ID);
             //alternatives: https://github.com/pagelines/DMS/blob/1.2/includes/lib.utils.php#L605 -- custom_trim_excerpt, improved_trim_excerpt, pl_short_excerpt
             if ($titlemetakey) {
                 $title = get_post_meta($post->ID, $titlemetakey, true);
             } else {
                 $title = '';
             }
             $title = $title ? $title : $post->post_title;
             if ($titlelimit != 'no') {
                 $title = wp_trim_words($title, $titlelimit);
             }
             if ($excerptmetakey) {
                 $excerpt = get_post_meta($post->ID, $excerptmetakey, true);
             } else {
                 $excerpt = '';
             }
             $excerpt = $excerpt ? $excerpt : get_the_excerpt();
             if ($excerptlimit != 'no') {
                 $excerpt = wp_trim_words($excerpt, $excerptlimit);
             }
             if (empty($excerpt)) {
                 $excerptoff = 'off';
             }
             if (has_post_thumbnail()) {
                 $fimage = get_post_thumbnail_id($post->ID);
                 $fimage = wp_get_attachment_image_src($fimage, $size);
                 $fimage = $fimage[0];
                 $fimage = str_replace('http://', '//', $fimage);
             }
             $fimage = sprintf('<div class="tps-fimage tps-fimage-%s span%s" style="height:%s; background-image: url(\'%s\'); background-position: %s; %s"></div>', $fimageposition, $fimagecols, $sliderheight, $fimage, $bgposition, $bgsize);
             $trayimage = $trayimagemetakey ? get_post_meta($post->ID, $trayimagemetakey, true) : '';
             //http://php.net/manual/en/function.getimagesize.php or something similar to wp_attachment_is_image() -- http://codex.wordpress.org/Function_Reference/wp_attachment_is_image
             if ($trayimage) {
                 if (getimagesize($trayimage) === false) {
                     $trayimage = '';
                 }
             }
             if (!$trayimage && $trayimagefallback) {
                 $trayimage = $trayimagefallback;
             }
             $trayimage = str_replace('http://', '//', $trayimage);
             $trayimageexists = $trayimage ? 'yes' : 'no';
             if ($trayimageexists == 'yes') {
                 $trayimagecode = sprintf('<a href="%s"><img class="tps-tray-custom center %s" src="%s" title="%s" alt="%s" /></a>', $link, $trayimageclass, $trayimage, $title, $excerpt);
             } else {
                 $trayimagecode = '';
             }
             $tray = sprintf('<div class="tps-tray-wrap tps-tray-wrap-%s span%s" style="height:%s; overflow: %s">', $trayposition, $traycols, $sliderheight, $trayoverflow);
             $tray .= '<div class="tps-tray">';
             $tray .= $trayimagecode;
             if (!$titleoff) {
                 $tray .= sprintf('<a href="%s"><%s class="tps-tray-title center">%s</%s></a>', $link, $titletag, $title, $titletag);
             }
             if (!$excerptoff) {
                 $tray .= sprintf('<p class="tps-tray-excerpt">%s', $excerpt);
                 if (!$morelinkoff) {
                     $tray .= sprintf(' <a class="tps-tray-more-link" href="%s">%s</a></p>', $link, $morelinktext);
                 } else {
                     $tray .= '</p>';
                 }
             }
             $tray .= '</div></div>';
             if ($trayposition == 'right') {
                 $output .= $fimage;
                 $output .= $tray;
             } else {
                 $output .= $tray;
                 $output .= $fimage;
             }
             $output .= '</li>';
         }
         $output .= '</ul></div>';
         echo $output;
     } else {
         if (!current_user_can('edit_posts')) {
             return;
         } else {
             $errormessage = '[pl_alertbox type="error" closable="yes"]Tray Post Slider was setup in a way that did not select any posts. Please edit this section\'s post selection or add posts to the selection so there will be section output. <em>(message only shown to Contributors and higher)</em>[/pl_alertbox]';
             echo do_shortcode($errormessage);
         }
     }
 }