Beispiel #1
0
 function inner($posts, $td_column_number = '')
 {
     $buffy = '';
     $td_block_layout = new td_block_layout();
     if (empty($td_column_number)) {
         $td_column_number = td_util::vc_get_column_number();
         // get the column width of the block from the page builder API
     }
     $td_post_count = 0;
     // the number of posts rendered
     $td_current_column = 1;
     //the current columng
     if (!empty($posts)) {
         foreach ($posts as $post) {
             $td_module_5 = new td_module_5($post);
             switch ($td_column_number) {
                 case '1':
                     //one column layout
                     $buffy .= $td_block_layout->open12();
                     //added in 010 theme - span 12 doesn't use rows
                     $buffy .= $td_module_5->render($post);
                     $buffy .= $td_block_layout->close12();
                     break;
                 case '2':
                     //two column layout
                     $buffy .= $td_block_layout->open_row();
                     $buffy .= $td_block_layout->open6();
                     $buffy .= $td_module_5->render($post);
                     $buffy .= $td_block_layout->close6();
                     if ($td_current_column == 2) {
                         $buffy .= $td_block_layout->close_row();
                     }
                     break;
                 case '3':
                     //three column layout
                     $buffy .= $td_block_layout->open_row();
                     $buffy .= $td_block_layout->open4();
                     $buffy .= $td_module_5->render($post);
                     $buffy .= $td_block_layout->close4();
                     if ($td_current_column == 3) {
                         $buffy .= $td_block_layout->close_row();
                     }
                     break;
             }
             //current column
             if ($td_current_column == $td_column_number) {
                 $td_current_column = 1;
             } else {
                 $td_current_column++;
             }
             $td_post_count++;
         }
     }
     $buffy .= $td_block_layout->close_all_tags();
     return $buffy;
 }
Beispiel #2
0
 function inner($posts, $td_column_number = '')
 {
     //global $post;
     $buffy = '';
     $td_block_layout = new td_block_layout();
     if (empty($td_column_number)) {
         $td_column_number = $td_block_layout->get_column_number();
         // get the column width of the block
     }
     $td_post_count = 0;
     // the number of posts rendered
     $td_current_column = 1;
     //the current column
     if (!empty($posts)) {
         foreach ($posts as $post) {
             $td_module_3 = new td_module_3($post);
             $td_module_5 = new td_module_5($post);
             switch ($td_column_number) {
                 case '1':
                     //one column layout
                     if ($td_post_count == 0) {
                         //first post
                         $buffy .= $td_module_5->render();
                     } else {
                         $buffy .= $td_module_3->render();
                     }
                     break;
                 case '2':
                     //two column layout
                     $buffy .= $td_block_layout->open_row();
                     if ($td_post_count <= 1) {
                         // big posts
                         $buffy .= $td_block_layout->open6();
                         $buffy .= $td_module_5->render();
                         $buffy .= $td_block_layout->close6();
                     }
                     if ($td_post_count == 1) {
                         //close big posts
                         $buffy .= $td_block_layout->close_row();
                     }
                     if ($td_post_count > 1) {
                         //4th post (big posts are rendered)
                         if ($td_current_column == 1) {
                             // column 1
                             $buffy .= $td_block_layout->open_row();
                         }
                         $buffy .= $td_block_layout->open6();
                         $buffy .= $td_module_3->render();
                         $buffy .= $td_block_layout->close6();
                         if ($td_current_column == 2) {
                             // column 2
                             $buffy .= $td_block_layout->close_row();
                         }
                     }
                     break;
                 case '3':
                     //three column layout
                     $buffy .= $td_block_layout->open_row();
                     if ($td_post_count <= 2) {
                         // big posts
                         $buffy .= $td_block_layout->open4();
                         $buffy .= $td_module_5->render();
                         $buffy .= $td_block_layout->close4();
                     }
                     if ($td_post_count == 2) {
                         //close big posts
                         $buffy .= $td_block_layout->close_row();
                     }
                     if ($td_post_count > 2) {
                         //4th post (big posts are rendered)
                         if ($td_current_column == 1) {
                             // column 1
                             $buffy .= $td_block_layout->open_row();
                         }
                         $buffy .= $td_block_layout->open4();
                         $buffy .= $td_module_3->render();
                         $buffy .= $td_block_layout->close4();
                         if ($td_current_column == 3) {
                             // column 3
                             $buffy .= $td_block_layout->close_row();
                         }
                     }
                     break;
             }
             //current column
             if ($td_current_column == $td_column_number) {
                 $td_current_column = 1;
             } else {
                 $td_current_column++;
             }
             $td_post_count++;
         }
     }
     $buffy .= $td_block_layout->close_all_tags();
     return $buffy;
 }
    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
    }
    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
    }