示例#1
0
function nv_recent_posts_shortcode($atts)
{
    extract(shortcode_atts(array('limit' => '', 'categories' => '', 'metadata' => '', 'show_date' => '', 'order' => 'date', 'orderby' => '', 'offset' => '', 'image_width' => '', 'image_height' => '', 'image_align' => '', 'image_effect' => '', 'content_type' => '', 'content' => 'textimage', 'excerpt' => ''), $atts));
    if (!empty($content_type)) {
        $content = $content_type;
    }
    ob_start();
    $q = new WP_Query('offset=' . $offset . '&orderby=' . $order . '&order=' . $orderby . '&category_name=' . $categories . '&posts_per_page=' . $limit);
    if (esc_attr($excerpt)) {
        $recent_excerpt = esc_attr($excerpt);
    } else {
        $recent_excerpt = "15";
    }
    ?>
		
		<ul class="nv-recent-posts">
		
		<?php 
    while ($q->have_posts()) {
        $q->the_post();
        $post_id = get_the_ID();
        $NV_previewimgurl = get_post_meta($post_id, '_cmb_previewimgurl', true) != '' ? get_post_meta($post_id, '_cmb_previewimgurl', true) : '';
        $disablegallink = get_post_meta($post_id, '_cmb_disablegallink', true) != '' ? get_post_meta($post_id, '_cmb_disablegallink', true) : '';
        $disablereadmore = get_post_meta($post_id, '_cmb_disablereadmore', true) != '' ? get_post_meta($post_id, '_cmb_disablereadmore', true) : '';
        $link_url = get_post_meta($post_id, '_cmb_galexturl', true) != '' ? get_post_meta($post_id, '_cmb_galexturl', true) : get_permalink();
        // check what image to use, custom, featured, image within post.
        if (empty($NV_previewimgurl)) {
            $post_image_id = get_post_thumbnail_id(get_the_ID());
            if ($post_image_id) {
                $thumbnail = wp_get_attachment_image_src($post_image_id, 'medium', false);
                $NV_previewimgurl = $thumbnail[0];
                $NV_previewimgurl = parse_url($NV_previewimgurl, PHP_URL_PATH);
                // make relative Image URL
            } else {
                $NV_previewimgurl = catch_image();
                // Check for images within post
            }
        }
        $image = $NV_previewimgurl;
        if ($image && ($content == 'textimage' || $content == 'titleimage' || $content == 'image')) {
            // check if link is disabled
            $image_link = $disablegallink != 'yes' ? $image_link = 'link="' . $link_url . '"' : '';
            $image = '[imageeffect type="' . $image_effect . '" align="' . $image_align . '" width="' . $image_width . '" height="' . $image_height . '"  alt="' . get_the_title() . '" url="' . $image . '" ' . $image_link . ' ]';
        } else {
            $image = '';
        }
        ?>
		
			<li>
				<?php 
        echo do_shortcode($image);
        if ($content != 'image') {
            ?>
					<div>
					<h4>
                    	<?php 
            if ($disablegallink == 'yes') {
                the_title();
            } else {
                ?>
							<a href="<?php 
                echo $link_url;
                ?>
"><?php 
                the_title();
                ?>
</a>
						<?php 
            }
            ?>
                    </h4>    
					<?php 
            if ($show_date == 'yes') {
                ?>
						<small><?php 
                echo get_the_date();
                ?>
</small>
					<?php 
            }
            if ($content != 'titleimage' && $content != 'title') {
                the_excerpt();
            }
            ?>
					</div>
				<?php 
        }
        if ($metadata == 'yes') {
            ?>
					<div class="recent-metadata">
						<?php 
            echo __('by', 'themeva');
            ?>
 <a href="<?php 
            echo get_author_posts_url(get_the_author_meta('ID'));
            ?>
"><?php 
            echo get_the_author_meta('first_name') . " " . get_the_author_meta('last_name');
            ?>
</a> <span class="subbreak">/</span> 
						<?php 
            echo __('in', 'themeva') . ' ';
            the_category(', ');
            ?>
 <span class="subbreak">/</span> 
						<?php 
            comments_popup_link(__('No Comments', 'themeva') . ' ', '1 ' . __('Comment', 'themeva') . ' ', '% ' . __('Comments', 'themeva'));
            ?>
						<div class="hozbreak clearfix">&nbsp;</div>
					</div>
				<?php 
        }
        ?>
                
				<div class="clear"></div>
			</li>
		<?php 
    }
    wp_reset_query();
    ?>
		
		</ul>
		
		
	<?php 
    $output_string = '';
    $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;
}
示例#2
0
    ?>
