Changeset 411180
- Timestamp:
- 07/17/2011 09:23:51 PM (15 years ago)
- Location:
- infinite-scroll/branches/Beta
- Files:
-
- 2 edited
-
infinitescroll.init.js.php (modified) (4 diffs)
-
wp_infinite_scroll.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
infinite-scroll/branches/Beta/infinitescroll.init.js.php
r411053 r411180 9 9 License : http://creativecommons.org/licenses/GPL/2.0/ 10 10 */ 11 define('infscr_version' , '2.0b2.110716'); 12 11 13 header('Content-Type: application/javascript'); 12 14 require_once( '../../../wp-load.php' ); 13 15 wp(); 14 15 define('infscr_version' , '2.0b2.110716');16 16 17 17 function outputLicense() … … 34 34 //Get pathParse and validate it. 35 35 $error = false; 36 if( (!empty($_GET['p'])&&!empty($_GET['s']))&&($_GET['s']==md5(NONCE_KEY.$_GET['p']."infscr".infscr_version)))36 if($pathInfo = unserialize(base64_decode($_GET['p']))) 37 37 { 38 if( !$pathParse = unserialize(base64_decode($_GET['p'])))39 $error = true; 38 if(empty($pathInfo[0])||count($pathInfo[0])<2||empty($pathInfo[1])||$pathInfo[1]!=md5(NONCE_KEY.$pathInfo[0][0]."infscr".$pathInfo[0][1].infscr_version)) 39 $error = true; 40 40 } 41 41 else … … 90 90 contentSelector : "'.$content_selector.'", 91 91 itemSelector : "'.$post_selector.'", 92 pathParse : ["'.$path Parse[0].'", "'.$pathParse[1].'"]92 pathParse : ["'.$pathInfo[0][0].'", "'.$pathInfo[0][1].'"] 93 93 }, function() { window.setTimeout(infinite_scroll_callback(), 1); } ); 94 94 });'; … … 98 98 echo file_get_contents("js/jquery.infinitescroll.min.js"); 99 99 echo 'function infinite_scroll_callback(){'.$js_calls.'} 100 jQuery(document).ready(function($){$("'.$content_selector.'").infinitescroll({debug:'.$debug.',loading:{img:"'.$loading_image.'",msgText:"'.$loading_text.'",finishedMsg:"'.$donetext.'"},state:{currPage:"'.$current_page.'"},nextSelector:"'.$next_selector.'",navSelector:"'.$navigation_selector.'",contentSelector:"'.$content_selector.'",itemSelector:"'.$post_selector.'",pathParse:["'.$path Parse[0].'","'.$pathParse[1].'"]},function(){window.setTimeout(infinite_scroll_callback(),1);});});';100 jQuery(document).ready(function($){$("'.$content_selector.'").infinitescroll({debug:'.$debug.',loading:{img:"'.$loading_image.'",msgText:"'.$loading_text.'",finishedMsg:"'.$donetext.'"},state:{currPage:"'.$current_page.'"},nextSelector:"'.$next_selector.'",navSelector:"'.$navigation_selector.'",contentSelector:"'.$content_selector.'",itemSelector:"'.$post_selector.'",pathParse:["'.$pathInfo[0][0].'","'.$pathInfo[0][1].'"]},function(){window.setTimeout(infinite_scroll_callback(),1);});});'; 101 101 } 102 102 } -
infinite-scroll/branches/Beta/wp_infinite_scroll.php
r411053 r411180 8 8 Author URI: http://www.infinite-scroll.com 9 9 License : http://creativecommons.org/licenses/GPL/2.0/ 10 11 12 BUGS:13 - javascript insertion doesnt work on themes: qwiilm!, craving4green, Lush, no limits, stripedplus14 - Note: Above bug left over from old plugin. Needs verifying.15 10 */ 16 11 define('infscr_version' , '2.0b2.110716'); … … 18 13 define('infscr_enabled' , 'enabled'); 19 14 define('infscr_disabled' , 'disabled'); 20 define('infscr_config' , 'enabledforadmins');21 define('infscr_maint' , 'disabledforadmins');15 define('infscr_config' , 'enabledforadmins'); 16 define('infscr_maint' , 'disabledforadmins'); 22 17 23 18 24 19 // options keys constants 25 define('key_infscr_state' , 'infscr_state');20 define('key_infscr_state' , 'infscr_state'); 26 21 define('key_infscr_js_calls' , 'infscr_js_calls'); 27 define('key_infscr_image' , 'infscr_image');28 define('key_infscr_text' , 'infscr_text');22 define('key_infscr_image' , 'infscr_image'); 23 define('key_infscr_text' , 'infscr_text'); 29 24 define('key_infscr_donetext' , 'infscr_donetext'); 30 define('key_infscr_content_selector' , 'infscr_content_selector');25 define('key_infscr_content_selector' , 'infscr_content_selector'); 31 26 define('key_infscr_nav_selector' , 'infscr_nav_selector'); 32 27 define('key_infscr_post_selector' , 'infscr_post_selector'); … … 34 29 35 30 // add options and defaults 36 add_option(key_infscr_state , infscr_config , 'If InfiniteScroll is turned on, off, or in maintenance');37 add_option(key_infscr_js_calls , '', 'Javascript to execute when new content loads in');38 add_option(key_infscr_image , plugins_url( 'infinite-scroll/ajax-loader.gif'), 'Loading image');39 add_option(key_infscr_text , '<em>Loading the next set of posts...</em>', 'Loading text');40 add_option(key_infscr_donetext , '<em>Congratulations, you\'ve reached the end of the internet.</em>', 'Completed text');41 add_option(key_infscr_content_selector , '#content' , 'Content Div css selector');42 add_option(key_infscr_nav_selector , 'div.navigation', 'Navigation Div css selector');43 add_option(key_infscr_post_selector , '#content div.post' , 'Post Div css selector');44 add_option(key_infscr_next_selector , 'div.navigation a:first' , 'Next page Anchor css selector');45 add_option(key_infscr_viewed_options , false , 'Ever Viewed Options Page');46 add_option(key_infscr_debug , 0, 'Debug Mode');31 add_option(key_infscr_state , infscr_config , 'If InfiniteScroll is turned on, off, or in maintenance'); 32 add_option(key_infscr_js_calls , '' , 'Javascript to execute when new content loads in'); 33 add_option(key_infscr_image , plugins_url( 'infinite-scroll/ajax-loader.gif') , 'Loading image'); 34 add_option(key_infscr_text , '<em>Loading the next set of posts...</em>' , 'Loading text'); 35 add_option(key_infscr_donetext , '<em>Congratulations, you\'ve reached the end of the internet.</em>' , 'Completed text'); 36 add_option(key_infscr_content_selector , '#content' , 'Content Div css selector'); 37 add_option(key_infscr_nav_selector , 'div.navigation' , 'Navigation Div css selector'); 38 add_option(key_infscr_post_selector , '#content div.post' , 'Post Div css selector'); 39 add_option(key_infscr_next_selector , 'div.navigation a:first' , 'Next page Anchor css selector'); 40 add_option(key_infscr_viewed_options , false , 'Ever Viewed Options Page'); 41 add_option(key_infscr_debug , 0 , 'Debug Mode'); 47 42 48 43 // adding actions 49 44 add_action('template_redirect' , 'wp_inf_scroll_pre_init'); 50 add_action('admin_menu' , 'add_wp_inf_scroll_options_page');51 add_action("wp" , 'wp_inf_scroll_404');45 add_action('admin_menu' , 'add_wp_inf_scroll_options_page'); 46 add_action("wp" , 'wp_inf_scroll_404'); 52 47 53 48 if ( get_option(key_infscr_state) == infscr_state_default && get_option(key_infscr_viewed_options) == false && !isset($_POST['submit']) ) … … 112 107 installations. 113 108 Added Build: 110628 */ 114 function wp_inf_scroll_get_pagenum_link() { 109 function wp_inf_scroll_get_pagenum_link() 110 { 115 111 global $wp_rewrite; 116 112 … … 152 148 $result = apply_filters('get_pagenum_link', $result); 153 149 return explode("|||INF-SPLITHERE|||",$result); 154 }150 } 155 151 function wp_inf_scroll_init() 156 152 { 157 153 global $user_level; 158 $load_infinite_scroll = true; 159 $error_reason = ""; 160 154 $load_infinite_scroll = true; 161 155 /* Lets start our pre-flight checks */ 162 if (get_option(key_infscr_state) == infscr_disabled )156 if (get_option(key_infscr_state) == infscr_disabled || (is_page() || is_single()) || (get_option(key_infscr_state) == infscr_maint && $user_level >= 8) || (get_option(key_infscr_state) == infscr_config && $user_level <= 8) || (!have_posts())) 163 157 $load_infinite_scroll = false; 164 else if (is_page() || is_single() ) /* single posts/pages dont get it */165 {166 $error_reason = 'Single post/page';167 $load_infinite_scroll = false;168 }169 else if (get_option(key_infscr_state) == infscr_maint && $user_level >= 8)170 {171 $error_reason = 'Administrator (Maintenance State)';172 $load_infinite_scroll = false;173 }174 else if (get_option(key_infscr_state) == infscr_config && $user_level <= 8)175 {176 $error_reason = 'Visitors (Config State)';177 $load_infinite_scroll = false;178 }179 else if ( !have_posts() )180 {181 $error_reason = 'No Posts to Display';182 $load_infinite_scroll = false;183 }184 158 185 159 /* Pre-flight checks complete. Are we good to fly? */ … … 192 166 $nextpage_no = intval($current_page) + 1; 193 167 $max_page = $wp_query->max_num_pages; 194 $pathParse = base64_encode(serialize(wp_inf_scroll_get_pagenum_link()));195 196 168 if ( !$max_page || $max_page >= $nextpage ) 197 169 { 198 //We have to pass pathParse to the script as the script can't determine the path itself. 199 //We have to introduce some form of validation, so we can validate/sign the pathParse we create. 200 $pathSign = md5(NONCE_KEY.$pathParse."infscr".infscr_version); 201 wp_register_script( "infinite-scroll-init", "$plugin_dir/infinitescroll.init.js.php?p=$pathParse&s=$pathSign", array("jquery"), infscr_version, false ); 170 //We have to pass pathInfo to the script as the script can't determine the path itself. 171 //We have to introduce some form of validation, so we can validate/sign the pathInfo we create. 172 $pathParse = wp_inf_scroll_get_pagenum_link(); 173 $pathInfo = base64_encode(serialize(array($pathParse,md5(NONCE_KEY.$pathParse[0]."infscr".$pathParse[1].infscr_version)))); 174 wp_register_script( "infinite-scroll-init", "$plugin_dir/infinitescroll.init.js.php?p=$pathInfo", array("jquery"), NULL, false ); 202 175 wp_enqueue_script( "infinite-scroll-init" ); 203 176 return true; 204 } 205 else 206 { 207 echo "<!-- Infinite-Scroll not added. Reason: No More Posts To Display After This -->\r\n"; 208 return false; 209 } 177 } 210 178 } 211 else 212 { 213 echo "<!-- Infinite-Scroll not added. Reason: $error_reason -->\r\n"; 214 return false; 215 } 179 return false; 216 180 } 217 181 … … 220 184 // if postback, store options 221 185 if (isset($_POST['info_update'])) 222 {186 { 223 187 check_admin_referer(); 224 188 … … 284 248 // update notification 285 249 echo "<div class='updated'><p><strong>Infinite Scroll options updated</strong></p></div>"; 286 }250 } 287 251 288 252 // output the options page … … 294 258 <div class="wrap"> 295 259 <?php 296 update_option(key_infscr_viewed_options, true);297 if (get_option(key_infscr_state) == infscr_disabled)298 echo wp_inf_scroll_error("Infinite-Scroll plugin is <strong>disabled</strong>.");?>260 update_option(key_infscr_viewed_options, true); 261 if (get_option(key_infscr_state) == infscr_disabled) 262 echo wp_inf_scroll_error("Infinite-Scroll plugin is <strong>disabled</strong>.");?> 299 263 300 <style type="text/css">301 table.infscroll-opttable { width: 100%;}302 table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }303 table.infscroll-opttable th { padding-top: 13px; text-align: right;}304 table.infscroll-opttable td p { margin: 0;}305 table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }306 table.infscroll-opttable dd { margin-bottom: 0 }307 </style>264 <style type="text/css"> 265 table.infscroll-opttable { width: 100%;} 266 table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; } 267 table.infscroll-opttable th { padding-top: 13px; text-align: right;} 268 table.infscroll-opttable td p { margin: 0;} 269 table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; } 270 table.infscroll-opttable dd { margin-bottom: 0 } 271 </style> 308 272 309 273 <h2>Infinite Scroll Options</h2>
Note: See TracChangeset
for help on using the changeset viewer.