WordPress.org

Plugin Directory

Changeset 1494938


Ignore:
Timestamp:
09/13/16 03:46:46 (13 months ago)
Author:
fernandobt
Message:

Version 0.70

Location:
list-category-posts
Files:
6 edited
6 copied

Legend:

Unmodified
Added
Removed
  • list-category-posts/tags/0.70/include/lcp-catlistdisplayer.php

    r1296434 r1494938  
    235235   */ 
    236236  private function lcp_build_post($single, $tag){ 
    237  
    238237    $class =''; 
    239238    if ( is_object($this->parent) && is_object($single) && $this->parent->ID == $single->ID ){ 
     
    396395    if(!empty($this->params['customfield_display'])){ 
    397396      $info = $this->catlist->get_custom_fields($this->params['customfield_display'], $single->ID); 
    398       if(empty($this->params['customfield_tag']) || $this->params['customfield_tag'] == null) 
     397      if(empty($this->params['customfield_tag']) || $this->params['customfield_tag'] == null){ 
    399398        $tag = 'div'; 
    400       if(empty($this->params['customfield_class']) || $this->params['customfield_class'] == null) 
     399      } else { 
     400        $tag = $this->params['customfield_tag']; 
     401      } 
     402 
     403      if(empty($this->params['customfield_class']) || $this->params['customfield_class'] == null){ 
    401404        $css_class = 'lcp_customfield'; 
     405      } else { 
     406        $css_class = $this->params['customfield_class']; 
     407      } 
     408 
    402409      $final_info = ''; 
    403410      if(!is_array($info)){ 
  • list-category-posts/tags/0.70/include/lcp-parameters.php

    r1261454 r1494938  
    66  private static $instance = null; 
    77  private $starting_with = null; 
     8  // $date_query tells us if we need to generate date_query args 
     9  private $date_query = false; 
    810  private $utils; 
    911  private $params; 
     
    5961      $args['author_name'] = $params['author_posts']; 
    6062    endif; 
     63 
     64    // Posts within given date range: 
     65    if ( $this->utils->lcp_not_empty('after') ) { 
     66      $this->after = $params['after']; 
     67      $date_query = true; 
     68    } 
     69 
     70    if ( $this->utils->lcp_not_empty('after_year') ) { 
     71      $this->after_year = $params['after_year']; 
     72      $date_query = true; 
     73    } 
     74 
     75    if ( $this->utils->lcp_not_empty('after_month') ) { 
     76      // after_month should be in the range [1, 12] 
     77      if ($params['after_month'] >= 1 && $params['after_month'] <= 12) { 
     78        $this->after_month = $params['after_month']; 
     79        $date_query = true; 
     80      } 
     81    } 
     82 
     83    if ( $this->utils->lcp_not_empty('after_day') ) { 
     84      // after_day should be in the range [1, 31] 
     85      if ($params['after_day'] >= 1 && $params['after_day'] <= 31) { 
     86        $this->after_day = $params['after_day']; 
     87        $date_query = true; 
     88      } 
     89    } 
     90 
     91    if ( $this->utils->lcp_not_empty('before') ) { 
     92      $this->before = $params['before']; 
     93      $date_query = true; 
     94    } 
     95 
     96    if ( $this->utils->lcp_not_empty('before_year') ) { 
     97      $this->before_year = $params['before_year']; 
     98      $date_query = true; 
     99    } 
     100 
     101    if ( $this->utils->lcp_not_empty('before_month') ) { 
     102      // before_month should be in the range [1, 12] 
     103      if ($params['before_month'] >= 1 && $params['before_month'] <= 12) { 
     104        $this->before_month = $params['before_month']; 
     105        $date_query = true; 
     106      } 
     107    } 
     108 
     109    if ( $this->utils->lcp_not_empty('before_day') ) { 
     110      // before_day should be in the range [1, 31] 
     111      if ($params['before_day'] >= 1 && $params['before_day'] <= 31) { 
     112        $this->before_day = $params['before_day']; 
     113        $date_query = true; 
     114      } 
     115    } 
     116 
     117    // Only generate date_query args if a before/after paramater was found 
     118    if (isset($date_query) ){ 
     119      $args['date_query'] = $this->create_date_query_args(); 
     120    } 
    61121 
    62122    /* 
     
    193253    return $post->ID; 
    194254  } 
     255 
     256  /* 
     257   * Create date_query args according to https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters 
     258   * There's probably a better way to check if values exist. 
     259   * Code should be cleaned up (this is first attempt at a solution). 
     260   */ 
     261  private function create_date_query_args() { 
     262    $date_query = array(); 
     263 
     264    // Keep track of parameters that are set to build the argument array. 
     265    $params_set = array( 
     266      'after' => false, 
     267      'after_year' => false, 
     268      'after_month' => false, 
     269      'after_day' => false, 
     270      'before' => false, 
     271      'before_year' => false, 
     272      'before_month' => false, 
     273      'before_day' => false, 
     274    ); 
     275 
     276    // Booleans to track which subarrays should be created. 
     277    $after = false; 
     278    $before = false; 
     279 
     280    /* 
     281     *  Check which paramaters are set and find out which subarrays 
     282     *  should be created. 
     283     */ 
     284    if ( isset($this->after) ) { 
     285      $params_set['after'] = true; 
     286      $after = true; 
     287    } 
     288 
     289    if ( isset($this->after_year) ) { 
     290      $params_set['after_year'] = true; 
     291      $after = true; 
     292    } 
     293 
     294    if ( isset($this->after_month) ) { 
     295      $params_set['after_month'] = true; 
     296      $after = true; 
     297    } 
     298 
     299    if ( isset($this->after_day) ) { 
     300      $params_set['after_day'] = true; 
     301      $after = true; 
     302    } 
     303 
     304    if ( isset($this->before) ) { 
     305      $params_set['before'] = true; 
     306      $before = true; 
     307    } 
     308 
     309    if ( isset($this->before_year) ) { 
     310      $params_set['before_year'] = true; 
     311      $before = true; 
     312    } 
     313 
     314    if ( isset($this->before_month) ) { 
     315      $params_set['before_month'] = true; 
     316      $before = true; 
     317    } 
     318 
     319    if ( isset($this->before_day) ) { 
     320      $params_set['before_day'] = true; 
     321      $before = true; 
     322    } 
     323 
     324    /* 
     325     * Build the subarrays. 
     326     * The after parameter takes priority over after_* parameters. 
     327     * Simlarly, the before parameter takes priority over before_* parameters. 
     328     */ 
     329    if ($after) { 
     330      if ($params_set['after']) { 
     331        $date_query['after'] = $this->after; 
     332      } else { 
     333        if ( $params_set['after_year'] ) $date_query['after']['year'] = $this->after_year; 
     334        if ( $params_set['after_month'] ) $date_query['after']['month'] = $this->after_month; 
     335        if ( $params_set['after_day'] ) $date_query['after']['day'] = $this->after_day; 
     336      } 
     337    } 
     338 
     339    if ($before) { 
     340      if ($params_set['before']) { 
     341        $date_query['before'] = $this->before; 
     342      } else { 
     343        if ( $params_set['before_year'] ) $date_query['before']['year'] = $this->before_year; 
     344        if ( $params_set['before_month'] ) $date_query['before']['month'] = $this->before_month; 
     345        if ( $params_set['before_day'] ) $date_query['before']['day'] = $this->before_day; 
     346      } 
     347    } 
     348    return $date_query; 
     349  } 
    195350} 
  • list-category-posts/tags/0.70/list-category-posts.php

    r1447893 r1494938  
    44  Plugin URI: https://github.com/picandocodigo/List-Category-Posts 
    55  Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2]. 
    6   Version: 0.69 
     6  Version: 0.70 
    77  Author: Fernando Briano 
    88  Author URI: http://fernandobriano.com 
     
    133133                             'link_titles' => true, 
    134134                             'link_dates' => 'no', 
     135                             'after' => '', 
     136                             'after_year' => '', 
     137                             'after_month' => '', 
     138                             'after_day' => '', 
     139                             'before' => '', 
     140                             'before_year' => '', 
     141                             'before_month' => '', 
     142                             'before_day' => '', 
    135143                           ), $atts); 
    136144    if($atts['numberposts'] == ''){ 
  • list-category-posts/tags/0.70/readme.txt

    r1447893 r1494938  
    44Tags: list, categories, posts, cms 
    55Requires at least: 3.3 
    6 Tested up to: 4.5.2 
    7 Stable tag: 0.69 
     6Tested up to: 4.6.1 
     7Stable tag: 0.70 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    2525the content! A lot of parameters have been added to customize what to 
    2626display and how to show it. Check [the full 
    27 documentation](https://wordpress.org/plugins/list-category-posts/other_notes/) 
     27documentation](https://github.com/picandocodigo/List-Category-Posts/wiki) 
    2828to learn about the different ways to use it. 
    2929 
     
    3939parameter in your shortcode). 
    4040 
    41 **[Read the instructions](http://wordpress.org/extend/plugins/list-category-posts/other_notes/)** to learn which parameters are available and how to use them. 
     41**[Read the instructions](https://github.com/picandocodigo/List-Category-Posts/wiki)** to learn which parameters are available and how to use them. 
    4242 
    4343If you want to **List Categories** instead of posts you can use my other plugin **[List categories](http://wordpress.org/plugins/list-categories/)**. 
     
    4747**Customization** 
    4848 
    49 The different elements to display can be styled with CSS. you can define an HTML tag to wrap the element with, and a CSS class for this tag. Check [Other Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) for usage. 
     49The different elements to display can be styled with CSS. you can define an HTML tag to wrap the element with, and a CSS class for this tag. Check [the documentation](https://github.com/picandocodigo/List-Category-Posts/wiki) for usage. 
    5050 
    5151Great to use WordPress as a CMS, and create pages with several categories posts. 
     
    5959yet. You can use the shortcode for the most flexibility. 
    6060 
    61 Please, read the information on [Other 
    62 Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) 
     61Please, read the information on [the wiki](https://github.com/picandocodigo/List-Category-Posts/wiki) 
    6362and 
    6463[Changelog](http://wordpress.org/extend/plugins/list-category-posts/changelog/) 
     
    8685* Upload the `list-category-posts` directory to your wp-content/plugins/ directory. 
    8786* Login to your WordPress Admin menu, go to Plugins, and activate it. 
     87* Start using the '[catlist]` shortcode in your posts and/or pages. 
    8888* You can find the List Category Posts widget in the Appearence > Widgets section on your WordPress Dashboard. 
    89 * If you want to customize the way the plugin displays the information, check the section on Templates on this documentation. 
     89* If you want to customize the way the plugin displays the information, check [HTML & CSS Customization](https://github.com/picandocodigo/List-Category-Posts/wiki/HTML-&-CSS-Customization) or the [section on Templates](https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System) on the wiki. 
    9090 
    9191==Other notes== 
     92 
     93Since the documentation on how to use the plugin has passed wordpress.org's character limit, the text was cut. I've since started using [a wiki](https://github.com/picandocodigo/List-Category-Posts/wiki) for more comfortable reading and maintaining. Please check it out, suggestions are welcome on GitHub issues! 
    9294 
    9395==Instructions on how to use the plugin== 
     
    132134 
    133135* **monthnum** and **year** - List posts from a certain year or month. You can use these together or independently. Example: `[catlist year=2015]` will list posts from the year 2015. `[catlist monthnum=8]` will list posts published in August of every year. `[catlist year=2012 monthnum=12]` will list posts from December 2012. 
     136 
     137* **date ranges** - You can also use date ranges for listing posts. For example "list every post after March 14th, 2005". The parameters are: ```after, after_year, after_month, after_day, before, before_year, before_month,  before_day```. These parameters are used to specify data_query arguments (see: [the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)).   
     138 
     139     If you want to list all the posts before a given date, say `Jun 17th, 2007` you can use these two options:   
     140     `[catlist before_year=2007 before_month=06 before_day=17]`   
     141     Or you can use the `before` parameter with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):   
     142     `[catlist before='2007/06/17']`   
     143 
     144     The same works for posts after a given date, you can use:   
     145     `[catlist after_year=2007 after_month=06 after_day=17]`   
     146     Or just `after` with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):   
     147     `[catlist after='2007/06/17']`   
     148 
     149    `after` takes priority over `after_year`, `after_month`, and `after_day`.   
     150    `before` takes priority over `before_year`, `before_month`, and `before_day`.   
    134151 
    135152* **search** - List posts that match a search term. `[catlist search="The Cake is a lie"]` 
     
    161178* **custom fields** - To use custom fields, you must specify two values: customfield_name and customfield_value. Using this only show posts that contain a custom field with this name and value. Both parameters must be defined, or neither will work. 
    162179 
    163 ==PAGINATION== 
    164  
    165 To use pagination, you need to set the following parameters in the shortcode: 
    166  
    167 * **pagination** set it to yes. `[catlist pagination=yes]` 
    168  
    169 * **numberposts** - Posts per page are set with the `numberposts` 
    170     parameter. `[catlist pagination=yes numberposts=5]` 
    171  
    172 * **instance** (only necessary when using the shortcode with 
    173     pagination more than once in the same page/post) - a number or 
    174     name to identify the instance where you are using pagination. 
    175     Since you can use the shortcode several times in the same page or 
    176     post, you need to identify the instance so that you paginate only 
    177     that instance. 
    178  
    179  
    180 Example: 
    181  
    182 `[catlist id=3 numberposts=5 pagination=yes instance=1]` 
    183  
    184 `[catlist id=5 numberposts=15 pagination=yes instance=2]` 
    185  
    186 You can customize what to show for the "next" and "previous" buttons 
    187 in the pagination navigation. Use the following params: 
    188  
    189  * **pagination_prev** - Replace the "<<" characters in the "previous" 
    190  button in the pagination navigation with a custom text. 
    191  * **pagination_next** - Replace the ">>" characters in the "next" 
    192  button in the pagination navigation with a custom text. 
    193  
    194 You can also set a default value for pagination in the Options Page. This will apply every time you use the shortcode. You can override the option by using `pagination='yes'` and `pagination='no'` in the shortcode. 
    195  
    196 ==Changing the pagination CSS== 
    197  
    198 If you want to customize the way the pagination is displayed, you can 
    199 copy the `lcp_paginator.css` file from the plugin's directory to your 
    200 theme's directory and customize it. Do not customize the file on the 
    201 plugin's directory since this file will be overwritten every time you 
    202 update the plugin. 
    203  
    204 The current page in pagination has its own CSS class: 
    205  
    206 ` 
    207 <li class='lcp_currentpage'>current_page</li> 
    208 ` 
    209  
    210 So you can style the current page number differently if you want to. 
     180==PAGINATION 
     181 
     182https://github.com/picandocodigo/List-Category-Posts/wiki/Pagination 
    211183 
    212184==OTHER PARAMETERS== 
     
    298270* **content** - **WARNING**: If you want to show the content on your listed posts, you might want to do this from a new [Page Template](http://codex.wordpress.org/Page_Templates) or a [Custom Post Type](http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates) template. Using this parameter is discouraged, you can have memory issues as well as infinite loop situations when you're displaying a post that's using List Category Posts. You have been warned. Usage: 
    299271 
    300 Show the excerpt or full content of the post. If there's a &lt;!--more--&gt; tag in the post, then it will behave just as WordPress does: only show the content previous to the more tag. Default is 'no'. Ex: `[catlist content=yes]` 
    301  
    302 Show the full content of the post regardless of whether there is a &lt;!--more--&gt; tag in the post. Ex: `[catlist content=full]` 
     272    * `yes` - Show the excerpt or full content of the post. If there's a &lt;!--more--&gt; tag in the post, then it will behave just as WordPress does: only show the content previous to the more tag. Default is 'no'. Ex: `[catlist content=yes]` 
     273 
     274    * `full` - Show the full content of the post regardless of whether there is a &lt;!--more--&gt; tag in the post. Ex: `[catlist content=full]` 
    303275 
    304276* **catlink** - Show the title of the category with a link to the category. Use the **catlink_string** option to change the link text. Default is 'no'. Ex: `[catlist catlink=yes]`. The way it's programmed, it should only display the title for the first category you chose, and include the posts from all of the categories. I thought of this parameter mostly for using several shortcodes on one page or post, so that each group of posts would have the title of that group's category. If you need to display several titles with posts, you should use one [catlist] shortcode for each category you want to display. 
     
    410382== HTML & CSS Customization == 
    411383 
    412 By default, the plugin lists the posts in an unordered list with the 
    413 `lcp_catlist` CSS class, like this: 
    414  
    415 `<ul class="lcp_catlist">` 
    416  
    417 So if you want to customize the appearance of the List Category Posts 
    418 lists, you can just edit the lcp_catlist class in your theme's CSS. 
    419  
    420 You can also customize what HTML tags different elements will be 
    421 surrounded with, and set a CSS class for this element, or just a CSS class 
    422 which will wrap the element with a `span` tag. 
    423  
    424 The customizable elements (so far) are: author, catlink (category link), comments, date, excerpt, morelink ("Read More" link), thumbnail and title (post title). 
    425  
    426 The parameters are: 
    427 `author_tag, author_class, catlink_tag, catlink_class, comments_tag, 
    428 comments_class, date_tag, date_class, date_modified_tag, 
    429 date_modified_class, excerpt_tag, excerpt_class, morelink_class, 
    430 thumbnail_class, title_tag, title_class, posts_morelink_class, 
    431 customfield_tag, customfield_class` 
    432  
    433 So let's say you want to wrap the displayed comments count with the p tag and a "lcp_comments" class, you would do: 
    434 `[catlist id=7 comments=yes comments_tag=p comments_class=lcp_comments]` 
    435 This would produce the following code: 
    436 `<p class="lcp_comments"> (3)</p>` 
    437  
    438 Or you just want to style the displayed date, you could wrap it with a span tag: 
    439 `[catlist name=blog date=yes date_tag=span date_class=lcp_date]` 
    440 This would produce the following code: 
    441 `<span class="lcp_date">March 21, 2011</span>` 
    442  
    443 Elements without a specified tag, but a specified class, will be wrapped with a span tag and its class. For example this: 
    444 `[catlist id=7  date=yes date_class="lcp_date"]` 
    445 Will produce the following: 
    446 `<span class="lcp_date">October 23, 2013</span>` 
    447  
    448 The only exceptions here are the **title_tag** and **title_class** 
    449 parameters. If you only use the **title_class** parameter, the CSS 
    450 class will be assigned to the `a` tag like this: 
    451 `[catlist id=1 title_class="lcp_title"]` 
    452 Will produce: 
    453 `<a href="http://127.0.0.1/wordpress/?p=38" title="Test" class="lcp_title">Test</a>` 
    454 But if you use both: 
    455 `[catlist numberposts=5 title_class=lcp_title title_tag=h4]` 
    456 You will get: 
    457 `<h4 class="lcp_title"> 
    458     <a title="Hipchat" href="http://127.0.0.1:8080/wordpress/?p=40"></a> 
    459 </h4>` 
     384https://github.com/picandocodigo/List-Category-Posts/wiki/HTML-&-CSS-Customization 
    460385 
    461386== Template System == 
    462387 
    463 Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files. 
    464  
    465 You can use the included template as an example to start. It's in the plugin's template folder under the name default.php. To use a template, use this code: 
    466 `[catlist id=1 template=templatename]` 
    467 If the template file were templatename.php. 
    468  
    469 You can have as many different templates as you want, and use them in different pages and posts. The template code is pretty well documented, so if you're a bit familiar with HTML and PHP, you'll have no problems creating your own template. I'm planning on reworking the template system in order to have a really user friendly way to create templates. 
     388https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System 
    470389 
    471390== Frequently Asked Questions == 
     
    477396**INSTRUCTIONS ON HOW TO USE THE PLUGIN** 
    478397 
    479 http://wordpress.org/extend/plugins/list-category-posts/other_notes/ - 
     398https://github.com/picandocodigo/List-Category-Posts/wiki/ 
    480399 
    481400Please read the instructions and the FAQ before opening a new topic in the support forums. 
     
    483402**TEMPLATE SYSTEM** 
    484403 
    485 How to customize the way the posts are shown: http://wordpress.org/extend/plugins/list-category-posts/other_notes/. I am aware the Template System is not the friendliest right now, I'll work on improving this if I ever get the time to work on it. 
     404How to customize the way the posts are shown: https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System. I am aware the Template System is not the friendliest right now, I'll work on improving this if I ever get the time to work on it. 
    486405 
    487406**NEW FEATURE REQUESTS, BUG FIXES, ENHANCEMENTS** 
     
    532451 
    533452== Changelog == 
     453 
     454= 0.70 = 
     455 
     456* Fixed [customfield_class and customfield_tag issues](https://github.com/picandocodigo/List-Category-Posts/issues/201). Thanks [vacuus](https://github.com/vacuus)!! 
     457* Tested up to WordPress 4.6.1 
     458* Added date range, thanks again [vacuus](https://github.com/vacuus)!! Check [the docs](https://github.com/picandocodigo/List-Category-Posts/wiki/How-to-select-which-posts-to-show) to read how to use this. 
    534459 
    535460= 0.69 = 
  • list-category-posts/trunk/include/lcp-catlistdisplayer.php

    r1296434 r1494938  
    235235   */ 
    236236  private function lcp_build_post($single, $tag){ 
    237  
    238237    $class =''; 
    239238    if ( is_object($this->parent) && is_object($single) && $this->parent->ID == $single->ID ){ 
     
    396395    if(!empty($this->params['customfield_display'])){ 
    397396      $info = $this->catlist->get_custom_fields($this->params['customfield_display'], $single->ID); 
    398       if(empty($this->params['customfield_tag']) || $this->params['customfield_tag'] == null) 
     397      if(empty($this->params['customfield_tag']) || $this->params['customfield_tag'] == null){ 
    399398        $tag = 'div'; 
    400       if(empty($this->params['customfield_class']) || $this->params['customfield_class'] == null) 
     399      } else { 
     400        $tag = $this->params['customfield_tag']; 
     401      } 
     402 
     403      if(empty($this->params['customfield_class']) || $this->params['customfield_class'] == null){ 
    401404        $css_class = 'lcp_customfield'; 
     405      } else { 
     406        $css_class = $this->params['customfield_class']; 
     407      } 
     408 
    402409      $final_info = ''; 
    403410      if(!is_array($info)){ 
  • list-category-posts/trunk/include/lcp-parameters.php

    r1261454 r1494938  
    66  private static $instance = null; 
    77  private $starting_with = null; 
     8  // $date_query tells us if we need to generate date_query args 
     9  private $date_query = false; 
    810  private $utils; 
    911  private $params; 
     
    5961      $args['author_name'] = $params['author_posts']; 
    6062    endif; 
     63 
     64    // Posts within given date range: 
     65    if ( $this->utils->lcp_not_empty('after') ) { 
     66      $this->after = $params['after']; 
     67      $date_query = true; 
     68    } 
     69 
     70    if ( $this->utils->lcp_not_empty('after_year') ) { 
     71      $this->after_year = $params['after_year']; 
     72      $date_query = true; 
     73    } 
     74 
     75    if ( $this->utils->lcp_not_empty('after_month') ) { 
     76      // after_month should be in the range [1, 12] 
     77      if ($params['after_month'] >= 1 && $params['after_month'] <= 12) { 
     78        $this->after_month = $params['after_month']; 
     79        $date_query = true; 
     80      } 
     81    } 
     82 
     83    if ( $this->utils->lcp_not_empty('after_day') ) { 
     84      // after_day should be in the range [1, 31] 
     85      if ($params['after_day'] >= 1 && $params['after_day'] <= 31) { 
     86        $this->after_day = $params['after_day']; 
     87        $date_query = true; 
     88      } 
     89    } 
     90 
     91    if ( $this->utils->lcp_not_empty('before') ) { 
     92      $this->before = $params['before']; 
     93      $date_query = true; 
     94    } 
     95 
     96    if ( $this->utils->lcp_not_empty('before_year') ) { 
     97      $this->before_year = $params['before_year']; 
     98      $date_query = true; 
     99    } 
     100 
     101    if ( $this->utils->lcp_not_empty('before_month') ) { 
     102      // before_month should be in the range [1, 12] 
     103      if ($params['before_month'] >= 1 && $params['before_month'] <= 12) { 
     104        $this->before_month = $params['before_month']; 
     105        $date_query = true; 
     106      } 
     107    } 
     108 
     109    if ( $this->utils->lcp_not_empty('before_day') ) { 
     110      // before_day should be in the range [1, 31] 
     111      if ($params['before_day'] >= 1 && $params['before_day'] <= 31) { 
     112        $this->before_day = $params['before_day']; 
     113        $date_query = true; 
     114      } 
     115    } 
     116 
     117    // Only generate date_query args if a before/after paramater was found 
     118    if (isset($date_query) ){ 
     119      $args['date_query'] = $this->create_date_query_args(); 
     120    } 
    61121 
    62122    /* 
     
    193253    return $post->ID; 
    194254  } 
     255 
     256  /* 
     257   * Create date_query args according to https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters 
     258   * There's probably a better way to check if values exist. 
     259   * Code should be cleaned up (this is first attempt at a solution). 
     260   */ 
     261  private function create_date_query_args() { 
     262    $date_query = array(); 
     263 
     264    // Keep track of parameters that are set to build the argument array. 
     265    $params_set = array( 
     266      'after' => false, 
     267      'after_year' => false, 
     268      'after_month' => false, 
     269      'after_day' => false, 
     270      'before' => false, 
     271      'before_year' => false, 
     272      'before_month' => false, 
     273      'before_day' => false, 
     274    ); 
     275 
     276    // Booleans to track which subarrays should be created. 
     277    $after = false; 
     278    $before = false; 
     279 
     280    /* 
     281     *  Check which paramaters are set and find out which subarrays 
     282     *  should be created. 
     283     */ 
     284    if ( isset($this->after) ) { 
     285      $params_set['after'] = true; 
     286      $after = true; 
     287    } 
     288 
     289    if ( isset($this->after_year) ) { 
     290      $params_set['after_year'] = true; 
     291      $after = true; 
     292    } 
     293 
     294    if ( isset($this->after_month) ) { 
     295      $params_set['after_month'] = true; 
     296      $after = true; 
     297    } 
     298 
     299    if ( isset($this->after_day) ) { 
     300      $params_set['after_day'] = true; 
     301      $after = true; 
     302    } 
     303 
     304    if ( isset($this->before) ) { 
     305      $params_set['before'] = true; 
     306      $before = true; 
     307    } 
     308 
     309    if ( isset($this->before_year) ) { 
     310      $params_set['before_year'] = true; 
     311      $before = true; 
     312    } 
     313 
     314    if ( isset($this->before_month) ) { 
     315      $params_set['before_month'] = true; 
     316      $before = true; 
     317    } 
     318 
     319    if ( isset($this->before_day) ) { 
     320      $params_set['before_day'] = true; 
     321      $before = true; 
     322    } 
     323 
     324    /* 
     325     * Build the subarrays. 
     326     * The after parameter takes priority over after_* parameters. 
     327     * Simlarly, the before parameter takes priority over before_* parameters. 
     328     */ 
     329    if ($after) { 
     330      if ($params_set['after']) { 
     331        $date_query['after'] = $this->after; 
     332      } else { 
     333        if ( $params_set['after_year'] ) $date_query['after']['year'] = $this->after_year; 
     334        if ( $params_set['after_month'] ) $date_query['after']['month'] = $this->after_month; 
     335        if ( $params_set['after_day'] ) $date_query['after']['day'] = $this->after_day; 
     336      } 
     337    } 
     338 
     339    if ($before) { 
     340      if ($params_set['before']) { 
     341        $date_query['before'] = $this->before; 
     342      } else { 
     343        if ( $params_set['before_year'] ) $date_query['before']['year'] = $this->before_year; 
     344        if ( $params_set['before_month'] ) $date_query['before']['month'] = $this->before_month; 
     345        if ( $params_set['before_day'] ) $date_query['before']['day'] = $this->before_day; 
     346      } 
     347    } 
     348    return $date_query; 
     349  } 
    195350} 
  • list-category-posts/trunk/list-category-posts.php

    r1447893 r1494938  
    44  Plugin URI: https://github.com/picandocodigo/List-Category-Posts 
    55  Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2]. 
    6   Version: 0.69 
     6  Version: 0.70 
    77  Author: Fernando Briano 
    88  Author URI: http://fernandobriano.com 
     
    133133                             'link_titles' => true, 
    134134                             'link_dates' => 'no', 
     135                             'after' => '', 
     136                             'after_year' => '', 
     137                             'after_month' => '', 
     138                             'after_day' => '', 
     139                             'before' => '', 
     140                             'before_year' => '', 
     141                             'before_month' => '', 
     142                             'before_day' => '', 
    135143                           ), $atts); 
    136144    if($atts['numberposts'] == ''){ 
  • list-category-posts/trunk/readme.txt

    r1447893 r1494938  
    44Tags: list, categories, posts, cms 
    55Requires at least: 3.3 
    6 Tested up to: 4.5.2 
    7 Stable tag: 0.69 
     6Tested up to: 4.6.1 
     7Stable tag: 0.70 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    2525the content! A lot of parameters have been added to customize what to 
    2626display and how to show it. Check [the full 
    27 documentation](https://wordpress.org/plugins/list-category-posts/other_notes/) 
     27documentation](https://github.com/picandocodigo/List-Category-Posts/wiki) 
    2828to learn about the different ways to use it. 
    2929 
     
    3939parameter in your shortcode). 
    4040 
    41 **[Read the instructions](http://wordpress.org/extend/plugins/list-category-posts/other_notes/)** to learn which parameters are available and how to use them. 
     41**[Read the instructions](https://github.com/picandocodigo/List-Category-Posts/wiki)** to learn which parameters are available and how to use them. 
    4242 
    4343If you want to **List Categories** instead of posts you can use my other plugin **[List categories](http://wordpress.org/plugins/list-categories/)**. 
     
    4747**Customization** 
    4848 
    49 The different elements to display can be styled with CSS. you can define an HTML tag to wrap the element with, and a CSS class for this tag. Check [Other Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) for usage. 
     49The different elements to display can be styled with CSS. you can define an HTML tag to wrap the element with, and a CSS class for this tag. Check [the documentation](https://github.com/picandocodigo/List-Category-Posts/wiki) for usage. 
    5050 
    5151Great to use WordPress as a CMS, and create pages with several categories posts. 
     
    5959yet. You can use the shortcode for the most flexibility. 
    6060 
    61 Please, read the information on [Other 
    62 Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) 
     61Please, read the information on [the wiki](https://github.com/picandocodigo/List-Category-Posts/wiki) 
    6362and 
    6463[Changelog](http://wordpress.org/extend/plugins/list-category-posts/changelog/) 
     
    8685* Upload the `list-category-posts` directory to your wp-content/plugins/ directory. 
    8786* Login to your WordPress Admin menu, go to Plugins, and activate it. 
     87* Start using the '[catlist]` shortcode in your posts and/or pages. 
    8888* You can find the List Category Posts widget in the Appearence > Widgets section on your WordPress Dashboard. 
    89 * If you want to customize the way the plugin displays the information, check the section on Templates on this documentation. 
     89* If you want to customize the way the plugin displays the information, check [HTML & CSS Customization](https://github.com/picandocodigo/List-Category-Posts/wiki/HTML-&-CSS-Customization) or the [section on Templates](https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System) on the wiki. 
    9090 
    9191==Other notes== 
     92 
     93Since the documentation on how to use the plugin has passed wordpress.org's character limit, the text was cut. I've since started using [a wiki](https://github.com/picandocodigo/List-Category-Posts/wiki) for more comfortable reading and maintaining. Please check it out, suggestions are welcome on GitHub issues! 
    9294 
    9395==Instructions on how to use the plugin== 
     
    132134 
    133135* **monthnum** and **year** - List posts from a certain year or month. You can use these together or independently. Example: `[catlist year=2015]` will list posts from the year 2015. `[catlist monthnum=8]` will list posts published in August of every year. `[catlist year=2012 monthnum=12]` will list posts from December 2012. 
     136 
     137* **date ranges** - You can also use date ranges for listing posts. For example "list every post after March 14th, 2005". The parameters are: ```after, after_year, after_month, after_day, before, before_year, before_month,  before_day```. These parameters are used to specify data_query arguments (see: [the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)).   
     138 
     139     If you want to list all the posts before a given date, say `Jun 17th, 2007` you can use these two options:   
     140     `[catlist before_year=2007 before_month=06 before_day=17]`   
     141     Or you can use the `before` parameter with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):   
     142     `[catlist before='2007/06/17']`   
     143 
     144     The same works for posts after a given date, you can use:   
     145     `[catlist after_year=2007 after_month=06 after_day=17]`   
     146     Or just `after` with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):   
     147     `[catlist after='2007/06/17']`   
     148 
     149    `after` takes priority over `after_year`, `after_month`, and `after_day`.   
     150    `before` takes priority over `before_year`, `before_month`, and `before_day`.   
    134151 
    135152* **search** - List posts that match a search term. `[catlist search="The Cake is a lie"]` 
     
    161178* **custom fields** - To use custom fields, you must specify two values: customfield_name and customfield_value. Using this only show posts that contain a custom field with this name and value. Both parameters must be defined, or neither will work. 
    162179 
    163 ==PAGINATION== 
    164  
    165 To use pagination, you need to set the following parameters in the shortcode: 
    166  
    167 * **pagination** set it to yes. `[catlist pagination=yes]` 
    168  
    169 * **numberposts** - Posts per page are set with the `numberposts` 
    170     parameter. `[catlist pagination=yes numberposts=5]` 
    171  
    172 * **instance** (only necessary when using the shortcode with 
    173     pagination more than once in the same page/post) - a number or 
    174     name to identify the instance where you are using pagination. 
    175     Since you can use the shortcode several times in the same page or 
    176     post, you need to identify the instance so that you paginate only 
    177     that instance. 
    178  
    179  
    180 Example: 
    181  
    182 `[catlist id=3 numberposts=5 pagination=yes instance=1]` 
    183  
    184 `[catlist id=5 numberposts=15 pagination=yes instance=2]` 
    185  
    186 You can customize what to show for the "next" and "previous" buttons 
    187 in the pagination navigation. Use the following params: 
    188  
    189  * **pagination_prev** - Replace the "<<" characters in the "previous" 
    190  button in the pagination navigation with a custom text. 
    191  * **pagination_next** - Replace the ">>" characters in the "next" 
    192  button in the pagination navigation with a custom text. 
    193  
    194 You can also set a default value for pagination in the Options Page. This will apply every time you use the shortcode. You can override the option by using `pagination='yes'` and `pagination='no'` in the shortcode. 
    195  
    196 ==Changing the pagination CSS== 
    197  
    198 If you want to customize the way the pagination is displayed, you can 
    199 copy the `lcp_paginator.css` file from the plugin's directory to your 
    200 theme's directory and customize it. Do not customize the file on the 
    201 plugin's directory since this file will be overwritten every time you 
    202 update the plugin. 
    203  
    204 The current page in pagination has its own CSS class: 
    205  
    206 ` 
    207 <li class='lcp_currentpage'>current_page</li> 
    208 ` 
    209  
    210 So you can style the current page number differently if you want to. 
     180==PAGINATION 
     181 
     182https://github.com/picandocodigo/List-Category-Posts/wiki/Pagination 
    211183 
    212184==OTHER PARAMETERS== 
     
    298270* **content** - **WARNING**: If you want to show the content on your listed posts, you might want to do this from a new [Page Template](http://codex.wordpress.org/Page_Templates) or a [Custom Post Type](http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates) template. Using this parameter is discouraged, you can have memory issues as well as infinite loop situations when you're displaying a post that's using List Category Posts. You have been warned. Usage: 
    299271 
    300 Show the excerpt or full content of the post. If there's a &lt;!--more--&gt; tag in the post, then it will behave just as WordPress does: only show the content previous to the more tag. Default is 'no'. Ex: `[catlist content=yes]` 
    301  
    302 Show the full content of the post regardless of whether there is a &lt;!--more--&gt; tag in the post. Ex: `[catlist content=full]` 
     272    * `yes` - Show the excerpt or full content of the post. If there's a &lt;!--more--&gt; tag in the post, then it will behave just as WordPress does: only show the content previous to the more tag. Default is 'no'. Ex: `[catlist content=yes]` 
     273 
     274    * `full` - Show the full content of the post regardless of whether there is a &lt;!--more--&gt; tag in the post. Ex: `[catlist content=full]` 
    303275 
    304276* **catlink** - Show the title of the category with a link to the category. Use the **catlink_string** option to change the link text. Default is 'no'. Ex: `[catlist catlink=yes]`. The way it's programmed, it should only display the title for the first category you chose, and include the posts from all of the categories. I thought of this parameter mostly for using several shortcodes on one page or post, so that each group of posts would have the title of that group's category. If you need to display several titles with posts, you should use one [catlist] shortcode for each category you want to display. 
     
    410382== HTML & CSS Customization == 
    411383 
    412 By default, the plugin lists the posts in an unordered list with the 
    413 `lcp_catlist` CSS class, like this: 
    414  
    415 `<ul class="lcp_catlist">` 
    416  
    417 So if you want to customize the appearance of the List Category Posts 
    418 lists, you can just edit the lcp_catlist class in your theme's CSS. 
    419  
    420 You can also customize what HTML tags different elements will be 
    421 surrounded with, and set a CSS class for this element, or just a CSS class 
    422 which will wrap the element with a `span` tag. 
    423  
    424 The customizable elements (so far) are: author, catlink (category link), comments, date, excerpt, morelink ("Read More" link), thumbnail and title (post title). 
    425  
    426 The parameters are: 
    427 `author_tag, author_class, catlink_tag, catlink_class, comments_tag, 
    428 comments_class, date_tag, date_class, date_modified_tag, 
    429 date_modified_class, excerpt_tag, excerpt_class, morelink_class, 
    430 thumbnail_class, title_tag, title_class, posts_morelink_class, 
    431 customfield_tag, customfield_class` 
    432  
    433 So let's say you want to wrap the displayed comments count with the p tag and a "lcp_comments" class, you would do: 
    434 `[catlist id=7 comments=yes comments_tag=p comments_class=lcp_comments]` 
    435 This would produce the following code: 
    436 `<p class="lcp_comments"> (3)</p>` 
    437  
    438 Or you just want to style the displayed date, you could wrap it with a span tag: 
    439 `[catlist name=blog date=yes date_tag=span date_class=lcp_date]` 
    440 This would produce the following code: 
    441 `<span class="lcp_date">March 21, 2011</span>` 
    442  
    443 Elements without a specified tag, but a specified class, will be wrapped with a span tag and its class. For example this: 
    444 `[catlist id=7  date=yes date_class="lcp_date"]` 
    445 Will produce the following: 
    446 `<span class="lcp_date">October 23, 2013</span>` 
    447  
    448 The only exceptions here are the **title_tag** and **title_class** 
    449 parameters. If you only use the **title_class** parameter, the CSS 
    450 class will be assigned to the `a` tag like this: 
    451 `[catlist id=1 title_class="lcp_title"]` 
    452 Will produce: 
    453 `<a href="http://127.0.0.1/wordpress/?p=38" title="Test" class="lcp_title">Test</a>` 
    454 But if you use both: 
    455 `[catlist numberposts=5 title_class=lcp_title title_tag=h4]` 
    456 You will get: 
    457 `<h4 class="lcp_title"> 
    458     <a title="Hipchat" href="http://127.0.0.1:8080/wordpress/?p=40"></a> 
    459 </h4>` 
     384https://github.com/picandocodigo/List-Category-Posts/wiki/HTML-&-CSS-Customization 
    460385 
    461386== Template System == 
    462387 
    463 Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files. 
    464  
    465 You can use the included template as an example to start. It's in the plugin's template folder under the name default.php. To use a template, use this code: 
    466 `[catlist id=1 template=templatename]` 
    467 If the template file were templatename.php. 
    468  
    469 You can have as many different templates as you want, and use them in different pages and posts. The template code is pretty well documented, so if you're a bit familiar with HTML and PHP, you'll have no problems creating your own template. I'm planning on reworking the template system in order to have a really user friendly way to create templates. 
     388https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System 
    470389 
    471390== Frequently Asked Questions == 
     
    477396**INSTRUCTIONS ON HOW TO USE THE PLUGIN** 
    478397 
    479 http://wordpress.org/extend/plugins/list-category-posts/other_notes/ - 
     398https://github.com/picandocodigo/List-Category-Posts/wiki/ 
    480399 
    481400Please read the instructions and the FAQ before opening a new topic in the support forums. 
     
    483402**TEMPLATE SYSTEM** 
    484403 
    485 How to customize the way the posts are shown: http://wordpress.org/extend/plugins/list-category-posts/other_notes/. I am aware the Template System is not the friendliest right now, I'll work on improving this if I ever get the time to work on it. 
     404How to customize the way the posts are shown: https://github.com/picandocodigo/List-Category-Posts/wiki/Template-System. I am aware the Template System is not the friendliest right now, I'll work on improving this if I ever get the time to work on it. 
    486405 
    487406**NEW FEATURE REQUESTS, BUG FIXES, ENHANCEMENTS** 
     
    532451 
    533452== Changelog == 
     453 
     454= 0.70 = 
     455 
     456* Fixed [customfield_class and customfield_tag issues](https://github.com/picandocodigo/List-Category-Posts/issues/201). Thanks [vacuus](https://github.com/vacuus)!! 
     457* Tested up to WordPress 4.6.1 
     458* Added date range, thanks again [vacuus](https://github.com/vacuus)!! Check [the docs](https://github.com/picandocodigo/List-Category-Posts/wiki/How-to-select-which-posts-to-show) to read how to use this. 
    534459 
    535460= 0.69 = 
Note: See TracChangeset for help on using the changeset viewer.