/**
  * get the single breadcrumbs
  * @param $post_title
  * @return string
  */
 static function get_single_breadcrumbs($post_title)
 {
     /**
      * check to see if we are on a custom post type page. If that's the case we will load the breadcrumbs
      * via @see td_page_generator::get_custom_post_type_breadcrumbs() - in this file
      */
     global $post;
     if ($post->post_type != 'post') {
         return self::get_custom_post_type_breadcrumbs();
     }
     // get the breadcrumb for single posts - ! if we are on a custom post type, we don't get here !
     if (td_util::get_option('tds_breadcrumbs_show') == 'hide') {
         return '';
     }
     $category_1_name = '';
     $category_1_url = '';
     $category_2_name = '';
     $category_2_url = '';
     $primary_category_id = td_global::get_primary_category_id();
     $primary_category_obj = get_category($primary_category_id);
     //print_r($primary_category_obj);
     if (!empty($primary_category_obj)) {
         if (!empty($primary_category_obj->name)) {
             $category_1_name = $primary_category_obj->name;
         } else {
             $category_1_name = '';
         }
         if (!empty($primary_category_obj->cat_ID)) {
             $category_1_url = get_category_link($primary_category_obj->cat_ID);
         }
         if (!empty($primary_category_obj->parent) and $primary_category_obj->parent != 0) {
             $parent_category_obj = get_category($primary_category_obj->parent);
             if (!empty($parent_category_obj)) {
                 $category_2_name = $parent_category_obj->name;
                 $category_2_url = get_category_link($parent_category_obj->cat_ID);
             }
         }
     }
     if (!empty($category_1_name)) {
         //parent category (only if we have one and if the theme is set to show it)
         if (!empty($category_2_name) and td_util::get_option('tds_breadcrumbs_show_parent') != 'hide') {
             $breadcrumbs_array[] = array('title_attribute' => __td('查看所有文章:', TD_THEME_NAME) . ' ' . htmlspecialchars($category_2_name), 'url' => $category_2_url, 'display_name' => $category_2_name);
         }
         //child category
         $breadcrumbs_array[] = array('title_attribute' => __td('查看所有文章:', TD_THEME_NAME) . ' ' . htmlspecialchars($category_1_name), 'url' => $category_1_url, 'display_name' => $category_1_name);
         //article title (only if the theme is set to show it)
         if (td_util::get_option('tds_breadcrumbs_show_article') != 'hide') {
             //child category
             $breadcrumbs_array[] = array('title_attribute' => $post_title, 'url' => '', 'display_name' => td_util::excerpt($post_title, 13));
         }
     }
     if (isset($breadcrumbs_array) and is_array($breadcrumbs_array)) {
         //the breadcrumbs may be empty due to settings
         return self::get_breadcrumbs($breadcrumbs_array);
         //generate the breadcrumbs
     } else {
         return '';
     }
 }
 /**
  * get the single breadcrumbs
  * @param $post_title
  * @return string
  */
 static function get_single_breadcrumbs($post_title)
 {
     if (td_util::get_option('tds_breadcrumbs_show') == 'hide') {
         return;
     }
     $category_1_name = '';
     $category_1_url = '';
     $category_2_name = '';
     $category_2_url = '';
     $primary_category_id = td_global::get_primary_category_id();
     $primary_category_obj = get_category($primary_category_id);
     //print_r($primary_category_obj);
     if (!empty($primary_category_obj)) {
         if (!empty($primary_category_obj->name)) {
             $category_1_name = $primary_category_obj->name;
         } else {
             $category_1_name = '';
         }
         if (!empty($primary_category_obj->cat_ID)) {
             $category_1_url = get_category_link($primary_category_obj->cat_ID);
         }
         if (!empty($primary_category_obj->parent) and $primary_category_obj->parent != 0) {
             $parent_category_obj = get_category($primary_category_obj->parent);
             if (!empty($parent_category_obj)) {
                 $category_2_name = $parent_category_obj->name;
                 $category_2_url = get_category_link($parent_category_obj->cat_ID);
             }
         }
     }
     if (!empty($category_1_name)) {
         //parent category (only if we have one and if the theme is set to show it)
         if (!empty($category_2_name) and td_util::get_option('tds_breadcrumbs_show_parent') != 'hide') {
             $breadcrumbs_array[] = array('title_attribute' => __td('View all posts in', TD_THEME_NAME) . ' ' . htmlspecialchars($category_2_name), 'url' => $category_2_url, 'display_name' => $category_2_name);
         }
         //child category
         $breadcrumbs_array[] = array('title_attribute' => __td('View all posts in', TD_THEME_NAME) . ' ' . htmlspecialchars($category_1_name), 'url' => $category_1_url, 'display_name' => $category_1_name);
         //article title (only if the theme is set to show it)
         if (td_util::get_option('tds_breadcrumbs_show_article') != 'hide') {
             //child category
             $breadcrumbs_array[] = array('title_attribute' => $post_title, 'url' => '', 'display_name' => td_util::excerpt($post_title, 13));
         }
     }
     if (isset($breadcrumbs_array) and is_array($breadcrumbs_array)) {
         //the breadcrumbs may be empty due to settings
         return self::get_breadcrumbs($breadcrumbs_array);
         //generate the breadcrumbs
     } else {
         return '';
     }
 }
