示例#1
2
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => 3, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'show_child_cat' => '', 'tag_slug' => '', 'header_color' => ''), $atts));
     $buffy = '';
     //output buffer
     $td_unique_id = td_global::td_generate_unique_id();
     $td_query =& td_data_source::get_wp_query($atts);
     //by ref  do the query
     //get the js for this block
     $buffy .= $this->get_block_js($atts, $td_query);
     $buffy .= '<div class="td_block_wrap td_block7">';
     //get the block title
     $buffy .= $this->get_block_title($atts);
     //get the sub category filter for this block
     $buffy .= $this->get_block_sub_cats($atts, $td_unique_id);
     $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
     //inner content of the block
     $buffy .= $this->inner($td_query->posts);
     $buffy .= '</div>';
     //get the ajax pagination for this block
     $buffy .= $this->get_block_pagination($atts, $td_unique_id);
     $buffy .= '</div> <!-- ./block1 -->';
     return $buffy;
 }
 /**
  * @todo mega menu subcats - folosim functia asta pentru ca e necesar sa avem alt output
  * @return bool|string
  */
 function get_pull_down_filter()
 {
     extract(shortcode_atts(array('limit' => 5, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'custom_title' => '', 'custom_url' => '', 'show_child_cat' => '', 'sub_cat_ajax' => ''), $this->atts));
     $buffy = '';
     if (!empty($show_child_cat) and !empty($category_id)) {
         $td_subcategories = get_categories(array('child_of' => $category_id));
         if (!empty($td_subcategories)) {
             if ($show_child_cat != 'all') {
                 $td_subcategories = array_slice($td_subcategories, 0, $show_child_cat);
             }
             $buffy .= '<div class="block-mega-child-cats">';
             //show all categories only on ajax
             if (empty($sub_cat_ajax)) {
                 $buffy .= '<a class="cur-sub-cat mega-menu-sub-cat-' . $this->block_uid . '" id="' . td_global::td_generate_unique_id() . '" data-td_block_id="' . $this->block_uid . '" data-td_filter_value="" href="' . get_category_link($category_id) . '">' . __td('All') . '</a>';
             }
             foreach ($td_subcategories as $td_category) {
                 $buffy .= '<a class="mega-menu-sub-cat-' . $this->block_uid . '"  id="' . td_global::td_generate_unique_id() . '" data-td_block_id="' . $this->block_uid . '" data-td_filter_value="' . $td_category->cat_ID . '" href="' . get_category_link($td_category->cat_ID) . '">' . $td_category->name . '</a>';
             }
             $buffy .= '</div>';
         } else {
             //there are no subcategories, return false - this is used by the mega menu block to alter it's structure
             return false;
         }
     }
     return $buffy;
 }
 function render($atts, $content = null)
 {
     parent::render($atts);
     // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
     // we have no related posts to display
     if ($this->td_query->post_count == 0) {
         return;
     }
     $buffy = '';
     //output buffer
     //get the js for this block
     $buffy .= $this->get_block_js();
     $buffy .= '<div class="' . $this->get_block_classes() . '">';
     //get the filter for this block
     $buffy .= '<h4 class="td-related-title">';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-left td-cur-simple-item" data-td_filter_value="" data-td_block_id="' . $this->block_uid . '" href="#">' . __td('RELATED ARTICLES') . '</a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_related_more_from_author" data-td_block_id="' . $this->block_uid . '" href="#">' . __td('MORE FROM AUTHOR') . '</a>';
     $buffy .= '</h4>';
     $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
     $buffy .= $this->inner($this->td_query->posts);
     //inner content of the block
     $buffy .= '</div>';
     //get the ajax pagination for this block
     $buffy .= $this->get_block_pagination();
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
示例#4
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '251, 252, 253, 254, 255, 256, 257, 258, 305, 306, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy = '';
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title_raw($atts, 'Popular category');
     if (!empty($categories)) {
         $buffy .= '<ul>';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
示例#5
0
 /**
  * renders the filter of the block
  * @return string
  */
 function get_pull_down_filter()
 {
     $buffy = '';
     if (empty($this->template_data_array['td_pull_down_items'])) {
         return '';
     }
     //generate unique id for this pull down filter control
     $pull_down_wrapper_id = "td_pulldown_" . $this->template_data_array['block_uid'];
     // wrapper
     $buffy .= '<div class="td-subcat-filter" id="' . $pull_down_wrapper_id . '">';
     // subcategory list
     $buffy .= '<ul class="td-subcat-list" id="' . $pull_down_wrapper_id . '_list">';
     foreach ($this->template_data_array['td_pull_down_items'] as $item) {
         $buffy .= '<li class="td-subcat-item"><a class="td-subcat-link" id="' . td_global::td_generate_unique_id() . '" data-td_filter_value="' . $item['id'] . '" data-td_block_id="' . $this->template_data_array['block_uid'] . '" href="#">' . $item['name'] . '</a></li>';
     }
     $buffy .= '</ul>';
     // subcategory dropdown list
     $buffy .= '<div class="td-subcat-dropdown">';
     $buffy .= '<div class="td-subcat-more" aria-haspopup="true"><span>' . __td('More', TD_THEME_NAME) . '</span><i class="td-icon-read-down"></i></div>';
     // the dropdown list
     $buffy .= '<ul class="td-pulldown-filter-list">';
     $buffy .= '</ul>';
     $buffy .= '</div>';
     $buffy .= '</div>';
     return $buffy;
 }
 function render($atts, $content = null)
 {
     parent::render($atts);
     // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
     // this block need td_column_number to add rows if more posts are displayed on a post.
     /// the td_column_number is not standard here, it's    5 for full width / 3 for content + sidebar
     extract(shortcode_atts(array('td_column_number' => ''), $atts));
     // we have no related posts to display
     if ($this->td_query->post_count == 0) {
         return;
     }
     $buffy = '';
     //output buffer
     //get the js for this block
     $buffy .= $this->get_block_js();
     $buffy .= '<div class="' . $this->get_block_classes() . '">';
     //get the filter for this block
     $buffy .= '<h4 class="td-related-title">';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-left td-cur-simple-item" data-td_filter_value="" data-td_block_id="' . $this->block_uid . '" href="#">' . __td('RELATED ARTICLES', TD_THEME_NAME) . '</a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_related_more_from_author" data-td_block_id="' . $this->block_uid . '" href="#">' . __td('MORE FROM AUTHOR', TD_THEME_NAME) . '</a>';
     $buffy .= '</h4>';
     $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
     $buffy .= $this->inner($this->td_query->posts, $td_column_number);
     //inner content of the block
     $buffy .= '</div>';
     //get the ajax pagination for this block
     $buffy .= $this->get_block_pagination();
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
 function render($atts, $content = null)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     $buffy = '';
     //output buffer
     extract(shortcode_atts(array('limit' => 4, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'tag_slug' => '', 'force_columns' => '', 'autoplay' => '', 'offset' => 0), $atts));
     if (empty($td_column_number)) {
         $td_column_number = td_util::vc_get_column_number();
         // get the column width of the block
     }
     if ($td_column_number == 3) {
         $current_limit = intval($limit);
         $post_limit = constant(get_class($this->internal_block_instance) . '::POST_LIMIT');
         $td_query = td_data_source::get_wp_query($atts);
         if (!empty($td_query->posts)) {
             if ($current_limit > $post_limit and count($td_query->posts) > $post_limit) {
                 $buffy .= '<div class="td-big-grid-slide td_block_wrap" id="iosSlider_' . $this->block_uid . '">';
                 $buffy .= '<div class="td-theme-slider td_block_inner" id="' . $this->block_uid . '">';
                 $current_offset = 0;
                 $atts['class'] = 'item';
                 while ($current_limit > 0) {
                     $atts['offset'] = $offset + $current_offset;
                     $buffy .= $this->internal_block_instance->render($atts);
                     $current_offset += $post_limit;
                     $current_limit -= $post_limit;
                 }
                 $buffy .= '</div>';
                 //end slider (if slider)
                 $buffy .= '<i class = "td-icon-left"></i>';
                 $buffy .= '<i class = "td-icon-right"></i>';
                 $buffy .= '</div>';
                 //end iosSlider (if slider)
                 $autoplay_settings = '';
                 $current_autoplay = filter_var($autoplay, FILTER_VALIDATE_INT);
                 if ($current_autoplay !== false) {
                     $autoplay_settings = 'autoSlide: true, autoSlideTimer: ' . $current_autoplay * 1000 . ',';
                 }
                 $slide_javascript = ';jQuery(document).ready(function() {
                     jQuery("#iosSlider_' . $this->block_uid . '").iosSlider({
                         snapToChildren: true,
                         desktopClickDrag: true,
                         keyboardControls: true,
                         responsiveSlides: true,
                         infiniteSlider: true,
                         ' . $autoplay_settings . '
                         navPrevSelector: jQuery("#iosSlider_' . $this->block_uid . ' .td-icon-left"),
                         navNextSelector: jQuery("#iosSlider_' . $this->block_uid . ' .td-icon-right")
                     });
                 });';
                 td_js_buffer::add_to_footer($slide_javascript);
             } else {
                 $buffy .= $this->internal_block_instance->render($atts);
             }
         }
     }
     return $buffy;
 }
 static function render_generic($atts, $list_type)
 {
     $block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     $buffy = '';
     //output buffer
     $buffy .= '<div class="td_block_wrap td_block_video_playlist">';
     $buffy .= '<div id=' . $block_uid . ' class="td_block_inner">';
     //inner content of the block
     $buffy .= self::inner($list_type);
     $buffy .= '</div>';
     $buffy .= '</div> <!-- ./block_video_playlist -->';
     return $buffy;
 }
