WordPress.org

Plugin Directory

Changeset 859825


Ignore:
Timestamp:
02/18/14 01:43:42 (4 years ago)
Author:
ArshamMirshah
Message:

1.4 do_shortcode, read more, and fixed false strings

Location:
add-posts-to-pages/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • add-posts-to-pages/trunk/index.php

    r848049 r859825  
    44Plugin URI: http://www.webmechanix.com/wordpress-plugins/add-posts-pages/ 
    55Description: Easily add posts to pages with this super lightweight plugin. Just select the number of posts to show & the category to pull them from and voila, you've added a set of posts anywhere on any page. 
    6 Version: 1.3.1 
     6Version: 1.4 
    77Author: Arsham Mirshah 
    88Author URI: http://www.webmechanix.com/ 
     
    2929        'h' => '2', 
    3030        'img' => false, 
    31         'size' => 64 
     31        'size' => 64, 
     32        'readmore' => false 
    3233    ), $atts ) ); 
    3334 
     
    3536/***************************************************Config*********************************************************/ 
    3637 
     38//setting full/img to false if it comes through as a string 
     39if($full == 'false'){ 
     40    $full = false; 
     41} 
     42if($img == 'false'){ 
     43    $img = false; 
     44} 
     45if($readmore == 'false'){ 
     46    $readmore = false; 
     47} 
     48 
     49//setting header size 
    3750$h = 'h'.$h; 
    3851 
    3952//querying posts on input filter parameters 
    4053$posts = get_posts('category_name='.$category.'&posts_per_page='.$show.'&tag='.$tag); 
    41  
     54wp_reset_postdata(); 
    4255 
    4356/***************************************************Out***********************************************************/ 
     
    7083    } 
    7184     
    72     if($full){ 
    73     $content = $post->post_content; 
    74     $content = wpautop($content); 
    75     $content = str_replace(']]>', ']]>', $content); 
     85    if($full || $readmore){ 
    7686 
    77     //output full post 
    78     $out .= '<div class="add_posts_content" style="clear:both;">'; 
    79     $out .= '<'.$h.' class="title" style="clear: none;"><a href="' . $permalink . '">' . $title . '</a></'.$h.'>'; 
    80     $out .= '<div class="post-content" style="clear:both";>'.$content.'</div>'; 
    81     $out .= '<hr style="margin:10px 0">'; 
    82     $out .= '</div>'; 
     87        //grab all the content of this post 
     88        $content = $post->post_content; 
     89 
     90        //if we're reading more 
     91        if($readmore){ 
     92            //change the content to only the content before the more break point 
     93            $more = strpos($content, "<!--more-->"); 
     94            if($more){ 
     95                $content = substr($content, 0, $more); 
     96            } 
     97        } 
     98 
     99        //format content as needed 
     100        $content = wpautop(do_shortcode($content)); 
     101        $content = str_replace(']]>', ']]&gt;', $content); 
     102     
     103        //output full post 
     104        $out .= '<div class="add_posts_content" style="clear:both;">'; 
     105        $out .= '<'.$h.' class="title" style="clear: none;"><a href="' . $permalink . '">' . $title . '</a></'.$h.'>'; 
     106        $out .= '<div class="post-content" style="clear:both";>'.$content; 
     107         
     108        //formatting for read more 
     109        if($readmore){ 
     110            $out .= ' <a href="' . $permalink . '">' . $readmore . '</a>'; 
     111        } 
     112         
     113        //close the post with a nice <hr> 
     114        $out .= '</div>';            
     115        $out .= '<hr style="margin:10px 0">'; 
     116        $out .= '</div>'; 
    83117 
    84118    //If NOT full, output either the <li> or <h#> tags & the title of the post 
  • add-posts-to-pages/trunk/readme.txt

    r848049 r859825  
    7575== Changelog == 
    7676 
     77= 1.4 = 
     78* Fixed full=false issue where it would show full post if you specified full=false 
     79* Added do_shortcode to allow for full posts to render shortcodes that are in the post 
     80* Added ability to break content at "read more" point 
     81 
    7782= 1.3.1 = 
    7883* Fixed NextGen Gallery (and probably other plugin) conflict. 
     
    106111== Upgrade Notice == 
    107112 
     113= 1.4 = 
     114* Fixed full=false issue where it would show full post if you specified full=false 
     115* Added do_shortcode to allow for full posts to render shortcodes that are in the post 
     116* Added ability to break content at "read more" point 
     117 
    108118= 1.3 = 
    109119Changed from query_posts to get_posts --- This should fix some interference with other plugins! :) 
Note: See TracChangeset for help on using the changeset viewer.