コード例 #1
0
ファイル: index.php プロジェクト: nougad/Tiny-Tiny-RSS
	<?php 
print_user_stylesheet($link);
?>
</head>
<body id="ttrssMobile">

<div id="content">
<?php 
if (!$go) {
    render_feeds_list($link);
} else {
    if ($go == "vf") {
        render_headlines($link);
    } else {
        if ($go == "view") {
            render_article($link);
        } else {
            if ($go == "sform") {
                render_search_form($link, $_GET["aid"], $_GET["ic"]);
            } else {
                print __("Internal error: Function not implemented");
            }
        }
    }
}
?>
</div>

</body>
</html>
コード例 #2
0
ファイル: article.php プロジェクト: nougad/Tiny-Tiny-RSS
<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE);
header('Content-Type: text/html; charset=utf-8');
define('MOBILE_VERSION', true);
require_once "../config.php";
require_once "functions.php";
require_once "../functions.php";
require_once "../sessions.php";
require_once "../version.php";
require_once "../db-prefs.php";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
init_connection($link);
login_sequence($link, true);
$id = db_escape_string($_REQUEST["id"]);
$feed_id = db_escape_string($_REQUEST["feed"]);
$cat_id = db_escape_string($_REQUEST["cat"]);
$is_cat = db_escape_string($_REQUEST["is_cat"]);
render_article($link, $id, $feed_id, $cat_id, $is_cat);
?>