示例#9
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('alias' => ''), $atts));
     $buffy = '';
     $buffy .= '<div class="td_block_wrap td_revolution_slider">';
     $buffy .= $this->get_block_title_raw($atts, '');
     $buffy .= '<div class="td_mod_wrap">';
     $buffy .= do_shortcode('[rev_slider ' . $alias . ']');
     $buffy .= '</div>';
     $buffy .= '</div>';
     return $buffy;
 }
示例#10
0
 function render_before_list_wrap()
 {
     if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') {
         $td_class_nr_of_columns = ' td-3-columns ';
     } else {
         $td_class_nr_of_columns = ' td-2-columns ';
     }
     $buffy = '';
     //generate unique gallery slider id
     $this->smart_list_tip_1_unique_id = 'smart_list_tip1_' . td_global::td_generate_unique_id();
     //wrapper with id for smart list wrapper type 1
     $buffy .= '<div class="td_smart_list_1' . $td_class_nr_of_columns . '">';
     $buffy .= '<div class="td-controls"><a class="td-left-smart-list doubleSliderPrevButton" href="#" onclick="return false;"><i class = "td-icon-left"></i>' . __td('Prev', TD_THEME_NAME) . '</a><a class="td-right-smart-list doubleSliderNextButton" href="#" onclick="return false;">' . __td('Next', TD_THEME_NAME) . '<i class = "td-icon-right"></i></a></div>';
     $buffy .= '<div class="td-iosSlider td-smart-list-slider" id="' . $this->smart_list_tip_1_unique_id . '">';
     $buffy .= '<div class ="td-slider">';
     return $buffy;
 }
