Changeset 2546965
- Timestamp:
- 06/13/2021 03:04:05 AM (5 years ago)
- Location:
- mini-loops
- Files:
-
- 24 added
- 1 deleted
- 15 edited
- 1 copied
-
assets/banner-772x250.png (modified) (1 prop) (previous)
-
assets/screenshot-1.png (modified) (1 prop) (previous)
-
assets/screenshot-2.png (modified) (1 prop) (previous)
-
assets/screenshot-3.png (modified) (1 prop) (previous)
-
assets/screenshot-4.png (modified) (1 prop) (previous)
-
assets/screenshot-5.png (deleted)
-
tags/1.4 (copied) (copied from mini-loops/trunk)
-
tags/1.4/.editorconfig (added)
-
tags/1.4/CHANGELOG.md (added)
-
tags/1.4/bin (added)
-
tags/1.4/bin/install-wp-tests.sh (added)
-
tags/1.4/composer.json (added)
-
tags/1.4/form.php (modified) (3 diffs)
-
tags/1.4/helpers.php (modified) (34 diffs)
-
tags/1.4/lang/mini-loops_fr-FR.mo (added)
-
tags/1.4/lang/mini-loops_fr-FR.po (added)
-
tags/1.4/mini-loops.php (modified) (1 diff)
-
tags/1.4/phpunit.xml (added)
-
tags/1.4/readme.md (added)
-
tags/1.4/readme.txt (modified) (4 diffs)
-
tags/1.4/tests (added)
-
tags/1.4/tests/bootstrap.php (added)
-
tags/1.4/tests/mini-loops-testcase.php (added)
-
tags/1.4/widget.php (modified) (8 diffs)
-
trunk/.editorconfig (added)
-
trunk/CHANGELOG.md (added)
-
trunk/bin (added)
-
trunk/bin/install-wp-tests.sh (added)
-
trunk/composer.json (added)
-
trunk/form.php (modified) (3 diffs)
-
trunk/helpers.php (modified) (34 diffs)
-
trunk/lang/mini-loops_fr-FR.mo (added)
-
trunk/lang/mini-loops_fr-FR.po (added)
-
trunk/mini-loops.php (modified) (1 diff)
-
trunk/phpunit.xml (added)
-
trunk/readme.md (added)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/tests (added)
-
trunk/tests/bootstrap.php (added)
-
trunk/tests/mini-loops-testcase.php (added)
-
trunk/widget.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mini-loops/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
mini-loops/assets/screenshot-1.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
mini-loops/assets/screenshot-2.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
mini-loops/assets/screenshot-3.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
mini-loops/assets/screenshot-4.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
mini-loops/tags/1.4/form.php
r976219 r2546965 1 1 <?php if ( ! defined( 'ABSPATH' ) ) die( '-1' ); ?> 2 2 <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 ); ?>" /> 5 5 </label> 6 6 </p> 7 7 <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 ); ?>" /> 10 10 </label> 11 11 </p> 12 12 <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> 15 15 </p> 16 16 … … 19 19 <div style="width:48%;float:left;"> 20 20 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> 42 42 </label> 43 43 </p> 44 44 <p> 45 45 <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' ) ); ?>"> 48 48 <?php 49 49 echo "<option value='any'" . selected( 'any', $post_type, false ) . ">Any</option>"; 50 50 $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' ) ); ?>"> 61 66 <?php 62 67 echo "<option value='any'" . selected( 'any', $post_status, false ) . ">Any</option>"; 63 68 $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' ) ); ?>"> 74 84 <?php 75 85 $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' ) ); ?>"> 86 101 <?php 87 102 $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> 94 114 </label> 95 115 </p> 96 116 <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 ); ?>" /> 99 119 </p> 100 120 <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> 139 159 </p> 140 160 … … 144 164 145 165 <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&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&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&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&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> 193 218 </p> 194 219 -
mini-loops/tags/1.4/helpers.php
r976219 r2546965 2 2 if ( ! defined( 'ABSPATH' ) ) die( '-1' ); 3 3 4 // Show recent posts function 4 /** 5 * Get default parameters 6 * 7 * @return array 8 */ 5 9 function get_miniloops_defaults() { 6 10 $defs = array( … … 39 43 } 40 44 45 /** 46 * get_miniloops 47 * 48 * @param array $args 49 * @return string 50 */ 41 51 function get_miniloops( $args = '' ) { 42 global $ wpdb, $post;52 global $post; 43 53 $defaults = get_miniloops_defaults(); 44 54 … … 153 163 if ( $maximum_age != 0 ) { 154 164 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 ) ); 156 166 $maximum_age_func = create_function('$filter','global $mini_loops_minimum_date; $filter .= " AND post_date >= \'' . $mini_loops_minimum_date .'\'"; return $filter;'); 157 167 add_filter( 'posts_where', $maximum_age_func ); … … 182 192 $before_items = do_shortcode( miniloops_shortcoder( stripslashes( $before_items ) ) ); 183 193 $before_items = apply_filters( 'miniloops_before_items_format', $before_items, $query, $miniloop, $args ); 194 184 195 $postlist .= $before_items; 185 196 … … 188 199 189 200 $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 ); 190 204 191 205 $item_format_to_use = apply_filters( 'miniloops_item_format', $item_format, $post_format ); … … 208 222 return $postlist; 209 223 } 224 225 /** 226 * miniloops 227 */ 210 228 function 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 */ 214 238 function miniloops_shortcoder( $input ) { 215 239 … … 238 262 } 239 263 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 */ 270 function 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 */ 283 function 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 */ 250 294 function miniloops_word_excerpt( $input, $limit ) { 251 295 $input = explode( ' ', $input ); 252 $input = array_splice( $input, 0, $limit );296 $input = array_splice( $input, 0, (int) $limit ); 253 297 return trim( implode( ' ', $input ) ); 254 298 } 255 299 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 */ 263 307 function get_miniloops_sc( $atts, $content ) { 264 $content = str_replace( '{', '[', str_replace('}', ']', $content ) ); 308 309 $content = str_replace( 310 [ '{', '}' ], 311 [ '[', ']' ], 312 $content 313 ); 314 265 315 if ( strpos( $content, '[ml_format' ) !== false ) { 266 316 $atts['item_format'] = do_shortcode( $content ); 267 317 } 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 ); 269 321 } 270 322 $args = shortcode_atts( get_miniloops_defaults(), $atts ); … … 273 325 } 274 326 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 */ 332 function 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 */ 369 add_shortcode( 'miniloops' , 'get_miniloops_sc'); 370 add_shortcode( 'miniloop' , 'get_miniloops_sc'); 281 371 add_shortcode( 'ml_format' , 'miniloop_item_format' ); 282 function miniloop_item_format( $atts, $content ) { 372 add_shortcode( 'ml_title' , 'miniloop_title' ); 373 add_shortcode( 'ml_url' , 'miniloop_url' ); 374 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' ); 375 add_shortcode( 'ml_content' , 'miniloop_content' ); 376 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' ); 377 add_shortcode( 'ml_author' , 'miniloop_author' ); 378 add_shortcode( 'ml_author_link' , 'miniloop_author_link' ); 379 add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' ); 380 add_shortcode( 'ml_field' , 'miniloop_field' ); 381 add_shortcode( 'ml_category' , 'miniloop_category' ); 382 add_shortcode( 'ml_tag' , 'miniloop_tag' ); 383 add_shortcode( 'ml_tax' , 'miniloop_taxonomy' ); 384 add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' ); 385 add_shortcode( 'ml_date' , 'miniloop_date' ); 386 add_shortcode( 'ml_post_type', 'miniloop_post_type' ); 387 add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' ); 388 add_shortcode( 'ml_class' , 'miniloop_class' ); 389 add_shortcode( 'ml_image' , 'miniloop_image' ); 390 391 /** 392 * miniloop_item_format 393 * shortcode callback 394 * 395 * @param array $atts 396 * @return string 397 */ 398 function miniloop_item_format( $atts ) { 283 399 extract( shortcode_atts( array( 284 400 'name' => 'ml_format', … … 287 403 } 288 404 289 add_shortcode( 'ml_title' , 'miniloop_title' ); 405 /** 406 * miniloop_title 407 * shortcode callback 408 * 409 * @param array $atts 410 * @return string 411 */ 290 412 function miniloop_title( $atts ) { 291 413 extract( shortcode_atts( array( … … 311 433 } 312 434 313 add_shortcode( 'ml_url' , 'miniloop_url' ); 435 /** 436 * miniloop_url 437 * shortcode callback 438 * 439 * @param array $atts 440 * @return string 441 */ 314 442 function miniloop_url( $atts ) { 315 443 extract( shortcode_atts( array( … … 329 457 } 330 458 331 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' ); 459 /** 460 * miniloop_excerpt 461 * shortcode callback 462 * 463 * @param array $atts 464 * @return string 465 */ 332 466 function miniloop_excerpt( $atts ) { 333 467 extract( shortcode_atts( array( … … 410 544 } 411 545 412 add_shortcode( 'ml_content' , 'miniloop_content' ); 546 /** 547 * miniloop_content 548 * shortcode callback 549 * 550 * @param array $atts 551 * @return string 552 */ 413 553 function miniloop_content( $atts ) { 414 554 extract( shortcode_atts( array( … … 424 564 } 425 565 426 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' ); 566 /** 567 * miniloop_comment_count 568 * shortcode callback 569 * 570 * @return string 571 */ 427 572 function miniloop_comment_count() { 428 573 $count = get_comment_count( get_the_ID() ); … … 431 576 } 432 577 433 add_shortcode( 'ml_author' , 'miniloop_author' ); 578 /** 579 * miniloop_author 580 * shortcode callback 581 * 582 * @return string 583 */ 434 584 function miniloop_author() { 435 585 … … 437 587 } 438 588 439 add_shortcode( 'ml_author_link' , 'miniloop_author_link' ); 589 /** 590 * miniloop_author_link 591 * shortcode callback 592 * 593 * @return string 594 */ 440 595 function miniloop_author_link() { 441 596 … … 443 598 } 444 599 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 */ 446 607 function miniloop_author_avatar( $atts ) { 447 608 extract( shortcode_atts( array( … … 455 616 } 456 617 457 add_shortcode( 'ml_field' , 'miniloop_field' ); 618 /** 619 * miniloop_field 620 * shortcode callback 621 * 622 * @param array $atts 623 * @return string 624 */ 458 625 function miniloop_field( $atts ) { 459 626 extract( shortcode_atts( array( … … 479 646 } 480 647 481 add_shortcode( 'ml_category' , 'miniloop_category' ); 648 /** 649 * miniloop_category 650 * shortcode callback 651 * 652 * @param array $atts 653 * @return string 654 */ 482 655 function miniloop_category( $atts ) { 483 656 $atts = shortcode_atts( array( … … 492 665 } 493 666 494 add_shortcode( 'ml_tag' , 'miniloop_tag' ); 667 /** 668 * miniloop_tag 669 * shortcode callback 670 * 671 * @param array $atts 672 * @return string 673 */ 495 674 function miniloop_tag( $atts ) { 496 675 $atts = shortcode_atts( array( … … 505 684 } 506 685 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 */ 509 693 function miniloop_taxonomy( $atts ) { 510 694 extract( shortcode_atts( array( … … 532 716 } 533 717 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 */ 537 728 function miniloop_archive( $atts ) { 538 729 extract( shortcode_atts( array( … … 543 734 return "{$before}##replace|archive##{$after}"; 544 735 } 736 add_shortcode( 'ba_archive' , 'miniloop_archive' ); 737 545 738 // For use with the BETA [ba_archive] shortcode 546 739 add_filter( 'miniloops_before_items_format', 'ml_hackish_filter', 10, 3 ); 547 740 add_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 */ 548 750 function ml_hackish_filter( $before_items, $query, $miniloop ) { 549 751 // if there is nothing to replace, carry on... … … 569 771 } 570 772 571 add_shortcode( 'ml_date' , 'miniloop_date' ); 773 /** 774 * miniloop_date 775 * shortcode callback 776 * 777 * @param array $atts 778 * @return string 779 */ 572 780 function miniloop_date( $atts ) { 573 781 extract( shortcode_atts( array( … … 579 787 } 580 788 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 */ 582 796 function miniloop_post_type( $atts ) { 583 797 extract( shortcode_atts( array( … … 590 804 } 591 805 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 */ 593 813 function miniloop_post_type_archive_link( $atts ) { 594 814 extract( shortcode_atts( array( … … 599 819 } 600 820 601 add_shortcode( 'ml_class' , 'miniloop_class' ); 821 /** 822 * miniloop_class 823 * shortcode callback 824 * 825 * @param array $atts 826 * @return string 827 */ 602 828 function miniloop_class( $atts ) { 603 829 extract( shortcode_atts( array( … … 613 839 } 614 840 615 add_shortcode( 'ml_image' , 'miniloop_image' ); 841 /** 842 * miniloop_image 843 * shortcode callback 844 * 845 * @param array $atts 846 * @return string 847 */ 616 848 function miniloop_image( $atts ) { 617 849 extract( shortcode_atts( array( … … 636 868 637 869 $crop = (bool) $crop; 638 639 870 foreach( $from as $from_where ) { 640 871 switch ( $from_where ) { 641 872 case 'thumb' : 642 643 873 if ( 'clear' == $cache ) { 644 874 miniloops_clear_thumbnail_cache( get_the_ID() ); … … 802 1032 } 803 1033 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 */ 804 1043 function miniloops_create_thumbnail_from_id( $att_id, $width, $height, $crop ) { 805 1044 $upl = wp_upload_dir(); … … 810 1049 } 811 1050 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 */ 812 1060 function miniloops_create_thumbnail_from_path( $file, $width, $height, $crop ) { 813 1061 $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 822 1064 $editor = wp_get_image_editor( $file ); 823 1065 if ( is_wp_error( $editor ) ) { 824 // return $editor;825 1066 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 826 1067 } … … 829 1070 $resized = $editor->resize( $width, $height, $crop ); 830 1071 if ( is_wp_error( $resized ) ) { 831 // return $resized;832 1072 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 833 1073 } … … 837 1077 838 1078 if ( is_wp_error( $saved ) ) { 839 // return $saved;840 1079 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 841 1080 } … … 845 1084 } 846 1085 1086 /** 1087 * miniloops_clear_thumbnail_cache 1088 * 1089 * @param int $post_id 1090 */ 847 1091 function miniloops_clear_thumbnail_cache( $post_id ) { 848 1092 delete_post_meta( $post_id, '_ml_thumb_thumb' ); … … 852 1096 /** 853 1097 * 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 854 1103 */ 855 1104 function miniloops_updated_deleted_post_meta( $meta_ids, $object_id, $meta_key, $_meta_value ) { -
mini-loops/tags/1.4/mini-loops.php
r1346549 r2546965 5 5 Plugin URI: http://trepmal.com/plugins/mini-loops/ 6 6 Description: Query posts and display them where you want 7 Version: 1. 3.17 Version: 1.4 8 8 Author: Kailey Lampert 9 9 Author URI: http://kaileylampert.com 10 10 11 Copyright (C) 2011- 16Kailey Lampert11 Copyright (C) 2011-21 Kailey Lampert 12 12 13 13 This program is free software: you can redistribute it and/or modify -
mini-loops/tags/1.4/readme.txt
r1346549 r2546965 4 4 Donate link: http://kaileylampert.com/donate/ 5 5 Requires at least: 3.5 6 Tested up to: 4.47 Stable tag: 1. 3.16 Tested up to: 5.7 7 Stable tag: 1.4 8 8 License: GPLv2 or later 9 9 … … 15 15 Show most recent posts, posts from categories, and more. Can be displayed via widgets, shortcodes, and template tags. 16 16 17 This is a new release, please report bugs to trepmal (at) gmail (dot) com before leaving a poor review. Thanks 17 Development is now happening at the [GitHub Repo](https://github.com/trepmal/mini-loops) 18 18 19 19 == Installation == … … 341 341 == Upgrade Notice == 342 342 343 = 1.4 = 344 General updates, improved shortcode compat with the Block Editor. 345 343 346 = 1.3 = 344 347 New: Automatically clear thumbnail cache and more. See Changelog … … 372 375 373 376 == Changelog == 377 378 = Version 1.4 = 379 * General upkeep 374 380 375 381 = Version 1.3.1 = -
mini-loops/tags/1.4/widget.php
r1346549 r2546965 4 4 class miniloops extends WP_Widget { 5 5 6 function miniloops() {6 function __construct() { 7 7 $widget_ops = array( 8 8 'classname' => 'miniloops', … … 16 16 function widget( $args, $instance ) { 17 17 18 extract( $args, EXTR_SKIP );18 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped 19 19 20 echo $ before_widget;20 echo $args['before_widget']; 21 21 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']; 25 25 } 26 26 … … 28 28 echo get_miniloops( $instance ); 29 29 30 echo $after_widget; 30 echo $args['after_widget']; 31 32 // phpcs:enable 31 33 32 34 } //end widget() … … 36 38 $instance = $old_instance; 37 39 //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; 40 42 $instance['title_url'] = esc_url( $new_instance['title_url'] ); 41 43 $instance['number_posts'] = (int) $new_instance['number_posts']; … … 47 49 $instance['order'] = esc_attr( $new_instance['order'] ); 48 50 $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; 58 60 $instance['categories'] = esc_attr( $new_instance['categories'] ); 59 61 $instance['tags'] = esc_attr( $new_instance['tags'] ); … … 62 64 $instance['custom_fields'] = esc_attr( $new_instance['custom_fields'] ); 63 65 $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'] ); 67 69 68 70 return $instance; … … 82 84 class miniminiloops extends miniloops { 83 85 84 function miniminiloops() {86 function __construct() { 85 87 $widget_ops = array( 86 88 'classname' => 'miniminiloops', … … 97 99 98 100 ?> 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> 100 102 <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 ); ?>" /> 103 105 </label> 104 106 </p> 105 107 <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> 108 110 </p> 109 111 <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 ); ?>" /> 112 114 </label> 113 115 </p> 114 116 <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 ); ?>" /> 117 119 </label> 118 120 </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> 142 144 <?php 143 145 } //end form() -
mini-loops/trunk/form.php
r976219 r2546965 1 1 <?php if ( ! defined( 'ABSPATH' ) ) die( '-1' ); ?> 2 2 <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 ); ?>" /> 5 5 </label> 6 6 </p> 7 7 <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 ); ?>" /> 10 10 </label> 11 11 </p> 12 12 <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> 15 15 </p> 16 16 … … 19 19 <div style="width:48%;float:left;"> 20 20 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> 42 42 </label> 43 43 </p> 44 44 <p> 45 45 <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' ) ); ?>"> 48 48 <?php 49 49 echo "<option value='any'" . selected( 'any', $post_type, false ) . ">Any</option>"; 50 50 $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' ) ); ?>"> 61 66 <?php 62 67 echo "<option value='any'" . selected( 'any', $post_status, false ) . ">Any</option>"; 63 68 $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' ) ); ?>"> 74 84 <?php 75 85 $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' ) ); ?>"> 86 101 <?php 87 102 $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> 94 114 </label> 95 115 </p> 96 116 <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 ); ?>" /> 99 119 </p> 100 120 <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> 139 159 </p> 140 160 … … 144 164 145 165 <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&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&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&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&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> 193 218 </p> 194 219 -
mini-loops/trunk/helpers.php
r976219 r2546965 2 2 if ( ! defined( 'ABSPATH' ) ) die( '-1' ); 3 3 4 // Show recent posts function 4 /** 5 * Get default parameters 6 * 7 * @return array 8 */ 5 9 function get_miniloops_defaults() { 6 10 $defs = array( … … 39 43 } 40 44 45 /** 46 * get_miniloops 47 * 48 * @param array $args 49 * @return string 50 */ 41 51 function get_miniloops( $args = '' ) { 42 global $ wpdb, $post;52 global $post; 43 53 $defaults = get_miniloops_defaults(); 44 54 … … 153 163 if ( $maximum_age != 0 ) { 154 164 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 ) ); 156 166 $maximum_age_func = create_function('$filter','global $mini_loops_minimum_date; $filter .= " AND post_date >= \'' . $mini_loops_minimum_date .'\'"; return $filter;'); 157 167 add_filter( 'posts_where', $maximum_age_func ); … … 182 192 $before_items = do_shortcode( miniloops_shortcoder( stripslashes( $before_items ) ) ); 183 193 $before_items = apply_filters( 'miniloops_before_items_format', $before_items, $query, $miniloop, $args ); 194 184 195 $postlist .= $before_items; 185 196 … … 188 199 189 200 $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 ); 190 204 191 205 $item_format_to_use = apply_filters( 'miniloops_item_format', $item_format, $post_format ); … … 208 222 return $postlist; 209 223 } 224 225 /** 226 * miniloops 227 */ 210 228 function 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 */ 214 238 function miniloops_shortcoder( $input ) { 215 239 … … 238 262 } 239 263 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 */ 270 function 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 */ 283 function 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 */ 250 294 function miniloops_word_excerpt( $input, $limit ) { 251 295 $input = explode( ' ', $input ); 252 $input = array_splice( $input, 0, $limit );296 $input = array_splice( $input, 0, (int) $limit ); 253 297 return trim( implode( ' ', $input ) ); 254 298 } 255 299 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 */ 263 307 function get_miniloops_sc( $atts, $content ) { 264 $content = str_replace( '{', '[', str_replace('}', ']', $content ) ); 308 309 $content = str_replace( 310 [ '{', '}' ], 311 [ '[', ']' ], 312 $content 313 ); 314 265 315 if ( strpos( $content, '[ml_format' ) !== false ) { 266 316 $atts['item_format'] = do_shortcode( $content ); 267 317 } 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 ); 269 321 } 270 322 $args = shortcode_atts( get_miniloops_defaults(), $atts ); … … 273 325 } 274 326 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 */ 332 function 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 */ 369 add_shortcode( 'miniloops' , 'get_miniloops_sc'); 370 add_shortcode( 'miniloop' , 'get_miniloops_sc'); 281 371 add_shortcode( 'ml_format' , 'miniloop_item_format' ); 282 function miniloop_item_format( $atts, $content ) { 372 add_shortcode( 'ml_title' , 'miniloop_title' ); 373 add_shortcode( 'ml_url' , 'miniloop_url' ); 374 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' ); 375 add_shortcode( 'ml_content' , 'miniloop_content' ); 376 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' ); 377 add_shortcode( 'ml_author' , 'miniloop_author' ); 378 add_shortcode( 'ml_author_link' , 'miniloop_author_link' ); 379 add_shortcode( 'ml_author_avatar' , 'miniloop_author_avatar' ); 380 add_shortcode( 'ml_field' , 'miniloop_field' ); 381 add_shortcode( 'ml_category' , 'miniloop_category' ); 382 add_shortcode( 'ml_tag' , 'miniloop_tag' ); 383 add_shortcode( 'ml_tax' , 'miniloop_taxonomy' ); 384 add_shortcode( 'ml_taxonomy' , 'miniloop_taxonomy' ); 385 add_shortcode( 'ml_date' , 'miniloop_date' ); 386 add_shortcode( 'ml_post_type', 'miniloop_post_type' ); 387 add_shortcode( 'ml_post_type_archive_link', 'miniloop_post_type_archive_link' ); 388 add_shortcode( 'ml_class' , 'miniloop_class' ); 389 add_shortcode( 'ml_image' , 'miniloop_image' ); 390 391 /** 392 * miniloop_item_format 393 * shortcode callback 394 * 395 * @param array $atts 396 * @return string 397 */ 398 function miniloop_item_format( $atts ) { 283 399 extract( shortcode_atts( array( 284 400 'name' => 'ml_format', … … 287 403 } 288 404 289 add_shortcode( 'ml_title' , 'miniloop_title' ); 405 /** 406 * miniloop_title 407 * shortcode callback 408 * 409 * @param array $atts 410 * @return string 411 */ 290 412 function miniloop_title( $atts ) { 291 413 extract( shortcode_atts( array( … … 311 433 } 312 434 313 add_shortcode( 'ml_url' , 'miniloop_url' ); 435 /** 436 * miniloop_url 437 * shortcode callback 438 * 439 * @param array $atts 440 * @return string 441 */ 314 442 function miniloop_url( $atts ) { 315 443 extract( shortcode_atts( array( … … 329 457 } 330 458 331 add_shortcode( 'ml_excerpt' , 'miniloop_excerpt' ); 459 /** 460 * miniloop_excerpt 461 * shortcode callback 462 * 463 * @param array $atts 464 * @return string 465 */ 332 466 function miniloop_excerpt( $atts ) { 333 467 extract( shortcode_atts( array( … … 410 544 } 411 545 412 add_shortcode( 'ml_content' , 'miniloop_content' ); 546 /** 547 * miniloop_content 548 * shortcode callback 549 * 550 * @param array $atts 551 * @return string 552 */ 413 553 function miniloop_content( $atts ) { 414 554 extract( shortcode_atts( array( … … 424 564 } 425 565 426 add_shortcode( 'ml_comment_count' , 'miniloop_comment_count' ); 566 /** 567 * miniloop_comment_count 568 * shortcode callback 569 * 570 * @return string 571 */ 427 572 function miniloop_comment_count() { 428 573 $count = get_comment_count( get_the_ID() ); … … 431 576 } 432 577 433 add_shortcode( 'ml_author' , 'miniloop_author' ); 578 /** 579 * miniloop_author 580 * shortcode callback 581 * 582 * @return string 583 */ 434 584 function miniloop_author() { 435 585 … … 437 587 } 438 588 439 add_shortcode( 'ml_author_link' , 'miniloop_author_link' ); 589 /** 590 * miniloop_author_link 591 * shortcode callback 592 * 593 * @return string 594 */ 440 595 function miniloop_author_link() { 441 596 … … 443 598 } 444 599 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 */ 446 607 function miniloop_author_avatar( $atts ) { 447 608 extract( shortcode_atts( array( … … 455 616 } 456 617 457 add_shortcode( 'ml_field' , 'miniloop_field' ); 618 /** 619 * miniloop_field 620 * shortcode callback 621 * 622 * @param array $atts 623 * @return string 624 */ 458 625 function miniloop_field( $atts ) { 459 626 extract( shortcode_atts( array( … … 479 646 } 480 647 481 add_shortcode( 'ml_category' , 'miniloop_category' ); 648 /** 649 * miniloop_category 650 * shortcode callback 651 * 652 * @param array $atts 653 * @return string 654 */ 482 655 function miniloop_category( $atts ) { 483 656 $atts = shortcode_atts( array( … … 492 665 } 493 666 494 add_shortcode( 'ml_tag' , 'miniloop_tag' ); 667 /** 668 * miniloop_tag 669 * shortcode callback 670 * 671 * @param array $atts 672 * @return string 673 */ 495 674 function miniloop_tag( $atts ) { 496 675 $atts = shortcode_atts( array( … … 505 684 } 506 685 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 */ 509 693 function miniloop_taxonomy( $atts ) { 510 694 extract( shortcode_atts( array( … … 532 716 } 533 717 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 */ 537 728 function miniloop_archive( $atts ) { 538 729 extract( shortcode_atts( array( … … 543 734 return "{$before}##replace|archive##{$after}"; 544 735 } 736 add_shortcode( 'ba_archive' , 'miniloop_archive' ); 737 545 738 // For use with the BETA [ba_archive] shortcode 546 739 add_filter( 'miniloops_before_items_format', 'ml_hackish_filter', 10, 3 ); 547 740 add_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 */ 548 750 function ml_hackish_filter( $before_items, $query, $miniloop ) { 549 751 // if there is nothing to replace, carry on... … … 569 771 } 570 772 571 add_shortcode( 'ml_date' , 'miniloop_date' ); 773 /** 774 * miniloop_date 775 * shortcode callback 776 * 777 * @param array $atts 778 * @return string 779 */ 572 780 function miniloop_date( $atts ) { 573 781 extract( shortcode_atts( array( … … 579 787 } 580 788 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 */ 582 796 function miniloop_post_type( $atts ) { 583 797 extract( shortcode_atts( array( … … 590 804 } 591 805 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 */ 593 813 function miniloop_post_type_archive_link( $atts ) { 594 814 extract( shortcode_atts( array( … … 599 819 } 600 820 601 add_shortcode( 'ml_class' , 'miniloop_class' ); 821 /** 822 * miniloop_class 823 * shortcode callback 824 * 825 * @param array $atts 826 * @return string 827 */ 602 828 function miniloop_class( $atts ) { 603 829 extract( shortcode_atts( array( … … 613 839 } 614 840 615 add_shortcode( 'ml_image' , 'miniloop_image' ); 841 /** 842 * miniloop_image 843 * shortcode callback 844 * 845 * @param array $atts 846 * @return string 847 */ 616 848 function miniloop_image( $atts ) { 617 849 extract( shortcode_atts( array( … … 636 868 637 869 $crop = (bool) $crop; 638 639 870 foreach( $from as $from_where ) { 640 871 switch ( $from_where ) { 641 872 case 'thumb' : 642 643 873 if ( 'clear' == $cache ) { 644 874 miniloops_clear_thumbnail_cache( get_the_ID() ); … … 802 1032 } 803 1033 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 */ 804 1043 function miniloops_create_thumbnail_from_id( $att_id, $width, $height, $crop ) { 805 1044 $upl = wp_upload_dir(); … … 810 1049 } 811 1050 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 */ 812 1060 function miniloops_create_thumbnail_from_path( $file, $width, $height, $crop ) { 813 1061 $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 822 1064 $editor = wp_get_image_editor( $file ); 823 1065 if ( is_wp_error( $editor ) ) { 824 // return $editor;825 1066 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 826 1067 } … … 829 1070 $resized = $editor->resize( $width, $height, $crop ); 830 1071 if ( is_wp_error( $resized ) ) { 831 // return $resized;832 1072 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 833 1073 } … … 837 1077 838 1078 if ( is_wp_error( $saved ) ) { 839 // return $saved;840 1079 return str_replace( $upl['basedir'], $upl['baseurl'], $file ); 841 1080 } … … 845 1084 } 846 1085 1086 /** 1087 * miniloops_clear_thumbnail_cache 1088 * 1089 * @param int $post_id 1090 */ 847 1091 function miniloops_clear_thumbnail_cache( $post_id ) { 848 1092 delete_post_meta( $post_id, '_ml_thumb_thumb' ); … … 852 1096 /** 853 1097 * 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 854 1103 */ 855 1104 function miniloops_updated_deleted_post_meta( $meta_ids, $object_id, $meta_key, $_meta_value ) { -
mini-loops/trunk/mini-loops.php
r1346549 r2546965 5 5 Plugin URI: http://trepmal.com/plugins/mini-loops/ 6 6 Description: Query posts and display them where you want 7 Version: 1. 3.17 Version: 1.4 8 8 Author: Kailey Lampert 9 9 Author URI: http://kaileylampert.com 10 10 11 Copyright (C) 2011- 16Kailey Lampert11 Copyright (C) 2011-21 Kailey Lampert 12 12 13 13 This program is free software: you can redistribute it and/or modify -
mini-loops/trunk/readme.txt
r1346549 r2546965 4 4 Donate link: http://kaileylampert.com/donate/ 5 5 Requires at least: 3.5 6 Tested up to: 4.47 Stable tag: 1. 3.16 Tested up to: 5.7 7 Stable tag: 1.4 8 8 License: GPLv2 or later 9 9 … … 15 15 Show most recent posts, posts from categories, and more. Can be displayed via widgets, shortcodes, and template tags. 16 16 17 This is a new release, please report bugs to trepmal (at) gmail (dot) com before leaving a poor review. Thanks 17 Development is now happening at the [GitHub Repo](https://github.com/trepmal/mini-loops) 18 18 19 19 == Installation == … … 341 341 == Upgrade Notice == 342 342 343 = 1.4 = 344 General updates, improved shortcode compat with the Block Editor. 345 343 346 = 1.3 = 344 347 New: Automatically clear thumbnail cache and more. See Changelog … … 372 375 373 376 == Changelog == 377 378 = Version 1.4 = 379 * General upkeep 374 380 375 381 = Version 1.3.1 = -
mini-loops/trunk/widget.php
r1346549 r2546965 4 4 class miniloops extends WP_Widget { 5 5 6 function miniloops() {6 function __construct() { 7 7 $widget_ops = array( 8 8 'classname' => 'miniloops', … … 16 16 function widget( $args, $instance ) { 17 17 18 extract( $args, EXTR_SKIP );18 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped 19 19 20 echo $ before_widget;20 echo $args['before_widget']; 21 21 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']; 25 25 } 26 26 … … 28 28 echo get_miniloops( $instance ); 29 29 30 echo $after_widget; 30 echo $args['after_widget']; 31 32 // phpcs:enable 31 33 32 34 } //end widget() … … 36 38 $instance = $old_instance; 37 39 //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; 40 42 $instance['title_url'] = esc_url( $new_instance['title_url'] ); 41 43 $instance['number_posts'] = (int) $new_instance['number_posts']; … … 47 49 $instance['order'] = esc_attr( $new_instance['order'] ); 48 50 $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; 58 60 $instance['categories'] = esc_attr( $new_instance['categories'] ); 59 61 $instance['tags'] = esc_attr( $new_instance['tags'] ); … … 62 64 $instance['custom_fields'] = esc_attr( $new_instance['custom_fields'] ); 63 65 $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'] ); 67 69 68 70 return $instance; … … 82 84 class miniminiloops extends miniloops { 83 85 84 function miniminiloops() {86 function __construct() { 85 87 $widget_ops = array( 86 88 'classname' => 'miniminiloops', … … 97 99 98 100 ?> 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> 100 102 <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 ); ?>" /> 103 105 </label> 104 106 </p> 105 107 <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> 108 110 </p> 109 111 <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 ); ?>" /> 112 114 </label> 113 115 </p> 114 116 <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 ); ?>" /> 117 119 </label> 118 120 </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> 142 144 <?php 143 145 } //end form()
Note: See TracChangeset
for help on using the changeset viewer.