td_global::load_single_post($post);
/*  ----------------------------------------------------------------------------
    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') {
示例#4
0
 function wp_head_hook_background_logic()
 {
     global $post, $paged;
     $background_params = array('is_boxed_layout' => false, 'is_stretched_bg' => false, 'theme_bg_image' => td_util::get_option('tds_site_background_image'), 'theme_bg_repeat' => td_util::get_option('tds_site_background_repeat'), 'theme_bg_position' => td_util::get_option('tds_site_background_position_x'), 'theme_bg_attachment' => td_util::get_option('tds_site_background_attachment'), 'theme_bg_color' => td_util::get_option('tds_site_background_color'), 'td_ad_background_click_link' => stripslashes(td_util::get_option('tds_background_click_url')), 'td_ad_background_click_target' => td_util::get_option('tds_background_click_target'));
     /*  --------------------------------------------------------------------------
            Read the background settings
         */
     // is stretch background?
     if (td_util::get_option('tds_stretch_background') == 'yes') {
         $background_params['is_stretched_bg'] = true;
     }
     // activate the boxed layout - if we have an image or color
     if ($background_params['theme_bg_image'] != '' or $background_params['theme_bg_color'] != '') {
         $background_params['is_boxed_layout'] = true;
     }
     /*  --------------------------------------------------------------------------
             we are on a category
         */
     if (is_category()) {
         // try to read the category settings
         $post_primary_category_id = intval(get_query_var('cat'));
         //we are on a category, get the id @todo verify this, get_query_var('cat') may not work with permalinks
         $background_params = $this->get_category_bg_settings($post_primary_category_id, $background_params);
     } elseif (is_page()) {
         $td_page = get_query_var('page') ? get_query_var('page') : 1;
         //rewrite the global var
         $td_paged = get_query_var('paged') ? get_query_var('paged') : 1;
         //rewrite the global var
         if ($td_paged > $td_page) {
             $paged = $td_paged;
         } else {
             $paged = $td_page;
         }
         if (!empty($post->post_content) and strpos($post->post_content, 'td_block_homepage_full_1') !== false and (empty($paged) or $paged < 2)) {
             // deactivate the background only on td_block_homepage_full_1 + page 1.
             // on the second page, load it with the normal site wide background
             //$background_params['theme_bg_image']  = '';
             return;
             // THIS SHORTCODE disables the background AND background color!
         }
     } elseif (is_singular('post')) {
         //is_single runs on all the posts types, that's why we need is_singular
         // try to read the background settings for the parent category of this post
         $post_primary_category_id = intval(td_global::get_primary_category_id());
         // we are on single post - get the primary category id
         $background_params = $this->get_category_bg_settings($post_primary_category_id, $background_params);
         // read the per post single_template
         $post_meta_values = get_post_meta($post->ID, 'td_post_theme_settings', true);
         // if we don't have any single_template set on this post, try to laod the default global setting
         if (empty($post_meta_values['td_post_template'])) {
             $td_site_post_template = td_util::get_option('td_default_site_post_template');
         } else {
             $td_site_post_template = $post_meta_values['td_post_template'];
         }
         if (!empty($td_site_post_template)) {
             // we have a single_template set on a per post basis or on the global setting in the pane > post settings -> default post template (site wide)
             // overwrite the theme_bg_image with the featured image if needed
             if (td_api_single_template::get_key($td_site_post_template, 'bg_use_featured_image_as_background') === true) {
                 $background_params['theme_bg_image'] = td_util::get_featured_image_src($post->ID, 'full');
                 $background_params['is_stretched_bg'] = true;
             }
             // disable the background image if needed - used by singe_post_templates that implement their own backgrounds
             if (td_api_single_template::get_key($td_site_post_template, 'bg_disable_background') === true) {
                 $background_params['theme_bg_image'] = '';
                 $background_params['theme_bg_color'] = '';
             }
             // overwrite the box layout settings with the ones provided here
             switch (td_api_single_template::get_key($td_site_post_template, 'bg_box_layout_config')) {
                 case 'auto':
                     // do nothing - the site will load the site wide boxed layout settings
                     break;
                 case 'td-boxed-layout':
                     //force a boxed layout regardless if the site has a bg image or bg color
                     $background_params['is_boxed_layout'] = true;
                     break;
                 case 'td-full-layout':
                     //force a full layout regardless if the site has a bg image or bg color
                     $background_params['is_boxed_layout'] = false;
                     break;
             }
         }
     }
     // WE HAVE TO HAVE A IMAGE OR COLOR - @todo wtf needs to be refactorized
     new td_background_render($background_params);
 }