示例#11
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => 5, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'show_child_cat' => '', 'tag_slug' => '', 'header_color' => ''), $atts));
     $buffy = '';
     //output buffer
     $td_unique_id = td_global::td_generate_unique_id();
     //custom categories
     //get subcategories, it returns false if there are no categories
     $get_block_sub_cats = $this->get_block_sub_cats($atts, $td_unique_id);
     $buffy_categories = '';
     $td_no_subcats_class = '';
     //we have subcategories
     if ($get_block_sub_cats !== false) {
         $buffy_categories .= '<div class="td_mega_menu_sub_cats">';
         //get the sub category filter for this block
         $buffy_categories .= $get_block_sub_cats;
         $buffy_categories .= '</div>';
         $atts['limit'] = 4;
         //alter the loop because we don't have space now with the categories
     } else {
         $td_no_subcats_class = ' td-no-subcats';
     }
     //end custom categories
     $td_query =& td_data_source::get_wp_query($atts);
     //by ref  do the query
     //get the js for this block
     $buffy .= $this->get_block_js($atts, $td_query);
     $buffy .= '<div class="td_block_wrap td_block_mega_menu' . $td_no_subcats_class . '">';
     //get the block title
     //$buffy .= $this->get_block_title($atts);
     //add the categories IF we have some
     $buffy .= $buffy_categories;
     $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner animated fadeInDown">';
     //inner content of the block
     $buffy .= $this->inner($td_query->posts);
     $buffy .= '</div>';
     $buffy .= $this->get_block_pagination($atts, $td_unique_id);
     //get the ajax pagination for this block
     $buffy .= '<div class="clearfix"></div>';
     $buffy .= '</div> <!-- ./block1 -->';
     return $buffy;
 }
 function render($atts, $content = null)
 {
     parent::render($atts);
     // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
     // this block need td_column_number to add rows if more posts are displayed on a post.
     /// the td_column_number is not standard here, it's    5 for full width / 3 for content + sidebar
     extract(shortcode_atts(array('td_column_number' => ''), $atts));
     // we have no related posts to display
     if ($this->td_query->post_count == 0) {
         return;
     }
     $buffy = '';
     //output buffer
     //get the js for this block
     $buffy .= $this->get_block_js();
     $buffy .= '<div class="' . $this->get_block_classes() . '">';
     //get the filter for this block
     $buffy .= '<h4 class="td-related-title">';
     // $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-left td-cur-simple-item" data-td_filter_value="" data-td_block_id="' . $this->block_uid . '" href="#">' . __td('RELATED ARTICLES', TD_THEME_NAME) . '</a>';
     $buffy .= '<span class="title-inner">' . __td('RELATED ARTICLES', TD_THEME_NAME) . '</span>';
     // ZA Custom
     $buffy .= '<div id="related-filter">Filter <img src="/wp-content/uploads/2015/12/icon-caret-down_white.png" alt=""></div>';
     $buffy .= '<div class="td-related-mobile">';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right " data-td_filter_value="td_related_more_from_author" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="NEUTRAL" src="/wp-content/uploads/2015/12/icon-articleNeutual.png" alt=""><img class="NEUTRAL-hover" src="/wp-content/uploads/2015/12/icon-articleNeutual-selected.png" alt=""><span> NEUTRAL</span></div></div></a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_tag_slug_filter_happy" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="HAPPY" src="/wp-content/uploads/2015/12/icon-articleHappy.png" alt=""><img class="HAPPY-hover" src="/wp-content/uploads/2015/12/icon-articleHappy-selected.png" alt=""><span> HAPPY</span></div></div></a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_tag_slug_filter_funny" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="HAPPY" src="/wp-content/uploads/2015/12/icon-articleFunny.png" alt=""><img class="HAPPY-hover" src="/wp-content/uploads/2015/12/icon-articleFunny-selected.png" alt=""><span> FUNNY</span></div></div></a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_tag_slug_filter_romantic" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="HAPPY" src="/wp-content/uploads/2015/12/icon-articleRomantic.png" alt=""><img class="HAPPY-hover" src="/wp-content/uploads/2015/12/icon-articleRomantic-selected.png" alt=""><span> ROMANTIC</span></div></div></a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_tag_slug_filter_surprised" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="HAPPY" src="/wp-content/uploads/2015/12/icon-articleSurprised.png" alt=""><img class="HAPPY-hover" src="/wp-content/uploads/2015/12/icon-articleSurprised-selected.png" alt=""><span> SURPRISED</span></div></div></a>';
     $buffy .= '<a id="' . td_global::td_generate_unique_id() . '" class="td-related-right" data-td_filter_value="td_tag_slug_filter_sad" data-td_block_id="' . $this->block_uid . '" href="#"><div class="td-related-mobile-inner"><div class="icon-title"><img class="HAPPY" src="/wp-content/uploads/2015/12/icon-articleSad.png" alt=""><img class="HAPPY-hover" src="/wp-content/uploads/2015/12/icon-articleSad-selected.png" alt=""><span> SAD</span></div></div></a>';
     $buffy .= '</div>';
     // End ZA Custom
     $buffy .= '</h4>';
     $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
     $buffy .= $this->inner($this->td_query->posts, $td_column_number);
     //inner content of the block
     $buffy .= '</div>';
     //get the ajax pagination for this block
     $buffy .= $this->get_block_pagination();
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
示例#13
0
 function inner($posts, $td_column_number = '')
 {
     $buffy = '';
     $navigation = '';
     if (!empty($this->atts['navigation'])) {
         $navigation = $this->atts['navigation'];
     }
     $td_block_layout = new td_block_layout();
     if (!empty($posts)) {
         $buffy .= $td_block_layout->open_row();
         $trending_now_unique_id = td_global::td_generate_unique_id();
         //generate unique id for this object
         $buffy .= '<div class="td-trending-now-wrapper" id="' . $trending_now_unique_id . '" data-start="' . esc_attr($navigation) . '">';
         $buffy .= '<div class="td-trending-now-title">' . __td('Trending Now', TD_THEME_NAME) . '</div><div class="td-trending-now-display-area">';
         foreach ($posts as $post_count => $post) {
             $td_module_trending_now = new td_module_trending_now($post);
             $buffy .= $td_module_trending_now->render($post_count);
         }
         $buffy .= '</div>';
         // ZA Cutom
         // $buffy .= '<div class="td-next-prev-wrap">';
         //     $buffy .= '<a href="#"
         //                   class="td_ajax-prev-pagex td-trending-now-nav-left"
         //                   data-wrapper-id="' . $trending_now_unique_id . '"
         //                   data-moving="left"
         //                   data-control-start="' . $navigation . '"><i class="td-icon-menu-left"></i></a>';
         //     $buffy .= '<a href="#"
         //                   class="td_ajax-next-pagex td-trending-now-nav-right"
         //                   data-wrapper-id="' . $trending_now_unique_id . '"
         //                   data-moving="right"
         //                   data-control-start="' . $navigation . '"><i class="td-icon-menu-right"></i></a>';
         // $buffy .= '</div>';
         $buffy .= '</div>';
         $buffy .= $td_block_layout->close_row();
     }
     $buffy .= $td_block_layout->close_all_tags();
     return $buffy;
 }
示例#14
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
 }
/**
 * @param string $output - is empty !!!
 * @param $atts
 * @param bool $content
 * @return mixed
 */
