function hvboom_get_portfolio()
{
    $portfolio = '<section class="hvboom-portfolio">' . PHP_EOL;
    $args = "post_type=portfolio";
    $catalog = new WP_Query($args);
    while ($catalog->have_posts()) {
        $catalog->the_post();
        $img = hvboom_get_image();
        $portfolio .= '  <article>' . PHP_EOL;
        $portfolio .= '    <div class="styling-wrapper">' . PHP_EOL;
        $portfolio .= $img;
        $portfolio .= '      <header><h1>';
        $portfolio .= sprintf('<a href="%s" rel="bookmark">', esc_url(get_permalink())) . get_the_title() . '</a>';
        $portfolio .= '</h1></header>' . PHP_EOL;
        $portfolio .= '      <section>' . get_the_excerpt() . '</section>' . PHP_EOL;
        $portfolio .= '      <hr />' . PHP_EOL;
        $portfolio .= '      <footer>' . PHP_EOL;
        $portfolio .= sprintf('      <a href="%s" class="" role="button">', esc_url(get_permalink())) . __('View Project', 'hvboom') . '</a>' . PHP_EOL;
        $portfolio .= '      </footer>' . PHP_EOL;
        $portfolio .= '    </div> <!-- end of styling-wrapper -->' . PHP_EOL;
        $portfolio .= '  </article>' . PHP_EOL;
        $portfolio .= '  <smart-break></smart-break> <!-- styling element used only to break article in a responsive way -->' . PHP_EOL;
    }
    wp_reset_postdata();
    $portfolio .= '</section>' . PHP_EOL;
    return $portfolio;
}
Example #2
0
 /**
  * Latest blog posts
  *
  * @param int    $limit post display limit
  *
  * @param string $thumbnail_size
  *
  * @return array
  */
 public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
 {
     $args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
     $array_out = array();
     $recent_posts = \get_posts(\wp_parse_args($args));
     /*$like_bool    = Option::get_theme_option( 'blog_list_like' );
       if ( $like_bool === '1' ) {
           $PostLike = \SilverWp\Ajax\PostLike::getInstance();
       }*/
     foreach ($recent_posts as $key => $recent) {
         \setup_postdata($recent);
         $post_id = $recent->ID;
         //$array_out[ $key ] = $recent;
         $array_out[$key]['ID'] = $post_id;
         $array_out[$key]['post_title'] = \get_the_title($post_id);
         $array_out[$key]['url'] = \get_the_permalink($post_id);
         $array_out[$key]['post_author'] = \get_the_author();
         $array_out[$key]['post_date'] = \get_the_date('', $post_id);
         $array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
         //$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
         $array_out[$key]['post_comment_count'] = $recent->comment_count;
         if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
             $array_out[$key]['post_excerpt'] = \get_the_excerpt();
         } else {
             $array_out[$key]['post_excerpt'] = $recent->post_excerpt;
         }
         $array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
         // Thumbnail
         $array_out[$key]['categories'] = self::getTaxonomy($post_id);
     }
     \wp_reset_postdata();
     return $array_out;
 }
