Changeset 1580310
- Timestamp:
- 01/23/2017 01:10:48 PM (9 years ago)
- Location:
- selectable-post-and-page/trunk
- Files:
-
- 2 added
- 6 edited
-
assets/css/wp-spp-admin.css (modified) (1 diff)
-
assets/js/wp-spp-admin.js (modified) (4 diffs)
-
languages/selectable-post-and-page.pot (added)
-
readme.txt (modified) (4 diffs)
-
screenshot-3.png (modified) (previous)
-
screenshot-4.png (modified) (previous)
-
screenshot-7.png (added)
-
selectable-post-and-page.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
selectable-post-and-page/trunk/assets/css/wp-spp-admin.css
r1565380 r1580310 46 46 } 47 47 48 .spp-excerpt-length input{ 48 .spp-excerpt-length input, 49 .spp-random-post-num input, 50 .spp-right input{ 49 51 float: right; 50 52 text-align: center; 51 53 } 52 54 55 .spp-right-2 input{ 56 float: right; 57 text-align: left; 58 } 59 -
selectable-post-and-page/trunk/assets/js/wp-spp-admin.js
r1565380 r1580310 21 21 22 22 if ( post_type === 'Page' ) { 23 //$( parent_next_p ).hide();24 23 $( parent_next_p ).slideUp(); 25 24 get_selected_data( false, widget_id, rlt_cont, orderby, order, saved_posts ); … … 28 27 if ( post_type === 'Post' ) { 29 28 var cat_val = $( parent_next_p ).find( 'select' ).val(); 30 //$( parent_next_p ).show();31 29 $( parent_next_p ).slideDown(); 32 30 get_selected_data( cat_val, widget_id, rlt_cont, orderby, order, saved_posts ); … … 83 81 $( container ).empty().html(d); 84 82 }); 85 /*86 $.ajax({87 url: ajaxurl,88 type: 'GET',89 cache: false,90 data: {91 action: 'wp_spp_category_result_edit_form',92 cat: selected_cat,93 id: widget_id,94 page: ( selected_cat === false ) ? true : false95 },96 success: function( d ){97 $( container ).empty().html(d);98 }99 });*/100 83 } 101 84 … … 114 97 } 115 98 }); 99 100 $( 'body' ).on( 'change', 'input[type=checkbox]', function( e ){ 101 var id = $( this ).attr( 'id' ); 102 if ( id.indexOf( 'random_post' ) !== -1) { 103 if ( $(this).is(':checked') ) { 104 $( ".spp-result-list" ).slideUp(); 105 $( ".spp-random-post-num" ).slideDown(); 106 } else { 107 $( ".spp-result-list" ).slideDown(); 108 $( ".spp-random-post-num" ).slideUp(); 109 } 110 } 111 }); 116 112 }); -
selectable-post-and-page/trunk/readme.txt
r1565588 r1580310 1 1 === Selectable Post and Page === 2 2 Contributors: HappyMox, odonbaatar 3 Tags: widget, categories, feature image, posts, recent posts, tags, thumbnails, widget, widgets3 Tags: widget, widgets, posts, categories, pages, feature image, random post, post thumbnails, random featured images 4 4 Requires at least: 4.7 5 5 Tested up to: 4.7 … … 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 10 An advanced posts display widget with many options. Display posts in your sidebars any way you'd like!11 9 12 10 == Description == … … 18 16 * Use for any sidebar. 19 17 * Get post(s) directly by a list of selected posts. 20 * Widget to display the post feature image. 18 * Widget to display the post feature image. 19 * It will be displayed at random as the featured image of any post without an image. 21 20 22 21 == Installation == … … 27 26 == Screenshots == 28 27 Use for widget and sidebar 29 1. Configuring a Selectable Post and Page in wp-admin with the Post and selected category displayed.30 1. Configuring a Selectable Post and Page in wp-admin with the selected page in lists displayed.31 1. Location of a Selectable Post and Page in wp-admin with widgets displayed.32 1. In the fontpage, sigle page or post and category list: Selectable Post and Page displayed pages(named by chrismas day and children's day) using right sidebar.33 1. In the fontpage, sigle page or post and category list: Selectable Post and Page displayed selected post (Post World's fastest land Animal is now racing, category: Fastest Animal) by category.34 1. In the footer of site: Displaying a selected post and pages.35 36 37 28 38 29 == Changelog == 30 = 1.2.0 = 31 * Added Random Post option. 32 * Improve some code. 33 * Added input of "More" and "Date". 34 39 35 = 1.0.0 = 40 36 * Initial release. -
selectable-post-and-page/trunk/selectable-post-and-page.php
r1565380 r1580310 2 2 /* 3 3 Plugin Name: Selectable Post and Page 4 Plugin URI: http ://happymox.wordpress.com/2016/12/28/selectable-post-and-page/5 Description: Add s a widget that can display posts froma single category and page.4 Plugin URI: https://wordpress.org/plugins/selectable-post-and-page/ 5 Description: Add a widget that can display posts from random, a single category and page. 6 6 Author: HappyMox 7 7 Text Domain: selectable-post-and-page 8 Version: 1. 0.08 Version: 1.2.0 9 9 Author URI: http://happymox.wordpress.com 10 10 */ … … 14 14 15 15 if( !defined( 'WP_SPP_VERSION' ) ) { 16 define( 'WP_SPP_VERSION', '1. 0.0' ); // Version of plugin16 define( 'WP_SPP_VERSION', '1.2.0' ); // Version of plugin 17 17 } 18 18 … … 39 39 // Script File 40 40 require_once( WP_SPP_DIR . '/include/class-wp-spp-script.php' ); 41 41 42 42 43 /** … … 67 68 array( $this, 'wp_spp_category_result_edit_form' ) 68 69 ); 70 71 // custom image cropped for SPP 72 add_image_size( 'spp-widget-thumb', 100, 100, true ); 69 73 } 70 74 … … 83 87 } 84 88 } 85 86 if( isset( $instance["posts"] ) ){ 87 // Get array of post info. 88 $cat_posts = new WP_Query( array( 'post__in' => $instance["posts"], 89 90 // Get array of post info. 91 if( isset( $instance["random_post"] ) ) { 92 $qry_arg = array( 'posts_per_page' => $instance["random_post_num"], 93 'post_status' => 'publish', 94 'post_type'=> strtolower( $instance['post_type'] ), 95 'orderby' => 'rand'); 96 } else if( isset( $instance["posts"] ) ){ 97 $qry_arg = array( 'post__in' => $instance["posts"], 89 98 'post_status' => 'publish', 90 99 'post_type'=> strtolower( $instance['post_type'] ), 91 100 'orderby' => $instance['orderby'], 92 'order' => $instance[ 'order_type' ]) 93 ); 101 'order' => $instance[ 'order_type' ]); 102 } else { 103 $qry_arg = ''; 104 } 105 106 if ( $qry_arg != '' ) { 107 $cat_posts = new WP_Query( $qry_arg ); 94 108 } 95 109 … … 104 118 "return '...<div style=\"text-align: right;\">" 105 119 . "<a href=\"' . get_permalink() . '\">" 106 . __( '> More', 'selectable-post-and-page' )120 . __( '> ' . $instance['more_text'], 'selectable-post-and-page' ) 107 121 . "</a></div>';" 108 122 ); 123 109 124 110 125 if( absint( $instance['excerpt_length'] ) > 0 ){ … … 119 134 if( isset( $cat_posts ) ){ 120 135 while( $cat_posts->have_posts() ){ 121 $cat_posts->the_post(); ?>136 $cat_posts->the_post(); ?> 122 137 <div class="post-item"> 123 <h4 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> 124 <?php if ( isset( $instance['post_date'] ) ):?> 125 <p class="post-meta">Date <?php the_time('m/d/Y'); ?></p> 138 <h4 class="post-title"> 139 <a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title_attribute();?>"> 140 <?php the_title();?> 141 </a> 142 </h4> 143 <?php //if ($instance['post_date'] == false):?> 144 <?php if (!isset( $instance['post_date'] )):?> 145 <div style="height: 3px;"></div> 126 146 <?php endif; ?> 127 147 128 <?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && has_post_thumbnail() ) : ?> 148 <?php if (isset( $instance['post_date'] )):?> 149 <p class="post-meta"><?php echo $instance['date_text'];?> <?php the_time('m/d/Y');?></p> 150 <?php endif; ?> 151 152 <?php if (function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && has_post_thumbnail()): ?> 129 153 <div class="post-thumbnail-side"> 130 154 <a class="thumbnail-frame-side" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><!-- nothing to see here --></a> … … 132 156 </div> 133 157 <?php endif; ?> 134 158 159 <?php if( $instance['excerpt_length'] > 0 ):?> 135 160 <div class="cat-post-content"> 136 <?php if( $instance['excerpt_length'] > 0 ):?> 137 <?php the_excerpt(); ?> 138 <?php endif; ?> 161 <?php the_excerpt();?> 139 162 </div> 163 <?php endif; ?> 140 164 </div><?php 141 165 } … … 168 192 $instance['post_type'] = isset( $instance[ 'post_type' ] ) ? $instance['post_type'] : 'Post'; 169 193 $instance[ 'post_date' ] = isset( $instance[ 'post_date' ] ) ? $instance[ 'post_date' ] : false; 194 $instance[ 'random_post' ] = isset( $instance[ 'random_post' ] ) ? $instance[ 'random_post' ] : false; 195 $instance[ 'random_post_num' ] = ( isset( $instance[ 'random_post_num' ] ) && $instance[ 'random_post_num' ] > 0 ) ? $instance[ 'random_post_num' ] : 1; 196 197 $instance['more_text'] = isset( $instance[ 'more_text' ] ) ? $instance['more_text'] : 'More'; 198 $instance['date_text'] = isset( $instance[ 'date_text' ] ) ? $instance['date_text'] : 'Date'; 170 199 $output = ''; 171 200 172 $cat = ($instance['post_type'] == 'Page')? false:$cat;201 $cat = ($instance['post_type'] == 'Page')?false:$cat; 173 202 174 203 $args = array( 'posts_per_page' => 100, … … 180 209 ); 181 210 $selected_posts = new WP_Query( $args ); 182 183 211 184 212 if( isset( $selected_posts ) ) { 185 213 $num = 1; … … 205 233 <label for="<?php echo $this->get_field_id( "hide_widget_title" );?>"> 206 234 <input type="checkbox" id="<?php echo $this->get_field_id( "hide_widget_title" ); ?>" name="<?php echo $this->get_field_name( "hide_widget_title" ); ?>" <?php checked( (bool) $instance['hide_widget_title'], true ); ?> /> 207 <?php _e( "Hide Title", 'selectable-post-and-page' ); ?>235 <?php _e( "Hide Widget title", 'selectable-post-and-page' ); ?> 208 236 </label> 209 237 </p> … … 220 248 <label for="<?php echo $this->get_field_id( "post_type" ) . $value; ?>"> 221 249 <?php _e( $desc, 'selectable-post-and-page' ); ?> 222 </label>250 </label> 223 251 <?php }?> 224 252 … … 257 285 </select> 258 286 </p> 259 <p class="spp-result-list"> 260 <h4><?php _e( 'Selectable Posts', 'selectable-post-and-page' ); ?>:</h4> 261 <div class="selectablepost-<?php echo $this->number . $this->id_base;?> spp-category_result"> 262 <?php echo $output;?> 287 <p> 288 <input type="checkbox" id="<?php echo $this->get_field_id( "random_post" )?>" name="<?php echo $this->get_field_name( "random_post" )?>" <?php checked( (bool) $instance['random_post'], true ); ?> /> 289 <label for="<?php echo $this->get_field_id( "random_post" )?>"> 290 <?php _e( 'Random post', 'selectable-post-and-page' ); ?> 291 </label> 292 </p> 293 <p class="spp-random-post-num"<?php echo ($instance['random_post'] == false)?' style="display: none;"':'' ?>> 294 <label for="<?php echo $this->get_field_id( "random_post_num" ); ?>"> 295 <?php _e( 'Number of posts to show:', 'selectable-post-and-page' ); ?> 296 </label> 297 <input type="text" id="<?php echo $this->get_field_id( "random_post_num" ); ?>" name="<?php echo $this->get_field_name( "random_post_num" ); ?>" value="<?php echo absint($instance['random_post_num']); ?>" size="3" /> 298 </p> 299 <div class="spp-result-list"<?php echo ($instance['random_post'] != false)?' style="display: none;"':'' ?>> 300 <h4><?php _e( 'Selectable Posts:', 'selectable-post-and-page' ); ?></h4> 301 <div class="<?php echo 'selectablepost-'.$this->number . $this->id_base. ' spp-category_result'; ?>"> 302 <?php echo $output; ?> 263 303 </div> 264 </p> 304 </div> 305 265 306 <p class="spp-excerpt-length"> 266 307 <label for="<?php echo $this->get_field_id( "excerpt_length" ); ?>"> … … 269 310 <input type="text" id="<?php echo $this->get_field_id( "excerpt_length" ); ?>" name="<?php echo $this->get_field_name( "excerpt_length" ); ?>" value="<?php echo absint($excerpt_length); ?>" size="3" /> 270 311 </p> 312 <!--------- Begin: More -------------> 271 313 <p> 272 314 <input type="checkbox" id="<?php echo $this->get_field_id( "read_more_link" )?>" name="<?php echo $this->get_field_name( "read_more_link" )?>" <?php checked( (bool) $instance['read_more_link'], true ); ?> /> … … 275 317 </label> 276 318 </p> 319 <p class="spp-right-2"> 320 <label for="<?php echo $this->get_field_id( "more_text" ); ?>"> 321 <?php _e( 'Text (for more):', 'selectable-post-and-page' ); ?> 322 </label> 323 <input type="text" id="<?php echo $this->get_field_id( "more_text" ); ?>" name="<?php echo $this->get_field_name( "more_text" ); ?>" value="<?php echo $instance['more_text']?>" size="23" /> 324 </p> 325 <!--------- End: More -------------> 277 326 <p> 278 327 <input type="checkbox" id="<?php echo $this->get_field_id( "post_date" )?>" name="<?php echo $this->get_field_name( "post_date" )?>" <?php checked( (bool) $instance['post_date'], true ); ?> /> … … 280 329 <?php _e( 'Display Post\'s Date', 'selectable-post-and-page' ); ?> 281 330 </label> 331 </p> 332 <p class="spp-right-2"> 333 <label for="<?php echo $this->get_field_id( "date_text" ); ?>"> 334 <?php _e( 'Text (for date):', 'selectable-post-and-page' ); ?> 335 </label> 336 <input type="text" id="<?php echo $this->get_field_id( "date_text" ); ?>" name="<?php echo $this->get_field_name( "date_text" ); ?>" value="<?php echo $instance['date_text']?>" size="23" /> 282 337 </p> 283 338 <?php … … 331 386 332 387 add_action( 'widgets_init', create_function( '', 'return register_widget("Selectable_Post_And_Page");' ) ); 388 389 function SPP_activate(){ 390 //add_action( 'widgets_init', create_function( '', 'return register_widget("Selectable_Post_And_Page");' ) ); 391 } 392 register_activation_hook( WP_SPP_DIR, 'SPP_active' ); 393 //register_activation_hook( WP_SPP_DIR, array( 'Selectable_Post_And_Page', 'SPP_active') ); 394 395 396 397
Note: See TracChangeset
for help on using the changeset viewer.