function td_gallery_shortcode($output = '', $atts, $content = false)
{
    $buffy = '';
    //check for gallery  = slide
    if (!empty($atts) and !empty($atts['td_select_gallery_slide']) and $atts['td_select_gallery_slide'] == 'slide') {
        $td_double_slider2_no_js_limit = 7;
        $td_nr_columns_slide = 'td-slide-on-2-columns';
        $nr_title_chars = 95;
        //check to see if we have or not sidebar on the page, to set the small images when need to show them on center
        if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') {
            $td_double_slider2_no_js_limit = 11;
            $td_nr_columns_slide = 'td-slide-on-3-columns';
            $nr_title_chars = 170;
        }
        $title_slide = '';
        //check for the title
        if (!empty($atts['td_gallery_title_input'])) {
            $title_slide = $atts['td_gallery_title_input'];
            //check how many chars the tile have, if more then 84 then that cut it and add ... after
            if (mb_strlen($title_slide, 'UTF-8') > $nr_title_chars) {
                $title_slide = mb_substr($title_slide, 0, $nr_title_chars, 'UTF-8') . '...';
            }
        }
        $slide_images_thumbs_css = '';
        $slide_display_html = '';
        $slide_cursor_html = '';
        $image_ids = explode(',', $atts['ids']);
        //check to make sure we have images
        if (count($image_ids) == 1 and !is_numeric($image_ids[0])) {
            return;
        }
        $image_ids = array_map('trim', $image_ids);
        //trim elements of the $ids_gallery array
        //generate unique gallery slider id
        $gallery_slider_unique_id = td_global::td_generate_unique_id();
        $cur_item_nr = 1;
        foreach ($image_ids as $image_id) {
            //get the info about attachment
            $image_attachment = td_util::attachment_get_full_info($image_id);
            //get images url
            $td_temp_image_url_80x60 = wp_get_attachment_image_src($image_id, 'td_80x60');
            //for the slide - for small images slide popup
            $td_temp_image_url_full = $image_attachment['src'];
            //default big image - for magnific popup
            //if we are on full wight (3 columns use the default images not the resize ones)
            if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') {
                $td_temp_image_url = wp_get_attachment_image_src($image_id, 'td_1021x580');
                //1021x580 images - for big slide
            } else {
                $td_temp_image_url = wp_get_attachment_image_src($image_id, 'td_0x420');
                //0x420 image sizes - for big slide
            }
            //check if we have all the images
            if (!empty($td_temp_image_url[0]) and !empty($td_temp_image_url_80x60[0]) and !empty($td_temp_image_url_full)) {
                //css for display the small cursor image
                $slide_images_thumbs_css .= '
                    #' . $gallery_slider_unique_id . '  .td-doubleSlider-2 .td-item' . $cur_item_nr . ' {
                        background: url(' . $td_temp_image_url_80x60[0] . ') 0 0 no-repeat;
                    }';
                //html for display the big image
                $class_post_content = '';
                if (!empty($image_attachment['description']) or !empty($image_attachment['caption'])) {
                    $class_post_content = 'td-gallery-slide-content';
                }
                //if picture has caption & description
                $figcaption = '';
                if (!empty($image_attachment['caption']) or !empty($image_attachment['description'])) {
                    $figcaption = '<figcaption class = "td-slide-caption ' . $class_post_content . '">';
                    if (!empty($image_attachment['caption'])) {
                        $figcaption .= '<div class = "td-gallery-slide-copywrite">' . $image_attachment['caption'] . '</div>';
                    }
                    if (!empty($image_attachment['description'])) {
                        $figcaption .= '<span>' . $image_attachment['description'] . '</span>';
                    }
                    $figcaption .= '</figcaption>';
                }
                $slide_display_html .= '
                    <div class = "td-slide-item td-item' . $cur_item_nr . '">
                        <figure class="td-slide-galery-figure td-slide-popup-gallery">
                            <a class="slide-gallery-image-link" href="' . $td_temp_image_url_full . '" title="' . $image_attachment['title'] . '"  data-caption="' . esc_attr($image_attachment['caption'], ENT_QUOTES) . '"  data-description="' . htmlentities($image_attachment['description'], ENT_QUOTES) . '">
                                <img src="' . $td_temp_image_url[0] . '" alt="' . htmlentities($image_attachment['alt'], ENT_QUOTES) . '">
                            </a>
                            ' . $figcaption . '
                        </figure>
                    </div>';
                //html for display the small cursor image
                $slide_cursor_html .= '
                    <div class = "td-button td-item' . $cur_item_nr . '">
                        <div class = "td-border"></div>
                    </div>';
                $cur_item_nr++;
            }
            //end check for images
        }
        //end foreach
        //check if we have html code for the slider
        if (!empty($slide_display_html) and !empty($slide_cursor_html)) {
            //get the number of slides
            $nr_of_slides = count($image_ids);
            if ($nr_of_slides < 0) {
                $nr_of_slides = 0;
            }
            $buffy = '
                <style type="text/css">
                    ' . $slide_images_thumbs_css . '
                </style>

                <div id="' . $gallery_slider_unique_id . '" class="' . $td_nr_columns_slide . '">
                    <div class="post_td_gallery">
                        <div class="td-gallery-slide-top">
                           <div class="td-gallery-title">' . $title_slide . '</div>

                            <div class="td-gallery-controls-wrapper">
                                <div class="td-gallery-slide-count"><span class="td-gallery-slide-item-focus">1</span> ' . __td('of', TD_THEME_NAME) . ' ' . $nr_of_slides . '</div>
                                <div class="td-gallery-slide-prev-next-but">
                                    <i class = "td-icon-left doubleSliderPrevButton"></i>
                                    <i class = "td-icon-right doubleSliderNextButton"></i>
                                </div>
                            </div>
                        </div>

                        <div class = "td-doubleSlider-1 ">
                            <div class = "td-slider">
                                ' . $slide_display_html . '
                            </div>
                        </div>

                        <div class = "td-doubleSlider-2">
                            <div class = "td-slider">
                                ' . $slide_cursor_html . '
                            </div>
                        </div>

                    </div>

                </div>
                ';
            $slide_javascript = '
                    //total number of slides
                    var ' . $gallery_slider_unique_id . '_nr_of_slides = ' . $nr_of_slides . ';

                    jQuery(document).ready(function() {
                        //magnific popup
                        jQuery("#' . $gallery_slider_unique_id . ' .td-slide-popup-gallery").magnificPopup({
                            delegate: "a",
                            type: "image",
                            tLoading: "Loading image #%curr%...",
                            mainClass: "mfp-img-mobile",
                            gallery: {
                                enabled: true,
                                navigateByImgClick: true,
                                preload: [0,1],
                                tCounter: \'%curr% ' . __td('of', TD_THEME_NAME) . ' %total%\'
                            },
                            image: {
                                tError: "<a href=\'%url%\'>The image #%curr%</a> could not be loaded.",
                                    titleSrc: function(item) {//console.log(item.el);
                                    //alert(jQuery(item.el).data("caption"));
                                    return item.el.attr("data-caption") + "<div>" + item.el.attr("data-description") + "<div>";
                                }
                            },
                            zoom: {
                                    enabled: true,
                                    duration: 300,
                                    opener: function(element) {
                                        return element.find("img");
                                    }
                            },

                            callbacks: {
                                change: function() {
                                    // Will fire when popup is closed
                                    jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-1").iosSlider("goToSlide", this.currItem.index + 1 );
                                }
                            }

                        });

                        jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-1").iosSlider({
                            scrollbar: true,
                            snapToChildren: true,
                            desktopClickDrag: true,
                            infiniteSlider: true,
                            responsiveSlides: true,
                            navPrevSelector: jQuery("#' . $gallery_slider_unique_id . ' .doubleSliderPrevButton"),
                            navNextSelector: jQuery("#' . $gallery_slider_unique_id . ' .doubleSliderNextButton"),
                            scrollbarHeight: "2",
                            scrollbarBorderRadius: "0",
                            scrollbarOpacity: "0.5",
                            onSliderResize: td_gallery_resize_update_vars_' . $gallery_slider_unique_id . ',
                            onSliderLoaded: doubleSlider2Load_' . $gallery_slider_unique_id . ',
                            onSlideChange: doubleSlider2Load_' . $gallery_slider_unique_id . ',
                            keyboardControls:true
                        });

                        //small image slide
                        jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-button").each(function(i) {
                            jQuery(this).bind("click", function() {
                                jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-1").iosSlider("goToSlide", i+1);
                            });
                        });

                        //check the number of slides
                        if(' . $gallery_slider_unique_id . '_nr_of_slides > ' . $td_double_slider2_no_js_limit . ') {
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2").iosSlider({
                                desktopClickDrag: true,
                                snapToChildren: true,
                                snapSlideCenter: true,
                                infiniteSlider: true
                            });
                        } else {
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2").addClass("td_center_slide2");
                        }

                        function doubleSlider2Load_' . $gallery_slider_unique_id . '(args) {
                            //var currentSlide = args.currentSlideNumber;
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2").iosSlider("goToSlide", args.currentSlideNumber);


                            //put a transparent border around all small sliders
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-button .td-border").css("border", "3px solid #ffffff").css("opacity", "0.5");
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-button").css("border", "0");

                            //put a white border around the focused small slide
                            jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-button:eq(" + (args.currentSlideNumber-1) + ") .td-border").css("border", "3px solid #ffffff").css("opacity", "1");
                            //jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-button:eq(" + (args.currentSlideNumber-1) + ")").css("border", "3px solid #ffffff");

                            //write the current slide number
                            td_gallery_write_current_slide_' . $gallery_slider_unique_id . '(args.currentSlideNumber);
                        }

                        //writes the current slider beside to prev and next buttons
                        function td_gallery_write_current_slide_' . $gallery_slider_unique_id . '(slide_nr) {
                            jQuery("#' . $gallery_slider_unique_id . ' .td-gallery-slide-item-focus").html(slide_nr);
                        }


                        /*
                        * Resize the iosSlider when the page is resided (fixes bug on Android devices)
                        */
                        function td_gallery_resize_update_vars_' . $gallery_slider_unique_id . '(args) {
                            if(tdDetect.isAndroid) {
                                setTimeout(function(){
                                    jQuery("#' . $gallery_slider_unique_id . ' .td-doubleSlider-1").iosSlider("update");
                                }, 1500);
                            }
                        }
                    });';
            td_js_buffer::add_to_footer($slide_javascript);
        }
        //end check if we have html code for the slider
    }
    //end if slide
    //!!!!!! WARNING
    //$return has to be != empty to overwride the default output
    return $buffy;
}
    function render($atts)
    {
        $this->block_uid = td_global::td_generate_unique_id();
        //update unique id on each render
        //global $post;
        extract(shortcode_atts(array('limit' => 4, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'tag_slug' => '', 'force_columns' => '', 'autoplay' => ''), $atts));
        //echo $atts['limit'];
        //$atts['limit'] = 4;//set 4 to remove the slide
        $buffy = '';
        //output buffer
        $id_slider = '';
        $class_iosSlider = '';
        $this->td_create_slider = 0;
        //if there are more then 4 images then make big grid a slide
        if ($atts['limit'] > 4) {
            $this->td_create_slider = 1;
            $id_slider = 'id="iosSlider_' . $this->block_uid . '"';
            $class_iosSlider = 'iosSlider';
        }
        $buffy .= '<div class="' . $class_iosSlider . ' td_block_wrap td_block_big_grid" ' . $id_slider . '>';
        $buffy .= '<div class="slider td_block_inner" id="' . $this->block_uid . '">';
        //do the query
        $td_query = td_data_source::get_wp_query($atts);
        //by ref  do the query
        //get the js for this block - last parm is block id
        $buffy .= $this->get_block_js($atts, $td_query);
        //$buffy .= '<div class="td_block_wrap td_block_big_grid">';
        //get the sub category filter for this block
        $buffy .= $this->get_block_sub_cats($atts);
        //$buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
        //inner content of the block
        $buffy .= $this->inner($td_query->posts, $force_columns);
        //$buffy .= '</div>';
        //$buffy .= '</div> <!-- ./td_block_big_grid -->';
        $buffy .= '</div>';
        //end slider (if slider)
        if ($this->td_create_slider == 1) {
            $buffy .= '<i class = "td-icon-left"></i>';
            $buffy .= '<i class = "td-icon-right"></i>';
        }
        $buffy .= '</div>';
        //end iosSlider (if slider)
        //close the ios slider wrappers
        if ($this->td_create_slider == 1) {
            //autoplay option for
            $autoplay_string = '';
            if (!empty($autoplay)) {
                $autoplay_string = 'autoSlide: true,
                            autoSlideTimer: ' . $autoplay * 1000 . ',';
            }
            $slide_javascript = '
                    jQuery(document).ready(function() {
                        jQuery("#iosSlider_' . $this->block_uid . '").iosSlider({
                            snapToChildren: true,
                            desktopClickDrag: true,
                            keyboardControls: false,
                            responsiveSlides: true,
                            infiniteSlider: true,
                            ' . $autoplay_string . '
                            navPrevSelector: jQuery("#iosSlider_' . $this->block_uid . ' .td-icon-left"),
                            navNextSelector: jQuery("#iosSlider_' . $this->block_uid . ' .td-icon-right"),
                            onSliderLoaded : td_resize_page_sliders,
		                    onSliderResize : td_resize_big_grid_update_vars_' . $this->block_uid . ',//td_resize_slide,
		                    onSlideChange : td_resize_slide
                        });
                    });


                    /*
                    * Resize the iosSlider when the page is resided (fixes bug on Android devices)
                    * For big grid the code runs on all devices because the big slider changes its height
                    * and we change the td_resize_slide function with this one
                    */
                    function td_resize_big_grid_update_vars_' . $this->block_uid . '(args) {
                        //if(tdDetect.isAndroid) {
                            setTimeout(function(){
                                jQuery("#iosSlider_' . $this->block_uid . '").iosSlider("update");
                            }, 1000);
                        //}
                    }
            ';
            td_js_buffer::add_to_footer($slide_javascript);
        }
        return $buffy;
    }
