issue. - What error handling do we need? - Mention div#infscr-loading so users can customize look more. - Check if you're in a table and thus you can't add divs. - fix this: http://capacity.electronest.com/2009/01/13/fixing-url-path/ */ // constants for enables/disabled define('infscr_enabled' , 'enabled'); define('infscr_disabled' , 'disabled'); define('infscr_maint' , 'disabledforadmins'); define('infscr_config' , 'enabledforadmins'); // 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 = get_option('siteurl').'/wp-content/plugins/infinite-scroll'.'/ajax-loader.gif'; define('infscr_image_default' , $image_path); define('infscr_text_default' , 'Loading the next set of posts...'); define('infscr_donetext_default' , 'Congratulations, you\'ve reached the end of the internet.'); 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'); // adding actions add_action('wp_footer' , 'wp_inf_scroll_add'); add_action('admin_menu' , 'add_wp_inf_scroll_options_page'); /* // used because wordpress doesnt like to tell us for sure what the homepage is. // removed because it doesnt quite work.. function is_frontpage() { global $post; $id = $post->ID; $show_on_front = get_option('show_on_front'); $page_on_front = get_option('page_on_front'); if ($show_on_front == 'page' && $page_on_front == $id ) { return true; } else { return false; } } */ if ( get_option(key_infscr_state) == infscr_state_default && !isset($_POST['submit']) ) { function setup_warning() { echo "

".__('Infinite Scroll is almost ready.')." ".sprintf(__('Please review the configuration and set the state to enabled for all users.'), "options-general.php?page=wp_infinite_scroll.php")."

"; } add_action('admin_notices', 'setup_warning'); return; } 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_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 js calls field $infscr_js_calls = $_POST[key_infscr_js_calls]; update_option(key_infscr_js_calls, $infscr_js_calls); // update image $infscr_image = $_POST[key_infscr_image]; update_option(key_infscr_image, $infscr_image); // 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 "

Infinite Scroll options updated

"; } // output the options page ?>
Infinite Scroll plugin is disabled.
No Javascript calls will be made after the content is added. This might cause errors in newly added content.

Infinite Scroll Options

All CSS selectors are found with the jQuery javascript library. See the jQuery CSS Selector documentation for an overview of all possibilities. Single-quotes are not allowed—only double-quotes may be used.
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; ?> "Enabled for admins only" will enable the plugin code only for logged-in administrators—visitors will not be affected while you configure the plugin. "Disabled for admins only" is useful for administrators when customizing the blog—infinite scroll will be disabled for them, but still enabled for any visitors.
\n"; ?>

The selector of the content div on the main page.

\n"; ?>

The selector of the post block.

Examples:
#content > *
#content div.post
div.primary div.entry
\n"; ?>

The selector of the navigation div (the one that includes the next and previous links).

\n"; ?>

The selector of the previous posts (next page) A tag.

Examples:
div.navigation a:first
div.navigation a:contains(Previous)
\n"; echo stripslashes(get_option(key_infscr_js_calls)); echo "\n"; ?>

Any functions that are applied to the post contents on page load will need to be executed when the new content comes in.

\n"; ?>

URL of image that will be displayed while content is being loaded. Visit www.ajaxload.info to customize your own loading spinner.

\n"; ?>

Text will be displayed while content is being loaded. HTML allowed.

'; ?>

Text will be displayed when all entries have already been retrieved. The plugin will show this message, fade it out, and cease working. HTML allowed.

'; return; } /* if (! is_paged() ) non-paged dont get it { echo ''; return; } */ /* !is_home() || !is_paged() || paged (archive, tags, categories) and home do. */ if (get_option(key_infscr_state) == infscr_maint && $user_level >= 8) { echo ''; return; } if (get_option(key_infscr_state) == infscr_config && $user_level <= 8) { echo ''; return; } $plugin_dir = get_option('siteurl').'/wp-content/plugins/infinite-scroll'; $js_calls = stripslashes(get_option(key_infscr_js_calls)); $loading_image = stripslashes(get_option(key_infscr_image)); $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)); if ($user_level >= 8) {$isAdmin = "true"; }else {$isAdmin = "false";} $js_string = << if (!(window.jQuery && jQuery.fn.jquery >= '1.2.6')){ document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E")); window.INFSCR_jQ=true; } EOT; echo $js_string; return; } ?>