Example #3
0
function blog_summary_shortcode($attr)
{
    // Describes what attributes to parse from shortcode; only 'count'
    extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr));
    // Queries to populate our loop based on shortcode count attribute
    $r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish");
    // Only run if we have posts; can't run this through searches
    if ($r->have_posts() && !is_search()) {
        // If we're using a Sandbox-friendly theme . . .
        if (function_exists('sandbox_body_class')) {
            // We can't have double hfeed classes, otherwise it won't parse
            $groupclasses = 'xoxo';
        } else {
            // Otherwise, use hfeed to ensure hAtom compliance
            $groupclasses = 'xoxo hfeed';
        }
        // Begin the output for shortcode and inserts in the group tag what classes we have
        $output = '<' . $grouptag . ' class="' . $groupclasses . '">';
        // Begins our loop for returning posts
        while ($r->have_posts()) {
            // Sets which post from our loop we're at
            $r->the_post();
            // Allows the_date() with multiple posts within a single day
            unset($previousday);
            // If we're using a Sandbox-friendly theme . . .
            if (function_exists('sandbox_post_class')) {
                // Let's use semantic classes with each entry element
                $entryclasses = sandbox_post_class(false);
            } else {
                // Otherwise, use hentry to ensure hAtom compliance
                $entryclasses = 'hentry';
            }
            // Begin entry wrapper and inserts what classes we got from above
            $output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">';
            // Post title
            $output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>';
            // Post date with hAtom support
            $output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>';
            // Comments number
            $output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>';
            // Post excerpt with hAtom support
            $output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>';
            // Close each post LI
            $output .= "\n" . '</' . $entrytag . '>';
            // Finish the have_posts() query
        }
        // while ( $r->have_posts() ) :
        // Close the parent UL
        $output .= "\n" . '</' . $grouptag . '>';
        // Rewinds loop from $r->the_post();
        rewind_posts();
        // End the initial IF statement
    }
    // if ( $r->have_posts() ) :
    // Clears our query to put the loop back where it was
    wp_reset_query();
    // $r = new WP_Query()
    // Returns $output to the shortcode
    return $output;
}
Example #4
0
function porto_get_excerpt($limit = 45, $more_link = true)
{
    global $porto_settings;
    if (!$limit) {
        $limit = 45;
    }
    if (has_excerpt()) {
        $content = strip_tags(strip_shortcodes(get_the_excerpt()));
    } else {
        $content = strip_tags(strip_shortcodes(get_the_content()));
    }
    $content = explode(' ', $content, $limit);
    if (count($content) >= $limit) {
        array_pop($content);
        if ($more_link) {
            $content = implode(" ", $content) . '... ';
        } else {
            $content = implode(" ", $content) . ' [...]';
        }
    } else {
        $content = implode(" ", $content);
    }
    if ($porto_settings['blog-excerpt-type'] == 'html') {
        $content = apply_filters('the_content', $content);
        $content = do_shortcode($content);
    }
    if ($more_link) {
        $content .= ' <a class="read-more" href="' . esc_url(apply_filters('the_permalink', get_permalink())) . '">' . __('read more', 'porto') . ' <i class="fa fa-angle-right"></i></a>';
    }
    if ($porto_settings['blog-excerpt-type'] != 'html') {
        $content = '<p class="post-excerpt">' . $content . '</p>';
    }
    return $content;
}
Example #5
0
function cfct_about_text()
{
    $about_text = get_option('cfct_about_text');
    if (!empty($about_text)) {
        $about_text = cfct_basic_content_formatting($about_text);
    } else {
        global $post, $wp_query;
        $orig_post = $post;
        isset($wp_query->query_vars['page']) ? $page = $wp_query->query_vars['page'] : ($page = null);
        // temporary - resetting below
        $wp_query->query_vars['page'] = null;
        remove_filter('the_excerpt', 'st_add_widget');
        $about_query = new WP_Query('pagename=about');
        while ($about_query->have_posts()) {
            $about_query->the_post();
            $about_text = get_the_excerpt() . sprintf(__('<a class="more" href="%s">more &rarr;</a>', 'carrington'), get_permalink());
        }
        $wp_query->query_vars['page'] = $page;
        $post = $orig_post;
        setup_postdata($post);
    }
    if (function_exists('st_add_widget')) {
        add_filter('the_excerpt', 'st_add_widget');
    }
    return $about_text;
}
Example #6
0
function todays_movies()
{
    $todays_movies = array();
    $args = array('post_type' => array('film'), 'posts_per_page' => -1);
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $schedule = get_post_meta(get_the_ID(), 'film_horaire', true);
            $duration = get_post_meta(get_the_ID(), 'film_duration', true);
            //the_title();
            //piklist::pre($schedule);
            foreach ($schedule as $key) {
                //echo $key['film_date'] . '<br>';
                $movie_iso_date = DateTime::createFromFormat('d/m/Y', $key['film_date'])->format('Y-m-d');
                //echo $movie_iso_date . '<br>';
                if (date('Y-m-d') == $movie_iso_date) {
                    $director = get_the_terms($post->ID, 'director');
                    $countries = get_the_terms($post->ID, 'country');
                    $languages = get_the_terms($post->ID, 'language');
                    $year = get_the_terms($post->ID, 'film-year');
                    $format = get_the_terms($post->ID, 'format');
                    $featured_image = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
                    $film_detail = array('id' => get_the_ID(), 'image' => $featured_image, 'title' => get_the_title(), 'duration' => $duration, 'excerpt' => get_the_excerpt(), 'link' => get_permalink(), 'date' => $movie_iso_date, 'hour' => $key['film_heure'], 'director' => $director, 'country' => $countries, 'language' => $languages, 'year' => $year, 'format' => $format);
                    array_push($todays_movies, $film_detail);
                }
            }
        }
        wp_reset_postdata();
    }
    return $todays_movies;
}
Example #7
0
function description()
{
    if (is_home() || is_front_page()) {
        echo trim(of_get_option('site_description'));
    } elseif (is_category()) {
        $description = strip_tags(category_description());
        echo trim($description);
    } elseif (is_single()) {
        if (get_the_excerpt()) {
            echo get_the_excerpt();
        } else {
            global $post;
            $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content))));
            echo mb_substr($description, 0, 220, 'utf-8');
        }
    } elseif (is_search()) {
        echo '“';
        the_search_query();
        echo '”为您找到结果 ';
        global $wp_query;
        echo $wp_query->found_posts;
        echo ' 个';
    } elseif (is_tag()) {
        $description = strip_tags(tag_description());
        echo trim($description);
    } else {
        $description = strip_tags(term_description());
        echo trim($description);
    }
}
Example #8
0
function get_skills_registration($atts)
{
    $string = '';
    //$attributes = shortcode_atts( array(), $atts ); //get attributes
    $args = array('posts_per_page' => -1, 'post_type' => 'skeleton_skill', 'orderby' => 'menu_order', 'order' => 'ASC');
    $skills = get_posts($args);
    global $post;
    $string .= "<h3 class='shortcode-title'>Skills</h3>";
    $i = 0;
    foreach ($skills as $post) {
        $i++;
        if ($i % 2 == 0) {
            $class = 'right';
        } else {
            $class = 'left';
        }
        setup_postdata($post);
        $bg_image_url = '"' . wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'full') . '"';
        $content = get_the_excerpt();
        $title = get_the_title();
        $link = get_the_permalink();
        $string .= "<div class='skill-container' style='background-image: url({$bg_image_url})'>";
        $string .= "<a class='skill-link' href='{$link}' title='{$title}'></a>";
        $string .= "<div class='skill-content {$class}'>";
        $string .= "<h4>{$title}</h4>";
        $string .= "<div class='description'>{$content}</div>";
        $string .= "</div>";
        //skill-content
        $string .= "</div>";
        //skill-container
    }
    wp_reset_query();
    return $string;
}
/**
 * Helper function to grab and display thumbnail from specified post
 * @since 1.4.0
 */