示例#5
0
 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'));
     }
 }
示例#6
0
    function td_render_more_article_box()
    {
        global $post;
        /**
         * More articles on post page
         */
        if (is_single() and td_util::get_option('tds_more_articles_on_post_pages_enable') == 'show') {
            //if to run the query
            $td_run_query = false;
            //current post ID
            $td_this_post_id = 0;
            //holds the tags for this post
            $td_get_post_tags = '';
            $td_post_tags = array();
            //primary category
            $primary_category = 0;
            //get the $post->ID
            if (!empty($post->ID) and intval($post->ID) > 0) {
                $td_this_post_id = intval($post->ID);
            }
            //create $args array  //'orderby' => 'date', 'order' => 'DESC' - this is the default for WP_Query
            switch (td_util::get_option('tds_more_articles_on_post_pages_display')) {
                //Same Tag
                case 'same_tag':
                    if ($td_this_post_id > 0) {
                        $td_get_post_tags = get_the_tags($td_this_post_id);
                        //itinerate to get the tags ids
                        if (!empty($td_get_post_tags)) {
                            foreach ($td_get_post_tags as $td_object_tag) {
                                $td_post_tags[] = $td_object_tag->term_id;
                            }
                        }
                        //if we have some tags
                        if (!empty($td_post_tags) and count($td_post_tags) > 0) {
                            $args = array('tag__in' => $td_post_tags, 'orderby' => 'rand');
                            $td_run_query = true;
                        }
                    }
                    break;
                    //Same Author
                //Same Author
                case 'same_author':
                    if (!empty($post->post_author) and intval($post->post_author) > 0) {
                        $args = array('author' => intval($post->post_author), 'orderby' => 'rand');
                        $td_run_query = true;
                    }
                    break;
                    //Random
                //Random
                case 'random':
                    $args = array('orderby' => 'rand');
                    $td_run_query = true;
                    break;
                    //Same Category
                //Same Category
                case 'same_category':
                    $primary_category = intval(td_global::get_primary_category_id());
                    if ($primary_category > 0) {
                        $args = array('cat' => $primary_category, 'orderby' => 'rand');
                        $td_run_query = true;
                    }
                    break;
                    //Latest Article
                //Latest Article
                default:
                    $args = array('orderby' => 'date', 'order' => 'DESC');
                    $td_run_query = true;
                    break;
            }
            //if to run the query
            if ($td_run_query === true) {
                //add number of post to $args
                $td_nr_of_posts = intval(td_util::get_option('tds_more_articles_on_post_pages_number'));
                if ($td_nr_of_posts > 0) {
                    $args['posts_per_page'] = $td_nr_of_posts;
                } else {
                    $args['posts_per_page'] = 1;
                }
                if ($td_this_post_id > 0) {
                    $args['post__not_in'] = array($td_this_post_id);
                }
                $args['ignore_sticky_posts'] = 1;
                //creating a new wp_query object foar our query
                $td_query_more_article = new WP_Query($args);
            }
            //add o post pages the more stories box
            if (!empty($td_query_more_article->posts)) {
                ?>
                <div class="td-more-articles-box">
                    <span class="td-sp td-sp-close-more-articles-box td-close-more-articles-box"></span>
                    <span class="td-more-articles-box-title"><?php 
                echo __td('MORE STORIES');
                ?>
</span>
                    <div class="td-content-more-articles-box">

                    <?php 
                $td_display_module = intval(td_util::get_option('tds_more_articles_on_post_pages_display_module'));
                //itinerate thru the resultset and display resuts
                foreach ($td_query_more_article->posts as $each_post) {
                    switch ($td_display_module) {
                        //module 3
                        case 3:
                            $td_mod = new td_module_3($each_post);
                            echo $td_mod->render();
                            break;
                            //module 4
                        //module 4
                        case 4:
                            $td_mod = new td_module_4($each_post);
                            echo $td_mod->render();
                            break;
                            //module 5
                        //module 5
                        case 5:
                            $td_mod = new td_module_5($each_post);
                            echo $td_mod->render();
                            break;
                            //module 6
                        //module 6
                        case 6:
                            $td_mod = new td_module_6($each_post);
                            echo $td_mod->render();
                            break;
                            //module 2
                        //module 2
                        default:
                            $td_mod = new td_module_2($each_post);
                            echo $td_mod->render();
                            break;
                    }
                }
                ?>
                    </div>
                </div><?php 
            }
            //if we have posts
        }
        //end more articles on post
    }
