Пример #1
0
function td_ajax_loop()
{
    $loopState = td_util::get_http_post_val('loopState');
    //print_r($loopState);
    $buffy = '';
    /**
     * @var WP_Query
     */
    $td_query =& td_data_source::get_wp_query($loopState['atts'], $loopState['currentPage']);
    //by ref  do the query
    if (!empty($td_query->posts)) {
        td_global::$is_wordpress_loop = true;
        ///if we are in wordpress loop; used by quotes in blocks to check if the blocks are displayed in blocks or in loop
        $td_template_layout = new td_template_layout($loopState['sidebarPosition']);
        $td_module_class = td_util::get_module_class_from_loop_id($loopState['moduleId']);
        //disable the grid for some of the modules
        $td_module_api = td_api_module::get_by_id($td_module_class);
        if ($td_module_api['uses_columns'] === false) {
            $td_template_layout->disable_output();
        }
        foreach ($td_query->posts as $post) {
            $buffy .= $td_template_layout->layout_open_element();
            if (class_exists($td_module_class)) {
                $td_mod = new $td_module_class($post);
                $buffy .= $td_mod->render();
            } else {
                td_util::error(__FILE__, 'Missing module: ' . $td_module_class);
            }
            $buffy .= $td_template_layout->layout_close_element();
            $td_template_layout->layout_next();
        }
        $buffy .= $td_template_layout->close_all_tags();
    } else {
        // no posts
    }
    $loopState['server_reply_html_data'] = $buffy;
    die(json_encode($loopState));
}
Пример #2
0
 /**
  * This method is used by modules to get content that has to be excerpted (cut)
  * IT RETURNS THE EXCERPT FROM THE POST IF IT'S ENTERED IN THE EXCERPT CUSTOM POST FIELD BY THE USER
  * @param string $cut_at - if provided the method will just cat at that point
  * @return string
  */
 function get_excerpt($cut_at = '')
 {
     //If the user supplied the excerpt in the post excerpt custom field, we just return that
     if ($this->post->post_excerpt != '') {
         return $this->post->post_excerpt;
     }
     $buffy = '';
     if ($cut_at != '') {
         // simple, $cut_at and return
         $buffy .= td_util::excerpt($this->post->post_content, $cut_at);
     } else {
         $current_module_class = get_class($this);
         //see if we have a default setting for this module, and if so only apply it if we don't get other things form theme panel.
         if (td_api_module::_check_excerpt_content($current_module_class)) {
             $db_content_excerpt = td_util::get_option($current_module_class . '_content_excerpt');
             if ($db_content_excerpt != '') {
                 //cut from the database settings
                 $buffy .= td_util::excerpt($this->post->post_content, $db_content_excerpt);
             } else {
                 //cut at the default size
                 $module_api = td_api_module::get_by_id($current_module_class);
                 $buffy .= td_util::excerpt($this->post->post_content, $module_api['excerpt_content']);
             }
         } else {
             /**
              * no $cut_at provided and no setting in td_config -> return the full $this->post->post_content
              * @see td_global::$modules_list
              */
             $buffy .= $this->post->post_content;
         }
     }
     return $buffy;
 }
Пример #3
0
/**
 * If you are looking for the loop that's handling the single post page (single.php), check out loop-single.php
 **/
// $global_flag_to_hide_no_post_to_display - comes from page-category-big-grid.php and is a flag to hide the 'No posts to display' message if on category page there are between 1 and 5  posts
global $loop_module_id, $loop_sidebar_position, $global_flag_to_hide_no_post_to_display;
///if we are in wordpress loop; used by quotes in blocks to check if the blocks are displayed in blocks or in loop
td_global::$is_wordpress_loop = true;
$td_template_layout = new td_template_layout($loop_sidebar_position);
if (empty($loop_module_id)) {
    //not sure if we need a default here
    $loop_module_id = 1;
}
$td_module_class = td_util::get_module_class_from_loop_id($loop_module_id);
//disable the grid for some of the modules
$td_module = td_api_module::get_by_id($td_module_class);
if ($td_module['uses_columns'] === false) {
    $td_template_layout->disable_output();
}
if (have_posts()) {
    while (have_posts()) {
        the_post();
        echo $td_template_layout->layout_open_element();
        if (class_exists($td_module_class)) {
            $td_mod = new $td_module_class($post);
            echo $td_mod->render();
        } else {
            td_util::error(__FILE__, 'Missing module: ' . $td_module_class);
        }
        echo $td_template_layout->layout_close_element();
        $td_template_layout->layout_next();