示例#17
0
    /**
     * @param $posts
     * @param string $td_column_number - get the column number
     * @param string $autoplay - not use via ajax
     * @param bool $is_ajax - if true the script will return the js inline, if not, it will use the td_js_buffer class
     * @return string
     */
    function inner($posts, $td_column_number = '', $autoplay = '', $is_ajax = false)
    {
        $buffy = '';
        $td_block_layout = new td_block_layout();
        if (empty($td_column_number)) {
            $td_column_number = td_util::vc_get_column_number();
            // get the column width of the block from the page builder API
        }
        $td_post_count = 0;
        // the number of posts rendered
        $td_unique_id_slide = td_global::td_generate_unique_id();
        //@generic class for sliders : td-theme-slider
        $buffy .= '<div id="' . $td_unique_id_slide . '" class="td-theme-slider iosSlider-col-' . $td_column_number . ' td_mod_wrap">';
        $buffy .= '<div class="td-slider ">';
        if (!empty($posts)) {
            foreach ($posts as $post) {
                //$buffy .= td_modules::mod_slide_render($post, $td_column_number, $td_post_count);
                $td_module_slide = new td_module_slide($post);
                $buffy .= $td_module_slide->render($td_column_number, $td_post_count, $td_unique_id_slide);
                $td_post_count++;
            }
        }
        $buffy .= $td_block_layout->close_all_tags();
        $buffy .= '</div>';
        //close slider
        $buffy .= '<i class = "td-icon-left prevButton"></i>';
        $buffy .= '<i class = "td-icon-right nextButton"></i>';
        $buffy .= '</div>';
        //close ios
        if (!empty($autoplay)) {
            $autoplay_string = '
            autoSlide: true,
            autoSlideTimer: ' . $autoplay * 1000 . ',
            ';
        } else {
            $autoplay_string = '';
        }
        //add resize events
        //$add_js_resize = '';
        //if($td_column_number > 1) {
        $add_js_resize = ',
                //onSliderLoaded : td_resize_normal_slide,
                //onSliderResize : td_resize_normal_slide_and_update';
        //}
        $slide_js = '
jQuery(document).ready(function() {
    jQuery("#' . $td_unique_id_slide . '").iosSlider({
        snapToChildren: true,
        desktopClickDrag: true,
        keyboardControls: false,
        responsiveSlideContainer: true,
        responsiveSlides: true,
        ' . $autoplay_string . '

        infiniteSlider: true,
        navPrevSelector: jQuery("#' . $td_unique_id_slide . ' .prevButton"),
        navNextSelector: jQuery("#' . $td_unique_id_slide . ' .nextButton")
        ' . $add_js_resize . '
    });
});
    ';
        if ($is_ajax) {
            $buffy .= '<script>' . $slide_js . '</script>';
        } else {
            td_js_buffer::add_to_footer($slide_js);
        }
        return $buffy;
    }
