Plugin Directory

Changeset 1160273


Ignore:
Timestamp:
05/14/2015 09:18:02 AM (11 years ago)
Author:
eugenyh
Message:

Version 0.6.2 released

Location:
advanced-recent-posts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • advanced-recent-posts/trunk/backend/lptw-recent-posts-backend.php

    r1158067 r1160273  
    3131                        </ul>
    3232                    </fieldset>
     33                </td>
     34            </tr>
     35            <tr id="post_types">
     36                <th scope="row"><label for="post_type">Post type:</label></th>
     37                <td>
     38                    <select id="post_type" name="post_type">
     39                    <?php
     40                        $post_types = get_post_types( '', 'names' );
     41                        foreach ( $post_types as $post_type ) {
     42                           echo '<option value="' . $post_type . '">' . $post_type . '</option>';
     43                        }
     44                    ?>
     45                    </select>
    3346                </td>
    3447            </tr>
  • advanced-recent-posts/trunk/backend/lptw-recent-posts-shortcode-builder.js

    r1158067 r1160273  
    11jQuery(document).ready(function($) {
    2   'use strict';
    3   /* widget scripts */
    4 
    5   $('body').on('click', '.lptw-categories-dropdown-link', function(e) {
    6     e.preventDefault();
    7     var $parent = $(this).closest('div[id]');
    8     $parent.find('#lptw-categories-wrapper').slideToggle('fast');
    9     $parent.find('#lptw-categories-action').toggleClass( 'lptw-categories-action-down' );
    10     $parent.find('#lptw-categories-action').toggleClass( 'lptw-categories-action-up' );
    11   });
    12 
    13   /* shortcode builder scripts */
    14 
    15   $("#lptw_generate_shortcode").click(function(e) {
    16     var sb_layout = $('input[name="sb_layout"]:checked', '#layout-types').val();
    17 
    18     var post_category_selected = [];
    19     $('#categories_list input:checked').each(function() {
    20       post_category_selected.push($(this).attr('value'));
    21     });
    22     var sb_category_id = post_category_selected.toString();
    23 
    24     if ($("#sb_fluid_images").is(":checked") == true) {
    25       var sb_fluid_images = "true";
    26       var sb_width = "";
    27       var sb_columns = "";
    28     } else {
    29       var sb_fluid_images = "false";
    30       var sb_width = $("#sb_width").val();
    31       var sb_columns = $('input[name="sb_columns"]:checked', '#columns_count').val();
    32     }
    33 
    34     var sb_posts_per_page = $("#posts_per_page").val();
    35 
    36     if ($("#reverse_post_order").is(":checked") == true) {
    37       var sb_reverse_post_order = "true";
    38     } else {
    39       var sb_reverse_post_order = "false";
    40     }
    41 
    42     var sb_thumbnail_size = $("#thumbnail_size").val();
    43     var sb_color_scheme = $("#color_scheme").val();
    44 
    45     if ($("#show_date_before_title").is(":checked") == true) {
    46       var sb_show_date_before_title = "true";
    47     } else {
    48       var sb_show_date_before_title = "false";
    49     }
    50 
    51     if ($("#show_date").is(":checked") == true) {
    52       var sb_show_date = "true";
    53     } else {
    54       var sb_show_date = "false";
    55     }
    56 
    57     if ($("#show_time").is(":checked") == true) {
    58       var sb_show_time = "true";
    59     } else {
    60       var sb_show_time = "false";
    61     }
    62 
    63     if ($("#show_time_before").is(":checked") == true) {
    64       var sb_show_time_before = "true";
    65     } else {
    66       var sb_show_time_before = "false";
    67     }
    68 
    69     var sb_date_format = $('input[name="sb_date_format"]:checked', '#date_formats').val();
    70     var sb_time_format = $('input[name="sb_time_format"]:checked', '#time_formats').val();
    71 
    72     /* clear unused options depending on layout */
    73 
    74     /* basic layout */
    75 
    76     /* thumbnail layout */
    77     if (sb_layout == 'thumbnail') {
    78       sb_fluid_images = '';
    79       sb_thumbnail_size = '';
    80       sb_color_scheme = '';
    81     }
    82 
    83     /* dropcap layout */
    84     if (sb_layout == 'dropcap') {
    85       sb_show_date = '';
    86       sb_fluid_images = '';
    87       sb_thumbnail_size = '';
    88       sb_color_scheme = '';
    89       sb_date_format = '';
    90       sb_time_format = '';
    91       sb_show_time = '';
    92       sb_show_time_before = '';
    93       sb_show_date_before_title = '';
    94     }
    95 
    96     /* responsive grid layout */
    97     if (sb_layout == 'grid-medium') {
    98       sb_fluid_images = '';
    99       sb_thumbnail_size = '';
    100       sb_width = '';
    101       sb_columns = '';
    102     }
    103 
    104 
    105     var shortcode = '[lptw_recentposts';
    106     if (sb_layout != '') {
    107       shortcode += ' layout="' + sb_layout + '"';
    108     }
    109     if (sb_category_id != '') {
    110       shortcode += ' category_id="' + sb_category_id + '"';
    111     }
    112     if (sb_fluid_images != "") {
    113       shortcode += ' fluid_images="' + sb_fluid_images + '"';
    114     }
    115     if (sb_width != '') {
    116       shortcode += ' width="' + sb_width + '"';
    117     }
    118     if (sb_columns != '') {
    119       shortcode += ' columns="' + sb_columns + '"';
    120     }
    121     if (sb_posts_per_page != '') {
    122       shortcode += ' posts_per_page="' + sb_posts_per_page + '"';
    123     }
    124     if (sb_reverse_post_order != '') {
    125       shortcode += ' reverse_post_order="' + sb_reverse_post_order + '"';
    126     }
    127     if (sb_thumbnail_size != '') {
    128       shortcode += ' thumbnail_size="' + sb_thumbnail_size + '"';
    129     }
    130     if (sb_color_scheme != '') {
    131       shortcode += ' color_scheme="' + sb_color_scheme + '"';
    132     }
    133     if (sb_show_date_before_title != '') {
    134       shortcode += ' show_date_before_title="' + sb_show_date_before_title + '"';
    135     }
    136     if (sb_show_date != '') {
    137       shortcode += ' show_date="' + sb_show_date + '"';
    138     }
    139     if (sb_show_time != '') {
    140       shortcode += ' show_time="' + sb_show_time + '"';
    141     }
    142     if (sb_show_time_before != '') {
    143       shortcode += ' show_time_before="' + sb_show_time_before + '"';
    144     }
    145     if (sb_date_format != '') {
    146       shortcode += ' date_format="' + sb_date_format + '"';
    147     }
    148     if (sb_time_format != '') {
    149       shortcode += ' time_format="' + sb_time_format + '"';
    150     }
    151     shortcode += ']';
    152 
    153     $('#lptw_generate_shortcode_result').val(shortcode).addClass('ready');
    154     e.preventDefault();
    155   });
    156 
    157   /* disable/enable inputs */
    158 
    159   $('#sb_fluid_images').change(function() {
    160     $('#sb_width').prop('disabled', function(i, v) {
    161       return !v;
    162     });
    163     $('#sb_columns_1').prop('disabled', function(i, v) {
    164       return !v;
    165     });
    166     $('#sb_columns_2').prop('disabled', function(i, v) {
    167       return !v;
    168     });
    169   });
    170 
    171   $(".layout-radio").change(function() {
    172 
    173     if ($("#layout-basic").is(":checked") == true) {
    174       /* disable all inputs with class layout-basic-hide */
    175       $('.layout-basic-hide').prop('disabled', true);
    176 
    177       /* enable all inputs with class layout-basic-show */
    178       $('.layout-basic-show').prop('disabled', false);
    179 
    180       $('#sb_fluid_images').prop('checked', true);
    181     }
    182 
    183     if ($("#layout-thumbnail").is(":checked") == true) {
    184       /* disable all inputs with class layout-thumbnail-hide */
    185       $('.layout-thumbnail-hide').prop('disabled', true);
    186 
    187       /* enable all inputs with class layout-thumbnail-show */
    188       $('.layout-thumbnail-show').prop('disabled', false);
    189 
    190       $('#sb_fluid_images').prop('checked', false);
    191     }
    192 
    193     if ($("#layout-dropcap").is(":checked") == true) {
    194       /* disable all inputs with class layout-dropcap-hide */
    195       $('.layout-dropcap-hide').prop('disabled', true);
    196 
    197       /* enable all inputs with class layout-dropcap-show */
    198       $('.layout-dropcap-show').prop('disabled', false);
    199 
    200       $('#sb_fluid_images').prop('checked', false);
    201     }
    202 
    203     if ($("#layout-grid-medium").is(":checked") == true) {
    204       /* disable all inputs with class layout-basic-hide */
    205       $('.layout-grid-hide').prop('disabled', true);
    206 
    207       /* enable all inputs with class layout-basic-show */
    208       $('.layout-grid-show').prop('disabled', false);
    209 
    210       $('#sb_fluid_images').prop('checked', false);
    211     }
    212 
    213   });
     2    'use strict';
     3    /* widget scripts */
     4
     5    $('body').on('click', '.lptw-categories-dropdown-link', function(e) {
     6        e.preventDefault();
     7        var $parent = $(this).closest('div[id]');
     8        $parent.find('#lptw-categories-wrapper').slideToggle('fast');
     9        $parent.find('#lptw-categories-action').toggleClass('lptw-categories-action-down');
     10        $parent.find('#lptw-categories-action').toggleClass('lptw-categories-action-up');
     11    });
     12
     13    /* shortcode builder scripts */
     14
     15    $("#lptw_generate_shortcode").click(function(e) {
     16        var sb_layout = $('input[name="sb_layout"]:checked', '#layout-types').val();
     17
     18        var sb_post_type = $("#post_type").val();
     19
     20        var post_category_selected = [];
     21        $('#categories_list input:checked').each(function() {
     22            post_category_selected.push($(this).attr('value'));
     23        });
     24        var sb_category_id = post_category_selected.toString();
     25
     26        if ($("#sb_fluid_images").is(":checked") == true) {
     27            var sb_fluid_images = "true";
     28            var sb_width = "";
     29            var sb_columns = "";
     30        } else {
     31            var sb_fluid_images = "false";
     32            var sb_width = $("#sb_width").val();
     33            var sb_columns = $('input[name="sb_columns"]:checked', '#columns_count').val();
     34        }
     35
     36        var sb_posts_per_page = $("#posts_per_page").val();
     37
     38        if ($("#reverse_post_order").is(":checked") == true) {
     39            var sb_reverse_post_order = "true";
     40        } else {
     41            var sb_reverse_post_order = "false";
     42        }
     43
     44        var sb_thumbnail_size = $("#thumbnail_size").val();
     45        var sb_color_scheme = $("#color_scheme").val();
     46
     47        if ($("#show_date_before_title").is(":checked") == true) {
     48            var sb_show_date_before_title = "true";
     49        } else {
     50            var sb_show_date_before_title = "false";
     51        }
     52
     53        if ($("#show_date").is(":checked") == true) {
     54            var sb_show_date = "true";
     55        } else {
     56            var sb_show_date = "false";
     57        }
     58
     59        if ($("#show_time").is(":checked") == true) {
     60            var sb_show_time = "true";
     61        } else {
     62            var sb_show_time = "false";
     63        }
     64
     65        if ($("#show_time_before").is(":checked") == true) {
     66            var sb_show_time_before = "true";
     67        } else {
     68            var sb_show_time_before = "false";
     69        }
     70
     71        var sb_date_format = $('input[name="sb_date_format"]:checked', '#date_formats').val();
     72        var sb_time_format = $('input[name="sb_time_format"]:checked', '#time_formats').val();
     73
     74        /* clear unused options depending on layout */
     75
     76        /* basic layout */
     77
     78        /* thumbnail layout */
     79        if (sb_layout == 'thumbnail') {
     80            sb_fluid_images = '';
     81            sb_thumbnail_size = '';
     82            sb_color_scheme = '';
     83        }
     84
     85        /* dropcap layout */
     86        if (sb_layout == 'dropcap') {
     87            sb_show_date = '';
     88            sb_fluid_images = '';
     89            sb_thumbnail_size = '';
     90            sb_color_scheme = '';
     91            sb_date_format = '';
     92            sb_time_format = '';
     93            sb_show_time = '';
     94            sb_show_time_before = '';
     95            sb_show_date_before_title = '';
     96        }
     97
     98        /* responsive grid layout */
     99        if (sb_layout == 'grid-medium') {
     100            sb_fluid_images = '';
     101            sb_thumbnail_size = '';
     102            sb_width = '';
     103            sb_columns = '';
     104        }
     105
     106
     107        var shortcode = '[lptw_recentposts';
     108        if (sb_layout != '') {
     109            shortcode += ' layout="' + sb_layout + '"';
     110        }
     111        if (sb_post_type != '') {
     112            shortcode += ' post_type="' + sb_post_type + '"';
     113        }
     114        if (sb_category_id != '') {
     115            shortcode += ' category_id="' + sb_category_id + '"';
     116        }
     117        if (sb_fluid_images != "") {
     118            shortcode += ' fluid_images="' + sb_fluid_images + '"';
     119        }
     120        if (sb_width != '') {
     121            shortcode += ' width="' + sb_width + '"';
     122        }
     123        if (sb_columns != '') {
     124            shortcode += ' columns="' + sb_columns + '"';
     125        }
     126        if (sb_posts_per_page != '') {
     127            shortcode += ' posts_per_page="' + sb_posts_per_page + '"';
     128        }
     129        if (sb_reverse_post_order != '') {
     130            shortcode += ' reverse_post_order="' + sb_reverse_post_order + '"';
     131        }
     132        if (sb_thumbnail_size != '') {
     133            shortcode += ' thumbnail_size="' + sb_thumbnail_size + '"';
     134        }
     135        if (sb_color_scheme != '') {
     136            shortcode += ' color_scheme="' + sb_color_scheme + '"';
     137        }
     138        if (sb_show_date_before_title != '') {
     139            shortcode += ' show_date_before_title="' + sb_show_date_before_title + '"';
     140        }
     141        if (sb_show_date != '') {
     142            shortcode += ' show_date="' + sb_show_date + '"';
     143        }
     144        if (sb_show_time != '') {
     145            shortcode += ' show_time="' + sb_show_time + '"';
     146        }
     147        if (sb_show_time_before != '') {
     148            shortcode += ' show_time_before="' + sb_show_time_before + '"';
     149        }
     150        if (sb_date_format != '') {
     151            shortcode += ' date_format="' + sb_date_format + '"';
     152        }
     153        if (sb_time_format != '') {
     154            shortcode += ' time_format="' + sb_time_format + '"';
     155        }
     156        shortcode += ']';
     157
     158        $('#lptw_generate_shortcode_result').val(shortcode).addClass('ready');
     159        e.preventDefault();
     160    });
     161
     162    /* disable/enable inputs */
     163
     164    $('#sb_fluid_images').change(function() {
     165        $('#sb_width').prop('disabled', function(i, v) {
     166            return !v;
     167        });
     168        $('#sb_columns_1').prop('disabled', function(i, v) {
     169            return !v;
     170        });
     171        $('#sb_columns_2').prop('disabled', function(i, v) {
     172            return !v;
     173        });
     174    });
     175
     176    $(".layout-radio").change(function() {
     177
     178        if ($("#layout-basic").is(":checked") == true) {
     179            /* disable all inputs with class layout-basic-hide */
     180            $('.layout-basic-hide').prop('disabled', true);
     181
     182            /* enable all inputs with class layout-basic-show */
     183            $('.layout-basic-show').prop('disabled', false);
     184
     185            $('#sb_fluid_images').prop('checked', true);
     186        }
     187
     188        if ($("#layout-thumbnail").is(":checked") == true) {
     189            /* disable all inputs with class layout-thumbnail-hide */
     190            $('.layout-thumbnail-hide').prop('disabled', true);
     191
     192            /* enable all inputs with class layout-thumbnail-show */
     193            $('.layout-thumbnail-show').prop('disabled', false);
     194
     195            $('#sb_fluid_images').prop('checked', false);
     196        }
     197
     198        if ($("#layout-dropcap").is(":checked") == true) {
     199            /* disable all inputs with class layout-dropcap-hide */
     200            $('.layout-dropcap-hide').prop('disabled', true);
     201
     202            /* enable all inputs with class layout-dropcap-show */
     203            $('.layout-dropcap-show').prop('disabled', false);
     204
     205            $('#sb_fluid_images').prop('checked', false);
     206        }
     207
     208        if ($("#layout-grid-medium").is(":checked") == true) {
     209            /* disable all inputs with class layout-basic-hide */
     210            $('.layout-grid-hide').prop('disabled', true);
     211
     212            /* enable all inputs with class layout-basic-show */
     213            $('.layout-grid-show').prop('disabled', false);
     214
     215            $('#sb_fluid_images').prop('checked', false);
     216        }
     217
     218    });
    214219
    215220
  • advanced-recent-posts/trunk/lptw-recent-posts.php

    r1158510 r1160273  
    44Plugin URI: http://lp-tricks.com/
    55Description: Plugin that shows the recent posts with thumbnails in the widget and in other parts of the your blog or theme with shortcodes.
    6 Tags: widget, posts, plugin, recent, recent posts, latest, latest posts, shortcode, thumbnail, thumbnails, categories, content, featured image, Taxonomy
    7 Version: 0.6.1
     6Tags: widget, posts, plugin, recent, recent posts, latest, latest posts, shortcode, thumbnail, thumbnails, categories, content, featured image, Taxonomy, custom post type, custom
     7Version: 0.6.2
    88Author: Eugene Holin
    99Author URI: http://lp-tricks.com/
     
    189189        $post_category = isset( $instance['post_category'] ) ? $instance['post_category'] : array();
    190190
     191        $post_type = isset( $instance['post_type'] ) ? $instance['post_type'] : 'post';
     192
    191193        /* don't show post in recent if it shows in page */
    192194        global $post;
     
    194196
    195197        $r = new WP_Query( apply_filters( 'widget_posts_args', array(
     198            'post_type'             => $post_type,
    196199            'posts_per_page'        => $number,
    197200            'no_found_rows'         => true,
     
    318321        if ( isset( $instance[ 'post_category' ] ) ) { $post_category = $instance[ 'post_category' ]; }
    319322
     323        if ( isset( $instance[ 'post_type' ] ) ) { $post_type = $instance[ 'post_type' ]; }
     324        else { $post_type = 'post_type'; }
     325
    320326        // Widget admin form
    321327        ?>
     
    326332        <p><input class="checkbox" type="checkbox" <?php checked( $show_widget_title ); ?> id="<?php echo $this->get_field_id( 'show_widget_title' ); ?>" name="<?php echo $this->get_field_name( 'show_widget_title' ); ?>" />
    327333        <label for="<?php echo $this->get_field_id( 'show_widget_title' ); ?>"><?php _e( 'Display widget title?', 'lptw_recent_posts_domain' ); ?></label></p>
     334
     335        <p>
     336            <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e( 'Post type:', 'lptw_recent_posts_domain' ); ?></label>
     337            <select name="<?php echo $this->get_field_name( 'post_type' ); ?>" id="<?php echo $this->get_field_id('post_type'); ?>" class="widefat">
     338                <?php
     339                    $post_types = get_post_types( '', 'names' );
     340                    foreach ( $post_types as $registered_post_type ) {
     341                        echo '<option value="' . $registered_post_type . '"'.selected( $post_type, $registered_post_type ).'>' . $registered_post_type . '</option>';
     342                    }
     343                ?>
     344            </select>
     345        </p>
    328346
    329347        <div class="lptw-categories-dropdown"><a class="lptw-categories-dropdown-link" href="#">List of categories <span id="lptw-categories-action" class="lptw-categories-action-down"></span></a></div>
     
    418436        } else { $instance['post_category'] = ''; }
    419437
     438        $instance['post_type'] = strip_tags($new_instance['post_type']);
     439
    420440        $this->flush_widget_cache();
    421441
     
    504524        $post_category = isset( $instance['post_category'] ) ? $instance['post_category'] : array();
    505525
     526        $post_type = isset( $instance['post_type'] ) ? $instance['post_type'] : 'post';
     527
    506528        /* don't show post in recent if it shows in page */
    507529        global $post;
     
    509531
    510532        $r = new WP_Query( apply_filters( 'widget_posts_args', array(
     533            'post_type'             => $post_type,
    511534            'posts_per_page'        => $number,
    512535            'no_found_rows'         => true,
     
    617640        if ( isset( $instance[ 'post_category' ] ) ) { $post_category = $instance[ 'post_category' ]; }
    618641
     642        if ( isset( $instance[ 'post_type' ] ) ) { $post_type = $instance[ 'post_type' ]; }
     643        else { $post_type = 'post_type'; }
     644
    619645        // Widget admin form
    620646        ?>
     
    625651        <p><input class="checkbox" type="checkbox" <?php checked( $show_widget_title ); ?> id="<?php echo $this->get_field_id( 'show_widget_title' ); ?>" name="<?php echo $this->get_field_name( 'show_widget_title' ); ?>" />
    626652        <label for="<?php echo $this->get_field_id( 'show_widget_title' ); ?>"><?php _e( 'Display widget title?', 'lptw_recent_posts_domain' ); ?></label></p>
     653
     654        <p>
     655            <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e( 'Post type:', 'lptw_recent_posts_domain' ); ?></label>
     656            <select name="<?php echo $this->get_field_name( 'post_type' ); ?>" id="<?php echo $this->get_field_id('post_type'); ?>" class="widefat">
     657                <?php
     658                    $post_types = get_post_types( '', 'names' );
     659                    foreach ( $post_types as $registered_post_type ) {
     660                        echo '<option value="' . $registered_post_type . '"'.selected( $post_type, $registered_post_type ).'>' . $registered_post_type . '</option>';
     661                    }
     662                ?>
     663            </select>
     664        </p>
    627665
    628666        <div class="lptw-categories-dropdown"><a class="lptw-categories-dropdown-link" href="#">List of categories <span id="lptw-categories-action" class="lptw-categories-action-down"></span></a></div>
     
    707745            $instance['post_category'] = $terms;
    708746        } else { $instance['post_category'] = ''; }
     747
     748        $instance['post_type'] = strip_tags($new_instance['post_type']);
    709749
    710750        $this->flush_widget_cache();
  • advanced-recent-posts/trunk/readme.txt

    r1158513 r1160273  
    11=== Plugin Name ===
    22Contributors: eugenyh
    3 Tags: widget, posts, plugin, recent, recent posts, latest, latest posts, shortcode, thumbnail, thumbnails, categories, content, featured image, Taxonomy
     3Tags: widget, posts, plugin, recent, recent posts, latest, latest posts, shortcode, thumbnail, thumbnails, categories, content, featured image, Taxonomy, custom post type, custom
    44Requires at least: 3.0.1
    55Tested up to: 4.2.2
    6 Stable tag: 0.6.1
     6Stable tag: 0.6.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333Better to see once than read a hundred times - see the [live demo](http://demo.lp-tricks.com/) on my website :)
    3434
     35Like my plugin? Please, rate :) &#9733;&#9733;&#9733;&#9733;&#9733;
     36
    3537**Contributing**
    3638
     
    4345== Installation ==
    4446
    45 1. Upload "lptw-recent-posts" folder to the "/wp-content/plugins/" directory
     471. Upload "advanced-recent-posts" folder to the "/wp-content/plugins/" directory
    46481. Activate the plugin through the Plugins menu into WordPress admin area
    47491. Use plugin shortcode builder to create a shortcode and use it a in your posts
     
    5860
    5961== Changelog ==
     62
     63= 0.6.2 =
     64* Added Custom Post Types support
    6065
    6166= 0.6.1 =
Note: See TracChangeset for help on using the changeset viewer.