/** * we have to render the block first in the buffer, to avoid two queries. * - IF there are posts, we already have the buffer with the block's content and we don't have to make another query * - IF there are no posts, we ignore the buffer and we can also remove the wraps in the child classes of this class */ protected function render_posts_to_buffer() { // get the global category top posts grid style setting $td_grid_style = td_util::get_option('tds_category_td_grid_style'); $limit = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop(); $block_name = td_api_category_top_posts_style::get_key(get_class($this), 'td_block_name'); // overwrite the $td_grid_style if the setting for this category was changed $td_grid_style_per_category_setting = td_util::get_category_option(td_global::$current_category_obj->cat_ID, 'tdc_category_td_grid_style'); if ($td_grid_style_per_category_setting != '') { $td_grid_style = $td_grid_style_per_category_setting; } // we have to have a default grid, there seems to be a problem with the grid styles if (empty($td_grid_style)) { $td_grid_style = 'td-grid-style-1'; } //parameters to filter to for big grid $atts_for_big_grid = array('limit' => $limit, 'category_id' => td_global::$current_category_obj->cat_ID, 'sort' => get_query_var('filter_by'), 'td_grid_style' => $td_grid_style); //show the big grid $block_instance = td_global_blocks::get_instance($block_name); $this->rendered_block_buffer = $block_instance->render($atts_for_big_grid); $this->rendered_posts_count = $block_instance->td_query->post_count; if ($this->rendered_posts_count > 0) { td_global::$custom_no_posts_message = false; } // use class_name($this) to get the id :) }
function widget($args, $instance) { /** * add the td_block_widget class to the block via the short code atts, we can add td_block_widget multiple times because array_unique in @see td_block::get_block_classes */ if (!empty($instance['class'])) { $instance['class'] = $instance['class'] . ' td_block_widget'; } else { $instance['class'] = 'td_block_widget'; } if (!empty($instance['content'])) { //render the instance - but also send the content parameter to the shortcode echo td_global_blocks::get_instance($this->td_block_id)->render($instance, $instance['content']); } else { //render the instance without the content parameter echo td_global_blocks::get_instance($this->td_block_id)->render($instance); } }
protected function render_list_item($item_array, $current_item_id, $current_item_number, $total_items_number) { //print_r($item_array); $buffy = ''; // render the pagination $buffy .= $this->callback_render_drop_down_pagination(); // ad smart list 8 $buffy .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'smart_list_8')); //creating each slide $buffy .= '<div class="td-item">'; $buffy .= '<div class="td-number-and-title"><h2><span class="td-sml-current-item-title">' . $item_array['title'] . '</span></h2></div>'; //adding description if (!empty($item_array['description'])) { $buffy .= '<span class="td-sml-description">' . $item_array['description'] . '</span>'; } $buffy .= '</div>'; // render the pagination $buffy .= $this->callback_render_drop_down_pagination(); return $buffy; }
protected function render_list_item($item_array, $current_item_id, $current_item_number, $total_items_number) { //print_r($item_array); $buffy = ''; // render the pagination $buffy .= $this->callback_render_pagination(); //creating each slide $buffy .= '<div class="td-item">'; $buffy .= '<h2><span class="td-sml-current-item-title">' . $current_item_number . '. ' . $item_array['title'] . '</span></h2>'; //get image info $first_img_all_info = td_util::attachment_get_full_info($item_array['first_img_id']); //image caption $first_img_caption = ''; if (!empty($first_img_all_info['caption'])) { $first_img_caption = $first_img_all_info['caption']; } //adding description if (!empty($item_array['description'])) { $buffy .= '<span class="td-sml-description">' . $item_array['description'] . '</span>'; } // ad smart list 6 $buffy .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'smart_list_7')); if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') { $first_img_info = wp_get_attachment_image_src($item_array['first_img_id'], 'td_1068x0'); } else { $first_img_info = wp_get_attachment_image_src($item_array['first_img_id'], 'td_696x0'); } if (!empty($first_img_info[0])) { $buffy .= ' <figure class="td-slide-smart-list-figure td-slide-smart-list-7"> <a class="td-sml-link-to-image" href="' . $first_img_all_info['src'] . '" data-caption="' . esc_attr($first_img_all_info['caption'], ENT_QUOTES) . '"> <img src="' . $first_img_info[0] . '"/> </a> <figcaption class="td-sml-caption"><div>' . $first_img_caption . '</div></figcaption> </figure>'; } // render the pagination $buffy .= $this->callback_render_pagination(); $buffy .= '</div>'; return $buffy; }
function td_ajax_block() { //get the data from ajax() call $td_atts = ''; //original block atts $td_column_number = 0; //should not be 0 (1 - 2 - 3) $td_current_page = 1; //the current page of the block $td_block_id = ''; //block uid $block_type = ''; //the type of the block? /** * ajax magic filtering works like this: * * each block has a js object generated by it that is hardcoded in the page @see td_block::get_block_js * * 1. ($_POST[td_atts]) -> $td_atts['td_ajax_filter_type'] - the ajax filter type is hardcoded in the block's javascript object in the td_atts variable $td_atts['td_ajax_filter_type'] * 2. $_POST['td_filter_value'] - the filter value td_filter_value is sent via post $_POST['td_filter_value'] * 3. $_POST['td_filter_value'] - overwrites the blocks default filters ! * 4. live_filter - is hardcoded in block's js object or changed by the code here. live_filter's are used to filter content based on current page's author/tags/categories etc */ /** * this is retrieved by js from the data-td_filter_value="" attribute of the link that the user has clicked @see td_block::generate_pull_down */ $td_filter_value = ''; /** * this is used to change the new ui filter into focus when the ajax replies ( when a user clicks on 'popular', 'popular' will have this id and it will be put into focus via javascript) */ $td_filter_ui_uid = ''; if (!empty($_POST['td_atts'])) { $td_atts = json_decode(stripslashes($_POST['td_atts']), true); //current block args } if (!empty($_POST['td_column_number'])) { $td_column_number = $_POST['td_column_number']; //the block is on x columns } if (!empty($_POST['td_current_page'])) { $td_current_page = $_POST['td_current_page']; } if (!empty($_POST['td_block_id'])) { $td_block_id = $_POST['td_block_id']; } if (!empty($_POST['block_type'])) { $block_type = $_POST['block_type']; } //read the id for this specific filter type if (!empty($_POST['td_filter_value'])) { $td_filter_value = $_POST['td_filter_value']; //the new id filter } //the clicked filter ui UID from the list if (!empty($_POST['td_filter_ui_uid'])) { $td_filter_ui_uid = $_POST['td_filter_ui_uid']; //the new id filter } /* * HANDLES THE PULL DOWN FILTER + TABS ON RELATED POSTS * read the block atts - td filter type and overwrite the default values at runtime! (ex: the user changed the category from the dropbox, we overwrite the static default category of the block) */ if (!empty($td_atts['td_ajax_filter_type'])) { //dynamic filtering switch ($td_atts['td_ajax_filter_type']) { case 'td_category_ids_filter': // by category - the user selected a category from the drop down. if it's empty, we show the default block atts if (!empty($td_filter_value)) { $td_atts['category_ids'] = $td_filter_value; unset($td_atts['category_id']); } break; case 'td_author_ids_filter': // by author if (!empty($td_filter_value)) { $td_atts['autors_id'] = $td_filter_value; } break; case 'td_tag_slug_filter': // by tag - due to wp query and for combining the tags with categories we have to convert tag_ids to tag_slugs if (!empty($td_filter_value)) { $term_obj = get_term($td_filter_value, 'post_tag'); $td_atts['tag_slug'] = $term_obj->slug; } break; case 'td_popularity_filter_fa': // by popularity (sort) if (!empty($td_filter_value)) { $td_atts['sort'] = $td_filter_value; } break; /** * used by the related posts block * - if $td_atts['td_ajax_filter_type'] == td_custom_related ( this is hardcoded in the block atts @see td_module_single.php:764) * - overwrite the live_filter for this block - ( the default live_filter is also hardcoded in the block atts @see td_module_single.php:764) * the default live_filter for this block is: 'live_filter' => 'cur_post_same_categories' * @var $td_filter_value comes via ajax */ /** * used by the related posts block * - if $td_atts['td_ajax_filter_type'] == td_custom_related ( this is hardcoded in the block atts @see td_module_single.php:764) * - overwrite the live_filter for this block - ( the default live_filter is also hardcoded in the block atts @see td_module_single.php:764) * the default live_filter for this block is: 'live_filter' => 'cur_post_same_categories' * @var $td_filter_value comes via ajax */ case 'td_custom_related': if ($td_filter_value == 'td_related_more_from_author') { $td_atts['live_filter'] = 'cur_post_same_author'; // change the live filter for the related posts } break; } } //file_put_contents('d:\filename.txt', print_r($_POST, true)); $td_query =& td_data_source::get_wp_query($td_atts, $td_current_page); //by ref do the query $buffy = ''; $buffy .= td_global_blocks::get_instance($block_type)->inner($td_query->posts, $td_column_number, '', true); //pagination $td_hide_prev = false; $td_hide_next = false; if ($td_current_page == 1) { $td_hide_prev = true; //hide link on page 1 } if (!empty($td_atts['offset']) && !empty($td_atts['limit']) && $td_atts['limit'] != 0) { if ($td_current_page >= ceil(($td_query->found_posts - $td_atts['offset']) / $td_atts['limit'])) { $td_hide_next = true; //hide link on last page } } else { if ($td_current_page >= $td_query->max_num_pages) { $td_hide_next = true; //hide link on last page } } // if ($td_current_page >= $td_query->max_num_pages ) { // $td_hide_next = true; //hide link on last page // } $buffyArray = array('td_data' => $buffy, 'td_block_id' => $td_block_id, 'td_hide_prev' => $td_hide_prev, 'td_hide_next' => $td_hide_next, 'td_filter_ui_uid' => $td_filter_ui_uid); // Return the String die(json_encode($buffyArray)); }
} } echo '</ul>'; echo '<div class="clearfix"></div>'; } } } //the category description if (!empty($cur_cat_obj->description)) { echo '<div class="entry-content">'; echo $cur_cat_obj->description; echo '</div>'; } //slider if ($loop_sidebar_position != 'no_sidebar') { $td_force_columns = '2'; } else { $td_force_columns = '3'; } //read the category slider settings $tdc_slider = td_util::get_category_option($cur_cat_obj->cat_ID, 'tdc_slider'); //swich by RADU A,get_tax_meta($cur_cat_obj->cat_ID, 'tdc_slider'); //show only on page 1 $paged = get_query_var('paged') ? get_query_var('paged') : 1; if ($tdc_slider != 'hide_slider' and $paged == '1') { if ($tdc_slider == '') { //show small slider echo td_global_blocks::get_instance('td_slide')->render(array('category_id' => $cur_cat_obj->cat_ID, 'sort' => 'featured', 'force_columns' => $td_force_columns, 'hide_title' => 'hide_title')); } else { } }
/** * This function is also callable, it is used to warm the cache for the ajax blocks * @param string $ajax_parameters * @return mixed */ function td_ajax_block($ajax_parameters = '') { $isAjaxCall = false; if (empty($ajax_parameters)) { $isAjaxCall = true; $ajax_parameters = array('td_atts' => '', 'td_column_number' => 0, 'td_current_page' => '', 'td_block_id' => '', 'block_type' => '', 'td_filter_value' => ''); if (!empty($_POST['td_atts'])) { $ajax_parameters['td_atts'] = json_decode(stripslashes($_POST['td_atts']), true); //current block args } if (!empty($_POST['td_column_number'])) { $ajax_parameters['td_column_number'] = $_POST['td_column_number']; //the block is on x columns } if (!empty($_POST['td_current_page'])) { $ajax_parameters['td_current_page'] = $_POST['td_current_page']; } if (!empty($_POST['td_block_id'])) { $ajax_parameters['td_block_id'] = $_POST['td_block_id']; } if (!empty($_POST['block_type'])) { $ajax_parameters['block_type'] = $_POST['block_type']; } //read the id for this specific filter type if (!empty($_POST['td_filter_value'])) { $ajax_parameters['td_filter_value'] = $_POST['td_filter_value']; //the new id filter } } /* * HANDLES THE PULL DOWN FILTER + TABS ON RELATED POSTS * read the block atts - td filter type and overwrite the default values at runtime! (ex: the user changed the category from the dropbox, we overwrite the static default category of the block) */ if (!empty($ajax_parameters['td_atts']['td_ajax_filter_type'])) { //dynamic filtering switch ($ajax_parameters['td_atts']['td_ajax_filter_type']) { case 'td_category_ids_filter': // by category - the user selected a category from the drop down. if it's empty, we show the default block atts if (!empty($ajax_parameters['td_filter_value'])) { $ajax_parameters['td_atts']['category_ids'] = $ajax_parameters['td_filter_value']; unset($ajax_parameters['td_atts']['category_id']); } break; case 'td_author_ids_filter': // by author if (!empty($ajax_parameters['td_filter_value'])) { $ajax_parameters['td_atts']['autors_id'] = $ajax_parameters['td_filter_value']; } break; case 'td_tag_slug_filter': // by tag - due to wp query and for combining the tags with categories we have to convert tag_ids to tag_slugs if (!empty($ajax_parameters['td_filter_value'])) { $term_obj = get_term($ajax_parameters['td_filter_value'], 'post_tag'); $ajax_parameters['td_atts']['tag_slug'] = $term_obj->slug; } break; case 'td_popularity_filter_fa': // by popularity (sort) if (!empty($ajax_parameters['td_filter_value'])) { $ajax_parameters['td_atts']['sort'] = $ajax_parameters['td_filter_value']; } break; /** * used by the related posts block * - if $td_atts['td_ajax_filter_type'] == td_custom_related ( this is hardcoded in the block atts @see td_module_single.php:764) * - overwrite the live_filter for this block - ( the default live_filter is also hardcoded in the block atts @see td_module_single.php:764) * the default live_filter for this block is: 'live_filter' => 'cur_post_same_categories' * @var $td_filter_value comes via ajax */ /** * used by the related posts block * - if $td_atts['td_ajax_filter_type'] == td_custom_related ( this is hardcoded in the block atts @see td_module_single.php:764) * - overwrite the live_filter for this block - ( the default live_filter is also hardcoded in the block atts @see td_module_single.php:764) * the default live_filter for this block is: 'live_filter' => 'cur_post_same_categories' * @var $td_filter_value comes via ajax */ case 'td_custom_related': if ($ajax_parameters['td_filter_value'] == 'td_related_more_from_author') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_author'; // change the live filter for the related posts } else { if ($ajax_parameters['td_filter_value'] == 'td_tag_slug_filter_happy') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_tags_happy'; // change the live filter for the related posts } else { if ($ajax_parameters['td_filter_value'] == 'td_tag_slug_filter_funny') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_tags_funny'; // change the live filter for the related posts } else { if ($ajax_parameters['td_filter_value'] == 'td_tag_slug_filter_romantic') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_tags_romantic'; // change the live filter for the related posts } else { if ($ajax_parameters['td_filter_value'] == 'td_tag_slug_filter_surprised') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_tags_surprised'; // change the live filter for the related posts } else { if ($ajax_parameters['td_filter_value'] == 'td_tag_slug_filter_sad') { $ajax_parameters['td_atts']['live_filter'] = 'cur_post_same_tags_sad'; // change the live filter for the related posts } } } } } } // End ZA Custom break; } } /** * @var WP_Query */ $td_query =& td_data_source::get_wp_query($ajax_parameters['td_atts'], $ajax_parameters['td_current_page']); //by ref do the query $buffy = td_global_blocks::get_instance($ajax_parameters['block_type'])->inner($td_query->posts, $ajax_parameters['td_column_number'], '', true); // remove whitespaces form the ajax HTML $search = array('/\\>[^\\S ]+/s', '/[^\\S ]+\\</s', '/(\\s)+/s'); $replace = array('>', '<', '\\1'); $buffy = preg_replace($search, $replace, $buffy); // end remove whitespaces //pagination $td_hide_prev = false; $td_hide_next = false; if ($ajax_parameters['td_current_page'] == 1) { $td_hide_prev = true; //hide link on page 1 } if (!empty($ajax_parameters['td_atts']['offset']) && !empty($ajax_parameters['td_atts']['limit']) && $ajax_parameters['td_atts']['limit'] != 0) { if ($ajax_parameters['td_current_page'] >= ceil(($td_query->found_posts - $ajax_parameters['td_atts']['offset']) / $ajax_parameters['td_atts']['limit'])) { $td_hide_next = true; //hide link on last page } } else { if ($ajax_parameters['td_current_page'] >= $td_query->max_num_pages) { $td_hide_next = true; //hide link on last page } } // if ($td_current_page >= $td_query->max_num_pages ) { // $td_hide_next = true; //hide link on last page // } $buffyArray = array('td_data' => $buffy, 'td_block_id' => $ajax_parameters['td_block_id'], 'td_hide_prev' => $td_hide_prev, 'td_hide_next' => $td_hide_next); if (true === $isAjaxCall) { die(json_encode($buffyArray)); } else { return json_encode($buffyArray); } }
/** * adds mega menu support * @param $items * @param string $args * @return array */ function hook_wp_nav_menu_objects($items, $args = '') { $items_buffy = array(); $td_is_firstMenu = true; //print_r($items); // foreach ($items as &$item) { // $item-> /** * $item * -> $item (is_mega_menu = true) - this item is a mega menu */ $item->is_mega_menu = false; // all items should have this property, we just init it here - when an item has this flag on it means that the item is the mega menu dropdown! // first menu fix if ($td_is_firstMenu) { $item->classes[] = 'menu-item-first'; $td_is_firstMenu = false; } // fix the down arros + shortcodes if (strpos($item->title, '[') === false) { } else { //on shortcodes [home] etc.. do not show down arrow $item->classes[] = 'td-no-down-arrow'; } //run shortcodes $item->title = do_shortcode($item->title); // read the menu item metadata! $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); /** * check to see if we are in the header menu location and if we have */ if ($this->is_header_menu_mobile === false) { /** * we are in the header menu location */ if ($td_mega_menu_cat != '') { // check to see if we are having a mega menu item (the item has metadata) //create a mega menu item $item->classes[] = 'td-menu-item'; $item->classes[] = 'td-mega-menu'; //add the parent menu (ex current menu to the buffer) //print_r($item); //show only the parent item properties $items_buffy[] = $item; //create a new mega menu item: - this is just the dropdown menu / not the parrent $new_item = $this->generate_wp_post(); /* * it's a mega menu, * - set the is_mega_menu flag * - alter the last item classes $last_item * - change the title and url of the current item */ $new_item->is_mega_menu = true; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = ''; $new_item->title = '<div class="td-mega-grid">'; $new_item->title .= td_global_blocks::get_instance('td_mega_menu')->render(array('limit' => '5', 'td_column_number' => 3, 'ajax_pagination' => 'next_prev', 'category_id' => $td_mega_menu_cat, 'show_child_cat' => '5')); $new_item->title .= '</div>'; $items_buffy[] = $new_item; } else { // the item is just a normal item in the header menu $item->classes[] = 'td-menu-item'; $item->classes[] = 'td-normal-menu'; $items_buffy[] = $item; } } else { /** * we are in the mobile menu location */ if ($td_mega_menu_cat != '') { //this is a mega menu, do a category check //add the parent item $items_buffy[] = $item; //check for subcategories $td_subcategories = get_categories(array('child_of' => $td_mega_menu_cat)); if (!empty($td_subcategories)) { $sub_categories_count = 0; foreach ($td_subcategories as $td_category) { if ($sub_categories_count == 5) { // only show 5 subcategories in the mobile menu - the same limit applies to the mega menu break; } $new_item = $this->generate_wp_post(); $new_item->is_mega_menu = false; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = get_category_link($td_category->cat_ID); $new_item->title = $td_category->name; $items_buffy[] = $new_item; $sub_categories_count++; } } } else { // this item is a normal item in the mobile menu $items_buffy[] = $item; } } } //end foreach /** * double warning :) - this pice of code runs FIRST because it's the mobile menu first */ if ($this->is_header_menu_mobile === true) { /* } foreach ($items as &$item) { $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); if ($td_mega_menu_cat != '' and $this->is_header_menu_mobile === false) { if ($item->is_mega_menu) { print_r($item); } } print_r($items); die; unset($items_buffy); */ } // we have two header-menu locations and the fist one is the mobile menu // the second one is the header menu if ($args->theme_location == 'header-menu') { $this->is_header_menu_mobile = false; } //print_r($items_buffy); //die; return $items_buffy; }
://schema.org/Organization"> <div class="td-logo-wrap-align"> <a itemprop="url" class="td-logo-wrap" href="<?php echo home_url(); ?> "> <span class="td-logo-text"><?php echo get_bloginfo('name'); ?> </span> <span class="td-tagline-text"><?php echo get_bloginfo('description'); ?> </span> </a> </div> <meta itemprop="name" content="<?php bloginfo('name'); ?> "> </div> <div class="span8"> <?php // show the header ad spot echo td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'header')); ?> </div> </div> </div> </div>
function td_ajax_block() { global $post; //get the data from ajax() call if (!empty($_POST['td_atts'])) { $td_atts = json_decode(stripslashes($_POST['td_atts']), true); //current block args } else { $td_atts = ''; //not ok } if (!empty($_POST['td_cur_cat'])) { $td_cur_cat = $_POST['td_cur_cat']; //the new id filter } else { $td_cur_cat = ''; } if (!empty($_POST['td_column_number'])) { $td_column_number = $_POST['td_column_number']; //the block is on x columns } else { $td_column_number = 0; //not ok } if (!empty($_POST['td_current_page'])) { $td_current_page = $_POST['td_current_page']; } else { $td_current_page = 1; } if (!empty($td_cur_cat)) { $td_atts['category_ids'] = $td_cur_cat; unset($td_atts['category_id']); } if (!empty($_POST['td_block_id'])) { $td_block_id = $_POST['td_block_id']; } else { $td_block_id = ''; //not ok } if (!empty($_POST['block_type'])) { $block_type = $_POST['block_type']; } else { $block_type = ''; } $td_query =& td_data_source::get_wp_query($td_atts, $td_current_page); //by ref do the query $buffy = ''; $buffy .= td_global_blocks::get_instance($block_type)->inner($td_query->posts, $td_column_number, '', true); //pagination $td_hide_prev = false; $td_hide_next = false; if ($td_current_page == 1) { $td_hide_prev = true; //hide link on page 1 } if ($td_current_page >= $td_query->max_num_pages) { $td_hide_next = true; //hide link on last page } $buffyArray = array('td_data' => $buffy, 'td_block_id' => $td_block_id, 'td_cur_cat' => $td_cur_cat, 'td_hide_prev' => $td_hide_prev, 'td_hide_next' => $td_hide_next); // Return the String die(json_encode($buffyArray)); }
<div class="td-footer-wrapper"> <div class="td-container"> <div class="td-pb-row"> <div class="td-pb-span12"> <?php // ad spot echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'footer_top')); ?> </div> </div> <div class="td-pb-row"> <div class="td-pb-span8"> <?php td_util::vc_set_column_number(2); dynamic_sidebar('Footer 1'); ?> </div> <div class="td-pb-span4"> <?php td_util::vc_set_column_number(1); dynamic_sidebar('Footer 2'); ?> </div> </div> </div> </div>
function hook_wp_nav_menu_objects($items, $args = '') { $items_buffy = array(); $td_is_firstMenu = true; //print_r($items); foreach ($items as &$item) { $item->is_mega_menu = false; // first menu fix if ($td_is_firstMenu) { $item->classes[] = 'menu-item-first'; $td_is_firstMenu = false; } // fix the down arros + shortcodes if (strpos($item->title, '[') === false) { } else { //on shortcodes [home] etc.. do not show down arrow $item->classes[] = 'td-no-down-arrow'; } //run shortcodes $item->title = do_shortcode($item->title); //is mega menu? $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); if ($td_mega_menu_cat != '' and $this->is_header_menu_mobile === false) { $item->classes[] = 'td-not-mega'; $item->classes[] = 'td-mega-menu'; //add the parent menu (ex current menu to the buffer) $items_buffy[] = $item; //create a new mega menu item: $post = new stdClass(); $post->ID = 0; $post->post_author = ''; $post->post_date = ''; $post->post_date_gmt = ''; $post->post_password = ''; $post->post_type = 'menu_tds'; $post->post_status = 'draft'; $post->to_ping = ''; $post->pinged = ''; $post->comment_status = get_option('default_comment_status'); $post->ping_status = get_option('default_ping_status'); $post->post_pingback = get_option('default_pingback_flag'); $post->post_category = get_option('default_category'); $post->page_template = 'default'; $post->post_parent = 0; $post->menu_order = 0; $new_item = new WP_Post($post); //$new_item-> /* * it's a mega menu, * - set the is_mega_menu flag * - alter the last item classes $last_item * - change the title and url of the current item */ $new_item->is_mega_menu = true; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = ''; $new_item->title = '<div class="td-mega-grid">'; $new_item->title .= td_global_blocks::get_instance('td_mega_menu')->render(array('limit' => '5', 'td_column_number' => 3, 'ajax_pagination' => 'next_prev', 'category_id' => $td_mega_menu_cat, 'show_child_cat' => '5')); $new_item->title .= '</div>'; $items_buffy[] = $new_item; } else { $item->classes[] = 'td-not-mega'; $items_buffy[] = $item; } } //end foreach // we have two header-menu locations and the fist one is the mobile menu // the second one is the header menu if ($args->theme_location == 'header-menu') { $this->is_header_menu_mobile = false; } //print_r($items_buffy); //die; return $items_buffy; }
function widget($args, $instance) { //render the instance echo td_global_blocks::get_instance($this->td_block_id)->render($instance); }
function get_content() { /* ---------------------------------------------------------------------------- Prepare the content */ $content = get_the_content(__td('Continue', TD_THEME_NAME)); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); /* ---------------------------------------------------------------------------- Smart list support @todo reorganizare partea asta */ $td_smart_list = get_post_meta($this->post->ID, 'td_smart_list', true); if (!empty($td_smart_list['smart_list_template'])) { switch ($td_smart_list['smart_list_template']) { case 'td_smart_list_1': $td_smart_list_obj = new td_smart_list_1(); break; case 'td_smart_list_2': $td_smart_list_obj = new td_smart_list_2(); break; case 'td_smart_list_3': $td_smart_list_obj = new td_smart_list_3(); break; case 'td_smart_list_4': $td_smart_list_obj = new td_smart_list_4(); break; } if (isset($td_smart_list_obj)) { return $td_smart_list_obj->render_from_post_content($content); } else { //there was an error? } } /* ---------------------------------------------------------------------------- end smart list - if we have a list, the function returns above */ /* ---------------------------------------------------------------------------- ad support on content */ $tds_inline_ad_paragraph = td_util::get_option('tds_inline_ad_paragraph'); $tds_inline_ad_align = td_util::get_option('tds_inline_ad_align'); if (td_util::is_ad_spot_enabled('content_inline') and is_single()) { if (empty($tds_inline_ad_paragraph)) { $tds_inline_ad_paragraph = 0; } $content_buffer = ''; // we replace the content with this buffer at the end $content_parts = preg_split('/(<p.*>)/U', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); //print_r($content_parts); //die; //$content_parts = explode('<p>', $content); foreach ($content_parts as $content_part_index => $content_part) { if (!empty($content_part)) { if ($tds_inline_ad_paragraph == $content_part_index / 2) { //we have 0 = > <p> 1 => content - that's why we have to divide by 2 //it's time to show the ad switch ($tds_inline_ad_align) { case 'left': $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'left')); break; case 'right': $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'right')); break; default: $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline')); break; } } $content_buffer .= $content_part; } } //end foreach $content = $content_buffer; } //add bottom ad if (td_util::is_ad_spot_enabled('content_bottom') and is_single()) { $content = $content . td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_bottom')); } return $content; }
} } $buffy .= '</ul>'; $buffy .= '<div class="clearfix"></div>'; $buffy .= '</div>'; } //get the `filter_by` URL ($_GET) variable $filter_by = get_query_var('filter_by'); $td_category_big_grid_drop_down_filter_options = array(array('id' => 'latest', 'value' => $category_link, 'caption' => __td('Latest')), array('id' => 'featured', 'value' => add_query_arg('filter_by', 'featured', $category_link), 'caption' => __td('Featured posts')), array('id' => 'popular', 'value' => add_query_arg('filter_by', 'popular', $category_link), 'caption' => __td('Most popular')), array('id' => 'popular7', 'value' => add_query_arg('filter_by', 'popular7', $category_link), 'caption' => __td('7 days popular')), array('id' => 'review_high', 'value' => add_query_arg('filter_by', 'review_high', $category_link), 'caption' => __td('By review score')), array('id' => 'random_posts', 'value' => add_query_arg('filter_by', 'random_posts', $category_link), 'caption' => __td('Random'))); // is a flag to hide the 'No posts to display' message if on category page there are between 1 and 5 posts $global_flag_to_hide_no_post_to_display = ''; //this flag is checked in the loop.php file to hide the `No posts to display` message if we have the big grid on the page and there are between 1 and 5 posts $global_flag_to_hide_no_post_to_display = $wp_query->post_count; //if there are post to display add also the drop down category filter if ($td_disable_big_grid != 'yes') { echo $buffy; //create the drop-down filter on category pages echo td_util::generate_category_pull_down($td_category_big_grid_drop_down_filter_options, $filter_by); //print_r($global_flag_to_hide_no_post_to_display); //only show the big grid on first page if ($paged < 2) { //parameters to filter to for big grid $atts_for_big_grid = array('limit' => '5', 'category_id' => $cur_cat_id); //add the sorting option to the big_grid if (!empty($filter_by)) { $atts_for_big_grid['sort'] = $filter_by; } //show the big grid echo td_global_blocks::get_instance('td_block_big_grid')->render($atts_for_big_grid); } }
<?php locate_template('parts/footer/td_footer_extra.php', true); ?> <?php dynamic_sidebar('Footer 1'); ?> </div> <div class="td-pb-span4"> <?php td_util::vc_set_column_number(1); echo td_global_blocks::get_instance('td_block_7')->render(array('custom_title' => __td('POPULAR POSTS', TD_THEME_NAME), 'limit' => 3, 'sort' => 'popular')); ?> <?php dynamic_sidebar('Footer 2'); ?> </div> <div class="td-pb-span4"> <?php td_util::vc_set_column_number(1); echo td_global_blocks::get_instance('td_block_popular_categories')->render(array('custom_title' => __td('POPULAR CATEGORIES', TD_THEME_NAME), 'limit' => 9)); ?> <?php dynamic_sidebar('Footer 3'); ?> </div> </div> </div> </div>
if (!empty($td_homepage_loop_slide['td_slide_background'])) { $td_slide_background = $td_homepage_loop_slide['td_slide_background']; } if (!empty($td_homepage_loop_slide['td_slide_b_color']) and $td_homepage_loop_slide['td_slide_b_color'] != '#') { $td_slide_b_color = $td_homepage_loop_slide['td_slide_b_color']; } } if (empty($paged) or $paged < 2) { echo td_page_generator::wrap_no_row_with_bg_start(); if (empty($paged) or $paged < 2) { //show this only on the first page ?> <div class="row-fluid"> <div class="span12 column_container"> <?php echo td_global_blocks::get_instance('td_slide_big')->render(array('sort' => 'featured', 'hide_title' => 'hide_title', 'force_columns' => 3, 'limit' => $td_slide_limit)); ?> </div> </div> <?php } echo td_page_generator::wrap_no_row_with_bg_end(); /* if (!empty($td_slide_background)) { echo '<script>' . "\n"; echo 'jQuery().ready(function() {' . "\n"; echo 'jQuery(".td-big-slide-background").backstretch("' . $td_slide_background . '", {fade:1200});' . "\n"; echo '});' . "\n"; echo '</script>' . "\n"; } */
function related_posts($force_sidebar_position = '') { if (!$this->is_single) { return; } if (td_util::get_option('tds_similar_articles') == 'hide') { return; } //td_global::$cur_single_template_sidebar_pos; //cur_post_same_tags //cur_post_same_author //cur_post_same_categories if (td_util::get_option('tds_similar_articles_type') == 'by_tag') { $td_related_ajax_filter_type = 'cur_post_same_tags'; } else { $td_related_ajax_filter_type = 'cur_post_same_categories'; } // the number of rows to show. this number will be multiplied with the hardcoded limit $tds_similar_articles_rows = td_util::get_option('tds_similar_articles_rows'); if (empty($tds_similar_articles_rows)) { $tds_similar_articles_rows = 1; } if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar' or $force_sidebar_position === 'no_sidebar') { $td_related_limit = 5 * $tds_similar_articles_rows; $td_related_class = 'td-related-full-width'; $td_column_number = 5; } else { $td_related_limit = 3 * $tds_similar_articles_rows; $td_related_class = ''; $td_column_number = 3; } /** * 'td_ajax_filter_type' => 'td_custom_related' - this ajax filter type overwrites the live filter via ajax @see td_ajax_block */ $td_block_args = array('limit' => $td_related_limit, 'ajax_pagination' => 'next_prev', 'live_filter' => $td_related_ajax_filter_type, 'td_ajax_filter_type' => 'td_custom_related', 'class' => $td_related_class, 'td_column_number' => $td_column_number); /** * @see td_block_related_posts */ return td_global_blocks::get_instance('td_block_related_posts')->render($td_block_args); }
function related_posts() { if (!$this->is_single) { return; } if (td_util::get_option('tds_similar_articles') == 'hide') { return; } //td_global::$cur_single_template_sidebar_pos; //cur_post_same_tags //cur_post_same_author //cur_post_same_categories if (td_util::get_option('tds_similar_articles_type') == 'by_tag') { $td_related_ajax_filter_type = 'cur_post_same_tags'; } else { $td_related_ajax_filter_type = 'cur_post_same_categories'; } if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') { $td_related_limit = 5; $td_related_class = 'td-related-full-width'; } else { $td_related_limit = 3; $td_related_class = ''; } /** * 'td_ajax_filter_type' => 'td_custom_related' - this ajax filter type overwrites the live filter via ajax @see td_ajax_block */ $td_block_args = array('limit' => $td_related_limit, 'ajax_pagination' => 'next_prev', 'live_filter' => $td_related_ajax_filter_type, 'td_ajax_filter_type' => 'td_custom_related', 'class' => $td_related_class); /** * @see td_related_posts */ return td_global_blocks::get_instance('td_related_posts')->render($td_block_args); }
/** * adds mega menu support * @param $items * @param string $args * @return array */ function hook_wp_nav_menu_objects($items, $args = '') { $items_buffy = array(); $td_is_firstMenu = true; //print_r($items); foreach ($items as &$item) { $item->is_mega_menu = false; /** * $item * -> $item (is_mega_menu = true) - this item is a mega menu */ $item->is_mega_menu = false; // all items should have this property, we just init it here - when an item has this flag on it means that the item is the mega menu dropdown! // first menu fix if ($td_is_firstMenu) { $item->classes[] = 'menu-item-first'; $td_is_firstMenu = false; } // fix the down arros + shortcodes if (strpos($item->title, '[') === false) { } else { //on shortcodes [home] etc.. do not show down arrow $item->classes[] = 'td-no-down-arrow'; } //run shortcodes $item->title = do_shortcode($item->title); //read mega menu and mega page menu settings $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); $td_mega_menu_page_id = get_post_meta($item->ID, 'td_mega_menu_page_id', true); if ($this->is_header_menu_mobile === true) { // a item in the mobile menu /** * we are in the mobile menu location */ if ($td_mega_menu_cat != '') { //this is a mega menu, do a category check //add the parent item $items_buffy[] = $item; $td_render_atts = td_api_block::get_key('td_block_mega_menu', 'render_atts'); $td_show_child_cat = 5; if (isset($td_render_atts['show_child_cat'])) { $td_show_child_cat = $td_render_atts['show_child_cat']; } //check for subcategories $td_subcategories = get_categories(array('child_of' => $td_mega_menu_cat, 'number' => $td_show_child_cat)); if (!empty($td_subcategories)) { $item->classes[] = 'menu-item-has-children'; // add the extra class for the dropdown to work foreach ($td_subcategories as $td_category) { $new_item = $this->generate_wp_post(); $new_item->is_mega_menu = false; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = get_category_link($td_category->cat_ID); $new_item->title = $td_category->name; $items_buffy[] = $new_item; } } } else { // this item is a normal item in the mobile menu $items_buffy[] = $item; } } elseif ($td_mega_menu_page_id != '') { // a item with a page - pege mega menu // the parent item (the one that appears in the main menu) $item->classes[] = 'td-menu-item'; $item->classes[] = 'td-mega-menu'; $item->classes[] = 'td-mega-menu-page'; $items_buffy[] = $item; //create a new mega menu item: - this is just the dropdown menu / not the parrent $new_item = $this->generate_wp_post(); $new_item->is_mega_menu = true; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = ''; //read the page content $content_post = get_post($td_mega_menu_page_id); $content = $content_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $new_item->title = '<div class="td-container-border"><div class="td-mega-grid">'; // the has_filter check is made for plugins, like bbpress, who think it's okay to remove all filters on 'the_content' if (!has_filter('the_content', 'do_shortcode')) { $new_item->title .= do_shortcode($content); } else { $new_item->title .= $content; } $new_item->title .= '</div></div>'; $items_buffy[] = $new_item; } elseif ($td_mega_menu_cat != '') { // a item with a category mega menu // the parent item (the one that appears in the main menu) $item->classes[] = 'td-menu-item'; $item->classes[] = 'td-mega-menu'; $items_buffy[] = $item; //create a new mega menu item: - this is just the dropdown menu / not the parrent $new_item = $this->generate_wp_post(); /* * it's a mega menu, * - set the is_mega_menu flag * - alter the last item classes $last_item * - change the title and url of the current item */ $new_item->is_mega_menu = true; //this is sent to the menu walkers $new_item->menu_item_parent = $item->ID; $new_item->url = ''; $new_item->title = '<div class="td-container-border"><div class="td-mega-grid">'; $td_render_atts = td_api_block::get_key('td_block_mega_menu', 'render_atts'); $new_item->title .= td_global_blocks::get_instance('td_block_mega_menu')->render(array('limit' => '5', 'td_column_number' => 3, 'ajax_pagination' => 'next_prev', 'category_id' => $td_mega_menu_cat, 'show_child_cat' => $td_render_atts['show_child_cat'], 'td_ajax_filter_type' => 'td_category_ids_filter')); $new_item->title .= '</div></div>'; $items_buffy[] = $new_item; } else { // normal menu item $item->classes[] = 'td-menu-item'; $item->classes[] = 'td-normal-menu'; $items_buffy[] = $item; } } //end foreach // we have two header-menu locations and the fist one is the mobile menu // the second one is the header menu if ($args->theme_location == 'header-menu') { $this->is_header_menu_mobile = false; } //print_r($items_buffy); //die; return $items_buffy; }
echo join(' ', get_post_class()); ?> " <?php echo $td_mod_single->get_item_scope(); ?> > <div class="td-pb-row"> <div class="td-pb-span12"> <div class="td-post-header"> <div class="td-crumb-container"><?php echo td_page_generator::get_single_breadcrumbs($td_mod_single->title); ?> </div> <?php echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'post_style_12')); ?> <header class="td-post-title"> <?php echo $td_mod_single->get_category(); ?> <?php echo $td_mod_single->get_title(); ?> <?php if (!empty($td_mod_single->td_post_theme_settings['td_subtitle'])) { ?> <p class="td-post-sub-title"><?php