Changeset 428453
- Timestamp:
- 08/25/2011 04:13:58 AM (15 years ago)
- Location:
- u-more-recent-posts
- Files:
-
- 3 deleted
- 6 edited
- 8 copied
-
tags/1.4.1 (copied) (copied from u-more-recent-posts/trunk)
-
tags/1.4.1/i (copied) (copied from u-more-recent-posts/trunk/i)
-
tags/1.4.1/inc (copied) (copied from u-more-recent-posts/trunk/inc)
-
tags/1.4.1/inc/script.js (modified) (15 diffs)
-
tags/1.4.1/inc/style.css (modified) (5 diffs)
-
tags/1.4.1/lang (deleted)
-
tags/1.4.1/languages (copied) (copied from u-more-recent-posts/trunk/languages)
-
tags/1.4.1/readme.txt (copied) (copied from u-more-recent-posts/trunk/readme.txt) (2 diffs)
-
tags/1.4.1/screenshot-1.png (copied) (copied from u-more-recent-posts/trunk/screenshot-1.png)
-
tags/1.4.1/screenshot-2.png (copied) (copied from u-more-recent-posts/trunk/screenshot-2.png)
-
tags/1.4.1/u-more-recent-posts.css (deleted)
-
tags/1.4.1/u-more-recent-posts.js (deleted)
-
tags/1.4.1/u-more-recent-posts.php (copied) (copied from u-more-recent-posts/trunk/u-more-recent-posts.php) (13 diffs)
-
trunk/inc/script.js (modified) (15 diffs)
-
trunk/inc/style.css (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/u-more-recent-posts.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
u-more-recent-posts/tags/1.4.1/inc/script.js
r427425 r428453 1 1 2 var UMRP_Widget = function(t , widget_type){2 var UMRP_Widget = function(t){ 3 3 var $ = jQuery; 4 var widget_id = t.id; 5 var container = $(t).find('.umrp-container'); 4 var $t = $(t); 5 var widget_id = t.id.replace('-container', ''); 6 var widget_type = $t.hasClass('widget-type') ? 'widget' : ($t.hasClass('shortcode-type') ? 'shortcode' : ''); 6 7 var list, progress, nav; 7 var options = {}, current_postid , auto_paginate_t;8 var options = {}, current_postid = '', auto_paginate_t; 8 9 9 10 var init = function(){ 10 11 resign_elements(); 11 12 12 if( container.hasClass('single') ){13 var match = /postid-(\d+)/.exec( container.attr('class') );13 if( $t.hasClass('single') ){ 14 var match = /postid-(\d+)/.exec( $t.attr('class') ); 14 15 current_postid = match ? match[1] : ''; 16 $t.removeClass('single'); 15 17 }else{ 16 18 UMRP_Cookie.remove_cookie(widget_id); … … 18 20 19 21 nav.find('a').live('click', function(){ 20 var match = /umrp-page=(\d+)/.exec(this.href); 21 var paged = match ? match[1] : ''; 22 var paged = Number(this.hash.replace('#', '')); 22 23 disappear(paged); 23 24 UMRP_Cookie.add_cookie(widget_id, paged, options.cookiepath); … … 25 26 }); 26 27 27 container.hover(28 $t.hover( 28 29 function(){ 29 30 $(this).addClass('pause'); … … 47 48 if( options.auto_paginate ) 48 49 next_page(); 49 50 50 }, 'json'); 51 51 52 52 }else if( widget_type=='shortcode'){ 53 options = /<!--(.*)-->/.exec( container.html());53 options = /<!--(.*)-->/.exec($t.html()); 54 54 options = $.parseJSON(options[1]); 55 55 } … … 59 59 60 60 var resign_elements = function(){ 61 list = container.find('ul');62 progress = container.find('.umrp-progress');63 nav = container.find('.umrp-nav');61 list = $t.find('.umrp-list'); 62 progress = $t.find('.umrp-progress'); 63 nav = $t.find('.umrp-nav'); 64 64 65 65 var list_pos = list.position(); … … 75 75 widget_id: widget_id, 76 76 paged: paged, 77 current_postid: current_postid ? current_postid : ''77 current_postid: current_postid 78 78 } 79 79 … … 87 87 88 88 $.post(umrp_vars.ajaxurl, data, function(html){ 89 container.html(html);89 $t.html(html); 90 90 resign_elements(); 91 91 appear(); … … 94 94 95 95 var appear = function(){ 96 var w = $(t).width();97 96 var h = list.height(); 98 97 list.css({height: h}); … … 110 109 111 110 case 'slidein': 112 wrap_for_slide();113 list.css({left: w }).animate({left:0}, dur);111 var wrap = wrap_for_slide(); 112 list.css({left: wrap.width()}).animate({left:0}, dur); 114 113 break; 115 114 }; … … 120 119 121 120 var disappear = function(paged){ 122 var w = $(t).width();123 121 var h = list.height(); 124 122 list.css({height: h}); … … 141 139 142 140 case 'slideout': 143 wrap_for_slide();144 list.animate({left:- w}, dur, '', function(){141 var wrap = wrap_for_slide(); 142 list.animate({left:-(wrap.width())}, dur, '', function(){ 145 143 get_list(paged); 146 144 }); … … 156 154 157 155 var wrap_for_slide = function(){ 158 var w = $ (t).width();156 var w = $t.width(); 159 157 var h = list.height(); 160 var wrap = container.find('div.umrp-slide'); 158 var margin = parseInt(list.css('margin-left')) 159 margin += parseInt(list.css('padding-left')); 160 list.width( w-margin ); 161 162 var wrap = $t.find('div.umrp-slide'); 161 163 if( !wrap.length ){ 162 164 wrap = $('<div class="umrp-slide"/>').css({width: w, height: h}); … … 181 183 182 184 var load_next_page = function(){ 183 if( container.hasClass('pause') ){185 if( $t.hasClass('pause') ){ 184 186 next_page(); 185 187 }else{ … … 188 190 } 189 191 } 190 191 192 192 193 init(); … … 230 231 231 232 jQuery(function(){ 232 jQuery('.widget_umrp').each(function(){ 233 new UMRP_Widget( this, 'widget' ); 234 }); 235 jQuery('.umrp-shortcode').each(function(){ 236 new UMRP_Widget( this, 'shortcode' ); 233 jQuery('.umrp-container').each(function(){ 234 new UMRP_Widget( this ); 237 235 }); 238 236 }); -
u-more-recent-posts/tags/1.4.1/inc/style.css
r427425 r428453 3 3 position: relative; 4 4 } 5 .umrp-container ul{5 .umrp-container .umrp-list { 6 6 margin-top: 0 !important; 7 7 margin-bottom: 0 !important; 8 8 } 9 .umrp-container li {9 .umrp-container .umrp-list li { 10 10 clear: both; 11 11 } … … 22 22 min-width: none !important; 23 23 } 24 .umrp- progress {24 .umrp-container .umrp-progress { 25 25 position: absolute; 26 26 top: 0; … … 32 32 /* effect 33 33 --------------------------------------------------------------------------------------- */ 34 .umrp- slide {34 .umrp-container .umrp-slide { 35 35 position: relative; 36 36 overflow: hidden; 37 37 } 38 .umrp- slide ul{38 .umrp-container .umrp-slide .umrp-list { 39 39 position: absolute; 40 40 top:0; … … 79 79 font-weight: normal !important; 80 80 color: #333; 81 text-decoration: none; 81 82 } 82 83 .umrp-nav .current, … … 99 100 font-size: 12px; 100 101 } 101 102 -
u-more-recent-posts/tags/1.4.1/readme.txt
r427432 r428453 5 5 Requires at least: 3.1 6 6 Tested up to: 3.2.1 7 Stable tag: 1.4 7 Stable tag: 1.4.1 8 8 9 9 This plugin make it possible to navigate more recent posts without refreshing screen. … … 41 41 42 42 == Changelog == 43 44 = 1.4.1 = 45 *Changed: DOM Structure 46 *Fixed: Slide effect 43 47 44 48 = 1.4 = -
u-more-recent-posts/tags/1.4.1/u-more-recent-posts.php
r427432 r428453 4 4 Plugin URI: http://urlless.com/u-more-recent-posts/ 5 5 Description: This plugin make it possible to navigate more recent posts without refreshing screen. 6 Version: 1.4 6 Version: 1.4.1 7 7 Author: Taehan Lee 8 8 Author URI: http://urlless.com … … 12 12 13 13 var $id = 'umrp'; 14 var $ver = '1.4 ';14 var $ver = '1.4.1'; 15 15 var $url; 16 16 … … 55 55 } 56 56 57 function the_list_for_widget( $widget_id, $paged='', $current_postid='' ){ 58 $opts = $this->get_widget_option($widget_id); 59 echo $this->get_the_list($opts, $paged, $current_postid, 'wp-'.$widget_id.'-paged'); 60 } 61 62 function the_list_for_shortcode( $list_id, $opts, $paged='', $current_postid='' ){ 63 echo $this->get_the_list($opts, $paged, $current_postid, 'wp-'.$list_id.'-paged' ); 64 } 65 66 function get_the_list($opts, $paged='', $current_postid='', $cookie_key='' ){ 67 $defaults = $this->get_default_options(); 68 $opts = wp_parse_args($opts, $defaults); 57 function ajax() { 58 check_ajax_referer( $this->id.'_nonce' ); 59 60 switch( $_POST['action_scope'] ): 61 62 case 'get_widget_option': 63 $opts = $this->get_widget_option( $_POST['widget_id'] ); 64 $opts['cookiepath'] = COOKIEPATH; 65 echo json_encode( $opts ); 66 break; 67 68 case 'the_list_for_widget': 69 $args = array( 70 'widget_id' => $_POST['widget_id'], 71 'paged' => $_POST['paged'], 72 'current_postid' => $_POST['current_postid'], 73 ); 74 $this->the_list_for_widget( $args ); 75 break; 76 77 case 'the_list_for_shortcode': 78 $args = array( 79 'widget_id' => $_POST['widget_id'], 80 'paged' => $_POST['paged'], 81 'current_postid' => $_POST['current_postid'], 82 'options' => (array) $_POST['options'], 83 ); 84 $this->the_list_for_shortcode( $args ); 85 break; 86 87 endswitch; 88 die(); 89 } 90 91 function get_widget_option($widget_id){ 92 $all_opts = get_option('widget_'.$this->id); 93 $index = (int) preg_replace('/'.$this->id.'-/', '', $widget_id); 94 $opts = $all_opts[$index]; 95 return $opts; 96 } 97 98 function the_list_for_widget( $args ){ 99 if( empty($args['widget_id']) ) 100 return false; 101 $args['options'] = $this->get_widget_option( $args['widget_id'] ); 102 $args['cookie_key'] = 'wp-'.$args['widget_id'].'-paged'; 103 echo $this->get_the_list($args); 104 } 105 106 function the_list_for_shortcode( $args ){ 107 if( empty($args['widget_id']) ) 108 return false; 109 $args['cookie_key'] = 'wp-'.$args['widget_id'].'-paged'; 110 echo $this->get_the_list( $args ); 111 } 112 113 function get_the_list( $args ){ 114 $default_args = array( 115 'options' => array(), 116 'paged' => '', 117 'current_postid' => '', 118 'cookie_key' => '', 119 ); 120 $args = wp_parse_args($args, $default_args); 121 extract($args); 122 123 $default_options = $this->get_default_options(); 124 $opts = wp_parse_args($options, $default_options); 69 125 70 126 $paged = ( empty($paged) AND is_single() AND !empty($_COOKIE[$cookie_key]) ) ? $_COOKIE[$cookie_key] : $paged; 71 127 $paged = max(1, absint($paged)); 72 128 73 $ args = array(74 'posts_per_page' => !empty($opts['number']) ? $opts['number'] : 5,129 $query_args = array( 130 'posts_per_page' => $opts['number'], 75 131 'paged' => $paged, 76 132 'post_status' => 'publish', … … 79 135 80 136 if( !empty($opts['post_type']) ) { 81 $ args['post_type'] = $opts['post_type'];137 $query_args['post_type'] = $opts['post_type']; 82 138 83 139 if( !empty($opts['tax_query']) AND isset($opts['tax_query'][$opts['post_type']]) ) { … … 100 156 $_tax_query['operator'] = $operator; 101 157 102 $ args['tax_query'] = array($_tax_query);158 $query_args['tax_query'] = array($_tax_query); 103 159 } 104 160 } … … 116 172 $authors = join(',', $ex_authors); 117 173 } 118 $ args['author'] = $authors;174 $query_args['author'] = $authors; 119 175 } 120 176 … … 124 180 } 125 181 126 $ args = apply_filters('umrp_query_parameters', $args);127 128 $q = new WP_Query($ args);182 $query_args = apply_filters('umrp_query_parameters', $query_args); 183 184 $q = new WP_Query($query_args); 129 185 if ( !$q->have_posts() ) 130 186 return false; 131 187 132 $ret = '<ul >';188 $ret = '<ul class="umrp-list">'; 133 189 while($q->have_posts()): $q->the_post(); 134 190 $post_id = get_the_ID(); … … 174 230 $total_page = $max_page>0 ? min($max_page, $q->max_num_pages) : $q->max_num_pages; 175 231 $page_args = array( 176 'base' => add_query_arg( 'umrp-page', '%#%', home_url('/') ), 232 'base' => '#%#%', 233 'format' => '', 177 234 'total' => $total_page, 178 235 'current' => $paged, … … 183 240 184 241 if( $page_links ){ 185 $page_links = $opts['navi_label'] . ' ' . $page_links;186 $page_links = '<div class="umrp-nav %s '.$opts['navi_align'].'">'.$page_links .'</div>';242 $page_links_label = $opts['navi_label'] ? '<span class="umrp-nav-label">'.$opts['navi_label'].'</span> ' : ''; 243 $page_links = '<div class="umrp-nav %s '.$opts['navi_align'].'">'.$page_links_label.$page_links.'</div>'; 187 244 $page_links_top = sprintf($page_links, 'umrp-nav-top'); 188 245 $page_links_bottom = sprintf($page_links, 'umrp-nav-bottom'); … … 209 266 function shortcode_display($atts){ 210 267 global $post; 211 $query_args = $this->get_default_options(); 212 foreach($query_args as $k=>$v){ 268 269 $default_atts = array( 270 'id' => 'umrp-shortcode', 271 ); 272 extract( shortcode_atts( $default_atts, $atts ) ); 273 274 $opts = $this->get_default_options(); 275 foreach($opts as $k=>$v){ 213 276 if( isset($atts[$k]) ) 214 $ query_args[$k] = $atts[$k];277 $opts[$k] = $atts[$k]; 215 278 } 216 279 if( isset($atts['tax_query']) ){ 217 $tax_query = wp_parse_args(preg_replace('/&/', '&', $atts['tax_query'])); 218 $query_args['tax_query'] = array($query_args['post_type'] => $tax_query); 219 } 220 $query_string = json_encode($query_args); 221 222 $default_atts = array( 223 'id' => '', 224 ); 225 extract( shortcode_atts( $default_atts, $atts ) ); 226 227 $class = $current_postid = ''; 280 $opts['tax_query'] = array($opts['post_type'] => wp_parse_args(preg_replace('/&/', '&', $atts['tax_query']))); 281 } 282 283 $container_class = 'shortcode-type'; 284 $current_postid = ''; 228 285 if( is_single() ){ 229 $c lass = 'single postid-'.$post->ID;286 $container_class .= ' single postid-'.$post->ID; 230 287 $current_postid = $post->ID; 231 288 } 289 290 $args = array( 291 'widget_id' => $id, 292 'current_postid' => $current_postid, 293 'options' => $opts, 294 ); 232 295 ?> 233 296 <div class="umrp-shortcode" id="<?php echo $id?>"> 234 <?php if( $ query_args['title'] ){ ?>235 <h3 class="umrp-title"><?php echo $ query_args['title']?></h3>297 <?php if( $opts['title'] ){ ?> 298 <h3 class="umrp-title"><?php echo $opts['title']?></h3> 236 299 <?php } ?> 237 <div class="umrp-container <?php echo $class?>">238 <?php echo $this-> get_the_list($query_args);?>239 <!--<?php echo $query_string?>-->300 <div id="<?php echo $id?>-container" class="umrp-container <?php echo $container_class?>"> 301 <?php echo $this->the_list_for_shortcode($args);?> 302 <!--<?php echo json_encode($opts)?>--> 240 303 </div> 241 304 </div> … … 243 306 } 244 307 245 function ajax() {246 check_ajax_referer( $this->id.'_nonce' );247 248 switch( $_POST['action_scope'] ):249 250 case 'get_widget_option':251 $opts = $this->get_widget_option( $_POST['widget_id'] );252 $opts['cookiepath'] = COOKIEPATH;253 echo json_encode( $opts );254 break;255 256 case 'the_list_for_widget':257 $this->the_list_for_widget( $_POST['widget_id'], $_POST['paged'], $_POST['current_postid'] );258 break;259 260 case 'the_list_for_shortcode':261 $this->the_list_for_shortcode( $_POST['widget_id'], (array) $_POST['options'], $_POST['paged'], $_POST['current_postid'] );262 break;263 264 endswitch;265 die();266 }267 308 268 309 function filter_where( $where = '' ) { … … 272 313 } 273 314 274 275 function get_widget_option($widget_id){276 $opts = get_option('widget_'.$this->id);277 $widget_id = (int) preg_replace('/'.$this->id.'-/', '', $widget_id);278 $opts = $opts[$widget_id];279 return $opts;280 }281 315 282 316 function get_post_thumbnail( $post_id, $w, $h ){ … … 353 387 354 388 extract($args); 389 355 390 $title = apply_filters('widget_title', $instance['title']); 391 $id = (int) str_replace('umrp-', '', $widget_id); 392 393 $container_class = 'widget-type'; 394 $current_postid = ''; 395 if( is_single() ){ 396 $container_class .= ' single postid-'.$post->ID; 397 $current_postid = $post->ID; 398 } 399 400 if( !empty($instance['custom_css']) ){ 401 $custom_css = preg_replace('/%widget_id%/', '#'.$widget_id.'-container', $instance['custom_css']); 402 $custom_css = preg_replace('/(\r|\n)/', '', $custom_css); 403 $custom_css = '<style>'.$custom_css.'</style>'; 404 } 405 406 $args = array( 407 'widget_id' => $widget_id, 408 'current_postid' => $current_postid, 409 ); 410 356 411 echo $before_widget; 357 if( $title ) echo $before_title . $title . $after_title; 358 359 $class = $current_postid = ''; 360 if( is_single() ){ 361 $class = 'single postid-'.$post->ID; 362 $current_postid = $post->ID; 363 } 412 if( $title ) 413 echo $before_title.$title.$after_title; 364 414 ?> 365 <div class="umrp-container <?php echo $class?>"> 366 <?php $umrp->the_list_for_widget( $widget_id, '', $current_postid );?> 415 416 <div id="umrp-<?php echo $id?>-container" class="umrp-container <?php echo $container_class?>"> 417 <?php $umrp->the_list_for_widget( $args );?> 367 418 </div> 419 368 420 <?php 369 if( !empty($instance['custom_css']) ){ 370 $css = $instance['custom_css']; 371 $css = str_replace('%widget_id%', '#'.$args['widget_id'], $css); 372 $css = preg_replace('/(\r|\n)/', '', $css); 373 echo '<style>'.$css.'</style>'; 374 } 375 421 echo $custom_css; 376 422 echo $after_widget; 377 423 } -
u-more-recent-posts/trunk/inc/script.js
r427425 r428453 1 1 2 var UMRP_Widget = function(t , widget_type){2 var UMRP_Widget = function(t){ 3 3 var $ = jQuery; 4 var widget_id = t.id; 5 var container = $(t).find('.umrp-container'); 4 var $t = $(t); 5 var widget_id = t.id.replace('-container', ''); 6 var widget_type = $t.hasClass('widget-type') ? 'widget' : ($t.hasClass('shortcode-type') ? 'shortcode' : ''); 6 7 var list, progress, nav; 7 var options = {}, current_postid , auto_paginate_t;8 var options = {}, current_postid = '', auto_paginate_t; 8 9 9 10 var init = function(){ 10 11 resign_elements(); 11 12 12 if( container.hasClass('single') ){13 var match = /postid-(\d+)/.exec( container.attr('class') );13 if( $t.hasClass('single') ){ 14 var match = /postid-(\d+)/.exec( $t.attr('class') ); 14 15 current_postid = match ? match[1] : ''; 16 $t.removeClass('single'); 15 17 }else{ 16 18 UMRP_Cookie.remove_cookie(widget_id); … … 18 20 19 21 nav.find('a').live('click', function(){ 20 var match = /umrp-page=(\d+)/.exec(this.href); 21 var paged = match ? match[1] : ''; 22 var paged = Number(this.hash.replace('#', '')); 22 23 disappear(paged); 23 24 UMRP_Cookie.add_cookie(widget_id, paged, options.cookiepath); … … 25 26 }); 26 27 27 container.hover(28 $t.hover( 28 29 function(){ 29 30 $(this).addClass('pause'); … … 47 48 if( options.auto_paginate ) 48 49 next_page(); 49 50 50 }, 'json'); 51 51 52 52 }else if( widget_type=='shortcode'){ 53 options = /<!--(.*)-->/.exec( container.html());53 options = /<!--(.*)-->/.exec($t.html()); 54 54 options = $.parseJSON(options[1]); 55 55 } … … 59 59 60 60 var resign_elements = function(){ 61 list = container.find('ul');62 progress = container.find('.umrp-progress');63 nav = container.find('.umrp-nav');61 list = $t.find('.umrp-list'); 62 progress = $t.find('.umrp-progress'); 63 nav = $t.find('.umrp-nav'); 64 64 65 65 var list_pos = list.position(); … … 75 75 widget_id: widget_id, 76 76 paged: paged, 77 current_postid: current_postid ? current_postid : ''77 current_postid: current_postid 78 78 } 79 79 … … 87 87 88 88 $.post(umrp_vars.ajaxurl, data, function(html){ 89 container.html(html);89 $t.html(html); 90 90 resign_elements(); 91 91 appear(); … … 94 94 95 95 var appear = function(){ 96 var w = $(t).width();97 96 var h = list.height(); 98 97 list.css({height: h}); … … 110 109 111 110 case 'slidein': 112 wrap_for_slide();113 list.css({left: w }).animate({left:0}, dur);111 var wrap = wrap_for_slide(); 112 list.css({left: wrap.width()}).animate({left:0}, dur); 114 113 break; 115 114 }; … … 120 119 121 120 var disappear = function(paged){ 122 var w = $(t).width();123 121 var h = list.height(); 124 122 list.css({height: h}); … … 141 139 142 140 case 'slideout': 143 wrap_for_slide();144 list.animate({left:- w}, dur, '', function(){141 var wrap = wrap_for_slide(); 142 list.animate({left:-(wrap.width())}, dur, '', function(){ 145 143 get_list(paged); 146 144 }); … … 156 154 157 155 var wrap_for_slide = function(){ 158 var w = $ (t).width();156 var w = $t.width(); 159 157 var h = list.height(); 160 var wrap = container.find('div.umrp-slide'); 158 var margin = parseInt(list.css('margin-left')) 159 margin += parseInt(list.css('padding-left')); 160 list.width( w-margin ); 161 162 var wrap = $t.find('div.umrp-slide'); 161 163 if( !wrap.length ){ 162 164 wrap = $('<div class="umrp-slide"/>').css({width: w, height: h}); … … 181 183 182 184 var load_next_page = function(){ 183 if( container.hasClass('pause') ){185 if( $t.hasClass('pause') ){ 184 186 next_page(); 185 187 }else{ … … 188 190 } 189 191 } 190 191 192 192 193 init(); … … 230 231 231 232 jQuery(function(){ 232 jQuery('.widget_umrp').each(function(){ 233 new UMRP_Widget( this, 'widget' ); 234 }); 235 jQuery('.umrp-shortcode').each(function(){ 236 new UMRP_Widget( this, 'shortcode' ); 233 jQuery('.umrp-container').each(function(){ 234 new UMRP_Widget( this ); 237 235 }); 238 236 }); -
u-more-recent-posts/trunk/inc/style.css
r427425 r428453 3 3 position: relative; 4 4 } 5 .umrp-container ul{5 .umrp-container .umrp-list { 6 6 margin-top: 0 !important; 7 7 margin-bottom: 0 !important; 8 8 } 9 .umrp-container li {9 .umrp-container .umrp-list li { 10 10 clear: both; 11 11 } … … 22 22 min-width: none !important; 23 23 } 24 .umrp- progress {24 .umrp-container .umrp-progress { 25 25 position: absolute; 26 26 top: 0; … … 32 32 /* effect 33 33 --------------------------------------------------------------------------------------- */ 34 .umrp- slide {34 .umrp-container .umrp-slide { 35 35 position: relative; 36 36 overflow: hidden; 37 37 } 38 .umrp- slide ul{38 .umrp-container .umrp-slide .umrp-list { 39 39 position: absolute; 40 40 top:0; … … 79 79 font-weight: normal !important; 80 80 color: #333; 81 text-decoration: none; 81 82 } 82 83 .umrp-nav .current, … … 99 100 font-size: 12px; 100 101 } 101 102 -
u-more-recent-posts/trunk/readme.txt
r427432 r428453 5 5 Requires at least: 3.1 6 6 Tested up to: 3.2.1 7 Stable tag: 1.4 7 Stable tag: 1.4.1 8 8 9 9 This plugin make it possible to navigate more recent posts without refreshing screen. … … 41 41 42 42 == Changelog == 43 44 = 1.4.1 = 45 *Changed: DOM Structure 46 *Fixed: Slide effect 43 47 44 48 = 1.4 = -
u-more-recent-posts/trunk/u-more-recent-posts.php
r427432 r428453 4 4 Plugin URI: http://urlless.com/u-more-recent-posts/ 5 5 Description: This plugin make it possible to navigate more recent posts without refreshing screen. 6 Version: 1.4 6 Version: 1.4.1 7 7 Author: Taehan Lee 8 8 Author URI: http://urlless.com … … 12 12 13 13 var $id = 'umrp'; 14 var $ver = '1.4 ';14 var $ver = '1.4.1'; 15 15 var $url; 16 16 … … 55 55 } 56 56 57 function the_list_for_widget( $widget_id, $paged='', $current_postid='' ){ 58 $opts = $this->get_widget_option($widget_id); 59 echo $this->get_the_list($opts, $paged, $current_postid, 'wp-'.$widget_id.'-paged'); 60 } 61 62 function the_list_for_shortcode( $list_id, $opts, $paged='', $current_postid='' ){ 63 echo $this->get_the_list($opts, $paged, $current_postid, 'wp-'.$list_id.'-paged' ); 64 } 65 66 function get_the_list($opts, $paged='', $current_postid='', $cookie_key='' ){ 67 $defaults = $this->get_default_options(); 68 $opts = wp_parse_args($opts, $defaults); 57 function ajax() { 58 check_ajax_referer( $this->id.'_nonce' ); 59 60 switch( $_POST['action_scope'] ): 61 62 case 'get_widget_option': 63 $opts = $this->get_widget_option( $_POST['widget_id'] ); 64 $opts['cookiepath'] = COOKIEPATH; 65 echo json_encode( $opts ); 66 break; 67 68 case 'the_list_for_widget': 69 $args = array( 70 'widget_id' => $_POST['widget_id'], 71 'paged' => $_POST['paged'], 72 'current_postid' => $_POST['current_postid'], 73 ); 74 $this->the_list_for_widget( $args ); 75 break; 76 77 case 'the_list_for_shortcode': 78 $args = array( 79 'widget_id' => $_POST['widget_id'], 80 'paged' => $_POST['paged'], 81 'current_postid' => $_POST['current_postid'], 82 'options' => (array) $_POST['options'], 83 ); 84 $this->the_list_for_shortcode( $args ); 85 break; 86 87 endswitch; 88 die(); 89 } 90 91 function get_widget_option($widget_id){ 92 $all_opts = get_option('widget_'.$this->id); 93 $index = (int) preg_replace('/'.$this->id.'-/', '', $widget_id); 94 $opts = $all_opts[$index]; 95 return $opts; 96 } 97 98 function the_list_for_widget( $args ){ 99 if( empty($args['widget_id']) ) 100 return false; 101 $args['options'] = $this->get_widget_option( $args['widget_id'] ); 102 $args['cookie_key'] = 'wp-'.$args['widget_id'].'-paged'; 103 echo $this->get_the_list($args); 104 } 105 106 function the_list_for_shortcode( $args ){ 107 if( empty($args['widget_id']) ) 108 return false; 109 $args['cookie_key'] = 'wp-'.$args['widget_id'].'-paged'; 110 echo $this->get_the_list( $args ); 111 } 112 113 function get_the_list( $args ){ 114 $default_args = array( 115 'options' => array(), 116 'paged' => '', 117 'current_postid' => '', 118 'cookie_key' => '', 119 ); 120 $args = wp_parse_args($args, $default_args); 121 extract($args); 122 123 $default_options = $this->get_default_options(); 124 $opts = wp_parse_args($options, $default_options); 69 125 70 126 $paged = ( empty($paged) AND is_single() AND !empty($_COOKIE[$cookie_key]) ) ? $_COOKIE[$cookie_key] : $paged; 71 127 $paged = max(1, absint($paged)); 72 128 73 $ args = array(74 'posts_per_page' => !empty($opts['number']) ? $opts['number'] : 5,129 $query_args = array( 130 'posts_per_page' => $opts['number'], 75 131 'paged' => $paged, 76 132 'post_status' => 'publish', … … 79 135 80 136 if( !empty($opts['post_type']) ) { 81 $ args['post_type'] = $opts['post_type'];137 $query_args['post_type'] = $opts['post_type']; 82 138 83 139 if( !empty($opts['tax_query']) AND isset($opts['tax_query'][$opts['post_type']]) ) { … … 100 156 $_tax_query['operator'] = $operator; 101 157 102 $ args['tax_query'] = array($_tax_query);158 $query_args['tax_query'] = array($_tax_query); 103 159 } 104 160 } … … 116 172 $authors = join(',', $ex_authors); 117 173 } 118 $ args['author'] = $authors;174 $query_args['author'] = $authors; 119 175 } 120 176 … … 124 180 } 125 181 126 $ args = apply_filters('umrp_query_parameters', $args);127 128 $q = new WP_Query($ args);182 $query_args = apply_filters('umrp_query_parameters', $query_args); 183 184 $q = new WP_Query($query_args); 129 185 if ( !$q->have_posts() ) 130 186 return false; 131 187 132 $ret = '<ul >';188 $ret = '<ul class="umrp-list">'; 133 189 while($q->have_posts()): $q->the_post(); 134 190 $post_id = get_the_ID(); … … 174 230 $total_page = $max_page>0 ? min($max_page, $q->max_num_pages) : $q->max_num_pages; 175 231 $page_args = array( 176 'base' => add_query_arg( 'umrp-page', '%#%', home_url('/') ), 232 'base' => '#%#%', 233 'format' => '', 177 234 'total' => $total_page, 178 235 'current' => $paged, … … 183 240 184 241 if( $page_links ){ 185 $page_links = $opts['navi_label'] . ' ' . $page_links;186 $page_links = '<div class="umrp-nav %s '.$opts['navi_align'].'">'.$page_links .'</div>';242 $page_links_label = $opts['navi_label'] ? '<span class="umrp-nav-label">'.$opts['navi_label'].'</span> ' : ''; 243 $page_links = '<div class="umrp-nav %s '.$opts['navi_align'].'">'.$page_links_label.$page_links.'</div>'; 187 244 $page_links_top = sprintf($page_links, 'umrp-nav-top'); 188 245 $page_links_bottom = sprintf($page_links, 'umrp-nav-bottom'); … … 209 266 function shortcode_display($atts){ 210 267 global $post; 211 $query_args = $this->get_default_options(); 212 foreach($query_args as $k=>$v){ 268 269 $default_atts = array( 270 'id' => 'umrp-shortcode', 271 ); 272 extract( shortcode_atts( $default_atts, $atts ) ); 273 274 $opts = $this->get_default_options(); 275 foreach($opts as $k=>$v){ 213 276 if( isset($atts[$k]) ) 214 $ query_args[$k] = $atts[$k];277 $opts[$k] = $atts[$k]; 215 278 } 216 279 if( isset($atts['tax_query']) ){ 217 $tax_query = wp_parse_args(preg_replace('/&/', '&', $atts['tax_query'])); 218 $query_args['tax_query'] = array($query_args['post_type'] => $tax_query); 219 } 220 $query_string = json_encode($query_args); 221 222 $default_atts = array( 223 'id' => '', 224 ); 225 extract( shortcode_atts( $default_atts, $atts ) ); 226 227 $class = $current_postid = ''; 280 $opts['tax_query'] = array($opts['post_type'] => wp_parse_args(preg_replace('/&/', '&', $atts['tax_query']))); 281 } 282 283 $container_class = 'shortcode-type'; 284 $current_postid = ''; 228 285 if( is_single() ){ 229 $c lass = 'single postid-'.$post->ID;286 $container_class .= ' single postid-'.$post->ID; 230 287 $current_postid = $post->ID; 231 288 } 289 290 $args = array( 291 'widget_id' => $id, 292 'current_postid' => $current_postid, 293 'options' => $opts, 294 ); 232 295 ?> 233 296 <div class="umrp-shortcode" id="<?php echo $id?>"> 234 <?php if( $ query_args['title'] ){ ?>235 <h3 class="umrp-title"><?php echo $ query_args['title']?></h3>297 <?php if( $opts['title'] ){ ?> 298 <h3 class="umrp-title"><?php echo $opts['title']?></h3> 236 299 <?php } ?> 237 <div class="umrp-container <?php echo $class?>">238 <?php echo $this-> get_the_list($query_args);?>239 <!--<?php echo $query_string?>-->300 <div id="<?php echo $id?>-container" class="umrp-container <?php echo $container_class?>"> 301 <?php echo $this->the_list_for_shortcode($args);?> 302 <!--<?php echo json_encode($opts)?>--> 240 303 </div> 241 304 </div> … … 243 306 } 244 307 245 function ajax() {246 check_ajax_referer( $this->id.'_nonce' );247 248 switch( $_POST['action_scope'] ):249 250 case 'get_widget_option':251 $opts = $this->get_widget_option( $_POST['widget_id'] );252 $opts['cookiepath'] = COOKIEPATH;253 echo json_encode( $opts );254 break;255 256 case 'the_list_for_widget':257 $this->the_list_for_widget( $_POST['widget_id'], $_POST['paged'], $_POST['current_postid'] );258 break;259 260 case 'the_list_for_shortcode':261 $this->the_list_for_shortcode( $_POST['widget_id'], (array) $_POST['options'], $_POST['paged'], $_POST['current_postid'] );262 break;263 264 endswitch;265 die();266 }267 308 268 309 function filter_where( $where = '' ) { … … 272 313 } 273 314 274 275 function get_widget_option($widget_id){276 $opts = get_option('widget_'.$this->id);277 $widget_id = (int) preg_replace('/'.$this->id.'-/', '', $widget_id);278 $opts = $opts[$widget_id];279 return $opts;280 }281 315 282 316 function get_post_thumbnail( $post_id, $w, $h ){ … … 353 387 354 388 extract($args); 389 355 390 $title = apply_filters('widget_title', $instance['title']); 391 $id = (int) str_replace('umrp-', '', $widget_id); 392 393 $container_class = 'widget-type'; 394 $current_postid = ''; 395 if( is_single() ){ 396 $container_class .= ' single postid-'.$post->ID; 397 $current_postid = $post->ID; 398 } 399 400 if( !empty($instance['custom_css']) ){ 401 $custom_css = preg_replace('/%widget_id%/', '#'.$widget_id.'-container', $instance['custom_css']); 402 $custom_css = preg_replace('/(\r|\n)/', '', $custom_css); 403 $custom_css = '<style>'.$custom_css.'</style>'; 404 } 405 406 $args = array( 407 'widget_id' => $widget_id, 408 'current_postid' => $current_postid, 409 ); 410 356 411 echo $before_widget; 357 if( $title ) echo $before_title . $title . $after_title; 358 359 $class = $current_postid = ''; 360 if( is_single() ){ 361 $class = 'single postid-'.$post->ID; 362 $current_postid = $post->ID; 363 } 412 if( $title ) 413 echo $before_title.$title.$after_title; 364 414 ?> 365 <div class="umrp-container <?php echo $class?>"> 366 <?php $umrp->the_list_for_widget( $widget_id, '', $current_postid );?> 415 416 <div id="umrp-<?php echo $id?>-container" class="umrp-container <?php echo $container_class?>"> 417 <?php $umrp->the_list_for_widget( $args );?> 367 418 </div> 419 368 420 <?php 369 if( !empty($instance['custom_css']) ){ 370 $css = $instance['custom_css']; 371 $css = str_replace('%widget_id%', '#'.$args['widget_id'], $css); 372 $css = preg_replace('/(\r|\n)/', '', $css); 373 echo '<style>'.$css.'</style>'; 374 } 375 421 echo $custom_css; 376 422 echo $after_widget; 377 423 }
Note: See TracChangeset
for help on using the changeset viewer.