示例#18
0
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, $this->map_param_default_array);
        //print_r($instance);
        if (!empty($this->map_array['params'])) {
            foreach ($this->map_array['params'] as $param) {
                switch ($param['type']) {
                    case 'textarea_html':
                        //print_r($param);
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>

                            <textarea  class="widefat" name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
" cols="30" rows="10"><?php 
                        echo esc_textarea($instance[$param['param_name']]);
                        ?>
</textarea>


                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>

                        </p>
                        <?php 
                        break;
                    case 'textfield':
                        //print_r($param);
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <input class="widefat" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"
                                   name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" type="text"
                                   value="<?php 
                        echo $instance[$param['param_name']];
                        ?>
" />

                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>

                        </p>
                        <?php 
                        break;
                    case 'dropdown':
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <select name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
" class="widefat">
                                <?php 
                        foreach ($param['value'] as $param_name => $param_value) {
                            ?>
                                    <option value="<?php 
                            echo $param_value;
                            ?>
"<?php 
                            selected($instance[$param['param_name']], $param_value);
                            ?>
><?php 
                            echo $param_name;
                            ?>
</option>
                                <?php 
                        }
                        ?>
                            </select>

                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>
                        </p>
                        <?php 
                        break;
                    case 'colorpicker':
                        $empty_color_fix = '#';
                        if (!empty($instance[$param['param_name']])) {
                            $empty_color_fix = $instance[$param['param_name']];
                        }
                        $widget_color_picker_id = td_global::td_generate_unique_id();
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <input data-td-w-color="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="widefat td-color-picker-field" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"
                                   name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" type="text"
                                   value="<?php 
                        echo $empty_color_fix;
                        ?>
" />
                            <div id="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="td-color-picker-widget" rel="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"></div>
                        </p>

                        <div class="td-wpa-info">
                            <?php 
                        echo $param['description'];
                        ?>
                        </div>

                        <script>
                            td_widget_attach_color_picker();
                        </script>


                        <?php 
                        break;
                }
            }
        }
    }
示例#19
0
 /**
  * the base render function. This is called by all the child classes of this class
  * this function also ECHOES the block specific css to the buffer (for hover and stuff)
  * WARNING! THIS FUNCTIONS ECHOs THE CSS - it was made to work this way as a hack because the blocks do not get the returned value of render in a buffer
  * @param $atts
  * @return string ''
  */
 function render($atts, $content = null)
 {
     $this->atts = $this->add_live_filter_atts($atts);
     //add live filter atts
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     // This makes sure that the limit is set to the default magic value of 5
     // @todo trebuie refactoriata partea cu limita, in paginatie e hardcodat tot 5 si deja este setat in constructor aici
     if (!isset($this->atts['limit'])) {
         // this should be a general block limit setting defined in global/config file
         $this->atts['limit'] = 5;
     }
     $this->td_query =& td_data_source::get_wp_query($this->atts);
     //by ref do the query
     extract(shortcode_atts(array('td_ajax_filter_type' => '', 'td_ajax_filter_ids' => '', 'td_filter_default_txt' => __td('All', TD_THEME_NAME)), $this->atts));
     // add the visual composer class for the designer option
     // $vc_class = preg_replace( '/\s*\.([^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', '$1', $css);
     // $this->add_class($vc_class);
     $td_pull_down_items = array();
     // td_block_mega_menu has it's own pull down implementation!
     if (get_class($this) != 'td_block_mega_menu') {
         // prepare the array for the td_pull_down_items, we send this array to the block_template
         if (!empty($td_ajax_filter_type)) {
             // make the default current pull down item (the first one is the default)
             $td_pull_down_items[0] = array('name' => $td_filter_default_txt, 'id' => '');
             switch ($td_ajax_filter_type) {
                 case 'td_category_ids_filter':
                     // by category
                     $td_categories = get_categories(array('include' => $td_ajax_filter_ids, 'exclude' => '1', 'number' => 100));
                     foreach ($td_categories as $td_category) {
                         $td_pull_down_items[] = array('name' => $td_category->name, 'id' => $td_category->cat_ID);
                     }
                     break;
                 case 'td_author_ids_filter':
                     // by author
                     $td_authors = get_users(array('who' => 'authors', 'include' => $td_ajax_filter_ids));
                     foreach ($td_authors as $td_author) {
                         $td_pull_down_items[] = array('name' => $td_author->display_name, 'id' => $td_author->ID);
                     }
                     break;
                 case 'td_tag_slug_filter':
                     // by tag slug
                     $td_tags = get_tags(array('include' => $td_ajax_filter_ids));
                     foreach ($td_tags as $td_tag) {
                         $td_pull_down_items[] = array('name' => $td_tag->name, 'id' => $td_tag->term_id);
                     }
                     break;
                 case 'td_popularity_filter_fa':
                     // by popularity
                     $td_pull_down_items[] = array('name' => __td('Featured', TD_THEME_NAME), 'id' => 'featured');
                     $td_pull_down_items[] = array('name' => __td('All time popular', TD_THEME_NAME), 'id' => 'popular');
                     break;
             }
         }
     }
     // add a persistent atts based block class (crc32 of atts + block_id)
     if (is_array($this->atts)) {
         // double check to prevent warnings if no atts
         $this->add_class('td_block_id_' . sanitize_html_class(str_replace('-', '', crc32(implode($this->atts) . $this->block_id))));
     }
     // add a unique class to the block
     $unique_block_class = $this->block_uid . '_rand';
     $this->add_class($unique_block_class);
     /**
      * Make a new block template instance (NOTE: ON EACH RENDER WE GENERATE A NEW BLOCK TEMPLATE)
      * td_block_template_x - Loaded via autoload
      * @see td_autoload_classes::loading_classes
      */
     $td_block_template_id = 'td_block_template_1';
     $this->td_block_template_data = array('atts' => $this->atts, 'block_uid' => $this->block_uid, 'unique_block_class' => $unique_block_class, 'td_pull_down_items' => $td_pull_down_items);
     $this->td_block_template_instance = new $td_block_template_id($this->td_block_template_data);
     // echo the default style of the block
     echo $this->block_template()->get_css();
     return '';
 }