" />
</a>
<?php 
} else {
    ?>
<a href="<?php 
    the_permalink();
    ?>
" rel="bookmark" title="<?php 
    the_title();
    ?>
">
<?php 
    if (has_post_thumbnail()) {
        the_post_thumbnail('thumbnail', array('alt' => get_the_title()));
    } else {
        ?>
<img class="home-thumb" src="<?php 
        echo catch_image();
        ?>
" alt="<?php 
        the_title();
        ?>
" />
<?php 
    }
    ?>
</a>
<?php 
}
示例#3
0
} elseif ($NV_authorname == 'yes') {
    $NV_authorname = 'enable';
} else {
    $NV_authorname = 'disable';
}
/* ------------------------------------
	:: Display Image
	------------------------------------ */
// check what image to use, custom, featured, image within post.
if (empty($NV_previewimgurl)) {
    $post_image_id = get_post_thumbnail_id(get_the_ID());
    if (!empty($post_image_id)) {
        $thumbnail = wp_get_attachment_image_src($post_image_id, 'large', false);
        $NV_previewimgurl = $thumbnail[0];
    } else {
        $NV_previewimgurl = catch_image();
        // Check for images within post
    }
}
/* ------------------------------------
	:: Display Postmeta Data
	------------------------------------ */
global $NV_postlayout;
$NV_postmetaalign = $NV_postlayout == 'grid' ? 'post_title' : of_get_option("postmetaalign");
// Display Postmeta Data
$NV_arhpostpostmeta = of_get_option('arhpostpostmeta');
// get postmeta data configuration
if (is_single() && ($NV_arhpostpostmeta == 'post_only' || $NV_arhpostpostmeta == '')) {
    $NV_arhpostpostmeta = 'display';
} elseif (!is_single() && ($NV_arhpostpostmeta == '' || $NV_arhpostpostmeta == 'archive_only')) {
    $NV_arhpostpostmeta = 'display';
         $NV_productprice = $product->get_price_html();
         // Product Price
     }
     if (class_exists('WPSC_Query')) {
         $NV_previewimgurl = wpsc_the_product_image();
         // Product Image
         $NV_productprice = wpsc_the_product_price();
         // Product Price
     }
     $NV_previewimgurl = parse_url($NV_previewimgurl, PHP_URL_PATH);
     // make relative Image URL
 } else {
     $NV_previewimgurl = get_post_meta($post->ID, '_cmb_previewimgurl', true);
     // Preview Image URL
 }
 $image = catch_image();
 // Check for images within post
 // check what image to use, custom, featured, image within post.
 if (empty($NV_previewimgurl)) {
     $post_image_id = get_post_thumbnail_id($post->ID);
     if (!empty($post_image_id)) {
         $thumbnail = wp_get_attachment_image_src($post_image_id, false);
         $NV_previewimgurl = $thumbnail[0];
     } elseif (!empty($image)) {
         $NV_previewimgurl = $image;
     }
 }
 $NV_movieurl = get_post_meta($post->ID, '_cmb_movieurl', true) != '' ? get_post_meta($post->ID, '_cmb_movieurl', true) : '';
 $NV_stagegallery = get_post_meta($post->ID, '_cmb_stagegallery', true) != '' ? get_post_meta($post->ID, '_cmb_stagegallery', true) : '';
 $NV_disablegallink = get_post_meta($post->ID, '_cmb_disablegallink', true) != '' ? get_post_meta($post->ID, '_cmb_disablegallink', true) : '';
 $NV_disablereadmore = get_post_meta($post->ID, '_cmb_disablereadmore', true) != '' ? get_post_meta($post->ID, '_cmb_disablereadmore', true) : '';
 public function widget($args, $instance)
 {
     // extract $args
     extract($args);
     // get options
     $shariff3UU = $GLOBALS["shariff3UU"];
     // container
     echo $before_widget;
     // print title of widget, if provided
     if (empty($instance['shariff-title'])) {
         $title = '';
     } else {
         apply_filters('shariff-title', $instance['shariff-title']);
         $title = $instance['shariff-title'];
     }
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     // print shorttag
     // keep original shorttag for further reference
     $original_shorttag = $instance['shariff-tag'];
     // if nothing is configured, use the global options from admin menu
     if ($instance['shariff-tag'] == '[shariff]') {
         $shorttag = buildShariffShorttag();
     } else {
         $shorttag = $instance['shariff-tag'];
     }
     // set url to current page to prevent sharing the first or last post on pages with multiple posts e.g. the blog page
     // ofc only when no manual url is provided in the shorttag
     $page_url = '';
     if (strpos($original_shorttag, ' url=') === false) {
         $wpurl = get_bloginfo('wpurl');
         $siteurl = get_bloginfo('url');
         // for "normal" installations
         $page_url = $wpurl . esc_url_raw($_SERVER['REQUEST_URI']);
         // kill ?view=mail etc. if pressed a second time
         $page_url = strtok($page_url, '?');
         // if wordpress is installed in a subdirectory, but links are mapped to the main domain
         if ($wpurl != $siteurl) {
             $subdir = str_replace($siteurl, '', $wpurl);
             $page_url = str_replace($subdir, '', $page_url);
         }
         $page_url = ' url="' . $page_url;
         $page_url .= '"';
     }
     // same for title
     $page_title = '';
     if (strpos($original_shorttag, 'title=') === false) {
         $wp_title = get_the_title();
         # for WP4.4
         // rtzTODO: use wp_get_document_title() with backward compatibility
         // prior wp_title( '', false );
         // wp_title for all pages that have it
         if (!empty($wp_title)) {
             $page_title = ltrim($wp_title);
         } else {
             $page_title = get_bloginfo('name');
         }
         $page_title = ' title="' . $page_title . '"';
     }
     // same for media
     $media = '';
     if (array_key_exists('services', $shariff3UU) && strstr($shariff3UU["services"], 'pinterest') && strpos($original_shorttag, 'media=') === false) {
         $feat_image = wp_get_attachment_url(get_post_thumbnail_id());
         if (!empty($feat_image)) {
             $media = ' media="' . esc_html($feat_image) . '"';
         } else {
             $first_image = catch_image();
             if (!empty($first_image)) {
                 $media = ' media="' . esc_html($first_image) . '"';
             } else {
                 if (isset($shariff3UU["default_pinterest"])) {
                     $media = ' media="' . $shariff3UU["default_pinterest"] . '"';
                 } else {
                     $media = ' media="' . plugins_url('/pictos/defaultHint.jpg', __FILE__) . '"';
                 }
             }
         }
     }
     // build shorttag and add url, title and media if necessary
     $shorttag = substr($shorttag, 0, -1) . $page_title . $page_url . $media . ']';
     // replace mailform with mailto if on blog page to avoid broken button
     if (!is_singular()) {
         $shorttag = str_replace('mailform', 'mailto', $shorttag);
     }
     // process the shortcode
     // but only if it is not password protected |or| "disable on password protected posts" is not set in the options
     if (post_password_required(get_the_ID()) != '1' || isset($shariff3UU["disable_on_protected"]) && $shariff3UU["disable_on_protected"] != '1') {
         echo do_shortcode($shorttag);
     }
     // close Container
     echo $after_widget;
 }