function arras_get_thumbnail($size = 'thumbnail', $id = NULL)
{
    global $post, $arras_image_sizes;
    $empty_thumbnail = '<img src="' . get_template_directory_uri() . '/images/thumbnail.png" alt="' . get_the_excerpt() . '" title="' . get_the_title() . '" />';
    if ($post) {
        $id = $post->ID;
    }
    // get post thumbnail (WordPress 2.9)
    if (function_exists('has_post_thumbnail')) {
        if (has_post_thumbnail($id)) {
            return get_the_post_thumbnail($id, $size, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
        } else {
            // Could it be an attachment?
            if ($post->post_type == 'attachment') {
                return wp_get_attachment_image($id, $size, false, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
            }
            // Use first thumbnail if auto thumbs is enabled.
            if (arras_get_option('auto_thumbs')) {
                $img_id = arras_get_first_post_image_id();
                if (!$img_id) {
                    return $empty_thumbnail;
                }
                return wp_get_attachment_image($img_id, $size, false, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
            }
        }
    }
    return $empty_thumbnail;
}
Example #10
0
function ipin_opengraph()
{
    if (is_single()) {
        global $post;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . preg_replace('/[\\n\\r]/', ' ', the_title_attribute('echo=0')) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
        $output .= '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
    if (is_tax('board')) {
        global $post, $wp_query;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . $wp_query->queried_object->name . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/board/') . $wp_query->queried_object->term_id . '/" />' . "\n";
        $output .= '<meta property="og:description" content="" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
}
 public function register_meta_tags()
 {
     add_action('wp_head', function () {
         if (is_singular() && false == post_password_required()) {
             if ('' == ($description = get_the_excerpt())) {
                 $description = wp_trim_words(esc_html(strip_shortcodes(get_the_content())), 20, '...');
             }
         } elseif (is_category() && '' != category_description()) {
             $description = category_description();
         } elseif (is_tag() && '' != term_description()) {
             $description = term_description();
         } else {
             $description = get_bloginfo('description');
         }
         $description = esc_attr($description);
         echo "<meta name=\"description\" content=\"{$description}\" />\n";
         echo "<meta name=\"og:description\" content=\"{$description}\" />\n";
         if (is_singular() && false == post_password_required() && has_post_thumbnail()) {
             list($image, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id(), 'facebook');
         } else {
             $image = apply_filters('', $this->get_theme_assets_url() . '/images/logo-fb.png');
         }
         $image = esc_url($image);
         echo "<meta name=\"og:image\" content=\"{$image}\" />\n";
         echo "<meta name=\"twitter:image\" content=\"{$image}\" />\n";
     });
 }
 function find_post()
 {
     $this->verify_ajax_call();
     $q = $_GET['query'];
     $the_query = new WP_Query('s=' . $q);
     //$response = array('empty','test');
     $d = new stdClass();
     $d->query = $q;
     $d->suggestions = array();
     $d->data = array();
     // The Loop
     global $post;
     while ($the_query->have_posts()) {
         $the_query->the_post();
         $d->suggestions[] = get_the_title();
         $content = get_the_content();
         $content = apply_filters('the_content', $content);
         $content = str_replace(']]>', ']]&gt;', $content);
         $d->data[] = array("content" => $content, "excerpt" => get_the_excerpt(), "url" => get_permalink());
     }
     // Reset Post Data
     wp_reset_postdata();
     // Serialize the response back as JSON
     echo json_encode($d);
     die;
 }
Example #13
0
function sequence_slider_display($atts)
{
    extract(shortcode_atts(array('limit' => 10), $atts));
    $args = array('post_type' => 'sequence-slider', 'posts_per_page' => $limit);
    // The Query
    $the_query = new WP_Query($args);
    $html = null;
    // The Loop
    if ($the_query->have_posts()) {
        $html .= '<div class="sequence-theme">';
        $html .= '<div class="sequence">';
        $html .= '<img class="sequence-prev" src="' . SEQUENCE_PLUGIN_URL . 'images/bt-prev.png" alt="Previous Frame" />';
        $html .= '<img class="sequence-next" src="' . SEQUENCE_PLUGIN_URL . 'images/bt-next.png" alt="Next Frame" />';
        $html .= '<ul class="sequence-canvas">';
        while ($the_query->have_posts()) {
            $the_query->the_post();
            //echo "<pre>";
            //print_r($the_query);
            $html .= '<li class="animate-in">';
            $html .= '<h3 class="title">' . get_the_title() . '</h3>';
            $html .= '<h4 class="subtitle">' . get_the_excerpt() . '';
            $html .= '<a class="slider_link" href="' . get_post_meta($the_query->post->ID, '_link', true) . '">' . get_post_meta($the_query->post->ID, '_text', true) . '</a></h4>';
            $html .= get_the_post_thumbnail($the_query->post->ID, 'full', array('class' => 'model'));
            $html .= '</li>';
        }
        $html .= '</ul>';
        //$html .= '<ul class="sequence-pagination"></ul>';
        $html .= '</div></div>';
    } else {
        // no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();
    return $html;
}
Example #14
0
 protected function queryAndResponse($arg)
 {
     $the_query = new WP_Query($arg);
     if ($the_query->have_posts()) {
         $counter = 0;
         $items = array();
         while ($the_query->have_posts()) {
             $the_query->the_post();
             global $post;
             $title = get_the_title();
             $link = get_permalink();
             $excerpt = wechat_get_excerpt(get_the_excerpt());
             if ($counter == 0) {
                 $thumb = wechat_get_thumb($post, array(640, 320));
             } else {
                 $thumb = wechat_get_thumb($post, array(80, 80));
             }
             $new_item = new NewsResponseItem($title, $excerpt, $thumb, $link);
             array_push($items, $new_item);
             // 最多显示3篇
             if (++$counter == 3) {
                 break;
             }
         }
         $this->responseNews($items);
     } else {
         $this->responseText("不好意思~没有找到您想要的东东~请换个关键字再试试?");
     }
     wp_reset_postdata();
 }
Example #15
0
function slickc_load_images($attributes)
{
    $args = array('post_type' => 'slickc', 'posts_per_page' => '-1', 'orderby' => $attributes['orderby'], 'order' => $attributes['order']);
    if (!empty($attributes['category'])) {
        $args['carousel_category'] = $attributes['category'];
    }
    if (!empty($attributes['id'])) {
        $args['p'] = $attributes['id'];
    }
    $loop = new WP_Query($args);
    $images = array();
    $output = '';
    while ($loop->have_posts()) {
        $loop->the_post();
        $image = get_the_post_thumbnail(get_the_ID(), 'full');
        if (!empty($image)) {
            $post_id = get_the_ID();
            $title = get_the_title();
            $content = get_the_excerpt();
            $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
            $image_src = $image_src[0];
            $url = get_post_meta(get_the_ID(), 'slickc_image_url');
            $url_openblank = get_post_meta(get_the_ID(), 'slickc_image_url_openblank');
            $images[] = array('post_id' => $post_id, 'title' => $title, 'content' => $content, 'image' => $image, 'img_src' => $image_src, 'url' => esc_url($url[0]), 'open_blank' => $url_openblank[0]);
        }
    }
    return $images;
}
 public function register_shortcode()
 {
     $loop = new WP_Query(array('post_type' => 'selcont_lecture_type', 'orderby' => 'title'));
     if ($loop->have_posts()) {
         $output = '<div class="lectures-list">';
         while ($loop->have_posts()) {
             $loop->the_post();
             $meta = get_post_meta(get_the_id(), '');
             $output .= '
                     <h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>
                     <div>
                     <strong>' . $meta['instructor_name_meta_box'][0] . '</strong>
                     <br/>
                     ' . get_the_excerpt() . '
                     </div>
                     <hr/>
                     <br/><br/>
             ';
         }
         $output .= '</div>';
     } else {
         $output = 'No Lectures Found.';
     }
     return $output;
 }
Example #17
0
function wpb_latest_sticky()
{
    /* Get all sticky posts */
    $sticky = get_option('sticky_posts');
    /* Sort the stickies with the newest ones at the top */
    rsort($sticky);
    /* Get the 5 newest stickies (change 5 for a different number) */
    $sticky = array_slice($sticky, 0, 1);
    /* Query sticky posts */
    $the_query = new WP_Query(array('post__in' => $sticky, 'ignore_sticky_posts' => 1));
    // The Loop
    $arr = array();
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $arr['permlink'] = get_permalink("", "", false);
            $arr['title'] = get_the_title("", "", false);
            $arr['excerpt'] = get_the_excerpt("", "", false);
            $arr['img_url'] = get_the_post_thumbnail_url();
        }
    } else {
        // no posts found
        $arr['excerpt'] = $arr['title'] = $arr['permlink'] = $arr["img_url"] = "404 not found any featured post ! :( ";
    }
    /* Restore original Post Data */
    wp_reset_postdata();
    return $arr;
}
function load_dummy()
{
    wp_enqueue_style('dummy-style', get_stylesheet_uri());
    wp_enqueue_script('dummy-js', get_template_directory_uri() . '/js/dummy.js');
    $slide_data = array();
    $the_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 6));
    while ($the_query->have_posts()) {
        $the_query->the_post();
        $has_thumb = false;
        $thumb_url;
        if (has_post_thumbnail()) {
            $has_thumb = true;
            $thumb_url = wp_get_attachment_url(get_post_thumbnail_id());
        } else {
            $thumb_url = null;
        }
        $link = esc_url(get_permalink());
        $title = get_the_title();
        $excerpt = get_the_excerpt();
        array_push($slide_data, array('hasThumb' => $has_thumb, 'thumbUrl' => $thumb_url, 'link' => $link, 'title' => $title, 'excerpt' => $excerpt));
    }
    $popup_data = array('enable' => get_option('show_popup'), 'imageUrl' => esc_url(get_theme_mod('popup_image')));
    wp_localize_script('dummy-js', 'slideData', $slide_data);
    wp_localize_script('dummy-js', 'popupData', $popup_data);
}
Example #19
0
/**
 * Helper function to grab and display thumbnail from specified post
 * @since 1.4.0
 */
function ar2_get_thumbnail($size = 'thumbnail', $id = NULL, $attr = array())
{
    global $post, $ar2_image_sizes;
    if ($post) {
        $id = $post->ID;
    }
    if (!key_exists('alt', $attr)) {
        $attr['alt'] = esc_attr(get_the_excerpt());
    }
    if (!key_exists('title', $attr)) {
        $attr['title'] = esc_attr(get_the_title());
    }
    if (has_post_thumbnail($id)) {
        return get_the_post_thumbnail($id, $size, $attr);
    } else {
        // Could it be an attachment?
        if ($post->post_type == 'attachment') {
            return wp_get_attachment_image($id, $size, false, $attr);
        }
        // Use first thumbnail if auto thumbs is enabled.
        if (ar2_get_theme_option('auto_thumbs')) {
            $img_id = ar2_get_first_post_image_id();
            if ($img_id) {
                return wp_get_attachment_image($img_id, $size, false, $attr);
            }
        }
    }
    // Return empty thumbnail if all else fails.
    return '<img src="' . get_template_directory_uri() . '/images/empty_thumbnail.gif" alt="' . $attr['alt'] . '" title="' . $attr['title'] . '" />';
}
 function widget($args, $instance)
 {
     extract($args);
     /* User-selected settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $category = $instance['category'];
     $show_count = $instance['show_count'];
     $show_date = $instance['show_date'] ? true : false;
     $show_thumb = $instance['show_thumb'] ? true : false;
     $show_excerpt = $instance['show_excerpt'] ? true : false;
     $excerpt_length = $instance['excerpt_length'];
     $show_title = $instance['hide_title'] ? false : true;
     /* Before widget (defined by themes). */
     echo $before_widget;
     /* Title of widget (before and after defined by themes). */
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="wpzoom-feature-posts">';
     $query_opts = apply_filters('wpzoom_query', array('posts_per_page' => $show_count, 'post_type' => 'post'));
     if ($category) {
         $query_opts['cat'] = $category;
     }
     query_posts($query_opts);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             echo '<li>';
             if ($show_thumb) {
                 $custom_field = option::get('cf_use') == 'on' ? get_post_meta($post->ID, option::get('cf_photo'), true) : '';
                 $args = array('size' => 'recent-widget', 'width' => $instance['thumb_width'], 'height' => $instance['thumb_height']);
                 if ($custom_field) {
                     $args['meta_key'] = option::get('cf_photo');
                 }
                 get_the_image($args);
             }
             if ($show_title) {
                 echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             }
             if ($show_date) {
                 echo '<small>' . get_the_date() . '</small>';
             }
             if ($show_excerpt) {
                 $the_excerpt = get_the_excerpt();
                 // cut to character limit
                 $the_excerpt = substr($the_excerpt, 0, $excerpt_length);
                 // cut to last space
                 $the_excerpt = substr($the_excerpt, 0, strrpos($the_excerpt, ' '));
                 echo '<span class="post-excerpt">' . $the_excerpt . '</span>';
             }
             echo '<div class="clear"></div></li>';
         }
     } else {
     }
     //Reset query_posts
     wp_reset_query();
     echo '</ul><div class="clear"></div>';
     /* After widget (defined by themes). */
     echo $after_widget;
 }