コード例 #3
0
ファイル: articles.php プロジェクト: php-fusion/PHP-Fusion
            dbquery("UPDATE " . DB_ARTICLES . " SET article_reads=article_reads+1 WHERE article_id='" . $_GET['article_id'] . "'");
        }
        $article = preg_split("/<!?--\\s*pagebreak\\s*-->/i", parse_textarea($data['article_article']));
        $pagecount = count($article);
        $article_subject = stripslashes($data['article_subject']);
        add_breadcrumb(array('link' => INFUSIONS . 'articles/articles.php?cat_id=' . $data['article_cat_id'], 'title' => $data['article_cat_name']));
        add_breadcrumb(array('link' => INFUSIONS . 'articles/articles.php?article_id=' . $_GET['article_id'], 'title' => $data['article_subject']));
        if ($data['article_keywords'] !== "") {
            set_meta("keywords", $data['article_keywords']);
        }
        $article_info = array("article_id" => $_GET['article_id'], "article_subject" => $article_subject, "article_snippet" => parse_textarea($data['article_snippet']), "article_article" => $article, "cat_id" => $data['article_cat_id'], "cat_name" => $data['article_cat_name'], "user_id" => $data['user_id'], "user_name" => $data['user_name'], "user_status" => $data['user_status'], "user_avatar" => $data['user_avatar'], "user_joined" => $data['user_joined'], "user_level" => $data['user_level'], "article_date" => $data['article_datestamp'], "article_breaks" => $data['article_breaks'], "article_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='" . $_GET['article_id'] . "'"), "article_reads" => $data['article_reads'], "article_allow_comments" => $data['article_allow_comments'], "article_allow_ratings" => $data['article_allow_ratings'], "page_nav" => $pagecount > 1 ? makepagenav($_GET['rowstart'], 1, $pagecount, 3, INFUSIONS . "articles/articles.php?article_id=" . $_GET['article_id'] . "&amp;") : "", "edit_link" => "");
        if (iADMIN && checkrights("A")) {
            $article_info['edit_link'] = INFUSIONS . "articles/articles_admin.php" . $aidlink . "&amp;action=edit&amp;section=article_form&amp;article_id=" . $article_info['article_id'];
        }
        set_title($article_subject . $locale['global_200'] . $locale['400']);
        render_article($article_subject, $article[$_GET['rowstart']], $article_info);
    } else {
        redirect(INFUSIONS . "articles/articles.php");
    }
} elseif (!isset($_GET['cat_id']) || !isnum($_GET['cat_id'])) {
    // category query
    set_title($locale['400']);
    $result = dbquery("SELECT\n\t\tac.article_cat_id, ac.article_cat_name, ac.article_cat_description, count(a.article_id) 'article_count', count(ac2.article_cat_id) 'article_sub_count'\n\t\tFROM " . DB_ARTICLE_CATS . " ac\n\t\tLEFT JOIN " . DB_ARTICLE_CATS . " ac2 on ac.article_cat_id=ac2.article_cat_parent\n\t\tLEFT JOIN " . DB_ARTICLES . " a on a.article_cat=ac.article_cat_id\n\t\t" . (multilang_table("AR") ? "WHERE ac.article_cat_language='" . LANGUAGE . "' AND" : "WHERE") . "\n\t\tac.article_cat_parent = '0'\n\t\tGROUP BY ac.article_cat_id\n\t\tORDER BY ac.article_cat_name\n\t\t");
    $info['articles_rows'] = dbrows($result);
    if ($info['articles_rows'] > 0) {
        while ($data = dbarray($result)) {
            $data['article_cat_description'] = parse_textarea($data['article_cat_description']);
            $info['articles']['item'][] = $data;
        }
    }
    render_articles_main($info);
コード例 #4
0
     $result = dbquery("UPDATE " . DB_ARTICLES . " SET article_reads=article_reads+1 WHERE article_id='" . (int) $_GET['article_id'] . "'");
 }
 $article = stripslashes($data['article_article']);
 if (preg_match('<--PAGEBREAK-->', $article)) {
     $article = explode("<--PAGEBREAK-->", $article);
 } else {
     $article = explode("<!-- pagebreak -->", $article);
 }
 $pagecount = count($article);
 $article_subject = stripslashes($data['article_subject']);
 $article_info = array("article_id" => (int) $_GET['article_id'], "cat_id" => $data['article_cat_id'], "cat_name" => $data['article_cat_name'], "user_id" => $data['user_id'], "user_name" => $data['user_name'], "user_status" => $data['user_status'], "article_subject" => $article_subject, "article_date" => $data['article_datestamp'], "article_breaks" => $data['article_breaks'], "article_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='" . (int) $_GET['article_id'] . "'"), "article_reads" => $data['article_reads'], "article_allow_comments" => $data['article_allow_comments']);
 add_to_title($locale['global_201'] . $article_subject);
 set_meta('keywords', $data['article_keywords'], false);
 set_meta('description', trimlink($article_subject, 255), false);
 echo "<!--pre_article-->";
 render_article($article_subject, $article[$_GET['page'] - 1], $article_info);
 echo "<!--sub_article-->";
 if ($settings['enable_tags']) {
     require_once INCLUDES . "tag_include.php";
     echo show_tags((int) $_GET['article_id'], "A");
 }
 if ($pagecount > 1) {
     echo "<div align='center' style='margin-top:5px;'>\n";
     echo pagination(true, (int) $_GET['page'] - 1, 1, $pagecount, 3, FUSION_SELF . "?article_id=" . (int) $_GET['article_id'] . "&amp;", "article", "-", (int) $_GET['article_id'], "-page-", "-", $article_subject);
     echo "\n</div>\n";
 }
 if ($data['article_allow_comments']) {
     require_once INCLUDES . "comments_include.php";
     showcomments("A", DB_ARTICLES, "article_id", (int) $_GET['article_id'], FUSION_SELF . "?article_id=" . (int) $_GET['article_id'], "article", "-", (int) $_GET['article_id'], "-page-", (int) $_GET['page'], "-", $article_subject);
 }
 if ($data['article_allow_ratings'] && $settings['ratings_enabled'] == "1") {
コード例 #5
0
ファイル: articles.lib.php プロジェクト: Rambutan/hamsterpaj
function render_full_article($article)
{
    if (empty($article)) {
        $out .= rounded_corners_top(array('color' => 'red'));
        $out .= '<h1>Den här artikeln kunde tyvärr inte hittas</h1>' . "\n";
        $out .= '<a href="?action=list"><< Gå till listan över artiklar</a>' . "\n";
        $out .= rounded_corners_bottom(array('color' => 'red'));
    } else {
        $out .= render_article($article);
        if ($article['photo_category_id'] > 0) {
            $options['category'] = $article['photo_category_id'];
            $photos = photos_fetch($options);
            $out .= '<h2>Tillhörande bilder</h2>' . "\n";
            $out .= photos_list($photos);
        }
        if ($article['showauthor'] == 1) {
            $out .= render_author($article['author']);
        }
        if (isset($article['forum_category_id']) && $article['forum_category_id'] != 0) {
            $all_categories_list = discussion_forum_categories_fetch(array('id' => $article['forum_category_id']));
            $category = array_pop($all_categories_list);
            $forum_security = forum_security(array('action' => 'view_category', 'category' => $category));
            if ($forum_security == true) {
                $path_to_category = discussion_forum_path_to_category(array('id' => $category['id']));
                $locator_options['categories'] = $path_to_category;
                unset($options);
                $options['max_levels'] = 0;
                $options['parent'] = $category['id'];
                $categories = discussion_forum_categories_fetch($options);
                $out .= discussion_forum_categories_list($categories);
                $out .= '<h2>Trådar</h2>' . "\n";
                $post_options['forum_id'] = $category['id'];
                $post_options['threads_only'] = true;
                $post_options['order_by_sticky'] = true;
                $post_options['page_offset'] = $request['page_offset'];
                $post_options['url_lookup'] = true;
                $threads = discussion_forum_post_fetch($post_options);
                //$threads['url'] = $path_to_trailing_category = array_pop($path_to_category) . '/' . $thread['handle'] . '/sida_1.php';
                $out .= discussion_forum_thread_list($threads);
                $path_to_trailing_category = array_pop($path_to_category);
                $out .= '<a href="' . $path_to_trailing_category['url'] . '">Skapa en egen tråd länkad till artikeln</a>' . '<br style="clear: both;" />';
                forum_update_category_session(array('category' => $category, 'threads' => $threads));
            }
        }
        if ($article['commentable'] == 1) {
            $out .= rounded_corners_top(array('color' => 'blue_deluxe'));
            if ($article['rankable'] == 1) {
                $out .= rank_input_draw($article['id'], 'articles');
            }
            $out .= comments_input_draw($article['id'], 'articles');
            $out .= '<div style="clear: both;"></div>' . "\n";
            $out .= rounded_corners_bottom();
            $out .= comments_list($article['id'], 'articles');
        }
    }
    if (is_privilegied('articles_admin')) {
        $out .= '<a href="/artiklar/index.php?action=admin&article=edit&id=' . $article['id'] . '">Ändra i artikeln</a>' . "\n";
    }
    return $out;
}
コード例 #6
0
function lptw_display_recent_posts($atts)
{
    $default_posts_per_page = get_option('posts_per_page', '10');
    $a = shortcode_atts(array('post_type' => 'post', 'category_id' => '', 'authors_id' => '', 'post_parent' => '0', 'posts_per_page' => $default_posts_per_page, 'exclude_posts' => '', 'exclude_current_post' => 'false', 'thumbnail_size' => 'thumbnail', 'random_thumbnail' => 'false', 'layout' => 'basic', 'color_scheme' => 'no-overlay', 'show_date' => 'true', 'fluid_images' => 'false', 'columns' => '1', 'height' => '', 'featured_height' => '400', 'min_height' => '400', 'width' => '300', 'date_format' => 'd.m.Y', 'time_format' => 'H:i', 'show_time' => 'true', 'show_time_before' => 'true', 'show_date_before_title' => 'true', 'order' => 'DESC', 'orderby' => 'date', 'reverse_post_order' => 'false', 'background_color' => '#4CAF50', 'text_color' => '#ffffff', 'no_thumbnails' => 'hide', 'space_hor' => 10, 'space_ver' => 10, 'tags_id' => '', 'tags_exclude' => 'false', 'override_colors' => 'false', 'excerpt_show' => 'true', 'excerpt_lenght' => '35', 'ignore_more_tag' => 'false', 'post_offset' => 0, 'read_more_show' => 'false', 'read_more_inline' => 'false', 'read_more_content' => 'Read more &rarr;', 'link_target' => 'self', 'show_subtitle' => 'true'), $atts);
    /* get the list of the post categories */
    if ($a['category_id'] == 'same_as_post') {
        $post_categories = get_the_category();
        if (!empty($post_categories)) {
            foreach ($post_categories as $category) {
                if ($category->taxonomy == 'category') {
                    $post_category[] = $category->term_id;
                }
            }
        }
    }
    /* ------------------------------------ WP_Query arguments filter start ------------------------------------ */
    if ($a['no_thumbnails'] == 'hide') {
        $meta_key = '_thumbnail_id';
    } else {
        $meta_key = '';
    }
    if (!empty($a['exclude_posts'])) {
        $exclude_post = explode(',', $a['exclude_posts']);
    } else {
        $exclude_post = '';
    }
    if ($a['exclude_current_post'] == 'true') {
        $current_post = get_the_ID();
        $exclude_post[] = $current_post;
    }
    if (strpos($a['authors_id'], ',') !== false) {
        $authors_id = array_map('intval', explode(',', $a['authors_id']));
    } else {
        $authors_id = (int) $a['authors_id'];
    }
    if (strpos($a['category_id'], ',') !== false) {
        $post_category = array_map('intval', explode(',', $a['category_id']));
    } else {
        if ($a['category_id'] != 'same_as_post') {
            $post_category = (int) $a['category_id'];
        }
    }
    $tax_query = '';
    if ($a['post_type'] != 'post' && !empty($post_category)) {
        $tax_query = array('relation' => 'AND');
        $taxonomies = get_object_taxonomies($a['post_type']);
        if (!empty($taxonomies)) {
            foreach ($taxonomies as $taxonomy) {
                $tax_array = array('taxonomy' => $taxonomy, 'field' => 'term_id', 'terms' => $post_category, 'include_children' => false);
                array_push($tax_query, $tax_array);
            }
        }
        $post_category = '';
    }
    if (strpos($a['tags_id'], ',') !== false) {
        $post_tags = array_map('intval', explode(',', $a['tags_id']));
    } else {
        $post_tags = (int) $a['tags_id'];
    }
    if ($a['post_type'] != 'post') {
        $post_tags = '';
    }
    if ($a['tags_exclude'] == 'true') {
        $tags_type = 'tag__not_in';
    } else {
        $tags_type = 'tag__in';
    }
    $lptw_shortcode_query_args = array('post_type' => $a['post_type'], 'posts_per_page' => $a['posts_per_page'], 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => $exclude_post, 'author__in' => $authors_id, 'category__in' => $post_category, $tags_type => $post_tags, 'tax_query' => $tax_query, 'order' => $a['order'], 'orderby' => $a['orderby'], 'meta_key' => $meta_key, 'offset' => $a['post_offset']);
    /* ------------------------------------ WP_Query arguments filter end ------------------------------------ */
    /* link target start */
    if ($a['link_target'] == 'new') {
        $link_target = '_blank';
    } else {
        $link_target = '_self';
    }
    /* link target end */
    /* date, title and subtitle position start */
    if ($a['show_date_before_title'] == 'true') {
        $date_pos = 1;
        $title_pos = 2;
    } else {
        $date_pos = 2;
        $title_pos = 1;
    }
    $subtitle_pos = 3;
    /* date, title and subtitle position end */
    $lptw_shortcode_query = new WP_Query($lptw_shortcode_query_args);
    if ($lptw_shortcode_query->have_posts()) {
        if ($a['reverse_post_order'] == 'true') {
            $lptw_shortcode_query->posts = array_reverse($lptw_shortcode_query->posts);
        }
        $i = 1;
        $rand_grid = rand(11111, 99999);
        $content = lptw_display_layout_header($a['layout'], $rand_grid);
        while ($lptw_shortcode_query->have_posts()) {
            $lptw_shortcode_query->the_post();
            $post_id = get_the_ID();
            $post_date = get_the_date($a['date_format']);
            $post_time = get_the_date($a['time_format']);
            $post_date_time = render_post_date($a, $post_date, $post_time);
            $post_subtitle = get_post_meta($post_id, 'lptw_post_subtitle', true);
            if ($post_subtitle != '' && $a['show_subtitle'] == 'true') {
                $post_subtitle_show = true;
            } else {
                $post_subtitle_show = false;
            }
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $a['thumbnail_size']);
            $url = $thumb['0'];
            if (!$url && $a['random_thumbnail'] == 'true') {
                $thumb_posts = get_posts(array('orderby' => 'rand', 'category' => $a['category_id'], 'numberposts' => 1, 'meta_key' => '_thumbnail_id'));
                foreach ($thumb_posts as $rand_post) {
                    $rand_post_id = $rand_post->ID;
                    $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($rand_post_id), $a['thumbnail_size']);
                    $url = $thumb['0'];
                }
            }
            /* ------------------------------------ main container columns ------------------------------------ */
            if ($a['fluid_images'] == 'true') {
                $column_class = 'lptw-columns-' . $a['columns'];
            } else {
                $column_class = 'lptw-columns-fixed';
            }
            /* ------------------------------------ main container styles start ------------------------------------ */
            $element_style_args = array();
            if ($a['width'] != '' && $a['fluid_images'] != 'true') {
                $element_style_args['width'] = $a['width'] . 'px';
            }
            if ($a['height'] != '' && $a['fluid_images'] != 'true') {
                $element_style_args['height'] = $a['height'] . 'px';
            }
            if ($a['columns'] > 1 && $a['layout'] != 'grid-medium') {
                if ($i % $a['columns'] == 0) {
                    $element_style_args['padding-bottom'] = $a['space_ver'] . 'px';
                } elseif ($i % $a['columns'] == 1 && $a['fluid_images'] != 'true') {
                    $element_style_args['padding-right'] = $a['space_hor'] . 'px';
                    $element_style_args['padding-bottom'] = $a['space_ver'] . 'px';
                    $element_style_args['clear'] = 'left';
                } else {
                    $element_style_args['padding-right'] = $a['space_hor'] . 'px';
                    $element_style_args['padding-bottom'] = $a['space_ver'] . 'px';
                }
            } else {
                if ($a['columns'] == 1 && $a['layout'] != 'grid-medium') {
                    $element_style_args['padding-bottom'] = $a['space_ver'] . 'px';
                } else {
                    $element_style_args['margin-bottom'] = $a['space_ver'] . 'px';
                }
            }
            /* ------------------------------------ main container styles end ------------------------------------ */
            /* ------------------------------------ start layouts output ------------------------------------ */
            /* ---------- basic layout (fluid images) - fixed or adaptive width, multiple columns ---------- */
            if ($a['layout'] == 'basic') {
                if ($url != '') {
                    $overlay_class = array('overlay', 'overlay-' . $a['color_scheme'], 'lptw-post-thumbnail-link');
                    $overlay_style = '';
                    $img_class = 'fluid-image-wrapper';
                    $img_content = '<img src="' . $url . '" alt="' . get_the_title() . '" class="fluid" />';
                    $layout_class = 'layout-' . $a['color_scheme'];
                } else {
                    $overlay_class = array('overlay', 'overlay-' . $a['color_scheme'], 'lptw-thumbnail-noimglink');
                    $overlay_style = array('background-color' => $a['background_color']);
                    $img_content = '';
                    $img_class = '';
                    /*$a['color_scheme'] = 'user';*/
                }
                if ($a['override_colors'] == 'true') {
                    $user_text_color = array('color' => $a['text_color']);
                } else {
                    $user_text_color = '';
                }
                $layout_classes = array(0 => 'basic-layout', 1 => $column_class, 2 => $layout_class);
                /* array with layout settings */
                $layout_sections = array(0 => array('type' => 'header', 'display' => true, 'id' => '', 'class' => ''));
                /* array with layout containers */
                $layout_containers = array(0 => array('place' => 'header', 'name' => 'image', 'display' => true, 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => $overlay_class, 'style' => $overlay_style, 'id' => ''), 1 => array('place' => 'header', 'name' => 'title', 'display' => true, 'class' => 'lptw-post-header', 'style' => '', 'id' => ''));
                /* array with layout objects */
                $layout_objects = array(0 => array('container' => 'image', 'display' => true, 'tag' => 'span', 'class' => $img_class, 'style' => '', 'id' => '', 'content' => $img_content), $date_pos => array('container' => 'title', 'display' => $a['show_date'], 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => array('lptw-post-date', 'date-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => $post_date_time), $title_pos => array('container' => 'title', 'display' => true, 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => array('lptw-post-title', 'title-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => get_the_title()), $subtitle_pos => array('container' => 'title', 'display' => $post_subtitle_show, 'tag' => 'span', 'class' => array('lptw-post-subtitle', 'subtitle-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => $post_subtitle));
                $content .= render_article($layout_classes, $element_style_args, $layout_sections, $layout_containers, $layout_objects);
                /* ---------- small thumbnails ---------- */
            } elseif ($a['layout'] == 'thumbnail') {
                /* get thumbnail url with size 100x100px */
                $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), array(100, 100));
                $title = get_the_title();
                if (empty($thumbnail) || $thumbnail == false) {
                    $img_class = 'lptw-thumbnail-noimglink';
                    $img_style = array('background-color' => $a['background_color'], 'color' => $a['text_color']);
                    $link_content = substr($title, 0, 1);
                } else {
                    $img_class = 'lptw-thumbnail-link';
                    $link_content = '<img src="' . $thumbnail['0'] . '" width="' . $thumbnail[1] . '" height="' . $thumbnail[2] . '" alt="' . $title . '" />';
                }
                $layout_classes = array(0 => 'thumbnail-layout', 1 => $column_class);
                /* array with layout settings */
                $layout_sections = array(0 => array('type' => 'header', 'display' => true, 'id' => '', 'class' => 'lptw-post-header'));
                /* array with layout containers */
                $layout_containers = array(0 => array('place' => 'header', 'name' => 'image', 'display' => true, 'class' => 'lptw-thumbnail-image', 'style' => '', 'id' => ''), 1 => array('place' => 'header', 'name' => 'title', 'display' => true, 'class' => 'lptw-thumbnail-title', 'style' => '', 'id' => ''));
                /* array with layout objects */
                $layout_objects = array(0 => array('container' => 'image', 'display' => true, 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => $img_class, 'style' => $img_style, 'id' => '', 'content' => $link_content), $date_pos => array('container' => 'title', 'display' => $a['show_date'], 'tag' => 'span', 'class' => 'lptw-post-date', 'style' => '', 'id' => '', 'content' => $post_date_time), $title_pos => array('container' => 'title', 'display' => true, 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => 'lptw-post-title', 'style' => '', 'id' => '', 'content' => $title), $subtitle_pos => array('container' => 'title', 'display' => $post_subtitle_show, 'tag' => 'span', 'class' => array('lptw-post-subtitle'), 'style' => '', 'id' => '', 'content' => $post_subtitle));
                $content .= render_article($layout_classes, $element_style_args, $layout_sections, $layout_containers, $layout_objects);
                /* ---------- recent posts without thumbnails, with date as drop cap ---------- */
            } elseif ($a['layout'] == 'dropcap') {
                $post_date = get_the_date('M.Y');
                $post_day = get_the_date('d');
                $layout_classes = array(0 => 'dropcap-layout', 1 => $column_class);
                /* array with layout settings */
                $layout_sections = array(0 => array('type' => 'header', 'display' => true, 'id' => ''));
                /* array with layout containers */
                $layout_containers = array(0 => array('place' => 'header', 'name' => 'date', 'display' => true, 'class' => 'lptw-dropcap-date', 'style' => array('background-color' => $a['background_color']), 'id' => ''), 1 => array('place' => 'header', 'name' => 'title', 'display' => true, 'class' => 'lptw-dropcap-title', 'style' => '', 'id' => ''));
                /* array with layout objects */
                $layout_objects = array(0 => array('container' => 'date', 'display' => true, 'tag' => 'span', 'class' => 'lptw-dropcap-day', 'style' => array('color' => $a['text_color']), 'id' => '', 'content' => $post_day), 1 => array('container' => 'date', 'display' => true, 'tag' => 'span', 'class' => 'lptw-dropcap-month', 'style' => array('color' => $a['text_color']), 'id' => '', 'content' => $post_date), 2 => array('container' => 'title', 'display' => true, 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => 'lptw-dropcap-date-link', 'style' => '', 'id' => '', 'content' => get_the_title()), 3 => array('container' => 'title', 'display' => $post_subtitle_show, 'tag' => 'span', 'class' => array('lptw-post-subtitle'), 'style' => '', 'id' => '', 'content' => $post_subtitle));
                /**
                                 Main render function
                                 **/
                $content .= render_article($layout_classes, $element_style_args, $layout_sections, $layout_containers, $layout_objects);
                /* --------- Responsive Grid - recent posts with thumbnail and featured posts --------- */
            } elseif ($a['layout'] == 'grid-medium') {
                /* get meta values */
                $featured = get_post_meta($post_id, 'featured_post', true);
                $embedded_video = get_post_meta($post_id, 'embedded_video', true);
                $hide_youtube_controls = get_post_meta($post_id, 'hide_youtube_controls', true);
                /* get embedded video frame code */
                $embedded_video_frame = lptw_get_first_embed_media($post_id);
                /* ------------ start calculate featured and base height and width ------------ */
                $featured_height = $a['featured_height'] . 'px';
                if ($a['fluid_images'] == 'true') {
                    $base_width = 100 / $a['columns'] - 1;
                    $normal_width = number_format($base_width, 2, '.', '') . '%';
                    $featured_width = number_format($base_width * 2 + 1, 2, '.', '') . '%';
                } else {
                    $normal_width = $a['width'] . 'px';
                    $featured_width = $a['width'] * 2 + $a['space_hor'] . 'px';
                }
                /* ------------ finish calculate featured and base height and width ------------ */
                /* ------------ start create styles ------------ */
                if ($a['height'] > 0) {
                    $element_style_args['height'] = $a['height'] . 'px';
                }
                if ($a['excerpt_show'] == 'false') {
                    $element_style_args['padding-bottom'] = '0.5rem';
                }
                if ($a['min_height'] > 0) {
                    $element_style_args['min-height'] = $a['min_height'] . 'px';
                }
                if ($a['override_colors'] == 'true') {
                    $user_text_color = 'style="color: ' . $a['text_color'] . ';"';
                    $element_style_args['background-color'] = $a['background_color'];
                } else {
                    $user_text_color = '';
                }
                if ($featured == 'on') {
                    $element_style_args['width'] = $featured_width;
                    $element_style_args['min-height'] = $featured_height;
                } else {
                    $element_style_args['width'] = $normal_width;
                }
                /* ------------ finish create styles ------------ */
                /* set the layout classes */
                $layout_classes = array('grid-layout', 'lptw-grid-element');
                if ($featured == 'on') {
                    array_push($layout_classes, 'lptw-featured');
                    $thumb_grid = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'lptw-grid-large');
                    if ($embedded_video != 'on') {
                        $display_post_header = 'true';
                        $element_style_args['background'] = 'url(' . $thumb_grid['0'] . ') center center no-repeat';
                        $element_style_args['background-size'] = 'cover';
                        $title_show = true;
                        /* image start */
                        $img_tag = 'a';
                        $img_href = get_the_permalink();
                        $img_class = 'lptw-post-grid-link';
                        $img_content = '<div class="overlay overlay-' . $a['color_scheme'] . '"></div>';
                        /* image end */
                    } else {
                        $display_post_header = 'false';
                        $title_show = false;
                        $img_tag = 'div';
                        $img_href = '';
                        $img_class = '';
                        $img_content = $embedded_video_frame;
                        array_push($layout_classes, 'lptw-video-container-featured');
                        if ($hide_youtube_controls != 'on') {
                            array_push($layout_classes, ' lptw-video-container-controls');
                        }
                    }
                } else {
                    $display_post_header = 'true';
                    array_push($layout_classes, 'grid-element-' . $a['color_scheme']);
                    /* image start */
                    if ($embedded_video == 'on' && $embedded_video_frame !== false) {
                        $img_tag = 'div';
                        $img_href = '';
                        if ($hide_youtube_controls != 'on') {
                            $controls_class = 'lptw-video-container-controls';
                        } else {
                            $controls_class = '';
                        }
                        $img_class = array('lptw-video-container', $controls_class);
                        $img_content = $embedded_video_frame;
                    } else {
                        $thumb_grid = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large');
                        $img_tag = 'a';
                        $img_href = get_the_permalink();
                        $img_class = '';
                        $img_content = '<img src="' . $thumb_grid['0'] . '" alt="' . get_the_title() . '" />';
                    }
                    /* image end */
                }
                /* end of post type switcher */
                /* ------------ the post excerpt start ------------ */
                if ($a['excerpt_show'] == 'true' && $featured != 'on') {
                    $excerpt_display = 'true';
                    $manual_excerpt = $lptw_shortcode_query->post->post_excerpt;
                    if (!empty($manual_excerpt)) {
                        $post_excerpt = $manual_excerpt;
                    } else {
                        $post_excerpt = lptw_custom_excerpt($a['excerpt_lenght'], $a['ignore_more_tag']);
                    }
                } else {
                    $excerpt_display = false;
                }
                if ($a['read_more_show'] == 'true' && $a['read_more_inline'] == 'true') {
                    $excerpt_style = array('display' => 'inline');
                    $read_more_style = array('margin-left' => '5px', 'display' => 'inline');
                }
                /* ------------ the post excerpt end ------------ */
                /* array with layout settings */
                $layout_sections = array(0 => array('type' => 'header', 'display' => 'true', 'id' => ''), 1 => array('type' => 'section', 'display' => $excerpt_display, 'id' => ''));
                /* array with layout containers
                 * 1 - image or video
                 * 2 - post header (title and date)
                 * 3 - post excerpt
                 */
                $layout_containers = array(0 => array('place' => 'header', 'name' => 'image', 'display' => 'true', 'class' => 'lptw-post-grid-link', 'style' => '', 'id' => ''), 1 => array('place' => 'header', 'name' => 'title', 'display' => $display_post_header, 'class' => 'lptw-post-header', 'style' => '', 'id' => ''), 2 => array('place' => 'section', 'name' => 'excerpt', 'display' => $excerpt_display, 'class' => array('post-excerpt', 'content-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => ''));
                /* array with layout objects
                 * 1 - image or video
                 * 2 - post title
                 * 3 - post date
                 * 4 - post subtitle
                 * 5 - post excerpt
                 * 6 - read more link
                 */
                $layout_objects = array(0 => array('container' => 'image', 'display' => 'true', 'tag' => $img_tag, 'href' => $img_href, 'class' => $img_class, 'style' => '', 'id' => '', 'content' => $img_content), $date_pos => array('container' => 'title', 'display' => $a['show_date'], 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => array('lptw-post-date', 'date-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => $post_date_time), $title_pos => array('container' => 'title', 'display' => 'true', 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => array('lptw-post-title', 'title-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => get_the_title()), $subtitle_pos => array('container' => 'title', 'display' => $post_subtitle_show, 'tag' => 'span', 'class' => array('lptw-post-subtitle', 'subtitle-' . $a['color_scheme']), 'style' => $user_text_color, 'id' => '', 'content' => $post_subtitle), 4 => array('container' => 'excerpt', 'display' => $excerpt_display, 'tag' => 'div', 'class' => '', 'style' => $excerpt_style, 'id' => '', 'content' => $post_excerpt), 5 => array('container' => 'excerpt', 'display' => $a['read_more_show'], 'tag' => 'a', 'href' => get_the_permalink(), 'target' => $link_target, 'class' => array('read-more-link', 'link-' . $a['color_scheme']), 'style' => $read_more_style, 'id' => '', 'content' => $a['read_more_content']));
                $content .= render_article($layout_classes, $element_style_args, $layout_sections, $layout_containers, $layout_objects);
            }
            /* end of the layout switcher */
            $i++;
        }
        // end while( $lptw_shortcode_query->have_posts() )
        $content .= '</div>';
        if ($a['layout'] == 'grid-medium') {
            $content .= '<script>
                            jQuery(window).on("load", function() {
                              var $ = jQuery;
                              $(".overlay").css("display", "block");
                              var $container = $("#lptw-grid-' . $rand_grid . '");
                              var fluid_images = ' . $a['fluid_images'] . ';
                              var countedColumnWidth;

                              // initialize
                              $container.masonry({
                                  itemSelector: ".lptw-grid-element",';
            if ($a['fluid_images'] != 'true') {
                $content .= 'gutter: ' . $a['space_hor'] . ',';
            }
            $content .= '     columnWidth: function(containerWidth) {
                                        if (containerWidth < 641) {
                                            $(".lptw-grid-element").css("width", "100%");
                                            countedColumnWidth = containerWidth - 1;
                                        } else if (containerWidth > 640) {
                                            $(".lptw-grid-element").css("width", "' . $normal_width . '");
                                            $(".lptw-featured").css("width", "' . $featured_width . '");
                                            if (fluid_images === true) {
                                        	    countedColumnWidth = (containerWidth / ' . $a['columns'] . ') - 1
                                            } else {
                                        	    countedColumnWidth = ' . $a['width'] . ' - 1
                                            }
                                        }
                                        return countedColumnWidth;
                                  }';
            $content .= '     });

                                $(window).resize(function() {
                                	var $container = $("#grid-container");
                                	var viewport = $(window).width();
                                    var fluid_images = ' . $a['fluid_images'] . ';

                                	if (viewport < 641) {
                                        $(".lptw-grid-element").css("width", "100%");
                                        $(".lptw-grid-element").css("height", "auto");
                                		$container.masonry("option", {
                                			columnWidth: viewport - 1
                                		});
                                	} else if (viewport > 640) {
                                        var containerWidth = $container.width();
                                        $(".lptw-grid-element").css("width", "' . $normal_width . '");
                                        $(".lptw-featured").css("width", "' . $featured_width . '");

                                        if (fluid_images === true) {
                                    		$container.masonry("option", {
                                    			columnWidth: (containerWidth / ' . $a['columns'] . ') - 1
                                    		});
                                        } else {
                                            $(".lptw-featured").css("height", "' . $a['height'] . '");
                                    		$container.masonry("option", {
                                    			columnWidth: ' . $a['width'] . ' - 1
                                    		});
                                        }
                                    }
                                });

                            });

                        </script>';
        }
    } else {
        $content = __('No recent posts', 'lptw_recent_posts_domain');
    }
    wp_reset_postdata();
    return $content;
}