/** * 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 get_category() { $buffy = ''; if (td_util::get_option('tds_p_categories_tags') != 'hide') { $buffy .= '<ul class="td-category">'; $categories = get_the_category($this->post->ID); $cat_array = array(); if ($categories) { foreach ($categories as $category) { if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name //get the parent of this cat $td_parent_cat_obj = get_category($category->category_parent); //if we have a parent, shot it first if (!empty($td_parent_cat_obj->name)) { $tax_meta__color_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID, 'tdc_color'); //swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_color'); $tax_meta__hide_on_post_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID, 'tdc_hide_on_post'); //swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_hide_on_post'); $cat_array[$td_parent_cat_obj->name] = array('color' => $tax_meta__color_parent, 'link' => get_category_link($td_parent_cat_obj->cat_ID), 'hide_on_post' => $tax_meta__hide_on_post_parent); } //show the category, only if we didn't already showed the parent $tax_meta_color = td_util::get_category_option($category->cat_ID, 'tdc_color'); //swich by RADU A, get_tax_meta($category->cat_ID,'tdc_color'); $tax_meta__hide_on_post_parent = td_util::get_category_option($category->cat_ID, 'tdc_hide_on_post'); //swich by RADU A, get_tax_meta($category->cat_ID,'tdc_hide_on_post'); $cat_array[$category->name] = array('color' => $tax_meta_color, 'link' => get_category_link($category->cat_ID), 'hide_on_post' => $tax_meta__hide_on_post_parent); } } } foreach ($cat_array as $td_cat_name => $td_cat_parms) { if ($td_cat_parms['hide_on_post'] == 'hide') { continue; } if (!empty($td_cat_parms['color'])) { $td_cat_color = ' style="background-color:' . $td_cat_parms['color'] . ';"'; } else { $td_cat_color = ''; } $buffy .= '<li class="entry-category"><a ' . $td_cat_color . ' href="' . $td_cat_parms['link'] . '">' . $td_cat_name . '</a></li>'; } $buffy .= '</ul>'; } return $buffy; }
/** * Reads an individual setting - only one setting! * @param $read_array - * 'ds' => 'data source ID', 'item_id' = > 'the category id for example', - OPTIONAL category id or author id or page id * 'option_id' => 'the option id ex: background' * @return returns the value of the setting */ static function read($read_array) { switch ($read_array['ds']) { case 'td_category': return td_util::get_category_option($read_array['item_id'], $read_array['option_id']); break; case 'td_option': return td_util::get_option($read_array['option_id']); //htmlspecialchars() break; case 'wp_option': return htmlspecialchars(get_option($read_array['option_id'])); break; case 'td_homepage': // here we get all the options for the homepage (including widgets?) break; case 'td_page_option': break; case 'td_widget': break; //author metadata //author metadata case 'td_author': return get_the_author_meta($read_array['option_id'], $read_array['item_id']); break; //wordpress theme mod datasource //wordpress theme mod datasource case 'wp_theme_mod': return htmlspecialchars(get_theme_mod($read_array['option_id'])); break; //wordpress usermenu to menu spot datasource //wordpress usermenu to menu spot datasource case 'wp_theme_menu_spot': $menu_spots_array = get_theme_mod('nav_menu_locations'); //check to see if there is a menu assigned to that particular option_id (menu id) if (isset($menu_spots_array[$read_array['option_id']])) { return $menu_spots_array[$read_array['option_id']]; } else { return ''; } break; //translation data source //translation data source case 'td_translate': //get all the translations (they are stored in the td_008 variable) $translations = td_util::get_option('td_translation_map_user'); if (!empty($translations[$read_array['option_id']])) { return $translations[$read_array['option_id']]; //htmlspecialchars() } else { return ''; } //return td_util::get_option($read_array['option_id']); break; //read the ads parameters //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id] //read the ads parameters //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id] case 'td_ads': //get all the ad spots (they are stored in the td_008 variable) $ads = td_util::get_option('td_ads'); if (!empty($ads[$read_array['item_id']]) and !empty($ads[$read_array['item_id']][$read_array['option_id']])) { return htmlspecialchars($ads[$read_array['item_id']][$read_array['option_id']]); } else { return ''; } break; //social networks //social networks case 'td_social_networks': $social_array = td_util::get_option('td_social_networks'); if (!empty($social_array[$read_array['option_id']])) { return $social_array[$read_array['option_id']]; } else { return ''; } break; case 'td_fonts_user_insert': $fonts_user_inserted = td_util::get_option('td_fonts_user_inserted'); if (!empty($fonts_user_inserted[$read_array['option_id']])) { return $fonts_user_inserted[$read_array['option_id']]; } break; case 'td_fonts': $fonts_user_inserted = td_util::get_option('td_fonts'); if (!empty($fonts_user_inserted[$read_array['item_id']][$read_array['option_id']])) { return $fonts_user_inserted[$read_array['item_id']][$read_array['option_id']]; } break; case 'td_block_styles': //get the hole block style array $td_block_styles = td_util::get_option('td_block_styles'); if (!empty($td_block_styles) and !empty($td_block_styles[$read_array['item_id']][$read_array['option_id']])) { return $td_block_styles[$read_array['item_id']][$read_array['option_id']]; } break; } }
the post template (single article template) */ //get_header(); //set the template id, used to get the template specific settings $template_id = 'home'; //home = blog index = blog - use the same settings from the blog index //prepare the loop variables //read the global settings $loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty) $loop_module_id = 1; //use the default 1 module (full post) //read the primary category sidebar position! - we have to make the page after the primary category or after the global setting $primary_category_id = td_global::get_primary_category_id(); if (!empty($primary_category_id)) { $tax_meta_sidebar = td_util::get_category_option($primary_category_id, 'tdc_sidebar_pos'); //swich by RADU A, get_tax_meta($primary_category_id, 'tdc_sidebar_pos'); if (!empty($tax_meta_sidebar)) { //update the sidebar position from the category setting $loop_sidebar_position = $tax_meta_sidebar; } } //read the custom single post settings - this setting overids all of them $td_post_theme_settings = get_post_meta($post->ID, 'td_post_theme_settings', true); if (!empty($td_post_theme_settings['td_sidebar_position'])) { $loop_sidebar_position = $td_post_theme_settings['td_sidebar_position']; } //set the content width if needed (we already have the default in functions) if ($loop_sidebar_position == 'no_sidebar') { $content_width = 980; }
/** * get the category spot of the single post / single post type * @return string - the html of the spot */ function get_category() { $terms_ui_array = array(); if ($this->post->post_type != 'post') { // CUSTOM POST TYPES - on custom post types, we retrieve the taxonomy setting from the panel and we show // only the ones that are selected in wp-admin, just like a normal theme $category_spot_taxonomy = td_util::get_ctp_option($this->post->post_type, 'tds_category_spot_taxonomy'); $terms_for_category_spot = wp_get_post_terms($this->post->ID, $category_spot_taxonomy); foreach ($terms_for_category_spot as $term_for_category_spot) { $term_for_category_spot_url = get_term_link($term_for_category_spot, $category_spot_taxonomy); if (!is_wp_error($term_for_category_spot_url)) { $terms_ui_array[$term_for_category_spot->name] = array('color' => '', 'link' => $term_for_category_spot_url, 'hide_on_post' => ''); } } } else { // POST TYPE - here we work with categories // NOTE: due to legacy, the theme also outputs the parent of the first category if available $categories = get_the_category($this->post->ID); if (!empty($categories)) { foreach ($categories as $category) { if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name //get the parent of this cat $td_parent_cat_obj = get_category($category->category_parent); //if we have a parent, shot it first if (!empty($td_parent_cat_obj->name)) { $tax_meta__color_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID, 'tdc_color'); //swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_color'); $tax_meta__hide_on_post_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID, 'tdc_hide_on_post'); //swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_hide_on_post'); $terms_ui_array[$td_parent_cat_obj->name] = array('color' => $tax_meta__color_parent, 'link' => get_category_link($td_parent_cat_obj->cat_ID), 'hide_on_post' => $tax_meta__hide_on_post_parent); } //show the category, only if we didn't already showed the parent $tax_meta_color = td_util::get_category_option($category->cat_ID, 'tdc_color'); //swich by RADU A, get_tax_meta($category->cat_ID,'tdc_color'); $tax_meta__hide_on_post_parent = td_util::get_category_option($category->cat_ID, 'tdc_hide_on_post'); //swich by RADU A, get_tax_meta($category->cat_ID,'tdc_hide_on_post'); $terms_ui_array[$category->name] = array('color' => $tax_meta_color, 'link' => get_category_link($category->cat_ID), 'hide_on_post' => $tax_meta__hide_on_post_parent); } } } } /** * output stage * we go in with an array of: * array ( * $terms_ui_array[category_name] = array ( * 'color' => '', * 'link' => '' * 'hide_on_post' * ) * ) */ $buffy = ''; if (td_util::get_option('tds_p_categories_tags') != 'hide') { $buffy .= '<ul class="td-category">'; foreach ($terms_ui_array as $term_name => $term_params) { if ($term_params['hide_on_post'] == 'hide') { continue; } if (!empty($term_params['color'])) { $td_cat_color = ' style="background-color:' . $term_params['color'] . ';"'; } else { $td_cat_color = ''; } $buffy .= '<li class="entry-category"><a ' . $td_cat_color . ' href="' . $term_params['link'] . '">' . $term_name . '</a></li>'; } $buffy .= '</ul>'; } return $buffy; }
/** * renders the infinite pagination and also the load more. It returns true if it changes the pagination so that the * calling function knows to not render the 'normal' pagination * @return bool - override the pagination or not */ private static function render_infinite_pagination() { global $wp_query, $loop_module_id, $loop_sidebar_position; // it's set by the template -- || -- /** * infinite loading pagination ONLY FOR CATEGORIES FOR NOW (19 aug 2015) */ if (!is_admin() and td_global::$current_template != 'page-homepage-loop' and is_category() and !empty($wp_query)) { // the filter_by parameter is used on categories to filter them. The theme uses normal pagination when the filter is used for now. // if we want to use the filter + loop ajax, we have to send the atts for each filter. It can be done, but not now (19 aug 2015) if (isset($_GET['filter_by'])) { return false; } $pagination_style = ''; // read the global settings $global_category_pagination_style = td_util::get_option('tds_category_pagination_style'); if (!empty($global_category_pagination_style)) { $pagination_style = $global_category_pagination_style; } // read the per category settings $category_pagination_style = td_util::get_category_option(td_global::$current_category_obj->cat_ID, 'tdc_category_pagination_style'); if (!empty($category_pagination_style)) { // overwrite the global pagination. For normal pagination we need to clean up the variable if ($category_pagination_style == 'normal') { $pagination_style = ''; } else { $pagination_style = $category_pagination_style; } } // check to see if we need infinite loading pagination if ($pagination_style != '') { if ($wp_query->query_vars['paged'] >= $wp_query->max_num_pages) { return true; // do not show any pagination because we do not have more pages } $ajax_pagination_infinite_stop = 0; if ($pagination_style == 'infinite_load_more') { $ajax_pagination_infinite_stop = 3; // after how many pages do we show a load more button. set to 0 to use only load more } ?> <script> jQuery(window).ready(function() { tdAjaxLoop.loopState.sidebarPosition = '<?php echo $loop_sidebar_position; ?> '; tdAjaxLoop.loopState.moduleId = '<?php echo $loop_module_id; ?> '; tdAjaxLoop.loopState.currentPage = 1; tdAjaxLoop.loopState.max_num_pages = <?php echo $wp_query->max_num_pages; ?> ; tdAjaxLoop.loopState.atts = { 'category_id':<?php echo $wp_query->query_vars['cat']; ?> , 'offset':<?php echo $wp_query->query_vars['offset']; ?> }; tdAjaxLoop.loopState.ajax_pagination_infinite_stop = <?php echo $ajax_pagination_infinite_stop; ?> ; tdAjaxLoop.init(); }); </script> <div class="td-ajax-loop-infinite"></div> <div class="td-load-more-wrap td-load-more-infinite-wrap"> <a href="#" class="td_ajax_load_more" data-td_block_id=""> <?php echo __td('Load more', TD_THEME_NAME); ?> <i class="td-icon-font td-icon-menu-down"></i> </a> </div> <?php return true; // notice the calling function that we modified the pagination } } return false; // by default return false if we don't want to change the pagination }
} } 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, reads the category background settings and patches the $background_params with the cat settings * @param $category_id - the category id, used to read the settings * @param $background_params - the current background settings * @return array - the patched background settings */ private function get_category_bg_settings($category_id, $background_params) { // read the background settings from the category if needed if (!empty($category_id)) { //get the category bg image $tdc_image = td_util::get_category_option($category_id, 'tdc_image'); if (!empty($tdc_image)) { $background_params['theme_bg_image'] = $tdc_image; $background_params['is_boxed_layout'] = true; } //get the category bg color $tdc_bg_color = td_util::get_category_option($category_id, 'tdc_bg_color'); if (!empty($tdc_bg_color)) { $background_params['theme_bg_color'] = $tdc_bg_color; $background_params['is_boxed_layout'] = true; } //get the bg style - from category specific $tdc_bg_repeat = td_util::get_category_option($category_id, 'tdc_bg_repeat'); switch ($tdc_bg_repeat) { case '': //do nothing - the background is already stretched if needed from the top of this function break; case 'stretch': $background_params['is_stretched_bg'] = true; break; case 'tile': $background_params['is_stretched_bg'] = false; $background_params['theme_bg_repeat'] = 'repeat'; break; } } return $background_params; }
/** * Generates the sibling categories, it also compiles the $custom_category_color_css and adds it to the footer css buffer * @param string $params_array * * array( * 'current_category_css' => ' * <style> * // the css style to compile * </style> * ', * 'show_background_color' => true - if true, the theme will output inline css to color the background color * ) * * @return string * @throws ErrorException */ protected function get_sibling_categories($params_array = '') { $buffy = ''; //the subcategories if (!empty($this->current_category_obj->cat_ID)) { if ($this->current_category_obj->parent === 0) { // get child categories $categories_objects = get_categories(array('parent' => $this->current_category_obj->cat_ID, 'hide_empty' => 0, 'number' => self::SIBLING_CATEGORY_LIMIT)); } // if no child categories get siblings if (empty($categories_objects)) { $categories_objects = get_categories(array('parent' => $this->current_category_obj->parent, 'hide_empty' => 0, 'number' => self::SIBLING_CATEGORY_LIMIT)); } } /** * if we have categories to show... show them */ if (!empty($categories_objects)) { $buffy = '<div class="td-category-siblings">'; $buffy .= '<ul class="td-category">'; foreach ($categories_objects as $category_object) { // ignore featured cat and uncategorized if ($category_object->name == TD_FEATURED_CAT or strtolower($category_object->cat_name) == 'uncategorized') { continue; } if (!empty($category_object->name) and td_util::get_category_option($category_object->cat_ID, 'tdc_hide_on_post') != 'hide') { $class = ''; if ($category_object->cat_ID == $this->current_category_id) { $class = 'td-current-sub-category'; } $td_css_inline = new td_css_inline(); // @todo we can add more properties as needed, ex: show_border_color if (!empty($params_array['show_background_color'])) { $tdc_color_current_cat = td_util::get_category_option($category_object->cat_ID, 'tdc_color'); $td_css_inline->add_css(array('background-color' => $tdc_color_current_cat)); } $buffy .= '<li class="entry-category"><a ' . $td_css_inline->get_inline_css() . ' class="' . $class . '" href="' . get_category_link($category_object->cat_ID) . '">' . $category_object->name . '</a></li>'; } } $buffy .= '</ul>'; // subcategory dropdown list $buffy .= '<div class="td-subcat-dropdown td-pulldown-filter-display-option">'; $buffy .= '<div class="td-subcat-more"><i class="td-icon-menu-down"></i></div>'; // the dropdown list $buffy .= '<ul class="td-pulldown-filter-list">'; $buffy .= '</ul>'; $buffy .= '</div>'; $buffy .= '<div class="clearfix"></div>'; $buffy .= '</div>'; } // compile the custom css if (!empty($params_array['current_category_css'])) { $tdc_color = td_util::get_category_option($this->current_category_obj->cat_ID, 'tdc_color'); $td_css_compiler = new td_css_compiler($params_array['current_category_css']); $td_css_compiler->load_setting_raw('current_category_color', $tdc_color); td_css_buffer::add_to_footer($td_css_compiler->compile_css()); } return $buffy; }
function wp_head_hook() { //if not empty, the theme will load the settings from this category id $category_id = 0; //background settings (color and images) for pages (except categories and post that are in a category) $this->theme_bg_image = td_util::get_option('tds_site_background_image'); $this->theme_bg_color = td_util::get_option('tds_site_background_color'); //background image options $this->theme_bg_repeat = td_util::get_option('tds_site_background_repeat'); $this->theme_bg_position = td_util::get_option('tds_site_background_position_x'); $this->theme_bg_attachment = td_util::get_option('tds_site_background_attachment'); //setting variable : is_stretched_bg if (td_util::get_option('tds_stretch_background') == 'yes') { $this->is_stretched_bg = true; } //background settings for category and post page (post that are in a category) if (is_category() or is_single()) { //read the category id if (is_category()) { $category_id = intval(get_query_var('cat')); } //read the post - category id if (is_single()) { $category_id = intval(td_global::get_primary_category_id()); } //echo $use_settings_from_category_id; if ($category_id > 0) { //get the category bg $tdc_image = td_util::get_category_option($category_id, 'tdc_image'); if (!empty($tdc_image)) { $this->is_boxed_layout = true; $this->theme_bg_image = $tdc_image; } //get the category bg color $tdc_bg_color = td_util::get_category_option($category_id, 'tdc_bg_color'); if (!empty($tdc_bg_color)) { $this->is_boxed_layout = true; $this->theme_bg_color = $tdc_bg_color; } //get the bg style - from category specific $tdc_bg_repeat = td_util::get_category_option($category_id, 'tdc_bg_repeat'); switch ($tdc_bg_repeat) { case '': //do nothing - the background is already stretched if needed from the top of this function break; case 'stretch': $this->is_stretched_bg = true; break; case 'tile': $this->is_stretched_bg = false; $this->theme_bg_repeat = 'repeat'; break; } } } //setting variable : is_boxed_layout if ($this->theme_bg_image != '' or $this->theme_bg_color != '') { $this->is_boxed_layout = true; //make the site boxed add_filter('td_css_buffer_render', array($this, 'add_css_custom_background')); } if ($this->is_stretched_bg == true) { //add the js filter for our custom bg add_filter('td_js_buffer_footer_render', array($this, 'add_js_hook')); } }
static function get_pagination() { global $wp_query; if (td_global::$current_template == '404') { return; } $pagenavi_options = self::pagenavi_init(); $request = $wp_query->request; $posts_per_page = intval(get_query_var('posts_per_page')); $paged = intval(get_query_var('paged')); $numposts = $wp_query->found_posts; $max_page = $wp_query->max_num_pages; //hack for category pages - pagination if (!is_admin() and is_category()) { // get the category object - with or without permalinks if (empty($wp_query->query_vars['cat'])) { $td_current_category_obj = get_category_by_path(get_query_var('category_name'), false); // when we have permalinks, we have to get the category object like this. } else { $td_current_category_obj = get_category($wp_query->query_vars['cat']); } if (isset($td_current_category_obj->cat_ID)) { $disable_category_big_grid_hide_option = td_util::get_category_option($td_current_category_obj->cat_ID, 'tdc_slider'); } else { $disable_category_big_grid_hide_option = ''; } //check if the slider for this category is enabled or disabled if ($disable_category_big_grid_hide_option != 'yes') { $numposts = $wp_query->found_posts - 5; //5 from big grid $max_page = ceil($numposts / $posts_per_page); } //echo '<br>num posts: '.$numposts; //echo '<br>max pages: '.$max_page; } if (empty($paged) || $paged == 0) { $paged = 1; } $pages_to_show = intval($pagenavi_options['num_pages']); $larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']); $larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if ($end_page - $start_page != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $max_page) { $start_page = $max_page - $pages_to_show_minus_1; $end_page = $max_page; } if ($start_page <= 0) { $start_page = 1; } $larger_per_page = $larger_page_to_show * $larger_page_multiple; $larger_start_page_start = self::td_round_number($start_page, 10) + $larger_page_multiple - $larger_per_page; $larger_start_page_end = self::td_round_number($start_page, 10) + $larger_page_multiple; $larger_end_page_start = self::td_round_number($end_page, 10) + $larger_page_multiple; $larger_end_page_end = self::td_round_number($end_page, 10) + $larger_per_page; if ($larger_start_page_end - $larger_page_multiple == $start_page) { $larger_start_page_start = $larger_start_page_start - $larger_page_multiple; $larger_start_page_end = $larger_start_page_end - $larger_page_multiple; } if ($larger_start_page_start <= 0) { $larger_start_page_start = $larger_page_multiple; } if ($larger_start_page_end > $max_page) { $larger_start_page_end = $max_page; } if ($larger_end_page_end > $max_page) { $larger_end_page_end = $max_page; } if ($max_page > 1 || intval($pagenavi_options['always_show']) == 1) { $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']); $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text); echo '<div class="page-nav td-pb-padding-side">'; previous_posts_link($pagenavi_options['prev_text']); if ($start_page >= 2 && $pages_to_show < $max_page) { $first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']); echo '<a href="' . esc_url(get_pagenum_link()) . '" class="first" title="' . $first_page_text . '">' . $first_page_text . '</a>'; if (!empty($pagenavi_options['dotleft_text'])) { echo '<span class="extend">' . $pagenavi_options['dotleft_text'] . '</span>'; } } if ($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) { for ($i = $larger_start_page_start; $i < $larger_start_page_end; $i += $larger_page_multiple) { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '<a href="' . esc_url(get_pagenum_link($i)) . '" class="page" title="' . $page_text . '">' . $page_text . '</a>'; } } for ($i = $start_page; $i <= $end_page; $i++) { if ($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']); echo '<span class="current">' . $current_page_text . '</span>'; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '<a href="' . esc_url(get_pagenum_link($i)) . '" class="page" title="' . $page_text . '">' . $page_text . '</a>'; } } if ($larger_page_to_show > 0 && $larger_end_page_start < $max_page) { for ($i = $larger_end_page_start; $i <= $larger_end_page_end; $i += $larger_page_multiple) { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '<a href="' . esc_url(get_pagenum_link($i)) . '" class="page" title="' . $page_text . '">' . $page_text . '</a>'; } } if ($end_page < $max_page) { if (!empty($pagenavi_options['dotright_text'])) { echo '<span class="extend">' . $pagenavi_options['dotright_text'] . '</span>'; } $last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']); echo '<a href="' . esc_url(get_pagenum_link($max_page)) . '" class="last" title="' . $last_page_text . '">' . $last_page_text . '</a>'; } next_posts_link($pagenavi_options['next_text'], $max_page); if (!empty($pages_text)) { echo '<span class="pages">' . $pages_text . '</span>'; } echo '</div>'; } }
<?php /* ---------------------------------------------------------------------------- the blog index template */ get_header(); global $loop_module_id, $loop_sidebar_position, $cur_cat_obj; $cur_cat_id = get_query_var('cat'); $cur_cat_obj = get_category($cur_cat_id); //read the per category setting $tdc_layout = td_util::get_category_option($cur_cat_id, 'tdc_layout'); //swich by RADU A, get_tax_meta($cur_cat_id, 'tdc_layout'); $tdc_sidebar_pos = td_util::get_category_option($cur_cat_id, 'tdc_sidebar_pos'); ////swich by RADU A, get_tax_meta($cur_cat_id, 'tdc_sidebar_pos'); // sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue $td_sidebar_position = ''; if ($loop_sidebar_position == 'sidebar_left') { $td_sidebar_position = 'td-sidebar-left'; } //set the template id, used to get the template specific settings $template_id = 'category'; //prepare the loop variables $loop_module_id = td_util::get_option('tds_' . $template_id . '_page_layout', 1); //module 1 is default $loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty) //override the category global template with the category specific settings if (!empty($tdc_layout)) { $loop_module_id = $tdc_layout; } if (!empty($tdc_sidebar_pos)) {
/** * Reads an individual setting - only one setting! * @param $read_array - * 'ds' => 'data source ID', 'item_id' = > 'the category id for example', - OPTIONAL category id or author id or page id * 'option_id' => 'the option id ex: background' * @return returns the value of the setting */ static function read($read_array) { switch ($read_array['ds']) { case 'td_taxonomy': return td_util::get_taxonomy_option($read_array['item_id'], $read_array['option_id']); break; case 'td_cpt': return td_util::get_ctp_option($read_array['item_id'], $read_array['option_id']); break; case 'td_category': return td_util::get_category_option($read_array['item_id'], $read_array['option_id']); break; case 'td_option': return td_util::get_option($read_array['option_id']); //htmlspecialchars() break; case 'wp_option': return htmlspecialchars(get_option($read_array['option_id'])); break; case 'td_homepage': // here we get all the options for the homepage (including widgets?) break; case 'td_page_option': break; case 'td_widget': break; //author metadata //author metadata case 'td_author': return get_the_author_meta($read_array['option_id'], $read_array['item_id']); break; //wordpress theme mod datasource //wordpress theme mod datasource case 'wp_theme_mod': return htmlspecialchars(get_theme_mod($read_array['option_id'])); break; //wordpress usermenu to menu spot datasource //wordpress usermenu to menu spot datasource case 'wp_theme_menu_spot': $menu_spots_array = get_theme_mod('nav_menu_locations'); //check to see if there is a menu assigned to that particular option_id (menu id) if (isset($menu_spots_array[$read_array['option_id']])) { return $menu_spots_array[$read_array['option_id']]; } else { return ''; } break; //translation data source //translation data source case 'td_translate': //get all the translations (they are stored in the td_008 variable) $translations = td_util::get_option('td_translation_map_user'); if (!empty($translations[$read_array['option_id']])) { return $translations[$read_array['option_id']]; //htmlspecialchars() } else { return ''; } //return td_util::get_option($read_array['option_id']); break; //read the ads parameters //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id] //read the ads parameters //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id] case 'td_ads': //get all the ad spots (they are stored in the td_008 variable) $ads = td_util::get_option('td_ads'); if (!empty($ads[$read_array['item_id']]) and !empty($ads[$read_array['item_id']][$read_array['option_id']])) { return htmlspecialchars($ads[$read_array['item_id']][$read_array['option_id']]); } else { return ''; } break; //social networks //social networks case 'td_social_networks': $social_array = td_util::get_option('td_social_networks'); if (!empty($social_array[$read_array['option_id']])) { return $social_array[$read_array['option_id']]; } else { return ''; } break; case 'td_fonts_user_insert': $fonts_user_inserted = td_util::get_option('td_fonts_user_inserted'); if (!empty($fonts_user_inserted[$read_array['option_id']])) { return $fonts_user_inserted[$read_array['option_id']]; } break; case 'td_fonts': $fonts_user_inserted = td_util::get_option('td_fonts'); if (!empty($fonts_user_inserted[$read_array['item_id']][$read_array['option_id']])) { return $fonts_user_inserted[$read_array['item_id']][$read_array['option_id']]; } break; case 'td_block_styles': //get the hole block style array $td_block_styles = td_util::get_option('td_block_styles'); if (!empty($td_block_styles) and !empty($td_block_styles[$read_array['item_id']][$read_array['option_id']])) { return $td_block_styles[$read_array['item_id']][$read_array['option_id']]; } break; // fake datasource for demo import panel, we just use the panel to render controls but we save on our own @todo - find a solution to this // fake datasource for demo import panel, we just use the panel to render controls but we save on our own @todo - find a solution to this case 'td_import_theme_styles': break; // fake datasource for metaboxes, we just use the panel to render controls but we save on our own @todo - find a solution to this // fake datasource for metaboxes, we just use the panel to render controls but we save on our own @todo - find a solution to this case 'td_page': break; case 'td_homepage_loop': break; case 'td_post_theme_settings': break; case 'td_update_theme_options': break; default: // try to get options for plugins return tdx_options::get_option($read_array['ds'], $read_array['option_id']); //return tdx_api_panel::get_data_from_datasource($read_array['ds'], $read_array['option_id']); break; } }
static function _helper_get_active_id() { $template_id = td_util::get_category_option(td_global::$current_category_obj->cat_ID, 'tdc_category_top_posts_style'); // first check the category setting if (empty($template_id)) { // now check the global setting - we have "default" selected on the category, the theme now looks for the global setting $template_id = td_util::get_option('tds_category_top_posts_style'); } if (empty($template_id)) { // nothing is set, check the default value $template_id = parent::get_default_component_id(__CLASS__); } return $template_id; }
//exclude uncategorized category $Obj_cat_uncategorized = get_category_by_slug('uncategorized'); $id_cat_uncategorized = $Obj_cat_uncategorized->term_id; //exclude featured category $Obj_cat_featured = get_category_by_slug('featured'); $id_cat_featured = $Obj_cat_featured->term_id; $td_sub_cats = get_categories(array('parent' => $cur_cat_obj->parent, 'exclude' => array($id_cat_uncategorized, $id_cat_featured), 'hide_empty' => 0, 'number' => $td_number_of_sibling_categories)); } } //$td_sub_cats = ''; //TO HIDE ALL THE CATEGORIES, UNCOMENT THIS LINE if (!empty($td_sub_cats)) { $buffy = '<div class="td-category-header">'; $buffy .= '<ul class="td-category td-category-page-subcats">'; foreach ($td_sub_cats as $td_sub_cat) { if (!empty($td_sub_cat->name) and td_util::get_category_option($td_sub_cat->cat_ID, 'tdc_hide_on_post') != 'hide') { $tax_meta_subcat_color = td_util::get_category_option($td_sub_cat->cat_ID, 'tdc_color'); $td_cat_color = ''; /* if (!empty($tax_meta_subcat_color)) { $td_cat_color = ' style="background-color:' . $tax_meta_subcat_color . ';"'; } else { */ if ($td_cat_without_subcats == 1 and $td_sub_cat->cat_ID == $cur_cat_id) { $td_cat_color = ' style="background-color:#222222;color:#ffffff;"'; } /*} */ $buffy .= '<li class="entry-category"><a ' . $td_cat_color . ' href="' . get_category_link($td_sub_cat->cat_ID) . '">' . $td_sub_cat->name . '</a></li>'; } } $buffy .= '</ul>'; $buffy .= '<div class="clearfix"></div>'; $buffy .= '</div>'; }
function td_modify_main_query_for_category_page($query) { //checking for category page and main query if (!is_admin() and is_category() and $query->is_main_query()) { //get the number of page where on $paged = get_query_var('paged'); //get the `filter_by` URL($_GET) variable $filter_by = get_query_var('filter_by'); //get the limit of posts on the category page $limit = get_option('posts_per_page'); // get the category object - with or without permalinks if (empty($query->query_vars['cat'])) { $td_current_category_obj = get_category_by_path(get_query_var('category_name'), false); // when we have permalinks, we have to get the category object like this. } else { $td_current_category_obj = get_category($query->query_vars['cat']); } //if this is `yes` then do not show the big grid $category_big_grid_hide_option = td_util::get_category_option($td_current_category_obj->cat_ID, 'tdc_slider'); //offset is hardcoded because of big grid $offset = 0; if ($category_big_grid_hide_option != 'yes') { $offset = 5; } //echo $filter_by; switch ($filter_by) { case 'featured': //get the category object $query->set('category_name', $td_current_category_obj->slug); $query->set('cat', get_cat_ID(TD_FEATURED_CAT)); //add the fetured cat break; case 'popular': $query->set('meta_key', td_page_views::$post_view_counter_key); $query->set('orderby', 'meta_value_num'); $query->set('order', 'DESC'); break; case 'popular7': $query->set('meta_key', td_page_views::$post_view_counter_7_day_total); $query->set('orderby', 'meta_value_num'); $query->set('order', 'DESC'); break; case 'review_high': $query->set('meta_key', td_review::$td_review_key); $query->set('orderby', 'meta_value_num'); $query->set('order', 'DESC'); break; case 'random_posts': $query->set('orderby', 'rand'); break; } //end switch // offset + custom pagination - if we have offset, wordpress overwrites the pagination and works with offset + limit if (!empty($offset) and $paged > 1) { $query->set('offset', $offset + ($paged - 1) * $limit); } else { $query->set('offset', $offset); } //print_r($query); } //end if main query }