示例#20
0
 /**
  * Creates a new page (blog or page post type)
  */
 function create_page($post_type = 'page', $title = '', $content = '', $page_template = '')
 {
     $post_main_category = 0;
     $post_array_categories = array();
     $this->separator();
     $slug = 'td_d_slug_' . $this->last_page_slug_id;
     if (empty($title)) {
         $title = $this->generate_title();
     }
     if (empty($content)) {
         $content = $this->generate_content();
     }
     $args = array('name' => $slug, 'post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => 1);
     $my_posts = get_posts($args);
     //get a random number; used for adding category id's to posts
     $number_category = count($this->category_array);
     $rand_category = rand(0, $number_category - 1);
     $post_main_category = $this->category_array[$rand_category];
     $post_array_categories = array($post_main_category);
     //add post to featured category only from the first category
     if ($post_main_category == $this->category_array[0]) {
         $post_array_categories[] = get_cat_ID(TD_FEATURED_CAT);
     }
     $new_post = array('post_title' => $title, 'post_status' => 'publish', 'post_type' => $post_type, 'post_name' => $slug, 'post_content' => $content, 'comment_status' => 'open', 'post_category' => $post_array_categories, 'guid' => td_global::td_generate_unique_id());
     if (empty($my_posts[0])) {
         //new post / page
         $this->last_page_id = wp_insert_post($new_post);
         $this->log("create_page({$post_type}, {$slug}, {$title}, {$page_template})", 'ID: ' . $this->last_page_id);
     } else {
         //update the existing one
         $new_post['ID'] = $my_posts[0]->ID;
         wp_insert_post($new_post);
         $this->last_page_id = $my_posts[0]->ID;
         $this->log("create_page({$post_type}, {$slug}, {$title}, {$page_template})", 'already exists, updated ID: ' . $this->last_page_id);
     }
     /*/all the posts are featured !!!
       if ($post_type == 'post') {
           wp_set_post_terms($this->last_page_id, get_cat_ID(TD_FEATURED_CAT), 'category');
       }*/
     //set the page template if we have one
     if (!empty($page_template)) {
         update_post_meta($this->last_page_id, '_wp_page_template', $page_template);
         //add options for different homepages
         if ($title == 'Homepage – with background') {
             update_post_meta($this->last_page_id, 'td_homepage_loop_slide', array('td_slide_background' => 'http://demo.tagdiv.com/newspaper/wp-content/uploads/2013/09/bg001.jpg'));
         }
         if ($title == 'Homepage 3 columns') {
             update_post_meta($this->last_page_id, 'td_homepage_loop', array('td_layout' => 6, 'td_sidebar_position' => 'no_sidebar'));
             update_post_meta($this->last_page_id, 'td_homepage_loop_filter', array('limit' => 12));
         }
     }
     $this->last_page_slug_id++;
 }
示例#21
0
 /**
  * Returns a pull down
  * @param $td_pull_down_items =
  * array (
  *   id
  *   name
  * )
  * @return string
  */
 private function generate_pull_down($td_pull_down_items)
 {
     $buffy = '';
     //generate unique id for this pull down filter control
     $pull_down_wrapper_id = "td_pulldown_" . $this->block_uid;
     $buffy .= '<div class="td-wrapper-pulldown-filter" id="' . $pull_down_wrapper_id . '">';
     $buffy .= '<div class="td-pulldown-filter-display-option" id="' . $pull_down_wrapper_id . '_display" data-td_block_id="' . $this->block_uid . '">';
     //show the default display valuea
     $buffy .= '<div id="td-pulldown-' . $this->block_uid . '-val"><span>';
     $buffy .= $td_pull_down_items[0]['name'] . ' </span><i class="td-icon-menu-down"></i>';
     $buffy .= '</div>';
     //builde the dropdown
     $buffy .= '<ul class="td-pulldown-filter-list" id="' . $pull_down_wrapper_id . '_list">';
     foreach ($td_pull_down_items as $item) {
         $buffy .= '<li class="td-pulldown-filter-item"><a class="td-pulldown-filter-link" id="' . td_global::td_generate_unique_id() . '" data-td_filter_value="' . $item['id'] . '" data-td_block_id="' . $this->block_uid . '" href="#">' . $item['name'] . '</a></li>';
     }
     $buffy .= '</ul>';
     $buffy .= '</div>';
     // /.td-pulldown-filter-display-option
     $buffy .= '</div>';
     return $buffy;
     /**
      * @return string
      */
 }
示例#22
0
 /**
  * Returns a category pull down
  * @param $td_pull_down_items =
  * array (
  *      id => value
  *      ..........
  * )
  * @return string
  */
 private function generate_category_pull_down($td_pull_down_items, $filter_by)
 {
     $buffy = '';
     $block_uid = td_global::td_generate_unique_id();
     $buffy .= '<div class="td-category-pulldown-filter td-wrapper-pulldown-filter">';
     $buffy .= '<div class="td-pulldown-filter-display-option">';
     //show the default display valuea
     $buffy .= '<div class="td-subcat-more">';
     if (empty($filter_by)) {
         $buffy .= $td_pull_down_items[0]['caption'] . ' <i class="td-icon-menu-down"></i>';
     } else {
         //print_r($td_pull_down_items);
         foreach ($td_pull_down_items as $item) {
             if ($item['id'] == $filter_by) {
                 $buffy .= $item['caption'] . ' <i class="td-icon-menu-down"></i>';
                 break;
             }
         }
     }
     $buffy .= '</div>';
     //builde the dropdown
     $buffy .= '<ul class="td-pulldown-filter-list">';
     foreach ($td_pull_down_items as $item) {
         $buffy .= '<li class="td-pulldown-filter-item"><a class="td-pulldown-category-filter-link" id="' . td_global::td_generate_unique_id() . '" data-td_block_id="' . $block_uid . '" href="' . $item['value'] . '">' . $item['caption'] . '</a></li>';
     }
     $buffy .= '</ul>';
     $buffy .= '</div>';
     //.td-pulldown-filter-display-option
     $buffy .= '</div>';
     return $buffy;
 }
示例#23
0
    static function box_start($panel_name, $is_open = true)
    {
        $box_uid = td_global::td_generate_unique_id();
        $buffy = '';
        $buffy .= '
        <div class="td-box ' . ($is_open === false ? 'td-box-close' : '') . '" id="' . $box_uid . '">
                        <div class="td-box-header" data-box-id="' . $box_uid . '" unselectable="on">
                            <div class="td-box-title">' . $panel_name . '</div>
                            <a class="td-box-toggle" data-box-id="' . $box_uid . '" href="#"><div class="td-box-close-open-icon"></div></a>
                        </div>

                        <div class="td-box-content" >
        ';
        return $buffy;
    }
    /**
     * this panel box will load an ajax view when it will open
     *  - the ajax views are in /wp-admin/panel/ajax_views
     * @param $panel_text - the display name of the panel
     * @param array $ajax_params - the parameters array that we want to send to the backend. MUST CONTAIN td_ajax_view and td_ajax_call
     * @return the box
     */
    static function ajax_box($panel_text, $ajax_params = array(), $custom_unique_id = '', $panel_class = '')
    {
        if (!empty($custom_unique_id)) {
            $box_uid = $custom_unique_id;
        } else {
            $box_uid = td_global::td_generate_unique_id();
        }
        $tad_ajax_parameters = '';
        if (!empty($ajax_params)) {
            $ajax_params['action'] = 'td_ajax_view_panel_loading';
            //this is added so we can directly send this json-encoded data (no javascript encoding necessary)
            $tad_ajax_parameters = "data-panel-ajax-params='" . json_encode($ajax_params) . "'";
        }
        $buffy = '
        <div class="td-box td-box-close ' . $panel_class . '" id="' . $box_uid . '">
            <div class="td-box-header td-box-header-js-ajax" data-box-id="' . $box_uid . '"  ' . $tad_ajax_parameters . '  unselectable="on">
                <div class="td-box-title">' . $panel_text . '</div>
                <a class="td-box-toggle" data-box-id="' . $box_uid . '" href="#"><div class="td-box-close-open-icon"></div></a>
            </div>

            <div class="td-box-content-wrap"><div class="td-box-content"></div></div>
        </div>
        ';
        return $buffy;
    }
示例#25
0
 static function add_page($params)
 {
     $new_post = array('post_title' => $params['title'], 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => self::parse_content_file($params['file']), 'comment_status' => 'open', 'guid' => td_global::td_generate_unique_id());
     //new post / page
     $page_id = wp_insert_post($new_post);
     // add our demo custom meta field, using this field we will delete all the pages
     update_post_meta($page_id, 'td_demo_content', true);
     // set the page template if we have one
     if (!empty($params['template'])) {
         update_post_meta($page_id, '_wp_page_template', $params['template']);
     }
     // on homepage latest articles
     if (!empty($params['td_layout'])) {
         $tmp_meta['td_layout'] = $params['td_layout'];
         update_post_meta($page_id, 'td_homepage_loop', $tmp_meta);
     }
     if (!empty($params['list_custom_title_show'])) {
         $tmp_meta['list_custom_title_show'] = $params['list_custom_title_show'];
         update_post_meta($page_id, 'td_homepage_loop', $tmp_meta);
     }
     if (!empty($params['sidebar_id'])) {
         $tmp_meta_sidebar['td_sidebar'] = $params['sidebar_id'];
         update_post_meta($page_id, 'td_homepage_loop', $tmp_meta_sidebar);
         $tmp_meta_2_2['td_sidebar'] = $params['sidebar_id'];
         update_post_meta($page_id, 'td_page', $tmp_meta_2_2);
     }
     // set as homepage?
     if (!empty($params['homepage']) and $params['homepage'] === true) {
         update_option('page_on_front', $page_id);
         update_option('show_on_front', 'page');
     }
     // on the default template
     if (!empty($params['sidebar_position'])) {
         $tmp_meta_2['td_sidebar_position'] = $params['sidebar_position'];
         update_post_meta($page_id, 'td_page', $tmp_meta_2);
         $tmp_meta_2_33['td_sidebar_position'] = $params['sidebar_position'];
         update_post_meta($page_id, 'td_homepage_loop', $tmp_meta_2_33);
     }
     if (!empty($params['limit'])) {
         $tmp_meta['limit'] = $params['limit'];
         update_post_meta($page_id, 'td_homepage_loop', $tmp_meta);
     }
     return $page_id;
 }
示例#26
0
    /**
     * @param $posts
     * @param string $td_column_number - get the column number
     * @param string $autoplay - not use via ajax
     * @param bool $is_ajax - if true the script will return the js inline, if not, it will use the td_js_buffer class
     * @return string
     */
    function inner($posts, $td_column_number = '', $autoplay = '', $is_ajax = false)
    {
        //global $post;
        $buffy = '';
        $td_block_layout = new td_block_layout();
        if (empty($td_column_number)) {
            $td_column_number = $td_block_layout->get_column_number();
            // get the column width of the block
        }
        $td_post_count = 0;
        // the number of posts rendered
        $td_current_column = 1;
        //the current column
        $td_unique_id_slide = td_global::td_generate_unique_id();
        $buffy .= '<div id="' . $td_unique_id_slide . '" class="iosSlider iosSlider-col-' . $td_column_number . ' td_mod_wrap">';
        $buffy .= '<div class="slider ">';
        if (!empty($posts)) {
            foreach ($posts as $post) {
                //$buffy .= td_modules::mod_slide_render($post, $td_column_number, $td_post_count);
                $td_module_slide = new td_module_slide($post);
                $buffy .= $td_module_slide->render($td_column_number, $td_post_count);
                //current column
                if ($td_current_column == $td_column_number) {
                    $td_current_column = 1;
                } else {
                    $td_current_column++;
                }
                $td_post_count++;
            }
        }
        $buffy .= $td_block_layout->close_all_tags();
        $buffy .= '</div>';
        //close slider
        $buffy .= '<div class = "prevButton"></div>';
        $buffy .= '<div class = "nextButton"></div>';
        $buffy .= '</div>';
        //clos ios
        if (!empty($autoplay)) {
            $autoplay_string = '
            autoSlide: true,
            autoSlideTimer: ' . $autoplay * 1000 . ',
            ';
        } else {
            $autoplay_string = '';
        }
        $slide_js = '
jQuery(document).ready(function() {
    jQuery("#' . $td_unique_id_slide . '").iosSlider({
        snapToChildren: true,
        desktopClickDrag: true,
        keyboardControls: false,
        ' . $autoplay_string . '

        infiniteSlider: true,
        navPrevSelector: jQuery("#' . $td_unique_id_slide . ' .prevButton"),
        navNextSelector: jQuery("#' . $td_unique_id_slide . ' .nextButton"),
        onSlideComplete: slideContentComplete,
        onSlideStart: slideStartedMoving
    });
});
    ';
        if ($is_ajax) {
            $buffy .= '<script>' . $slide_js . '</script>';
        } else {
            td_js_buffer::add_to_footer($slide_js);
        }
        return $buffy;
    }
示例#27
0
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, $this->map_param_default_array);
        //print_r($instance);
        if (!empty($this->map_array['params'])) {
            foreach ($this->map_array['params'] as $param) {
                switch ($param['type']) {
                    case 'textarea_html':
                        //print_r($param);
                        ?>
	                    <p>
	                        <label for="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>

	                        <textarea  class="widefat" name="<?php 
                        echo $this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
" cols="30" rows="10"><?php 
                        echo esc_textarea($instance[$param['param_name']]);
                        ?>
</textarea>


	                        <div class="td-wpa-info">
	                            <?php 
                        echo $param['description'];
                        ?>
	                        </div>

	                    </p>
	                    <?php 
                        break;
                    case 'textfield':
                        // we have to change custom_title to custom-title to have "-title" at the end. That's what
                        // WordPress uses to put the title of the widget on post @see widgets.js
                        // suggested at: http://forum.tagdiv.com/topic/please-add-block-title-to-backend-widget-title/#post-58087
                        if ($param['param_name'] == 'custom_title') {
                            $field_id = $this->get_field_id('custom-title');
                        } else {
                            $field_id = $this->get_field_id($param['param_name']);
                        }
                        ?>
	                    <p>
	                        <label for="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
	                        <input class="widefat" id="<?php 
                        echo $field_id;
                        ?>
"
	                               name="<?php 
                        echo $this->get_field_name($param['param_name']);
                        ?>
" type="text"
	                               value="<?php 
                        echo $instance[$param['param_name']];
                        ?>
" />

	                        <div class="td-wpa-info">
	                            <?php 
                        echo $param['description'];
                        ?>
	                        </div>

	                    </p>
	                    <?php 
                        break;
                    case 'dropdown':
                        ?>
	                    <p>
	                        <label for="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
	                        <select name="<?php 
                        echo $this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
" class="widefat">
	                            <?php 
                        foreach ($param['value'] as $param_name => $param_value) {
                            ?>
	                                <option value="<?php 
                            echo $param_value;
                            ?>
"<?php 
                            selected($instance[$param['param_name']], $param_value);
                            ?>
><?php 
                            echo $param_name;
                            ?>
</option>
	                            <?php 
                        }
                        ?>
	                        </select>

	                        <div class="td-wpa-info">
	                            <?php 
                        echo $param['description'];
                        ?>
	                        </div>
	                    </p>
	                    <?php 
                        break;
                    case 'colorpicker':
                        $empty_color_fix = '#';
                        if (!empty($instance[$param['param_name']])) {
                            $empty_color_fix = $instance[$param['param_name']];
                        }
                        $widget_color_picker_id = td_global::td_generate_unique_id();
                        ?>
	                    <p>
	                        <label for="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
	                        <input data-td-w-color="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="widefat td-color-picker-field" id="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"
	                               name="<?php 
                        echo $this->get_field_name($param['param_name']);
                        ?>
" type="text"
	                               value="<?php 
                        echo $empty_color_fix;
                        ?>
" />
	                        <div id="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="td-color-picker-widget" rel="<?php 
                        echo $this->get_field_id($param['param_name']);
                        ?>
"></div>
	                    </p>

	                    <div class="td-wpa-info">
	                        <?php 
                        echo $param['description'];
                        ?>
	                    </div>

	                    <script>
	                        td_widget_attach_color_picker();
	                    </script>


	                    <?php 
                        break;
                }
            }
        }
    }