Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Copy from Beta to Trunk; merge wouldn't work..

  • Loading branch information...
commit 7a62b0eaf10d7bdbc3a77e26b650652c98c8e825 1 parent 9d48471
@samcleaver samcleaver authored
View
11 includes/admin.css
@@ -0,0 +1,11 @@
+/* Admin CSS */
+table.infscroll-opttable { width: 100%; }
+table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }
+table.infscroll-opttable th { padding-top: 9px; text-align: right;}
+table.infscroll-opttable td p { margin: 0;}
+table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }
+table.infscroll-opttable dd { margin-bottom: 0 }
+.infscroll-tab { display:none; }
+.infscroll-tab-active { display:block; }
+.infscroll_preset_nav { text-align: right; padding-top: 25px;}
+.form-table th { width: 20%; font-weight:bold; text-align:right; }
View
18 includes/helpinfo.html
@@ -0,0 +1,18 @@
+<p>This screen allows you to change the settings for the Infinite-Scroll plugin.</p>
+<p> The most common issues that users face when trying to set this plugin up are either:
+ <ul>
+ <li>They don't know what selectors to use.</li>
+ <li>The plugin doesn't work correctly with a certain theme or plugin. (In rare cases it might even break them!)</li>
+ </ul> </p>
+ <p> If you are having either of the problems above or perhaps something different then fear not! We actively monitor the forums over at <a href="http://wordpress.org/tags/infinite-scroll?forum_id=10" target="_blank">Wordpress Support</a>. Remember, your issue will be looked at/rectified faster if you provide all or some of the following info:
+ <ul>
+ <li>Version of the script you are using. <em>HINT: You are currently running version: {INFSCROLL_VERSION}</em></li>
+ <li>The exact issue you are seeing, with as much detail as possible. Its near impossible to help when you open a thread screaming "IT DOESNT WORK!! PLZ HELP. KTHNX.&lt;end post&gt;".</li>
+ <li>An example that we can look at, be it the url to the site you are working on or at the very least the combination of theme/plugins that you are running.</li>
+ <li>Use common sense, if theres additional info that you think will help us help you then put it in the post.</li>
+ </ul> </p>
+ <p> Finally, I'd like to take this opportunity to thank all the <a href="https://github.com/paulirish/infinite-scroll/contributors" target="_blank">contributors</a> to Infinite-Scroll. <a href="https://github.com/dirkhaim" target="_blank">Dirkhaim</a>/<a href="http://paulirish.com/" target="_blank">Paul Irish</a> for getting this Wordpress plugin going. </p>
+ <p><strong> Useful Links: </strong></p>
+ <p> <a href="http://wordpress.org/extend/plugins/infinite-scroll/" target="_blank">Infinite-Scroll Wordpress Plugin Site</a> </p>
+ <p> <a href="https://github.com/paulirish/infinite-scroll/" target="_blank">Infinite-Scroll Github</a> </p>
+ <p> <em>Enjoy Infinitely Scrolling! - <a href="http://beaver6813.com" target="_blank">Beaver6813</a></em> </p>
View
265 includes/infinite-scroll.class.php
@@ -0,0 +1,265 @@
+<?php
+/*Infinite-Scroll Main Class
+Dependencies: Wordpress.*/
+class infiniteScroll {
+static $Version, $Defaults, $PresetRepo, $PresetDB, $PresetRev;
+public function __construct()
+ {
+ self::$Version = '2.0b2.120111';
+ self::$PresetRepo = 'http://plugins.svn.wordpress.org/infinite-scroll/branches/PresetDB/PresetDB.csv.php';
+ self::$PresetDB = WP_PLUGIN_DIR."/infinite-scroll/PresetDB.csv.php";
+ self::$PresetRev = WP_PLUGIN_DIR."/infinite-scroll/PresetDB.rev.php";
+ //Load defaults
+ self::$Defaults = array(
+ 'general' => array(
+ 'infscr_state' => array('enabledforadmins',"Infinite Scroll State Is","dropdown",array("disabled"=>"OFF","disabledforadmins"=>"ON for Visitors Only","enabledforadmins"=>"ON for Admins Only","enabled"=>"ON")),
+ 'infscr_debug' => array('0',"Debug Mode","dropdown",array(0=>"OFF",1=>"ON")),
+ 'infscr_behavior' => array('undefined',"Scrolling Behavior","dropdown",array('undefined'=>"Automatic",'twitter'=>"Manual Triggering")),
+ 'infscr_js_calls' => array('',"Javascript to be called after the next posts are fetched","textarea"),
+ 'infscr_image' => array(plugins_url('infinite-scroll/ajax-loader.gif'),"Loading Image","fileupload"),
+ 'infscr_image_align' => array(1,"Loading Image Align","dropdown",array(0=>"Left",1=>"Centre",2=>"Right")),
+ 'infscr_text' => array('<em>Loading the next set of posts...</em>',"Loading Text","textarea"),
+ 'infscr_donetext' => array('<em>Congratulations, you\'ve reached the end of the internet.</em>',"\"You've reached the end\" text","textarea")),
+ 'selectors' => array(
+ 'infscr_content_selector' => array('#content',"Content Selector","text"),
+ 'infscr_post_selector' => array('#content div.post',"Posts Selector","text"),
+ 'infscr_nav_selector' => array('div.navigation',"Navigation Selector","text"),
+ 'infscr_next_selector' => array('div.navigation a:first',"Next Page Selector","text")),
+ 'misc' => array(
+ 'infscr_viewed_options' => array(false,false,false,false))
+ );
+ }
+public static function addDefaults()
+ {
+ $tmp = get_option('infscr_options');
+ if(!is_array($tmp))
+ {
+ //infscr_options doesn't exist, check for legacy
+ $stateopts = get_option('infscr_state');
+ if(!empty($stateopts))
+ {
+ //We have legacy! Lets run an import
+ $legacyarray = array();
+ foreach(self::$Defaults as $key => $value)
+ {
+ foreach($value as $innerkey => $innerval)
+ {
+ $legacyarray[$innerkey] = get_option($innerkey);
+ }
+ }
+ update_option('infscr_options', $legacyarray);
+ //We'll now check that that was successful and if it was, remove the legacy variables
+ //If it didn't work then we'll leave them for now
+ $tmp = get_option('infscr_options');
+ if(is_array($tmp)) {
+ foreach(self::$Defaults as $key => $value)
+ {
+ foreach($value as $innerkey => $innerval)
+ {
+ delete_option($innerkey);
+ }
+ }
+ }
+ }
+ else
+ {
+ //If there are no legacy variables
+ $newsettings = array();
+ foreach(self::$Defaults as $key => $value)
+ {
+ foreach($value as $innerkey => $innerval)
+ {
+ $newsettings[$innerkey] = $innerval[0];
+ }
+ }
+ update_option('infscr_options', $newsettings);
+ }
+ }
+ }
+public static function addjQuery()
+ {
+ global $wp_scripts;
+ //Now, some of the versions of jQuery bundled with Wordpress are monolithic.
+ //Lets check how old they are!
+ //Check if jQuery registered and its version. If not then we'll just pretend its
+ //an old version.
+ if(!empty($wp_scripts->registered['jquery']->ver))
+ $versioncode = explode(".",$wp_scripts->registered['jquery']->ver);
+ else
+ $versioncode = array(1,1,1);
+ //Lets check the main branch, we won't be *that* picky!
+ if($versioncode[1]<6)
+ {
+ wp_deregister_script( 'jquery' );
+ //IMPORTANT. Our versions of jQuery, like Wordpress, also append jQuery.noConflict();
+ if((stripslashes(get_option('infscr_debug'))==1))
+ wp_enqueue_script( 'jquery', plugins_url('infinite-scroll')."/js/jquery-1.6.2.js", array(), '1.6.2', false );
+ else
+ wp_enqueue_script( 'jquery', plugins_url('infinite-scroll')."/js/jquery-1.6.2.min.js", array(), '1.6.2', false );
+ }
+ return true;
+ }
+
+public static function addStyle()
+ {
+ switch(get_option('infscr_image_align'))
+ {
+ default:
+ case 0:
+ $align = "left";
+ break;
+ case 1:
+ $align = "center";
+ break;
+ case 2:
+ $align = "right";
+ break;
+ }
+ echo "<!-- Infinite-Scroll Style -->
+ <style type=\"text/css\">
+ #infscr-loading img { text-align: $align; }
+ </style>\r\n";
+ return true;
+ }
+
+public static function addInfiniteScroll()
+ {
+ global $user_level,$wp_query;
+ $load_infinite_scroll = true;
+ /* Lets start our pre-flight checks */
+ if(is_page() || is_single() || !have_posts())
+ $load_infinite_scroll = false;
+
+ $load_infinite_scroll = apply_filters('infinite_scroll_load_override', $load_infinite_scroll);
+
+ if (get_option('infscr_state') == 'disabled' || (get_option('infscr_state') == 'disabledforadmins' && $user_level >= 8) || (get_option('infscr_state') == 'enabledforadmins' && $user_level <= 8))
+ $load_infinite_scroll = false;
+
+ /* Pre-flight checks complete. Are we good to fly? */
+ if($load_infinite_scroll)
+ {
+ /* Loading Infinite-Scroll */
+ $plugin_dir = plugins_url('infinite-scroll');
+ $current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
+
+ $nextpage_no = intval($current_page) + 1;
+ $max_page = $wp_query->max_num_pages;
+ if ( !$max_page || $max_page >= $nextpage_no )
+ {
+ self::addjQuery();
+ //We have to pass pathInfo to the script as the script can't determine the path itself.
+ //We have to introduce some form of validation, so we can validate/sign the pathInfo we create.
+ $pathParse = self::getPagenumLink();
+ $pathParse[] = $current_page;
+ $pathInfo = base64_encode(serialize(array($pathParse,md5(NONCE_KEY.$pathParse[0]."infscr".$pathParse[1].self::$Version.$pathParse[2]))));
+ wp_enqueue_script( "infinite-scroll-init" , "$plugin_dir/infinitescroll.init.js.php?p=$pathInfo", array("jquery"), NULL, false );
+ return true;
+ }
+ }
+ return false;
+ }
+
+public static function trigger404()
+ {
+ $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
+ if (($paged && $paged > 1) && !have_posts())
+ {
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ header("Status: 404 Not Found");
+ }
+ }
+
+public static function showError($message)
+ {
+ return "<div class=\"error\"><p>$message</p></div>\n";
+ }
+
+public static function showSetupWarning()
+ {
+ return "<div id='infinitescroll-warning' class='updated fade'><p><strong>Infinite Scroll is almost ready</strong> Please <a href=\"options-general.php?page=wp_infinite_scroll.php\">review the configuration and set the state to ON</a></p></div>\n";
+ }
+
+public static function showLicense()
+ {
+ return "/*
+ --------------------------------
+ Infinite Scroll Wordpress Plugin
+ --------------------------------
+ + http://wordpress.org/extend/plugins/infinite-scroll/
+ + version ".self::$Version."
+ + Copyright 2011 Beaver6813, dirkhaim, Paul Irish
+ + Licensed under the GPLv2 License
+
+ + Documentation: http://infinite-scroll.com/
+
+*/
+";
+ }
+public static function getPagenumLink()
+ {
+ global $wp_rewrite;
+
+ $request = remove_query_arg( 'paged' );
+
+ $home_root = parse_url(home_url());
+ $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
+ $home_root = preg_quote( trailingslashit( $home_root ), '|' );
+
+ $request = preg_replace('|^'. $home_root . '|', '', $request);
+ $request = preg_replace('|^/+|', '', $request);
+
+ if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
+ $base = trailingslashit( get_bloginfo( 'url' ) );
+ $result = add_query_arg( 'paged', "|||INF-SPLITHERE|||", $base . $request );
+ } else {
+ $qs_regex = '|\?.*?$|';
+ preg_match( $qs_regex, $request, $qs_match );
+
+ if ( !empty( $qs_match[0] ) ) {
+ $query_string = $qs_match[0];
+ $request = preg_replace( $qs_regex, '', $request );
+ } else {
+ $query_string = '';
+ }
+
+ $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
+ $request = preg_replace( '|^index\.php|', '', $request);
+ $request = ltrim($request, '/');
+
+ $base = trailingslashit( get_bloginfo( 'url' ) );
+
+ if ( $wp_rewrite->using_index_permalinks() && '' != $request )
+ $base .= 'index.php/';
+
+ $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . "|||INF-SPLITHERE|||", 'paged' );
+ $result = $base . $request . $query_string;
+ }
+ $result = apply_filters('get_pagenum_link', $result);
+ return explode("|||INF-SPLITHERE|||",$result);
+ }
+public static function initOptions()
+ {
+ include("options.class.php");
+ include("presets.class.php");
+ //Load Settings
+ register_setting('infinitescroll', 'infscr_options', array('infiniteScrollOptions','validateOptions'));
+ infiniteScrollOptions::loadSettings("general",'general_section', '', array('infiniteScrollOptions','generalText'), "infiniteScrollGeneral");
+ infiniteScrollOptions::loadSettings("selectors",'selectors_section', '', array('infiniteScrollOptions','selectorsText'), "infiniteScrollSelectors");
+ //Add setup warning if required
+ $currentopts = get_option('infscr_options');
+ if ( $currentopts['infscr_state'] == self::$Defaults['general']['infscr_state'][0] && $currentopts['infscr_viewed_options'] == false && !isset($_POST['submit']) )
+ add_action('admin_notices', array('infiniteScroll', 'showSetupWarning'));
+ }
+public static function addOptPageLoader()
+ {
+ $optionspage = add_options_page('Infinite Scroll Options', 'Infinite Scroll', 'manage_options', 'wp_infinite_scroll.php', array('infiniteScrollOptions', 'addOptPage'));
+ add_action("load-".$optionspage, array('infiniteScrollOptions', 'addOptJavascript'));
+ add_action('admin_print_styles-'.$optionspage, array('infiniteScrollOptions', 'addOptStyle') );
+ add_contextual_help($optionspage,str_replace("{INFSCROLL_VERSION}",self::$Version,file_get_contents(WP_PLUGIN_DIR."/infinite-scroll/includes/helpinfo.html")));
+ }
+public static function slashOnlyDouble($text)
+ {
+ return addcslashes(stripslashes($text), '"');
+ }
+
+}
View
337 includes/options.class.php
@@ -0,0 +1,337 @@
+<?php
+/*Infinite-Scroll Options Class
+Dependencies: Wordpress, infiniteScroll.*/
+class infiniteScrollOptions extends infiniteScroll {
+
+public static function pageActive($tab,$mode)
+ {
+ if(empty($_GET['default']))
+ $default = "general";
+ else
+ $default = $_GET['default'];
+ if($default==$tab)
+ {
+ if($mode=="nav")
+ return " nav-tab-active";
+ else
+ return " infscroll-tab-active";
+ }
+ return "";
+ }
+
+public static function matchDefault($default)
+ {
+ switch($default)
+ {
+ case 'general':
+ case 'selectors':
+ case 'presets':
+ return $default;
+ break;
+
+ default:
+ return "";
+ break;
+ }
+ }
+public static function selectorsText()
+ {
+ echo " <p>All CSS selectors are found with the jQuery javascript library. See the <a href=\"http://docs.jquery.com/Selectors\">jQuery CSS Selector documentation</a> for an overview of all possibilities. Single-quotes are not allowed&mdash;only double-quotes may be used.</p>
+ <table class=\"editform infscroll-opttable\" cellspacing=\"0\" >
+ <tbody>
+ <tr>
+ <th width=\"20%\" >
+ <label for=\"themepresets\">Theme Presets:</label>
+ </th>
+ <td>";
+ $presetinfo = infiniteScrollPresets::presetGet(strtolower(get_current_theme()));
+ if($presetinfo[0]=='ERROR')
+ {
+ if($presetinfo[1]=='Could not find preset for theme.')
+ echo "<img src=\"".site_url('/wp-includes/images/smilies/icon_cry.gif')."\" alt=\":-(\"/> We don't currently have a preset for your theme. You'll have to try and enter the right selectors manually using their description and default values.";
+ else
+ echo $presetinfo[1];
+ }
+ else
+ {
+ echo "We found a preset for your theme: ".get_current_theme();
+ echo "<p class=\"submit\">
+ <input type='button' name='auto_fill' value='Auto-Fill' />
+ <input name='auto_fill_content' type='hidden' value='{$presetinfo[1]['content']}' />
+ <input name='auto_fill_post' type='hidden' value='{$presetinfo[1]['post']}' />
+ <input name='auto_fill_nav' type='hidden' value='{$presetinfo[1]['nav']}' />
+ <input name='auto_fill_next' type='hidden' value='{$presetinfo[1]['next']}' />
+ </p>";
+ }
+ echo "</td>
+ <td width=\"50%\">
+ <p>To help new (or lazy) users, we have a new preset function. We've compiled a list of common themes and the selectors you should use on infinite-scroll for them.</p>
+ </td>
+ </tr>
+ </tbody>
+ </table>";
+ }
+public static function generalText()
+ {
+ echo "<p style=\"font-style:italic;\">NOTE: If you haven't already, make sure you choose the correct selectors for your theme in the selectors tab above. This is needed for the plugin to work correctly. If you've tried and it still doesn't work then check out the Help menu in the top right!</p>";
+ }
+//We use a little dirty hack to get around the stupid limitations put on the design of the settings pages
+//FYI this is closing </td> and opening a new one for our descriptions
+public static function addFieldtext($callbackarr)
+ {
+ $options = get_option('infscr_options');
+ if(isset($options[$callbackarr[0]]))
+ $value = $options[$callbackarr[0]];
+ else
+ $value = parent::$Defaults[$callbackarr[1]][$callbackarr[0]][0];
+ echo "<input id='infscr_options[$callbackarr[0]]' name='infscr_options[$callbackarr[0]]' size='40' type='text' value='$value' /></td><td width='50%'>".self::getDescription($callbackarr[0])."</td>";
+ }
+public static function addFielddropdown($callbackarr)
+ {
+ $options = get_option('infscr_options');
+ if(isset($options[$callbackarr[0]]))
+ $value = $options[$callbackarr[0]];
+ else
+ $value = parent::$Defaults[$callbackarr[1]][$callbackarr[0]][0];
+ echo "<select name='infscr_options[$callbackarr[0]]' id='infscr_options[$callbackarr[0]]'>\n";
+ foreach(parent::$Defaults[$callbackarr[1]][$callbackarr[0]][3] as $optkey => $optval)
+ {
+ echo "<option value='$optkey'";
+ if ($value == $optkey)
+ echo "selected='selected'";
+ echo ">$optval</option>\n";
+ }
+ echo "</select></td><td width='50%'>".self::getDescription($callbackarr[0])."</td>";
+ }
+public static function addFieldtextarea($callbackarr)
+ {
+ $options = get_option('infscr_options');
+ if(isset($options[$callbackarr[0]]))
+ $value = $options[$callbackarr[0]];
+ else
+ $value = parent::$Defaults[$callbackarr[1]][$callbackarr[0]][0];
+ echo "<textarea name='infscr_options[$callbackarr[0]]' rows='2' style='width: 95%;'>\n";
+ echo stripslashes($value);
+ echo "</textarea></td><td width='50%'>".self::getDescription($callbackarr[0])."</td>";
+ }
+public static function addFieldfileupload($callbackarr)
+ {
+ echo "<input type='file' name='infscr_options[$callbackarr[0]]' id='infscr_options[$callbackarr[0]]' size='30' /></td><td width='50%'>".self::getDescription($callbackarr[0])."</td>";
+ }
+
+public static function loadSettings($settingsgrp, $id, $title, $callback, $page)
+ {
+ add_settings_section($id, $title, $callback, $page);
+ foreach(parent::$Defaults[$settingsgrp] as $key=>$value)
+ {
+ add_settings_field($key, $value[1], array("infiniteScrollOptions","addField".$value[2]), $page, $id, array($key,$settingsgrp));
+ }
+ }
+public static function validateOptions($input)
+ {
+ $options = get_option('infscr_options');
+ if (isset($input['infscr_state']) && ($input['infscr_state'] == 'enabled' || $input['infscr_state'] == 'disabled' || $input['infscr_state'] == 'disabledforadmins' || $input['infscr_state'] == 'enabledforadmins'))
+ $options['infscr_state'] = $input['infscr_state'];
+ if (isset($input['infscr_debug']) && ($input['infscr_debug'] == 0 || $input['infscr_debug'] == 1))
+ $options['infscr_debug'] = $input['infscr_debug'];
+ if (isset($input['infscr_behavior']) && ($input['infscr_behavior'] == 'undefined' || $input['infscr_behavior'] == 'twitter'))
+ $options['infscr_behavior'] = $input['infscr_behavior'];
+ if (isset($input['infscr_js_calls']))
+ $options['infscr_js_calls'] = $input['infscr_js_calls'];
+ if (isset($input['infscr_image_align']) && ($input['infscr_image_align'] == 0 || $input['infscr_image_align'] == 1 || $input['infscr_image_align'] == 2))
+ $options['infscr_image_align'] = $input['infscr_image_align'];
+ if (isset($input['infscr_text']))
+ $options['infscr_text'] = $input['infscr_text'];
+ if (isset($input['infscr_donetext']))
+ $options['infscr_donetext'] = $input['infscr_donetext'];
+ if (isset($input['infscr_content_selector']))
+ $options['infscr_content_selector'] = esc_js($input['infscr_content_selector']);
+ if (isset($input['infscr_nav_selector']))
+ $options['infscr_nav_selector'] = esc_js($input['infscr_nav_selector']);
+ if (isset($input['infscr_post_selector']))
+ $options['infscr_post_selector'] = esc_js($input['infscr_post_selector']);
+ if (isset($input['infscr_next_selector']))
+ $options['infscr_next_selector'] = esc_js($input['infscr_next_selector']);
+
+ /* Handle Image Upload */
+ //FYI I do know that the add_settings_error() function does work, but only as of 3.0. I'd rather keep compatability with 2.7.
+ if(!empty($_FILES['infscr_options']['tmp_name']['infscr_image']))
+ {
+ $uploaddetails = wp_check_filetype($_FILES['infscr_options']['name']['infscr_image']);
+ if(!empty($uploaddetails['ext']))
+ {
+ $uploadres = wp_upload_bits("inf-loading-".rand().".".$uploaddetails['ext'], null, file_get_contents($_FILES['infscr_options']['tmp_name']['infscr_image']));
+ if(!$uploadres['error'])
+ $options['infscr_image'] = $uploadres['url'];
+
+ }
+ }
+ return $options;
+ }
+public static function addOptStyle()
+ {
+ $plugin_dir = plugins_url('infinite-scroll');
+ wp_enqueue_style( "infinite-scroll-admin-style" , "$plugin_dir/includes/admin.css", false, parent::$Version, false );
+ }
+public static function addOptJavascript()
+ {
+ parent::addjQuery();
+ if(self::pageActive("presets","tab")=="")
+ $presetdefault = 1;
+ else
+ $presetdefault = 2;
+ if(!empty($_GET['infpage'])&&((int) $_GET['infpage']) == $_GET['infpage']&&$_GET['infpage']>=0)
+ $infscr_preset_page = $_GET['infpage'];
+ else
+ $infscr_preset_page = 1;
+ $plugin_dir = plugins_url('infinite-scroll');
+ $pathParse = array("options-general.php?page=wp_infinite_scroll.php&infpage=","",$infscr_preset_page);
+ $pathInfo = base64_encode(serialize(array($pathParse,md5(NONCE_KEY.$pathParse[0]."infscr".$pathParse[1]. parent::$Version.$pathParse[2]))));
+ wp_enqueue_script( "infinite-scroll-init", "$plugin_dir/infinitescroll.init.js.php?p=$pathInfo&a=$presetdefault", array("jquery"), NULL, false );
+ wp_enqueue_script( "infinite-scroll-admin", "$plugin_dir/js/admin_options.js", array("jquery", "infinite-scroll-init"), parent::$Version, false );
+ }
+public static function addOptPage()
+ {
+ $plugin_dir = plugins_url('infinite-scroll');
+ $currentopts = get_option('infscr_options');
+
+ //Check if user wants to add preset
+ if(isset($_POST['preset_add']))
+ {
+ if(isset($_POST['preset_overwrite']))
+ $overwrite = 1;
+ else
+ $overwrite = 0;
+ $addresult = infiniteScrollPresets::presetAdd($_POST['preset_themename'],$_POST['preset_content'],$_POST['preset_nav'],$_POST['preset_posts'],$_POST['preset_next'],$overwrite);
+ if($addresult[0]=='OK')
+ {
+ echo "<div class='updated'><p><strong>{$addresult[1]}</strong></p></div>";
+ }
+ else
+ echo parent::showError($addresult[1]);
+ }
+ //Update that they have viewed options
+ if(!$currentopts['infscr_viewed_options'])
+ {
+ $currentopts['infscr_viewed_options'] = true;
+ update_option("infscr_options", $currentopts);
+ }
+ //Check if user wants to update preset db
+ if(isset($_GET['presetup'])&&$_GET['presetup']==1)
+ {
+ $updateresult = infiniteScrollPresets::presetUpdate();
+ if($updateresult[0]=='OK')
+ {
+ echo "<div class='updated'><p><strong>{$updateresult[1]}</strong></p></div>";
+ }
+ else
+ echo parent::showError($updateresult[1]);
+ }
+
+ if($currentopts['infscr_state'] == 'disabled')
+ echo parent::showError("Infinite-Scroll plugin is <strong>disabled</strong>.");
+
+ if (function_exists('wp_tiny_mce')) {
+ add_filter('teeny_mce_buttons', create_function('$a', "
+ return array('bold, italic, underline, separator, strikethrough, justifyleft, justifycenter, justifyright, code');"));
+ add_filter('teeny_mce_before_init', create_function('$a', '
+ $a["theme"] = "advanced";
+ $a["skin"] = "wp_theme";
+ $a["height"] = "50";
+ $a["width"] = "240";
+ $a["onpageload"] = "";
+ $a["mode"] = "exact";
+ $a["elements"] = "'.'infscr_options[infscr_text]'.','.'infscr_options[infscr_donetext]'.'";
+ $a["editor_selector"] = "mceEditor";
+ $a["plugins"] = "safari,inlinepopups,spellchecker";
+ return $a;'));
+
+ wp_tiny_mce(true);
+ }
+ echo '<div class="wrap">
+ <form name="infinitescrollform" action="options.php" method="post" enctype="multipart/form-data">';
+ settings_fields('infinitescroll');
+ echo '<h2>Infinite Scroll Options</h2>
+ <h2 class="nav-tab-wrapper">
+<a href="options-general.php?page=wp_infinite_scroll.php&default=general" class="nav-tab'.self::pageActive("general","nav").'" rel="general">General</a><a href="options-general.php?page=wp_infinite_scroll.php&default=selectors" class="nav-tab'.self::pageActive("selectors","nav").'" rel="selectors">Selectors</a><a href="options-general.php?page=wp_infinite_scroll.php&default=presets" class="nav-tab'.self::pageActive("presets","nav").'" rel="presets" style="float:right;">Preset Manager</a>
+</h2>';
+ echo '<div class="infscroll-tab infscroll-tab-general'.infiniteScrollOptions::pageActive("general","tab").'">';
+ do_settings_sections('infiniteScrollGeneral');
+ echo '<p class="submit" style="text-align:center;">
+ <input name="Submit" type="submit" class="button-primary" value="';
+ esc_attr_e('Save Changes');
+ echo '" />
+ </p>
+ </div>';
+ echo '<div class="infscroll-tab infscroll-tab-selectors'.infiniteScrollOptions::pageActive("selectors","tab").'">';
+ do_settings_sections('infiniteScrollSelectors');
+ echo '<p class="submit" style="text-align:center;">
+ <input name="Submit" type="submit" class="button-primary" value="';
+ esc_attr_e('Save Changes');
+ echo '" />
+ </p>
+ </div>';
+ echo "</form>";
+ include("presets.tab.php");
+ echo "</div>";
+ }
+public static function getDescription($key)
+ {
+ switch($key)
+ {
+ case 'infscr_state':
+ $description = '"ON for Admins Only" will enable the plugin code only for logged-in administrators&mdash;visitors will not be affected while you configure the plugin. "ON for Visitors Only" is useful for administrators when customizing the blog&mdash;infinite scroll will be disabled for them, but still enabled for any visitors.';
+ break;
+ case 'infscr_debug':
+ $description = 'ON will turn on Debug mode. This will enable developer javascript console logging whilst in use. (Recommended: OFF, May break some browsers).';
+ break;
+ case 'infscr_behavior':
+ $description = 'Automatic behavior is the default behavior used by infinite scroll, once the user reaches the end of the page, it\'ll load the next set of posts. Manual triggering turns off automatic loading, it won\'t use AJAX to load any more posts until the user clicks the link/button for more posts.';
+ break;
+ case 'infscr_js_calls':
+ $description = 'Any functions that are applied to the post contents on page load will need to be executed when the new content comes in.';
+ break;
+ case 'infscr_image':
+ $options = get_option('infscr_options');
+ $description = 'Current Image:<br /><div style="text-align:center;margin-bottom:15px;"><img src="'.$options['infscr_image'].'" alt="The Loading Image" /></div>
+<p>URL of image that will be displayed while content is being loaded. Visit <a href="http://www.ajaxload.info" target="_blank">www.ajaxload.info</a> to customize your own loading spinner.</p>';
+ break;
+ case 'infscr_image_align':
+ $description = '';
+ break;
+ case 'infscr_text':
+ $description = 'Text will be displayed while content is being loaded.';
+ break;
+ case 'infscr_donetext':
+ $description = 'Text will be displayed when all entries have already been retrieved. The plugin will show this message, fade it out, and cease working.';
+ break;
+ case 'infscr_content_selector':
+ $description = 'The selector of the content div on the main page.';
+ break;
+ case 'infscr_post_selector':
+ $description = '<p>The selector of the post block.</p>
+ <dl>
+ <dt>Examples:</dt>
+ <dd>#content &gt; *</dd>
+ <dd>#content div.post</dd>
+ <dd>div.primary div.entry</dd>
+ </dl>';
+ break;
+ case 'infscr_nav_selector':
+ $description = 'The selector of the navigation div (the one that includes the next and previous links).';
+ break;
+ case 'infscr_next_selector':
+ $description = '<p>The selector of the previous posts (next page) A tag.</p>
+ <dl>
+ <dt>Examples:</dt>
+ <dd>div.navigation a:first</dd>
+ <dd>div.navigation a:contains(Previous)</dd>
+ </dl>';
+ break;
+ default:
+ $description = '';
+ break;
+ }
+ return $description;
+ }
+}
View
150 includes/presets.class.php
@@ -0,0 +1,150 @@
+<?php
+/*Infinite-Scroll Presets Class
+Dependencies: Wordpress, infiniteScroll.*/
+class infiniteScrollPresets extends infiniteScroll {
+//FYI We use this function for a certain part of the presetAdd as we don't want eol.
+private static function presetToCSV($data)
+ {
+ $outstream = fopen("php://temp", 'r+');
+ fputcsv($outstream, $data, ',', '"');
+ rewind($outstream);
+ $csv = fgets($outstream);
+ fclose($outstream);
+ $csv = substr($csv, 0, (0 - strlen(PHP_EOL)));
+ return $csv;
+ }
+public static function presetAdd($themename,$content,$nav,$post,$next,$overwrite)
+ {
+ if (($handle = @fopen(parent::$PresetDB, "r+")) !== FALSE) {
+ //Discard first and second line
+ fgets($handle, 4096);
+ fgets($handle, 4096);
+ $continueparse = true;
+ $previouscursor = ftell($handle);
+ while (($data = fgetcsv($handle, 1000, ",")) !== FALSE && $continueparse == true) {
+ if(isset($data[0])&&$data[0]==$themename)
+ {
+ if($overwrite==1)
+ {
+ fseek($handle,$previouscursor);
+ fwrite($handle, self::presetToCSV(array($themename,$content,$nav,$post,$next)));
+ $continueparse = false;
+ }
+ else
+ return array("ERROR","A preset for this theme already exists!");
+ }
+ elseif($data[0]=='End Preset DB*/ ?>')
+ {
+ fseek($handle,$previouscursor);
+ fputcsv($handle,array($themename,$content,$nav,$post,$next),",");
+ fwrite($handle,'End Preset DB*/ ?>');
+ $continueparse = false;
+ }
+ $previouscursor = ftell($handle);
+ }
+ fclose($handle);
+ //If we're still here then we presume it went okay...
+ return array("OK","Preset Added Successfully.");
+ }
+ else
+ return array("ERROR","Preset Database Doesn't Exist. Try Updating From Preset Manager.");
+
+ }
+public static function presetGet($themename)
+ {
+ if (($handle = @fopen(parent::$PresetDB, "r")) !== FALSE) {
+ //Discard first and second line
+ fgets($handle, 4096);
+ fgets($handle, 4096);
+ $continueparse = true;
+ $themeinfo = false;
+ while (($data = fgetcsv($handle, 1000, ",")) !== FALSE && $continueparse == true) {
+ if(isset($data[0])&&$data[0]==$themename)
+ {
+ $themeinfo = array("name"=>$data[0],"content"=>$data[1],"nav"=>$data[2],"post"=>$data[3],"next"=>$data[4]);
+ $continueparse = false;
+ }
+ }
+ fclose($handle);
+ if($themeinfo!=false)
+ return array("OK",$themeinfo);
+ else
+ return array("ERROR","Could not find preset for theme.");
+ }
+ else
+ return array("ERROR","Preset Database Doesn't Exist. Try Updating From Preset Manager.");
+
+ }
+public static function presetGetAll()
+ {
+ if (($handle = @fopen(parent::$PresetDB, "r")) !== FALSE) {
+ //Discard first and second line
+ fgets($handle, 4096);
+ fgets($handle, 4096);
+ $presets = array();
+ while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
+ if(count($data)>2)
+ {
+ $presets[] = array("name"=>$data[0],"content"=>$data[1],"nav"=>$data[2],"post"=>$data[3],"next"=>$data[4]);
+ }
+ }
+ fclose($handle);
+ return array("OK",$presets);
+ }
+ else
+ return array("ERROR","Preset Database Doesn't Exist. Try Updating.");
+ }
+public static function presetUpdate()
+ {
+ //First get current rev version
+ if (($handle = @fopen(parent::$PresetRev, "r")) !== FALSE) {
+ //Discard first line
+ fgets($handle, 4096);
+ $currentrev = fgets($handle, 4096);
+ fclose($handle);
+ }
+ if(!isset($currentrev))
+ $currentrev = 0;
+ //Now check SubVersion
+ $headresponse = get_headers(parent::$PresetRepo,1);
+ if($headresponse[0]!='HTTP/1.1 404 Not Found'&&!empty($headresponse['ETag']))
+ {
+ $etag = trim($headresponse['ETag'],'"');
+ $exetag = explode("//",$etag);
+ $reporev = $exetag[0];
+ if($reporev>$currentrev)
+ {
+ $newdb = file_get_contents(parent::$PresetRepo);
+ if(file_put_contents(parent::$PresetDB,$newdb))
+ {
+ if(file_put_contents(parent::$PresetRev,"<?php /*Infinite-Scroll Preset DB Rev File. Contains Subversion Rev Info.\n$reporev\nEnd Preset DB Rev File*/ ?>"))
+ return array("OK","Successfully Updated Preset Database To Latest Version");
+ else
+ return array("ERROR","Could not update revision file. Please check that ".WP_PLUGIN_DIR."/infinite-scroll/ is writable.");
+ }
+ else
+ return array("ERROR","Could not update preset file. Please check that ".WP_PLUGIN_DIR."/infinite-scroll/ is writable.");
+ }
+ else
+ {
+ return array("OK","You already have the most current version!");
+ }
+ }
+ else
+ return array("ERROR","Could not contact Wordpress repo. Are you behind a Firewall? Couldn't access: ".parent::$PresetRepo);
+ }
+public static function presetExport()
+ {
+ if(file_exists(parent::$PresetDB))
+ {
+ header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
+ header("Content-Description: Preset DB Export");
+ header("Content-Disposition: attachment; filename=PresetDB.csv.php");
+ header("Content-Type: text/csv");
+ readfile(parent::$PresetDB);
+ return true;
+ }
+ else
+ return false;
+ }
+}
View
125 includes/presets.tab.php
@@ -0,0 +1,125 @@
+<div class="infscroll-tab infscroll-tab-presets<?php echo infiniteScrollOptions::pageActive("presets","tab");?>">
+ <p>For advanced users only. Generally you shouldn't need to use this.</p>
+ <table class="editform infscroll-opttable" cellspacing="0" >
+ <tbody>
+ <tr>
+ <th width="20%" >
+ <label for="themepresets">Add Preset:</label>
+ </th>
+ <td colspan="2">
+ <form action="options-general.php?page=wp_infinite_scroll.php&default=presets" method="post">
+ <table>
+ <tr valign="top"><th scope="row">Theme Name</th><td><input type="text" value="<?php if(isset($_POST['preset_themename'])) echo $_POST['preset_themename']; else echo strtolower(get_current_theme());?>" size="40" name="preset_themename" id="preset_themename"></td></tr>
+ <tr valign="top"><th scope="row">Content Selector</th><td><input type="text" value="<?php if(isset($_POST['preset_content'])) echo $_POST['preset_content'];?>" size="40" name="preset_content" id="preset_content"></td></tr>
+ <tr valign="top"><th scope="row">Posts Selector</th><td><input type="text" value="<?php if(isset($_POST['preset_posts'])) echo $_POST['preset_posts'];?>" size="40" name="preset_posts" id="preset_posts"></td></tr>
+ <tr valign="top"><th scope="row">Navigation Selector</th><td><input type="text" value="<?php if(isset($_POST['preset_nav'])) echo $_POST['preset_nav'];?>" size="40" name="preset_nav" id="preset_next"></td></tr>
+ <tr valign="top"><th scope="row">Next Page Selector</th><td><input type="text" value="<?php if(isset($_POST['preset_next'])) echo $_POST['preset_next'];?>" size="40" name="preset_next" id="preset_next"></td></tr>
+ </table>
+ <p class="submit" style="text-align:left;">
+<input type='submit' name='preset_add' value='Add to Preset DB' /><br /><label for="preset_overwrite">Overwrite Existing Theme Preset: </label><input name="preset_overwrite" id="preset_overwrite" type="checkbox" value="1" />
+ </p>
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <th width="20%" >
+ <label for="themepresets">Update Preset DB:</label>
+ </th>
+ <td>
+ <a href="options-general.php?page=<?php echo $_GET['page']; ?>&default=presets&presetup=1" alt="Check for Updates" class="infscroll-preset-update button">Check for Updates</a>
+ </td>
+ <td width="50%">
+ <p>Update your preset database to the newest version from our Wordpress repo. NOTE: This will remove any "custom" presets you may have added.</p>
+ </td>
+ </tr>
+ <tr>
+ <th width="20%" >
+ <label for="themepresets">Export Preset DB:</label>
+ </th>
+ <td>
+ <a href="<?php echo plugins_url('infinite-scroll')."/presetdb.php?do=export&r=".mt_rand();?>" alt="Export Database" class="infscroll-preset-export button">Export Database</a>
+ </td>
+ <td width="50%">
+ <p>Exporting the preset database might be useful if you ever want to share your custom presets with someone else.</p>
+ </td>
+ </tr>
+ <tr style="border-top:2px solid black;">
+ <th>
+ <label for="<?php echo 'infscr_content_selector'; ?>">View Existing Presets:</label>
+ </th>
+ <td colspan="2">
+ <table width="100%" border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <th width="20%" style="text-align:left;">Preset/Theme Name</th>
+ <th width="20%" style="text-align:left;">Content Selector</th>
+ <th width="20%" style="text-align:left;">Post Selector</th>
+ <th width="20%" style="text-align:left;">Navigation Selector</th>
+ <th width="20%" style="text-align:left;">Previous Posts Selector</th>
+ </tr>
+ </table>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1" class="infscroll_preset_list">
+ <?php
+ //Will be quite a memory hog when the database gets larger
+ //TODO: Work on nosql style method of selecting ranges
+ if(!empty($_GET['infpage'])&&((int) $_GET['infpage']) == $_GET['infpage']&&$_GET['infpage']>=0)
+ $infscr_preset_page = $_GET['infpage'];
+ else
+ $infscr_preset_page = 1;
+ $finalpresets = infiniteScrollPresets::presetGetAll();
+ if($finalpresets[0]=='ERROR')
+ {
+ echo "<tr>
+ <td width=\"100%\" colspan=\"5\">{$finalpresets[1]}</td>
+ </tr>";
+ }
+ else
+ {
+ $finalpresets = $finalpresets[1];
+ //Determine length of results
+ $length = count($finalpresets) - 1;
+
+ $limit = 20;
+ $nextpage = $infscr_preset_page + 1;
+ $start = ($infscr_preset_page-1) * $limit;
+
+ if(($start+$limit)>$length)
+ $nextpage = -1;
+ if($start<=$length)
+ {
+ //Extract what we want
+ $finalpresets = array_slice($finalpresets, $start, $limit);
+ foreach($finalpresets as $key=>$value)
+ {
+ if($key%2)
+ $rowstyle = " style='background-color:#F7F7F7;'";
+ else
+ $rowstyle = "";
+ echo "<tr$rowstyle>
+ <td width=\"20%\">{$value['name']}</td>
+ <td width=\"20%\">{$value['content']}</td>
+ <td width=\"20%\">{$value['post']}</td>
+ <td width=\"20%\">{$value['nav']}</td>
+ <td width=\"20%\">{$value['next']}</td>
+ </tr>";
+ }
+ }
+ else
+ {
+ echo "<tr>
+ <td width=\"100%\" colspan=\"5\">No More Presets Available...</td>
+ </tr>";
+ }
+ }
+ ?>
+ </table>
+ <div class="infscroll_preset_nav">
+ <?php if($nextpage!=-1) {?>
+ <a href="options-general.php?page=<?php echo $_GET['page']; ?>&default=<?php echo infiniteScrollOptions::matchDefault($_GET['default']);?>&infpage=<?php echo $nextpage;?>" alt="More Results" class="button">More Results</a>
+ <?php }?>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
View
112 infinitescroll.init.js.php
@@ -0,0 +1,112 @@
+<?php
+ob_start();
+require_once( '../../../wp-load.php' );
+wp();
+ob_clean();
+header($_SERVER["SERVER_PROTOCOL"]." 200 Ok");
+header("Status: 200");
+header('Content-Type: application/javascript');
+//Get pathParse and validate it.
+$error = false;
+if($pathInfo = unserialize(base64_decode($_GET['p'])))
+ {
+ if(empty($pathInfo[0])||count($pathInfo[0])<2||empty($pathInfo[1])||$pathInfo[1]!=md5(NONCE_KEY.$pathInfo[0][0]."infscr".$pathInfo[0][1].infiniteScroll::$Version.$pathInfo[0][2]))
+ $error = true;
+ }
+else
+ $error = true;
+
+if($error)
+ echo "//Missing/Invalid PathParse or Signature.";
+else
+ {
+ //Lets setup settings!
+ $plugin_dir = plugins_url('infinite-scroll');
+ $infscropts = get_option("infscr_options");
+ //Go through and check for defaults
+ foreach(infiniteScroll::$Defaults as $key => $value)
+ {
+ foreach($value as $inkey => $invalue)
+ {
+ if(!isset($infscropts[$inkey]))
+ $infscropts[$inkey] = $invalue[0];
+ }
+ }
+ $debug = (stripslashes($infscropts['infscr_debug'])==1) ? "true" : "false";
+ $scheme = (is_ssl()) ? "https://" : "http://";
+ if(isset($_GET['a']) && $_GET['a']>0)
+ {
+ $noscheme = parse_url(stripslashes($plugin_dir."/ajax-loader.gif"));
+ $loading_text = "Loading Additional Presets...";
+ $donetext = "No More Presets To Display!";
+ $content_selector = ".infscroll_preset_list";
+ $navigation_selector= ".infscroll_preset_nav";
+ $post_selector = ".infscroll_preset_list tr";
+ $next_selector = ".infscroll_preset_nav a:first";
+ $js_calls = "if(jQuery('.infscroll_preset_list tr:last td:first').text()=='No More Presets Available...') { window.setTimeout(function() { jQuery(\".infscroll_preset_list\").infinitescroll(\"destroy\"); }, 10); };";
+ $behavior = 'undefined';
+ }
+ else
+ {
+ $noscheme = parse_url(stripslashes($infscropts['infscr_image']));
+ $loading_text = infiniteScroll::slashOnlyDouble($infscropts['infscr_text']);
+ $donetext = infiniteScroll::slashOnlyDouble($infscropts['infscr_donetext']);
+ $content_selector = stripslashes($infscropts['infscr_content_selector']);
+ $navigation_selector= stripslashes($infscropts['infscr_nav_selector']);
+ $post_selector = stripslashes($infscropts['infscr_post_selector']);
+ $next_selector = stripslashes($infscropts['infscr_next_selector']);
+ $js_calls = stripslashes($infscropts['infscr_js_calls']);
+ $behavior = stripslashes($infscropts['infscr_behavior']);
+ }
+ $loading_image = $scheme.$noscheme['host'].$noscheme['path'];
+ //Start Loading!
+ //Load infinite-scroll
+ echo infiniteScroll::showLicense();
+ if($debug=="true")
+ {
+ readfile("js/jquery.infinitescroll.js");
+ if($behavior=='twitter')
+ readfile("js/behaviors/manual-trigger.js");
+ echo '//We leave a function outside the infinite-scroll area so that it works with older jQuery versions
+ function infinite_scroll_callback(newElements,data) {
+ '.$js_calls.'
+ }
+ jQuery(document).ready(function($) {
+ // Infinite Scroll jQuery+Wordpress plugin
+ // Now we\'re inside, we should be able to use $ again
+ $("'.$content_selector.'").infinitescroll({
+ debug : '.$debug.',
+ loading : {
+ img : "'.$loading_image.'",
+ msgText : "'.$loading_text.'",
+ finishedMsg : "'.$donetext.'"
+ },
+ state : {
+ currPage : "'.$pathInfo[0][2].'"
+ },
+ behavior : "'.$behavior.'",
+ nextSelector : "'.$next_selector.'",
+ navSelector : "'.$navigation_selector.'",
+ contentSelector : "'.$content_selector.'",
+ itemSelector : "'.$post_selector.'",
+ pathParse : ["'.$pathInfo[0][0].'", "'.$pathInfo[0][1].'"]
+ }, function(newElements,data) { window.setTimeout(function(){infinite_scroll_callback(newElements,data)}, 1); } );
+ ';
+ //If its on the admin page and the tab is not active by default, pause it!
+ if(isset($_GET['a']) && $_GET['a']==1)
+ echo '$("'.$content_selector.'").infinitescroll("pause");';
+ echo '});';
+
+ }
+ else
+ {
+ readfile("js/jquery.infinitescroll.min.js");
+ if($behavior=='twitter')
+ readfile("js/behaviors/manual-trigger.min.js");
+ echo 'function infinite_scroll_callback(newElements,data){'.$js_calls.'}
+jQuery(document).ready(function($){$("'.$content_selector.'").infinitescroll({debug:'.$debug.',loading:{img:"'.$loading_image.'",msgText:"'.$loading_text.'",finishedMsg:"'.$donetext.'"},state:{currPage:"'.$pathInfo[0][2].'"},behavior:"'.$behavior.'",nextSelector:"'.$next_selector.'",navSelector:"'.$navigation_selector.'",contentSelector:"'.$content_selector.'",itemSelector:"'.$post_selector.'",pathParse:["'.$pathInfo[0][0].'","'.$pathInfo[0][1].'"]},function(newElements,data){window.setTimeout(function(){infinite_scroll_callback(newElements,data)},1);});';
+ if(isset($_GET['a']) && $_GET['a']==1)
+ echo '$("'.$content_selector.'").infinitescroll("pause");';
+ echo '});';
+ }
+ }?>
View
24 js/admin_options.js
@@ -0,0 +1,24 @@
+jQuery(document).ready(function($) {
+ $(".nav-tab-wrapper .nav-tab").click(function (event) {
+ event.preventDefault();
+ $newactive = $(this).attr("rel");
+ if($newactive=='presets')
+ jQuery(".infscroll_preset_list").infinitescroll("resume");
+ else
+ jQuery(".infscroll_preset_list").infinitescroll("pause");
+ $(".infscroll-tab-active").removeClass("infscroll-tab-active");
+ $(".infscroll-tab-"+$newactive).addClass("infscroll-tab-active");
+ $(".nav-tab-wrapper .nav-tab-active").removeClass("nav-tab-active");
+ $(this).addClass("nav-tab-active");
+ });
+ $(".submit input[name=auto_fill]").click(function (event) {
+ event.preventDefault();
+ $(document.infinitescrollform["infscr_options[infscr_content_selector]"]).val($(this).siblings("input[name=auto_fill_content]").val());
+ $(document.infinitescrollform["infscr_options[infscr_post_selector]"]).val($(this).siblings("input[name=auto_fill_post]").val());
+ $(document.infinitescrollform["infscr_options[infscr_nav_selector]"]).val($(this).siblings("input[name=auto_fill_nav]").val());
+ $(document.infinitescrollform["infscr_options[infscr_next_selector]"]).val($(this).siblings("input[name=auto_fill_next]").val());
+ $('.infscroll-tab-selectors input[type=text]').animate({backgroundColor: "yellow"},50, function () {
+ jQuery('.infscroll-tab-selectors input[type=text]').animate({ backgroundColor: "white" }, 500);});
+ });
+
+});
View
100 js/behaviors/manual-trigger.js
@@ -0,0 +1,100 @@
+/*
+ --------------------------------
+ Infinite Scroll Behavior
+ Manual / Twitter-style
+ --------------------------------
+ + https://github.com/paulirish/infinitescroll/
+ + version 2.0b2.110617
+ + Copyright 2011 Paul Irish & Luke Shumard
+ + Licensed under the MIT license
+
+ + Documentation: http://infinite-scroll.com/
+
+*/
+jQuery.extend(jQuery.infinitescroll.prototype,{
+
+ _loadcallback_twitter: function infscr_loadcallback_twitter(box,data) {
+ var opts = this.options,
+ callback = this.options.callback, // GLOBAL OBJECT FOR CALLBACK
+ result = (opts.state.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append',
+ frag;
+ switch (result) {
+
+ case 'done':
+
+ instance._showdonemsg();
+ return false;
+
+ break;
+
+ case 'no-append':
+
+ if (opts.dataType == 'html') {
+ data = '<div>' + data + '</div>';
+ data = $(data).find(opts.itemSelector);
+ };
+
+ break;
+
+ case 'append':
+ var children = box.children();
+
+ // if it didn't return anything
+ if (children.length == 0) {
+ return this._error('end');
+ }
+
+
+ // use a documentFragment because it works when content is going into a table or UL
+ frag = document.createDocumentFragment();
+ while (box[0].firstChild) {
+ frag.appendChild(box[0].firstChild);
+ }
+ this._debug('contentSelector', jQuery(opts.contentSelector)[0]);
+ jQuery(opts.itemSelector).filter(":last").after(frag);
+ // previously, we would pass in the new DOM element as context for the callback
+ // however we're now using a documentfragment, which doesnt havent parents or children,
+ // so the context is the contentContainer guy, and we pass in an array
+ // of the elements collected as the first argument.
+ data = children.get();
+ break;
+
+ }
+
+ // loadingEnd function
+ opts.loading.finished.call(jQuery(opts.contentSelector)[0],opts)
+
+
+ // smooth scroll to ease in the new content
+ if (opts.animate) {
+ var scrollTo = jQuery(window).scrollTop() + jQuery('#infscr-loading').height() + opts.extraScrollPx + 'px';
+ jQuery('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts.state.isDuringAjax = false; });
+ }
+
+ if (!opts.animate) opts.state.isDuringAjax = false; // once the call is done, we can allow it again.
+
+ callback(instance,data);
+ },
+ _setup_twitter: function infscr_setup_twitter () {
+ var opts = this.options,
+ instance = this;
+
+ // Bind nextSelector link to retrieve
+ jQuery(opts.nextSelector).click(function(e) {
+ if (e.which == 1 && !e.metaKey && !e.shiftKey) {
+ e.preventDefault();
+ instance.retrieve();
+ }
+ });
+
+ // Define loadingStart to never hide pager
+ instance.options.loading.start = function (opts) {
+ opts.loading.msg
+ .appendTo(opts.loading.selector)
+ .show(opts.loading.speed, function () {
+ beginAjax(opts);
+ });
+ }
+ }
+
+});
View
1  js/behaviors/manual-trigger.min.js
@@ -0,0 +1 @@
+jQuery.extend(jQuery.infinitescroll.prototype,{_loadcallback_twitter:function a(a,b,c){var d=c.callback,e=c.state.isDone?"done":!c.appendCallback?"no-append":"append",f;switch(e){case"done":instance._showdonemsg();return false;break;case"no-append":if(c.dataType=="html"){b="<div>"+b+"</div>";b=$(b).find(c.itemSelector)}break;case"append":var g=a.children();if(g.length==0){return this._error("end")}f=document.createDocumentFragment();while(a[0].firstChild){f.appendChild(a[0].firstChild)}this._debug("contentSelector",jQuery(c.contentSelector)[0]);jQuery(c.itemSelector).filter(":last").after(f);b=g.get();break}c.loading.finished.call(jQuery(c.contentSelector)[0],c);if(c.animate){var h=jQuery(window).scrollTop()+jQuery("#infscr-loading").height()+c.extraScrollPx+"px";jQuery("html,body").animate({scrollTop:h},800,function(){c.state.isDuringAjax=false})}if(!c.animate)c.state.isDuringAjax=false;d(instance,b)},_setup_twitter:function b(){var a=this.options,b=this;jQuery(a.nextSelector).click(function(a){if(a.which==1&&!a.metaKey&&!a.shiftKey){a.preventDefault();b.retrieve()}});b.options.loading.start=function(a){a.loading.msg.appendTo(a.loading.selector).show(a.loading.speed,function(){beginAjax(a)})}}})
View
0  jquery.infinitescroll.js → js/jquery.infinitescroll.js
File renamed without changes
View
0  jquery.infinitescroll.min.js → js/jquery.infinitescroll.min.js
File renamed without changes
View
12 presetdb.php
@@ -0,0 +1,12 @@
+<?php
+require_once( '../../../wp-load.php' );
+wp();
+check_admin_referer();
+include("includes/presets.class.php");
+//What are we being asked for?
+if($_GET['do']=='export')
+ {
+ if(!infiniteScrollPresets::presetExport())
+ echo "Error exporting file. (Could not find the database to export). Please try again.";
+ }
+?>
View
46 readme.txt
@@ -1,9 +1,9 @@
-=== Plugin Name ===
-Contributors: paul.irish, dirkhaim, beaver6813
+=== Infinite-Scroll ===
+Contributors: beaver6813, dirkhaim, paul.irish
Donate link: http://www.infinite-scroll.com
Tags: ajax, pagination, scrolling, scroll, endless, reading
-Requires at least: 2.6
-Tested up to: 3.2
+Requires at least: 2.7
+Tested up to: 3.3
Stable tag: 2.0b
Automatically append the next page of posts (via AJAX) to your page when a user scrolls to the bottom.
@@ -48,6 +48,44 @@ Because it is. Go to [infinite-scroll.com](http://www.infinite-scroll.com) for m
1. Loading the next set of posts
== Changelog ==
+= 2.0b2.120111 =
+* Added infinite_scroll_load_override filter to manually force infinite-scroll to load on a page.
+* Thanks to https://github.com/samargulies for the above patch.
+
+= 2.0b2.111218 =
+* Updated preset DB with basic themes
+* Made a few fixes in options/presets to prep for main release.
+* Changed hook used by 404 detection to template_redirect from wp.
+
+= 2.0b2.110822 =
+* Removed registration/enqueuing script in favor of just enqueueing
+* Fixed bug/typo in compressed init script
+
+= 2.0b2.110821 =
+* Converted options pages to use Settings API
+* Added behavior selection (Manual triggering)
+
+= 2.0b2.110818 =
+* Completely revamped admin panel adding more modular management
+* Added ability to center loading image
+* Added WYSIWYG editor to HTML allowed fields in admin panel
+* Updated Javascript callback to pass DOM for new elements added
+* Added Preset manager
+* Added ability to auto-fill selector fields from theme preset
+* Overhaul of underlying code, seperating out into classes to cut down
+on code processed (and hence load time) for the end-user.
+
+= 2.0b2.110723 =
+* Improved escaping on settings to allow greater flexibility.
+* Fixed issue with jQuery not loading if WP version is up to date.
+* Fixed issue with plugin showing twice on plugin list.
+
+= 2.0b2.110716 =
+* Moved init script from direct page insertion to seperate script.
+* Cleaned up unneeded declared constants.
+* Combined init script and library into one minified script.
+* This fixes an incompatability with HeadJS plugin.
+
= 2.0b2.110713 =
* Fixed multiple jQuery loaded conflicts.
* Now uses standard Wordpress javascript insertion.
View
571 wp_infinite_scroll.php
@@ -1,565 +1,26 @@
<?php
/*
Plugin Name: Infinite Scroll
-Version: 2.0b2.110713
+Version: 2.0b2.120111
Plugin URI: http://www.infinite-scroll.com
Description: Automatically loads the next page of posts into the bottom of the initial page.
-Author: dirkhaim, Paul Irish, Beaver6813
+Author: Beaver6813, dirkhaim, Paul Irish
Author URI: http://www.infinite-scroll.com
License : http://creativecommons.org/licenses/GPL/2.0/
-
-
-BUGS:
- - javascript insertion doesnt work on themes: qwiilm!, craving4green, Lush, no limits, stripedplus
- - Note: Above bug left over from old plugin. Needs verifying.
*/
-
-// constants for enables/disabled
-define('infscr_enabled' , 'enabled');
-define('infscr_disabled' , 'disabled');
-define('infscr_config' , 'enabledforadmins');
-define('infscr_maint' , 'disabledforadmins');
-
-
-// options keys constants
-define('key_infscr_state' , 'infscr_state');
-define('key_infscr_js_calls' , 'infscr_js_calls');
-define('key_infscr_image' , 'infscr_image');
-define('key_infscr_text' , 'infscr_text');
-define('key_infscr_donetext' , 'infscr_donetext');
-define('key_infscr_content_selector' , 'infscr_content_selector');
-define('key_infscr_nav_selector' , 'infscr_nav_selector');
-define('key_infscr_post_selector' , 'infscr_post_selector');
-define('key_infscr_next_selector' , 'infscr_next_selector');
-
-
-// defaults
-define('infscr_state_default' , infscr_config);
-define('infscr_js_calls_default' , '');
-
-$image_path = plugins_url( 'infinite-scroll/ajax-loader.gif');
-define('infscr_image_default' , $image_path);
-define('infscr_text_default' , '<em>Loading the next set of posts...</em>');
-define('infscr_donetext_default' , '<em>Congratulations, you\'ve reached the end of the internet.</em>');
-define('infscr_content_selector_default' , '#content');
-define('infscr_post_selector_default' , '#content div.post');
-define('infscr_nav_selector_default' , 'div.navigation');
-define('infscr_next_selector_default', 'div.navigation a:first');
-
-
-// add options
-add_option(key_infscr_state , infscr_state_default , 'If InfiniteScroll is turned on, off, or in maintenance');
-add_option(key_infscr_js_calls , infscr_js_calls_default , 'Javascript to execute when new content loads in');
-add_option(key_infscr_image , infscr_image_default , 'Loading image');
-add_option(key_infscr_text , infscr_text_default , 'Loading text');
-add_option(key_infscr_donetext , infscr_donetext_default , 'Completed text');
-add_option(key_infscr_content_selector , infscr_content_selector_default , 'Content Div css selector');
-add_option(key_infscr_nav_selector , infscr_nav_selector_default , 'Navigation Div css selector');
-add_option(key_infscr_post_selector , infscr_post_selector_default , 'Post Div css selector');
-add_option(key_infscr_next_selector , infscr_next_selector_default , 'Next page Anchor css selector');
-add_option(key_infscr_viewed_options , false , 'Ever Viewed Options Page');
-add_option(key_infscr_debug , 0 , 'Debug Mode');
-
-// adding actions
-add_action('template_redirect' , 'wp_inf_scroll_pre_init');
-add_action('wp_head' , 'wp_inf_scroll_init');
-add_action('admin_menu' , 'add_wp_inf_scroll_options_page');
-add_action("wp" , 'wp_inf_scroll_404');
-
-if ( get_option(key_infscr_state) == infscr_state_default && get_option(key_infscr_viewed_options) == false && !isset($_POST['submit']) )
- add_action('admin_notices', 'wp_inf_scroll_setup_warning');
-
-function wp_inf_scroll_pre_init($wp)
- {
- global $wp_scripts;
- //Now, some of the versions of jQuery bundled with Wordpress are monolithic.
- //Lets check how old they are!
- //Check if jQuery registered and its version. If not then we'll just pretend its
- //an old version.
- if(!empty($wp_scripts->registered['jquery']->ver))
- $versioncode = explode(".",$wp_scripts->registered['jquery']->ver);
- else
- $versioncode = array(1,1,1);
- //Lets check the main branch, we won't be *that* picky!
- if($versioncode[1]<6)
- {
- wp_deregister_script( 'jquery' );
- //IMPORTANT. Our versions of jQuery, like Wordpress, also append jQuery.noConflict();
- if((stripslashes(get_option(key_infscr_debug))==1))
- wp_register_script( 'jquery', plugins_url('infinite-scroll')."/js/jquery-1.6.2.js", array(), '1.6.2', false );
- else
- wp_register_script( 'jquery', plugins_url('infinite-scroll')."/js/jquery-1.6.2.min.js", array(), '1.6.2', false );
- wp_enqueue_script( 'jquery' );
- }
- }
-/*
-Because recently (3.0) WP doesn't always throw a 404 when posts aren't found.
+include("includes/infinite-scroll.class.php");
+new infiniteScroll();
+//Add Generic Actions
+add_action('init' , array('infiniteScroll', 'addDefaults'));
+
+//Add Main Blog Actions
+add_action('template_redirect' , array('infiniteScroll', 'addInfiniteScroll'));
+add_action('wp_head' , array('infiniteScroll', 'addStyle'));
+/*Because recently (3.0) WP doesn't always throw a 404 when posts aren't found.
Infinite-Scroll relies on 404 errors to terminate.. so we'll force them. */
-function wp_inf_scroll_404($wp)
- {
- if(!have_posts())
- {
- header("HTTP/1.1 404 Not Found");
- header("Status: 404 Not Found");
- }
- }
-
-function add_wp_inf_scroll_options_page()
- {
- global $wpdb;
- add_options_page('Infinite Scroll Options', 'Infinite Scroll', 8, basename(__FILE__), 'wp_inf_scroll_options_page');
- }
-
-function wp_inf_scroll_error($message)
- {
- return "<div class=\"error\"><p>$message</p></div>\n";
- }
-
-function wp_inf_scroll_setup_warning()
- {
- echo "<div id='infinitescroll-warning' class='updated fade'><p><strong>".__('Infinite Scroll is almost ready.')."</strong> ".sprintf(__('Please <a href="%1$s">review the configuration and set the state to ON</a>.'), "options-general.php?page=wp_infinite_scroll.php")."</p></div>\n";
- }
-/*
-Stripped down version of get_pagenum_link() from link-template.php
-We use this to retrieve the URL array (seperated for placement of page number).
-This saves using regex on the entire URL that could be unpredictable on some
-installations.
-Added Build: 110628 */
-function wp_inf_scroll_get_pagenum_link() {
- global $wp_rewrite;
-
- $request = remove_query_arg( 'paged' );
-
- $home_root = parse_url(home_url());
- $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
- $home_root = preg_quote( trailingslashit( $home_root ), '|' );
-
- $request = preg_replace('|^'. $home_root . '|', '', $request);
- $request = preg_replace('|^/+|', '', $request);
-
- if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
- $base = trailingslashit( get_bloginfo( 'url' ) );
- $result = add_query_arg( 'paged', "|||INF-SPLITHERE|||", $base . $request );
- } else {
- $qs_regex = '|\?.*?$|';
- preg_match( $qs_regex, $request, $qs_match );
-
- if ( !empty( $qs_match[0] ) ) {
- $query_string = $qs_match[0];
- $request = preg_replace( $qs_regex, '', $request );
- } else {
- $query_string = '';
- }
-
- $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
- $request = preg_replace( '|^index\.php|', '', $request);
- $request = ltrim($request, '/');
-
- $base = trailingslashit( get_bloginfo( 'url' ) );
-
- if ( $wp_rewrite->using_index_permalinks() && '' != $request )
- $base .= 'index.php/';
-
- $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . "|||INF-SPLITHERE|||", 'paged' );
- $result = $base . $request . $query_string;
- }
- $result = apply_filters('get_pagenum_link', $result);
- return explode("|||INF-SPLITHERE|||",$result);
-}
-function wp_inf_scroll_init()
- {
- global $user_level;
- $load_infinite_scroll = true;
- $error_reason = "";
-
- /* Lets start our pre-flight checks */
- if (get_option(key_infscr_state) == infscr_disabled)
- $load_infinite_scroll = false;
- else if (is_page() || is_single() ) /* single posts/pages dont get it */
- {
- $error_reason = 'Single post/page';
- $load_infinite_scroll = false;
- }
- else if (get_option(key_infscr_state) == infscr_maint && $user_level >= 8)
- {
- $error_reason = 'Administrator (Maintenance State)';
- $load_infinite_scroll = false;
- }
- else if (get_option(key_infscr_state) == infscr_config && $user_level <= 8)
- {
- $error_reason = 'Visitors (Config State)';
- $load_infinite_scroll = false;
- }
- else if ( !have_posts() )
- {
- $error_reason = 'No Posts to Display';
- $load_infinite_scroll = false;
- }
-
- /* Pre-flight checks complete. Are we good to fly? */
- if($load_infinite_scroll)
- {
- /* Loading Infinite-Scroll */
-
- $site_url = site_url();
- $plugin_dir = plugins_url('infinite-scroll');
- $js_calls = stripslashes(get_option(key_infscr_js_calls));
- //Fancy stuff (not) to detect https or http
- $noscheme = parse_url(stripslashes(get_option(key_infscr_image)));
- if (is_ssl())
- $scheme = "https://";
- else
- $scheme = "http://";
- $loading_image = $scheme.$noscheme['host'].$noscheme['path'];
- $loading_text = stripslashes(get_option(key_infscr_text));
- $donetext = stripslashes(get_option(key_infscr_donetext));
- $content_selector = stripslashes(get_option(key_infscr_content_selector));
- $navigation_selector= stripslashes(get_option(key_infscr_nav_selector));
- $post_selector = stripslashes(get_option(key_infscr_post_selector));
- $next_selector = stripslashes(get_option(key_infscr_next_selector));
- $debug = (stripslashes(get_option(key_infscr_debug))==1) ? "true" : "false";
- $current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $pathParse = wp_inf_scroll_get_pagenum_link();
- $nextpage_no = intval($current_page) + 1;
- $max_page = $wp_query->max_num_pages;
-
- if ( !$max_page || $max_page >= $nextpage )
- {
- if($debug=="true")
- echo "<script type=\"text/javascript\" src=\"$plugin_dir/jquery.infinitescroll.js\"></script>";
- else
- echo "<script type=\"text/javascript\" src=\"$plugin_dir/jquery.infinitescroll.min.js\"></script>";
- echo "<script type=\"text/javascript\">
- //We leave a function outside the infinite-scroll area so that it works with older jQuery versions
- function infinite_scroll_callback() {
- $js_calls
- }
- jQuery(document).ready(function($) {
- // Infinite Scroll jQuery+Wordpress plugin
- // Now we're inside, we should be able to use $ again
- $('$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 : [\"{$pathParse[0]}\", \"{$pathParse[1]}\"]
- }, function() { window.setTimeout(infinite_scroll_callback(), 1); } );
- });
- </script>";
- return true;
- }
- else
- {
- echo "<!-- Infinite-Scroll not added. Reason: No More Posts To Display After This -->\r\n";
- return false;
- }
- }
- else
- {
- echo "<!-- Infinite-Scroll not added. Reason: $error_reason -->\r\n";
- return false;
- }
-
- }
-
-function wp_inf_scroll_options_page()
- {
- // if postback, store options
- if (isset($_POST['info_update']))
- {
- check_admin_referer();
-
- // update state
- $infscr_state = $_POST[key_infscr_state];
- if ($infscr_state != infscr_enabled && $infscr_state != infscr_disabled && $infscr_state != infscr_maint && $infscr_state != infscr_config)
- $infscr_state = infscr_state_default;
- update_option(key_infscr_state, $infscr_state);
-
- // update debug
- $infscr_debug = $_POST[key_infscr_debug];
- update_option(key_infscr_debug, $infscr_debug);
-
- // update js calls field
- $infscr_js_calls = $_POST[key_infscr_js_calls];
- update_option(key_infscr_js_calls, $infscr_js_calls);
-
- // update image
- /* Handle Image Upload */
- if(!empty($_FILES[key_infscr_image]['tmp_name']))
- {
- $infscr_image = $_FILES[key_infscr_image];
- $uploaddetails = wp_check_filetype($infscr_image["name"]);
- if(!empty($uploaddetails['ext']))
- {
- $uploadres = wp_upload_bits("inf-loading-".rand().".".$uploaddetails['ext'], null, file_get_contents($infscr_image["tmp_name"]));
- if(!$uploadres['error'])
- update_option(key_infscr_image, $uploadres['url']);
- else
- echo wp_inf_scroll_error("Error Saving Loading Bar: {$uploadres['error']}");
- }
- else
- {
- echo wp_inf_scroll_error("Could Not Determine File Extension. Supported Files Are: .jpg, .jpeg. gif. .png");
- }
- }
-
- // update text
- $infscr_text = $_POST[key_infscr_text];
- update_option(key_infscr_text, $infscr_text);
-
- // update done text
- $infscr_donetext = $_POST[key_infscr_donetext];
- update_option(key_infscr_donetext, $infscr_donetext);
-
- // update content selector
- $content_selector = $_POST[key_infscr_content_selector];
- update_option(key_infscr_content_selector, $content_selector);
-
- // update the navigation selector
- $navigation_selector = $_POST[key_infscr_nav_selector];
- update_option(key_infscr_nav_selector, $navigation_selector);
-
- // update the post selector
- $post_selector = $_POST[key_infscr_post_selector];
- update_option(key_infscr_post_selector, $post_selector);
-
- // update the next selector
- $next_selector = $_POST[key_infscr_next_selector];
- update_option(key_infscr_next_selector, $next_selector);
-
-
- // update notification
- echo "<div class='updated'><p><strong>Infinite Scroll options updated</strong></p></div>";
- }
-
- // output the options page
-if ( get_option(key_infscr_state) == infscr_state_default && get_option(key_infscr_viewed_options) == true && !isset($_POST['submit']) )
- wp_inf_scroll_setup_warning();
-?>
-
-<form action="options-general.php?page=<?php echo basename(__FILE__); ?>" method="post" enctype="multipart/form-data">
- <div class="wrap">
-<?php
- update_option(key_infscr_viewed_options, true);
- if (get_option(key_infscr_state) == infscr_disabled)
- echo wp_inf_scroll_error("Infinite-Scroll plugin is <strong>disabled</strong>.");?>
-
- <style type="text/css">
- table.infscroll-opttable { width: 100%;}
- table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }
- table.infscroll-opttable th { padding-top: 13px; text-align: right;}
- table.infscroll-opttable td p { margin: 0;}
- table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }
- table.infscroll-opttable dd { margin-bottom: 0 }
- </style>
-
- <h2>Infinite Scroll Options</h2>
-
- <p>All CSS selectors are found with the jQuery javascript library. See the <a href="http://docs.jquery.com/Selectors">jQuery CSS Selector documentation</a> for an overview of all possibilities. Single-quotes are not allowed&mdash;only double-quotes may be used.
-
- <table class="editform infscroll-opttable" cellspacing="0" >
- <tbody>
- <tr>
- <th width="30%" >
- <label for="<?php echo key_infscr_state; ?>">Infinite Scroll state is:</label>
- </th>
- <td>
- <?php
- echo "<select name='".key_infscr_state."' id='".key_infscr_state."'>\n";
- echo "<option value='".infscr_disabled."'";
- if (get_option(key_infscr_state) == infscr_disabled)
- echo "selected='selected'";
- echo ">OFF</option>\n";
-
- echo "<option value='".infscr_maint."'";
- if (get_option(key_infscr_state) == infscr_maint)
- echo "selected='selected'";
- echo ">ON for Visitors Only</option>\n";
-
- echo "<option value='".infscr_config."'";
- if (get_option(key_infscr_state) == infscr_config)
- echo "selected='selected'";
- echo ">ON for Admins Only</option>\n";
-
- echo "<option value='".infscr_enabled."'";
- if (get_option(key_infscr_state) == infscr_enabled)
- echo "selected='selected'";
- echo ">ON</option>\n";
-
- echo "</select>";
- ?>
- </td>
- <td width="50%">
- "ON for Admins Only" will enable the plugin code only for logged-in administrators&mdash;visitors will not be affected while you configure the plugin. "ON for Visitors Only" is useful for administrators when customizing the blog&mdash;infinite scroll will be disabled for them, but still enabled for any visitors.
- </td>
- </tr>
-<tr>
- <th width="30%" >
- <label for="<?php echo key_infscr_debug; ?>">Debug Mode:</label>
- </th>
- <td>
- <?php
- echo "<select name='".key_infscr_debug."' id='".key_infscr_debug."'>\n";
- echo "<option value='0'";
- if (get_option(key_infscr_debug) == 0)
- echo "selected='selected'";
- echo ">OFF</option>\n";
-
- echo "<option value='1'";
- if (get_option(key_infscr_debug) == 1)
- echo "selected='selected'";
- echo ">ON</option>\n";
-
- echo "</select>";
- ?>
- </td>
- <td width="50%">
- ON will turn on Debug mode. This will enable developer javascript console logging whilst in use. (Recommended: OFF, May break some browsers).
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_content_selector; ?>">Content CSS Selector:</label>
- </th>
- <td>
- <?php
- echo "<input name='".key_infscr_content_selector."' id='".key_infscr_content_selector."' value='".stripslashes(get_option(key_infscr_content_selector))."' size='30' type='text'>\n";
- ?>
- </td>
- <td>
- <p>The selector of the content div on the main page.</p>
- </td>
- </tr>
-
- <tr>
- <th >
- <label for="<?php echo key_infscr_post_selector; ?>">Post CSS Selector:</label>
- </th>
- <td>
- <?php
- echo "<input name='".key_infscr_post_selector."' id='".key_infscr_post_selector."' value='".stripslashes(get_option(key_infscr_post_selector))."' size='30' type='text'>\n";
- ?>
- </td>
- <td>
- <p>The selector of the post block.</p>
- <dl>
- <dt>Examples:</dt>
- <dd>#content &gt; *</dd>
- <dd>#content div.post</dd>
- <dd>div.primary div.entry</dd>
- </dl>
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_nav_selector; ?>">Navigation Links CSS Selector:</label>
- </th>
- <td>
- <?php
- echo "<input name='".key_infscr_nav_selector."' id='".key_infscr_nav_selector."' value='".stripslashes(get_option(key_infscr_nav_selector))."' size='30' type='text'>\n";
- ?>
-
- </td>
- <td>
- <p>The selector of the navigation div (the one that includes the next and previous links).</p>
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_next_selector; ?>">Previous posts CSS Selector:</label>
- </th>
- <td>
- <?php
- echo "<input name='".key_infscr_next_selector."' id='".key_infscr_next_selector."' value='".stripslashes(get_option(key_infscr_next_selector))."' size='30' type='text'>\n";
- ?>
- </td>
- <td>
- <p>The selector of the previous posts (next page) A tag.</p>
- <dl>
- <dt>Examples:</dt>
- <dd>div.navigation a:first</dd>
- <dd>div.navigation a:contains(Previous)</dd>
- </dl>
- </td>
- </tr>
-
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_js_calls; ?>">Javascript to be called after the next posts are fetched:</label>
- </th>
- <td>
- <?php
- echo "<textarea name='".key_infscr_js_calls."' rows='2' style='width: 95%;'>\n";
- echo stripslashes(get_option(key_infscr_js_calls));
- echo "</textarea>\n";
- ?>
- </td>
- <td>
- <p>Any functions that are applied to the post contents on page load will need to be executed when the new content comes in.</p>
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_image; ?>">Loading image:</label>
- </th>
- <td>
- <?php
- echo "<input type='file' name='".key_infscr_image."' id='".key_infscr_image."' size='30' />\n";
- ?>
- </td>
- <td>Current Image:<br /><div style="text-align:center;margin-bottom:15px;"><img src="<?php echo stripslashes(get_option(key_infscr_image));?>" alt="The Loading Image" /></div>
-<p>URL of image that will be displayed while content is being loaded. Visit <a href="http://www.ajaxload.info" target="_blank">www.ajaxload.info</a> to customize your own loading spinner.</p>
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_text; ?>">Loading text:</label>
- </th>
- <td>
- <?php
- echo "<input name='".key_infscr_text."' id='".key_infscr_text."' value='".stripslashes(get_option(key_infscr_text))."' size='30' type='text'>\n";
- ?>
- </td>
- <td>
- <p>Text will be displayed while content is being loaded. <small><acronym>HTML</acrynom> allowed.</small></p>
- </td>
- </tr>
-
- <tr>
- <th>
- <label for="<?php echo key_infscr_donetext; ?>">"You've reached the end" text:</label>
- </th>
- <td>
- <?php
- echo '<input name="'.key_infscr_donetext.'" id="'.key_infscr_donetext.'" value="'.stripslashes(get_option(key_infscr_donetext)).'" size="30" type="text">';
- ?>
- </td>
- <td>
- <p>Text will be displayed when all entries have already been retrieved. The plugin will show this message, fade it out, and cease working. <small><acronym>HTML</acrynom> allowed.</small></p>
- </td>
- </tr>
+add_action("template_redirect" , array('infiniteScroll', 'trigger404'));
- </tbody>
- </table>
-
- <p class="submit">
- <input type='submit' name='info_update' value='Update Options' />
- </p>
- </div>
-</form>
-<?php }?>
+//Add Admin Panel Actions
+add_action('admin_init' , array('infiniteScroll', 'initOptions'));
+add_action('admin_menu' , array('infiniteScroll', 'addOptPageLoader'));
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.