Example #21
0
function get_tour_info()
{
    $tourinfo = array();
    $tour_ID = get_the_ID();
    $tour_title = get_the_title();
    $tour_feat_image_url = get_no_img_url();
    if (has_post_thumbnail()) {
        $tour_feat_image_url = wp_get_attachment_url(get_post_thumbnail_id());
    }
    $tour_excerpt = get_the_excerpt();
    $tour_post_link = get_permalink($tour_ID);
    $tour_departure = get_location_ID(get_post_meta($tour_ID, 'tour_departure', true));
    $tour_arrival = get_location_ID(get_post_meta($tour_ID, 'tour_arrival', true));
    $tour_price = get_post_meta($tour_ID, 'tour_price', true);
    $tour_price_discount = get_post_meta($tour_ID, 'tour_price_discount', true);
    $tour_start = get_post_meta($tour_ID, 'tour_start', true);
    $tour_end = get_post_meta($tour_ID, 'tour_end', true);
    $tour_days = get_post_meta($tour_ID, 'tour_days', true);
    $tourinfo['tour_ID'] = $tour_ID;
    $tourinfo['tour_title'] = $tour_title;
    $tourinfo['tour_feat_image_url'] = $tour_feat_image_url;
    $tourinfo['tour_excerpt'] = $tour_excerpt;
    $tourinfo['tour_post_link'] = $tour_post_link;
    $tourinfo['tour_departure'] = $tour_departure;
    $tourinfo['tour_arrival'] = $tour_arrival;
    $tourinfo['tour_price'] = $tour_price;
    $tourinfo['tour_price_discount'] = $tour_price_discount;
    $tourinfo['tour_start'] = $tour_start;
    $tourinfo['tour_end'] = $tour_end;
    $tourinfo['tour_days'] = $tour_days;
    return $tourinfo;
}
Example #22
0
 /**
  *
  */
 function widget($args, $instance)
 {
     global $wpdb, $shortname, $irish_framework_params;
     $prefix = MISS_PREFIX;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', MISS_TEXTDOMAIN) : $instance['title'], $instance, $this->id_base);
     $tagline = apply_filters('widget_tagline', empty($instance['tagline']) ? '' : '<h6>' . $instance['tagline'] . '</h6>', $instance, $this->id_base);
     if (!($number = (int) $instance['number'])) {
         $number = 3;
     } else {
         if ($number < 1) {
             $number = 1;
         } else {
             if ($number > 15) {
                 $number = 15;
             }
         }
     }
     $out = $before_widget;
     $out .= $before_title . $title . $after_title . $tagline;
     $disable_thumb = $instance['disable_thumb'] ? '1' : '0';
     $show_rating = isset($instance['show_rating']) ? '1' : '0';
     $recent_query = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'category__not_in' => array(miss_exclude_category_string($minus = false)), 'ignore_sticky_posts' => 1));
     if ($recent_query->have_posts()) {
         $out .= '<ul class="post_list small_post_list">';
         while ($recent_query->have_posts()) {
             $recent_query->the_post();
             $out .= '<li class="post_list_module">';
             /*				
             					$out .= miss_get_post_image( $filter_args );
             				$get_year = get_the_time( 'Y', get_the_ID() );
             				$get_month = get_the_time( 'm', get_the_ID() );
              else {
             					$out .= '<div class="month pull-left">';
             					$out .= '<span class="day">';
             					$out .= get_the_date('d');
             					$out .= '</span>';
             					$out .= get_the_date('M');
             					$out .= '</div>';
             				}
             */
             if (!$disable_thumb) {
                 $widget_thumb_img = $irish_framework_params->layout['big_sidebar_images']['small_post_list'];
                 $out .= miss_get_post_image(array('width' => $widget_thumb_img[0], 'height' => $widget_thumb_img[1], 'img_class' => 'image', 'preload' => false, 'placeholder' => true, 'echo' => false, 'wp_resize' => miss_get_setting('image_resize_type') == 'wordpress' ? true : false));
             }
             $out .= '<p class="post_title">';
             $out .= '<a rel="bookmark" href="' . esc_url(get_permalink()) . '" title="' . esc_attr(get_the_title()) . '">' . get_the_title() . '</a>';
             $out .= '</p>';
             $out .= '<div class="post_excerpt">';
             $out .= miss_excerpt(get_the_excerpt(), apply_filters('miss_home_spotlight_excerpt', 60), apply_filters('miss_excerpt', THEME_ELLIPSIS));
             $out .= '</div>';
             $out .= '<div class="clearboth"></div>';
             $out .= '</li>';
         }
         $out .= '</ul>';
     }
     $out .= $after_widget;
     wp_reset_postdata();
     echo $out;
 }
 function bl_posttype_shortcodes_showposts($params = array())
 {
     // Pulls the paramater values passed from the shortcode options
     extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
     // Builds the query based on the available params
     $query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
     // Looks for the presence of any qualifying posts inside the defined loop
     if ($query->have_posts()) {
         // We open the post container only where specified posts are available
         $shortcodeOutput = '<div>';
         while ($query->have_posts()) {
             $query->the_post();
             // Wraps each qualifying post for output in an <article> tag with Schema data.
             $shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
             $shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
             $shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
             $shortcodeOutput .= '</a>';
             $shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
             $shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
             $shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
             $shortcodeOutput .= '<article>';
         }
         // Closes off the parent container
         $shortcodeOutput .= '</div>';
     }
     // Resets the wordpress loop
     wp_reset_postdata();
     // Returns the concatenated shortcodeOutput to the page
     return $shortcodeOutput;
 }
