Plugin Directory

Changeset 2546965


Ignore:
Timestamp:
06/13/2021 03:04:05 AM (5 years ago)
Author:
trepmal
Message:

Update to version 1.4 from GitHub

Location:
mini-loops
Files:
24 added
1 deleted
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • mini-loops/assets/banner-772x250.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • mini-loops/assets/screenshot-1.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • mini-loops/assets/screenshot-2.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • mini-loops/assets/screenshot-3.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • mini-loops/assets/screenshot-4.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • mini-loops/tags/1.4/form.php

    r976219 r2546965  
    11<?php if ( ! defined( 'ABSPATH' ) ) die( '-1' ); ?>
    22        <p style="width:40%;float:left;">
    3             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mini-loops' );?>
    4                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo stripslashes( $title ); ?>" />
     3            <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'mini-loops' );?>
     4                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    55            </label>
    66        </p>
    77        <p style="width:40%;margin-left:2%;float:left;">
    8             <label for="<?php echo $this->get_field_id( 'title_url' ); ?>"><?php _e( 'Title URL:', 'mini-loops' );?>
    9                 <input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="text" value="<?php echo $title_url; ?>" />
     8            <label for="<?php echo esc_attr( $this->get_field_id( 'title_url' )  ); ?>"><?php esc_html_e( 'Title URL:', 'mini-loops' );?>
     9                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title_url' ) ); ?>" type="text" value="<?php echo esc_attr( $title_url ); ?>" />
    1010            </label>
    1111        </p>
    1212        <p style="width:15%;margin-left:2%;float:left;padding-top:20px;height:20px;">
    13             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_title'); ?>" name="<?php echo $this->get_field_name('hide_title'); ?>"<?php checked( $hide_title ); ?> />
    14             <label for="<?php echo $this->get_field_id('hide_title'); ?>"><?php _e('Hide Title?', 'mini-loops' );?></label>
     13            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('hide_title' ) ); ?>"<?php checked( $hide_title ); ?> />
     14            <label for="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>"><?php esc_html_e('Hide Title?', 'mini-loops' );?></label>
    1515        </p>
    1616
     
    1919    <div style="width:48%;float:left;">
    2020
    21         <h3><?php _e( 'Query', 'mini-loops' ); ?></h3>
    22         <p style="width:48%;float:left;">
    23             <label for="<?php echo $this->get_field_id('number_posts'); ?>"><?php _e('Number of Posts:', 'mini-loops' );?>
    24                 <input class="widefat" id="<?php echo $this->get_field_id('number_posts'); ?>" name="<?php echo $this->get_field_name('number_posts'); ?>" type="number" value="<?php echo $number_posts; ?>" />
    25             </label>
    26         </p>
    27         <p style="width:48%;float:right;">
    28             <label for="<?php echo $this->get_field_id('post_offset'); ?>"><?php _e('Posts Offset:', 'mini-loops' );?>
    29                 <input class="widefat" id="<?php echo $this->get_field_id('post_offset'); ?>" name="<?php echo $this->get_field_name('post_offset'); ?>" type="number" value="<?php echo $post_offset; ?>" />
    30             </label>
    31         </p>
    32         <p style="width:48%;float:left;">
    33             <label for="<?php echo $this->get_field_id('maximum_age'); ?>"><?php _e('Maximum Age:', 'mini-loops' );?>
    34                 <input class="widefat" id="<?php echo $this->get_field_id('maximum_age'); ?>" name="<?php echo $this->get_field_name('maximum_age'); ?>" type="number" value="<?php echo $maximum_age; ?>" />
    35                 <small>(<?php _e('Only posts less than X days old.', 'mini-loops');?>) </small>
    36             </label>
    37         </p>
    38         <p style="width:48%;float:right;">
    39             <label for="<?php echo $this->get_field_id('post_author'); ?>"><?php _e('Author:', 'mini-loops');?>
    40                 <input class="widefat" id="<?php echo $this->get_field_id('post_author'); ?>" name="<?php echo $this->get_field_name('post_author'); ?>" type="text" value="<?php echo $post_author; ?>" /><br />
    41                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
     21        <h3><?php esc_html_e( 'Query', 'mini-loops' ); ?></h3>
     22        <p style="width:48%;float:left;">
     23            <label for="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>"><?php esc_html_e('Number of Posts:', 'mini-loops' );?>
     24                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('number_posts' ) ); ?>" type="number" value="<?php echo esc_attr( $number_posts ); ?>" />
     25            </label>
     26        </p>
     27        <p style="width:48%;float:right;">
     28            <label for="<?php echo esc_attr( $this->get_field_id('post_offset' ) ); ?>"><?php esc_html_e('Posts Offset:', 'mini-loops' );?>
     29                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_offset' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_offset' ) ); ?>" type="number" value="<?php echo esc_attr( $post_offset ); ?>" />
     30            </label>
     31        </p>
     32        <p style="width:48%;float:left;">
     33            <label for="<?php echo esc_attr( $this->get_field_id('maximum_age' ) ); ?>"><?php esc_html_e('Maximum Age:', 'mini-loops' );?>
     34                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('maximum_age' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('maximum_age' ) ); ?>" type="number" value="<?php echo esc_attr( $maximum_age ); ?>" />
     35                <small>(<?php esc_html_e('Only posts less than X days old.', 'mini-loops');?>) </small>
     36            </label>
     37        </p>
     38        <p style="width:48%;float:right;">
     39            <label for="<?php echo esc_attr( $this->get_field_id('post_author' ) ); ?>"><?php esc_html_e('Author:', 'mini-loops');?>
     40                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_author' ) ); ?>" type="text" value="<?php echo esc_attr( $post_author ); ?>" /><br />
     41                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
    4242            </label>
    4343        </p>
    4444        <p>
    4545        <p style="width:48%;float:left;clear:left;">
    46             <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'mini-loops' );?>
    47                 <select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>">
     46            <label for="<?php echo esc_attr( $this->get_field_id('post_type' ) ); ?>"><?php esc_html_e('Post Type:', 'mini-loops' );?>
     47                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_type' ) ); ?>">
    4848                <?php
    4949                    echo "<option value='any'" . selected( 'any', $post_type, false ) . ">Any</option>";
    5050                    $pts = get_post_types( array( 'public' => true ), 'objects' );
    51                     foreach($pts as $slug=>$obj) {
    52                         echo "<option value='{$slug}'" . selected( $slug, $post_type, false ) . ">{$obj->labels->name}</option>";
    53                     }
    54                 ?>
    55                 </select>
    56             </label>
    57         </p>
    58         <p style="width:48%;float:right;">
    59             <label for="<?php echo $this->get_field_id('post_status'); ?>"><?php _e('Post Status:', 'mini-loops' );?>
    60                 <select class="widefat" id="<?php echo $this->get_field_id('post_status'); ?>" name="<?php echo $this->get_field_name('post_status'); ?>">
     51                    foreach ( $pts as $slug => $obj ) {
     52                        printf(
     53                            '<option value="%s" %s>%s</option>',
     54                            esc_attr( $slug ),
     55                            selected( $slug, $post_type, false ),
     56                            esc_html( $obj->labels->name )
     57                        );
     58                    }
     59                ?>
     60                </select>
     61            </label>
     62        </p>
     63        <p style="width:48%;float:right;">
     64            <label for="<?php echo esc_attr( $this->get_field_id( 'post_status' ) ); ?>"><?php esc_html_e('Post Status:', 'mini-loops' );?>
     65                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_status' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_status' ) ); ?>">
    6166                <?php
    6267                    echo "<option value='any'" . selected( 'any', $post_status, false ) . ">Any</option>";
    6368                    $pss = get_available_post_statuses();
    64                     foreach($pss as $k=>$v) {
    65                         echo "<option value='{$v}'" . selected( $v, $post_status, false ) . ">{$v}</option>";
    66                     }
    67                 ?>
    68                 </select>
    69             </label>
    70         </p>
    71         <p style="width:48%;float:left;">
    72             <label for="<?php echo $this->get_field_id('order_by'); ?>"><?php _e('Order by:', 'mini-loops' );?>
    73                 <select class="widefat" id="<?php echo $this->get_field_id('order_by'); ?>" name="<?php echo $this->get_field_name('order_by'); ?>">
     69                    foreach ( $pss as $k => $v ) {
     70                        printf(
     71                            '<option value="%s" %s>%s</option>',
     72                            esc_attr( $v ),
     73                            selected( $v, $post_status, false ),
     74                            esc_html( $v )
     75                        );
     76                    }
     77                ?>
     78                </select>
     79            </label>
     80        </p>
     81        <p style="width:48%;float:left;">
     82            <label for="<?php echo esc_attr( $this->get_field_id('order_by' ) ); ?>"><?php esc_html_e('Order by:', 'mini-loops' );?>
     83                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('order_by' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order_by' ) ); ?>">
    7484                <?php
    7585                    $obs = array( 'id' => 'ID', 'author' => __('Author', 'mini-loops'), 'title' => __('Title', 'mini-loops'), 'date' => __('Date', 'mini-loops'), 'modified' => __('Last-modified Date', 'mini-loops'), 'parent', __('Parent ID', 'mini-loops'), 'rand' => __('Random', 'mini-loops'), 'comment_count' => __('Comment Count', 'mini-loops'), 'menu_order' => __('Menu Order', 'mini-loops'), 'meta_value' => __('Meta Value*', 'mini-loops'), 'meta_value_num' => __('Meta Value Numerical*', 'mini-loops') );
    76                     foreach($obs as $k=>$v) {
    77                         echo "<option value='{$k}'" . selected( $k, $order_by, false ) . ">{$v}</option>";
    78                     }
    79                 ?>
    80                 </select>
    81             </label>
    82         </p>
    83         <p style="width:48%;float:right;">
    84             <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:', 'mini-loops' );?>
    85                 <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>">
     86                    foreach ( $obs as $k => $v ) {
     87                        printf(
     88                            '<option value="%s" %s>%s</option>',
     89                            esc_attr( $k ),
     90                            selected( $k, $order_by, false ),
     91                            esc_html( $k )
     92                        );
     93                    }
     94                ?>
     95                </select>
     96            </label>
     97        </p>
     98        <p style="width:48%;float:right;">
     99            <label for="<?php echo esc_attr( $this->get_field_id('order' ) ); ?>"><?php esc_html_e('Order:', 'mini-loops' );?>
     100                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order' ) ); ?>">
    86101                <?php
    87102                    $obs = array( 'ASC', 'DESC' );
    88                     foreach($obs as $v) {
    89                         echo "<option value='{$v}'" . selected( $v, $order, false ) . ">{$v}</option>";
    90                     }
    91                 ?>
    92                 </select>
    93                 <small>(<?php _e('ABC vs ZYX', 'mini-loops');?>)</small>
     103                    foreach ( $obs as $v ) {
     104                        printf(
     105                            '<option value="%s" %s>%s</option>',
     106                            esc_attr( $v ),
     107                            selected( $v, $order, false ),
     108                            esc_html( $v )
     109                        );
     110                    }
     111                ?>
     112                </select>
     113                <small>(<?php esc_html_e('ABC vs ZYX', 'mini-loops');?>)</small>
    94114            </label>
    95115        </p>
    96116        <p style="clear:both;">
    97             <label for="<?php echo $this->get_field_id('order_meta_key'); ?>"><?php _e('*Meta key required for meta value ordering', 'mini-loops');?></label>
    98             <input type="text" class="widefat" id="<?php echo $this->get_field_id('order_meta_key'); ?>" name="<?php echo $this->get_field_name('order_meta_key'); ?>" value="<?php echo $order_meta_key; ?>" />
     117            <label for="<?php echo esc_attr( $this->get_field_id('order_meta_key' ) ); ?>"><?php esc_html_e('*Meta key required for meta value ordering', 'mini-loops');?></label>
     118            <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('order_meta_key' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order_meta_key' ) ); ?>" value="<?php echo esc_attr( $order_meta_key ); ?>" />
    99119        </p>
    100120        <p style="clear:both;">
    101             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('reverse_order'); ?>" name="<?php echo $this->get_field_name('reverse_order'); ?>"<?php checked( $reverse_order ); ?> />
    102             <label for="<?php echo $this->get_field_id('reverse_order'); ?>"><?php _e('Show posts in reverse order?', 'mini-loops');?></label>
    103             <small>(<?php _e('ABC vs CBA', 'mini-loops');?>)</small>
    104         </p>
    105         <p>
    106             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('shuffle_order'); ?>" name="<?php echo $this->get_field_name('shuffle_order'); ?>"<?php checked( $shuffle_order ); ?> />
    107             <label for="<?php echo $this->get_field_id('shuffle_order'); ?>"><?php _e('Shuffle post order?', 'mini-loops');?></label>
    108             <small>(<?php _e('ABC vs BCA', 'mini-loops');?>)</small>
    109         </p>
    110         <p style="width:48%;float:left;">
    111             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('ignore_sticky'); ?>" name="<?php echo $this->get_field_name('ignore_sticky'); ?>"<?php checked( $ignore_sticky ); ?> />
    112             <label for="<?php echo $this->get_field_id('ignore_sticky'); ?>"><?php _e('Unstick sticky posts?', 'mini-loops');?></label>
    113         </p>
    114         <p style="width:48%;float:right;">
    115             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('only_sticky'); ?>" name="<?php echo $this->get_field_name('only_sticky'); ?>"<?php checked( $only_sticky ); ?> />
    116             <label for="<?php echo $this->get_field_id('only_sticky'); ?>"><?php _e('Only sticky posts?', 'mini-loops');?></label>
    117         </p>
    118         <p style="width:48%;float:left;">
    119             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('exclude_sticky'); ?>" name="<?php echo $this->get_field_name('exclude_sticky'); ?>"<?php checked( $exclude_sticky ); ?> />
    120             <label for="<?php echo $this->get_field_id('exclude_sticky'); ?>"><?php _e('Exclude sticky posts?', 'mini-loops');?></label>
    121         </p>
    122         <p style="clear:both;"><small><?php _e( '"Only" will take precedence if both sticky options are checked.', 'mini-loops' ); ?></small></p>
    123         <p>
    124             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('exclude_current'); ?>" name="<?php echo $this->get_field_name('exclude_current'); ?>"<?php checked( $exclude_current ); ?> />
    125             <label for="<?php echo $this->get_field_id('exclude_current'); ?>"><?php _e('If viewing a single post, exclude it?', 'mini-loops');?></label>
    126         </p>
    127         <p style="clear:both;"><small><?php _e( 'This option is ignored if "Only sticky" is checked.', 'mini-loops' ); ?></small></p>
    128         <p>
    129             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_category'); ?>" name="<?php echo $this->get_field_name('current_category'); ?>"<?php checked( $current_category ); ?> />
    130             <label for="<?php echo $this->get_field_id('current_category'); ?>"><?php _e('Get posts from current category (if archive)?', 'mini-loops');?></label>
    131         </p>
    132         <p>
    133             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_single_category'); ?>" name="<?php echo $this->get_field_name('current_single_category'); ?>"<?php checked( $current_single_category ); ?> />
    134             <label for="<?php echo $this->get_field_id('current_single_category'); ?>"><?php _e('Get posts from first category (if single)?', 'mini-loops');?></label>
    135         </p>
    136         <p>
    137             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_author'); ?>" name="<?php echo $this->get_field_name('current_author'); ?>"<?php checked( $current_author ); ?> />
    138             <label for="<?php echo $this->get_field_id('current_author'); ?>"><?php _e('Get posts from current author (if single or archive)?', 'mini-loops');?></label>
     121            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('reverse_order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('reverse_order' ) ); ?>"<?php checked( $reverse_order ); ?> />
     122            <label for="<?php echo esc_attr( $this->get_field_id('reverse_order' ) ); ?>"><?php esc_html_e('Show posts in reverse order?', 'mini-loops');?></label>
     123            <small>(<?php esc_html_e('ABC vs CBA', 'mini-loops');?>)</small>
     124        </p>
     125        <p>
     126            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('shuffle_order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('shuffle_order' ) ); ?>"<?php checked( $shuffle_order ); ?> />
     127            <label for="<?php echo esc_attr( $this->get_field_id('shuffle_order' ) ); ?>"><?php esc_html_e('Shuffle post order?', 'mini-loops');?></label>
     128            <small>(<?php esc_html_e('ABC vs BCA', 'mini-loops');?>)</small>
     129        </p>
     130        <p style="width:48%;float:left;">
     131            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('ignore_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('ignore_sticky' ) ); ?>"<?php checked( $ignore_sticky ); ?> />
     132            <label for="<?php echo esc_attr( $this->get_field_id('ignore_sticky' ) ); ?>"><?php esc_html_e('Unstick sticky posts?', 'mini-loops');?></label>
     133        </p>
     134        <p style="width:48%;float:right;">
     135            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('only_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('only_sticky' ) ); ?>"<?php checked( $only_sticky ); ?> />
     136            <label for="<?php echo esc_attr( $this->get_field_id('only_sticky' ) ); ?>"><?php esc_html_e('Only sticky posts?', 'mini-loops');?></label>
     137        </p>
     138        <p style="width:48%;float:left;">
     139            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('exclude_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude_sticky' ) ); ?>"<?php checked( $exclude_sticky ); ?> />
     140            <label for="<?php echo esc_attr( $this->get_field_id('exclude_sticky' ) ); ?>"><?php esc_html_e('Exclude sticky posts?', 'mini-loops');?></label>
     141        </p>
     142        <p style="clear:both;"><small><?php esc_html_e( '"Only" will take precedence if both sticky options are checked.', 'mini-loops' ); ?></small></p>
     143        <p>
     144            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('exclude_current' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude_current' ) ); ?>"<?php checked( $exclude_current ); ?> />
     145            <label for="<?php echo esc_attr( $this->get_field_id('exclude_current' ) ); ?>"><?php esc_html_e('If viewing a single post, exclude it?', 'mini-loops');?></label>
     146        </p>
     147        <p style="clear:both;"><small><?php esc_html_e( 'This option is ignored if "Only sticky" is checked.', 'mini-loops' ); ?></small></p>
     148        <p>
     149            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_category' ) ); ?>"<?php checked( $current_category ); ?> />
     150            <label for="<?php echo esc_attr( $this->get_field_id('current_category' ) ); ?>"><?php esc_html_e('Get posts from current category (if archive)?', 'mini-loops');?></label>
     151        </p>
     152        <p>
     153            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_single_category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_single_category' ) ); ?>"<?php checked( $current_single_category ); ?> />
     154            <label for="<?php echo esc_attr( $this->get_field_id('current_single_category' ) ); ?>"><?php esc_html_e('Get posts from first category (if single)?', 'mini-loops');?></label>
     155        </p>
     156        <p>
     157            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_author' ) ); ?>"<?php checked( $current_author ); ?> />
     158            <label for="<?php echo esc_attr( $this->get_field_id('current_author' ) ); ?>"><?php esc_html_e('Get posts from current author (if single or archive)?', 'mini-loops');?></label>
    139159        </p>
    140160
     
    144164
    145165        <p style="width:48%;float:left;">
    146             <label for="<?php echo $this->get_field_id('categories'); ?>"><?php _e('Categories:', 'mini-loops');?>
    147                 <input class="widefat" id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" type="text" value="<?php echo $categories; ?>" /><br />
    148                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
    149             </label>
    150         </p>
    151         <p style="width:48%;float:right;">
    152             <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Tags:', 'mini-loops');?>
    153                 <input class="widefat" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" type="text" value="<?php echo $tags; ?>" /><br />
    154                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
    155             </label>
    156         </p>
    157             <label for="<?php echo $this->get_field_id('tax'); ?>"><?php _e('Custom Taxonomies:', 'mini-loops');?>
    158                 <input class="widefat" id="<?php echo $this->get_field_id('tax'); ?>" name="<?php echo $this->get_field_name('tax'); ?>" type="text" value="<?php echo $tax; ?>" /><br />
    159                 <small>(<?php _e('Ex: category=1,2,4&amp;post_tag=6,12', 'mini-loops');?><br />
    160                         <?php _e('Available: ', 'mini-loops'); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?>)</small>
    161             </label>
    162         </p>
    163         <p>
    164             <label for="<?php echo $this->get_field_id('custom_fields'); ?>"><?php _e('Custom Fields:', 'mini-loops');?>
    165                 <input class="widefat" id="<?php echo $this->get_field_id('custom_fields'); ?>" name="<?php echo $this->get_field_name('custom_fields'); ?>" type="text" value="<?php echo $custom_fields; ?>" /><br />
    166                 <small>(<?php _e('Ex: meta_key=meta_value&amp;meta_key2=meta_value2', 'mini-loops');?>)</small>
    167             </label>
    168         </p>
    169         <p>
    170             <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e('Exclude Posts:', 'mini-loops');?>
    171                 <input class="widefat" id="<?php echo $this->get_field_id('exclude'); ?>" name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $exclude; ?>" /><br />
    172                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>)</small>
    173             </label>
    174         </p>
    175         <h3 style="clear:both;"><?php _e( 'Format', 'mini-loops' ); ?></h3>
    176         <p style="width:48%;float:left;">
    177             <label for="<?php echo $this->get_field_id('before_items'); ?>"><?php _e('Before Item:', 'mini-loops');?>
    178                 <?php /*<input class="widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $before_items ) ); ?>" />*/?>
    179                 <textarea class="widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>"><?php echo htmlspecialchars( stripslashes( $before_items ) ); ?></textarea>
    180             </label>
    181         </p>
    182         <p style="width:48%;float:right;">
    183             <label for="<?php echo $this->get_field_id('after_items'); ?>"><?php _e('After Item:', 'mini-loops');?>
    184                 <?php /*<input class="widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $after_items ) ); ?>" />*/?>
    185                 <textarea class="widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>"><?php echo htmlspecialchars( stripslashes( $after_items ) ); ?></textarea>
    186             </label>
    187         </p>
    188         <p>
    189             <label for="<?php echo $this->get_field_id('item_format'); ?>"><?php _e('Item Format:', 'mini-loops');?>
    190                 <textarea class="widefat" rows="5" id="<?php echo $this->get_field_id('item_format'); ?>" name="<?php echo $this->get_field_name('item_format'); ?>"><?php echo stripslashes( $item_format ); ?></textarea>
    191             </label>
    192             <small><em><a href="http://wordpress.org/extend/plugins/mini-loops/other_notes/"><?php _e('See an explanation of options.', 'mini-loops');?></a></em></small>
     166            <label for="<?php echo esc_attr( $this->get_field_id( 'categories' ) ); ?>"><?php esc_html_e('Categories:', 'mini-loops');?>
     167                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('categories' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('categories' ) ); ?>" type="text" value="<?php echo esc_attr( $categories ); ?>" /><br />
     168                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
     169            </label>
     170        </p>
     171        <p style="width:48%;float:right;">
     172            <label for="<?php echo esc_attr( $this->get_field_id( 'tags' ) ); ?>"><?php esc_html_e('Tags:', 'mini-loops');?>
     173                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('tags' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('tags' ) ); ?>" type="text" value="<?php echo esc_attr( $tags ); ?>" /><br />
     174                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
     175            </label>
     176        </p>
     177            <label for="<?php echo esc_attr( $this->get_field_id( 'tax' ) ); ?>"><?php esc_html_e('Custom Taxonomies:', 'mini-loops');?>
     178                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('tax' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('tax' ) ); ?>" type="text" value="<?php echo esc_attr( $tax ); ?>" /><br />
     179                <small>(<?php esc_html_e('Ex: category=1,2,4&amp;post_tag=6,12', 'mini-loops');?><br />
     180                        <?php
     181                        $taxonomy_names = get_taxonomies( array( 'public' => true ) );
     182                        printf(
     183                            esc_html('Available: %', 'mini-loops'),
     184                            implode( ', ', array_map( 'esc_html', $taxonomy_names ) )
     185                        ); ?>)</small>
     186            </label>
     187        </p>
     188        <p>
     189            <label for="<?php echo esc_attr( $this->get_field_id('custom_fields' ) ); ?>"><?php esc_html_e('Custom Fields:', 'mini-loops');?>
     190                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('custom_fields' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('custom_fields' ) ); ?>" type="text" value="<?php echo esc_attr( $custom_fields ); ?>" /><br />
     191                <small>(<?php esc_html_e('Ex: meta_key=meta_value&amp;meta_key2=meta_value2', 'mini-loops');?>)</small>
     192            </label>
     193        </p>
     194        <p>
     195            <label for="<?php echo esc_attr( $this->get_field_id('exclude' ) ); ?>"><?php esc_html_e('Exclude Posts:', 'mini-loops');?>
     196                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude' ) ); ?>" type="text" value="<?php echo esc_attr( $exclude ); ?>" /><br />
     197                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>)</small>
     198            </label>
     199        </p>
     200        <h3 style="clear:both;"><?php esc_html_e( 'Format', 'mini-loops' ); ?></h3>
     201        <p style="width:48%;float:left;">
     202            <label for="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>"><?php esc_html_e('Before Item:', 'mini-loops');?>
     203                <?php /*<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items' ) ); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $before_items ) ); ?>" />*/?>
     204                <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items' ) ); ?>"><?php echo esc_textarea( stripslashes( $before_items ) ); ?></textarea>
     205            </label>
     206        </p>
     207        <p style="width:48%;float:right;">
     208            <label for="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>"><?php esc_html_e('After Item:', 'mini-loops');?>
     209                <?php /*<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items' ) ); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $after_items ) ); ?>" />*/?>
     210                <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items' ) ); ?>"><?php echo esc_textarea( stripslashes( $after_items ) ); ?></textarea>
     211            </label>
     212        </p>
     213        <p>
     214            <label for="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>"><?php esc_html_e('Item Format:', 'mini-loops');?>
     215                <textarea class="widefat" rows="5" id="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('item_format' ) ); ?>"><?php echo esc_textarea( $item_format ); ?></textarea>
     216            </label>
     217            <small><em><a href="http://wordpress.org/extend/plugins/mini-loops/other_notes/"><?php esc_html_e('See an explanation of options.', 'mini-loops');?></a></em></small>
    193218        </p>
    194219
  • mini-loops/tags/1.4/helpers.php

    r976219 r2546965  
    22if ( ! defined( 'ABSPATH' ) ) die( '-1' );
    33
    4 // Show recent posts function
     4/**
     5 * Get default parameters
     6 *
     7 * @return array
     8 */
    59function get_miniloops_defaults() {
    610    $defs = array(
     
    3943}
    4044
     45/**
     46 * get_miniloops
     47 *
     48 * @param array $args
     49 * @return string
     50 */
    4151function get_miniloops( $args = '' ) {
    42     global $wpdb, $post;
     52    global $post;
    4353    $defaults = get_miniloops_defaults();
    4454
     
    153163    if ( $maximum_age != 0 ) {
    154164        global $mini_loops_minimum_date;
    155         $mini_loops_minimum_date = date( 'Y-m-d', time() - ( $maximum_age * 24 * 60 * 60 ) );
     165        $mini_loops_minimum_date = gmdate( 'Y-m-d', time() - ( $maximum_age * 24 * 60 * 60 ) );
    156166        $maximum_age_func = create_function('$filter','global $mini_loops_minimum_date; $filter .= " AND post_date >= \'' . $mini_loops_minimum_date .'\'"; return $filter;');
    157167        add_filter( 'posts_where', $maximum_age_func );
     
    182192        $before_items = do_shortcode( miniloops_shortcoder( stripslashes( $before_items ) ) );
    183193        $before_items = apply_filters( 'miniloops_before_items_format', $before_items, $query, $miniloop, $args );
     194
    184195        $postlist .= $before_items;
    185196
     
    188199
    189200            $post_format = current_theme_supports('post-formats') ? get_post_format( get_the_ID() ) : 'standard';
     201
     202            // decodes shortcode brackets
     203            $item_format = html_entity_decode( $item_format );
    190204
    191205            $item_format_to_use = apply_filters( 'miniloops_item_format', $item_format, $post_format );
     
    208222    return $postlist;
    209223}
     224
     225/**
     226 * miniloops
     227 */
    210228function miniloops( $params ) {
    211     echo get_miniloops( $params );
    212 }
    213 
     229    echo wp_kses_post( get_miniloops( $params ) );
     230}
     231
     232/**
     233 * miniloops_shortcoder
     234 *
     235 * @param string $input
     236 * @return string
     237 */
    214238function miniloops_shortcoder( $input ) {
    215239
     
    238262}
    239263
    240     function miniloops_shortcode_finder( $shortcode ) {
    241         if ( substr( $shortcode, 0, 3 ) == 'ml_' ) {
    242             return true;
    243         }
    244         return false;
    245     }
    246     function miniloops_shortcode_filter( $shortcode ) {
    247         return substr( $shortcode, 3 );
    248     }
    249 
     264/**
     265 * miniloops_shortcode_finder
     266 *
     267 * @param string $shortcode
     268 * @return bool
     269 */
     270function miniloops_shortcode_finder( $shortcode ) {
     271    if ( substr( $shortcode, 0, 3 ) == 'ml_' ) {
     272        return true;
     273    }
     274    return false;
     275}
     276
     277/**
     278 * miniloops_shortcode_filter
     279 *
     280 * @param string $shortcode
     281 * @return string
     282 */
     283function miniloops_shortcode_filter( $shortcode ) {
     284    return substr( $shortcode, 3 );
     285}
     286
     287/**
     288 * miniloops_word_excerpt
     289 *
     290 * @param string $input
     291 * @param int    $limit
     292 * @return string
     293 */
    250294function miniloops_word_excerpt( $input, $limit ) {
    251295    $input = explode( ' ', $input );
    252     $input = array_splice( $input, 0, $limit );
     296    $input = array_splice( $input, 0, (int) $limit );
    253297    return trim( implode( ' ', $input ) );
    254298}
    255299
    256 /*
    257 
    258     shortcode for posts and pages
    259 
    260 */
    261 add_shortcode( 'miniloops' , 'get_miniloops_sc');
    262 add_shortcode( 'miniloop' , 'get_miniloops_sc');
     300/**
     301 * shortcode for posts and pages
     302 *
     303 * @param array $atts
     304 * @param string $content
     305 * @return string
     306 */
    263307function get_miniloops_sc( $atts, $content ) {
    264     $content = str_replace( '{', '[', str_replace('}', ']', $content ) );
     308
     309    $content = str_replace(
     310        [ '{', '}' ],
     311        [ '[', ']' ],
     312        $content
     313    );
     314
    265315    if ( strpos( $content, '[ml_format' ) !== false ) {
    266316        $atts['item_format'] = do_shortcode( $content );
    267317    } elseif ( ! empty( $content) ) {
    268         $atts['item_format'] = $content;
     318        $content = ltrim( $content, '</p>' );
     319        $content = rtrim( $content, '<p>' );
     320        $atts['item_format'] = miniloops_straighten_quote( $content );
    269321    }
    270322    $args = shortcode_atts( get_miniloops_defaults(), $atts );
     
    273325}
    274326
    275 /*
    276 
    277     shortcodes for use in the Item Format
    278     (but in fact can be used anywhere)
    279 
    280 */
     327/**
     328 * @link https://stackoverflow.com/a/21491305
     329 * @param string $input
     330 * @return string
     331 */
     332function miniloops_straighten_quote( $input ) {
     333    $chr_map = array(
     334        // Windows codepage 1252
     335        "\xC2\x82" => "'", // U+0082⇒U+201A single low-9 quotation mark
     336        "\xC2\x84" => '"', // U+0084⇒U+201E double low-9 quotation mark
     337        "\xC2\x8B" => "'", // U+008B⇒U+2039 single left-pointing angle quotation mark
     338        "\xC2\x91" => "'", // U+0091⇒U+2018 left single quotation mark
     339        "\xC2\x92" => "'", // U+0092⇒U+2019 right single quotation mark
     340        "\xC2\x93" => '"', // U+0093⇒U+201C left double quotation mark
     341        "\xC2\x94" => '"', // U+0094⇒U+201D right double quotation mark
     342        "\xC2\x9B" => "'", // U+009B⇒U+203A single right-pointing angle quotation mark
     343
     344        // Regular Unicode     // U+0022 quotation mark (")
     345                               // U+0027 apostrophe     (')
     346        "\xC2\xAB"     => '"', // U+00AB left-pointing double angle quotation mark
     347        "\xC2\xBB"     => '"', // U+00BB right-pointing double angle quotation mark
     348        "\xE2\x80\x98" => "'", // U+2018 left single quotation mark
     349        "\xE2\x80\x99" => "'", // U+2019 right single quotation mark
     350        "\xE2\x80\x9A" => "'", // U+201A single low-9 quotation mark
     351        "\xE2\x80\x9B" => "'", // U+201B single high-reversed-9 quotation mark
     352        "\xE2\x80\x9C" => '"', // U+201C left double quotation mark
     353        "\xE2\x80\x9D" => '"', // U+201D right double quotation mark
     354        "\xE2\x80\x9E" => '"', // U+201E double low-9 quotation mark
     355        "\xE2\x80\x9F" => '"', // U+201F double high-reversed-9 quotation mark
     356        "\xE2\x80\xB9" => "'", // U+2039 single left-pointing angle quotation mark
     357        "\xE2\x80\xBA" => "'", // U+203A single right-pointing angle quotation mark
     358    );
     359    $chr = array_keys( $chr_map ); // but: for efficiency you should
     360    $rpl = array_values( $chr_map ); // pre-calculate these two arrays
     361    $output = str_replace( $chr, $rpl, html_entity_decode( $input, ENT_QUOTES, "UTF-8" ) );
     362    return $output;
     363}
     364
     365/**
     366 * shortcodes for use in the Item Format
     367 * (but in fact can be used anywhere)
     368 */
     369add_shortcode( 'miniloops' , 'get_miniloops_sc');
     370add_shortcode( 'miniloop' , 'get_miniloops_sc');
    281371add_shortcode( 'ml_format' , 'miniloop_item_format' );
    282 function miniloop_item_format( $atts, $content ) {
     372add_shortcode( 'ml_title' , 'miniloop_title' );
     373add_shortcode( 'ml_url' , 'miniloop_url' );
     374add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' );
     375add_shortcode( 'ml_content' , 'miniloop_content' );
     376add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' );
     377add_shortcode( 'ml_author' , 'miniloop_author' );
     378add_shortcode( 'ml_author_link' , 'miniloop_author_link' );
     379add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' );
     380add_shortcode( 'ml_field' , 'miniloop_field' );
     381add_shortcode( 'ml_category' , 'miniloop_category' );
     382add_shortcode( 'ml_tag' , 'miniloop_tag' );
     383add_shortcode( 'ml_tax' , 'miniloop_taxonomy' );
     384add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' );
     385add_shortcode( 'ml_date' , 'miniloop_date' );
     386add_shortcode( 'ml_post_type', 'miniloop_post_type' );
     387add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' );
     388add_shortcode( 'ml_class' , 'miniloop_class' );
     389add_shortcode( 'ml_image' , 'miniloop_image' );
     390
     391/**
     392 * miniloop_item_format
     393 * shortcode callback
     394 *
     395 * @param array $atts
     396 * @return string
     397 */
     398function miniloop_item_format( $atts ) {
    283399    extract( shortcode_atts( array(
    284400        'name' => 'ml_format',
     
    287403}
    288404
    289 add_shortcode( 'ml_title' , 'miniloop_title' );
     405/**
     406 * miniloop_title
     407 * shortcode callback
     408 *
     409 * @param array $atts
     410 * @return string
     411 */
    290412function miniloop_title( $atts ) {
    291413    extract( shortcode_atts( array(
     
    311433}
    312434
    313 add_shortcode( 'ml_url' , 'miniloop_url' );
     435/**
     436 * miniloop_url
     437 * shortcode callback
     438 *
     439 * @param array $atts
     440 * @return string
     441 */
    314442function miniloop_url( $atts ) {
    315443    extract( shortcode_atts( array(
     
    329457}
    330458
    331 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' );
     459/**
     460 * miniloop_excerpt
     461 * shortcode callback
     462 *
     463 * @param array $atts
     464 * @return string
     465 */
    332466function miniloop_excerpt( $atts ) {
    333467    extract( shortcode_atts( array(
     
    410544}
    411545
    412 add_shortcode( 'ml_content' , 'miniloop_content' );
     546/**
     547 * miniloop_content
     548 * shortcode callback
     549 *
     550 * @param array $atts
     551 * @return string
     552 */
    413553function miniloop_content( $atts ) {
    414554    extract( shortcode_atts( array(
     
    424564}
    425565
    426 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' );
     566/**
     567 * miniloop_comment_count
     568 * shortcode callback
     569 *
     570 * @return string
     571 */
    427572function miniloop_comment_count() {
    428573    $count = get_comment_count( get_the_ID() );
     
    431576}
    432577
    433 add_shortcode( 'ml_author' , 'miniloop_author' );
     578/**
     579 * miniloop_author
     580 * shortcode callback
     581 *
     582 * @return string
     583 */
    434584function miniloop_author() {
    435585
     
    437587}
    438588
    439 add_shortcode( 'ml_author_link' , 'miniloop_author_link' );
     589/**
     590 * miniloop_author_link
     591 * shortcode callback
     592 *
     593 * @return string
     594 */
    440595function miniloop_author_link() {
    441596
     
    443598}
    444599
    445 add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' );
     600/**
     601 * miniloop_author_avatar
     602 * shortcode callback
     603 *
     604 * @param array $atts
     605 * @return string
     606 */
    446607function miniloop_author_avatar( $atts ) {
    447608    extract( shortcode_atts( array(
     
    455616}
    456617
    457 add_shortcode( 'ml_field' , 'miniloop_field' );
     618/**
     619 * miniloop_field
     620 * shortcode callback
     621 *
     622 * @param array $atts
     623 * @return string
     624 */
    458625function miniloop_field( $atts ) {
    459626    extract( shortcode_atts( array(
     
    479646}
    480647
    481 add_shortcode( 'ml_category' , 'miniloop_category' );
     648/**
     649 * miniloop_category
     650 * shortcode callback
     651 *
     652 * @param array $atts
     653 * @return string
     654 */
    482655function miniloop_category( $atts ) {
    483656    $atts = shortcode_atts( array(
     
    492665}
    493666
    494 add_shortcode( 'ml_tag' , 'miniloop_tag' );
     667/**
     668 * miniloop_tag
     669 * shortcode callback
     670 *
     671 * @param array $atts
     672 * @return string
     673 */
    495674function miniloop_tag( $atts ) {
    496675    $atts = shortcode_atts( array(
     
    505684}
    506685
    507 add_shortcode( 'ml_tax' , 'miniloop_taxonomy' );
    508 add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' );
     686/**
     687 * miniloop_taxonomy
     688 * shortcode callback
     689 *
     690 * @param array $atts
     691 * @return string
     692 */
    509693function miniloop_taxonomy( $atts ) {
    510694    extract( shortcode_atts( array(
     
    532716}
    533717
    534 // BETA - not fully tested, may not work under some conditions
    535 // 'ba' prefix for 'before/after' - special hackish use
    536 add_shortcode( 'ba_archive' , 'miniloop_archive' );
     718/**
     719 * miniloop_archive
     720 * shortcode callback
     721 *
     722 * BETA - not fully tested, may not work under some conditions
     723 * 'ba' prefix for 'before/after' - special hackish use
     724 *
     725 * @param array $atts
     726 * @return string
     727 */
    537728function miniloop_archive( $atts ) {
    538729    extract( shortcode_atts( array(
     
    543734    return "{$before}##replace|archive##{$after}";
    544735}
     736add_shortcode( 'ba_archive' , 'miniloop_archive' );
     737
    545738// For use with the BETA [ba_archive] shortcode
    546739add_filter( 'miniloops_before_items_format', 'ml_hackish_filter', 10, 3 );
    547740add_filter( 'miniloops_after_items_format', 'ml_hackish_filter', 10, 3 );
     741
     742/**
     743 * ml_hackish_filter
     744 *
     745 * @param string $before_items
     746 * @param mixed $query
     747 * @param object $miniloop
     748 * @return string
     749 */
    548750function ml_hackish_filter( $before_items, $query, $miniloop ) {
    549751    // if there is nothing to replace, carry on...
     
    569771}
    570772
    571 add_shortcode( 'ml_date' , 'miniloop_date' );
     773/**
     774 * miniloop_date
     775 * shortcode callback
     776 *
     777 * @param array $atts
     778 * @return string
     779 */
    572780function miniloop_date( $atts ) {
    573781    extract( shortcode_atts( array(
     
    579787}
    580788
    581 add_shortcode( 'ml_post_type', 'miniloop_post_type' );
     789/**
     790 * miniloop_post_type
     791 * shortcode callback
     792 *
     793 * @param array $atts
     794 * @return string
     795 */
    582796function miniloop_post_type( $atts ) {
    583797    extract( shortcode_atts( array(
     
    590804}
    591805
    592 add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' );
     806/**
     807 * miniloop_post_type_archive_link
     808 * shortcode callback
     809 *
     810 * @param array $atts
     811 * @return string
     812 */
    593813function miniloop_post_type_archive_link( $atts ) {
    594814    extract( shortcode_atts( array(
     
    599819}
    600820
    601 add_shortcode( 'ml_class' , 'miniloop_class' );
     821/**
     822 * miniloop_class
     823 * shortcode callback
     824 *
     825 * @param array $atts
     826 * @return string
     827 */
    602828function miniloop_class( $atts ) {
    603829    extract( shortcode_atts( array(
     
    613839}
    614840
    615 add_shortcode( 'ml_image' , 'miniloop_image' );
     841/**
     842 * miniloop_image
     843 * shortcode callback
     844 *
     845 * @param array $atts
     846 * @return string
     847 */
    616848function miniloop_image( $atts ) {
    617849    extract( shortcode_atts( array(
     
    636868
    637869    $crop = (bool) $crop;
    638 
    639870    foreach( $from as $from_where ) {
    640871    switch ( $from_where ) {
    641872        case 'thumb' :
    642 
    643873            if ( 'clear' == $cache ) {
    644874                miniloops_clear_thumbnail_cache( get_the_ID() );
     
    8021032}
    8031033
     1034/**
     1035 * miniloops_create_thumbnail_from_id
     1036 *
     1037 * @param int $att_id
     1038 * @param int $width
     1039 * @param int $height
     1040 * @param bool $crop
     1041 * @return string
     1042 */
    8041043function miniloops_create_thumbnail_from_id( $att_id, $width, $height, $crop ) {
    8051044    $upl = wp_upload_dir();
     
    8101049}
    8111050
     1051/**
     1052 * miniloops_create_thumbnail_from_path
     1053 *
     1054 * @param string $file
     1055 * @param int $width
     1056 * @param int $height
     1057 * @param bool $crop
     1058 * @return string
     1059 */
    8121060function miniloops_create_thumbnail_from_path( $file, $width, $height, $crop ) {
    8131061    $upl = wp_upload_dir();
    814     // deprecated method
    815     // $new = image_resize( $file, $width, $height, true, "ml-{$width}x{$height}" );
    816     // if ( is_wp_error( $new ) )
    817     //  //if the image could not be resized, return the original url
    818     //  return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    819     // return str_replace( $upl['basedir'], $upl['baseurl'], $new );
    820 
    821     // robbed from the depracted image_resize() function
     1062
     1063    // robbed from the deprecated image_resize() function
    8221064    $editor = wp_get_image_editor( $file );
    8231065    if ( is_wp_error( $editor ) ) {
    824         // return $editor;
    8251066        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8261067    }
     
    8291070    $resized = $editor->resize( $width, $height, $crop );
    8301071    if ( is_wp_error( $resized ) ) {
    831         // return $resized;
    8321072        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8331073    }
     
    8371077
    8381078    if ( is_wp_error( $saved ) ) {
    839         // return $saved;
    8401079        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8411080    }
     
    8451084}
    8461085
     1086/**
     1087 * miniloops_clear_thumbnail_cache
     1088 *
     1089 * @param int $post_id
     1090 */
    8471091function miniloops_clear_thumbnail_cache( $post_id ) {
    8481092    delete_post_meta( $post_id, '_ml_thumb_thumb' );
     
    8521096/**
    8531097 * Automatically clear the thumbnail cache for the post whenever its featured image is deleted or changed
     1098 *
     1099 * @param int $meta_ids
     1100 * @param int $object_id
     1101 * @param string $meta_key
     1102 * @param string $_meta_value
    8541103 */
    8551104function miniloops_updated_deleted_post_meta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
  • mini-loops/tags/1.4/mini-loops.php

    r1346549 r2546965  
    55Plugin URI: http://trepmal.com/plugins/mini-loops/
    66Description: Query posts and display them where you want
    7 Version: 1.3.1
     7Version: 1.4
    88Author: Kailey Lampert
    99Author URI: http://kaileylampert.com
    1010
    11 Copyright (C) 2011-16 Kailey Lampert
     11Copyright (C) 2011-21 Kailey Lampert
    1212
    1313This program is free software: you can redistribute it and/or modify
  • mini-loops/tags/1.4/readme.txt

    r1346549 r2546965  
    44Donate link: http://kaileylampert.com/donate/
    55Requires at least: 3.5
    6 Tested up to: 4.4
    7 Stable tag: 1.3.1
     6Tested up to: 5.7
     7Stable tag: 1.4
    88License: GPLv2 or later
    99
     
    1515Show most recent posts, posts from categories, and more. Can be displayed via widgets, shortcodes, and template tags.
    1616
    17 This is a new release, please report bugs to trepmal (at) gmail (dot) com before leaving a poor review. Thanks
     17Development is now happening at the [GitHub Repo](https://github.com/trepmal/mini-loops)
    1818
    1919== Installation ==
     
    341341== Upgrade Notice ==
    342342
     343= 1.4 =
     344General updates, improved shortcode compat with the Block Editor.
     345
    343346= 1.3 =
    344347New: Automatically clear thumbnail cache and more. See Changelog
     
    372375
    373376== Changelog ==
     377
     378= Version 1.4 =
     379* General upkeep
    374380
    375381= Version 1.3.1 =
  • mini-loops/tags/1.4/widget.php

    r1346549 r2546965  
    44class miniloops extends WP_Widget {
    55
    6     function miniloops() {
     6    function __construct() {
    77        $widget_ops = array(
    88            'classname'   => 'miniloops',
     
    1616    function widget( $args, $instance ) {
    1717
    18         extract( $args, EXTR_SKIP );
     18         // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
    1919
    20         echo $before_widget;
     20        echo $args['before_widget'];
    2121        if ( ! $instance['hide_title'] ) {
    22             $title = apply_filters( 'widget_title', stripslashes( $instance['title'] ) );
    23             $title = empty( $instance['title_url'] ) ? $title : '<a href="'. esc_url( $instance['title_url'] ) .'">'. $title .'</a>';
    24             echo $before_title . $title . $after_title;
     22            $title = apply_filters( 'widget_title', $instance['title'] );
     23            $title = empty( $instance['title_url'] ) ? wp_kses_post( $title ) : '<a href="'. esc_url( $instance['title_url'] ) .'">'. wp_kses_post( $title ) .'</a>';
     24            echo $args['before_title'] . $title . $args['after_title'];
    2525        }
    2626
     
    2828        echo get_miniloops( $instance );
    2929
    30         echo $after_widget;
     30        echo $args['after_widget'];
     31
     32         // phpcs:enable
    3133
    3234    } //end widget()
     
    3638        $instance = $old_instance;
    3739        //get old variables
    38         $instance['title']                   = wp_filter_post_kses( $new_instance['title'] );
    39         $instance['hide_title']              = (bool) $new_instance['hide_title'] ? 1 : 0;
     40        $instance['title']                   = wp_kses_post( $new_instance['title'] );
     41        $instance['hide_title']              = (bool) isset( $new_instance['hide_title'] ) ? 1 : 0;
    4042        $instance['title_url']               = esc_url( $new_instance['title_url'] );
    4143        $instance['number_posts']            = (int) $new_instance['number_posts'];
     
    4749        $instance['order']                   = esc_attr( $new_instance['order'] );
    4850        $instance['order_meta_key']          = esc_attr( $new_instance['order_meta_key'] );
    49         $instance['reverse_order']           = (bool) $new_instance['reverse_order'] ? 1 : 0;
    50         $instance['shuffle_order']           = (bool) $new_instance['shuffle_order'] ? 1 : 0;
    51         $instance['ignore_sticky']           = (bool) $new_instance['ignore_sticky'] ? 1 : 0;
    52         $instance['only_sticky']             = (bool) $new_instance['only_sticky'] ? 1 : 0;
    53         $instance['exclude_sticky']          = (bool) $new_instance['exclude_sticky'] ? 1 : 0;
    54         $instance['exclude_current']         = (bool) $new_instance['exclude_current'] ? 1 : 0;
    55         $instance['current_category']        = (bool) $new_instance['current_category'] ? 1 : 0;
    56         $instance['current_single_category'] = (bool) $new_instance['current_single_category'] ? 1 : 0;
    57         $instance['current_author']          = (bool) $new_instance['current_author'] ? 1 : 0;
     51        $instance['reverse_order']           = (bool) isset( $new_instance['reverse_order'] ) ? 1 : 0;
     52        $instance['shuffle_order']           = (bool) isset( $new_instance['shuffle_order'] ) ? 1 : 0;
     53        $instance['ignore_sticky']           = (bool) isset( $new_instance['ignore_sticky'] ) ? 1 : 0;
     54        $instance['only_sticky']             = (bool) isset( $new_instance['only_sticky'] ) ? 1 : 0;
     55        $instance['exclude_sticky']          = (bool) isset( $new_instance['exclude_sticky'] ) ? 1 : 0;
     56        $instance['exclude_current']         = (bool) isset( $new_instance['exclude_current'] ) ? 1 : 0;
     57        $instance['current_category']        = (bool) isset( $new_instance['current_category'] ) ? 1 : 0;
     58        $instance['current_single_category'] = (bool) isset( $new_instance['current_single_category'] ) ? 1 : 0;
     59        $instance['current_author']          = (bool) isset( $new_instance['current_author'] ) ? 1 : 0;
    5860        $instance['categories']              = esc_attr( $new_instance['categories'] );
    5961        $instance['tags']                    = esc_attr( $new_instance['tags'] );
     
    6264        $instance['custom_fields']           = esc_attr( $new_instance['custom_fields'] );
    6365        $instance['exclude']                 = esc_attr( $new_instance['exclude'] );
    64         $instance['before_items']            = wp_filter_post_kses( $new_instance['before_items'] );
    65         $instance['item_format']             = wp_filter_post_kses( $new_instance['item_format'] );
    66         $instance['after_items']             = wp_filter_post_kses( $new_instance['after_items'] );
     66        $instance['before_items']            = wp_kses_post( $new_instance['before_items'] );
     67        $instance['item_format']             = wp_kses_post( $new_instance['item_format'] );
     68        $instance['after_items']             = wp_kses_post( $new_instance['after_items'] );
    6769
    6870        return $instance;
     
    8284class miniminiloops extends miniloops {
    8385
    84     function miniminiloops() {
     86    function __construct() {
    8587        $widget_ops = array(
    8688            'classname'   => 'miniminiloops',
     
    9799
    98100        ?>
    99         <p><?php _e( 'Back to basics. Just recent posts. No fuss.', 'mini-loops' ); ?></p>
     101        <p><?php esc_html_e( 'Back to basics. Just recent posts. No fuss.', 'mini-loops' ); ?></p>
    100102        <p style="width:63%;float:left;">
    101             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mini-loops' );?>
    102                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo stripslashes( $title ); ?>" />
     103            <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'mini-loops' );?>
     104                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    103105            </label>
    104106        </p>
    105107        <p style="width:33%;float:right;padding-top:20px;height:20px;">
    106             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_title'); ?>" name="<?php echo $this->get_field_name('hide_title'); ?>"<?php checked( $hide_title ); ?> />
    107             <label for="<?php echo $this->get_field_id('hide_title'); ?>"><?php _e('Hide Title?', 'mini-loops' );?></label>
     108            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('hide_title') ); ?>"<?php checked( $hide_title ); ?> />
     109            <label for="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>"><?php esc_html_e('Hide Title?', 'mini-loops' );?></label>
    108110        </p>
    109111        <p style="width:48%;float:left;">
    110             <label for="<?php echo $this->get_field_id( 'title_url' ); ?>"><?php _e( 'Title URL:', 'mini-loops' );?>
    111                 <input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="text" value="<?php echo $title_url; ?>" />
     112            <label for="<?php echo esc_attr( $this->get_field_id( 'title_url' )  ); ?>"><?php esc_html_e( 'Title URL:', 'mini-loops' );?>
     113                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('title_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title_url') ); ?>" type="text" value="<?php echo esc_attr( $title_url ); ?>" />
    112114            </label>
    113115        </p>
    114116        <p style="width:48%;float:right;">
    115             <label for="<?php echo $this->get_field_id('number_posts'); ?>"><?php _e('Number of Posts:', 'mini-loops' );?>
    116                 <input class="widefat" id="<?php echo $this->get_field_id('number_posts'); ?>" name="<?php echo $this->get_field_name('number_posts'); ?>" type="number" value="<?php echo $number_posts; ?>" />
     117            <label for="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>"><?php esc_html_e('Number of Posts:', 'mini-loops' );?>
     118                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('number_posts') ); ?>" type="number" value="<?php echo esc_attr( $number_posts ); ?>" />
    117119            </label>
    118120        </p>
    119         <input name="<?php echo $this->get_field_name('post_offset'); ?>" type="hidden" value="<?php echo $post_offset; ?>" />
    120         <input name="<?php echo $this->get_field_name('maximum_age'); ?>" type="hidden" value="<?php echo $maximum_age; ?>" />
    121         <input name="<?php echo $this->get_field_name('post_type'); ?>" type="hidden" value="<?php echo $post_type; ?>" />
    122         <input name="<?php echo $this->get_field_name('post_status'); ?>" type="hidden" value="<?php echo $post_status; ?>" />
    123         <input name="<?php echo $this->get_field_name('order_by'); ?>" type="hidden" value="<?php echo $order_by; ?>" />
    124         <input name="<?php echo $this->get_field_name('order'); ?>" type="hidden" value="<?php echo $order; ?>" />
    125         <input name="<?php echo $this->get_field_name('reverse_order'); ?>" type="hidden" value="<?php echo $reverse_order; ?>" />
    126         <input name="<?php echo $this->get_field_name('shuffle_order'); ?>" type="hidden" value="<?php echo $shuffle_order; ?>" />
    127         <input name="<?php echo $this->get_field_name('ignore_sticky'); ?>" type="hidden" value="<?php echo $ignore_sticky; ?>" />
    128         <input name="<?php echo $this->get_field_name('only_sticky'); ?>" type="hidden" value="<?php echo $only_sticky; ?>" />
    129         <input name="<?php echo $this->get_field_name('exclude_sticky'); ?>" type="hidden" value="<?php echo $exclude_sticky; ?>" />
    130         <input name="<?php echo $this->get_field_name('exclude_current'); ?>" type="hidden" value="<?php echo $exclude_current; ?>" />
    131         <input name="<?php echo $this->get_field_name('current_category'); ?>" type="hidden" value="<?php echo $current_category; ?>" />
    132         <input name="<?php echo $this->get_field_name('current_author'); ?>" type="hidden" value="<?php echo $current_author; ?>" />
    133         <input name="<?php echo $this->get_field_name('categories'); ?>" type="hidden" value="<?php echo $categories; ?>" />
    134         <input name="<?php echo $this->get_field_name('tags'); ?>" type="hidden" value="<?php echo $tags; ?>" />
    135         <input name="<?php echo $this->get_field_name('post_author'); ?>" type="hidden" value="<?php echo $post_author; ?>" />
    136         <input name="<?php echo $this->get_field_name('tax'); ?>" type="hidden" value="<?php echo $tax; ?>" />
    137         <input name="<?php echo $this->get_field_name('custom_fields'); ?>" type="hidden" value="<?php echo $custom_fields; ?>" />
    138         <input name="<?php echo $this->get_field_name('exclude'); ?>" type="hidden" value="<?php echo $exclude; ?>" />
    139         <textarea class="hidden widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>"><?php echo htmlspecialchars( stripslashes( $before_items ) ); ?></textarea>
    140         <textarea class="hidden widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>"><?php echo htmlspecialchars( stripslashes( $after_items ) ); ?></textarea>
    141         <textarea class="hidden widefat" rows="5" id="<?php echo $this->get_field_id('item_format'); ?>" name="<?php echo $this->get_field_name('item_format'); ?>"><?php echo stripslashes( $item_format ); ?></textarea>
     121        <input name="<?php echo esc_attr( $this->get_field_name('post_offset') ); ?>" type="hidden" value="<?php echo esc_attr( $post_offset ); ?>" />
     122        <input name="<?php echo esc_attr( $this->get_field_name('maximum_age') ); ?>" type="hidden" value="<?php echo esc_attr( $maximum_age ); ?>" />
     123        <input name="<?php echo esc_attr( $this->get_field_name('post_type') ); ?>" type="hidden" value="<?php echo esc_attr( $post_type ); ?>" />
     124        <input name="<?php echo esc_attr( $this->get_field_name('post_status') ); ?>" type="hidden" value="<?php echo esc_attr( $post_status ); ?>" />
     125        <input name="<?php echo esc_attr( $this->get_field_name('order_by') ); ?>" type="hidden" value="<?php echo esc_attr( $order_by ); ?>" />
     126        <input name="<?php echo esc_attr( $this->get_field_name('order') ); ?>" type="hidden" value="<?php echo esc_attr( $order ); ?>" />
     127        <input name="<?php echo esc_attr( $this->get_field_name('reverse_order') ); ?>" type="hidden" value="<?php echo esc_attr( $reverse_order ); ?>" />
     128        <input name="<?php echo esc_attr( $this->get_field_name('shuffle_order') ); ?>" type="hidden" value="<?php echo esc_attr( $shuffle_order ); ?>" />
     129        <input name="<?php echo esc_attr( $this->get_field_name('ignore_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $ignore_sticky ); ?>" />
     130        <input name="<?php echo esc_attr( $this->get_field_name('only_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $only_sticky ); ?>" />
     131        <input name="<?php echo esc_attr( $this->get_field_name('exclude_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude_sticky ); ?>" />
     132        <input name="<?php echo esc_attr( $this->get_field_name('exclude_current') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude_current ); ?>" />
     133        <input name="<?php echo esc_attr( $this->get_field_name('current_category') ); ?>" type="hidden" value="<?php echo esc_attr( $current_category ); ?>" />
     134        <input name="<?php echo esc_attr( $this->get_field_name('current_author') ); ?>" type="hidden" value="<?php echo esc_attr( $current_author ); ?>" />
     135        <input name="<?php echo esc_attr( $this->get_field_name('categories') ); ?>" type="hidden" value="<?php echo esc_attr( $categories ); ?>" />
     136        <input name="<?php echo esc_attr( $this->get_field_name('tags') ); ?>" type="hidden" value="<?php echo esc_attr( $tags ); ?>" />
     137        <input name="<?php echo esc_attr( $this->get_field_name('post_author') ); ?>" type="hidden" value="<?php echo esc_attr( $post_author ); ?>" />
     138        <input name="<?php echo esc_attr( $this->get_field_name('tax') ); ?>" type="hidden" value="<?php echo esc_attr( $tax ); ?>" />
     139        <input name="<?php echo esc_attr( $this->get_field_name('custom_fields') ); ?>" type="hidden" value="<?php echo esc_attr( $custom_fields ); ?>" />
     140        <input name="<?php echo esc_attr( $this->get_field_name('exclude') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude ); ?>" />
     141        <textarea class="hidden widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items') ); ?>"><?php echo esc_textarea( $before_items ); ?></textarea>
     142        <textarea class="hidden widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items') ); ?>"><?php echo esc_textarea( $after_items ); ?></textarea>
     143        <textarea class="hidden widefat" rows="5" id="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('item_format') ); ?>"><?php echo esc_textarea( $item_format ); ?></textarea>
    142144        <?php
    143145    } //end form()
  • mini-loops/trunk/form.php

    r976219 r2546965  
    11<?php if ( ! defined( 'ABSPATH' ) ) die( '-1' ); ?>
    22        <p style="width:40%;float:left;">
    3             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mini-loops' );?>
    4                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo stripslashes( $title ); ?>" />
     3            <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'mini-loops' );?>
     4                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    55            </label>
    66        </p>
    77        <p style="width:40%;margin-left:2%;float:left;">
    8             <label for="<?php echo $this->get_field_id( 'title_url' ); ?>"><?php _e( 'Title URL:', 'mini-loops' );?>
    9                 <input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="text" value="<?php echo $title_url; ?>" />
     8            <label for="<?php echo esc_attr( $this->get_field_id( 'title_url' )  ); ?>"><?php esc_html_e( 'Title URL:', 'mini-loops' );?>
     9                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title_url' ) ); ?>" type="text" value="<?php echo esc_attr( $title_url ); ?>" />
    1010            </label>
    1111        </p>
    1212        <p style="width:15%;margin-left:2%;float:left;padding-top:20px;height:20px;">
    13             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_title'); ?>" name="<?php echo $this->get_field_name('hide_title'); ?>"<?php checked( $hide_title ); ?> />
    14             <label for="<?php echo $this->get_field_id('hide_title'); ?>"><?php _e('Hide Title?', 'mini-loops' );?></label>
     13            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('hide_title' ) ); ?>"<?php checked( $hide_title ); ?> />
     14            <label for="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>"><?php esc_html_e('Hide Title?', 'mini-loops' );?></label>
    1515        </p>
    1616
     
    1919    <div style="width:48%;float:left;">
    2020
    21         <h3><?php _e( 'Query', 'mini-loops' ); ?></h3>
    22         <p style="width:48%;float:left;">
    23             <label for="<?php echo $this->get_field_id('number_posts'); ?>"><?php _e('Number of Posts:', 'mini-loops' );?>
    24                 <input class="widefat" id="<?php echo $this->get_field_id('number_posts'); ?>" name="<?php echo $this->get_field_name('number_posts'); ?>" type="number" value="<?php echo $number_posts; ?>" />
    25             </label>
    26         </p>
    27         <p style="width:48%;float:right;">
    28             <label for="<?php echo $this->get_field_id('post_offset'); ?>"><?php _e('Posts Offset:', 'mini-loops' );?>
    29                 <input class="widefat" id="<?php echo $this->get_field_id('post_offset'); ?>" name="<?php echo $this->get_field_name('post_offset'); ?>" type="number" value="<?php echo $post_offset; ?>" />
    30             </label>
    31         </p>
    32         <p style="width:48%;float:left;">
    33             <label for="<?php echo $this->get_field_id('maximum_age'); ?>"><?php _e('Maximum Age:', 'mini-loops' );?>
    34                 <input class="widefat" id="<?php echo $this->get_field_id('maximum_age'); ?>" name="<?php echo $this->get_field_name('maximum_age'); ?>" type="number" value="<?php echo $maximum_age; ?>" />
    35                 <small>(<?php _e('Only posts less than X days old.', 'mini-loops');?>) </small>
    36             </label>
    37         </p>
    38         <p style="width:48%;float:right;">
    39             <label for="<?php echo $this->get_field_id('post_author'); ?>"><?php _e('Author:', 'mini-loops');?>
    40                 <input class="widefat" id="<?php echo $this->get_field_id('post_author'); ?>" name="<?php echo $this->get_field_name('post_author'); ?>" type="text" value="<?php echo $post_author; ?>" /><br />
    41                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
     21        <h3><?php esc_html_e( 'Query', 'mini-loops' ); ?></h3>
     22        <p style="width:48%;float:left;">
     23            <label for="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>"><?php esc_html_e('Number of Posts:', 'mini-loops' );?>
     24                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('number_posts' ) ); ?>" type="number" value="<?php echo esc_attr( $number_posts ); ?>" />
     25            </label>
     26        </p>
     27        <p style="width:48%;float:right;">
     28            <label for="<?php echo esc_attr( $this->get_field_id('post_offset' ) ); ?>"><?php esc_html_e('Posts Offset:', 'mini-loops' );?>
     29                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_offset' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_offset' ) ); ?>" type="number" value="<?php echo esc_attr( $post_offset ); ?>" />
     30            </label>
     31        </p>
     32        <p style="width:48%;float:left;">
     33            <label for="<?php echo esc_attr( $this->get_field_id('maximum_age' ) ); ?>"><?php esc_html_e('Maximum Age:', 'mini-loops' );?>
     34                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('maximum_age' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('maximum_age' ) ); ?>" type="number" value="<?php echo esc_attr( $maximum_age ); ?>" />
     35                <small>(<?php esc_html_e('Only posts less than X days old.', 'mini-loops');?>) </small>
     36            </label>
     37        </p>
     38        <p style="width:48%;float:right;">
     39            <label for="<?php echo esc_attr( $this->get_field_id('post_author' ) ); ?>"><?php esc_html_e('Author:', 'mini-loops');?>
     40                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_author' ) ); ?>" type="text" value="<?php echo esc_attr( $post_author ); ?>" /><br />
     41                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
    4242            </label>
    4343        </p>
    4444        <p>
    4545        <p style="width:48%;float:left;clear:left;">
    46             <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'mini-loops' );?>
    47                 <select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>">
     46            <label for="<?php echo esc_attr( $this->get_field_id('post_type' ) ); ?>"><?php esc_html_e('Post Type:', 'mini-loops' );?>
     47                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_type' ) ); ?>">
    4848                <?php
    4949                    echo "<option value='any'" . selected( 'any', $post_type, false ) . ">Any</option>";
    5050                    $pts = get_post_types( array( 'public' => true ), 'objects' );
    51                     foreach($pts as $slug=>$obj) {
    52                         echo "<option value='{$slug}'" . selected( $slug, $post_type, false ) . ">{$obj->labels->name}</option>";
    53                     }
    54                 ?>
    55                 </select>
    56             </label>
    57         </p>
    58         <p style="width:48%;float:right;">
    59             <label for="<?php echo $this->get_field_id('post_status'); ?>"><?php _e('Post Status:', 'mini-loops' );?>
    60                 <select class="widefat" id="<?php echo $this->get_field_id('post_status'); ?>" name="<?php echo $this->get_field_name('post_status'); ?>">
     51                    foreach ( $pts as $slug => $obj ) {
     52                        printf(
     53                            '<option value="%s" %s>%s</option>',
     54                            esc_attr( $slug ),
     55                            selected( $slug, $post_type, false ),
     56                            esc_html( $obj->labels->name )
     57                        );
     58                    }
     59                ?>
     60                </select>
     61            </label>
     62        </p>
     63        <p style="width:48%;float:right;">
     64            <label for="<?php echo esc_attr( $this->get_field_id( 'post_status' ) ); ?>"><?php esc_html_e('Post Status:', 'mini-loops' );?>
     65                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_status' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_status' ) ); ?>">
    6166                <?php
    6267                    echo "<option value='any'" . selected( 'any', $post_status, false ) . ">Any</option>";
    6368                    $pss = get_available_post_statuses();
    64                     foreach($pss as $k=>$v) {
    65                         echo "<option value='{$v}'" . selected( $v, $post_status, false ) . ">{$v}</option>";
    66                     }
    67                 ?>
    68                 </select>
    69             </label>
    70         </p>
    71         <p style="width:48%;float:left;">
    72             <label for="<?php echo $this->get_field_id('order_by'); ?>"><?php _e('Order by:', 'mini-loops' );?>
    73                 <select class="widefat" id="<?php echo $this->get_field_id('order_by'); ?>" name="<?php echo $this->get_field_name('order_by'); ?>">
     69                    foreach ( $pss as $k => $v ) {
     70                        printf(
     71                            '<option value="%s" %s>%s</option>',
     72                            esc_attr( $v ),
     73                            selected( $v, $post_status, false ),
     74                            esc_html( $v )
     75                        );
     76                    }
     77                ?>
     78                </select>
     79            </label>
     80        </p>
     81        <p style="width:48%;float:left;">
     82            <label for="<?php echo esc_attr( $this->get_field_id('order_by' ) ); ?>"><?php esc_html_e('Order by:', 'mini-loops' );?>
     83                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('order_by' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order_by' ) ); ?>">
    7484                <?php
    7585                    $obs = array( 'id' => 'ID', 'author' => __('Author', 'mini-loops'), 'title' => __('Title', 'mini-loops'), 'date' => __('Date', 'mini-loops'), 'modified' => __('Last-modified Date', 'mini-loops'), 'parent', __('Parent ID', 'mini-loops'), 'rand' => __('Random', 'mini-loops'), 'comment_count' => __('Comment Count', 'mini-loops'), 'menu_order' => __('Menu Order', 'mini-loops'), 'meta_value' => __('Meta Value*', 'mini-loops'), 'meta_value_num' => __('Meta Value Numerical*', 'mini-loops') );
    76                     foreach($obs as $k=>$v) {
    77                         echo "<option value='{$k}'" . selected( $k, $order_by, false ) . ">{$v}</option>";
    78                     }
    79                 ?>
    80                 </select>
    81             </label>
    82         </p>
    83         <p style="width:48%;float:right;">
    84             <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:', 'mini-loops' );?>
    85                 <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>">
     86                    foreach ( $obs as $k => $v ) {
     87                        printf(
     88                            '<option value="%s" %s>%s</option>',
     89                            esc_attr( $k ),
     90                            selected( $k, $order_by, false ),
     91                            esc_html( $k )
     92                        );
     93                    }
     94                ?>
     95                </select>
     96            </label>
     97        </p>
     98        <p style="width:48%;float:right;">
     99            <label for="<?php echo esc_attr( $this->get_field_id('order' ) ); ?>"><?php esc_html_e('Order:', 'mini-loops' );?>
     100                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id('order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order' ) ); ?>">
    86101                <?php
    87102                    $obs = array( 'ASC', 'DESC' );
    88                     foreach($obs as $v) {
    89                         echo "<option value='{$v}'" . selected( $v, $order, false ) . ">{$v}</option>";
    90                     }
    91                 ?>
    92                 </select>
    93                 <small>(<?php _e('ABC vs ZYX', 'mini-loops');?>)</small>
     103                    foreach ( $obs as $v ) {
     104                        printf(
     105                            '<option value="%s" %s>%s</option>',
     106                            esc_attr( $v ),
     107                            selected( $v, $order, false ),
     108                            esc_html( $v )
     109                        );
     110                    }
     111                ?>
     112                </select>
     113                <small>(<?php esc_html_e('ABC vs ZYX', 'mini-loops');?>)</small>
    94114            </label>
    95115        </p>
    96116        <p style="clear:both;">
    97             <label for="<?php echo $this->get_field_id('order_meta_key'); ?>"><?php _e('*Meta key required for meta value ordering', 'mini-loops');?></label>
    98             <input type="text" class="widefat" id="<?php echo $this->get_field_id('order_meta_key'); ?>" name="<?php echo $this->get_field_name('order_meta_key'); ?>" value="<?php echo $order_meta_key; ?>" />
     117            <label for="<?php echo esc_attr( $this->get_field_id('order_meta_key' ) ); ?>"><?php esc_html_e('*Meta key required for meta value ordering', 'mini-loops');?></label>
     118            <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('order_meta_key' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('order_meta_key' ) ); ?>" value="<?php echo esc_attr( $order_meta_key ); ?>" />
    99119        </p>
    100120        <p style="clear:both;">
    101             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('reverse_order'); ?>" name="<?php echo $this->get_field_name('reverse_order'); ?>"<?php checked( $reverse_order ); ?> />
    102             <label for="<?php echo $this->get_field_id('reverse_order'); ?>"><?php _e('Show posts in reverse order?', 'mini-loops');?></label>
    103             <small>(<?php _e('ABC vs CBA', 'mini-loops');?>)</small>
    104         </p>
    105         <p>
    106             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('shuffle_order'); ?>" name="<?php echo $this->get_field_name('shuffle_order'); ?>"<?php checked( $shuffle_order ); ?> />
    107             <label for="<?php echo $this->get_field_id('shuffle_order'); ?>"><?php _e('Shuffle post order?', 'mini-loops');?></label>
    108             <small>(<?php _e('ABC vs BCA', 'mini-loops');?>)</small>
    109         </p>
    110         <p style="width:48%;float:left;">
    111             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('ignore_sticky'); ?>" name="<?php echo $this->get_field_name('ignore_sticky'); ?>"<?php checked( $ignore_sticky ); ?> />
    112             <label for="<?php echo $this->get_field_id('ignore_sticky'); ?>"><?php _e('Unstick sticky posts?', 'mini-loops');?></label>
    113         </p>
    114         <p style="width:48%;float:right;">
    115             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('only_sticky'); ?>" name="<?php echo $this->get_field_name('only_sticky'); ?>"<?php checked( $only_sticky ); ?> />
    116             <label for="<?php echo $this->get_field_id('only_sticky'); ?>"><?php _e('Only sticky posts?', 'mini-loops');?></label>
    117         </p>
    118         <p style="width:48%;float:left;">
    119             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('exclude_sticky'); ?>" name="<?php echo $this->get_field_name('exclude_sticky'); ?>"<?php checked( $exclude_sticky ); ?> />
    120             <label for="<?php echo $this->get_field_id('exclude_sticky'); ?>"><?php _e('Exclude sticky posts?', 'mini-loops');?></label>
    121         </p>
    122         <p style="clear:both;"><small><?php _e( '"Only" will take precedence if both sticky options are checked.', 'mini-loops' ); ?></small></p>
    123         <p>
    124             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('exclude_current'); ?>" name="<?php echo $this->get_field_name('exclude_current'); ?>"<?php checked( $exclude_current ); ?> />
    125             <label for="<?php echo $this->get_field_id('exclude_current'); ?>"><?php _e('If viewing a single post, exclude it?', 'mini-loops');?></label>
    126         </p>
    127         <p style="clear:both;"><small><?php _e( 'This option is ignored if "Only sticky" is checked.', 'mini-loops' ); ?></small></p>
    128         <p>
    129             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_category'); ?>" name="<?php echo $this->get_field_name('current_category'); ?>"<?php checked( $current_category ); ?> />
    130             <label for="<?php echo $this->get_field_id('current_category'); ?>"><?php _e('Get posts from current category (if archive)?', 'mini-loops');?></label>
    131         </p>
    132         <p>
    133             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_single_category'); ?>" name="<?php echo $this->get_field_name('current_single_category'); ?>"<?php checked( $current_single_category ); ?> />
    134             <label for="<?php echo $this->get_field_id('current_single_category'); ?>"><?php _e('Get posts from first category (if single)?', 'mini-loops');?></label>
    135         </p>
    136         <p>
    137             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('current_author'); ?>" name="<?php echo $this->get_field_name('current_author'); ?>"<?php checked( $current_author ); ?> />
    138             <label for="<?php echo $this->get_field_id('current_author'); ?>"><?php _e('Get posts from current author (if single or archive)?', 'mini-loops');?></label>
     121            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('reverse_order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('reverse_order' ) ); ?>"<?php checked( $reverse_order ); ?> />
     122            <label for="<?php echo esc_attr( $this->get_field_id('reverse_order' ) ); ?>"><?php esc_html_e('Show posts in reverse order?', 'mini-loops');?></label>
     123            <small>(<?php esc_html_e('ABC vs CBA', 'mini-loops');?>)</small>
     124        </p>
     125        <p>
     126            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('shuffle_order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('shuffle_order' ) ); ?>"<?php checked( $shuffle_order ); ?> />
     127            <label for="<?php echo esc_attr( $this->get_field_id('shuffle_order' ) ); ?>"><?php esc_html_e('Shuffle post order?', 'mini-loops');?></label>
     128            <small>(<?php esc_html_e('ABC vs BCA', 'mini-loops');?>)</small>
     129        </p>
     130        <p style="width:48%;float:left;">
     131            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('ignore_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('ignore_sticky' ) ); ?>"<?php checked( $ignore_sticky ); ?> />
     132            <label for="<?php echo esc_attr( $this->get_field_id('ignore_sticky' ) ); ?>"><?php esc_html_e('Unstick sticky posts?', 'mini-loops');?></label>
     133        </p>
     134        <p style="width:48%;float:right;">
     135            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('only_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('only_sticky' ) ); ?>"<?php checked( $only_sticky ); ?> />
     136            <label for="<?php echo esc_attr( $this->get_field_id('only_sticky' ) ); ?>"><?php esc_html_e('Only sticky posts?', 'mini-loops');?></label>
     137        </p>
     138        <p style="width:48%;float:left;">
     139            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('exclude_sticky' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude_sticky' ) ); ?>"<?php checked( $exclude_sticky ); ?> />
     140            <label for="<?php echo esc_attr( $this->get_field_id('exclude_sticky' ) ); ?>"><?php esc_html_e('Exclude sticky posts?', 'mini-loops');?></label>
     141        </p>
     142        <p style="clear:both;"><small><?php esc_html_e( '"Only" will take precedence if both sticky options are checked.', 'mini-loops' ); ?></small></p>
     143        <p>
     144            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('exclude_current' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude_current' ) ); ?>"<?php checked( $exclude_current ); ?> />
     145            <label for="<?php echo esc_attr( $this->get_field_id('exclude_current' ) ); ?>"><?php esc_html_e('If viewing a single post, exclude it?', 'mini-loops');?></label>
     146        </p>
     147        <p style="clear:both;"><small><?php esc_html_e( 'This option is ignored if "Only sticky" is checked.', 'mini-loops' ); ?></small></p>
     148        <p>
     149            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_category' ) ); ?>"<?php checked( $current_category ); ?> />
     150            <label for="<?php echo esc_attr( $this->get_field_id('current_category' ) ); ?>"><?php esc_html_e('Get posts from current category (if archive)?', 'mini-loops');?></label>
     151        </p>
     152        <p>
     153            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_single_category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_single_category' ) ); ?>"<?php checked( $current_single_category ); ?> />
     154            <label for="<?php echo esc_attr( $this->get_field_id('current_single_category' ) ); ?>"><?php esc_html_e('Get posts from first category (if single)?', 'mini-loops');?></label>
     155        </p>
     156        <p>
     157            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('current_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('current_author' ) ); ?>"<?php checked( $current_author ); ?> />
     158            <label for="<?php echo esc_attr( $this->get_field_id('current_author' ) ); ?>"><?php esc_html_e('Get posts from current author (if single or archive)?', 'mini-loops');?></label>
    139159        </p>
    140160
     
    144164
    145165        <p style="width:48%;float:left;">
    146             <label for="<?php echo $this->get_field_id('categories'); ?>"><?php _e('Categories:', 'mini-loops');?>
    147                 <input class="widefat" id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" type="text" value="<?php echo $categories; ?>" /><br />
    148                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
    149             </label>
    150         </p>
    151         <p style="width:48%;float:right;">
    152             <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Tags:', 'mini-loops');?>
    153                 <input class="widefat" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" type="text" value="<?php echo $tags; ?>" /><br />
    154                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>) </small>
    155             </label>
    156         </p>
    157             <label for="<?php echo $this->get_field_id('tax'); ?>"><?php _e('Custom Taxonomies:', 'mini-loops');?>
    158                 <input class="widefat" id="<?php echo $this->get_field_id('tax'); ?>" name="<?php echo $this->get_field_name('tax'); ?>" type="text" value="<?php echo $tax; ?>" /><br />
    159                 <small>(<?php _e('Ex: category=1,2,4&amp;post_tag=6,12', 'mini-loops');?><br />
    160                         <?php _e('Available: ', 'mini-loops'); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?>)</small>
    161             </label>
    162         </p>
    163         <p>
    164             <label for="<?php echo $this->get_field_id('custom_fields'); ?>"><?php _e('Custom Fields:', 'mini-loops');?>
    165                 <input class="widefat" id="<?php echo $this->get_field_id('custom_fields'); ?>" name="<?php echo $this->get_field_name('custom_fields'); ?>" type="text" value="<?php echo $custom_fields; ?>" /><br />
    166                 <small>(<?php _e('Ex: meta_key=meta_value&amp;meta_key2=meta_value2', 'mini-loops');?>)</small>
    167             </label>
    168         </p>
    169         <p>
    170             <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e('Exclude Posts:', 'mini-loops');?>
    171                 <input class="widefat" id="<?php echo $this->get_field_id('exclude'); ?>" name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $exclude; ?>" /><br />
    172                 <small>(<?php _e('IDs, comma-separated.', 'mini-loops');?>)</small>
    173             </label>
    174         </p>
    175         <h3 style="clear:both;"><?php _e( 'Format', 'mini-loops' ); ?></h3>
    176         <p style="width:48%;float:left;">
    177             <label for="<?php echo $this->get_field_id('before_items'); ?>"><?php _e('Before Item:', 'mini-loops');?>
    178                 <?php /*<input class="widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $before_items ) ); ?>" />*/?>
    179                 <textarea class="widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>"><?php echo htmlspecialchars( stripslashes( $before_items ) ); ?></textarea>
    180             </label>
    181         </p>
    182         <p style="width:48%;float:right;">
    183             <label for="<?php echo $this->get_field_id('after_items'); ?>"><?php _e('After Item:', 'mini-loops');?>
    184                 <?php /*<input class="widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $after_items ) ); ?>" />*/?>
    185                 <textarea class="widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>"><?php echo htmlspecialchars( stripslashes( $after_items ) ); ?></textarea>
    186             </label>
    187         </p>
    188         <p>
    189             <label for="<?php echo $this->get_field_id('item_format'); ?>"><?php _e('Item Format:', 'mini-loops');?>
    190                 <textarea class="widefat" rows="5" id="<?php echo $this->get_field_id('item_format'); ?>" name="<?php echo $this->get_field_name('item_format'); ?>"><?php echo stripslashes( $item_format ); ?></textarea>
    191             </label>
    192             <small><em><a href="http://wordpress.org/extend/plugins/mini-loops/other_notes/"><?php _e('See an explanation of options.', 'mini-loops');?></a></em></small>
     166            <label for="<?php echo esc_attr( $this->get_field_id( 'categories' ) ); ?>"><?php esc_html_e('Categories:', 'mini-loops');?>
     167                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('categories' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('categories' ) ); ?>" type="text" value="<?php echo esc_attr( $categories ); ?>" /><br />
     168                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
     169            </label>
     170        </p>
     171        <p style="width:48%;float:right;">
     172            <label for="<?php echo esc_attr( $this->get_field_id( 'tags' ) ); ?>"><?php esc_html_e('Tags:', 'mini-loops');?>
     173                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('tags' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('tags' ) ); ?>" type="text" value="<?php echo esc_attr( $tags ); ?>" /><br />
     174                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>) </small>
     175            </label>
     176        </p>
     177            <label for="<?php echo esc_attr( $this->get_field_id( 'tax' ) ); ?>"><?php esc_html_e('Custom Taxonomies:', 'mini-loops');?>
     178                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('tax' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('tax' ) ); ?>" type="text" value="<?php echo esc_attr( $tax ); ?>" /><br />
     179                <small>(<?php esc_html_e('Ex: category=1,2,4&amp;post_tag=6,12', 'mini-loops');?><br />
     180                        <?php
     181                        $taxonomy_names = get_taxonomies( array( 'public' => true ) );
     182                        printf(
     183                            esc_html('Available: %', 'mini-loops'),
     184                            implode( ', ', array_map( 'esc_html', $taxonomy_names ) )
     185                        ); ?>)</small>
     186            </label>
     187        </p>
     188        <p>
     189            <label for="<?php echo esc_attr( $this->get_field_id('custom_fields' ) ); ?>"><?php esc_html_e('Custom Fields:', 'mini-loops');?>
     190                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('custom_fields' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('custom_fields' ) ); ?>" type="text" value="<?php echo esc_attr( $custom_fields ); ?>" /><br />
     191                <small>(<?php esc_html_e('Ex: meta_key=meta_value&amp;meta_key2=meta_value2', 'mini-loops');?>)</small>
     192            </label>
     193        </p>
     194        <p>
     195            <label for="<?php echo esc_attr( $this->get_field_id('exclude' ) ); ?>"><?php esc_html_e('Exclude Posts:', 'mini-loops');?>
     196                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('exclude' ) ); ?>" type="text" value="<?php echo esc_attr( $exclude ); ?>" /><br />
     197                <small>(<?php esc_html_e('IDs, comma-separated.', 'mini-loops');?>)</small>
     198            </label>
     199        </p>
     200        <h3 style="clear:both;"><?php esc_html_e( 'Format', 'mini-loops' ); ?></h3>
     201        <p style="width:48%;float:left;">
     202            <label for="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>"><?php esc_html_e('Before Item:', 'mini-loops');?>
     203                <?php /*<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items' ) ); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $before_items ) ); ?>" />*/?>
     204                <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items' ) ); ?>"><?php echo esc_textarea( stripslashes( $before_items ) ); ?></textarea>
     205            </label>
     206        </p>
     207        <p style="width:48%;float:right;">
     208            <label for="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>"><?php esc_html_e('After Item:', 'mini-loops');?>
     209                <?php /*<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items' ) ); ?>" type="text" value="<?php echo htmlspecialchars( stripslashes( $after_items ) ); ?>" />*/?>
     210                <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items' ) ); ?>"><?php echo esc_textarea( stripslashes( $after_items ) ); ?></textarea>
     211            </label>
     212        </p>
     213        <p>
     214            <label for="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>"><?php esc_html_e('Item Format:', 'mini-loops');?>
     215                <textarea class="widefat" rows="5" id="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('item_format' ) ); ?>"><?php echo esc_textarea( $item_format ); ?></textarea>
     216            </label>
     217            <small><em><a href="http://wordpress.org/extend/plugins/mini-loops/other_notes/"><?php esc_html_e('See an explanation of options.', 'mini-loops');?></a></em></small>
    193218        </p>
    194219
  • mini-loops/trunk/helpers.php

    r976219 r2546965  
    22if ( ! defined( 'ABSPATH' ) ) die( '-1' );
    33
    4 // Show recent posts function
     4/**
     5 * Get default parameters
     6 *
     7 * @return array
     8 */
    59function get_miniloops_defaults() {
    610    $defs = array(
     
    3943}
    4044
     45/**
     46 * get_miniloops
     47 *
     48 * @param array $args
     49 * @return string
     50 */
    4151function get_miniloops( $args = '' ) {
    42     global $wpdb, $post;
     52    global $post;
    4353    $defaults = get_miniloops_defaults();
    4454
     
    153163    if ( $maximum_age != 0 ) {
    154164        global $mini_loops_minimum_date;
    155         $mini_loops_minimum_date = date( 'Y-m-d', time() - ( $maximum_age * 24 * 60 * 60 ) );
     165        $mini_loops_minimum_date = gmdate( 'Y-m-d', time() - ( $maximum_age * 24 * 60 * 60 ) );
    156166        $maximum_age_func = create_function('$filter','global $mini_loops_minimum_date; $filter .= " AND post_date >= \'' . $mini_loops_minimum_date .'\'"; return $filter;');
    157167        add_filter( 'posts_where', $maximum_age_func );
     
    182192        $before_items = do_shortcode( miniloops_shortcoder( stripslashes( $before_items ) ) );
    183193        $before_items = apply_filters( 'miniloops_before_items_format', $before_items, $query, $miniloop, $args );
     194
    184195        $postlist .= $before_items;
    185196
     
    188199
    189200            $post_format = current_theme_supports('post-formats') ? get_post_format( get_the_ID() ) : 'standard';
     201
     202            // decodes shortcode brackets
     203            $item_format = html_entity_decode( $item_format );
    190204
    191205            $item_format_to_use = apply_filters( 'miniloops_item_format', $item_format, $post_format );
     
    208222    return $postlist;
    209223}
     224
     225/**
     226 * miniloops
     227 */
    210228function miniloops( $params ) {
    211     echo get_miniloops( $params );
    212 }
    213 
     229    echo wp_kses_post( get_miniloops( $params ) );
     230}
     231
     232/**
     233 * miniloops_shortcoder
     234 *
     235 * @param string $input
     236 * @return string
     237 */
    214238function miniloops_shortcoder( $input ) {
    215239
     
    238262}
    239263
    240     function miniloops_shortcode_finder( $shortcode ) {
    241         if ( substr( $shortcode, 0, 3 ) == 'ml_' ) {
    242             return true;
    243         }
    244         return false;
    245     }
    246     function miniloops_shortcode_filter( $shortcode ) {
    247         return substr( $shortcode, 3 );
    248     }
    249 
     264/**
     265 * miniloops_shortcode_finder
     266 *
     267 * @param string $shortcode
     268 * @return bool
     269 */
     270function miniloops_shortcode_finder( $shortcode ) {
     271    if ( substr( $shortcode, 0, 3 ) == 'ml_' ) {
     272        return true;
     273    }
     274    return false;
     275}
     276
     277/**
     278 * miniloops_shortcode_filter
     279 *
     280 * @param string $shortcode
     281 * @return string
     282 */
     283function miniloops_shortcode_filter( $shortcode ) {
     284    return substr( $shortcode, 3 );
     285}
     286
     287/**
     288 * miniloops_word_excerpt
     289 *
     290 * @param string $input
     291 * @param int    $limit
     292 * @return string
     293 */
    250294function miniloops_word_excerpt( $input, $limit ) {
    251295    $input = explode( ' ', $input );
    252     $input = array_splice( $input, 0, $limit );
     296    $input = array_splice( $input, 0, (int) $limit );
    253297    return trim( implode( ' ', $input ) );
    254298}
    255299
    256 /*
    257 
    258     shortcode for posts and pages
    259 
    260 */
    261 add_shortcode( 'miniloops' , 'get_miniloops_sc');
    262 add_shortcode( 'miniloop' , 'get_miniloops_sc');
     300/**
     301 * shortcode for posts and pages
     302 *
     303 * @param array $atts
     304 * @param string $content
     305 * @return string
     306 */
    263307function get_miniloops_sc( $atts, $content ) {
    264     $content = str_replace( '{', '[', str_replace('}', ']', $content ) );
     308
     309    $content = str_replace(
     310        [ '{', '}' ],
     311        [ '[', ']' ],
     312        $content
     313    );
     314
    265315    if ( strpos( $content, '[ml_format' ) !== false ) {
    266316        $atts['item_format'] = do_shortcode( $content );
    267317    } elseif ( ! empty( $content) ) {
    268         $atts['item_format'] = $content;
     318        $content = ltrim( $content, '</p>' );
     319        $content = rtrim( $content, '<p>' );
     320        $atts['item_format'] = miniloops_straighten_quote( $content );
    269321    }
    270322    $args = shortcode_atts( get_miniloops_defaults(), $atts );
     
    273325}
    274326
    275 /*
    276 
    277     shortcodes for use in the Item Format
    278     (but in fact can be used anywhere)
    279 
    280 */
     327/**
     328 * @link https://stackoverflow.com/a/21491305
     329 * @param string $input
     330 * @return string
     331 */
     332function miniloops_straighten_quote( $input ) {
     333    $chr_map = array(
     334        // Windows codepage 1252
     335        "\xC2\x82" => "'", // U+0082⇒U+201A single low-9 quotation mark
     336        "\xC2\x84" => '"', // U+0084⇒U+201E double low-9 quotation mark
     337        "\xC2\x8B" => "'", // U+008B⇒U+2039 single left-pointing angle quotation mark
     338        "\xC2\x91" => "'", // U+0091⇒U+2018 left single quotation mark
     339        "\xC2\x92" => "'", // U+0092⇒U+2019 right single quotation mark
     340        "\xC2\x93" => '"', // U+0093⇒U+201C left double quotation mark
     341        "\xC2\x94" => '"', // U+0094⇒U+201D right double quotation mark
     342        "\xC2\x9B" => "'", // U+009B⇒U+203A single right-pointing angle quotation mark
     343
     344        // Regular Unicode     // U+0022 quotation mark (")
     345                               // U+0027 apostrophe     (')
     346        "\xC2\xAB"     => '"', // U+00AB left-pointing double angle quotation mark
     347        "\xC2\xBB"     => '"', // U+00BB right-pointing double angle quotation mark
     348        "\xE2\x80\x98" => "'", // U+2018 left single quotation mark
     349        "\xE2\x80\x99" => "'", // U+2019 right single quotation mark
     350        "\xE2\x80\x9A" => "'", // U+201A single low-9 quotation mark
     351        "\xE2\x80\x9B" => "'", // U+201B single high-reversed-9 quotation mark
     352        "\xE2\x80\x9C" => '"', // U+201C left double quotation mark
     353        "\xE2\x80\x9D" => '"', // U+201D right double quotation mark
     354        "\xE2\x80\x9E" => '"', // U+201E double low-9 quotation mark
     355        "\xE2\x80\x9F" => '"', // U+201F double high-reversed-9 quotation mark
     356        "\xE2\x80\xB9" => "'", // U+2039 single left-pointing angle quotation mark
     357        "\xE2\x80\xBA" => "'", // U+203A single right-pointing angle quotation mark
     358    );
     359    $chr = array_keys( $chr_map ); // but: for efficiency you should
     360    $rpl = array_values( $chr_map ); // pre-calculate these two arrays
     361    $output = str_replace( $chr, $rpl, html_entity_decode( $input, ENT_QUOTES, "UTF-8" ) );
     362    return $output;
     363}
     364
     365/**
     366 * shortcodes for use in the Item Format
     367 * (but in fact can be used anywhere)
     368 */
     369add_shortcode( 'miniloops' , 'get_miniloops_sc');
     370add_shortcode( 'miniloop' , 'get_miniloops_sc');
    281371add_shortcode( 'ml_format' , 'miniloop_item_format' );
    282 function miniloop_item_format( $atts, $content ) {
     372add_shortcode( 'ml_title' , 'miniloop_title' );
     373add_shortcode( 'ml_url' , 'miniloop_url' );
     374add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' );
     375add_shortcode( 'ml_content' , 'miniloop_content' );
     376add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' );
     377add_shortcode( 'ml_author' , 'miniloop_author' );
     378add_shortcode( 'ml_author_link' , 'miniloop_author_link' );
     379add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' );
     380add_shortcode( 'ml_field' , 'miniloop_field' );
     381add_shortcode( 'ml_category' , 'miniloop_category' );
     382add_shortcode( 'ml_tag' , 'miniloop_tag' );
     383add_shortcode( 'ml_tax' , 'miniloop_taxonomy' );
     384add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' );
     385add_shortcode( 'ml_date' , 'miniloop_date' );
     386add_shortcode( 'ml_post_type', 'miniloop_post_type' );
     387add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' );
     388add_shortcode( 'ml_class' , 'miniloop_class' );
     389add_shortcode( 'ml_image' , 'miniloop_image' );
     390
     391/**
     392 * miniloop_item_format
     393 * shortcode callback
     394 *
     395 * @param array $atts
     396 * @return string
     397 */
     398function miniloop_item_format( $atts ) {
    283399    extract( shortcode_atts( array(
    284400        'name' => 'ml_format',
     
    287403}
    288404
    289 add_shortcode( 'ml_title' , 'miniloop_title' );
     405/**
     406 * miniloop_title
     407 * shortcode callback
     408 *
     409 * @param array $atts
     410 * @return string
     411 */
    290412function miniloop_title( $atts ) {
    291413    extract( shortcode_atts( array(
     
    311433}
    312434
    313 add_shortcode( 'ml_url' , 'miniloop_url' );
     435/**
     436 * miniloop_url
     437 * shortcode callback
     438 *
     439 * @param array $atts
     440 * @return string
     441 */
    314442function miniloop_url( $atts ) {
    315443    extract( shortcode_atts( array(
     
    329457}
    330458
    331 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' );
     459/**
     460 * miniloop_excerpt
     461 * shortcode callback
     462 *
     463 * @param array $atts
     464 * @return string
     465 */
    332466function miniloop_excerpt( $atts ) {
    333467    extract( shortcode_atts( array(
     
    410544}
    411545
    412 add_shortcode( 'ml_content' , 'miniloop_content' );
     546/**
     547 * miniloop_content
     548 * shortcode callback
     549 *
     550 * @param array $atts
     551 * @return string
     552 */
    413553function miniloop_content( $atts ) {
    414554    extract( shortcode_atts( array(
     
    424564}
    425565
    426 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' );
     566/**
     567 * miniloop_comment_count
     568 * shortcode callback
     569 *
     570 * @return string
     571 */
    427572function miniloop_comment_count() {
    428573    $count = get_comment_count( get_the_ID() );
     
    431576}
    432577
    433 add_shortcode( 'ml_author' , 'miniloop_author' );
     578/**
     579 * miniloop_author
     580 * shortcode callback
     581 *
     582 * @return string
     583 */
    434584function miniloop_author() {
    435585
     
    437587}
    438588
    439 add_shortcode( 'ml_author_link' , 'miniloop_author_link' );
     589/**
     590 * miniloop_author_link
     591 * shortcode callback
     592 *
     593 * @return string
     594 */
    440595function miniloop_author_link() {
    441596
     
    443598}
    444599
    445 add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' );
     600/**
     601 * miniloop_author_avatar
     602 * shortcode callback
     603 *
     604 * @param array $atts
     605 * @return string
     606 */
    446607function miniloop_author_avatar( $atts ) {
    447608    extract( shortcode_atts( array(
     
    455616}
    456617
    457 add_shortcode( 'ml_field' , 'miniloop_field' );
     618/**
     619 * miniloop_field
     620 * shortcode callback
     621 *
     622 * @param array $atts
     623 * @return string
     624 */
    458625function miniloop_field( $atts ) {
    459626    extract( shortcode_atts( array(
     
    479646}
    480647
    481 add_shortcode( 'ml_category' , 'miniloop_category' );
     648/**
     649 * miniloop_category
     650 * shortcode callback
     651 *
     652 * @param array $atts
     653 * @return string
     654 */
    482655function miniloop_category( $atts ) {
    483656    $atts = shortcode_atts( array(
     
    492665}
    493666
    494 add_shortcode( 'ml_tag' , 'miniloop_tag' );
     667/**
     668 * miniloop_tag
     669 * shortcode callback
     670 *
     671 * @param array $atts
     672 * @return string
     673 */
    495674function miniloop_tag( $atts ) {
    496675    $atts = shortcode_atts( array(
     
    505684}
    506685
    507 add_shortcode( 'ml_tax' , 'miniloop_taxonomy' );
    508 add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' );
     686/**
     687 * miniloop_taxonomy
     688 * shortcode callback
     689 *
     690 * @param array $atts
     691 * @return string
     692 */
    509693function miniloop_taxonomy( $atts ) {
    510694    extract( shortcode_atts( array(
     
    532716}
    533717
    534 // BETA - not fully tested, may not work under some conditions
    535 // 'ba' prefix for 'before/after' - special hackish use
    536 add_shortcode( 'ba_archive' , 'miniloop_archive' );
     718/**
     719 * miniloop_archive
     720 * shortcode callback
     721 *
     722 * BETA - not fully tested, may not work under some conditions
     723 * 'ba' prefix for 'before/after' - special hackish use
     724 *
     725 * @param array $atts
     726 * @return string
     727 */
    537728function miniloop_archive( $atts ) {
    538729    extract( shortcode_atts( array(
     
    543734    return "{$before}##replace|archive##{$after}";
    544735}
     736add_shortcode( 'ba_archive' , 'miniloop_archive' );
     737
    545738// For use with the BETA [ba_archive] shortcode
    546739add_filter( 'miniloops_before_items_format', 'ml_hackish_filter', 10, 3 );
    547740add_filter( 'miniloops_after_items_format', 'ml_hackish_filter', 10, 3 );
     741
     742/**
     743 * ml_hackish_filter
     744 *
     745 * @param string $before_items
     746 * @param mixed $query
     747 * @param object $miniloop
     748 * @return string
     749 */
    548750function ml_hackish_filter( $before_items, $query, $miniloop ) {
    549751    // if there is nothing to replace, carry on...
     
    569771}
    570772
    571 add_shortcode( 'ml_date' , 'miniloop_date' );
     773/**
     774 * miniloop_date
     775 * shortcode callback
     776 *
     777 * @param array $atts
     778 * @return string
     779 */
    572780function miniloop_date( $atts ) {
    573781    extract( shortcode_atts( array(
     
    579787}
    580788
    581 add_shortcode( 'ml_post_type', 'miniloop_post_type' );
     789/**
     790 * miniloop_post_type
     791 * shortcode callback
     792 *
     793 * @param array $atts
     794 * @return string
     795 */
    582796function miniloop_post_type( $atts ) {
    583797    extract( shortcode_atts( array(
     
    590804}
    591805
    592 add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' );
     806/**
     807 * miniloop_post_type_archive_link
     808 * shortcode callback
     809 *
     810 * @param array $atts
     811 * @return string
     812 */
    593813function miniloop_post_type_archive_link( $atts ) {
    594814    extract( shortcode_atts( array(
     
    599819}
    600820
    601 add_shortcode( 'ml_class' , 'miniloop_class' );
     821/**
     822 * miniloop_class
     823 * shortcode callback
     824 *
     825 * @param array $atts
     826 * @return string
     827 */
    602828function miniloop_class( $atts ) {
    603829    extract( shortcode_atts( array(
     
    613839}
    614840
    615 add_shortcode( 'ml_image' , 'miniloop_image' );
     841/**
     842 * miniloop_image
     843 * shortcode callback
     844 *
     845 * @param array $atts
     846 * @return string
     847 */
    616848function miniloop_image( $atts ) {
    617849    extract( shortcode_atts( array(
     
    636868
    637869    $crop = (bool) $crop;
    638 
    639870    foreach( $from as $from_where ) {
    640871    switch ( $from_where ) {
    641872        case 'thumb' :
    642 
    643873            if ( 'clear' == $cache ) {
    644874                miniloops_clear_thumbnail_cache( get_the_ID() );
     
    8021032}
    8031033
     1034/**
     1035 * miniloops_create_thumbnail_from_id
     1036 *
     1037 * @param int $att_id
     1038 * @param int $width
     1039 * @param int $height
     1040 * @param bool $crop
     1041 * @return string
     1042 */
    8041043function miniloops_create_thumbnail_from_id( $att_id, $width, $height, $crop ) {
    8051044    $upl = wp_upload_dir();
     
    8101049}
    8111050
     1051/**
     1052 * miniloops_create_thumbnail_from_path
     1053 *
     1054 * @param string $file
     1055 * @param int $width
     1056 * @param int $height
     1057 * @param bool $crop
     1058 * @return string
     1059 */
    8121060function miniloops_create_thumbnail_from_path( $file, $width, $height, $crop ) {
    8131061    $upl = wp_upload_dir();
    814     // deprecated method
    815     // $new = image_resize( $file, $width, $height, true, "ml-{$width}x{$height}" );
    816     // if ( is_wp_error( $new ) )
    817     //  //if the image could not be resized, return the original url
    818     //  return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    819     // return str_replace( $upl['basedir'], $upl['baseurl'], $new );
    820 
    821     // robbed from the depracted image_resize() function
     1062
     1063    // robbed from the deprecated image_resize() function
    8221064    $editor = wp_get_image_editor( $file );
    8231065    if ( is_wp_error( $editor ) ) {
    824         // return $editor;
    8251066        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8261067    }
     
    8291070    $resized = $editor->resize( $width, $height, $crop );
    8301071    if ( is_wp_error( $resized ) ) {
    831         // return $resized;
    8321072        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8331073    }
     
    8371077
    8381078    if ( is_wp_error( $saved ) ) {
    839         // return $saved;
    8401079        return str_replace( $upl['basedir'], $upl['baseurl'], $file );
    8411080    }
     
    8451084}
    8461085
     1086/**
     1087 * miniloops_clear_thumbnail_cache
     1088 *
     1089 * @param int $post_id
     1090 */
    8471091function miniloops_clear_thumbnail_cache( $post_id ) {
    8481092    delete_post_meta( $post_id, '_ml_thumb_thumb' );
     
    8521096/**
    8531097 * Automatically clear the thumbnail cache for the post whenever its featured image is deleted or changed
     1098 *
     1099 * @param int $meta_ids
     1100 * @param int $object_id
     1101 * @param string $meta_key
     1102 * @param string $_meta_value
    8541103 */
    8551104function miniloops_updated_deleted_post_meta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
  • mini-loops/trunk/mini-loops.php

    r1346549 r2546965  
    55Plugin URI: http://trepmal.com/plugins/mini-loops/
    66Description: Query posts and display them where you want
    7 Version: 1.3.1
     7Version: 1.4
    88Author: Kailey Lampert
    99Author URI: http://kaileylampert.com
    1010
    11 Copyright (C) 2011-16 Kailey Lampert
     11Copyright (C) 2011-21 Kailey Lampert
    1212
    1313This program is free software: you can redistribute it and/or modify
  • mini-loops/trunk/readme.txt

    r1346549 r2546965  
    44Donate link: http://kaileylampert.com/donate/
    55Requires at least: 3.5
    6 Tested up to: 4.4
    7 Stable tag: 1.3.1
     6Tested up to: 5.7
     7Stable tag: 1.4
    88License: GPLv2 or later
    99
     
    1515Show most recent posts, posts from categories, and more. Can be displayed via widgets, shortcodes, and template tags.
    1616
    17 This is a new release, please report bugs to trepmal (at) gmail (dot) com before leaving a poor review. Thanks
     17Development is now happening at the [GitHub Repo](https://github.com/trepmal/mini-loops)
    1818
    1919== Installation ==
     
    341341== Upgrade Notice ==
    342342
     343= 1.4 =
     344General updates, improved shortcode compat with the Block Editor.
     345
    343346= 1.3 =
    344347New: Automatically clear thumbnail cache and more. See Changelog
     
    372375
    373376== Changelog ==
     377
     378= Version 1.4 =
     379* General upkeep
    374380
    375381= Version 1.3.1 =
  • mini-loops/trunk/widget.php

    r1346549 r2546965  
    44class miniloops extends WP_Widget {
    55
    6     function miniloops() {
     6    function __construct() {
    77        $widget_ops = array(
    88            'classname'   => 'miniloops',
     
    1616    function widget( $args, $instance ) {
    1717
    18         extract( $args, EXTR_SKIP );
     18         // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
    1919
    20         echo $before_widget;
     20        echo $args['before_widget'];
    2121        if ( ! $instance['hide_title'] ) {
    22             $title = apply_filters( 'widget_title', stripslashes( $instance['title'] ) );
    23             $title = empty( $instance['title_url'] ) ? $title : '<a href="'. esc_url( $instance['title_url'] ) .'">'. $title .'</a>';
    24             echo $before_title . $title . $after_title;
     22            $title = apply_filters( 'widget_title', $instance['title'] );
     23            $title = empty( $instance['title_url'] ) ? wp_kses_post( $title ) : '<a href="'. esc_url( $instance['title_url'] ) .'">'. wp_kses_post( $title ) .'</a>';
     24            echo $args['before_title'] . $title . $args['after_title'];
    2525        }
    2626
     
    2828        echo get_miniloops( $instance );
    2929
    30         echo $after_widget;
     30        echo $args['after_widget'];
     31
     32         // phpcs:enable
    3133
    3234    } //end widget()
     
    3638        $instance = $old_instance;
    3739        //get old variables
    38         $instance['title']                   = wp_filter_post_kses( $new_instance['title'] );
    39         $instance['hide_title']              = (bool) $new_instance['hide_title'] ? 1 : 0;
     40        $instance['title']                   = wp_kses_post( $new_instance['title'] );
     41        $instance['hide_title']              = (bool) isset( $new_instance['hide_title'] ) ? 1 : 0;
    4042        $instance['title_url']               = esc_url( $new_instance['title_url'] );
    4143        $instance['number_posts']            = (int) $new_instance['number_posts'];
     
    4749        $instance['order']                   = esc_attr( $new_instance['order'] );
    4850        $instance['order_meta_key']          = esc_attr( $new_instance['order_meta_key'] );
    49         $instance['reverse_order']           = (bool) $new_instance['reverse_order'] ? 1 : 0;
    50         $instance['shuffle_order']           = (bool) $new_instance['shuffle_order'] ? 1 : 0;
    51         $instance['ignore_sticky']           = (bool) $new_instance['ignore_sticky'] ? 1 : 0;
    52         $instance['only_sticky']             = (bool) $new_instance['only_sticky'] ? 1 : 0;
    53         $instance['exclude_sticky']          = (bool) $new_instance['exclude_sticky'] ? 1 : 0;
    54         $instance['exclude_current']         = (bool) $new_instance['exclude_current'] ? 1 : 0;
    55         $instance['current_category']        = (bool) $new_instance['current_category'] ? 1 : 0;
    56         $instance['current_single_category'] = (bool) $new_instance['current_single_category'] ? 1 : 0;
    57         $instance['current_author']          = (bool) $new_instance['current_author'] ? 1 : 0;
     51        $instance['reverse_order']           = (bool) isset( $new_instance['reverse_order'] ) ? 1 : 0;
     52        $instance['shuffle_order']           = (bool) isset( $new_instance['shuffle_order'] ) ? 1 : 0;
     53        $instance['ignore_sticky']           = (bool) isset( $new_instance['ignore_sticky'] ) ? 1 : 0;
     54        $instance['only_sticky']             = (bool) isset( $new_instance['only_sticky'] ) ? 1 : 0;
     55        $instance['exclude_sticky']          = (bool) isset( $new_instance['exclude_sticky'] ) ? 1 : 0;
     56        $instance['exclude_current']         = (bool) isset( $new_instance['exclude_current'] ) ? 1 : 0;
     57        $instance['current_category']        = (bool) isset( $new_instance['current_category'] ) ? 1 : 0;
     58        $instance['current_single_category'] = (bool) isset( $new_instance['current_single_category'] ) ? 1 : 0;
     59        $instance['current_author']          = (bool) isset( $new_instance['current_author'] ) ? 1 : 0;
    5860        $instance['categories']              = esc_attr( $new_instance['categories'] );
    5961        $instance['tags']                    = esc_attr( $new_instance['tags'] );
     
    6264        $instance['custom_fields']           = esc_attr( $new_instance['custom_fields'] );
    6365        $instance['exclude']                 = esc_attr( $new_instance['exclude'] );
    64         $instance['before_items']            = wp_filter_post_kses( $new_instance['before_items'] );
    65         $instance['item_format']             = wp_filter_post_kses( $new_instance['item_format'] );
    66         $instance['after_items']             = wp_filter_post_kses( $new_instance['after_items'] );
     66        $instance['before_items']            = wp_kses_post( $new_instance['before_items'] );
     67        $instance['item_format']             = wp_kses_post( $new_instance['item_format'] );
     68        $instance['after_items']             = wp_kses_post( $new_instance['after_items'] );
    6769
    6870        return $instance;
     
    8284class miniminiloops extends miniloops {
    8385
    84     function miniminiloops() {
     86    function __construct() {
    8587        $widget_ops = array(
    8688            'classname'   => 'miniminiloops',
     
    9799
    98100        ?>
    99         <p><?php _e( 'Back to basics. Just recent posts. No fuss.', 'mini-loops' ); ?></p>
     101        <p><?php esc_html_e( 'Back to basics. Just recent posts. No fuss.', 'mini-loops' ); ?></p>
    100102        <p style="width:63%;float:left;">
    101             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mini-loops' );?>
    102                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo stripslashes( $title ); ?>" />
     103            <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'mini-loops' );?>
     104                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    103105            </label>
    104106        </p>
    105107        <p style="width:33%;float:right;padding-top:20px;height:20px;">
    106             <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_title'); ?>" name="<?php echo $this->get_field_name('hide_title'); ?>"<?php checked( $hide_title ); ?> />
    107             <label for="<?php echo $this->get_field_id('hide_title'); ?>"><?php _e('Hide Title?', 'mini-loops' );?></label>
     108            <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('hide_title') ); ?>"<?php checked( $hide_title ); ?> />
     109            <label for="<?php echo esc_attr( $this->get_field_id('hide_title' ) ); ?>"><?php esc_html_e('Hide Title?', 'mini-loops' );?></label>
    108110        </p>
    109111        <p style="width:48%;float:left;">
    110             <label for="<?php echo $this->get_field_id( 'title_url' ); ?>"><?php _e( 'Title URL:', 'mini-loops' );?>
    111                 <input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="text" value="<?php echo $title_url; ?>" />
     112            <label for="<?php echo esc_attr( $this->get_field_id( 'title_url' )  ); ?>"><?php esc_html_e( 'Title URL:', 'mini-loops' );?>
     113                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('title_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title_url') ); ?>" type="text" value="<?php echo esc_attr( $title_url ); ?>" />
    112114            </label>
    113115        </p>
    114116        <p style="width:48%;float:right;">
    115             <label for="<?php echo $this->get_field_id('number_posts'); ?>"><?php _e('Number of Posts:', 'mini-loops' );?>
    116                 <input class="widefat" id="<?php echo $this->get_field_id('number_posts'); ?>" name="<?php echo $this->get_field_name('number_posts'); ?>" type="number" value="<?php echo $number_posts; ?>" />
     117            <label for="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>"><?php esc_html_e('Number of Posts:', 'mini-loops' );?>
     118                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('number_posts' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('number_posts') ); ?>" type="number" value="<?php echo esc_attr( $number_posts ); ?>" />
    117119            </label>
    118120        </p>
    119         <input name="<?php echo $this->get_field_name('post_offset'); ?>" type="hidden" value="<?php echo $post_offset; ?>" />
    120         <input name="<?php echo $this->get_field_name('maximum_age'); ?>" type="hidden" value="<?php echo $maximum_age; ?>" />
    121         <input name="<?php echo $this->get_field_name('post_type'); ?>" type="hidden" value="<?php echo $post_type; ?>" />
    122         <input name="<?php echo $this->get_field_name('post_status'); ?>" type="hidden" value="<?php echo $post_status; ?>" />
    123         <input name="<?php echo $this->get_field_name('order_by'); ?>" type="hidden" value="<?php echo $order_by; ?>" />
    124         <input name="<?php echo $this->get_field_name('order'); ?>" type="hidden" value="<?php echo $order; ?>" />
    125         <input name="<?php echo $this->get_field_name('reverse_order'); ?>" type="hidden" value="<?php echo $reverse_order; ?>" />
    126         <input name="<?php echo $this->get_field_name('shuffle_order'); ?>" type="hidden" value="<?php echo $shuffle_order; ?>" />
    127         <input name="<?php echo $this->get_field_name('ignore_sticky'); ?>" type="hidden" value="<?php echo $ignore_sticky; ?>" />
    128         <input name="<?php echo $this->get_field_name('only_sticky'); ?>" type="hidden" value="<?php echo $only_sticky; ?>" />
    129         <input name="<?php echo $this->get_field_name('exclude_sticky'); ?>" type="hidden" value="<?php echo $exclude_sticky; ?>" />
    130         <input name="<?php echo $this->get_field_name('exclude_current'); ?>" type="hidden" value="<?php echo $exclude_current; ?>" />
    131         <input name="<?php echo $this->get_field_name('current_category'); ?>" type="hidden" value="<?php echo $current_category; ?>" />
    132         <input name="<?php echo $this->get_field_name('current_author'); ?>" type="hidden" value="<?php echo $current_author; ?>" />
    133         <input name="<?php echo $this->get_field_name('categories'); ?>" type="hidden" value="<?php echo $categories; ?>" />
    134         <input name="<?php echo $this->get_field_name('tags'); ?>" type="hidden" value="<?php echo $tags; ?>" />
    135         <input name="<?php echo $this->get_field_name('post_author'); ?>" type="hidden" value="<?php echo $post_author; ?>" />
    136         <input name="<?php echo $this->get_field_name('tax'); ?>" type="hidden" value="<?php echo $tax; ?>" />
    137         <input name="<?php echo $this->get_field_name('custom_fields'); ?>" type="hidden" value="<?php echo $custom_fields; ?>" />
    138         <input name="<?php echo $this->get_field_name('exclude'); ?>" type="hidden" value="<?php echo $exclude; ?>" />
    139         <textarea class="hidden widefat" id="<?php echo $this->get_field_id('before_items'); ?>" name="<?php echo $this->get_field_name('before_items'); ?>"><?php echo htmlspecialchars( stripslashes( $before_items ) ); ?></textarea>
    140         <textarea class="hidden widefat" id="<?php echo $this->get_field_id('after_items'); ?>" name="<?php echo $this->get_field_name('after_items'); ?>"><?php echo htmlspecialchars( stripslashes( $after_items ) ); ?></textarea>
    141         <textarea class="hidden widefat" rows="5" id="<?php echo $this->get_field_id('item_format'); ?>" name="<?php echo $this->get_field_name('item_format'); ?>"><?php echo stripslashes( $item_format ); ?></textarea>
     121        <input name="<?php echo esc_attr( $this->get_field_name('post_offset') ); ?>" type="hidden" value="<?php echo esc_attr( $post_offset ); ?>" />
     122        <input name="<?php echo esc_attr( $this->get_field_name('maximum_age') ); ?>" type="hidden" value="<?php echo esc_attr( $maximum_age ); ?>" />
     123        <input name="<?php echo esc_attr( $this->get_field_name('post_type') ); ?>" type="hidden" value="<?php echo esc_attr( $post_type ); ?>" />
     124        <input name="<?php echo esc_attr( $this->get_field_name('post_status') ); ?>" type="hidden" value="<?php echo esc_attr( $post_status ); ?>" />
     125        <input name="<?php echo esc_attr( $this->get_field_name('order_by') ); ?>" type="hidden" value="<?php echo esc_attr( $order_by ); ?>" />
     126        <input name="<?php echo esc_attr( $this->get_field_name('order') ); ?>" type="hidden" value="<?php echo esc_attr( $order ); ?>" />
     127        <input name="<?php echo esc_attr( $this->get_field_name('reverse_order') ); ?>" type="hidden" value="<?php echo esc_attr( $reverse_order ); ?>" />
     128        <input name="<?php echo esc_attr( $this->get_field_name('shuffle_order') ); ?>" type="hidden" value="<?php echo esc_attr( $shuffle_order ); ?>" />
     129        <input name="<?php echo esc_attr( $this->get_field_name('ignore_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $ignore_sticky ); ?>" />
     130        <input name="<?php echo esc_attr( $this->get_field_name('only_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $only_sticky ); ?>" />
     131        <input name="<?php echo esc_attr( $this->get_field_name('exclude_sticky') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude_sticky ); ?>" />
     132        <input name="<?php echo esc_attr( $this->get_field_name('exclude_current') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude_current ); ?>" />
     133        <input name="<?php echo esc_attr( $this->get_field_name('current_category') ); ?>" type="hidden" value="<?php echo esc_attr( $current_category ); ?>" />
     134        <input name="<?php echo esc_attr( $this->get_field_name('current_author') ); ?>" type="hidden" value="<?php echo esc_attr( $current_author ); ?>" />
     135        <input name="<?php echo esc_attr( $this->get_field_name('categories') ); ?>" type="hidden" value="<?php echo esc_attr( $categories ); ?>" />
     136        <input name="<?php echo esc_attr( $this->get_field_name('tags') ); ?>" type="hidden" value="<?php echo esc_attr( $tags ); ?>" />
     137        <input name="<?php echo esc_attr( $this->get_field_name('post_author') ); ?>" type="hidden" value="<?php echo esc_attr( $post_author ); ?>" />
     138        <input name="<?php echo esc_attr( $this->get_field_name('tax') ); ?>" type="hidden" value="<?php echo esc_attr( $tax ); ?>" />
     139        <input name="<?php echo esc_attr( $this->get_field_name('custom_fields') ); ?>" type="hidden" value="<?php echo esc_attr( $custom_fields ); ?>" />
     140        <input name="<?php echo esc_attr( $this->get_field_name('exclude') ); ?>" type="hidden" value="<?php echo esc_attr( $exclude ); ?>" />
     141        <textarea class="hidden widefat" id="<?php echo esc_attr( $this->get_field_id('before_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('before_items') ); ?>"><?php echo esc_textarea( $before_items ); ?></textarea>
     142        <textarea class="hidden widefat" id="<?php echo esc_attr( $this->get_field_id('after_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('after_items') ); ?>"><?php echo esc_textarea( $after_items ); ?></textarea>
     143        <textarea class="hidden widefat" rows="5" id="<?php echo esc_attr( $this->get_field_id('item_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('item_format') ); ?>"><?php echo esc_textarea( $item_format ); ?></textarea>
    142144        <?php
    143145    } //end form()
Note: See TracChangeset for help on using the changeset viewer.