示例#7
0
    function td_render_more_article_box()
    {
        global $post;
        /**
         * More articles on post page
         */
        if (is_single() and td_util::get_option('tds_more_articles_on_post_pages_enable') == 'show') {
            //if to run the query
            $td_run_query = false;
            //current post ID
            $td_this_post_id = 0;
            //holds the tags for this post
            $td_get_post_tags = '';
            $td_post_tags = array();
            //primary category
            $primary_category = 0;
            //get the $post->ID
            if (!empty($post->ID) and intval($post->ID) > 0) {
                $td_this_post_id = intval($post->ID);
            }
            //create $args array  //'orderby' => 'date', 'order' => 'DESC' - this is the default for WP_Query
            switch (td_util::get_option('tds_more_articles_on_post_pages_display')) {
                //Same Tag
                case 'same_tag':
                    if ($td_this_post_id > 0) {
                        $td_get_post_tags = get_the_tags($td_this_post_id);
                        //itinerate to get the tags ids
                        if (!empty($td_get_post_tags)) {
                            foreach ($td_get_post_tags as $td_object_tag) {
                                $td_post_tags[] = $td_object_tag->term_id;
                            }
                        }
                        //if we have some tags
                        if (!empty($td_post_tags) and count($td_post_tags) > 0) {
                            $args = array('tag__in' => $td_post_tags, 'orderby' => 'rand');
                            $td_run_query = true;
                        }
                    }
                    break;
                    //Same Author
                //Same Author
                case 'same_author':
                    if (!empty($post->post_author) and intval($post->post_author) > 0) {
                        $args = array('author' => intval($post->post_author), 'orderby' => 'rand');
                        $td_run_query = true;
                    }
                    break;
                    //Random
                //Random
                case 'random':
                    $args = array('orderby' => 'rand');
                    $td_run_query = true;
                    break;
                    //Same Category
                //Same Category
                case 'same_category':
                    $primary_category = intval(td_global::get_primary_category_id());
                    if ($primary_category > 0) {
                        $args = array('cat' => $primary_category, 'orderby' => 'rand');
                        $td_run_query = true;
                    }
                    break;
                    //Latest Article
                //Latest Article
                default:
                    $args = array('orderby' => 'date', 'order' => 'DESC');
                    $td_run_query = true;
                    break;
            }
            //if to run the query
            if ($td_run_query === true) {
                //add number of post to $args
                $td_nr_of_posts = intval(td_util::get_option('tds_more_articles_on_post_pages_number'));
                if ($td_nr_of_posts > 0) {
                    $args['posts_per_page'] = $td_nr_of_posts;
                } else {
                    $args['posts_per_page'] = 1;
                }
                if ($td_this_post_id > 0) {
                    $args['post__not_in'] = array($td_this_post_id);
                }
                $args['ignore_sticky_posts'] = 1;
                //creating a new wp_query object foar our query
                $td_query_more_article = new WP_Query($args);
            }
            //add o post pages the more stories box
            if (!empty($td_query_more_article->posts)) {
                ?>
                <div class="td-more-articles-box">
                    <i class="td-icon-close td-close-more-articles-box"></i>
                    <span class="td-more-articles-box-title"><?php 
                echo __td('MORE STORIES', TD_THEME_NAME);
                ?>
</span>
                    <div class="td-content-more-articles-box">

                    <?php 
                $td_display_module = intval(td_util::get_option('tds_more_articles_on_post_pages_display_module'));
                //itinerate thru the resultset and display resuts
                foreach ($td_query_more_article->posts as $each_post) {
                    switch ($td_display_module) {
                        //module 2
                        case 2:
                            $td_mod = new td_module_2($each_post);
                            echo $td_mod->render();
                            break;
                            //module 3
                        //module 3
                        case 3:
                            $td_mod = new td_module_3($each_post);
                            echo $td_mod->render();
                            break;
                            //module 4
                        //module 4
                        case 4:
                            $td_mod = new td_module_4($each_post);
                            echo $td_mod->render();
                            break;
                            //module 5
                        //module 5
                        case 5:
                            $td_mod = new td_module_5($each_post);
                            echo $td_mod->render();
                            break;
                            //module 6
                        //module 6
                        case 6:
                            $td_mod = new td_module_6($each_post);
                            echo $td_mod->render();
                            break;
                            //module 7
                        //module 7
                        case 7:
                            $td_mod = new td_module_7($each_post);
                            echo $td_mod->render();
                            break;
                            //module 8
                        //module 8
                        case 8:
                            $td_mod = new td_module_8($each_post);
                            echo $td_mod->render();
                            break;
                            //module 9
                        //module 9
                        case 9:
                            $td_mod = new td_module_9($each_post);
                            echo $td_mod->render();
                            break;
                        default:
                            // $td_mod = new td_module_1($each_post);
                            // echo $td_mod->render();
                            // facebook //
                            // $instance = array(
                            //     "like_args" => array(
                            //             "href" => "https://www.facebook.com/rabbitcard",
                            //             "height" => "432",
                            //             "show_faces" => "1",
                            //             "stream" => "",
                            //             "cover" => "1"
                            //         )
                            // );
                            // the_widget( 'WPCOM_Widget_Facebook_LikeBox', $instance, $args );
                            // facebook //
                            echo '<div class="fb-page" data-href="https://www.facebook.com/rabbitcard" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="false"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/rabbitcard"><a href="https://www.facebook.com/rabbitcard">Rabbit</a></blockquote></div></div>';
                            // twitter //
                            echo '<br><br>';
                            $number = str_replace(".", ",", reset(explode(" ", end(explode('title="', reset(explode("/Rabbit_Card/followers", file_get_contents("https://twitter.com/rabbit_card"))))))));
                            echo '<div class="td_block_wrap td_block_social_counter td_block_widget td_block_id_2612886708 td_uid_50_564ad88d7b82d_rand td-pb-border-top">
                                <div class="td_social_type td-pb-margin-side td_social_twitter">
                                <div class="td-sp td-sp-twitter"></div>
                                <span class="td_social_info">' . $number . '</span>
                                <span class="td_social_info td_social_info_name">ผู้ติดตาม</span>
                                <span class="td_social_button">
                                <a href="https://twitter.com/Rabbit_Card" target="_blank">ติดตาม</a>
                                </span></div></div>';
                            break;
                    }
                }
                ?>
                    </div>
                </div><?php 
            }
            //if we have posts
        }
        //end more articles on post
    }