Example #24
0
function hsinsider_get_lead_art($post = null)
{
    if (empty($post)) {
        global $post;
    }
    if (has_post_thumbnail()) {
        $featured_id = get_post_thumbnail_id($post->ID);
        $the_query = wp_cache_get($featured_id . '_attachment');
        if ($the_query == false) {
            /**
             * Query for the Featured Image Caption
             */
            $args = array('p' => $featured_id, 'post_type' => 'attachment');
            $the_query = new WP_Query($args);
            // Set the cache to expire the data after 300 seconds
            wp_cache_set($featured_id . '_attachment', $the_query, '', 300);
        }
        if ($the_query->have_posts()) {
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $featured_caption = get_the_excerpt();
            }
        }
        wp_reset_postdata();
        $featured_url = wp_get_attachment_url($featured_id);
        $featured_html = '<figure><img src="' . esc_url($featured_url) . '" class="attachment-post-thumbnail size-post-thumbnail wp-post-image img-responsive"/><figcaption class="wp-caption-text">' . esc_html($featured_caption) . '</figcaption></figure>';
        echo $featured_html;
    }
}
 /**
  * Get post excerpt
  *
  * @since  1.0.0
  * @param array  $args array of arguments.
  * @param [type] $type - post, term.
  * @param int    $id ID of post.
  * @return string
  */
 public function get_content($args = array(), $type = 'post', $id = 0)
 {
     $object = call_user_func(array($this, 'get_' . $type . '_object'), $id);
     if ('post' === $type && empty($object->ID) || 'term' === $type && empty($object->term_id)) {
         return '';
     }
     $default_args = array('visible' => true, 'content_type' => 'post_content', 'length' => -1, 'trimmed_type' => 'word', 'ending' => '&hellip;', 'html' => '<p %1$s>%2$s</p>', 'class' => '', 'echo' => false);
     $args = wp_parse_args($args, $default_args);
     $html = '';
     if (filter_var($args['visible'], FILTER_VALIDATE_BOOLEAN)) {
         if ('term' === $type) {
             $text = $object->description;
         } elseif ('post_content' === $args['content_type'] || 'post_excerpt' === $args['content_type'] && empty($object->{$args}['content_type'])) {
             $text = get_the_content();
         } else {
             $text = get_the_excerpt();
         }
         $text = $this->cut_text($text, $args['length'], $args['trimmed_type'], $args['ending'], true);
         if ($text) {
             $html_class = $args['class'] ? 'class="' . $args['class'] . '"' : '';
             $html = sprintf($args['html'], $html_class, $text);
         }
     }
     $html = apply_filters('the_content', $html);
     return $this->output_method($html, $args['echo']);
 }
