function circleflip_blog_thumbnail_fallback($html, $post_id, $post_thumbnail_id, $size, $attr) { // global $_wp_additional_image_sizes, $wp_query; if (!$html) { $html = circleflip_get_default_image($size); // if ( cr_get_option( 'post_default', false ) ) { // $html = '<img src="' . cr_get_option('post_default') . '"">'; // } else if ( ! $post_thumbnail_id && isset( $_wp_additional_image_sizes[$size] ) ) { // $html = "<img src='http://placehold.it/" // . "{$_wp_additional_image_sizes[$size]['width']}x" // . "{$_wp_additional_image_sizes[$size]['height']}'>"; // } } return $html; }
echo 'portfolioHomeMargin'; } ?> portfolioHome"> <div class="portfolioHomeImg"> <?php if (circleflip_valid($image_recent)) { ?> <?php echo wp_get_attachment_image($image_id, 'recent_home_posts'); ?> <?php } else { ?> <?php echo circleflip_get_default_image('recent_home_posts'); ?> <?php } echo circleflip_get_post_format_media($post->ID, 'recent_home_posts', 'my_unique_portfolio_posts'); ?> </div> </div> <?php if ($relatedCount > $relatedNumber) { $relatedCount = 0; } ?> <?php } ?>
function circleflip_portfolio_loadmore() { add_filter('circleflip_post_format_gallery_html', 'circleflip_gallery_portfolioformat', 10, 5); add_filter('circleflip_post_format_standard_html', 'circleflip_standard_portfolioformat', 10, 5); add_filter('circleflip_post_format_video_html', 'circleflip_video_portfolioformat', 10, 5); add_filter('circleflip_post_format_audio_html', 'circleflip_audio_portfolioformat', 10, 5); add_filter('circleflip_post_format_media_size', 'circleflip_full_video_size', 10, 5); add_filter('circleflip_post_format_meta', 'circleflip_gallery_layout', 10, 5); /* * Latest Posts - Popular - Selected Posts * Blog Posts - Portfolio * with Latest or Popular (Selected Categories Multiple Select) * Order -> Ascending or descending * Number of Posts */ $post_or_portfolio = isset($_POST['post_or_portfolio']) && 'portfolio' == $_POST['post_or_portfolio'] ? 'circleflip-portfolio' : 'post'; $cat_key = 'post' == $post_or_portfolio ? 'cat' : 'tax_query'; if ('circleflip-portfolio' == $post_or_portfolio) { $tax_query = array(array('taxonomy' => 'circleflip-portfolio-cats', 'field' => 'id', 'terms' => isset($_POST['cat_id']) ? explode(',', $_POST['cat_id']) : array())); } else { $tax_query = isset($_POST['cat_id']) ? $_POST['cat_id'] : ''; } switch ($_POST['post_type']) { // Latest case '0': $args = array('posts_per_page' => $_POST['postsnumber'], $cat_key => $tax_query, 'post_type' => $post_or_portfolio, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $_POST['pageNumber'], 'post_status' => 'publish'); break; // Popular // Popular case '1': global $wpdb; $args = array('posts_per_page' => $_POST['postsnumber'], 'post_type' => $post_or_portfolio, 'orderby' => 'post__in', 'post_status' => 'publish', $cat_key => $tax_query, 'post__in' => $wpdb->get_col("SELECT post_id, COUNT(*) as total FROM views_count WHERE 1 = 1 GROUP BY post_id ORDER BY total {$post_order}"), 'paged' => $_POST['pageNumber'], 'order' => 'DESC'); break; default: $args = array('posts_per_page' => $_POST['postsnumber'], $cat_key => $tax_query, 'post_type' => $post_or_portfolio, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $_POST['pageNumber'], 'post_status' => 'publish'); break; } if (empty($_POST['cat_id'])) { unset($args[$cat_key]); } $output = circleflip_query($args); switch ($_POST['layout']) { case 'span4': $image_size = 'recent_home_posts_two'; break; case 'span3': $image_size = 'recent_home_posts'; break; default: $image_size = 'recent_home_posts_two'; break; } foreach ($output as $post) { $src = ''; $image_recent = ''; if (has_post_thumbnail($post->ID)) { $post_img = wp_get_attachment_image($post->ID, $image_size); } else { if ($image_size == 'recent_home_posts_two') { $width = '367'; $height = '195'; } else { $width = '270'; $height = '150'; } $post_img = circleflip_get_default_image($image_size); } $post->postData = ' <div class="' . $_POST['layout'] . ' portfolioHome"> <div class="portfolioHomeImg"> ' . $post_img . circleflip_get_post_format_media($post->ID, $image_size, 'my_unique_portfolio_posts') . ' </div> </div>'; } echo json_encode($output); die; }
function widget($args, $instance) { // outputs the content of the widget wp_enqueue_style('recent_posts', get_template_directory_uri() . "/css/widgets/recent_posts.css", '2.0.3'); extract($args); $latest_title = apply_filters('widget_title', $instance['title']); echo $before_widget; ?> <!-- Widget Title --> <?php echo $before_title, $latest_title, $after_title; ?> <?php $latest_count = $instance['count']; $args = array('post_status' => 'publish', 'post_type' => 'post', 'order' => 'DESC', 'posts_per_page' => (int) $latest_count); $the_query = new WP_Query($args); add_filter('excerpt_more', array($this, 'excerpt_more')); add_filter('wp_trim_words', array($this, 'trim_excerpt'), 10, 4); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); ?> <!-- Single Post --> <div class="footerPost clearfix"> <!-- Image --> <?php if (has_post_thumbnail()) { the_post_thumbnail('cf-recent-posts'); } else { echo circleflip_get_default_image('cf-recent-posts'); ?> <?php } ?> <!-- Title --> <a href="<?php the_permalink(); ?> "> <h4> <?php the_title(); ?> </h4> </a> <!-- Text --> <?php the_excerpt(); ?> <!-- Date --> <span><?php printf(_x('%s ago', 'post published time', 'circleflip'), human_time_diff(get_the_date('U', get_the_ID()))); ?> </span> </div> <?php } } wp_reset_postdata(); remove_filter('wp_trim_words', array($this, 'trim_excerpt'), 10); remove_filter('excerpt_more', array($this, 'excerpt_more')); ?> <?php echo $after_widget; }
function magazineStyle4($instance) { extract($instance); $this->magazine_style4_enqueue(); /* * Latest Posts - Popular - Selected Posts * Blog Posts - Portfolio * with Latest or Popular (Selected Categories Multiple Select) * Order -> Ascending or descending * Number of Posts */ $post_selected_cats = isset(${"post_selected_cats_{$post_cat_type}"}) ? ${"post_selected_cats_{$post_cat_type}"} : array(); $output = circleflip_query($this->build_query_args($instance)); switch ($type_mag) { case '0': $layout = 'span4'; $image_size = 'recent_home_posts_two'; break; case '1': $layout = 'span3'; $image_size = 'recent_home_posts'; break; case '2': $layout = 'span6'; $image_size = 'magazine_half'; break; default: $layout = 'span4'; $image_size = 'recent_home_posts_two'; break; } $titleIconClass; switch ($titleIcon) { case 0: $titleIconClass = 'withoutIcon'; break; case 1: $titleIconClass = 'withIcon'; break; default: $titleIconClass = 'withoutIcon'; } $titleIconHead = ''; if ($titleIconClass == 'withIcon') { $iconHead; if (defined("ICL_LANGUAGE_CODE") && "ar" === ICL_LANGUAGE_CODE) { $iconHead = "icon-left-open-mini"; } else { $iconHead = "icon-right-open-mini"; } $titleIconHead = '<div class="headerDot"><span class="' . esc_attr($iconHead) . '"></span></div>'; } if ($output) { ?> <div class="magazineStyle magazineStyle4"> <?php if (circleflip_valid($title) || $post_type != 2 && $reload_section == "enable") { ?> <div class="titleBlock"> <?php if (circleflip_valid($title)) { ?> <h3 class="alignLeft"> <?php echo $titleIconHead . esc_html($title); ?> </h3> <?php } ?> <?php if ($post_type != 2 && $reload_section == "enable") { ?> <?php if (!circleflip_valid($title)) { ?> <h3 class="alignLeft"></h3> <?php } ?> <a class="loadMagazinePosts loadMagazine4Posts" data-pagenumber="2" data-posttype="<?php echo esc_attr($post_type); ?> " data-layout="<?php echo esc_attr($layout); ?> " data-postsnumber="<?php echo esc_attr($post_number); ?> " data-cats="<?php echo isset($post_selected_cats) ? esc_attr(implode(',', $post_selected_cats)) : ''; ?> " data-post-or-portfolio="<?php echo esc_attr($post_cat_type); ?> "> <span class="icon-spin3"></span> </a> <?php } ?> </div> <?php } ?> <div class="circleFlip row"> <?php global $post; foreach ($output as $post) { setup_postdata($post); ?> <div class="<?php echo esc_attr($layout . ' ' . $entrance_animation); ?> magazinePost magazinePost4 animateCr"> <!-- Magazine post Image --> <div class="image"> <?php if (has_post_thumbnail($post->ID)) { ?> <?php echo get_the_post_thumbnail($post->ID, $image_size); ?> <?php } else { echo circleflip_get_default_image($image_size); ?> <?php } ?> </div> <!-- Magazine post Right part --> <div class="magazineData"> <!-- Magazine post Author --> <div class="magazinePostAuthor"> <?php echo get_avatar($post->post_author); ?> <a href="<?php echo esc_url(get_author_posts_url($post->post_author)); ?> "><p><?php the_author_meta('display_name'); ?> </p></a> </div> <!-- Magazine post Date --> <div class="magazinePostDate"> <p> /</p> <span><?php echo get_the_date('d M Y'); ?> </span> </div> <!-- Magazine post title --> <?php $original_title = $post->post_title; $mag_post_title = circleflip_string_limit_characters($original_title, '45'); ?> <a class="magazinePostTitle" href="<?php the_permalink(); ?> "><h4><?php echo esc_html($mag_post_title); ?> </h4></a> <!-- Magazine post Categories --> <div class="magazineCategories"> <?php $post_categories = wp_get_post_categories(get_the_ID()); $cats = array(); for ($i = 0; $i < count($post_categories); $i++) { $cat = get_category($post_categories[$i]); $cat_name = $cat->name; $cat_link = get_category_link($cat->cat_ID); //$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug ); if ($i != count($post_categories) - 1) { echo ' <a href=' . esc_url($cat_link) . '><p>' . esc_html($cat_name) . ' , </p></a>'; } else { echo ' <a href=' . esc_url($cat_link) . '><p>' . esc_html($cat_name) . '</p></a>'; } } ?> </div> <!-- Magazine post excerpt --> <?php $original_text = sanitize_text_field($post->post_content); $mag_post_text = circleflip_string_limit_characters($original_text, '125'); ?> <p class="magazinePostExcerpt"><?php echo $mag_post_text; ?> </p> <!-- Magazine post views & comments number --> <div class="magazinePostViews"> <span class="icon-eye"></span> <span class="mag_views_no"> <?php if (cr_get_option("rtl", '0') == '1') { $standard = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); $east_arabic = array("٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"); $numOfViews = circleflip_read_number_of_views(get_the_ID()); $numOfViews = str_replace($standard, $east_arabic, $numOfViews); } else { $numOfViews = circleflip_read_number_of_views(get_the_ID()); } echo esc_html($numOfViews); ?> </span> </div> <div class="magazinePostComments"> <span class="icon-comment-1"></span> <span class="mag_comments_no"> <?php comments_number('0'); ?> </span> </div> <div class="magazinePostBtn"> <!-- <a href="<?php the_permalink(); ?> "><?php _e('more..', 'circleflip'); ?> </a> --> <a href="<?php the_permalink(); ?> " class=""> <span><?php _e('Read More..', 'circleflip'); ?> </span> </a> </div> </div> </div> <?php } ?> </div> </div> <?php if ($check_element_color == 1) { ?> <style> <?php $id_modified = str_replace('_', '-', $block_id); ?> #<?php echo $id_modified; ?> .magazinePost4 .image .magazinePostDate, #<?php echo $id_modified; ?> .magazinePostViews .mag_views_no, #<?php echo $id_modified; ?> .magazinePostComments .mag_comments_no, #<?php echo $id_modified; ?> [class*="btnStyle"].red{ background-color: <?php echo $elements_color; ?> ; } #<?php echo $id_modified; ?> .magazinePostTitle h4:hover, #<?php echo $id_modified; ?> .color, #<?php echo $id_modified; ?> .magazinePost4 .magazinePostBtn a:hover, #<?php echo $id_modified; ?> .magazinePost4 .magazinePostAuthor p:hover, #<?php echo $id_modified; ?> .magazinePost4 .magazineCategories p{ color: <?php echo $elements_color; ?> !important; } #<?php echo $id_modified; ?> .magazinePostViews .mag_views_no, #<?php echo $id_modified; ?> .magazinePostComments .mag_comments_no, #<?php echo $id_modified; ?> .magazinePost4 .magazinePostBtn a:hover{ border-color: <?php echo $elements_color; ?> ; } </style> <?php } } circleflip_end_query(); }
function circleflip_standard_mag4format($media_html, $post_id, $size, $ident, $audiovideo) { $post = get_post($post_id); if ('my_unique_mag4_posts' == $ident) { $src = ''; $image_mag = ''; if (has_post_thumbnail($post_id)) { $image_id = get_post_thumbnail_id($post_id); $image_mag = wp_get_attachment_image_src($image_id, $size); $src = $image_mag[0]; } ob_start(); ?> <!-- Magazine post Image --> <div class="image"> <?php if (circleflip_valid($src)) { ?> <?php echo wp_get_attachment_image($image_id, $size); ?> <?php } else { echo circleflip_get_default_image($size); ?> <?php } ?> </div> <!-- Magazine post Right part --> <div class="magazineData"> <!-- Magazine post Author --> <div class="magazinePostAuthor"> <?php echo get_avatar($post->post_author); ?> <a href="<?php echo get_author_posts_url($post->post_author); ?> "><p><?php the_author_meta('display_name', $post->post_author); ?> </p></a> </div> <!-- Magazine post Date --> <div class="magazinePostDate"> <p> /</p> <span><?php echo get_the_date('d M Y', $post->ID); ?> </span> </div> <!-- Magazine post title --> <?php $original_title = $post->post_title; $mag_post_title = circleflip_string_limit_characters($original_title, '45'); ?> <a class="magazinePostTitle" href="<?php echo get_permalink($post->ID); ?> "><h4><?php echo esc_html($mag_post_title); ?> </h4></a> <!-- Magazine post Categories --> <div class="magazineCategories"> <?php $post_categories = wp_get_post_categories($post->ID); $cats = array(); for ($i = 0; $i < count($post_categories); $i++) { $cat = get_category($post_categories[$i]); $cat_name = $cat->name; $cat_link = get_category_link($cat->cat_ID); //$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug ); if ($i != count($post_categories) - 1) { echo ' <a href=' . esc_url($cat_link) . '><p>' . esc_html($cat_name) . ' , </p></a>'; } else { echo ' <a href=' . esc_url($cat_link) . '><p>' . esc_html($cat_name) . '</p></a>'; } } ?> </div> <!-- Magazine post excerpt --> <?php $original_text = sanitize_text_field($post->post_content); $mag_post_text = circleflip_string_limit_characters($original_text, '125'); ?> <p class="magazinePostExcerpt"><?php echo esc_html($mag_post_text); ?> </p> <!-- Magazine post views & comments number --> <div class="magazinePostViews"> <span class="icon-eye"></span> <span class="mag_views_no"> <?php if (cr_get_option("rtl", '0') == '1') { $standard = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); $east_arabic = array("٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"); $numOfViews = circleflip_read_number_of_views($post->ID); $numOfViews = str_replace($standard, $east_arabic, $numOfViews); } else { $numOfViews = circleflip_read_number_of_views($post->ID); } echo esc_html($numOfViews); ?> </span> </div> <div class="magazinePostComments"> <span class="icon-comment-1"></span> <span class="mag_comments_no"> <?php comments_number('0'); ?> </span> </div> <div class="magazinePostBtn"> <!-- <a href="<?php the_permalink(); ?> "><?php _e('more..', 'circleflip'); ?> </a> --> <a href="<?php echo get_permalink($post->ID); ?> " class=""> <span><?php _e('Read More..', 'circleflip'); ?> </span> </a> </div> </div> <?php $media_html = ob_get_clean(); } return $media_html; }