function excerpt($car = 80, $post_id=null){
  $disc = get_the_excerpt($post_id);
  if(strlen($disc) > $car){
    $disc = substr($disc, 0, $car).'...';
  }
  echo $disc;
}
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
     $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
     if ($group = $instance['group']) {
         $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
     }
     $terms = get_posts($termargs);
     if ($terms && count($terms)) {
         echo '<ul class="wpglossary widget-list">';
         foreach ($terms as $term) {
             setup_postdata($term);
             $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
             $desc = '';
             $display = $instance['display'];
             if ($display && $display != 'title') {
                 $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
                 $desc = '<br>' . $desc;
             }
             echo '<li>' . $title . $desc . '</li>';
         }
         wp_reset_postdata();
         echo '</ul>';
     } else {
         echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
     }
     echo $after_widget;
 }
 public function getColumn($column)
 {
     global $post;
     switch ($column) {
         case 'category':
             echo get_the_term_list($post->ID, $post->post_type . '_category', '', ', ', '');
             break;
         case 'thumbnail':
             if ($post->Thumbnail) {
                 echo GummRegistry::get('Helper', 'Media')->display($post->Thumbnail->guid, array('width' => 70, 'height' => 70));
             }
             break;
         case 'gallery_album':
             echo get_the_term_list($post->ID, 'gallery_album', '', ', ', '');
             break;
         case 'portfolio_cats':
             echo get_the_term_list($post->ID, 'portfolio_cat', '', ', ', '');
             break;
         case $post->post_type . '_author':
             $author = isset($post->PostMeta['author']) ? $post->PostMeta['author'] : '';
             $organisation = isset($post->PostMeta['organisation']) ? $post->PostMeta['organisation'] : '';
             echo '<span class="testimonial_author_name">' . $author . '</span>';
             if ($organisation) {
                 echo ' - <span class="testimonial_author_occupation">' . $organisation . '</span>';
             }
             break;
         case $post->post_type . '_excerpt':
             edit_post_link(GummRegistry::get('Helper', 'Text')->truncate(get_the_excerpt(), 100, array('exact' => false)));
             break;
     }
 }
Example #29
0
function ipin_head()
{
    //Opengraph
    if (is_single()) {
        global $post;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . preg_replace('/[\\n\\r]/', ' ', mb_strimwidth(the_title_attribute('echo=0'), 0, 255, ' ...')) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
        if ($post->post_content == '') {
            $meta_categories = get_the_category($post->ID);
            foreach ($meta_categories as $meta_category) {
                $meta_category_name = $meta_category->name;
            }
            if (ipin_get_post_board()) {
                $meta_board_name = ipin_get_post_board()->name;
            } else {
                $meta_board_name = __('Untitled', ipin);
            }
            $output .= '<meta property="og:description" content="' . esc_attr(__('Pinned onto', 'ipin') . ' ' . $meta_board_name . ' ' . __('Board in', 'ipin') . ' ' . $meta_category_name . ' ' . __('Category', 'ipin')) . '" />' . "\n";
        } else {
            $output .= '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
        }
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        if (get_option('wsl_settings_Facebook_app_id')) {
            $output .= '<meta property="fb:app_id" content="' . get_option('wsl_settings_Facebook_app_id') . '" />' . "\n";
        }
        echo $output;
    }
    if (is_tax('board')) {
        global $post, $wp_query, $wp_taxonomies;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . esc_attr($wp_query->queried_object->name) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/' . $wp_taxonomies["board"]->rewrite['slug'] . '/' . sanitize_title($wp_query->queried_object->name, '_') . '/') . $wp_query->queried_object->term_id . '/" />' . "\n";
        $output .= '<meta property="og:description" content="" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
    if (is_author()) {
        global $wp_query, $wp_rewrite;
        $user_info = get_user_by('id', $wp_query->query_vars['author']);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . esc_attr($user_info->display_name) . ' (' . $user_info->user_nicename . ')" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/') . $wp_rewrite->author_base . '/' . $user_info->user_nicename . '/" />' . "\n";
        $output .= '<meta property="og:description" content="' . esc_attr($user_info->description) . '" />' . "\n";
        $avatar_id = get_user_meta($user_info->ID, 'ipin_user_avatar', true);
        if ($avatar_id != '' && $avatar_id != 'deleted') {
            $user_avatar = wp_get_attachment_image_src($avatar_id, 'full');
            $output .= '<meta property="og:image" content="' . $user_avatar[0] . '" />' . "\n";
        }
        echo $output;
    }
}
Example #30
0
/**
 * Display the testimonial content.
 *
 * @param null $length
 *
 * @since 1.24.0
 * @since 2.4.0 Run content through selected filters only, instead
 *              of all filters added to the_excerpt() or the_content().
 *
 * @todo Use native auto-excerpt and trim_words instead.
 */
function wpmtst_the_content($length = null)
{
    if ($length) {
        $excerpt = false;
    } else {
        $excerpt = WPMST()->atts('excerpt');
        $length = WPMST()->atts('length');
    }
    // In View settings, {excerpt} overrides {length} overrides {full content}.
    if ($excerpt) {
        $content = get_the_excerpt();
        $content = apply_filters('the_excerpt', $content);
    } else {
        if ($length) {
            $content = wpmtst_get_field('truncated', array('char_limit' => $length));
        } else {
            $content = get_the_content();
        }
        // Applying all content filters breaks POS NextGEN Gallery.
        // So need to find a way to select which additional filters, if any, to apply.
        // For instance, All In One Rich Snippets.
        //$content = apply_filters( 'the_content', $content );
        $content = wptexturize($content);
        $content = convert_smilies($content);
        $content = wpautop($content);
        $content = shortcode_unautop($content);
        $content = do_shortcode($content);
    }
    echo $content;
}