waterwise-wp/0000775000103300000410000000000011177140771013320 5ustar robertwww-datawaterwise-wp/wp-trackback.php0000644000103300000410000000655211016305267016403 0ustar robertwww-data\n"; echo "\n"; echo "1\n"; echo "$error_message\n"; echo ""; die(); } else { echo '\n"; echo "\n"; echo "0\n"; echo ""; } } // trackback is done by a POST $request_array = 'HTTP_POST_VARS'; if ( !$_GET['tb_id'] ) { $tb_id = explode('/', $_SERVER['REQUEST_URI']); $tb_id = intval( $tb_id[ count($tb_id) - 1 ] ); } $tb_url = $_POST['url']; $charset = $_POST['charset']; // These three are stripslashed here so that they can be properly escaped after mb_convert_encoding() $title = stripslashes($_POST['title']); $excerpt = stripslashes($_POST['excerpt']); $blog_name = stripslashes($_POST['blog_name']); if ($charset) $charset = strtoupper( trim($charset) ); else $charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS'; // No valid uses for UTF-7 if ( false !== strpos($charset, 'UTF-7') ) die; if ( function_exists('mb_convert_encoding') ) { // For international trackbacks $title = mb_convert_encoding($title, get_option('blog_charset'), $charset); $excerpt = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset); $blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset); } // Now that mb_convert_encoding() has been given a swing, we need to escape these three $title = $wpdb->escape($title); $excerpt = $wpdb->escape($excerpt); $blog_name = $wpdb->escape($blog_name); if ( is_single() || is_page() ) $tb_id = $posts[0]->ID; if ( !intval( $tb_id ) ) trackback_response(1, 'I really need an ID for this to work.'); if (empty($title) && empty($tb_url) && empty($blog_name)) { // If it doesn't look like a trackback at all... wp_redirect(get_permalink($tb_id)); exit; } if ( !empty($tb_url) && !empty($title) ) { header('Content-Type: text/xml; charset=' . get_option('blog_charset') ); if ( !pings_open($tb_id) ) trackback_response(1, 'Sorry, trackbacks are closed for this item.'); $title = wp_html_excerpt( $title, 250 ).'...'; $excerpt = wp_html_excerpt( $excerpt, 252 ).'...'; $comment_post_ID = (int) $tb_id; $comment_author = $blog_name; $comment_author_email = ''; $comment_author_url = $tb_url; $comment_content = "$title\n\n$excerpt"; $comment_type = 'trackback'; $dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) ); if ( $dupe ) trackback_response(1, 'We already have a ping from that URL for this post.'); $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type'); wp_new_comment($commentdata); do_action('trackback_post', $wpdb->insert_id); trackback_response(0); } ?>waterwise-wp/wp-config-sample.php0000644000103300000410000000470111121663701017171 0ustar robertwww-data waterwise-wp/wp-settings.php0000644000103300000410000004440711136612764016325 0ustar robertwww-data $v ) if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) { $GLOBALS[$k] = NULL; unset($GLOBALS[$k]); } } wp_unregister_GLOBALS(); unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate ); /** * The $blog_id global, which you can change in the config allows you to create a simple * multiple blog installation using just one WordPress and changing $blog_id around. * * @global int $blog_id * @since 2.0.0 */ if ( ! isset($blog_id) ) $blog_id = 1; // Fix for IIS, which doesn't set REQUEST_URI if ( empty( $_SERVER['REQUEST_URI'] ) ) { // IIS Mod-Rewrite if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } // IIS Isapi_Rewrite else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { // Use ORIG_PATH_INFO if there is no PATH_INFO if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) ) $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) if ( isset($_SERVER['PATH_INFO']) ) { if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; else $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; } // Append the query string if it exists and isn't null if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; // Fix for Dreamhost and other PHP as CGI hosts if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) unset($_SERVER['PATH_INFO']); // Fix empty PHP_SELF $PHP_SELF = $_SERVER['PHP_SELF']; if ( empty($PHP_SELF) ) $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); if ( version_compare( '4.3', phpversion(), '>' ) ) { die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) ); } if ( !defined('WP_CONTENT_DIR') ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) { include(ABSPATH . '.maintenance'); // If the $upgrading timestamp is older than 10 minutes, don't die. if ( ( time() - $upgrading ) < 600 ) { if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { require_once( WP_CONTENT_DIR . '/maintenance.php' ); die(); } $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; header( "$protocol 503 Service Unavailable", true, 503 ); header( 'Content-Type: text/html; charset=utf-8' ); ?> Maintenance

Briefly unavailable for scheduled maintenance. Check back in a minute.

* $nTimePageTookToExecute = timer_stop(); * echo $nTimePageTookToExecute; * * * Or instead, you can do: * * timer_stop(1); * * which will do what the above does. If you need the result, you can assign it to a variable, but * most cases, you only need to echo it. * * @since 0.71 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called * @global int $timeend Seconds and Microseconds added together from when function is called * * @param int $display Use '0' or null to not echo anything and 1 to echo the total time * @param int $precision The amount of digits from the right of the decimal to display. Default is 3. * @return float The "second.microsecond" finished time calculation */ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal global $timestart, $timeend; $mtime = microtime(); $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; $timeend = $mtime; $timetotal = $timeend-$timestart; $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); if ( $display ) echo $r; return $r; } timer_start(); // Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development. if (defined('WP_DEBUG') and WP_DEBUG == true) { error_reporting(E_ALL); } else { // Unicode Extension is in PHP 6.0 only or do version check when this changes. if ( function_exists('unicode_decode') ) error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_USER_NOTICE ^ E_STRICT ); else if ( defined( 'E_DEPRECATED' ) ) // Introduced in PHP 5.3 error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_USER_NOTICE ); else error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE); } // For an advanced caching plugin to use, static because you would only want one if ( defined('WP_CACHE') ) @include WP_CONTENT_DIR . '/advanced-cache.php'; /** * Stores the location of the WordPress directory of functions, classes, and core content. * * @since 1.0.0 */ define('WPINC', 'wp-includes'); if ( !defined('WP_LANG_DIR') ) { /** * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR * and uses that folder if it exists. Or it uses the "languages" folder in WPINC. * * @since 2.1.0 */ if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) { define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH if (!defined('LANGDIR')) { // Old static relative path maintained for limited backwards compatibility - won't work in some cases define('LANGDIR', 'wp-content/languages'); } } else { define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH if (!defined('LANGDIR')) { // Old relative path maintained for backwards compatibility define('LANGDIR', WPINC . '/languages'); } } } require (ABSPATH . WPINC . '/compat.php'); require (ABSPATH . WPINC . '/functions.php'); require (ABSPATH . WPINC . '/classes.php'); require_wp_db(); if ( !empty($wpdb->error) ) dead_db(); $prefix = $wpdb->set_prefix($table_prefix); if ( is_wp_error($prefix) ) wp_die(/*WP_I18N_BAD_PREFIX*/'ERROR: $table_prefix in wp-config.php can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/); if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) require_once (WP_CONTENT_DIR . '/object-cache.php'); else require_once (ABSPATH . WPINC . '/cache.php'); wp_cache_init(); if ( function_exists('wp_cache_add_global_groups') ) { wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta')); wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); } require (ABSPATH . WPINC . '/plugin.php'); require (ABSPATH . WPINC . '/default-filters.php'); include_once(ABSPATH . WPINC . '/streams.php'); include_once(ABSPATH . WPINC . '/gettext.php'); require_once (ABSPATH . WPINC . '/l10n.php'); if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) { if ( defined('WP_SITEURL') ) $link = WP_SITEURL . '/wp-admin/install.php'; elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; else $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; require_once(ABSPATH . WPINC . '/kses.php'); require_once(ABSPATH . WPINC . '/pluggable.php'); wp_redirect($link); die(); // have to die here ~ Mark } require (ABSPATH . WPINC . '/formatting.php'); require (ABSPATH . WPINC . '/capabilities.php'); require (ABSPATH . WPINC . '/query.php'); require (ABSPATH . WPINC . '/theme.php'); require (ABSPATH . WPINC . '/user.php'); require (ABSPATH . WPINC . '/general-template.php'); require (ABSPATH . WPINC . '/link-template.php'); require (ABSPATH . WPINC . '/author-template.php'); require (ABSPATH . WPINC . '/post.php'); require (ABSPATH . WPINC . '/post-template.php'); require (ABSPATH . WPINC . '/category.php'); require (ABSPATH . WPINC . '/category-template.php'); require (ABSPATH . WPINC . '/comment.php'); require (ABSPATH . WPINC . '/comment-template.php'); require (ABSPATH . WPINC . '/rewrite.php'); require (ABSPATH . WPINC . '/feed.php'); require (ABSPATH . WPINC . '/bookmark.php'); require (ABSPATH . WPINC . '/bookmark-template.php'); require (ABSPATH . WPINC . '/kses.php'); require (ABSPATH . WPINC . '/cron.php'); require (ABSPATH . WPINC . '/version.php'); require (ABSPATH . WPINC . '/deprecated.php'); require (ABSPATH . WPINC . '/script-loader.php'); require (ABSPATH . WPINC . '/taxonomy.php'); require (ABSPATH . WPINC . '/update.php'); require (ABSPATH . WPINC . '/canonical.php'); require (ABSPATH . WPINC . '/shortcodes.php'); require (ABSPATH . WPINC . '/media.php'); require (ABSPATH . WPINC . '/http.php'); if ( !defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up /** * Allows for the plugins directory to be moved from the default location. * * @since 2.6.0 */ if ( !defined('WP_PLUGIN_DIR') ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash /** * Allows for the plugins directory to be moved from the default location. * * @since 2.6.0 */ if ( !defined('WP_PLUGIN_URL') ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash /** * Allows for the plugins directory to be moved from the default location. * * @since 2.1.0 */ if ( !defined('PLUGINDIR') ) define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat. /** * Used to guarantee unique hash cookies * @since 1.5 */ define('COOKIEHASH', md5(get_option('siteurl'))); /** * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php * @since 2.5.0 */ $wp_default_secret_key = 'put your unique phrase here'; /** * It is possible to define this in wp-config.php * @since 2.0.0 */ if ( !defined('USER_COOKIE') ) define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH); /** * It is possible to define this in wp-config.php * @since 2.0.0 */ if ( !defined('PASS_COOKIE') ) define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH); /** * It is possible to define this in wp-config.php * @since 2.5.0 */ if ( !defined('AUTH_COOKIE') ) define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('SECURE_AUTH_COOKIE') ) define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('LOGGED_IN_COOKIE') ) define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH); /** * It is possible to define this in wp-config.php * @since 2.3.0 */ if ( !defined('TEST_COOKIE') ) define('TEST_COOKIE', 'wordpress_test_cookie'); /** * It is possible to define this in wp-config.php * @since 1.2.0 */ if ( !defined('COOKIEPATH') ) define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) ); /** * It is possible to define this in wp-config.php * @since 1.5.0 */ if ( !defined('SITECOOKIEPATH') ) define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) ); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('ADMIN_COOKIE_PATH') ) define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' ); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('PLUGINS_COOKIE_PATH') ) define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) ); /** * It is possible to define this in wp-config.php * @since 2.0.0 */ if ( !defined('COOKIE_DOMAIN') ) define('COOKIE_DOMAIN', false); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('FORCE_SSL_ADMIN') ) define('FORCE_SSL_ADMIN', false); force_ssl_admin(FORCE_SSL_ADMIN); /** * It is possible to define this in wp-config.php * @since 2.6.0 */ if ( !defined('FORCE_SSL_LOGIN') ) define('FORCE_SSL_LOGIN', false); force_ssl_login(FORCE_SSL_LOGIN); /** * It is possible to define this in wp-config.php * @since 2.5.0 */ if ( !defined( 'AUTOSAVE_INTERVAL' ) ) define( 'AUTOSAVE_INTERVAL', 60 ); require (ABSPATH . WPINC . '/vars.php'); // Check for hacks file if the option is enabled if (get_option('hack_file')) { if (file_exists(ABSPATH . 'my-hacks.php')) require(ABSPATH . 'my-hacks.php'); } if ( get_option('active_plugins') && !defined('WP_INSTALLING') ) { $current_plugins = get_option('active_plugins'); if ( is_array($current_plugins) ) { foreach ($current_plugins as $plugin) { if ( '' != $plugin && 0 == validate_file($plugin) && file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) include_once(WP_PLUGIN_DIR . '/' . $plugin); } } } require (ABSPATH . WPINC . '/pluggable.php'); /* * In most cases the default internal encoding is latin1, which is of no use, * since we want to use the mb_ functions for utf-8 strings */ if (function_exists('mb_internal_encoding')) { if (!@mb_internal_encoding(get_option('blog_charset'))) mb_internal_encoding('UTF-8'); } if ( defined('WP_CACHE') && function_exists('wp_cache_postload') ) wp_cache_postload(); do_action('plugins_loaded'); $default_constants = array( 'WP_POST_REVISIONS' => true ); foreach ( $default_constants as $c => $v ) @define( $c, $v ); // will fail if the constant is already defined unset($default_constants, $c, $v); // If already slashed, strip. if ( get_magic_quotes_gpc() ) { $_GET = stripslashes_deep($_GET ); $_POST = stripslashes_deep($_POST ); $_COOKIE = stripslashes_deep($_COOKIE); } // Escape with wpdb. $_GET = add_magic_quotes($_GET ); $_POST = add_magic_quotes($_POST ); $_COOKIE = add_magic_quotes($_COOKIE); $_SERVER = add_magic_quotes($_SERVER); do_action('sanitize_comment_cookies'); /** * WordPress Query object * @global object $wp_the_query * @since 2.0.0 */ $wp_the_query =& new WP_Query(); /** * Holds the reference to @see $wp_the_query * Use this global for WordPress queries * @global object $wp_query * @since 1.5.0 */ $wp_query =& $wp_the_query; /** * Holds the WordPress Rewrite object for creating pretty URLs * @global object $wp_rewrite * @since 1.5.0 */ $wp_rewrite =& new WP_Rewrite(); /** * WordPress Object * @global object $wp * @since 2.0.0 */ $wp =& new WP(); do_action('setup_theme'); /** * Web Path to the current active template directory * @since 1.5.0 */ define('TEMPLATEPATH', get_template_directory()); /** * Web Path to the current active template stylesheet directory * @since 2.1.0 */ define('STYLESHEETPATH', get_stylesheet_directory()); // Load the default text localization domain. load_default_textdomain(); /** * The locale of the blog * @since 1.5.0 */ $locale = get_locale(); $locale_file = WP_LANG_DIR . "/$locale.php"; if ( is_readable($locale_file) ) require_once($locale_file); // Pull in locale data after loading text domain. require_once(ABSPATH . WPINC . '/locale.php'); /** * WordPress Locale object for loading locale domain date and various strings. * @global object $wp_locale * @since 2.1.0 */ $wp_locale =& new WP_Locale(); // Load functions for active theme. if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') ) include(STYLESHEETPATH . '/functions.php'); if ( file_exists(TEMPLATEPATH . '/functions.php') ) include(TEMPLATEPATH . '/functions.php'); /** * Runs just before PHP shuts down execution. * * @access private * @since 1.2.0 */ function shutdown_action_hook() { do_action('shutdown'); wp_cache_close(); } register_shutdown_function('shutdown_action_hook'); $wp->init(); // Sets up current user. // Everything is loaded and initialized. do_action('init'); ?> waterwise-wp/wp-rss2.php0000644000103300000410000000033411075035274015342 0ustar robertwww-datawaterwise-wp/readme.html0000644000103300000410000001672611102132500015430 0ustar robertwww-data WordPress › ReadMe

WordPress
Version 2.7

Semantic Personal Publishing Platform

First Things First

Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.

— Matt Mullenweg

Installation: Famous 5-minute install

  1. Unzip the package in an empty directory.
  2. Open up wp-config-sample.php with a text editor like WordPad or similar and fill in your database connection details.
  3. Save the file as wp-config.php
  4. Upload everything.
  5. Open /wp-admin/install.php in your browser. This should setup the tables needed for your blog. If there is an error, double check your wp-config.php file, and try again. If it fails again, please go to the support forums with as much data as you can gather.
  6. Note the password given to you.
  7. The install script should then send you to the login page. Sign in with the username admin and the password generated during the installation. You can then click on 'Profile' to change the password.

Upgrading

Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php.

Upgrading from any previous WordPress to 2.7:

  1. Delete your old WP files, saving ones you've modified.
  2. Upload the new files.
  3. Point your browser to /wp-admin/upgrade.php.
  4. You wanted more, perhaps? That's it!

Template Changes

If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, we've created a special guide for you.

Online Resources

If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:

The WordPress Codex
The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.
The Development Blog
This is where you'll find the latest updates and news related to WordPress. Bookmark and check often.
WordPress Planet
The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.
WordPress Support Forums
If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.
WordPress IRC Channel
Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpress)

System Recommendations

WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.

Upgrading from another system

WordPress can import from a number of systems. First you need to get WordPress installed and working as described above.

XML-RPC and Atom Interface

You can now post to your WordPress blog with tools like Windows Live Writer, Ecto, Bloggar, Radio Userland (which means you can use Radio's email-to-blog feature), NewzCrawler, and other tools that support the Blogging APIs! :) You can read more about XML-RPC support on the Codex.

Post via Email

You can post from an email client! To set this up go to your "Writing" options screen and fill in the connection details for your secret POP3 account. Then you need to set up wp-mail.php to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your wp-mail.php URL.

Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address discrete. The script will delete emails that are successfully posted.

User Roles

We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can read more about Roles and Capabilities on the Codex.

Final notes

Share the Love

WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better—you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.

Copyright

WordPress is released under the GPL (see license.txt).

waterwise-wp/index.php0000644000103300000410000000061511016346411015127 0ustar robertwww-datawaterwise-wp/wp-includes/0000775000103300000410000000000011144353006015541 5ustar robertwww-datawaterwise-wp/wp-includes/formatting.php0000644000103300000410000022026611140365610020432 0ustar robertwww-data * 'cause today's effort makes it worth tomorrow's "holiday"... * * Becomes: * * ’cause today’s effort makes it worth tomorrow’s “holiday”… * * Code within certain html blocks are skipped. * * @since 0.71 * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases * * @param string $text The text to be formatted * @return string The string replaced with html entities */ function wptexturize($text) { global $wp_cockneyreplace; $next = true; $has_pre_parent = false; $output = ''; $curl = ''; $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $stop = count($textarr); // if a plugin has provided an autocorrect array, use it if ( isset($wp_cockneyreplace) ) { $cockney = array_keys($wp_cockneyreplace); $cockneyreplace = array_values($wp_cockneyreplace); } else { $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause"); $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); } $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney); $static_replacements = array_merge(array('—', ' — ', '–', 'xn--', '…', '“', '’s', '”', ' ™'), $cockneyreplace); $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); for ( $i = 0; $i < $stop; $i++ ) { $curl = $textarr[$i]; if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag // static strings $curl = str_replace($static_characters, $static_replacements, $curl); // regular expressions $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); } elseif (strpos($curl, '') !== false) { $has_pre_parent = false; } else { $next = true; } $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); $output .= $curl; } return $output; } /** * Accepts matches array from preg_replace_callback in wpautop() or a string. * * Ensures that the contents of a <
>...<
> HTML block are not * converted into paragraphs or line-breaks. * * @since 1.2.0 * * @param array|string $matches The array or string * @return string The pre block without paragraph/line-break conversion. */ function clean_pre($matches) { if ( is_array($matches) ) $text = $matches[1] . $matches[2] . ""; else $text = $matches; $text = str_replace('
', '', $text); $text = str_replace('

', "\n", $text); $text = str_replace('

', '', $text); return $text; } /** * Replaces double line-breaks with paragraph elements. * * A group of regex replaces used to identify text formatted with newlines and * replace double line-breaks with HTML paragraph tags. The remaining * line-breaks after conversion become <
> tags, unless $br is set to '0' * or 'false'. * * @since 0.71 * * @param string $pee The text which has to be formatted. * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. * @return string Text which has been converted into correct paragraph tags. */ function wpautop($pee, $br = 1) { $pee = $pee . "\n"; // just to make things a little easier, pad the end $pee = preg_replace('|
\s*
|', "\n\n", $pee); // Space things out a little $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)'; $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); $pee = preg_replace('!()!', "$1\n\n", $pee); $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines if ( strpos($pee, ']*)>\s*|', "", $pee); // no pee inside object/embed $pee = preg_replace('|\s*\s*|', '', $pee); } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates // make paragraphs, including one at the end $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); $pee = ''; foreach ( $pees as $tinkle ) $pee .= '

' . trim($tinkle, "\n") . "

\n"; $pee = preg_replace('|

\s*?

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([^<]+)\s*?(]*>)!', "

$1

$2", $pee); $pee = preg_replace( '|

|', "$1

", $pee ); $pee = preg_replace('!

\s*(]*>)\s*

!', "$1", $pee); // don't pee all over a tag $pee = preg_replace("|

(|", "$1", $pee); // problem with nested lists $pee = preg_replace('|

]*)>|i', "

", $pee); $pee = str_replace('

', '

', $pee); $pee = preg_replace('!

\s*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\s*

!', "$1", $pee); if ($br) { $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "", $matches[0]);'), $pee); $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks $pee = str_replace('', "\n", $pee); } $pee = preg_replace('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); if (strpos($pee, ')(.*?)!is', 'clean_pre', $pee ); $pee = preg_replace( "|\n

$|", '

', $pee ); $pee = preg_replace('/

\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone return $pee; } /** * Checks to see if a string is utf8 encoded. * * @author bmorel at ssi dot fr * * @since 1.2.1 * * @param string $Str The string to be checked * @return bool True if $Str fits a UTF-8 model, false otherwise. */ function seems_utf8($Str) { # by bmorel at ssi dot fr $length = strlen($Str); for ($i=0; $i < $length; $i++) { if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b else return false; # Does not match any model for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? if ((++$i == $length) || ((ord($Str[$i]) & 0xC0) != 0x80)) return false; } } return true; } /** * Converts a number of special characters into their HTML entities. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to encode " to * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. * * @since 1.2.2 * * @param string $string The text which is to be encoded. * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. * @param string $charset Optional. The character encoding of the string. Default is false. * @param boolean $double_encode Optional. Whether or not to encode existing html entities. Default is false. * @return string The encoded text with HTML entities. */ function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { $string = (string) $string; if ( 0 === strlen( $string ) ) { return ''; } // Don't bother if there are no specialchars - saves some processing if ( !preg_match( '/[&<>"\']/', $string ) ) { return $string; } // Account for the previous behaviour of the function when the $quote_style is not an accepted value if ( empty( $quote_style ) ) { $quote_style = ENT_NOQUOTES; } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { $quote_style = ENT_QUOTES; } // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() if ( !$charset ) { static $_charset; if ( !isset( $_charset ) ) { $alloptions = wp_load_alloptions(); $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; } $charset = $_charset; } if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) { $charset = 'UTF-8'; } $_quote_style = $quote_style; if ( $quote_style === 'double' ) { $quote_style = ENT_COMPAT; $_quote_style = ENT_COMPAT; } elseif ( $quote_style === 'single' ) { $quote_style = ENT_NOQUOTES; } // Handle double encoding ourselves if ( !$double_encode ) { $string = wp_specialchars_decode( $string, $_quote_style ); $string = preg_replace( '/&(#?x?[0-9]+|[a-z]+);/i', '|wp_entity|$1|/wp_entity|', $string ); } $string = @htmlspecialchars( $string, $quote_style, $charset ); // Handle double encoding ourselves if ( !$double_encode ) { $string = str_replace( array( '|wp_entity|', '|/wp_entity|' ), array( '&', ';' ), $string ); } // Backwards compatibility if ( 'single' === $_quote_style ) { $string = str_replace( "'", ''', $string ); } return $string; } /** * Converts a number of HTML entities into their special characters. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to decode " entities, * or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded. * * @since 2.8 * * @param string $string The text which is to be decoded. * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. * @return string The decoded text without HTML entities. */ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { $string = (string) $string; if ( 0 === strlen( $string ) ) { return ''; } // Don't bother if there are no entities - saves a lot of processing if ( strpos( $string, '&' ) === false ) { return $string; } // Match the previous behaviour of wp_specialchars() when the $quote_style is not an accepted value if ( empty( $quote_style ) ) { $quote_style = ENT_NOQUOTES; } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { $quote_style = ENT_QUOTES; } // More complete than get_html_translation_table( HTML_SPECIALCHARS ) $single = array( ''' => '\'', ''' => '\'' ); $single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' ); $double = array( '"' => '"', '"' => '"', '"' => '"' ); $double_preg = array( '/�*34;/' => '"', '/�*22;/i' => '"' ); $others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' ); $others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' ); if ( $quote_style === ENT_QUOTES ) { $translation = array_merge( $single, $double, $others ); $translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) { $translation = array_merge( $double, $others ); $translation_preg = array_merge( $double_preg, $others_preg ); } elseif ( $quote_style === 'single' ) { $translation = array_merge( $single, $others ); $translation_preg = array_merge( $single_preg, $others_preg ); } elseif ( $quote_style === ENT_NOQUOTES ) { $translation = $others; $translation_preg = $others_preg; } // Remove zero padding on numeric entities $string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string ); // Replace characters according to translation table return strtr( $string, $translation ); } /** * Checks for invalid UTF8 in a string. * * @since 2.8 * * @param string $string The text which is to be checked. * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false. * @return string The checked text. */ function wp_check_invalid_utf8( $string, $strip = false ) { $string = (string) $string; if ( 0 === strlen( $string ) ) { return ''; } // Store the site charset as a static to avoid multiple calls to get_option() static $is_utf8; if ( !isset( $is_utf8 ) ) { $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); } if ( !$is_utf8 ) { return $string; } // Check for support for utf8 in the installed PCRE library once and store the result in a static static $utf8_pcre; if ( !isset( $utf8_pcre ) ) { $utf8_pcre = @preg_match( '/^./u', 'a' ); } // We can't demand utf8 in the PCRE installation, so just return the string in those cases if ( !$utf8_pcre ) { return $string; } // preg_match fails when it encounters invalid UTF8 in $string if ( 1 === @preg_match( '/^./us', $string ) ) { return $string; } // Attempt to strip the bad chars if requested (not recommended) if ( $strip && function_exists( 'iconv' ) ) { return iconv( 'utf-8', 'utf-8', $string ); } return ''; } /** * Encode the Unicode values to be used in the URI. * * @since 1.5.0 * * @param string $utf8_string * @param int $length Max length of the string * @return string String with Unicode encoded for URI. */ function utf8_uri_encode( $utf8_string, $length = 0 ) { $unicode = ''; $values = array(); $num_octets = 1; $unicode_length = 0; $string_length = strlen( $utf8_string ); for ($i = 0; $i < $string_length; $i++ ) { $value = ord( $utf8_string[ $i ] ); if ( $value < 128 ) { if ( $length && ( $unicode_length >= $length ) ) break; $unicode .= chr($value); $unicode_length++; } else { if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; $values[] = $value; if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) break; if ( count( $values ) == $num_octets ) { if ($num_octets == 3) { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); $unicode_length += 9; } else { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); $unicode_length += 6; } $values = array(); $num_octets = 1; } } } return $unicode; } /** * Converts all accent characters to ASCII characters. * * If there are no accent characters, then the string given is just returned. * * @since 1.2.1 * * @param string $string Text that might have accent characters * @return string Filtered string with replaced "nice" characters. */ function remove_accents($string) { if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; if (seems_utf8($string)) { $chars = array( // Decompositions for Latin-1 Supplement chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', chr(195).chr(159) => 's', chr(195).chr(160) => 'a', chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', chr(195).chr(191) => 'y', // Decompositions for Latin Extended-A chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', chr(197).chr(154) => 'S',chr(197).chr(155) => 's', chr(197).chr(156) => 'S',chr(197).chr(157) => 's', chr(197).chr(158) => 'S',chr(197).chr(159) => 's', chr(197).chr(160) => 'S', chr(197).chr(161) => 's', chr(197).chr(162) => 'T', chr(197).chr(163) => 't', chr(197).chr(164) => 'T', chr(197).chr(165) => 't', chr(197).chr(166) => 'T', chr(197).chr(167) => 't', chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', chr(197).chr(190) => 'z', chr(197).chr(191) => 's', // Euro Sign chr(226).chr(130).chr(172) => 'E', // GBP (Pound) Sign chr(194).chr(163) => ''); $string = strtr($string, $chars); } else { // Assume ISO-8859-1 if not UTF-8 $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158) .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251) .chr(252).chr(253).chr(255); $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $string = strtr($string, $chars['in'], $chars['out']); $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); $string = str_replace($double_chars['in'], $double_chars['out'], $string); } return $string; } /** * Filters certain characters from the file name. * * Turns all strings to lowercase removing most characters except alphanumeric * with spaces, dashes and periods. All spaces and underscores are converted to * dashes. Multiple dashes are converted to a single dash. Finally, if the file * name ends with a dash, it is removed. * * @since 2.1.0 * * @param string $name The file name * @return string Sanitized file name */ function sanitize_file_name( $name ) { // Like sanitize_title, but with periods $name = strtolower( $name ); $name = preg_replace('/&.+?;/', '', $name); // kill entities $name = str_replace( '_', '-', $name ); $name = preg_replace('/[^a-z0-9\s-.]/', '', $name); $name = preg_replace('/\s+/', '-', $name); $name = preg_replace('|-+|', '-', $name); $name = trim($name, '-'); return $name; } /** * Sanitize username stripping out unsafe characters. * * If $strict is true, only alphanumeric characters (as well as _, space, ., -, * @) are returned. * Removes tags, octets, entities, and if strict is enabled, will remove all * non-ASCII characters. After sanitizing, it passes the username, raw username * (the username in the parameter), and the strict parameter as parameters for * the filter. * * @since 2.0.0 * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username, * and $strict parameter. * * @param string $username The username to be sanitized. * @param bool $strict If set limits $username to specific characters. Default false. * @return string The sanitized username, after passing through filters. */ function sanitize_user( $username, $strict = false ) { $raw_username = $username; $username = strip_tags($username); // Kill octets $username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username); $username = preg_replace('/&.+?;/', '', $username); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username); // Consolidate contiguous whitespace $username = preg_replace('|\s+|', ' ', $username); return apply_filters('sanitize_user', $username, $raw_username, $strict); } /** * Sanitizes title or use fallback title. * * Specifically, HTML and PHP tags are stripped. Further actions can be added * via the plugin API. If $title is empty and $fallback_title is set, the latter * will be used. * * @since 1.0.0 * * @param string $title The string to be sanitized. * @param string $fallback_title Optional. A title to use if $title is empty. * @return string The sanitized string. */ function sanitize_title($title, $fallback_title = '') { $title = strip_tags($title); $title = apply_filters('sanitize_title', $title); if ( '' === $title || false === $title ) $title = $fallback_title; return $title; } /** * Sanitizes title, replacing whitespace with dashes. * * Limits the output to alphanumeric characters, underscore (_) and dash (-). * Whitespace becomes a dash. * * @since 1.2.0 * * @param string $title The title to be sanitized. * @return string The sanitized title. */ function sanitize_title_with_dashes($title) { $title = strip_tags($title); // Preserve escaped octets. $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); // Remove percent signs that are not part of an octet. $title = str_replace('%', '', $title); // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); $title = remove_accents($title); if (seems_utf8($title)) { if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); } $title = utf8_uri_encode($title, 200); } $title = strtolower($title); $title = preg_replace('/&.+?;/', '', $title); // kill entities $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; } /** * Ensures a string is a valid SQL order by clause. * * Accepts one or more columns, with or without ASC/DESC, and also accepts * RAND(). * * @since 2.5.1 * * @param string $orderby Order by string to be checked. * @return string|false Returns the order by clause if it is a match, false otherwise. */ function sanitize_sql_orderby( $orderby ){ preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches); if ( !$obmatches ) return false; return $orderby; } /** * Converts a number of characters from a string. * * Metadata tags <> and <<category>> are removed, <<br>> and <<hr>> are * converted into correct XHTML and Unicode characters are converted to the * valid range. * * @since 0.71 * * @param string $content String of characters to be converted. * @param string $deprecated Not used. * @return string Converted string. */ function convert_chars($content, $deprecated = '') { // Translation of invalid Unicode references range to valid range $wp_htmltranswinuni = array( '€' => '€', // the Euro sign '' => '', '‚' => '‚', // these are Windows CP1252 specific characters 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers '„' => '„', '…' => '…', '†' => '†', '‡' => '‡', 'ˆ' => 'ˆ', '‰' => '‰', 'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ', '' => '', 'Ž' => 'ž', '' => '', '' => '', '‘' => '‘', '’' => '’', '“' => '“', '”' => '”', '•' => '•', '–' => '–', '—' => '—', '˜' => '˜', '™' => '™', 'š' => 'š', '›' => '›', 'œ' => 'œ', '' => '', 'ž' => '', 'Ÿ' => 'Ÿ' ); // Remove metadata tags $content = preg_replace('/<title>(.+?)<\/title>/','',$content); $content = preg_replace('/<category>(.+?)<\/category>/','',$content); // Converts lone & characters into & (a.k.a. &) $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content); // Fix Word pasting $content = strtr($content, $wp_htmltranswinuni); // Just a little XHTML help $content = str_replace('<br>', '<br />', $content); $content = str_replace('<hr>', '<hr />', $content); return $content; } /** * Fixes javascript bugs in browsers. * * Converts unicode characters to HTML numbered entities. * * @since 1.5.0 * @uses $is_macIE * @uses $is_winIE * * @param string $text Text to be made safe. * @return string Fixed text. */ function funky_javascript_fix($text) { // Fixes for browsers' javascript bugs global $is_macIE, $is_winIE; /** @todo use preg_replace_callback() instead */ if ( $is_winIE || $is_macIE ) $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text); return $text; } /** * Will only balance the tags if forced to and the option is set to balance tags. * * The option 'use_balanceTags' is used for whether the tags will be balanced. * Both the $force parameter and 'use_balanceTags' option will have to be true * before the tags will be balanced. * * @since 0.71 * * @param string $text Text to be balanced * @param bool $force Forces balancing, ignoring the value of the option. Default false. * @return string Balanced text */ function balanceTags( $text, $force = false ) { if ( !$force && get_option('use_balanceTags') == 0 ) return $text; return force_balance_tags( $text ); } /** * Balances tags of string using a modified stack. * * @since 2.0.4 * * @author Leonard Lin <leonard@acm.org> * @license GPL v2.0 * @copyright November 4, 2001 * @version 1.1 * @todo Make better - change loop condition to $text in 1.2 * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004 * 1.1 Fixed handling of append/stack pop order of end text * Added Cleaning Hooks * 1.0 First Version * * @param string $text Text to be balanced. * @return string Balanced text. */ function force_balance_tags( $text ) { $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves # WP bug fix for comments - in case you REALLY meant to type '< !--' $text = str_replace('< !--', '< !--', $text); # WP bug fix for LOVE <3 (and other situations with '<' before a number) $text = preg_replace('#<([0-9]{1})#', '<$1', $text); while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) { $newtext .= $tagqueue; $i = strpos($text,$regex[0]); $l = strlen($regex[0]); // clear the shifter $tagqueue = ''; // Pop or Push if ($regex[1][0] == "/") { // End Tag $tag = strtolower(substr($regex[1],1)); // if too many closing tags if($stacksize <= 0) { $tag = ''; //or close to be safe $tag = '/' . $tag; } // if stacktop value = tag close value then pop else if ($tagstack[$stacksize - 1] == $tag) { // found closing tag $tag = '</' . $tag . '>'; // Close Tag // Pop array_pop ($tagstack); $stacksize--; } else { // closing tag not at top, search for it for ($j=$stacksize-1;$j>=0;$j--) { if ($tagstack[$j] == $tag) { // add tag to tagqueue for ($k=$stacksize-1;$k>=$j;$k--){ $tagqueue .= '</' . array_pop ($tagstack) . '>'; $stacksize--; } break; } } $tag = ''; } } else { // Begin Tag $tag = strtolower($regex[1]); // Tag Cleaning // If self-closing or '', don't do anything. if((substr($regex[2],-1) == '/') || ($tag == '')) { } // ElseIf it's a known single-entity tag but it doesn't close itself, do so elseif ( in_array($tag, $single_tags) ) { $regex[2] .= '/'; } else { // Push the tag onto the stack // If the top of the stack is the same as the tag we want to push, close previous tag if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) { $tagqueue = '</' . array_pop ($tagstack) . '>'; $stacksize--; } $stacksize = array_push ($tagstack, $tag); } // Attributes $attributes = $regex[2]; if($attributes) { $attributes = ' '.$attributes; } $tag = '<'.$tag.$attributes.'>'; //If already queuing a close tag, then put this tag on, too if ($tagqueue) { $tagqueue .= $tag; $tag = ''; } } $newtext .= substr($text,0,$i) . $tag; $text = substr($text,$i+$l); } // Clear Tag Queue $newtext .= $tagqueue; // Add Remaining text $newtext .= $text; // Empty Stack while($x = array_pop($tagstack)) { $newtext .= '</' . $x . '>'; // Add remaining tags to close } // WP fix for the bug with HTML comments $newtext = str_replace("< !--","<!--",$newtext); $newtext = str_replace("< !--","< !--",$newtext); return $newtext; } /** * Acts on text which is about to be edited. * * Unless $richedit is set, it is simply a holder for the 'format_to_edit' * filter. If $richedit is set true htmlspecialchars() will be run on the * content, converting special characters to HTMl entities. * * @since 0.71 * * @param string $content The text about to be edited. * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false. * @return string The text after the filter (and possibly htmlspecialchars()) has been run. */ function format_to_edit($content, $richedit = false) { $content = apply_filters('format_to_edit', $content); if (! $richedit ) $content = htmlspecialchars($content); return $content; } /** * Holder for the 'format_to_post' filter. * * @since 0.71 * * @param string $content The text to pass through the filter. * @return string Text returned from the 'format_to_post' filter. */ function format_to_post($content) { $content = apply_filters('format_to_post', $content); return $content; } /** * Add leading zeros when necessary. * * If you set the threshold to '4' and the number is '10', then you will get * back '0010'. If you set the number to '4' and the number is '5000', then you * will get back '5000'. * * Uses sprintf to append the amount of zeros based on the $threshold parameter * and the size of the number. If the number is large enough, then no zeros will * be appended. * * @since 0.71 * * @param mixed $number Number to append zeros to if not greater than threshold. * @param int $threshold Digit places number needs to be to not have zeros added. * @return string Adds leading zeros to number if needed. */ function zeroise($number, $threshold) { return sprintf('%0'.$threshold.'s', $number); } /** * Adds backslashes before letters and before a number at the start of a string. * * @since 0.71 * * @param string $string Value to which backslashes will be added. * @return string String with backslashes inserted. */ function backslashit($string) { $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string); $string = preg_replace('/([a-z])/i', '\\\\\1', $string); return $string; } /** * Appends a trailing slash. * * Will remove trailing slash if it exists already before adding a trailing * slash. This prevents double slashing a string or path. * * The primary use of this is for paths and thus should be used for paths. It is * not restricted to paths and offers no specific path support. * * @since 1.2.0 * @uses untrailingslashit() Unslashes string if it was slashed already. * * @param string $string What to add the trailing slash to. * @return string String with trailing slash added. */ function trailingslashit($string) { return untrailingslashit($string) . '/'; } /** * Removes trailing slash if it exists. * * The primary use of this is for paths and thus should be used for paths. It is * not restricted to paths and offers no specific path support. * * @since 2.2.0 * * @param string $string What to remove the trailing slash from. * @return string String without the trailing slash. */ function untrailingslashit($string) { return rtrim($string, '/'); } /** * Adds slashes to escape strings. * * Slashes will first be removed if magic_quotes_gpc is set, see {@link * http://www.php.net/magic_quotes} for more details. * * @since 0.71 * * @param string $gpc The string returned from HTTP request data. * @return string Returns a string escaped with slashes. */ function addslashes_gpc($gpc) { global $wpdb; if (get_magic_quotes_gpc()) { $gpc = stripslashes($gpc); } return $wpdb->escape($gpc); } /** * Navigates through an array and removes slashes from the values. * * If an array is passed, the array_map() function causes a callback to pass the * value back to the function. The slashes from this value will removed. * * @since 2.0.0 * * @param array|string $value The array or string to be striped. * @return array|string Stripped array (or string in the callback). */ function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } /** * Navigates through an array and encodes the values to be used in a URL. * * Uses a callback to pass the value of the array back to the function as a * string. * * @since 2.2.0 * * @param array|string $value The array or string to be encoded. * @return array|string $value The encoded array (or string from the callback). */ function urlencode_deep($value) { $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value); return $value; } /** * Converts email addresses characters to HTML entities to block spam bots. * * @since 0.71 * * @param string $emailaddy Email address. * @param int $mailto Optional. Range from 0 to 1. Used for encoding. * @return string Converted email address. */ function antispambot($emailaddy, $mailto=0) { $emailNOSPAMaddy = ''; srand ((float) microtime() * 1000000); for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) { $j = floor(rand(0, 1+$mailto)); if ($j==0) { $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';'; } elseif ($j==1) { $emailNOSPAMaddy .= substr($emailaddy,$i,1); } elseif ($j==2) { $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2); } } $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy); return $emailNOSPAMaddy; } /** * Callback to convert URI match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @access private * * @param array $matches Single Regex Match. * @return string HTML A element with URI address. */ function _make_url_clickable_cb($matches) { $ret = ''; $url = $matches[2]; $url = clean_url($url); if ( empty($url) ) return $matches[0]; // removed trailing [.,;:] from URL if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($url, -1); $url = substr($url, 0, strlen($url)-1); } return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret; } /** * Callback to convert URL match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @access private * * @param array $matches Single Regex Match. * @return string HTML A element with URL address. */ function _make_web_ftp_clickable_cb($matches) { $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; $dest = clean_url($dest); if ( empty($dest) ) return $matches[0]; // removed trailing [,;:] from URL if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($dest, -1); $dest = substr($dest, 0, strlen($dest)-1); } return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>" . $ret; } /** * Callback to convert email address match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @access private * * @param array $matches Single Regex Match. * @return string HTML A element with email address. */ function _make_email_clickable_cb($matches) { $email = $matches[2] . '@' . $matches[3]; return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; } /** * Convert plaintext URI to HTML links. * * Converts URI, www and ftp, and email addresses. Finishes by fixing links * within links. * * @since 0.71 * * @param string $ret Content to convert URIs. * @return string Content with converted URIs. */ function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret); $ret = trim($ret); return $ret; } /** * Adds rel nofollow string to all HTML A elements in content. * * @since 1.5.0 * * @param string $text Content that may contain HTML A elements. * @return string Converted content. */ function wp_rel_nofollow( $text ) { global $wpdb; // This is a pre save filter, so text is already escaped. $text = stripslashes($text); $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); $text = $wpdb->escape($text); return $text; } /** * Callback to used to add rel=nofollow string to HTML A element. * * Will remove already existing rel="nofollow" and rel='nofollow' from the * string to prevent from invalidating (X)HTML. * * @since 2.3.0 * * @param array $matches Single Match * @return string HTML A Element with rel nofollow. */ function wp_rel_nofollow_callback( $matches ) { $text = $matches[1]; $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text); return "<a $text rel=\"nofollow\">"; } /** * Convert text equivalent of smilies to images. * * Will only convert smilies if the option 'use_smilies' is true and the globals * used in the function aren't empty. * * @since 0.71 * @uses $wp_smiliessearch, $wp_smiliesreplace Smiley replacement arrays. * * @param string $text Content to convert smilies from text. * @return string Converted content with text smilies replaced with images. */ function convert_smilies($text) { global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between $stop = count($textarr);// loop stuff for ($i = 0; $i < $stop; $i++) { $content = $textarr[$i]; if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag $content = preg_replace($wp_smiliessearch, $wp_smiliesreplace, $content); } $output .= $content; } } else { // return default text. $output = $text; } return $output; } /** * Checks to see if the text is a valid email address. * * @since 0.71 * * @param string $user_email The email address to be checked. * @return bool Returns true if valid, otherwise false. */ function is_email($user_email) { $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i"; if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) { if (preg_match($chars, $user_email)) { return true; } else { return false; } } else { return false; } } /** * Convert to ASCII from email subjects. * * @since 1.2.0 * @usedby wp_mail() handles charsets in email subjects * * @param string $string Subject line * @return string Converted string to ASCII */ function wp_iso_descrambler($string) { /* this may only work with iso-8859-1, I'm afraid */ if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) { return $string; } else { $subject = str_replace('_', ' ', $matches[2]); $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject); return $subject; } } /** * Returns a date in the GMT equivalent. * * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the * value of the 'gmt_offset' option. * * @since 1.2.0 * * @uses get_option() to retrieve the the value of 'gmt_offset'. * @param string $string The date to be converted. * @return string GMT version of the date provided. */ function get_gmt_from_date($string) { preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600); return $string_gmt; } /** * Converts a GMT date into the correct format for the blog. * * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of * gmt_offset. * * @since 1.2.0 * * @param string $string The date to be converted. * @return string Formatted date relative to the GMT offset. */ function get_date_from_gmt($string) { preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600); return $string_localtime; } /** * Computes an offset in seconds from an iso8601 timezone. * * @since 1.5.0 * * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. * @return int|float The offset in seconds. */ function iso8601_timezone_to_offset($timezone) { // $timezone is either 'Z' or '[+|-]hhmm' if ($timezone == 'Z') { $offset = 0; } else { $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1; $hours = intval(substr($timezone, 1, 2)); $minutes = intval(substr($timezone, 3, 4)) / 60; $offset = $sign * 3600 * ($hours + $minutes); } return $offset; } /** * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. * * @since 1.5.0 * * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}. * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. */ function iso8601_to_datetime($date_string, $timezone = 'user') { $timezone = strtolower($timezone); if ($timezone == 'gmt') { preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits); if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset $offset = iso8601_timezone_to_offset($date_bits[7]); } else { // we don't have a timezone, so we assume user local timezone (not server's!) $offset = 3600 * get_option('gmt_offset'); } $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); $timestamp -= $offset; return gmdate('Y-m-d H:i:s', $timestamp); } else if ($timezone == 'user') { return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string); } } /** * Adds a element attributes to open links in new windows. * * Comment text in popup windows should be filtered through this. Right now it's * a moderately dumb function, ideally it would detect whether a target or rel * attribute was already there and adjust its actions accordingly. * * @since 0.71 * * @param string $text Content to replace links to open in a new window. * @return string Content that has filtered links. */ function popuplinks($text) { $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); return $text; } /** * Strips out all characters that are not allowable in an email. * * @since 1.5.0 * * @param string $email Email address to filter. * @return string Filtered email address. */ function sanitize_email($email) { return preg_replace('/[^a-z0-9+_.@-]/i', '', $email); } /** * Determines the difference between two timestamps. * * The difference is returned in a human readable format such as "1 hour", * "5 mins", "2 days". * * @since 1.5.0 * * @param int $from Unix timestamp from which the difference begins. * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. * @return string Human readable time difference. */ function human_time_diff( $from, $to = '' ) { if ( empty($to) ) $to = time(); $diff = (int) abs($to - $from); if ($diff <= 3600) { $mins = round($diff / 60); if ($mins <= 1) { $mins = 1; } $since = sprintf(__ngettext('%s min', '%s mins', $mins), $mins); } else if (($diff <= 86400) && ($diff > 3600)) { $hours = round($diff / 3600); if ($hours <= 1) { $hours = 1; } $since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours); } elseif ($diff >= 86400) { $days = round($diff / 86400); if ($days <= 1) { $days = 1; } $since = sprintf(__ngettext('%s day', '%s days', $days), $days); } return $since; } /** * Generates an excerpt from the content, if needed. * * The excerpt word amount will be 55 words and if the amount is greater than * that, then the string '[...]' will be appended to the excerpt. If the string * is less than 55 words, then the content will be returned as is. * * @since 1.5.0 * * @param string $text The exerpt. If set to empty an excerpt is generated. * @return string The excerpt. */ function wp_trim_excerpt($text) { if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = apply_filters('excerpt_length', 55); $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words, '[...]'); $text = implode(' ', $words); } } return $text; } /** * Converts named entities into numbered entities. * * @since 1.5.1 * * @param string $text The text within which entities will be converted. * @return string Text with converted entities. */ function ent2ncr($text) { $to_ncr = array( '"' => '"', '&' => '&', '⁄' => '/', '<' => '<', '>' => '>', '|' => '|', ' ' => ' ', '¡' => '¡', '¢' => '¢', '£' => '£', '¤' => '¤', '¥' => '¥', '¦' => '¦', '&brkbar;' => '¦', '§' => '§', '¨' => '¨', '¨' => '¨', '©' => '©', 'ª' => 'ª', '«' => '«', '¬' => '¬', '­' => '­', '®' => '®', '¯' => '¯', '&hibar;' => '¯', '°' => '°', '±' => '±', '²' => '²', '³' => '³', '´' => '´', 'µ' => 'µ', '¶' => '¶', '·' => '·', '¸' => '¸', '¹' => '¹', 'º' => 'º', '»' => '»', '¼' => '¼', '½' => '½', '¾' => '¾', '¿' => '¿', 'À' => 'À', 'Á' => 'Á', 'Â' => 'Â', 'Ã' => 'Ã', 'Ä' => 'Ä', 'Å' => 'Å', 'Æ' => 'Æ', 'Ç' => 'Ç', 'È' => 'È', 'É' => 'É', 'Ê' => 'Ê', 'Ë' => 'Ë', 'Ì' => 'Ì', 'Í' => 'Í', 'Î' => 'Î', 'Ï' => 'Ï', 'Ð' => 'Ð', 'Ñ' => 'Ñ', 'Ò' => 'Ò', 'Ó' => 'Ó', 'Ô' => 'Ô', 'Õ' => 'Õ', 'Ö' => 'Ö', '×' => '×', 'Ø' => 'Ø', 'Ù' => 'Ù', 'Ú' => 'Ú', 'Û' => 'Û', 'Ü' => 'Ü', 'Ý' => 'Ý', 'Þ' => 'Þ', 'ß' => 'ß', 'à' => 'à', 'á' => 'á', 'â' => 'â', 'ã' => 'ã', 'ä' => 'ä', 'å' => 'å', 'æ' => 'æ', 'ç' => 'ç', 'è' => 'è', 'é' => 'é', 'ê' => 'ê', 'ë' => 'ë', 'ì' => 'ì', 'í' => 'í', 'î' => 'î', 'ï' => 'ï', 'ð' => 'ð', 'ñ' => 'ñ', 'ò' => 'ò', 'ó' => 'ó', 'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö', '÷' => '÷', 'ø' => 'ø', 'ù' => 'ù', 'ú' => 'ú', 'û' => 'û', 'ü' => 'ü', 'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ', 'Œ' => 'Œ', 'œ' => 'œ', 'Š' => 'Š', 'š' => 'š', 'Ÿ' => 'Ÿ', 'ƒ' => 'ƒ', 'ˆ' => 'ˆ', '˜' => '˜', 'Α' => 'Α', 'Β' => 'Β', 'Γ' => 'Γ', 'Δ' => 'Δ', 'Ε' => 'Ε', 'Ζ' => 'Ζ', 'Η' => 'Η', 'Θ' => 'Θ', 'Ι' => 'Ι', 'Κ' => 'Κ', 'Λ' => 'Λ', 'Μ' => 'Μ', 'Ν' => 'Ν', 'Ξ' => 'Ξ', 'Ο' => 'Ο', 'Π' => 'Π', 'Ρ' => 'Ρ', 'Σ' => 'Σ', 'Τ' => 'Τ', 'Υ' => 'Υ', 'Φ' => 'Φ', 'Χ' => 'Χ', 'Ψ' => 'Ψ', 'Ω' => 'Ω', 'α' => 'α', 'β' => 'β', 'γ' => 'γ', 'δ' => 'δ', 'ε' => 'ε', 'ζ' => 'ζ', 'η' => 'η', 'θ' => 'θ', 'ι' => 'ι', 'κ' => 'κ', 'λ' => 'λ', 'μ' => 'μ', 'ν' => 'ν', 'ξ' => 'ξ', 'ο' => 'ο', 'π' => 'π', 'ρ' => 'ρ', 'ς' => 'ς', 'σ' => 'σ', 'τ' => 'τ', 'υ' => 'υ', 'φ' => 'φ', 'χ' => 'χ', 'ψ' => 'ψ', 'ω' => 'ω', 'ϑ' => 'ϑ', 'ϒ' => 'ϒ', 'ϖ' => 'ϖ', ' ' => ' ', ' ' => ' ', ' ' => ' ', '‌' => '‌', '‍' => '‍', '‎' => '‎', '‏' => '‏', '–' => '–', '—' => '—', '‘' => '‘', '’' => '’', '‚' => '‚', '“' => '“', '”' => '”', '„' => '„', '†' => '†', '‡' => '‡', '•' => '•', '…' => '…', '‰' => '‰', '′' => '′', '″' => '″', '‹' => '‹', '›' => '›', '‾' => '‾', '⁄' => '⁄', '€' => '€', 'ℑ' => 'ℑ', '℘' => '℘', 'ℜ' => 'ℜ', '™' => '™', 'ℵ' => 'ℵ', '↵' => '↵', '⇐' => '⇐', '⇑' => '⇑', '⇒' => '⇒', '⇓' => '⇓', '⇔' => '⇔', '∀' => '∀', '∂' => '∂', '∃' => '∃', '∅' => '∅', '∇' => '∇', '∈' => '∈', '∉' => '∉', '∋' => '∋', '∏' => '∏', '∑' => '∑', '−' => '−', '∗' => '∗', '√' => '√', '∝' => '∝', '∞' => '∞', '∠' => '∠', '∧' => '∧', '∨' => '∨', '∩' => '∩', '∪' => '∪', '∫' => '∫', '∴' => '∴', '∼' => '∼', '≅' => '≅', '≈' => '≈', '≠' => '≠', '≡' => '≡', '≤' => '≤', '≥' => '≥', '⊂' => '⊂', '⊃' => '⊃', '⊄' => '⊄', '⊆' => '⊆', '⊇' => '⊇', '⊕' => '⊕', '⊗' => '⊗', '⊥' => '⊥', '⋅' => '⋅', '⌈' => '⌈', '⌉' => '⌉', '⌊' => '⌊', '⌋' => '⌋', '⟨' => '〈', '⟩' => '〉', '←' => '←', '↑' => '↑', '→' => '→', '↓' => '↓', '↔' => '↔', '◊' => '◊', '♠' => '♠', '♣' => '♣', '♥' => '♥', '♦' => '♦' ); return str_replace( array_keys($to_ncr), array_values($to_ncr), $text ); } /** * Formats text for the rich text editor. * * The filter 'richedit_pre' is applied here. If $text is empty the filter will * be applied to an empty string. * * @since 2.0.0 * * @param string $text The text to be formatted. * @return string The formatted text after filter is applied. */ function wp_richedit_pre($text) { // Filtering a blank results in an annoying <br />\n if ( empty($text) ) return apply_filters('richedit_pre', ''); $output = convert_chars($text); $output = wpautop($output); $output = htmlspecialchars($output, ENT_NOQUOTES); return apply_filters('richedit_pre', $output); } /** * Formats text for the HTML editor. * * Unless $output is empty it will pass through htmlspecialchars before the * 'htmledit_pre' filter is applied. * * @since 2.5.0 * * @param string $output The text to be formatted. * @return string Formatted text after filter applied. */ function wp_htmledit_pre($output) { if ( !empty($output) ) $output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > & return apply_filters('htmledit_pre', $output); } /** * Checks and cleans a URL. * * A number of characters are removed from the URL. If the URL is for displaying * (the default behaviour) amperstands are also replaced. The 'clean_url' filter * is applied to the returned cleaned URL. * * @since 1.2.0 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set * via $protocols or the common ones set in the function. * * @param string $url The URL to be cleaned. * @param array $protocols Optional. An array of acceptable protocols. * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set. * @param string $context Optional. How the URL will be used. Default is 'display'. * @return string The cleaned $url after the 'cleaned_url' filter is applied. */ function clean_url( $url, $protocols = null, $context = 'display' ) { $original_url = $url; if ('' == $url) return $url; $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$*\'()\\x80-\\xff]|i', '', $url); $strip = array('%0d', '%0a'); $url = str_replace($strip, '', $url); $url = str_replace(';//', '://', $url); /* If the URL doesn't appear to contain a scheme, we * presume it needs http:// appended (unless a relative * link starting with / or a php file). */ if ( strpos($url, ':') === false && substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) $url = 'http://' . $url; // Replace ampersands and single quotes only when displaying. if ( 'display' == $context ) { $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); $url = str_replace( "'", ''', $url ); } if ( !is_array($protocols) ) $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) return ''; return apply_filters('clean_url', $url, $original_url, $context); } /** * Performs clean_url() for database usage. * * @see clean_url() * * @since 2.3.1 * * @param string $url The URL to be cleaned. * @param array $protocols An array of acceptable protocols. * @return string The cleaned URL. */ function sanitize_url( $url, $protocols = null ) { return clean_url( $url, $protocols, 'db' ); } /** * Convert entities, while preserving already-encoded entities. * * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes. * * @since 1.2.2 * * @param string $myHTML The text to be converted. * @return string Converted text. */ function htmlentities2($myHTML) { $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); $translation_table[chr(38)] = '&'; return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) ); } /** * Escape single quotes, specialchar double quotes, and fix line endings. * * The filter 'js_escape' is also applied here. * * @since 2.0.4 * * @param string $text The text to be escaped. * @return string Escaped text. */ function js_escape($text) { $safe_text = wp_check_invalid_utf8( $text ); $safe_text = wp_specialchars( $safe_text, ENT_COMPAT ); $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); $safe_text = preg_replace( "/\r?\n/", "\\n", addslashes( $safe_text ) ); return apply_filters( 'js_escape', $safe_text, $text ); } /** * Escaping for HTML attributes. * * @since 2.0.6 * * @param string $text * @return string */ function attribute_escape( $text ) { $safe_text = wp_check_invalid_utf8( $text ); $safe_text = wp_specialchars( $safe_text, ENT_QUOTES ); return apply_filters( 'attribute_escape', $safe_text, $text ); } /** * Escape a HTML tag name. * * @since 2.5.0 * * @param string $tag_name * @return string */ function tag_escape($tag_name) { $safe_tag = strtolower( preg_replace('/[^a-zA-Z_:]/', '', $tag_name) ); return apply_filters('tag_escape', $safe_tag, $tag_name); } /** * Escapes text for SQL LIKE special characters % and _. * * @since 2.5.0 * * @param string $text The text to be escaped. * @return string text, safe for inclusion in LIKE query. */ function like_escape($text) { return str_replace(array("%", "_"), array("\\%", "\\_"), $text); } /** * Convert full URL paths to absolute paths. * * Removes the http or https protocols and the domain. Keeps the path '/' at the * beginning, so it isn't a true relative link, but from the web root base. * * @since 2.1.0 * * @param string $link Full URL path. * @return string Absolute path. */ function wp_make_link_relative( $link ) { return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link ); } /** * Sanitises various option values based on the nature of the option. * * This is basically a switch statement which will pass $value through a number * of functions depending on the $option. * * @since 2.0.5 * * @param string $option The name of the option. * @param string $value The unsanitised value. * @return string Sanitized value. */ function sanitize_option($option, $value) { switch ($option) { case 'admin_email': $value = sanitize_email($value); break; case 'thumbnail_size_w': case 'thumbnail_size_h': case 'medium_size_w': case 'medium_size_h': case 'large_size_w': case 'large_size_h': case 'default_post_edit_rows': case 'mailserver_port': case 'comment_max_links': case 'page_on_front': case 'rss_excerpt_length': case 'default_category': case 'default_email_category': case 'default_link_category': case 'close_comments_days_old': case 'comments_per_page': case 'thread_comments_depth': $value = abs((int) $value); break; case 'posts_per_page': case 'posts_per_rss': $value = (int) $value; if ( empty($value) ) $value = 1; if ( $value < -1 ) $value = abs($value); break; case 'default_ping_status': case 'default_comment_status': // Options that if not there have 0 value but need to be something like "closed" if ( $value == '0' || $value == '') $value = 'closed'; break; case 'blogdescription': case 'blogname': $value = addslashes($value); $value = wp_filter_post_kses( $value ); // calls stripslashes then addslashes $value = stripslashes($value); $value = wp_specialchars( $value ); break; case 'blog_charset': $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes break; case 'date_format': case 'time_format': case 'mailserver_url': case 'mailserver_login': case 'mailserver_pass': case 'ping_sites': case 'upload_path': $value = strip_tags($value); $value = addslashes($value); $value = wp_filter_kses($value); // calls stripslashes then addslashes $value = stripslashes($value); break; case 'gmt_offset': $value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes break; case 'siteurl': case 'home': $value = stripslashes($value); $value = clean_url($value); break; default : $value = apply_filters("sanitize_option_{$option}", $value, $option); break; } return $value; } /** * Parses a string into variables to be stored in an array. * * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on. * * @since 2.2.1 * @uses apply_filters() for the 'wp_parse_str' filter. * * @param string $string The string to be parsed. * @param array $array Variables will be stored in this array. */ function wp_parse_str( $string, &$array ) { parse_str( $string, $array ); if ( get_magic_quotes_gpc() ) $array = stripslashes_deep( $array ); $array = apply_filters( 'wp_parse_str', $array ); } /** * Convert lone less than signs. * * KSES already converts lone greater than signs. * * @uses wp_pre_kses_less_than_callback in the callback function. * @since 2.3.0 * * @param string $text Text to be converted. * @return string Converted text. */ function wp_pre_kses_less_than( $text ) { return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text); } /** * Callback function used by preg_replace. * * @uses wp_specialchars to format the $matches text. * @since 2.3.0 * * @param array $matches Populated by matches to preg_replace. * @return string The text returned after wp_specialchars if needed. */ function wp_pre_kses_less_than_callback( $matches ) { if ( false === strpos($matches[0], '>') ) return wp_specialchars($matches[0]); return $matches[0]; } /** * WordPress implementation of PHP sprintf() with filters. * * @since 2.5.0 * @link http://www.php.net/sprintf * * @param string $pattern The string which formatted args are inserted. * @param mixed $args,... Arguments to be formatted into the $pattern string. * @return string The formatted string. */ function wp_sprintf( $pattern ) { $args = func_get_args( ); $len = strlen($pattern); $start = 0; $result = ''; $arg_index = 0; while ( $len > $start ) { // Last character: append and break if ( strlen($pattern) - 1 == $start ) { $result .= substr($pattern, -1); break; } // Literal %: append and continue if ( substr($pattern, $start, 2) == '%%' ) { $start += 2; $result .= '%'; continue; } // Get fragment before next % $end = strpos($pattern, '%', $start + 1); if ( false === $end ) $end = $len; $fragment = substr($pattern, $start, $end - $start); // Fragment has a specifier if ( $pattern{$start} == '%' ) { // Find numbered arguments or take the next one in order if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; $fragment = str_replace("%{$matches[1]}$", '%', $fragment); } else { ++$arg_index; $arg = isset($args[$arg_index]) ? $args[$arg_index] : ''; } // Apply filters OR sprintf $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); if ( $_fragment != $fragment ) $fragment = $_fragment; else $fragment = sprintf($fragment, strval($arg) ); } // Append to result and move to next fragment $result .= $fragment; $start = $end; } return $result; } /** * Localize list items before the rest of the content. * * The '%l' must be at the first characters can then contain the rest of the * content. The list items will have ', ', ', and', and ' and ' added depending * on the amount of list items in the $args parameter. * * @since 2.5.0 * * @param string $pattern Content containing '%l' at the beginning. * @param array $args List items to prepend to the content and replace '%l'. * @return string Localized list items and rest of the content. */ function wp_sprintf_l($pattern, $args) { // Not a match if ( substr($pattern, 0, 2) != '%l' ) return $pattern; // Nothing to work with if ( empty($args) ) return ''; // Translate and filter the delimiter set (avoid ampersands and entities here) $l = apply_filters('wp_sprintf_l', array( 'between' => _c(', |between list items'), 'between_last_two' => _c(', and |between last two list items'), 'between_only_two' => _c(' and |between only two list items'), )); $args = (array) $args; $result = array_shift($args); if ( count($args) == 1 ) $result .= $l['between_only_two'] . array_shift($args); // Loop when more than two args $i = count($args); while ( $i ) { $arg = array_shift($args); $i--; if ( $i == 1 ) $result .= $l['between_last_two'] . $arg; else $result .= $l['between'] . $arg; } return $result . substr($pattern, 2); } /** * Safely extracts not more than the first $count characters from html string. * * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* * be counted as one character. For example & will be counted as 4, < as * 3, etc. * * @since 2.5.0 * * @param integer $str String to get the excerpt from. * @param integer $count Maximum number of characters to take. * @return string The excerpt. */ function wp_html_excerpt( $str, $count ) { $str = strip_tags( $str ); $str = mb_strcut( $str, 0, $count ); // remove part of an entity at the end $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str ); return $str; } /** * Add a Base url to relative links in passed content. * * By default it supports the 'src' and 'href' attributes. However this can be * changed via the 3rd param. * * @since 2.7.0 * * @param string $content String to search for links in. * @param string $base The base URL to prefix to links. * @param array $attrs The attributes which should be processed. * @return string The processed content. */ function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { $attrs = implode('|', (array)$attrs); return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", create_function('$m', 'return _links_add_base($m, "' . $base . '");'), $content); } /** * Callback to add a base url to relative links in passed content. * * @since 2.7.0 * @access private * * @param string $m The matched link. * @param string $base The base URL to prefix to links. * @return string The processed link. */ function _links_add_base($m, $base) { //1 = attribute name 2 = quotation mark 3 = URL return $m[1] . '=' . $m[2] . (strpos($m[3], 'http://') === false ? path_join($base, $m[3]) : $m[3]) . $m[2]; } /** * Adds a Target attribute to all links in passed content. * * This function by default only applies to <a> tags, however this can be * modified by the 3rd param. * * <b>NOTE:</b> Any current target attributed will be striped and replaced. * * @since 2.7.0 * * @param string $content String to search for links in. * @param string $target The Target to add to the links. * @param array $tags An array of tags to apply to. * @return string The processed content. */ function links_add_target( $content, $target = '_blank', $tags = array('a') ) { $tags = implode('|', (array)$tags); return preg_replace_callback("!<($tags)(.+?)>!i", create_function('$m', 'return _links_add_target($m, "' . $target . '");'), $content); } /** * Callback to add a target attribute to all links in passed content. * * @since 2.7.0 * @access private * * @param string $m The matched link. * @param string $target The Target to add to the links. * @return string The processed link. */ function _links_add_target( $m, $target ) { $tag = $m[1]; $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]); return '<' . $tag . $link . ' target="' . $target . '">'; } // normalize EOL characters and strip duplicate whitespace function normalize_whitespace( $str ) { $str = trim($str); $str = str_replace("\r", "\n", $str); $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); return $str; } ?> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/plugin.php�����������������������������������������������������������������0000644�0001033�0000041�00000056063�11107610233�017555� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * The plugin API is located in this file, which allows for creating actions * and filters and hooking functions, and methods. The functions or methods will * then be run when the action or filter is called. * * The API callback examples reference functions, but can be methods of classes. * To hook methods, you'll need to pass an array one of two ways. * * Any of the syntaxes explained in the PHP documentation for the * {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'} * type are valid. * * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for * more information and examples on how to use a lot of these functions. * * @package WordPress * @subpackage Plugin * @since 1.5 */ /** * Hooks a function or method to a specific filter action. * * Filters are the hooks that WordPress launches to modify text of various types * before adding it to the database or sending it to the browser screen. Plugins * can specify that one or more of its PHP functions is executed to * modify specific types of text at these times, using the Filter API. * * To use the API, the following code should be used to bind a callback to the * filter. * * <code> * function example_hook($example) { echo $example; } * add_filter('example_filter', 'example_hook'); * </code> * * In WordPress 1.5.1+, hooked functions can take extra arguments that are set * when the matching do_action() or apply_filters() call is run. The * $accepted_args allow for calling functions only when the number of args * match. Hooked functions can take extra arguments that are set when the * matching do_action() or apply_filters() call is run. For example, the action * comment_id_not_found will pass any functions that hook onto it the ID of the * requested comment. * * <strong>Note:</strong> the function will return true no matter if the * function was hooked fails or not. There are no checks for whether the * function exists beforehand and no checks to whether the <tt>$function_to_add * is even a string. It is up to you to take care and this is done for * optimization purposes, so everything is as quick as possible. * * @package WordPress * @subpackage Plugin * @since 0.71 * @global array $wp_filter Stores all of the filters added in the form of * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process. * * @param string $tag The name of the filter to hook the $function_to_add to. * @param callback $function_to_add The name of the function to be called when the filter is applied. * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. * @param int $accepted_args optional. The number of arguments the function accept (default 1). * @return boolean true */ function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { global $wp_filter, $merged_filters; $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); unset( $merged_filters[ $tag ] ); return true; } /** * Check if any filter has been registered for a hook. * * @package WordPress * @subpackage Plugin * @since 2.5 * @global array $wp_filter Stores all of the filters * * @param string $tag The name of the filter hook. * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. * @return int|boolean Optionally returns the priority on that hook for the specified function. */ function has_filter($tag, $function_to_check = false) { global $wp_filter; $has = !empty($wp_filter[$tag]); if ( false === $function_to_check || false == $has ) return $has; if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) ) return false; foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) { if ( isset($wp_filter[$tag][$priority][$idx]) ) return $priority; } return false; } /** * Call the functions added to a filter hook. * * The callback functions attached to filter hook $tag are invoked by calling * this function. This function can be used to create a new filter hook by * simply calling this function with the name of the new hook specified using * the $tag parameter. * * The function allows for additional arguments to be added and passed to hooks. * <code> * function example_hook($string, $arg1, $arg2) * { * //Do stuff * return $string; * } * $value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2'); * </code> * * @package WordPress * @subpackage Plugin * @since 0.71 * @global array $wp_filter Stores all of the filters * @global array $merged_filters Merges the filter hooks using this function. * @global array $wp_current_filter stores the list of current filters with the current one last * * @param string $tag The name of the filter hook. * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on. * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>. * @return mixed The filtered value after all hooked functions are applied to it. */ function apply_filters($tag, $value) { global $wp_filter, $merged_filters, $wp_current_filter; $args = array(); $wp_current_filter[] = $tag; // Do 'all' actions first if ( isset($wp_filter['all']) ) { $args = func_get_args(); _wp_call_all_hook($args); } if ( !isset($wp_filter[$tag]) ) { array_pop($wp_current_filter); return $value; } // Sort if ( !isset( $merged_filters[ $tag ] ) ) { ksort($wp_filter[$tag]); $merged_filters[ $tag ] = true; } reset( $wp_filter[ $tag ] ); if ( empty($args) ) $args = func_get_args(); do { foreach( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ){ $args[1] = $value; $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); } } while ( next($wp_filter[$tag]) !== false ); array_pop( $wp_current_filter ); return $value; } /** * Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * * To remove a hook, the $function_to_remove and $priority arguments must match * when the hook was added. This goes for both filters and actions. No warning * will be given on removal failure. * * @package WordPress * @subpackage Plugin * @since 1.2 * * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional. The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). * @return boolean Whether the function existed before it was removed. */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); if ( true === $r) { unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); if ( empty($GLOBALS['wp_filter'][$tag][$priority]) ) unset($GLOBALS['wp_filter'][$tag][$priority]); unset($GLOBALS['merged_filters'][$tag]); } return $r; } /** * Remove all of the hooks from a filter. * * @since 2.7 * * @param string $tag The filter to remove hooks from. * @param int $priority The priority number to remove. * @return bool True when finished. */ function remove_all_filters($tag, $priority = false) { global $wp_filter, $merged_filters; if( isset($wp_filter[$tag]) ) { if( false !== $priority && isset($$wp_filter[$tag][$priority]) ) unset($wp_filter[$tag][$priority]); else unset($wp_filter[$tag]); } if( isset($merged_filters[$tag]) ) unset($merged_filters[$tag]); return true; } /** * Retrieve the name of the current filter or action. * * @package WordPress * @subpackage Plugin * @since 2.5 * * @return string Hook name of the current filter or action. */ function current_filter() { global $wp_current_filter; return end( $wp_current_filter ); } /** * Hooks a function on to a specific action. * * Actions are the hooks that the WordPress core launches at specific points * during execution, or when specific events occur. Plugins can specify that * one or more of its PHP functions are executed at these points, using the * Action API. * * @uses add_filter() Adds an action. Parameter list and functionality are the same. * * @package WordPress * @subpackage Plugin * @since 1.2 * * @param string $tag The name of the action to which the $function_to_add is hooked. * @param callback $function_to_add The name of the function you wish to be called. * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. * @param int $accepted_args optional. The number of arguments the function accept (default 1). */ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return add_filter($tag, $function_to_add, $priority, $accepted_args); } /** * Execute functions hooked on a specific action hook. * * This function invokes all functions attached to action hook $tag. It is * possible to create new action hooks by simply calling this function, * specifying the name of the new hook using the <tt>$tag</tt> parameter. * * You can pass extra arguments to the hooks, much like you can with * apply_filters(). * * @see apply_filters() This function works similar with the exception that * nothing is returned and only the functions or methods are called. * * @package WordPress * @subpackage Plugin * @since 1.2 * @global array $wp_filter Stores all of the filters * @global array $wp_actions Increments the amount of times action was triggered. * * @param string $tag The name of the action to be executed. * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. * @return null Will return null if $tag does not exist in $wp_filter array */ function do_action($tag, $arg = '') { global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; if ( is_array($wp_actions) ) $wp_actions[] = $tag; else $wp_actions = array($tag); $wp_current_filter[] = $tag; // Do 'all' actions first if ( isset($wp_filter['all']) ) { $all_args = func_get_args(); _wp_call_all_hook($all_args); } if ( !isset($wp_filter[$tag]) ) { array_pop($wp_current_filter); return; } $args = array(); if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this) $args[] =& $arg[0]; else $args[] = $arg; for ( $a = 2; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); // Sort if ( !isset( $merged_filters[ $tag ] ) ) { ksort($wp_filter[$tag]); $merged_filters[ $tag ] = true; } reset( $wp_filter[ $tag ] ); do { foreach ( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } while ( next($wp_filter[$tag]) !== false ); array_pop($wp_current_filter); } /** * Retrieve the number times an action is fired. * * @package WordPress * @subpackage Plugin * @since 2.1 * @global array $wp_actions Increments the amount of times action was triggered. * * @param string $tag The name of the action hook. * @return int The number of times action hook <tt>$tag</tt> is fired */ function did_action($tag) { global $wp_actions; if ( empty($wp_actions) ) return 0; return count(array_keys($wp_actions, $tag)); } /** * Execute functions hooked on a specific action hook, specifying arguments in an array. * * @see do_action() This function is identical, but the arguments passed to the * functions hooked to <tt>$tag</tt> are supplied using an array. * * @package WordPress * @subpackage Plugin * @since 2.1 * @global array $wp_filter Stores all of the filters * @global array $wp_actions Increments the amount of times action was triggered. * * @param string $tag The name of the action to be executed. * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> * @return null Will return null if $tag does not exist in $wp_filter array */ function do_action_ref_array($tag, $args) { global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; if ( !is_array($wp_actions) ) $wp_actions = array($tag); else $wp_actions[] = $tag; $wp_current_filter[] = $tag; // Do 'all' actions first if ( isset($wp_filter['all']) ) { $all_args = func_get_args(); _wp_call_all_hook($all_args); } if ( !isset($wp_filter[$tag]) ) { array_pop($wp_current_filter); return; } // Sort if ( !isset( $merged_filters[ $tag ] ) ) { ksort($wp_filter[$tag]); $merged_filters[ $tag ] = true; } reset( $wp_filter[ $tag ] ); do { foreach( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } while ( next($wp_filter[$tag]) !== false ); array_pop($wp_current_filter); } /** * Check if any action has been registered for a hook. * * @package WordPress * @subpackage Plugin * @since 2.5 * @see has_filter() has_action() is an alias of has_filter(). * * @param string $tag The name of the action hook. * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. * @return int|boolean Optionally returns the priority on that hook for the specified function. */ function has_action($tag, $function_to_check = false) { return has_filter($tag, $function_to_check); } /** * Removes a function from a specified action hook. * * This function removes a function attached to a specified action hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * * @package WordPress * @subpackage Plugin * @since 1.2 * * @param string $tag The action hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). * @return boolean Whether the function is removed. */ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { return remove_filter($tag, $function_to_remove, $priority, $accepted_args); } /** * Remove all of the hooks from an action. * * @since 2.7 * * @param string $tag The action to remove hooks from. * @param int $priority The priority number to remove them from. * @return bool True when finished. */ function remove_all_actions($tag, $priority = false) { return remove_all_filters($tag, $priority); } // // Functions for handling plugins. // /** * Gets the basename of a plugin. * * This method extracts the name of a plugin from its filename. * * @package WordPress * @subpackage Plugin * @since 1.5 * * @access private * * @param string $file The filename of plugin. * @return string The name of a plugin. * @uses WP_PLUGIN_DIR */ function plugin_basename($file) { $file = str_replace('\\','/',$file); // sanitize for Win32 installs $file = preg_replace('|/+|','/', $file); // remove any duplicate slash $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir return $file; } /** * Set the activation hook for a plugin. * * When a plugin is activated, the action 'activate_PLUGINNAME' hook is * activated. In the name of this hook, PLUGINNAME is replaced with the name of * the plugin, including the optional subdirectory. For example, when the plugin * is located in wp-content/plugin/sampleplugin/sample.php, then the name of * this hook will become 'activate_sampleplugin/sample.php'. When the plugin * consists of only one file and is (as by default) located at * wp-content/plugin/sample.php the name of this hook will be * 'activate_sample.php'. * * @package WordPress * @subpackage Plugin * @since 2.0 * * @access private * * @param string $file The filename of the plugin including the path. * @param callback $function the function hooked to the 'activate_PLUGIN' action. */ function register_activation_hook($file, $function) { $file = plugin_basename($file); add_action('activate_' . $file, $function); } /** * Set the deactivation hook for a plugin. * * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is * deactivated. In the name of this hook, PLUGINNAME is replaced with the name * of the plugin, including the optional subdirectory. For example, when the * plugin is located in wp-content/plugin/sampleplugin/sample.php, then * the name of this hook will become 'activate_sampleplugin/sample.php'. * * When the plugin consists of only one file and is (as by default) located at * wp-content/plugin/sample.php the name of this hook will be * 'activate_sample.php'. * * @package WordPress * @subpackage Plugin * @since 2.0 * * @access private * * @param string $file The filename of the plugin including the path. * @param callback $function the function hooked to the 'activate_PLUGIN' action. */ function register_deactivation_hook($file, $function) { $file = plugin_basename($file); add_action('deactivate_' . $file, $function); } /** * Set the uninstallation hook for a plugin. * * Registers the uninstall hook that will be called when the user clicks on the * uninstall link that calls for the plugin to uninstall itself. The link won't * be active unless the plugin hooks into the action. * * The plugin should not run arbitrary code outside of functions, when * registering the uninstall hook. In order to run using the hook, the plugin * will have to be included, which means that any code laying outside of a * function will be run during the uninstall process. The plugin should not * hinder the uninstall process. * * If the plugin can not be written without running code within the plugin, then * the plugin should create a file named 'uninstall.php' in the base plugin * folder. This file will be called, if it exists, during the uninstall process * bypassing the uninstall hook. The plugin, when using the 'uninstall.php' * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before * executing. * * @since 2.7 * * @param string $file * @param callback $callback The callback to run when the hook is called. */ function register_uninstall_hook($file, $callback) { // The option should not be autoloaded, because it is not needed in most // cases. Emphasis should be put on using the 'uninstall.php' way of // uninstalling the plugin. $uninstallable_plugins = (array) get_option('uninstall_plugins'); $uninstallable_plugins[plugin_basename($file)] = $callback; update_option('uninstall_plugins', $uninstallable_plugins); } /** * Calls the 'all' hook, which will process the functions hooked into it. * * The 'all' hook passes all of the arguments or parameters that were used for * the hook, which this function was called for. * * This function is used internally for apply_filters(), do_action(), and * do_action_ref_array() and is not meant to be used from outside those * functions. This function does not check for the existence of the all hook, so * it will fail unless the all hook exists prior to this function call. * * @package WordPress * @subpackage Plugin * @since 2.5 * @access private * * @uses $wp_filter Used to process all of the functions in the 'all' hook * * @param array $args The collected parameters from the hook that was called. * @param string $hook Optional. The hook name that was used to call the 'all' hook. */ function _wp_call_all_hook($args) { global $wp_filter; reset( $wp_filter['all'] ); do { foreach( (array) current($wp_filter['all']) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], $args); } while ( next($wp_filter['all']) !== false ); } /** * Build Unique ID for storage and retrieval. * * The old way to serialize the callback caused issues and this function is the * solution. It works by checking for objects and creating an a new property in * the class to keep track of the object and new objects of the same class that * need to be added. * * It also allows for the removal of actions and filters for objects after they * change class properties. It is possible to include the property $wp_filter_id * in your class and set it to "null" or a number to bypass the workaround. * However this will prevent you from adding new classes and any new classes * will overwrite the previous hook by the same class. * * Functions and static method callbacks are just returned as strings and * shouldn't have any speed penalty. * * @package WordPress * @subpackage Plugin * @access private * @since 2.2.3 * @link http://trac.wordpress.org/ticket/3875 * * @global array $wp_filter Storage for all of the filters and actions * @param string $tag Used in counting how many hooks were applied * @param string|array $function Used for creating unique id * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. * @param string $type filter or action * @return string Unique ID for usage as array key */ function _wp_filter_build_unique_id($tag, $function, $priority) { global $wp_filter; // If function then just skip all of the tests and not overwrite the following. if ( is_string($function) ) return $function; // Object Class Calling else if (is_object($function[0]) ) { $obj_idx = get_class($function[0]).$function[1]; if ( !isset($function[0]->wp_filter_id) ) { if ( false === $priority ) return false; $count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0; $function[0]->wp_filter_id = $count; $obj_idx .= $count; unset($count); } else $obj_idx .= $function[0]->wp_filter_id; return $obj_idx; } // Static Calling else if ( is_string($function[0]) ) return $function[0].$function[1]; } ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/vars.php�������������������������������������������������������������������0000644�0001033�0000041�00000005324�11115225366�017234� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * Creates common globals for the rest of WordPress * * Sets $pagenow global which is the current page. Checks * for the browser to set which one is currently being used. * * Detects which user environment WordPress is being used on. * Only attempts to check for Apache and IIS. Two web servers * with known permalink capability. * * @package WordPress */ // On which page are we ? if ( is_admin() ) { // wp-admin pages are checked more carefully preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); $pagenow = $self_matches[1]; $pagenow = preg_replace('#\?.*?$#', '', $pagenow); if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { $pagenow = 'index.php'; } else { preg_match('#(.*?)(/|$)#', $pagenow, $self_matches); $pagenow = strtolower($self_matches[1]); if ( '.php' !== substr($pagenow, -4, 4) ) $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) } } else { if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) ) $pagenow = strtolower($self_matches[1]); else $pagenow = 'index.php'; } // Simple browser detection $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) { $is_lynx = true; } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) { $is_chrome = true; } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) { $is_safari = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) { $is_gecko = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) { $is_winIE = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { $is_macIE = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { $is_opera = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) { $is_NS4 = true; } if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false ) $is_iphone = true; $is_IE = ( $is_macIE || $is_winIE ); // Server detection /** * Whether the server software is Apache or something else * @global bool $is_apache */ $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false; /** * Whether the server software is IIS or something else * @global bool $is_IIS */ $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false; ?>������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/script-loader.php����������������������������������������������������������0000644�0001033�0000041�00000051245�11136601033�021024� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * WordPress scripts and styles default loader. * * Most of the functionality that existed here was moved to * {@link http://backpress.automattic.com/ BackPress}. WordPress themes and * plugins will only be concerned about the filters and actions set in this * file. * * @package WordPress */ /** BackPress: WordPress Dependencies Class */ require( ABSPATH . WPINC . '/class.wp-dependencies.php' ); /** BackPress: WordPress Scripts Class */ require( ABSPATH . WPINC . '/class.wp-scripts.php' ); /** BackPress: WordPress Scripts Functions */ require( ABSPATH . WPINC . '/functions.wp-scripts.php' ); /** BackPress: WordPress Styles Class */ require( ABSPATH . WPINC . '/class.wp-styles.php' ); /** BackPress: WordPress Styles Functions */ require( ABSPATH . WPINC . '/functions.wp-styles.php' ); /** * Setup WordPress scripts to load by default for Administration Panels. * * Localizes a few of the scripts. * * @since 2.6.0 * * @param object $scripts WP_Scripts object. */ function wp_default_scripts( &$scripts ) { if (!$guessurl = site_url()) $guessurl = wp_guess_url(); $scripts->base_url = $guessurl; $scripts->default_version = get_bloginfo( 'version' ); $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081210' ); $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' ); $scripts->localize( 'quicktags', 'quicktagsL10n', array( 'quickLinks' => __('(Quick Links)'), 'wordLookup' => __('Enter a word to look up:'), 'dictionaryLookup' => attribute_escape(__('Dictionary lookup')), 'lookup' => attribute_escape(__('lookup')), 'closeAllOpenTags' => attribute_escape(__('Close all open tags')), 'closeTags' => attribute_escape(__('close tags')), 'enterURL' => __('Enter the URL'), 'enterImageURL' => __('Enter the URL of the image'), 'enterImageDescription' => __('Enter a description of the image'), 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};' ) ); $scripts->add( 'colorpicker', '/wp-includes/js/colorpicker.js', array('prototype'), '3517' ); // Modify this version when tinyMCE plugins are changed. function mce_version() { return '20081129'; } add_filter( 'tiny_mce_version', 'mce_version' ); $scripts->add( 'editor', '/wp-admin/js/editor.js', false, mce_version() ); $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); $scripts->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20081210' ); $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 'noPerm' => __('You do not have permission to do that.'), 'broken' => __('An unidentified error has occurred.'), 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' ) ); $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081210' ); $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' ); $scripts->localize( 'wp-lists', 'wpListL10n', array( 'url' => admin_url('admin-ajax.php') ) ); $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.0'); $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.0'); $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.0'); $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.0'); $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.0'); $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.0' ); $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.0'); $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.0'); $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.2.6'); $scripts->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '2.02'); $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.js', array('jquery'), '2.0-4561'); $scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' ); $scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1b'); $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); $scripts->add( 'jquery-hotkeys', '/wp-includes/js/jquery/jquery.hotkeys.js', array('jquery'), '0.0.2' ); $scripts->add( 'jquery-table-hotkeys', '/wp-includes/js/jquery/jquery.table-hotkeys.js', array('jquery', 'jquery-hotkeys'), '20081128' ); $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20090123'); $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.2.0-20081031'); $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.2.0-20081031'); $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.2.0-20081031'); $scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array( 'is_lighttpd_before_150' => is_lighttpd_before_150(), ) ); $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.2.0-20081031'); $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.2.0-20081201'); // these error messages came from the sample swfupload js, they might need changing. $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), 'zero_byte_file' => __('This file is empty. Please try another.'), 'invalid_filetype' => __('This file type is not allowed. Please try another.'), 'default_error' => __('An error occurred in the upload. Please try again later.'), 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), 'upload_limit_exceeded' => __('You may only upload 1 file.'), 'http_error' => __('HTTP error.'), 'upload_failed' => __('Upload failed.'), 'io_error' => __('IO error.'), 'security_error' => __('Security error.'), 'file_cancelled' => __('File cancelled.'), 'upload_stopped' => __('Upload stopped.'), 'dismiss' => __('Dismiss'), 'crunching' => __('Crunching…'), 'deleted' => __('Deleted'), 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' ) ); $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.2' ); $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.2' ); $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.2c' ); $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core'), '1.5.2' ); $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210'); if ( is_admin() ) { $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20081210' ); $scripts->localize( 'ajaxcat', 'catL10n', array( 'add' => attribute_escape(__('Add')), 'how' => __('Separate multiple categories with commas.'), 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};' ) ); $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081210' ); $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20081210' ); $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20081210' ); $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081210' ); $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 'empty' => __('Strength indicator'), 'short' => __('Very weak'), 'bad' => __('Weak'), 'good' => _c('Medium|password strength'), 'strong' => __('Strong'), 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' ) ); $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081210' ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) ) ); $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20081210' ); $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081210' ); $scripts->localize( 'postbox', 'postboxL10n', array( 'requestFile' => admin_url('admin-ajax.php') ) ); $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20081210' ); $scripts->localize( 'slug', 'slugL10n', array( 'requestFile' => admin_url('admin-ajax.php'), 'save' => __('Save'), 'cancel' => __('Cancel'), 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' ) ); $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081210' ); $scripts->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), 'addTag' => attribute_escape(__('Add new tag')), 'separate' => __('Separate tags with commas'), 'cancel' => __('Cancel'), 'edit' => __('Edit'), 'publishOn' => __('Publish on:'), 'publishOnFuture' => __('Schedule for:'), 'publishOnPast' => __('Published on:'), 'showcomm' => __('Show more comments'), 'endcomm' => __('No more comments found.'), 'publish' => __('Publish'), 'schedule' => __('Schedule'), 'update' => __('Update Post'), 'savePending' => __('Save as Pending'), 'saveDraft' => __('Save Draft'), 'private' => __('Private'), 'public' => __('Public'), 'publicSticky' => __('Public, Sticky'), 'password' => __('Password Protected'), 'privatelyPublished' => __('Privately Published'), 'published' => __('Published'), 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' ) ); $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081210' ); $scripts->localize( 'page', 'postL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'), 'publishOn' => __('Publish on:'), 'publishOnFuture' => __('Schedule for:'), 'publishOnPast' => __('Published on:'), 'showcomm' => __('Show more comments'), 'endcomm' => __('No more comments found.'), 'publish' => __('Publish'), 'schedule' => __('Schedule'), 'update' => __('Update Page'), 'savePending' => __('Save as Pending'), 'saveDraft' => __('Save Draft'), 'private' => __('Private'), 'public' => __('Public'), 'password' => __('Password Protected'), 'privatelyPublished' => __('Privately Published'), 'published' => __('Published'), 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' ) ); $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081210' ); $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081210' ); $scripts->localize( 'comment', 'commentL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'), 'submittedOn' => __('Submitted on:'), 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};' ) ); $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081210' ); $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081210' ); $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081210' ); $scripts->localize( 'admin-widgets', 'widgetsL10n', array( 'add' => __('Add'), 'edit' => __('Edit'), 'cancel' => __('Cancel'), 'lameReminder' => __('Remember to click the "Save Changes" button at the bottom of the Current Widgets column after you\'re all done!'), 'lamerReminder' => __("You're about to leave without having saved your changes!"), 'l10n_print_after' => 'try{convertEntities(widgetsL10n);}catch(e){};' )); $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20081210' ); $scripts->localize( 'word-count', 'wordCountL10n', array( 'count' => __('Word count: %d'), 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};' )); $scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20081210' ); $scripts->localize( 'wp-gears', 'wpGearsL10n', array( 'updateCompleted' => __('Update completed.'), 'error' => __('Error:'), 'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};' )); $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' ); $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081210' ); $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.'), 'ntdeltitle' => __('Remove From Bulk Edit'), 'notitle' => __('(no title)'), 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' ) ); $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081210' ); $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.'), 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' ) ); $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20081210' ); $scripts->localize( 'plugin-install', 'plugininstallL10n', array( 'plugin_information' => __('Plugin Information:'), 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};' ) ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081210' ); $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' ); } } /** * Assign default styles to $styles object. * * Nothing is returned, because the $styles parameter is passed by reference. * Meaning that whatever object is passed will be updated without having to * reassign the variable that was passed back to the same value. This saves * memory. * * Adding default styles is not the only task, it also assigns the base_url * property, the default version, and text direction for the object. * * @since 2.6.0 * * @param object $styles */ function wp_default_styles( &$styles ) { // This checks to see if site_url() returns something and if it does not // then it assigns $guess_url to wp_guess_url(). Strange format, but it works. if ( ! $guessurl = site_url() ) $guessurl = wp_guess_url(); $styles->base_url = $guessurl; $styles->default_version = get_bloginfo( 'version' ); $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr'; $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' ); $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081210' ); $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20081210' ); $styles->add_data( 'ie', 'conditional', 'gte IE 6' ); $styles->add( 'colors', true, array(), '20081210' ); // Register "meta" stylesheet for admin colors $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way? $styles->add_data( 'colors-fresh', 'rtl', true ); $styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210'); $styles->add_data( 'colors-classic', 'rtl', true ); $styles->add( 'global', '/wp-admin/css/global.css', array(), '20081210' ); $styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' ); $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' ); $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081210' ); $styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' ); $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css', array(), '20081210' ); $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20081210' ); $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20081210' ); $styles->add( 'login', '/wp-admin/css/login.css', array(), '20081210' ); $styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' ); $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' ); foreach ( $rtl_styles as $rtl_style ) $styles->add_data( $rtl_style, 'rtl', true ); } /** * Reorder JavaScript scripts array to place prototype before jQuery. * * @since 2.3.1 * * @param array $js_array JavaScript scripst array * @return array Reordered array, if needed. */ function wp_prototype_before_jquery( $js_array ) { if ( false === $jquery = array_search( 'jquery', $js_array ) ) return $js_array; if ( false === $prototype = array_search( 'prototype', $js_array ) ) return $js_array; if ( $prototype < $jquery ) return $js_array; unset($js_array[$prototype]); array_splice( $js_array, $jquery, 0, 'prototype' ); return $js_array; } /** * Load localized script just in time for MCE. * * These localizations require information that may not be loaded even by init. * * @since 2.5.0 */ function wp_just_in_time_script_localization() { global $current_user; wp_localize_script( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => AUTOSAVE_INTERVAL, 'previewPageText' => __('Preview this Page'), 'previewPostText' => __('Preview this Post'), 'requestFile' => admin_url('admin-ajax.php'), 'savingText' => __('Saving Draft…'), 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};' ) ); $userid = isset($current_user) ? $current_user->ID : 0; wp_localize_script( 'common', 'userSettings', array( 'url' => SITECOOKIEPATH, 'uid' => $userid, 'time' => time() ) ); } /** * Administration Panel CSS for changing the styles. * * If installing the 'wp-admin/' directory will be replaced with './'. * * The $_wp_admin_css_colors global manages the Administration Panels CSS * stylesheet that is loaded. The option that is set is 'admin_color' and is the * color and key for the array. The value for the color key is an object with * a 'url' parameter that has the URL path to the CSS file. * * The query from $src parameter will be appended to the URL that is given from * the $_wp_admin_css_colors array value URL. * * @since 2.6.0 * @uses $_wp_admin_css_colors * * @param string $src Source URL. * @param string $handle Either 'colors' or 'colors-rtl'. * @return string URL path to CSS stylesheet for Administration Panels. */ function wp_style_loader_src( $src, $handle ) { if ( defined('WP_INSTALLING') ) return preg_replace( '#^wp-admin/#', './', $src ); if ( 'colors' == $handle || 'colors-rtl' == $handle ) { global $_wp_admin_css_colors; $color = get_user_option('admin_color'); if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) $color = 'fresh'; $color = $_wp_admin_css_colors[$color]; $parsed = parse_url( $src ); $url = $color->url; if ( isset($parsed['query']) && $parsed['query'] ) { wp_parse_str( $parsed['query'], $qv ); $url = add_query_arg( $qv, $url ); } return $url; } return $src; } add_action( 'wp_default_scripts', 'wp_default_scripts' ); add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); add_action( 'wp_default_styles', 'wp_default_styles' ); add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/link-template.php����������������������������������������������������������0000644�0001033�0000041�00000122201�11136560161�021017� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * WordPress Link Template Functions * * @package WordPress * @subpackage Template */ /** * Display the permalink for the current post. * * @since 1.2.0 * @uses apply_filters() Calls 'the_permalink' filter on the permalink string. */ function the_permalink() { echo apply_filters('the_permalink', get_permalink()); } /** * Retrieve trailing slash string, if blog set for adding trailing slashes. * * Conditionally adds a trailing slash if the permalink structure has a trailing * slash, strips the trailing slash if not. The string is passed through the * 'user_trailingslashit' filter. Will remove trailing slash from string, if * blog is not set to have them. * * @since 2.2.0 * @uses $wp_rewrite * * @param $string String a URL with or without a trailing slash. * @param $type_of_url String the type of URL being considered (e.g. single, category, etc) for use in the filter. * @return string */ function user_trailingslashit($string, $type_of_url = '') { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes ) $string = trailingslashit($string); else $string = untrailingslashit($string); // Note that $type_of_url can be one of following: // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged $string = apply_filters('user_trailingslashit', $string, $type_of_url); return $string; } /** * Display permalink anchor for current post. * * The permalink mode title will use the post title for the 'a' element 'id' * attribute. The id mode uses 'post-' with the post ID for the 'id' attribute. * * @since 0.71 * * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'. */ function permalink_anchor($mode = 'id') { global $post; switch ( strtolower($mode) ) { case 'title': $title = sanitize_title($post->post_title) . '-' . $post->ID; echo '<a id="'.$title.'"></a>'; break; case 'id': default: echo '<a id="post-' . $post->ID . '"></a>'; break; } } /** * Retrieve full permalink for current post or post ID. * * @since 1.0.0 * * @param int $id Optional. Post ID. * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name. * @return string */ function get_permalink($id = 0, $leavename = false) { $rewritecode = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename? '' : '%pagename%', ); if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) $post = $id; else $post = &get_post($id); if ( empty($post->ID) ) return false; if ( $post->post_type == 'page' ) return get_page_link($post->ID, $leavename); elseif ($post->post_type == 'attachment') return get_attachment_link($post->ID); $permalink = get_option('permalink_structure'); if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) { $unixtime = strtotime($post->post_date); $category = ''; if ( strpos($permalink, '%category%') !== false ) { $cats = get_the_category($post->ID); if ( $cats ) { usort($cats, '_usort_terms_by_ID'); // order by ID $category = $cats[0]->slug; if ( $parent = $cats[0]->parent ) $category = get_category_parents($parent, false, '/', true) . $category; } // show default category in permalinks, without // having to assign it explicitly if ( empty($category) ) { $default_category = get_category( get_option( 'default_category' ) ); $category = is_wp_error( $default_category ) ? '' : $default_category->slug; } } $author = ''; if ( strpos($permalink, '%author%') !== false ) { $authordata = get_userdata($post->post_author); $author = $authordata->user_nicename; } $date = explode(" ",date('Y m d H i s', $unixtime)); $rewritereplace = array( $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name, ); $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); $permalink = user_trailingslashit($permalink, 'single'); return apply_filters('post_link', $permalink, $post, $leavename); } else { // if they're not using the fancy permalink option $permalink = get_option('home') . '/?p=' . $post->ID; return apply_filters('post_link', $permalink, $post, $leavename); } } /** * Retrieve permalink from post ID. * * @since 1.0.0 * * @param int $post_id Optional. Post ID. * @param mixed $deprecated Not used. * @return string */ function post_permalink($post_id = 0, $deprecated = '') { return get_permalink($post_id); } /** * Retrieve the permalink for current page or page ID. * * Respects page_on_front. Use this one. * * @since 1.5.0 * * @param int $id Optional. Post ID. * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name. * @return string */ function get_page_link($id = false, $leavename = false) { global $post; $id = (int) $id; if ( !$id ) $id = (int) $post->ID; if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) $link = get_option('home'); else $link = _get_page_link( $id , $leavename ); return apply_filters('page_link', $link, $id); } /** * Retrieve the page permalink. * * Ignores page_on_front. Internal use only. * * @since 2.1.0 * @access private * * @param int $id Optional. Post ID. * @param bool $leavename Optional. Leave name. * @return string */ function _get_page_link( $id = false, $leavename = false ) { global $post, $wp_rewrite; if ( !$id ) $id = (int) $post->ID; else $post = &get_post($id); $pagestruct = $wp_rewrite->get_page_permastruct(); if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) { $link = get_page_uri($id); $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); $link = get_option('home') . "/$link"; $link = user_trailingslashit($link, 'page'); } else { $link = get_option('home') . "/?page_id=$id"; } return apply_filters( '_get_page_link', $link, $id ); } /** * Retrieve permalink for attachment. * * This can be used in the WordPress Loop or outside of it. * * @since 2.0.0 * * @param int $id Optional. Post ID. * @return string */ function get_attachment_link($id = false) { global $post, $wp_rewrite; $link = false; if (! $id) { $id = (int) $post->ID; } $object = get_post($id); if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) { $parent = get_post($object->post_parent); if ( 'page' == $parent->post_type ) $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front else $parentlink = get_permalink( $object->post_parent ); if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) $name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker else $name = $object->post_name; if (strpos($parentlink, '?') === false) $link = user_trailingslashit( trailingslashit($parentlink) . $name ); } if (! $link ) { $link = get_bloginfo('url') . "/?attachment_id=$id"; } return apply_filters('attachment_link', $link, $id); } /** * Retrieve the permalink for the year archives. * * @since 1.5.0 * * @param int|bool $year False for current year or year for permalink. * @return string */ function get_year_link($year) { global $wp_rewrite; if ( !$year ) $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600)); $yearlink = $wp_rewrite->get_year_permastruct(); if ( !empty($yearlink) ) { $yearlink = str_replace('%year%', $year, $yearlink); return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year); } else { return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); } } /** * Retrieve the permalink for the month archives with year. * * @since 1.0.0 * * @param bool|int $year False for current year. Integer of year. * @param bool|int $month False for current month. Integer of month. * @return string */ function get_month_link($year, $month) { global $wp_rewrite; if ( !$year ) $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600)); if ( !$month ) $month = gmdate('m', time()+(get_option('gmt_offset') * 3600)); $monthlink = $wp_rewrite->get_month_permastruct(); if ( !empty($monthlink) ) { $monthlink = str_replace('%year%', $year, $monthlink); $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month); } else { return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); } } /** * Retrieve the permalink for the day archives with year and month. * * @since 1.0.0 * * @param bool|int $year False for current year. Integer of year. * @param bool|int $month False for current month. Integer of month. * @param bool|int $day False for current day. Integer of day. * @return string */ function get_day_link($year, $month, $day) { global $wp_rewrite; if ( !$year ) $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600)); if ( !$month ) $month = gmdate('m', time()+(get_option('gmt_offset') * 3600)); if ( !$day ) $day = gmdate('j', time()+(get_option('gmt_offset') * 3600)); $daylink = $wp_rewrite->get_day_permastruct(); if ( !empty($daylink) ) { $daylink = str_replace('%year%', $year, $daylink); $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day); } else { return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); } } /** * Retrieve the permalink for the feed type. * * @since 1.5.0 * * @param string $feed Optional, defaults to default feed. Feed type. * @return string */ function get_feed_link($feed = '') { global $wp_rewrite; $permalink = $wp_rewrite->get_feed_permastruct(); if ( '' != $permalink ) { if ( false !== strpos($feed, 'comments_') ) { $feed = str_replace('comments_', '', $feed); $permalink = $wp_rewrite->get_comment_feed_permastruct(); } if ( get_default_feed() == $feed ) $feed = ''; $permalink = str_replace('%feed%', $feed, $permalink); $permalink = preg_replace('#/+#', '/', "/$permalink"); $output = get_option('home') . user_trailingslashit($permalink, 'feed'); } else { if ( empty($feed) ) $feed = get_default_feed(); if ( false !== strpos($feed, 'comments_') ) $feed = str_replace('comments_', 'comments-', $feed); $output = get_option('home') . "/?feed={$feed}"; } return apply_filters('feed_link', $output, $feed); } /** * Retrieve the permalink for the post comments feed. * * @since 2.2.0 * * @param int $post_id Optional. Post ID. * @param string $feed Optional. Feed type. * @return string */ function get_post_comments_feed_link($post_id = '', $feed = '') { global $id; if ( empty($post_id) ) $post_id = (int) $id; if ( empty($feed) ) $feed = get_default_feed(); if ( '' != get_option('permalink_structure') ) { $url = trailingslashit( get_permalink($post_id) ) . 'feed'; if ( $feed != get_default_feed() ) $url .= "/$feed"; $url = user_trailingslashit($url, 'single_feed'); } else { $type = get_post_field('post_type', $post_id); if ( 'page' == $type ) $url = get_option('home') . "/?feed=$feed&page_id=$post_id"; else $url = get_option('home') . "/?feed=$feed&p=$post_id"; } return apply_filters('post_comments_feed_link', $url); } /** * Display the comment feed link for a post. * * Prints out the comment feed link for a post. Link text is placed in the * anchor. If no link text is specified, default text is used. If no post ID is * specified, the current post is used. * * @package WordPress * @subpackage Feed * @since 2.5.0 * * @param string $link_text Descriptive text. * @param int $post_id Optional post ID. Default to current post. * @param string $feed Optional. Feed format. * @return string Link to the comment feed for the current post. */ function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { $url = get_post_comments_feed_link($post_id, $feed); if ( empty($link_text) ) $link_text = __('Comments Feed'); echo "<a href='$url'>$link_text</a>"; } /** * Retrieve the feed link for a given author. * * Returns a link to the feed for all posts by a given author. A specific feed * can be requested or left blank to get the default feed. * * @package WordPress * @subpackage Feed * @since 2.5.0 * * @param int $author_id ID of an author. * @param string $feed Optional. Feed type. * @return string Link to the feed for the author specified by $author_id. */ function get_author_feed_link( $author_id, $feed = '' ) { $author_id = (int) $author_id; $permalink_structure = get_option('permalink_structure'); if ( empty($feed) ) $feed = get_default_feed(); if ( '' == $permalink_structure ) { $link = get_option('home') . "?feed=$feed&author=" . $author_id; } else { $link = get_author_posts_url($author_id); if ( $feed == get_default_feed() ) $feed_link = 'feed'; else $feed_link = "feed/$feed"; $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); } $link = apply_filters('author_feed_link', $link, $feed); return $link; } /** * Retrieve the feed link for a category. * * Returns a link to the feed for all post in a given category. A specific feed * can be requested or left blank to get the default feed. * * @package WordPress * @subpackage Feed * @since 2.5.0 * * @param int $cat_id ID of a category. * @param string $feed Optional. Feed type. * @return string Link to the feed for the category specified by $cat_id. */ function get_category_feed_link($cat_id, $feed = '') { $cat_id = (int) $cat_id; $category = get_category($cat_id); if ( empty($category) || is_wp_error($category) ) return false; if ( empty($feed) ) $feed = get_default_feed(); $permalink_structure = get_option('permalink_structure'); if ( '' == $permalink_structure ) { $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; } else { $link = get_category_link($cat_id); if( $feed == get_default_feed() ) $feed_link = 'feed'; else $feed_link = "feed/$feed"; $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); } $link = apply_filters('category_feed_link', $link, $feed); return $link; } /** * Retrieve permalink for feed of tag. * * @since 2.3.0 * * @param int $tag_id Tag ID. * @param string $feed Optional. Feed type. * @return string */ function get_tag_feed_link($tag_id, $feed = '') { $tag_id = (int) $tag_id; $tag = get_tag($tag_id); if ( empty($tag) || is_wp_error($tag) ) return false; $permalink_structure = get_option('permalink_structure'); if ( empty($feed) ) $feed = get_default_feed(); if ( '' == $permalink_structure ) { $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; } else { $link = get_tag_link($tag->term_id); if ( $feed == get_default_feed() ) $feed_link = 'feed'; else $feed_link = "feed/$feed"; $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); } $link = apply_filters('tag_feed_link', $link, $feed); return $link; } /** * Retrieve edit tag link. * * @since 2.7.0 * * @param int $tag_id Tag ID * @return string */ function get_edit_tag_link( $tag_id = 0 ) { $tag = get_term($tag_id, 'post_tag'); if ( !current_user_can('manage_categories') ) return; $location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id; return apply_filters( 'get_edit_tag_link', $location ); } /** * Display or retrieve edit tag link with formatting. * * @since 2.7.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param int|object $tag Tag object or ID * @return string|null HTML content, if $echo is set to false. */ function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { $tag = get_term($tag, 'post_tag'); if ( !current_user_can('manage_categories') ) return; if ( empty($link) ) $link = __('Edit This'); $link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit tag' ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after; } /** * Retrieve the permalink for the feed of the search results. * * @since 2.5.0 * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string */ function get_search_feed_link($search_query = '', $feed = '') { if ( empty($search_query) ) $search = attribute_escape(get_search_query()); else $search = attribute_escape(stripslashes($search_query)); if ( empty($feed) ) $feed = get_default_feed(); $link = get_option('home') . "?s=$search&feed=$feed"; $link = apply_filters('search_feed_link', $link); return $link; } /** * Retrieve the permalink for the comments feed of the search results. * * @since 2.5.0 * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string */ function get_search_comments_feed_link($search_query = '', $feed = '') { if ( empty($search_query) ) $search = attribute_escape(get_search_query()); else $search = attribute_escape(stripslashes($search_query)); if ( empty($feed) ) $feed = get_default_feed(); $link = get_option('home') . "?s=$search&feed=comments-$feed"; $link = apply_filters('search_feed_link', $link); return $link; } /** * Retrieve edit posts link for post. * * Can be used within the WordPress loop or outside of it. Can be used with * pages, posts, attachments, and revisions. * * @since 2.3.0 * * @param int $id Optional. Post ID. * @param string $context Optional, default to display. How to write the '&', defaults to '&'. * @return string */ function get_edit_post_link( $id = 0, $context = 'display' ) { if ( !$post = &get_post( $id ) ) return; if ( 'display' == $context ) $action = 'action=edit&'; else $action = 'action=edit&'; switch ( $post->post_type ) : case 'page' : if ( !current_user_can( 'edit_page', $post->ID ) ) return; $file = 'page'; $var = 'post'; break; case 'attachment' : if ( !current_user_can( 'edit_post', $post->ID ) ) return; $file = 'media'; $var = 'attachment_id'; break; case 'revision' : if ( !current_user_can( 'edit_post', $post->ID ) ) return; $file = 'revision'; $var = 'revision'; $action = ''; break; default : if ( !current_user_can( 'edit_post', $post->ID ) ) return; $file = 'post'; $var = 'post'; break; endswitch; return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context ); } /** * Retrieve edit posts link for post. * * @since 1.0.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. */ function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { global $post; if ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; } else { if ( !current_user_can( 'edit_post', $post->ID ) ) return; } $link = '<a class="post-edit-link" href="' . get_edit_post_link( $post->ID ) . '" title="' . attribute_escape( __( 'Edit post' ) ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; } /** * Retrieve edit comment link. * * @since 2.3.0 * * @param int $comment_id Optional. Comment ID. * @return string */ function get_edit_comment_link( $comment_id = 0 ) { $comment = &get_comment( $comment_id ); $post = &get_post( $comment->comment_post_ID ); if ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; } else { if ( !current_user_can( 'edit_post', $post->ID ) ) return; } $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; return apply_filters( 'get_edit_comment_link', $location ); } /** * Display or retrieve edit comment link with formatting. * * @since 1.0.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @return string|null HTML content, if $echo is set to false. */ function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { global $comment, $post; if ( $post->post_type == 'attachment' ) { } elseif ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; } else { if ( !current_user_can( 'edit_post', $post->ID ) ) return; } $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; } /** * Display edit bookmark (literally a URL external to blog) link. * * @since 2.7.0 * * @param int $link Optional. Bookmark ID. * @return string */ function get_edit_bookmark_link( $link = 0 ) { $link = get_bookmark( $link ); if ( !current_user_can('manage_links') ) return; $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); } /** * Display edit bookmark (literally a URL external to blog) link anchor content. * * @since 2.7.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param int $bookmark Optional. Bookmark ID. */ function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { $bookmark = get_bookmark($bookmark); if ( !current_user_can('manage_links') ) return; if ( empty($link) ) $link = __('Edit This'); $link = '<a href="' . get_edit_bookmark_link( $link ) . '" title="' . __( 'Edit link' ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; } // Navigation links /** * Retrieve previous post link that is adjacent to current post. * * @since 1.5.0 * * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. * @return string */ function get_previous_post($in_same_cat = false, $excluded_categories = '') { return get_adjacent_post($in_same_cat, $excluded_categories); } /** * Retrieve next post link that is adjacent to current post. * * @since 1.5.0 * * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. * @return string */ function get_next_post($in_same_cat = false, $excluded_categories = '') { return get_adjacent_post($in_same_cat, $excluded_categories, false); } /** * Retrieve adjacent post link. * * Can either be next or previous post link. * * @since 2.5.0 * * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. * @param bool $previous Optional. Whether to retrieve previous post. * @return string */ function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) { global $post, $wpdb; if( empty($post) || !is_single() || is_attachment() ) return null; $current_post_date = $post->post_date; $join = ''; $posts_in_ex_cats_sql = ''; if ( $in_same_cat || !empty($excluded_categories) ) { $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; if ( $in_same_cat ) { $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids'); $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")"; } $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'"; if ( !empty($excluded_categories) ) { $excluded_categories = array_map('intval', explode(' and ', $excluded_categories)); if ( !empty($cat_array) ) { $excluded_categories = array_diff($excluded_categories, $cat_array); $posts_in_ex_cats_sql = ''; } if ( !empty($excluded_categories) ) { $posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')'; } } } $adjacent = $previous ? 'previous' : 'next'; $op = $previous ? '<' : '>'; $order = $previous ? 'DESC' : 'ASC'; $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date), $in_same_cat, $excluded_categories ); $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort"); } /** * Display previous post link that is adjacent to the current post. * * @since 1.5.0 * * @param string $format Optional. Link anchor format. * @param string $link Optional. Link permalink format. * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. */ function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); } /** * Display next post link that is adjacent to the current post. * * @since 1.5.0 * * @param string $format Optional. Link anchor format. * @param string $link Optional. Link permalink format. * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. */ function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); } /** * Display adjacent post link. * * Can be either next post link or previous. * * @since 2.5.0 * * @param string $format Link anchor format. * @param string $link Link permalink format. * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. * @param bool $previous Optional, default is true. Whether display link to previous post. */ function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { if ( $previous && is_attachment() ) $post = & get_post($GLOBALS['post']->post_parent); else $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); if ( !$post ) return; $title = $post->post_title; if ( empty($post->post_title) ) $title = $previous ? __('Previous Post') : __('Next Post'); $title = apply_filters('the_title', $title, $post); $date = mysql2date(get_option('date_format'), $post->post_date); $string = '<a href="'.get_permalink($post).'">'; $link = str_replace('%title', $title, $link); $link = str_replace('%date', $date, $link); $link = $string . $link . '</a>'; $format = str_replace('%link', $link, $format); $adjacent = $previous ? 'previous' : 'next'; echo apply_filters( "{$adjacent}_post_link", $format, $link ); } /** * Retrieve get links for page numbers. * * @since 1.5.0 * * @param int $pagenum Optional. Page ID. * @return string */ function get_pagenum_link($pagenum = 1) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( 'paged' ); $home_root = parse_url(get_option('home')); $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( 'home' ) ); if ( $pagenum > 1 ) { $result = add_query_arg( 'paged', $pagenum, $base . $request ); } else { $result = $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( '|page/\d+/?$|', '', $request); $request = preg_replace( '|^index\.php|', '', $request); $request = ltrim($request, '/'); $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) $base .= 'index.php/'; if ( $pagenum > 1 ) { $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' ); } $result = $base . $request . $query_string; } $result = apply_filters('get_pagenum_link', $result); return $result; } /** * Retrieve next posts pages link. * * Backported from 2.1.3 to 2.0.10. * * @since 2.0.10 * * @param int $max_page Optional. Max pages. * @return string */ function get_next_posts_page_link($max_page = 0) { global $paged; if ( !is_single() ) { if ( !$paged ) $paged = 1; $nextpage = intval($paged) + 1; if ( !$max_page || $max_page >= $nextpage ) return get_pagenum_link($nextpage); } } /** * Display or return the next posts pages link. * * @since 0.71 * * @param int $max_page Optional. Max pages. * @param boolean $echo Optional. Echo or return; */ function next_posts( $max_page = 0, $echo = true ) { $output = clean_url( get_next_posts_page_link( $max_page ) ); if ( $echo ) echo $output; else return $output; } /** * Return the next posts pages link. * * @since 2.7.0 * * @param string $label Content for link text. * @param int $max_page Optional. Max pages. * @return string|null */ function get_next_posts_link( $label = 'Next Page »', $max_page = 0 ) { global $paged, $wp_query; if ( !$max_page ) { $max_page = $wp_query->max_num_pages; } if ( !$paged ) $paged = 1; $nextpage = intval($paged) + 1; if ( !is_single() && ( empty($paged) || $nextpage <= $max_page) ) { $attr = apply_filters( 'next_posts_link_attributes', '' ); return '<a href="' . next_posts( $max_page, false ) . "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; } } /** * Display the next posts pages link. * * @since 0.71 * @uses get_next_posts_link() * * @param string $label Content for link text. * @param int $max_page Optional. Max pages. */ function next_posts_link( $label = 'Next Page »', $max_page = 0 ) { echo get_next_posts_link( $label, $max_page ); } /** * Retrieve previous post pages link. * * Will only return string, if not on a single page or post. * * Backported to 2.0.10 from 2.1.3. * * @since 2.0.10 * * @return string|null */ function get_previous_posts_page_link() { global $paged; if ( !is_single() ) { $nextpage = intval($paged) - 1; if ( $nextpage < 1 ) $nextpage = 1; return get_pagenum_link($nextpage); } } /** * Display or return the previous posts pages link. * * @since 0.71 * * @param boolean $echo Optional. Echo or return; */ function previous_posts( $echo = true ) { $output = clean_url( get_previous_posts_page_link() ); if ( $echo ) echo $output; else return $output; } /** * Return the previous posts pages link. * * @since 2.7.0 * * @param string $label Optional. Previous page link text. * @return string|null */ function get_previous_posts_link( $label = '« Previous Page' ) { global $paged; if ( !is_single() && $paged > 1 ) { $attr = apply_filters( 'previous_posts_link_attributes', '' ); return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&$1', $label ) .'</a>'; } } /** * Display the previous posts page link. * * @since 0.71 * @uses get_previous_posts_link() * * @param string $label Optional. Previous page link text. */ function previous_posts_link( $label = '« Previous Page' ) { echo get_previous_posts_link( $label ); } /** * Display post pages link navigation for previous and next pages. * * @since 0.71 * * @param string $sep Optional. Separator for posts navigation links. * @param string $prelabel Optional. Label for previous pages. * @param string $nxtlabel Optional Label for next pages. */ function posts_nav_link( $sep = ' — ', $prelabel = '« Previous Page', $nxtlabel = 'Next Page »' ) { global $wp_query; if ( !is_singular() ) { $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var('paged'); //only have sep if there's both prev and next results if ($paged < 2 || $paged >= $max_num_pages) { $sep = ''; } if ( $max_num_pages > 1 ) { previous_posts_link($prelabel); echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); next_posts_link($nxtlabel); } } } /** * Retrieve page numbers links. * * @since 2.7.0 * * @param int $pagenum Optional. Page number. * @return string */ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { global $post, $wp_rewrite; $pagenum = (int) $pagenum; $result = get_permalink( $post->ID ); if ( 'newest' == get_option('default_comments_page') ) { if ( $pagenum != $max_page ) { if ( $wp_rewrite->using_permalinks() ) $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged'); else $result = add_query_arg( 'cpage', $pagenum, $result ); } } elseif ( $pagenum > 1 ) { if ( $wp_rewrite->using_permalinks() ) $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged'); else $result = add_query_arg( 'cpage', $pagenum, $result ); } $result .= '#comments'; $result = apply_filters('get_comments_pagenum_link', $result); return $result; } /** * Return the link to next comments pages. * * @since 2.7.1 * * @param string $label Optional. Label for link text. * @param int $max_page Optional. Max page. * @return string|null */ function get_next_comments_link( $label = '', $max_page = 0 ) { global $wp_query; if ( !is_singular() ) return; $page = get_query_var('cpage'); $nextpage = intval($page) + 1; if ( empty($max_page) ) $max_page = $wp_query->max_num_comment_pages; if ( empty($max_page) ) $max_page = get_comment_pages_count(); if ( $nextpage > $max_page ) return; if ( empty($label) ) $label = __('Newer Comments »'); return '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; } /** * Display the link to next comments pages. * * @since 2.7.0 * * @param string $label Optional. Label for link text. * @param int $max_page Optional. Max page. */ function next_comments_link( $label = '', $max_page = 0 ) { echo get_next_comments_link( $label, $max_page ); } /** * Return the previous comments page link. * * @since 2.7.1 * * @param string $label Optional. Label for comments link text. * @return string|null */ function get_previous_comments_link( $label = '' ) { if ( !is_singular() ) return; $page = get_query_var('cpage'); if ( intval($page) <= 1 ) return; $prevpage = intval($page) - 1; if ( empty($label) ) $label = __('« Older Comments'); return '<a href="' . clean_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; } /** * Display the previous comments page link. * * @since 2.7.0 * * @param string $label Optional. Label for comments link text. */ function previous_comments_link( $label = '' ) { echo get_previous_comments_link( $label ); } /** * Create pagination links for the comments on the current post. * * @see paginate_links() * @since 2.7.0 * * @param string|array $args Optional args. See paginate_links. * @return string Markup for pagination links. */ function paginate_comments_links($args = array()) { global $wp_query, $wp_rewrite; if ( !is_singular() ) return; $page = get_query_var('cpage'); if ( !$page ) $page = 1; $max_page = get_comment_pages_count(); $defaults = array( 'base' => add_query_arg( 'cpage', '%#%' ), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments' ); if ( $wp_rewrite->using_permalinks() ) $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged'); $args = wp_parse_args( $args, $defaults ); $page_links = paginate_links( $args ); if ( $args['echo'] ) echo $page_links; else return $page_links; } /** * Retrieve shortcut link. * * Use this in 'a' element 'href' attribute. * * @since 2.6.0 * * @return string */ function get_shortcut_link() { $link = "javascript: var d=document, w=window, e=w.getSelection, k=d.getSelection, x=d.selection, s=(e?e():(k)?k():(x?x.createRange().text:0)), f='" . admin_url('press-this.php') . "', l=d.location, e=encodeURIComponent, g=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=2'; function a(){ if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=720,height=570')){ l.href=g; } }"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) $link .= 'setTimeout(a,0);'; else $link .= 'a();'; $link .= "void(0);"; $link = str_replace(array("\r", "\n", "\t"), '', $link); return apply_filters('shortcut_link', $link); } /** * Retrieve the site url. * * Returns the 'site_url' option with the appropriate protocol, 'https' if * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is * overridden. * * @package WordPress * @since 2.6.0 * * @param string $path Optional. Path relative to the site url. * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'. * @return string Site url link with optional path appended. */ function site_url($path = '', $scheme = null) { // should the list of allowed schemes be maintained elsewhere? $orig_scheme = $scheme; if ( !in_array($scheme, array('http', 'https')) ) { if ( ('login_post' == $scheme) && ( force_ssl_login() || force_ssl_admin() ) ) $scheme = 'https'; elseif ( ('login' == $scheme) && ( force_ssl_admin() ) ) $scheme = 'https'; elseif ( ('admin' == $scheme) && force_ssl_admin() ) $scheme = 'https'; else $scheme = ( is_ssl() ? 'https' : 'http' ); } $url = str_replace( 'http://', "{$scheme}://", get_option('siteurl') ); if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) $url .= '/' . ltrim($path, '/'); return apply_filters('site_url', $url, $path, $orig_scheme); } /** * Retrieve the url to the admin area. * * @package WordPress * @since 2.6.0 * * @param string $path Optional path relative to the admin url * @return string Admin url link with optional path appended */ function admin_url($path = '') { $url = site_url('wp-admin/', 'admin'); if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) $url .= ltrim($path, '/'); return $url; } /** * Retrieve the url to the includes directory. * * @package WordPress * @since 2.6.0 * * @param string $path Optional. Path relative to the includes url. * @return string Includes url link with optional path appended. */ function includes_url($path = '') { $url = site_url() . '/' . WPINC . '/'; if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) $url .= ltrim($path, '/'); return $url; } /** * Retrieve the url to the content directory. * * @package WordPress * @since 2.6.0 * * @param string $path Optional. Path relative to the content url. * @return string Content url link with optional path appended. */ function content_url($path = '') { $scheme = ( is_ssl() ? 'https' : 'http' ); $url = WP_CONTENT_URL; if ( 0 === strpos($url, 'http') ) { if ( is_ssl() ) $url = str_replace( 'http://', "{$scheme}://", $url ); } if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) $url .= '/' . ltrim($path, '/'); return $url; } /** * Retrieve the url to the plugins directory. * * @package WordPress * @since 2.6.0 * * @param string $path Optional. Path relative to the plugins url. * @return string Plugins url link with optional path appended. */ function plugins_url($path = '') { $scheme = ( is_ssl() ? 'https' : 'http' ); $url = WP_PLUGIN_URL; if ( 0 === strpos($url, 'http') ) { if ( is_ssl() ) $url = str_replace( 'http://', "{$scheme}://", $url ); } if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) $url .= '/' . ltrim($path, '/'); return $url; } ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/bookmark-template.php������������������������������������������������������0000644�0001033�0000041�00000022415�11121657265�021703� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * Bookmark Template Functions for usage in Themes * * @package WordPress * @subpackage Template */ /** * The formatted output of a list of bookmarks. * * The $bookmarks array must contain bookmark objects and will be iterated over * to retrieve the bookmark to be used in the output. * * The output is formatted as HTML with no way to change that format. However, * what is between, before, and after can be changed. The link itself will be * HTML. * * This function is used internally by wp_list_bookmarks() and should not be * used by themes. * * The defaults for overwriting are: * 'show_updated' - Default is 0 (integer). Will show the time of when the * bookmark was last updated. * 'show_description' - Default is 0 (integer). Whether to show the description * of the bookmark. * 'show_images' - Default is 1 (integer). Whether to show link image if * available. * 'show_name' - Default is 0 (integer). Whether to show link name if * available. * 'before' - Default is '<li>' (string). The html or text to prepend to each * bookmarks. * 'after' - Default is '</li>' (string). The html or text to append to each * bookmarks. * 'link_before' - Default is '' (string). The html or text to prepend to each * bookmarks inside the <a> tag. * 'link_after' - Default is '' (string). The html or text to append to each * bookmarks inside the <a> tag. * 'between' - Default is '\n' (string). The string for use in between the link, * description, and image. * 'show_rating' - Default is 0 (integer). Whether to show the link rating. * * @since 2.1.0 * @access private * @usedby wp_list_bookmarks() * * @param array $bookmarks List of bookmarks to traverse * @param string|array $args Optional. Overwrite the defaults. * @return string Formatted output in HTML */ function _walk_bookmarks($bookmarks, $args = '' ) { $defaults = array( 'show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'show_name' => 0, 'before' => '<li>', 'after' => '</li>', 'between' => "\n", 'show_rating' => 0, 'link_before' => '', 'link_after' => '' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $output = ''; // Blank string to start with. foreach ( (array) $bookmarks as $bookmark ) { if ( !isset($bookmark->recently_updated) ) $bookmark->recently_updated = false; $output .= $before; if ( $show_updated && $bookmark->recently_updated ) $output .= get_option('links_recently_updated_prepend'); $the_link = '#'; if ( !empty($bookmark->link_url) ) $the_link = clean_url($bookmark->link_url); $rel = $bookmark->link_rel; if ( '' != $rel ) $rel = ' rel="' . $rel . '"'; $desc = attribute_escape(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display')); $name = attribute_escape(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display')); $title = $desc; if ( $show_updated ) if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) { $title .= ' ('; $title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * 3600))); $title .= ')'; } if ( '' != $title ) $title = ' title="' . $title . '"'; $alt = ' alt="' . $name . '"'; $target = $bookmark->link_target; if ( '' != $target ) $target = ' target="' . $target . '"'; $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; $output .= $link_before; if ( $bookmark->link_image != null && $show_images ) { if ( strpos($bookmark->link_image, 'http') !== false ) $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; else // If it's a relative path $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />"; if ($show_name) $output .= $name; } else { $output .= $name; } $output .= $link_after; $output .= '</a>'; if ( $show_updated && $bookmark->recently_updated ) $output .= get_option('links_recently_updated_append'); if ( $show_description && '' != $desc ) $output .= $between . $desc; if ($show_rating) { $output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display'); } $output .= "$after\n"; } // end while return $output; } /** * Retrieve or echo all of the bookmarks. * * List of default arguments are as follows: * 'orderby' - Default is 'name' (string). How to order the links by. String is * based off of the bookmark scheme. * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either * ascending or descending order. * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to * display. * 'category' - Default is empty string (string). Include the links in what * category ID(s). * 'category_name' - Default is empty string (string). Get links by category * name. * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide * links marked as 'invisible'. * 'show_updated' - Default is 0 (integer). Will show the time of when the * bookmark was last updated. * 'echo' - Default is 1 (integer). Whether to echo (default) or return the * formatted bookmarks. * 'categorize' - Default is 1 (integer). Whether to show links listed by * category (default) or show links in one column. * * These options define how the Category name will appear before the category * links are displayed, if 'categorize' is 1. If 'categorize' is 0, then it will * display for only the 'title_li' string and only if 'title_li' is not empty. * 'title_li' - Default is 'Bookmarks' (translatable string). What to show * before the links appear. * 'title_before' - Default is '<h2>' (string). The HTML or text to show before * the 'title_li' string. * 'title_after' - Default is '</h2>' (string). The HTML or text to show after * the 'title_li' string. * 'class' - Default is 'linkcat' (string). The CSS class to use for the * 'title_li'. * * 'category_before' - Default is '<li id="%id" class="%class">'. String must * contain '%id' and '%class' to get * the id of the category and the 'class' argument. These are used for * formatting in themes. * Argument will be displayed before the 'title_before' argument. * 'category_after' - Default is '</li>' (string). The HTML or text that will * appear after the list of links. * * These are only used if 'categorize' is set to 1 or true. * 'category_orderby' - Default is 'name'. How to order the bookmark category * based on term scheme. * 'category_order' - Default is 'ASC'. Set the order by either ASC (ascending) * or DESC (descending). * * @see _walk_bookmarks() For other arguments that can be set in this function * and passed to _walk_bookmarks(). * @see get_bookmarks() For other arguments that can be set in this function and * passed to get_bookmarks(). * @link http://codex.wordpress.org/Template_Tags/wp_list_bookmarks * * @since 2.1.0 * @uses _list_bookmarks() Used to iterate over all of the bookmarks and return * the html * @uses get_terms() Gets all of the categories that are for links. * * @param string|array $args Optional. Overwrite the defaults of the function * @return string|null Will only return if echo option is set to not echo. * Default is not return anything. */ function wp_list_bookmarks($args = '') { $defaults = array( 'orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 'exclude_category' => '', 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, 'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>', 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $output = ''; if ( $categorize ) { //Split the bookmarks into ul's for each category $cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0)); foreach ( (array) $cats as $cat ) { $params = array_merge($r, array('category'=>$cat->term_id)); $bookmarks = get_bookmarks($params); if ( empty($bookmarks) ) continue; $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before); $catname = apply_filters( "link_category", $cat->name ); $output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n"; $output .= _walk_bookmarks($bookmarks, $r); $output .= "\n\t</ul>\n$category_after\n"; } } else { //output one single list using title_li for the title $bookmarks = get_bookmarks($r); if ( !empty($bookmarks) ) { if ( !empty( $title_li ) ){ $output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before); $output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n"; $output .= _walk_bookmarks($bookmarks, $r); $output .= "\n\t</ul>\n$category_after\n"; } else { $output .= _walk_bookmarks($bookmarks, $r); } } } $output = apply_filters( 'wp_list_bookmarks', $output ); if ( !$echo ) return $output; echo $output; } ?> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/http.php�������������������������������������������������������������������0000644�0001033�0000041�00000116124�11130712501�017226� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * Simple and uniform HTTP request API. * * Will eventually replace and standardize the WordPress HTTP requests made. * * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal * * @package WordPress * @subpackage HTTP * @since 2.7 * @author Jacob Santos <wordpress@santosj.name> */ /** * WordPress HTTP Class for managing HTTP Transports and making HTTP requests. * * This class is called for the functionality of making HTTP requests and should * replace Snoopy functionality, eventually. There is no available functionality * to add HTTP transport implementations, since most of the HTTP transports are * added and available for use. * * The exception is that cURL is not available as a transport and lacking an * implementation. It will be added later and should be a patch on the WordPress * Trac. * * There are no properties, because none are needed and for performance reasons. * Some of the functions are static and while they do have some overhead over * functions in PHP4, the purpose is maintainability. When PHP5 is finally the * requirement, it will be easy to add the static keyword to the code. It is not * as easy to convert a function to a method after enough code uses the old way. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http { /** * PHP4 style Constructor - Calls PHP5 Style Constructor * * @since 2.7 * @return WP_Http */ function WP_Http() { $this->__construct(); } /** * PHP5 style Constructor - Setup available transport if not available. * * PHP4 does not have the 'self' keyword and since WordPress supports PHP4, * the class needs to be used for the static call. * * The transport are setup to save time. This should only be called once, so * the overhead should be fine. * * @since 2.7 * @return WP_Http */ function __construct() { WP_Http::_getTransport(); WP_Http::_postTransport(); } /** * Tests the WordPress HTTP objects for an object to use and returns it. * * Tests all of the objects and returns the object that passes. Also caches * that object to be used later. * * The order for the GET/HEAD requests are Streams, HTTP Extension, Fopen, * and finally Fsockopen. fsockopen() is used last, because it has the most * overhead in its implementation. There isn't any real way around it, since * redirects have to be supported, much the same way the other transports * also handle redirects. * * There are currently issues with "localhost" not resolving correctly with * DNS. This may cause an error "failed to open stream: A connection attempt * failed because the connected party did not properly respond after a * period of time, or established connection failed because connected host * has failed to respond." * * @since 2.7 * @access private * * @param array $args Request args, default us an empty array * @return object|null Null if no transports are available, HTTP transport object. */ function &_getTransport( $args = array() ) { static $working_transport, $blocking_transport, $nonblocking_transport; if ( is_null($working_transport) ) { if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { $working_transport['exthttp'] = new WP_Http_ExtHttp(); $blocking_transport[] = &$working_transport['exthttp']; } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { $working_transport['curl'] = new WP_Http_Curl(); $blocking_transport[] = &$working_transport['curl']; } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { $working_transport['streams'] = new WP_Http_Streams(); $blocking_transport[] = &$working_transport['streams']; } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) { $working_transport['fopen'] = new WP_Http_Fopen(); $blocking_transport[] = &$working_transport['fopen']; } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { $working_transport['fsockopen'] = new WP_Http_Fsockopen(); $blocking_transport[] = &$working_transport['fsockopen']; } foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) { if ( isset($working_transport[$transport]) ) $nonblocking_transport[] = &$working_transport[$transport]; } } if ( isset($args['blocking']) && !$args['blocking'] ) return $nonblocking_transport; else return $blocking_transport; } /** * Tests the WordPress HTTP objects for an object to use and returns it. * * Tests all of the objects and returns the object that passes. Also caches * that object to be used later. This is for posting content to a URL and * is used when there is a body. The plain Fopen Transport can not be used * to send content, but the streams transport can. This is a limitation that * is addressed here, by just not including that transport. * * @since 2.7 * @access private * * @param array $args Request args, default us an empty array * @return object|null Null if no transports are available, HTTP transport object. */ function &_postTransport( $args = array() ) { static $working_transport, $blocking_transport, $nonblocking_transport; if ( is_null($working_transport) ) { if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { $working_transport['exthttp'] = new WP_Http_ExtHttp(); $blocking_transport[] = &$working_transport['exthttp']; } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { $working_transport['streams'] = new WP_Http_Streams(); $blocking_transport[] = &$working_transport['streams']; } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { $working_transport['fsockopen'] = new WP_Http_Fsockopen(); $blocking_transport[] = &$working_transport['fsockopen']; } foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) { if ( isset($working_transport[$transport]) ) $nonblocking_transport[] = &$working_transport[$transport]; } } if ( isset($args['blocking']) && !$args['blocking'] ) return $nonblocking_transport; else return $blocking_transport; } /** * Send a HTTP request to a URI. * * The body and headers are part of the arguments. The 'body' argument is * for the body and will accept either a string or an array. The 'headers' * argument should be an array, but a string is acceptable. If the 'body' * argument is an array, then it will automatically be escaped using * http_build_query(). * * The only URI that are supported in the HTTP Transport implementation are * the HTTP and HTTPS protocols. HTTP and HTTPS are assumed so the server * might not know how to handle the send headers. Other protocols are * unsupported and most likely will fail. * * The defaults are 'method', 'timeout', 'redirection', 'httpversion', * 'blocking' and 'user-agent'. * * Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports * technically allow others, but should not be assumed. The 'timeout' is * used to sent how long the connection should stay open before failing when * no response. 'redirection' is used to track how many redirects were taken * and used to sent the amount for other transports, but not all transports * accept setting that value. * * The 'httpversion' option is used to sent the HTTP version and accepted * values are '1.0', and '1.1' and should be a string. Version 1.1 is not * supported, because of chunk response. The 'user-agent' option is the * user-agent and is used to replace the default user-agent, which is * 'WordPress/WP_Version', where WP_Version is the value from $wp_version. * * 'blocking' is the default, which is used to tell the transport, whether * it should halt PHP while it performs the request or continue regardless. * Actually, that isn't entirely correct. Blocking mode really just means * whether the fread should just pull what it can whenever it gets bytes or * if it should wait until it has enough in the buffer to read or finishes * reading the entire content. It doesn't actually always mean that PHP will * continue going after making the request. * * @access public * @since 2.7 * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return boolean */ function request( $url, $args = array() ) { global $wp_version; $defaults = array( 'method' => 'GET', 'timeout' => apply_filters( 'http_request_timeout', 5), 'redirection' => apply_filters( 'http_request_redirection_count', 5), 'httpversion' => apply_filters( 'http_request_version', '1.0'), 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ), 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); $r = apply_filters( 'http_request_args', $r ); if ( is_null( $r['headers'] ) ) $r['headers'] = array(); if ( ! is_array($r['headers']) ) { $processedHeaders = WP_Http::processHeaders($r['headers']); $r['headers'] = $processedHeaders['headers']; } if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } if ( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } if ( is_null($r['body']) ) { // Some servers fail when sending content without the content-length // header being set. $r['headers']['Content-Length'] = 0; $transports = WP_Http::_getTransport($r); } else { if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) { $r['body'] = http_build_query($r['body'], null, '&'); $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'); $r['headers']['Content-Length'] = strlen($r['body']); } if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) ) $r['headers']['Content-Length'] = strlen($r['body']); $transports = WP_Http::_postTransport($r); } $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); foreach( (array) $transports as $transport ) { $response = $transport->request($url, $r); if( !is_wp_error($response) ) return $response; } return $response; } /** * Uses the POST HTTP method. * * Used for sending data that is expected to be in the body. * * @access public * @since 2.7 * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return boolean */ function post($url, $args = array()) { $defaults = array('method' => 'POST'); $r = wp_parse_args( $args, $defaults ); return $this->request($url, $r); } /** * Uses the GET HTTP method. * * Used for sending data that is expected to be in the body. * * @access public * @since 2.7 * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return boolean */ function get($url, $args = array()) { $defaults = array('method' => 'GET'); $r = wp_parse_args( $args, $defaults ); return $this->request($url, $r); } /** * Uses the HEAD HTTP method. * * Used for sending data that is expected to be in the body. * * @access public * @since 2.7 * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return boolean */ function head($url, $args = array()) { $defaults = array('method' => 'HEAD'); $r = wp_parse_args( $args, $defaults ); return $this->request($url, $r); } /** * Parses the responses and splits the parts into headers and body. * * @access public * @static * @since 2.7 * * @param string $strResponse The full response string * @return array Array with 'headers' and 'body' keys. */ function processResponse($strResponse) { list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2); return array('headers' => $theHeaders, 'body' => $theBody); } /** * Transform header string into an array. * * If an array is given then it is assumed to be raw header data with * numeric keys with the headers as the values. No headers must be passed * that were already processed. * * @access public * @static * @since 2.7 * * @param string|array $headers * @return array Processed string headers */ function processHeaders($headers) { if ( is_string($headers) ) $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) ); $response = array('code' => 0, 'message' => ''); $newheaders = array(); foreach ( $headers as $tempheader ) { if ( empty($tempheader) ) continue; if ( false === strpos($tempheader, ':') ) { list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3); $response['code'] = $iResponseCode; $response['message'] = $strResponseMsg; continue; } list($key, $value) = explode(':', $tempheader, 2); if ( ! empty($value) ) $newheaders[strtolower($key)] = trim($value); } return array('response' => $response, 'headers' => $newheaders); } /** * Decodes chunk transfer-encoding, based off the HTTP 1.1 specification. * * Based off the HTTP http_encoding_dechunk function. Does not support * UTF-8. Does not support returning footer headers. Shouldn't be too * difficult to support it though. * * @todo Add support for footer chunked headers. * @access public * @since 2.7 * @static * * @param string $body Body content * @return string Chunked decoded body on success or raw body on failure. */ function chunkTransferDecode($body) { $body = str_replace(array("\r\n", "\r"), "\n", $body); // The body is not chunked encoding or is malformed. if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) ) return $body; $parsedBody = ''; //$parsedHeaders = array(); Unsupported while ( true ) { $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match ); if ( $hasChunk ) { if ( empty($match[1]) ) return $body; $length = hexdec( $match[1] ); $chunkLength = strlen( $match[0] ); $strBody = substr($body, $chunkLength, $length); $parsedBody .= $strBody; $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n"); if( "0" == trim($body) ) return $parsedBody; // Ignore footer headers. } else { return $body; } } } } /** * HTTP request method uses fsockopen function to retrieve the url. * * This would be the preferred method, but the fsockopen implementation has the * most overhead of all the HTTP transport implementations. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http_Fsockopen { /** * Send a HTTP request to a URI using fsockopen(). * * Does not support non-blocking mode. * * @see WP_Http::request For default options descriptions. * * @since 2.7 * @access public * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return array 'headers', 'body', and 'response' keys. */ function request($url, $args = array()) { $defaults = array( 'method' => 'GET', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } else if( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } $iError = null; // Store error number $strError = null; // Store error string $arrURL = parse_url($url); $secure_transport = false; if ( ! isset($arrURL['port']) ) { if ( ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl') ) { $arrURL['host'] = 'ssl://' . $arrURL['host']; $arrURL['port'] = apply_filters('http_request_port', 443); $secure_transport = true; } else { $arrURL['port'] = apply_filters('http_request_default_port', 80); } } else { $arrURL['port'] = apply_filters('http_request_port', $arrURL['port']); } // There are issues with the HTTPS and SSL protocols that cause errors // that can be safely ignored and should be ignored. if ( true === $secure_transport ) $error_reporting = error_reporting(0); $startDelay = time(); if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) $handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); else $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); $endDelay = time(); // If the delay is greater than the timeout then fsockopen should't be // used, because it will cause a long delay. $elapseDelay = ($endDelay-$startDelay) > $r['timeout']; if ( true === $elapseDelay ) add_option( 'disable_fsockopen', $endDelay, null, true ); if ( false === $handle ) return new WP_Error('http_request_failed', $iError . ': ' . $strError); // WordPress supports PHP 4.3, which has this function. Removed sanity // checking for performance reasons. stream_set_timeout($handle, $r['timeout'] ); $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); $requestPath = empty($requestPath) ? '/' : $requestPath; $strHeaders = ''; $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; if( isset($r['user-agent']) ) $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; if ( is_array($r['headers']) ) { foreach ( (array) $r['headers'] as $header => $headerValue ) $strHeaders .= $header . ': ' . $headerValue . "\r\n"; } else { $strHeaders .= $r['headers']; } $strHeaders .= "\r\n"; if ( ! is_null($r['body']) ) $strHeaders .= $r['body']; fwrite($handle, $strHeaders); if ( ! $r['blocking'] ) { fclose($handle); return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); } $strResponse = ''; while ( ! feof($handle) ) $strResponse .= fread($handle, 4096); fclose($handle); if ( true === $secure_transport ) error_reporting($error_reporting); $process = WP_Http::processResponse($strResponse); $arrHeaders = WP_Http::processHeaders($process['headers']); // Is the response code within the 400 range? if ( (int) $arrHeaders['response']['code'] >= 400 && (int) $arrHeaders['response']['code'] < 500 ) return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']); // If location is found, then assume redirect and redirect to location. if ( isset($arrHeaders['headers']['location']) ) { if ( $r['redirection']-- > 0 ) { return $this->request($arrHeaders['headers']['location'], $r); } else { return new WP_Error('http_request_failed', __('Too many redirects.')); } } // If the body was chunk encoded, then decode it. if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) $process['body'] = WP_Http::chunkTransferDecode($process['body']); return array('headers' => $arrHeaders['headers'], 'body' => $process['body'], 'response' => $arrHeaders['response']); } /** * Whether this class can be used for retrieving an URL. * * @since 2.7 * @static * @return boolean False means this class can not be used, true means it can. */ function test() { if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours return false; if ( function_exists( 'fsockopen' ) ) return true; return false; } } /** * HTTP request method uses fopen function to retrieve the url. * * Requires PHP version greater than 4.3.0 for stream support. Does not allow * for $context support, but should still be okay, to write the headers, before * getting the response. Also requires that 'allow_url_fopen' to be enabled. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http_Fopen { /** * Send a HTTP request to a URI using fopen(). * * This transport does not support sending of headers and body, therefore * should not be used in the instances, where there is a body and headers. * * Notes: Does not support non-blocking mode. Ignores 'redirection' option. * * @see WP_Http::retrieve For default options descriptions. * * @access public * @since 2.7 * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return array 'headers', 'body', and 'response' keys. */ function request($url, $args = array()) { global $http_response_header; $defaults = array( 'method' => 'GET', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); $arrURL = parse_url($url); if ( false === $arrURL ) return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) $handle = @fopen($url, 'r'); else $handle = fopen($url, 'r'); if (! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); // WordPress supports PHP 4.3, which has this function. Removed sanity // checking for performance reasons. stream_set_timeout($handle, $r['timeout'] ); if ( ! $r['blocking'] ) { fclose($handle); return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); } $strResponse = ''; while ( ! feof($handle) ) $strResponse .= fread($handle, 4096); $theHeaders = ''; if ( function_exists('stream_get_meta_data') ) { $meta = stream_get_meta_data($handle); $theHeaders = $meta['wrapper_data']; if( isset( $meta['wrapper_data']['headers'] ) ) $theHeaders = $meta['wrapper_data']['headers']; } else { if( ! isset( $http_response_header ) ) global $http_response_header; $theHeaders = $http_response_header; } fclose($handle); $processedHeaders = WP_Http::processHeaders($theHeaders); if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) $strResponse = WP_Http::chunkTransferDecode($strResponse); return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); } /** * Whether this class can be used for retrieving an URL. * * @static * @return boolean False means this class can not be used, true means it can. */ function test() { if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) ) return false; return true; } } /** * HTTP request method uses Streams to retrieve the url. * * Requires PHP 5.0+ and uses fopen with stream context. Requires that * 'allow_url_fopen' PHP setting to be enabled. * * Second preferred method for getting the URL, for PHP 5. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http_Streams { /** * Send a HTTP request to a URI using streams with fopen(). * * @access public * @since 2.7 * * @param string $url * @param str|array $args Optional. Override the defaults. * @return array 'headers', 'body', and 'response' keys. */ function request($url, $args = array()) { $defaults = array( 'method' => 'GET', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } else if( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } $arrURL = parse_url($url); if ( false === $arrURL ) return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); // Convert Header array to string. $strHeaders = ''; if ( is_array( $r['headers'] ) ) foreach( $r['headers'] as $name => $value ) $strHeaders .= "{$name}: $value\r\n"; else if ( is_string( $r['headers'] ) ) $strHeaders = $r['headers']; $arrContext = array('http' => array( 'method' => strtoupper($r['method']), 'user_agent' => $r['user-agent'], 'max_redirects' => $r['redirection'], 'protocol_version' => (float) $r['httpversion'], 'header' => $strHeaders, 'timeout' => $r['timeout'] ) ); if ( ! is_null($r['body']) && ! empty($r['body'] ) ) $arrContext['http']['content'] = $r['body']; $context = stream_context_create($arrContext); if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) $handle = @fopen($url, 'r', false, $context); else $handle = fopen($url, 'r', false, $context); if ( ! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); // WordPress supports PHP 4.3, which has this function. Removed sanity // checking for performance reasons. stream_set_timeout($handle, $r['timeout'] ); if ( ! $r['blocking'] ) { stream_set_blocking($handle, 0); fclose($handle); return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); } $strResponse = stream_get_contents($handle); $meta = stream_get_meta_data($handle); $processedHeaders = array(); if( isset( $meta['wrapper_data']['headers'] ) ) $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']['headers']); else $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']); if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) $strResponse = WP_Http::chunkTransferDecode($strResponse); fclose($handle); return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); } /** * Whether this class can be used for retrieving an URL. * * @static * @access public * @since 2.7 * * @return boolean False means this class can not be used, true means it can. */ function test() { if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) ) return false; if ( version_compare(PHP_VERSION, '5.0', '<') ) return false; return true; } } /** * HTTP request method uses HTTP extension to retrieve the url. * * Requires the HTTP extension to be installed. This would be the preferred * transport since it can handle a lot of the problems that forces the others to * use the HTTP version 1.0. Even if PHP 5.2+ is being used, it doesn't mean * that the HTTP extension will be enabled. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http_ExtHTTP { /** * Send a HTTP request to a URI using HTTP extension. * * Does not support non-blocking. * * @access public * @since 2.7 * * @param string $url * @param str|array $args Optional. Override the defaults. * @return array 'headers', 'body', and 'response' keys. */ function request($url, $args = array()) { $defaults = array( 'method' => 'GET', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } else if( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } switch ( $r['method'] ) { case 'POST': $r['method'] = HTTP_METH_POST; break; case 'HEAD': $r['method'] = HTTP_METH_HEAD; break; case 'GET': default: $r['method'] = HTTP_METH_GET; } $arrURL = parse_url($url); if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); $options = array( 'timeout' => $r['timeout'], 'connecttimeout' => $r['timeout'], 'redirect' => $r['redirection'], 'useragent' => $r['user-agent'], 'headers' => $r['headers'], ); if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts $strResponse = @http_request($r['method'], $url, $r['body'], $options, $info); else $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts if ( false === $strResponse || ! empty($info['error']) ) //Error may still be set, Response may return headers or partial document, and error contains a reason the request was aborted, eg, timeout expired or max-redirects reached return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']); if ( ! $r['blocking'] ) return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2); $theHeaders = WP_Http::processHeaders($theHeaders); if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) { if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) $theBody = @http_chunked_decode($theBody); else $theBody = http_chunked_decode($theBody); } $theResponse = array(); $theResponse['code'] = $info['response_code']; $theResponse['message'] = get_status_header_desc($info['response_code']); return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse); } /** * Whether this class can be used for retrieving an URL. * * @static * @since 2.7 * * @return boolean False means this class can not be used, true means it can. */ function test() { if ( function_exists('http_request') ) return true; return false; } } /** * HTTP request method uses Curl extension to retrieve the url. * * Requires the Curl extension to be installed. * * @package WordPress * @subpackage HTTP * @since 2.7 */ class WP_Http_Curl { /** * Send a HTTP request to a URI using cURL extension. * * @access public * @since 2.7 * * @param string $url * @param str|array $args Optional. Override the defaults. * @return array 'headers', 'body', and 'response' keys. */ function request($url, $args = array()) { $defaults = array( 'method' => 'GET', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null ); $r = wp_parse_args( $args, $defaults ); if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } else if( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } // cURL extension will sometimes fail when the timeout is less than 1 as // it may round down to 0, which gives it unlimited timeout. if ( $r['timeout'] > 0 && $r['timeout'] < 1 ) $r['timeout'] = 1; $handle = curl_init(); curl_setopt( $handle, CURLOPT_URL, $url); // The cURL extension requires that the option be set for the HEAD to // work properly. if ( 'HEAD' === $r['method'] ) { curl_setopt( $handle, CURLOPT_NOBODY, true ); } if ( true === $r['blocking'] ) { curl_setopt( $handle, CURLOPT_HEADER, true ); curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); } else { curl_setopt( $handle, CURLOPT_HEADER, false ); curl_setopt( $handle, CURLOPT_NOBODY, true ); curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 ); } curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); // The option doesn't work with safe mode or when open_basedir is set. if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); if( ! is_null($r['headers']) ) curl_setopt( $handle, CURLOPT_HTTPHEADER, $r['headers'] ); if ( $r['httpversion'] == '1.0' ) curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); else curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); if ( ! $r['blocking'] ) { curl_exec( $handle ); curl_close( $handle ); return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); } $theResponse = curl_exec( $handle ); if ( !empty($theResponse) ) { $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE); $theHeaders = trim( substr($theResponse, 0, $headerLength) ); $theBody = substr( $theResponse, $headerLength ); if ( false !== strrpos($theHeaders, "\r\n\r\n") ) { $headerParts = explode("\r\n\r\n", $theHeaders); $theHeaders = $headerParts[ count($headerParts) -1 ]; } $theHeaders = WP_Http::processHeaders($theHeaders); } else { if ( $curl_error = curl_error($handle) ) return new WP_Error('http_request_failed', $curl_error); if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) return new WP_Error('http_request_failed', __('Too many redirects.')); $theHeaders = array( 'headers' => array() ); $theBody = ''; } $response = array(); $response['code'] = curl_getinfo( $handle, CURLINFO_HTTP_CODE ); $response['message'] = get_status_header_desc($response['code']); curl_close( $handle ); return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response); } /** * Whether this class can be used for retrieving an URL. * * @static * @since 2.7 * * @return boolean False means this class can not be used, true means it can. */ function test() { if ( function_exists('curl_init') && function_exists('curl_exec') ) return true; return false; } } /** * Returns the initialized WP_Http Object * * @since 2.7 * @access private * * @return WP_Http HTTP Transport object. */ function &_wp_http_get_object() { static $http; if ( is_null($http) ) $http = new WP_Http(); return $http; } /** * Retrieve the raw response from the HTTP request. * * The array structure is a little complex. * * <code> * $res = array( 'headers' => array(), 'response' => array('code', 'message') ); * </code> * * All of the headers in $res['headers'] are with the name as the key and the * value as the value. So to get the User-Agent, you would do the following. * * <code> * $user_agent = $res['headers']['user-agent']; * </code> * * The body is the raw response content and can be retrieved from $res['body']. * * This function is called first to make the request and there are other API * functions to abstract out the above convoluted setup. * * @since 2.7.0 * * @param string $url Site URL to retrieve. * @param array $args Optional. Override the defaults. * @return string The body of the response */ function wp_remote_request($url, $args = array()) { $objFetchSite = _wp_http_get_object(); return $objFetchSite->request($url, $args); } /** * Retrieve the raw response from the HTTP request using the GET method. * * @see wp_remote_request() For more information on the response array format. * * @since 2.7 * * @param string $url Site URL to retrieve. * @param array $args Optional. Override the defaults. * @return string The body of the response */ function wp_remote_get($url, $args = array()) { $objFetchSite = _wp_http_get_object(); return $objFetchSite->get($url, $args); } /** * Retrieve the raw response from the HTTP request using the POST method. * * @see wp_remote_request() For more information on the response array format. * * @since 2.7 * * @param string $url Site URL to retrieve. * @param array $args Optional. Override the defaults. * @return string The body of the response */ function wp_remote_post($url, $args = array()) { $objFetchSite = _wp_http_get_object(); return $objFetchSite->post($url, $args); } /** * Retrieve the raw response from the HTTP request using the HEAD method. * * @see wp_remote_request() For more information on the response array format. * * @since 2.7 * * @param string $url Site URL to retrieve. * @param array $args Optional. Override the defaults. * @return string The body of the response */ function wp_remote_head($url, $args = array()) { $objFetchSite = _wp_http_get_object(); return $objFetchSite->head($url, $args); } /** * Retrieve only the headers from the raw response. * * @since 2.7 * * @param array $response HTTP response. * @return array The headers of the response. Empty array if incorrect parameter given. */ function wp_remote_retrieve_headers(&$response) { if ( ! isset($response['headers']) || ! is_array($response['headers'])) return array(); return $response['headers']; } /** * Retrieve a single header by name from the raw response. * * @since 2.7 * * @param array $response * @param string $header Header name to retrieve value from. * @return array The header value. Empty string on if incorrect parameter given. */ function wp_remote_retrieve_header(&$response, $header) { if ( ! isset($response['headers']) || ! is_array($response['headers'])) return ''; if ( array_key_exists($header, $response['headers']) ) return $response['headers'][$header]; return ''; } /** * Retrieve only the response code from the raw response. * * Will return an empty array if incorrect parameter value is given. * * @since 2.7 * * @param array $response HTTP response. * @return array The keys 'code' and 'message' give information on the response. */ function wp_remote_retrieve_response_code(&$response) { if ( ! isset($response['response']) || ! is_array($response['response'])) return ''; return $response['response']['code']; } /** * Retrieve only the response message from the raw response. * * Will return an empty array if incorrect parameter value is given. * * @since 2.7 * * @param array $response HTTP response. * @return array The keys 'code' and 'message' give information on the response. */ function wp_remote_retrieve_response_message(&$response) { if ( ! isset($response['response']) || ! is_array($response['response'])) return ''; return $response['response']['message']; } /** * Retrieve only the body from the raw response. * * @since 2.7 * * @param array $response HTTP response. * @return string The body of the response. Empty string if no body or incorrect parameter given. */ function wp_remote_retrieve_body(&$response) { if ( ! isset($response['body']) ) return ''; return $response['body']; } ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/class-pop3.php�������������������������������������������������������������0000644�0001033�0000041�00000050216�11103704127�020237� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * mail_fetch/setup.php * * @package SquirrelMail * * @copyright (c) 1999-2006 The SquirrelMail Project Team * * @copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved * Modified by Philippe Mingo 2001 mingo@rotedic.com * An RFC 1939 compliant wrapper class for the POP3 protocol. * * Licensed under the GNU GPL. For full terms see the file COPYING. * * pop3 class * * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $ */ class POP3 { var $ERROR = ''; // Error string. var $TIMEOUT = 60; // Default timeout before giving up on a // network operation. var $COUNT = -1; // Mailbox msg count var $BUFFER = 512; // Socket buffer for socket fgets() calls. // Per RFC 1939 the returned line a POP3 // server can send is 512 bytes. var $FP = ''; // The connection to the server's // file descriptor var $MAILSERVER = ''; // Set this to hard code the server name var $DEBUG = FALSE; // set to true to echo pop3 // commands and responses to error_log // this WILL log passwords! var $BANNER = ''; // Holds the banner returned by the // pop server - used for apop() var $ALLOWAPOP = FALSE; // Allow or disallow apop() // This must be set to true // manually function POP3 ( $server = '', $timeout = '' ) { settype($this->BUFFER,"integer"); if( !empty($server) ) { // Do not allow programs to alter MAILSERVER // if it is already specified. They can get around // this if they -really- want to, so don't count on it. if(empty($this->MAILSERVER)) $this->MAILSERVER = $server; } if(!empty($timeout)) { settype($timeout,"integer"); $this->TIMEOUT = $timeout; if (!ini_get('safe_mode')) set_time_limit($timeout); } return true; } function update_timer () { if (!ini_get('safe_mode')) set_time_limit($this->TIMEOUT); return true; } function connect ($server, $port = 110) { // Opens a socket to the specified server. Unless overridden, // port defaults to 110. Returns true on success, false on fail // If MAILSERVER is set, override $server with it's value if (!isset($port) || !$port) {$port = 110;} if(!empty($this->MAILSERVER)) $server = $this->MAILSERVER; if(empty($server)){ $this->ERROR = "POP3 connect: " . _("No server specified"); unset($this->FP); return false; } $fp = @fsockopen("$server", $port, $errno, $errstr); if(!$fp) { $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]"; unset($this->FP); return false; } socket_set_blocking($fp,-1); $this->update_timer(); $reply = fgets($fp,$this->BUFFER); $reply = $this->strip_clf($reply); if($this->DEBUG) error_log("POP3 SEND [connect: $server] GOT [$reply]",0); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]"; unset($this->FP); return false; } $this->FP = $fp; $this->BANNER = $this->parse_banner($reply); return true; } function user ($user = "") { // Sends the USER command, returns true or false if( empty($user) ) { $this->ERROR = "POP3 user: " . _("no login ID submitted"); return false; } elseif(!isset($this->FP)) { $this->ERROR = "POP3 user: " . _("connection not established"); return false; } else { $reply = $this->send_cmd("USER $user"); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]"; return false; } else return true; } } function pass ($pass = "") { // Sends the PASS command, returns # of msgs in mailbox, // returns false (undef) on Auth failure if(empty($pass)) { $this->ERROR = "POP3 pass: " . _("No password submitted"); return false; } elseif(!isset($this->FP)) { $this->ERROR = "POP3 pass: " . _("connection not established"); return false; } else { $reply = $this->send_cmd("PASS $pass"); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]"; $this->quit(); return false; } else { // Auth successful. $count = $this->last("count"); $this->COUNT = $count; return $count; } } } function apop ($login,$pass) { // Attempts an APOP login. If this fails, it'll // try a standard login. YOUR SERVER MUST SUPPORT // THE USE OF THE APOP COMMAND! // (apop is optional per rfc1939) if(!isset($this->FP)) { $this->ERROR = "POP3 apop: " . _("No connection to server"); return false; } elseif(!$this->ALLOWAPOP) { $retVal = $this->login($login,$pass); return $retVal; } elseif(empty($login)) { $this->ERROR = "POP3 apop: " . _("No login ID submitted"); return false; } elseif(empty($pass)) { $this->ERROR = "POP3 apop: " . _("No password submitted"); return false; } else { $banner = $this->BANNER; if( (!$banner) or (empty($banner)) ) { $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort"); $retVal = $this->login($login,$pass); return $retVal; } else { $AuthString = $banner; $AuthString .= $pass; $APOPString = md5($AuthString); $cmd = "APOP $login $APOPString"; $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort"); $retVal = $this->login($login,$pass); return $retVal; } else { // Auth successful. $count = $this->last("count"); $this->COUNT = $count; return $count; } } } } function login ($login = "", $pass = "") { // Sends both user and pass. Returns # of msgs in mailbox or // false on failure (or -1, if the error occurs while getting // the number of messages.) if( !isset($this->FP) ) { $this->ERROR = "POP3 login: " . _("No connection to server"); return false; } else { $fp = $this->FP; if( !$this->user( $login ) ) { // Preserve the error generated by user() return false; } else { $count = $this->pass($pass); if( (!$count) || ($count == -1) ) { // Preserve the error generated by last() and pass() return false; } else return $count; } } } function top ($msgNum, $numLines = "0") { // Gets the header and first $numLines of the msg body // returns data in an array with each returned line being // an array element. If $numLines is empty, returns // only the header information, and none of the body. if(!isset($this->FP)) { $this->ERROR = "POP3 top: " . _("No connection to server"); return false; } $this->update_timer(); $fp = $this->FP; $buffer = $this->BUFFER; $cmd = "TOP $msgNum $numLines"; fwrite($fp, "TOP $msgNum $numLines\r\n"); $reply = fgets($fp, $buffer); $reply = $this->strip_clf($reply); if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } if(!$this->is_ok($reply)) { $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]"; return false; } $count = 0; $MsgArray = array(); $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { $MsgArray[$count] = $line; $count++; $line = fgets($fp,$buffer); if(empty($line)) { break; } } return $MsgArray; } function pop_list ($msgNum = "") { // If called with an argument, returns that msgs' size in octets // No argument returns an associative array of undeleted // msg numbers and their sizes in octets if(!isset($this->FP)) { $this->ERROR = "POP3 pop_list: " . _("No connection to server"); return false; } $fp = $this->FP; $Total = $this->COUNT; if( (!$Total) or ($Total == -1) ) { return false; } if($Total == 0) { return array("0","0"); // return -1; // mailbox empty } $this->update_timer(); if(!empty($msgNum)) { $cmd = "LIST $msgNum"; fwrite($fp,"$cmd\r\n"); $reply = fgets($fp,$this->BUFFER); $reply = $this->strip_clf($reply); if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } if(!$this->is_ok($reply)) { $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; return false; } list($junk,$num,$size) = preg_split('/\s+/',$reply); return $size; } $cmd = "LIST"; $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { $reply = $this->strip_clf($reply); $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; return false; } $MsgArray = array(); $MsgArray[0] = $Total; for($msgC=1;$msgC <= $Total; $msgC++) { if($msgC > $Total) { break; } $line = fgets($fp,$this->BUFFER); $line = $this->strip_clf($line); if(ereg("^\.",$line)) { $this->ERROR = "POP3 pop_list: " . _("Premature end of list"); return false; } list($thisMsg,$msgSize) = preg_split('/\s+/',$line); settype($thisMsg,"integer"); if($thisMsg != $msgC) { $MsgArray[$msgC] = "deleted"; } else { $MsgArray[$msgC] = $msgSize; } } return $MsgArray; } function get ($msgNum) { // Retrieve the specified msg number. Returns an array // where each line of the msg is an array element. if(!isset($this->FP)) { $this->ERROR = "POP3 get: " . _("No connection to server"); return false; } $this->update_timer(); $fp = $this->FP; $buffer = $this->BUFFER; $cmd = "RETR $msgNum"; $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]"; return false; } $count = 0; $MsgArray = array(); $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { if ( $line{0} == '.' ) { $line = substr($line,1); } $MsgArray[$count] = $line; $count++; $line = fgets($fp,$buffer); if(empty($line)) { break; } } return $MsgArray; } function last ( $type = "count" ) { // Returns the highest msg number in the mailbox. // returns -1 on error, 0+ on success, if type != count // results in a popstat() call (2 element array returned) $last = -1; if(!isset($this->FP)) { $this->ERROR = "POP3 last: " . _("No connection to server"); return $last; } $reply = $this->send_cmd("STAT"); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]"; return $last; } $Vars = preg_split('/\s+/',$reply); $count = $Vars[1]; $size = $Vars[2]; settype($count,"integer"); settype($size,"integer"); if($type != "count") { return array($count,$size); } return $count; } function reset () { // Resets the status of the remote server. This includes // resetting the status of ALL msgs to not be deleted. // This method automatically closes the connection to the server. if(!isset($this->FP)) { $this->ERROR = "POP3 reset: " . _("No connection to server"); return false; } $reply = $this->send_cmd("RSET"); if(!$this->is_ok($reply)) { // The POP3 RSET command -never- gives a -ERR // response - if it ever does, something truely // wild is going on. $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]"; @error_log("POP3 reset: ERROR [$reply]",0); } $this->quit(); return true; } function send_cmd ( $cmd = "" ) { // Sends a user defined command string to the // POP server and returns the results. Useful for // non-compliant or custom POP servers. // Do NOT includ the \r\n as part of your command // string - it will be appended automatically. // The return value is a standard fgets() call, which // will read up to $this->BUFFER bytes of data, until it // encounters a new line, or EOF, whichever happens first. // This method works best if $cmd responds with only // one line of data. if(!isset($this->FP)) { $this->ERROR = "POP3 send_cmd: " . _("No connection to server"); return false; } if(empty($cmd)) { $this->ERROR = "POP3 send_cmd: " . _("Empty command string"); return ""; } $fp = $this->FP; $buffer = $this->BUFFER; $this->update_timer(); fwrite($fp,"$cmd\r\n"); $reply = fgets($fp,$buffer); $reply = $this->strip_clf($reply); if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } return $reply; } function quit() { // Closes the connection to the POP3 server, deleting // any msgs marked as deleted. if(!isset($this->FP)) { $this->ERROR = "POP3 quit: " . _("connection does not exist"); return false; } $fp = $this->FP; $cmd = "QUIT"; fwrite($fp,"$cmd\r\n"); $reply = fgets($fp,$this->BUFFER); $reply = $this->strip_clf($reply); if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } fclose($fp); unset($this->FP); return true; } function popstat () { // Returns an array of 2 elements. The number of undeleted // msgs in the mailbox, and the size of the mbox in octets. $PopArray = $this->last("array"); if($PopArray == -1) { return false; } if( (!$PopArray) or (empty($PopArray)) ) { return false; } return $PopArray; } function uidl ($msgNum = "") { // Returns the UIDL of the msg specified. If called with // no arguments, returns an associative array where each // undeleted msg num is a key, and the msg's uidl is the element // Array element 0 will contain the total number of msgs if(!isset($this->FP)) { $this->ERROR = "POP3 uidl: " . _("No connection to server"); return false; } $fp = $this->FP; $buffer = $this->BUFFER; if(!empty($msgNum)) { $cmd = "UIDL $msgNum"; $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; return false; } list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply); return $myUidl; } else { $this->update_timer(); $UIDLArray = array(); $Total = $this->COUNT; $UIDLArray[0] = $Total; if ($Total < 1) { return $UIDLArray; } $cmd = "UIDL"; fwrite($fp, "UIDL\r\n"); $reply = fgets($fp, $buffer); $reply = $this->strip_clf($reply); if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } if(!$this->is_ok($reply)) { $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; return false; } $line = ""; $count = 1; $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { if(ereg("^\.\r\n",$line)) { break; } list ($msg,$msgUidl) = preg_split('/\s+/',$line); $msgUidl = $this->strip_clf($msgUidl); if($count == $msg) { $UIDLArray[$msg] = $msgUidl; } else { $UIDLArray[$count] = 'deleted'; } $count++; $line = fgets($fp,$buffer); } } return $UIDLArray; } function delete ($msgNum = "") { // Flags a specified msg as deleted. The msg will not // be deleted until a quit() method is called. if(!isset($this->FP)) { $this->ERROR = "POP3 delete: " . _("No connection to server"); return false; } if(empty($msgNum)) { $this->ERROR = "POP3 delete: " . _("No msg number submitted"); return false; } $reply = $this->send_cmd("DELE $msgNum"); if(!$this->is_ok($reply)) { $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]"; return false; } return true; } // ********************************************************* // The following methods are internal to the class. function is_ok ($cmd = "") { // Return true or false on +OK or -ERR if( empty($cmd) ) return false; else return( ereg ("^\+OK", $cmd ) ); } function strip_clf ($text = "") { // Strips \r\n from server responses if(empty($text)) return $text; else { $stripped = str_replace("\r",'',$text); $stripped = str_replace("\n",'',$stripped); return $stripped; } } function parse_banner ( $server_text ) { $outside = true; $banner = ""; $length = strlen($server_text); for($count =0; $count < $length; $count++) { $digit = substr($server_text,$count,1); if(!empty($digit)) { if( (!$outside) && ($digit != '<') && ($digit != '>') ) { $banner .= $digit; } if ($digit == '<') { $outside = false; } if($digit == '>') { $outside = true; } } } $banner = $this->strip_clf($banner); // Just in case return "<$banner>"; } } // End class ?> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������waterwise-wp/wp-includes/feed-atom-comments.php�����������������������������������������������������0000644�0001033�0000041�00000010256�11135435210�021736� 0����������������������������������������������������������������������������������������������������ustar �robert��������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /** * Atom Feed Template for displaying Atom Comments feed. * * @package WordPress */ header('Content-Type: application/atom+xml; charset=' . get_option('blog_charset'), true); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>'; ?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php echo get_option('rss_language'); ?>" xmlns:thr="http://purl.org/syndication/thread/1.0" <?php do_action('atom_ns'); ?> > <title type="text"><?php if ( is_singular() ) printf(ent2ncr(__('Comments on: %s')), get_the_title_rss()); elseif ( is_search() ) printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss( 'name' ), attribute_escape(get_search_query())); else printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss( 'name' ) . get_wp_title_rss()); ?> comment_post_ID); get_post_custom($comment_post->ID); ?> <?php if ( !is_singular() ) { $title = get_the_title($comment_post->ID); $title = apply_filters('the_title_rss', $title); printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss()); } else { printf(ent2ncr(__('By: %s')), get_comment_author_rss()); } ?> ' . get_comment_author_url() . ''; ?> ]]> ]]> comment_parent == 0 ) : // This comment is top level ?> comment_parent); // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, its more important that they both use the same system ?> comment_ID, $comment_post->ID); ?> waterwise-wp/wp-includes/cache.php0000644000103300000410000002745011110355630017321 0ustar robertwww-dataadd($key, $data, $flag, $expire); } /** * Closes the cache. * * This function has ceased to do anything since WordPress 2.5. The * functionality was removed along with the rest of the persistant cache. This * does not mean that plugins can't implement this function when they need to * make sure that the cache is cleaned up after WordPress no longer needs it. * * @since 2.0.0 * * @return bool Always returns True */ function wp_cache_close() { return true; } /** * Removes the cache contents matching ID and flag. * * @since 2.0.0 * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::delete() * * @param int|string $id What the contents in the cache are called * @param string $flag Where the cache contents are grouped * @return bool True on successful removal, false on failure */ function wp_cache_delete($id, $flag = '') { global $wp_object_cache; return $wp_object_cache->delete($id, $flag); } /** * Removes all cache items. * * @since 2.0.0 * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::flush() * * @return bool Always returns true */ function wp_cache_flush() { global $wp_object_cache; return $wp_object_cache->flush(); } /** * Retrieves the cache contents from the cache by ID and flag. * * @since 2.0.0 * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::get() * * @param int|string $id What the contents in the cache are called * @param string $flag Where the cache contents are grouped * @return bool|mixed False on failure to retrieve contents or the cache * contents on success */ function wp_cache_get($id, $flag = '') { global $wp_object_cache; return $wp_object_cache->get($id, $flag); } /** * Sets up Object Cache Global and assigns it. * * @since 2.0.0 * @global WP_Object_Cache $wp_object_cache WordPress Object Cache */ function wp_cache_init() { $GLOBALS['wp_object_cache'] =& new WP_Object_Cache(); } /** * Replaces the contents of the cache with new data. * * @since 2.0.0 * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::replace() * * @param int|string $id What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $flag Where to group the cache contents * @param int $expire When to expire the cache contents * @return bool False if cache ID and group already exists, true on success */ function wp_cache_replace($key, $data, $flag = '', $expire = 0) { global $wp_object_cache; return $wp_object_cache->replace($key, $data, $flag, $expire); } /** * Saves the data to the cache. * * @since 2.0 * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::set() * * @param int|string $id What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $flag Where to group the cache contents * @param int $expire When to expire the cache contents * @return bool False if cache ID and group already exists, true on success */ function wp_cache_set($key, $data, $flag = '', $expire = 0) { global $wp_object_cache; return $wp_object_cache->set($key, $data, $flag, $expire); } /** * Adds a group or set of groups to the list of global groups. * * @since 2.6.0 * * @param string|array $groups A group or an array of groups to add */ function wp_cache_add_global_groups( $groups ) { // Default cache doesn't persist so nothing to do here. return; } /** * Adds a group or set of groups to the list of non-persistent groups. * * @since 2.6.0 * * @param string|array $groups A group or an array of groups to add */ function wp_cache_add_non_persistent_groups( $groups ) { // Default cache doesn't persist so nothing to do here. return; } /** * WordPress Object Cache * * The WordPress Object Cache is used to save on trips to the database. The * Object Cache stores all of the cache data to memory and makes the cache * contents available by using a key, which is used to name and later retrieve * the cache contents. * * The Object Cache can be replaced by other caching mechanisms by placing files * in the wp-content folder which is looked at in wp-settings. If that file * exists, then this file will not be included. * * @package WordPress * @subpackage Cache * @since 2.0 */ class WP_Object_Cache { /** * Holds the cached objects * * @var array * @access private * @since 2.0.0 */ var $cache = array (); /** * Cache objects that do not exist in the cache * * @var array * @access private * @since 2.0.0 */ var $non_existant_objects = array (); /** * The amount of times the cache data was already stored in the cache. * * @since 2.5.0 * @access private * @var int */ var $cache_hits = 0; /** * Amount of times the cache did not have the request in cache * * @var int * @access public * @since 2.0.0 */ var $cache_misses = 0; /** * Adds data to the cache if it doesn't already exist. * * @uses WP_Object_Cache::get Checks to see if the cache already has data. * @uses WP_Object_Cache::set Sets the data after the checking the cache * contents existance. * * @since 2.0.0 * * @param int|string $id What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $group Where to group the cache contents * @param int $expire When to expire the cache contents * @return bool False if cache ID and group already exists, true on success */ function add($id, $data, $group = 'default', $expire = '') { if (empty ($group)) $group = 'default'; if (false !== $this->get($id, $group, false)) return false; return $this->set($id, $data, $group, $expire); } /** * Remove the contents of the cache ID in the group * * If the cache ID does not exist in the group and $force parameter is set * to false, then nothing will happen. The $force parameter is set to false * by default. * * On success the group and the id will be added to the * $non_existant_objects property in the class. * * @since 2.0.0 * * @param int|string $id What the contents in the cache are called * @param string $group Where the cache contents are grouped * @param bool $force Optional. Whether to force the unsetting of the cache * ID in the group * @return bool False if the contents weren't deleted and true on success */ function delete($id, $group = 'default', $force = false) { if (empty ($group)) $group = 'default'; if (!$force && false === $this->get($id, $group, false)) return false; unset ($this->cache[$group][$id]); $this->non_existant_objects[$group][$id] = true; return true; } /** * Clears the object cache of all data * * @since 2.0.0 * * @return bool Always returns true */ function flush() { $this->cache = array (); return true; } /** * Retrieves the cache contents, if it exists * * The contents will be first attempted to be retrieved by searching by the * ID in the cache group. If the cache is hit (success) then the contents * are returned. * * On failure, the $non_existant_objects property is checked and if the * cache group and ID exist in there the cache misses will not be * incremented. If not in the nonexistant objects property, then the cache * misses will be incremented and the cache group and ID will be added to * the nonexistant objects. * * @since 2.0.0 * * @param int|string $id What the contents in the cache are called * @param string $group Where the cache contents are grouped * @return bool|mixed False on failure to retrieve contents or the cache * contents on success */ function get($id, $group = 'default') { if (empty ($group)) $group = 'default'; if (isset ($this->cache[$group][$id])) { $this->cache_hits += 1; if ( is_object($this->cache[$group][$id]) ) return wp_clone($this->cache[$group][$id]); else return $this->cache[$group][$id]; } if ( isset ($this->non_existant_objects[$group][$id]) ) return false; $this->non_existant_objects[$group][$id] = true; $this->cache_misses += 1; return false; } /** * Replace the contents in the cache, if contents already exist * * @since 2.0.0 * @see WP_Object_Cache::set() * * @param int|string $id What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $group Where to group the cache contents * @param int $expire When to expire the cache contents * @return bool False if not exists, true if contents were replaced */ function replace($id, $data, $group = 'default', $expire = '') { if (empty ($group)) $group = 'default'; if (false === $this->get($id, $group, false)) return false; return $this->set($id, $data, $group, $expire); } /** * Sets the data contents into the cache * * The cache contents is grouped by the $group parameter followed by the * $id. This allows for duplicate ids in unique groups. Therefore, naming of * the group should be used with care and should follow normal function * naming guidelines outside of core WordPress usage. * * The $expire parameter is not used, because the cache will automatically * expire for each time a page is accessed and PHP finishes. The method is * more for cache plugins which use files. * * @since 2.0.0 * * @param int|string $id What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $group Where to group the cache contents * @param int $expire Not Used * @return bool Always returns true */ function set($id, $data, $group = 'default', $expire = '') { if (empty ($group)) $group = 'default'; if (NULL === $data) $data = ''; if ( is_object($data) ) $data = wp_clone($data); $this->cache[$group][$id] = $data; if(isset($this->non_existant_objects[$group][$id])) unset ($this->non_existant_objects[$group][$id]); return true; } /** * Echos the stats of the caching. * * Gives the cache hits, and cache misses. Also prints every cached group, * key and the data. * * @since 2.0.0 */ function stats() { echo "

"; echo "Cache Hits: {$this->cache_hits}
"; echo "Cache Misses: {$this->cache_misses}
"; echo "

"; foreach ($this->cache as $group => $cache) { echo "

"; echo "Group: $group
"; echo "Cache:"; echo "

";
			print_r($cache);
			echo "
"; } } /** * PHP4 constructor; Calls PHP 5 style constructor * * @since 2.0.0 * * @return WP_Object_Cache */ function WP_Object_Cache() { return $this->__construct(); } /** * Sets up object properties; PHP 5 style constructor * * @since 2.0.8 * @return null|WP_Object_Cache If cache is disabled, returns null. */ function __construct() { /** * @todo This should be moved to the PHP4 style constructor, PHP5 * already calls __destruct() */ register_shutdown_function(array(&$this, "__destruct")); } /** * Will save the object cache before object is completely destroyed. * * Called upon object destruction, which should be when PHP ends. * * @since 2.0.8 * * @return bool True value. Won't be used by PHP */ function __destruct() { return true; } } ?> waterwise-wp/wp-includes/kses.php0000644000103300000410000007674511135667304017251 0ustar robertwww-data * * @package External * @subpackage KSES * * @internal * *** CONTACT INFORMATION *** * E-mail: metaur at users dot sourceforge dot net * Web page: http://sourceforge.net/projects/kses * Paper mail: Ulf Harnhammar * Ymergatan 17 C * 753 25 Uppsala * SWEDEN * * [kses strips evil scripts!] */ /** * You can override this in your my-hacks.php file You can also override this * in a plugin file. The my-hacks.php is deprecated in its usage. * * @since 1.2.0 */ if (!defined('CUSTOM_TAGS')) define('CUSTOM_TAGS', false); if (!CUSTOM_TAGS) { /** * Kses global for default allowable HTML tags. * * Can be override by using CUSTOM_TAGS constant. * * @global array $allowedposttags * @since 2.0.0 */ $allowedposttags = array( 'address' => array(), 'a' => array( 'class' => array (), 'href' => array (), 'id' => array (), 'title' => array (), 'rel' => array (), 'rev' => array (), 'name' => array (), 'target' => array()), 'abbr' => array( 'class' => array (), 'title' => array ()), 'acronym' => array( 'title' => array ()), 'b' => array(), 'big' => array(), 'blockquote' => array( 'id' => array (), 'cite' => array (), 'class' => array(), 'lang' => array(), 'xml:lang' => array()), 'br' => array ( 'class' => array ()), 'button' => array( 'disabled' => array (), 'name' => array (), 'type' => array (), 'value' => array ()), 'caption' => array( 'align' => array (), 'class' => array ()), 'cite' => array ( 'class' => array(), 'dir' => array(), 'lang' => array(), 'title' => array ()), 'code' => array ( 'style' => array()), 'col' => array( 'align' => array (), 'char' => array (), 'charoff' => array (), 'span' => array (), 'dir' => array(), 'style' => array (), 'valign' => array (), 'width' => array ()), 'del' => array( 'datetime' => array ()), 'dd' => array(), 'div' => array( 'align' => array (), 'class' => array (), 'dir' => array (), 'lang' => array(), 'style' => array (), 'xml:lang' => array()), 'dl' => array(), 'dt' => array(), 'em' => array(), 'fieldset' => array(), 'font' => array( 'color' => array (), 'face' => array (), 'size' => array ()), 'form' => array( 'action' => array (), 'accept' => array (), 'accept-charset' => array (), 'enctype' => array (), 'method' => array (), 'name' => array (), 'target' => array ()), 'h1' => array( 'align' => array (), 'class' => array ()), 'h2' => array( 'align' => array (), 'class' => array ()), 'h3' => array( 'align' => array (), 'class' => array ()), 'h4' => array( 'align' => array (), 'class' => array ()), 'h5' => array( 'align' => array (), 'class' => array ()), 'h6' => array( 'align' => array (), 'class' => array ()), 'hr' => array( 'align' => array (), 'class' => array (), 'noshade' => array (), 'size' => array (), 'width' => array ()), 'i' => array(), 'img' => array( 'alt' => array (), 'align' => array (), 'border' => array (), 'class' => array (), 'height' => array (), 'hspace' => array (), 'longdesc' => array (), 'vspace' => array (), 'src' => array (), 'style' => array (), 'width' => array ()), 'ins' => array( 'datetime' => array (), 'cite' => array ()), 'kbd' => array(), 'label' => array( 'for' => array ()), 'legend' => array( 'align' => array ()), 'li' => array ( 'align' => array (), 'class' => array ()), 'p' => array( 'class' => array (), 'align' => array (), 'dir' => array(), 'lang' => array(), 'style' => array (), 'xml:lang' => array()), 'pre' => array( 'style' => array(), 'width' => array ()), 'q' => array( 'cite' => array ()), 's' => array(), 'span' => array ( 'class' => array (), 'dir' => array (), 'align' => array (), 'lang' => array (), 'style' => array (), 'title' => array (), 'xml:lang' => array()), 'strike' => array(), 'strong' => array(), 'sub' => array(), 'sup' => array(), 'table' => array( 'align' => array (), 'bgcolor' => array (), 'border' => array (), 'cellpadding' => array (), 'cellspacing' => array (), 'class' => array (), 'dir' => array(), 'id' => array(), 'rules' => array (), 'style' => array (), 'summary' => array (), 'width' => array ()), 'tbody' => array( 'align' => array (), 'char' => array (), 'charoff' => array (), 'valign' => array ()), 'td' => array( 'abbr' => array (), 'align' => array (), 'axis' => array (), 'bgcolor' => array (), 'char' => array (), 'charoff' => array (), 'class' => array (), 'colspan' => array (), 'dir' => array(), 'headers' => array (), 'height' => array (), 'nowrap' => array (), 'rowspan' => array (), 'scope' => array (), 'style' => array (), 'valign' => array (), 'width' => array ()), 'textarea' => array( 'cols' => array (), 'rows' => array (), 'disabled' => array (), 'name' => array (), 'readonly' => array ()), 'tfoot' => array( 'align' => array (), 'char' => array (), 'class' => array (), 'charoff' => array (), 'valign' => array ()), 'th' => array( 'abbr' => array (), 'align' => array (), 'axis' => array (), 'bgcolor' => array (), 'char' => array (), 'charoff' => array (), 'class' => array (), 'colspan' => array (), 'headers' => array (), 'height' => array (), 'nowrap' => array (), 'rowspan' => array (), 'scope' => array (), 'valign' => array (), 'width' => array ()), 'thead' => array( 'align' => array (), 'char' => array (), 'charoff' => array (), 'class' => array (), 'valign' => array ()), 'title' => array(), 'tr' => array( 'align' => array (), 'bgcolor' => array (), 'char' => array (), 'charoff' => array (), 'class' => array (), 'style' => array (), 'valign' => array ()), 'tt' => array(), 'u' => array(), 'ul' => array ( 'class' => array (), 'style' => array (), 'type' => array ()), 'ol' => array ( 'class' => array (), 'start' => array (), 'style' => array (), 'type' => array ()), 'var' => array ()); /** * Kses allowed HTML elements. * * @global array $allowedtags * @since 1.0.0 */ $allowedtags = array( 'a' => array( 'href' => array (), 'title' => array ()), 'abbr' => array( 'title' => array ()), 'acronym' => array( 'title' => array ()), 'b' => array(), 'blockquote' => array( 'cite' => array ()), // 'br' => array(), 'cite' => array (), 'code' => array(), 'del' => array( 'datetime' => array ()), // 'dd' => array(), // 'dl' => array(), // 'dt' => array(), 'em' => array (), 'i' => array (), // 'ins' => array('datetime' => array(), 'cite' => array()), // 'li' => array(), // 'ol' => array(), // 'p' => array(), 'q' => array( 'cite' => array ()), 'strike' => array(), 'strong' => array(), // 'sub' => array(), // 'sup' => array(), // 'u' => array(), // 'ul' => array(), ); } /** * Filters content and keeps only allowable HTML elements. * * This function makes sure that only the allowed HTML element names, attribute * names and attribute values plus only sane HTML entities will occur in * $string. You have to remove any slashes from PHP's magic quotes before you * call this function. * * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news', * 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This covers all common * link protocols, except for 'javascript' which should not be allowed for * untrusted users. * * @since 1.0.0 * * @param string $string Content to filter through kses * @param array $allowed_html List of allowed HTML elements * @param array $allowed_protocols Optional. Allowed protocol in links. * @return string Filtered content with only allowed HTML elements */ function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) { $string = wp_kses_no_null($string); $string = wp_kses_js_entities($string); $string = wp_kses_normalize_entities($string); $allowed_html_fixed = wp_kses_array_lc($allowed_html); $string = wp_kses_hook($string, $allowed_html_fixed, $allowed_protocols); // WP changed the order of these funcs and added args to wp_kses_hook return wp_kses_split($string, $allowed_html_fixed, $allowed_protocols); } /** * You add any kses hooks here. * * There is currently only one kses WordPress hook and it is called here. All * parameters are passed to the hooks and expected to recieve a string. * * @since 1.0.0 * * @param string $string Content to filter through kses * @param array $allowed_html List of allowed HTML elements * @param array $allowed_protocols Allowed protocol in links * @return string Filtered content through 'pre_kses' hook */ function wp_kses_hook($string, $allowed_html, $allowed_protocols) { $string = apply_filters('pre_kses', $string, $allowed_html, $allowed_protocols); return $string; } /** * This function returns kses' version number. * * @since 1.0.0 * * @return string KSES Version Number */ function wp_kses_version() { return '0.2.2'; } /** * Searches for HTML tags, no matter how malformed. * * It also matches stray ">" characters. * * @since 1.0.0 * * @param string $string Content to filter * @param array $allowed_html Allowed HTML elements * @param array $allowed_protocols Allowed protocols to keep * @return string Content with fixed HTML tags */ function wp_kses_split($string, $allowed_html, $allowed_protocols) { global $pass_allowed_html, $pass_allowed_protocols; $pass_allowed_html = $allowed_html; $pass_allowed_protocols = $allowed_protocols; return preg_replace_callback('%((|$))|(<[^>]*(>|$)|>))%', create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string); } /** * Callback for wp_kses_split for fixing malformed HTML tags. * * This function does a lot of work. It rejects some very malformed things like * <:::>. It returns an empty string, if the element isn't allowed (look ma, no * strip_tags()!). Otherwise it splits the tag into an element and an attribute * list. * * After the tag is split into an element and an attribute list, it is run * through another filter which will remove illegal attributes and once that is * completed, will be returned. * * @access private * @since 1.0.0 * @uses wp_kses_attr() * * @param string $string Content to filter * @param array $allowed_html Allowed HTML elements * @param array $allowed_protocols Allowed protocols to keep * @return string Fixed HTML element */ function wp_kses_split2($string, $allowed_html, $allowed_protocols) { $string = wp_kses_stripslashes($string); if (substr($string, 0, 1) != '<') return '>'; # It matched a ">" character if (preg_match('%^)?$%', $string, $matches)) { $string = str_replace(array(''), '', $matches[1]); while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) ) $string = $newstring; if ( $string == '' ) return ''; // prevent multiple dashes in comments $string = preg_replace('/--+/', '-', $string); // prevent three dashes closing a comment $string = preg_replace('/-$/', '', $string); return ""; } # Allow HTML comments if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) return ''; # It's seriously malformed $slash = trim($matches[1]); $elem = $matches[2]; $attrlist = $matches[3]; if (!@isset($allowed_html[strtolower($elem)])) return ''; # They are using a not allowed HTML element if ($slash != '') return "<$slash$elem>"; # No attributes are allowed for closing elements return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols); } /** * Removes all attributes, if none are allowed for this element. * * If some are allowed it calls wp_kses_hair() to split them further, and then * it builds up new HTML code from the data that kses_hair() returns. It also * removes "<" and ">" characters, if there are any left. One more thing it does * is to check if the tag has a closing XHTML slash, and if it does, it puts one * in the returned code as well. * * @since 1.0.0 * * @param string $element HTML element/tag * @param string $attr HTML attributes from HTML element to closing HTML element tag * @param array $allowed_html Allowed HTML elements * @param array $allowed_protocols Allowed protocols to keep * @return string Sanitized HTML element */ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { # Is there a closing XHTML slash at the end of the attributes? $xhtml_slash = ''; if (preg_match('%\s/\s*$%', $attr)) $xhtml_slash = ' /'; # Are any attributes allowed at all for this element? if (@ count($allowed_html[strtolower($element)]) == 0) return "<$element$xhtml_slash>"; # Split it $attrarr = wp_kses_hair($attr, $allowed_protocols); # Go through $attrarr, and save the allowed attributes for this element # in $attr2 $attr2 = ''; foreach ($attrarr as $arreach) { if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])])) continue; # the attribute is not allowed $current = $allowed_html[strtolower($element)][strtolower($arreach['name'])]; if ($current == '') continue; # the attribute is not allowed if (!is_array($current)) $attr2 .= ' '.$arreach['whole']; # there are no checks else { # there are some checks $ok = true; foreach ($current as $currkey => $currval) if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) { $ok = false; break; } if ($ok) $attr2 .= ' '.$arreach['whole']; # it passed them } # if !is_array($current) } # foreach # Remove any "<" or ">" characters $attr2 = preg_replace('/[<>]/', '', $attr2); return "<$element$attr2$xhtml_slash>"; } /** * Builds an attribute list from string containing attributes. * * This function does a lot of work. It parses an attribute list into an array * with attribute data, and tries to do the right thing even if it gets weird * input. It will add quotes around attribute values that don't have any quotes * or apostrophes around them, to make it easier to produce HTML code that will * conform to W3C's HTML specification. It will also remove bad URL protocols * from attribute values. It also reduces duplicate attributes by using the * attribute defined first (foo='bar' foo='baz' will result in foo='bar'). * * @since 1.0.0 * * @param string $attr Attribute list from HTML element to closing HTML element tag * @param array $allowed_protocols Allowed protocols to keep * @return array List of attributes after parsing */ function wp_kses_hair($attr, $allowed_protocols) { $attrarr = array (); $mode = 0; $attrname = ''; $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action'); # Loop through the whole attribute list while (strlen($attr) != 0) { $working = 0; # Was the last operation successful? switch ($mode) { case 0 : # attribute name, href for instance if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) { $attrname = $match[1]; $working = $mode = 1; $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr); } break; case 1 : # equals sign or valueless ("selected") if (preg_match('/^\s*=\s*/', $attr)) # equals sign { $working = 1; $mode = 2; $attr = preg_replace('/^\s*=\s*/', '', $attr); break; } if (preg_match('/^\s+/', $attr)) # valueless { $working = 1; $mode = 0; if(FALSE === array_key_exists($attrname, $attrarr)) { $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); } $attr = preg_replace('/^\s+/', '', $attr); } break; case 2 : # attribute value, a URL after href= for instance if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match)) # "value" { $thisval = $match[1]; if ( in_array($attrname, $uris) ) $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); if(FALSE === array_key_exists($attrname, $attrarr)) { $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); } $working = 1; $mode = 0; $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); break; } if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) # 'value' { $thisval = $match[1]; if ( in_array($attrname, $uris) ) $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); if(FALSE === array_key_exists($attrname, $attrarr)) { $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); } $working = 1; $mode = 0; $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); break; } if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) # value { $thisval = $match[1]; if ( in_array($attrname, $uris) ) $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); if(FALSE === array_key_exists($attrname, $attrarr)) { $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); } # We add quotes to conform to W3C's HTML spec. $working = 1; $mode = 0; $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); } break; } # switch if ($working == 0) # not well formed, remove and try again { $attr = wp_kses_html_error($attr); $mode = 0; } } # while if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr)) # special case, for when the attribute list ends with a valueless # attribute like "selected" $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); return $attrarr; } /** * Performs different checks for attribute values. * * The currently implemented checks are "maxlen", "minlen", "maxval", "minval" * and "valueless" with even more checks to come soon. * * @since 1.0.0 * * @param string $value Attribute value * @param string $vless Whether the value is valueless or not. Use 'y' or 'n' * @param string $checkname What $checkvalue is checking for. * @param mixed $checkvalue What constraint the value should pass * @return bool Whether check passes (true) or not (false) */ function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) { $ok = true; switch (strtolower($checkname)) { case 'maxlen' : # The maxlen check makes sure that the attribute value has a length not # greater than the given value. This can be used to avoid Buffer Overflows # in WWW clients and various Internet servers. if (strlen($value) > $checkvalue) $ok = false; break; case 'minlen' : # The minlen check makes sure that the attribute value has a length not # smaller than the given value. if (strlen($value) < $checkvalue) $ok = false; break; case 'maxval' : # The maxval check does two things: it checks that the attribute value is # an integer from 0 and up, without an excessive amount of zeroes or # whitespace (to avoid Buffer Overflows). It also checks that the attribute # value is not greater than the given value. # This check can be used to avoid Denial of Service attacks. if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) $ok = false; if ($value > $checkvalue) $ok = false; break; case 'minval' : # The minval check checks that the attribute value is a positive integer, # and that it is not smaller than the given value. if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) $ok = false; if ($value < $checkvalue) $ok = false; break; case 'valueless' : # The valueless check checks if the attribute has a value # (like ) or not ($term->name"; if ( $links ) $taxonomies[$taxonomy] = wp_sprintf($t['template'], $t['label'], $links, $terms); } return $taxonomies; } /** * Retrieve all taxonomies of a post with just the names. * * @since 2.5.0 * @uses get_object_taxonomies() * * @param int $post Optional. Post ID * @return array */ function get_post_taxonomies($post = 0) { $post =& get_post($post); return get_object_taxonomies($post); } /** * Determine if the given object is associated with any of the given terms. * * The given terms are checked against the object's terms' term_ids, names and slugs. * Terms given as integers will only be checked against the object's terms' term_ids. * If no terms are given, determines if object is associated with any terms in the given taxonomy. * * @since 2.7.0 * @uses get_object_term_cache() * @uses wp_get_object_terms() * * @param int $object_id. ID of the object (post ID, link ID, ...) * @param string $taxonomy. Single taxonomy name * @param int|string|array $terms Optional. Term term_id, name, slug or array of said * @return bool|WP_Error. WP_Error on input error. */ function is_object_in_term( $object_id, $taxonomy, $terms = null ) { if ( !$object_id = (int) $object_id ) return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) ); $object_terms = get_object_term_cache( $object_id, $taxonomy ); if ( empty( $object_terms ) ) $object_terms = wp_get_object_terms( $object_id, $taxonomy ); if ( is_wp_error( $object_terms ) ) return $object_terms; if ( empty( $object_terms ) ) return false; if ( empty( $terms ) ) return ( !empty( $object_terms ) ); $terms = (array) $terms; if ( $ints = array_filter( $terms, 'is_int' ) ) $strs = array_diff( $terms, $ints ); else $strs =& $terms; foreach ( $object_terms as $object_term ) { if ( $ints && in_array( $object_term->term_id, $ints ) ) return true; // If int, check against term_id if ( $strs ) { if ( in_array( $object_term->term_id, $strs ) ) return true; if ( in_array( $object_term->name, $strs ) ) return true; if ( in_array( $object_term->slug, $strs ) ) return true; } } return false; } ?> waterwise-wp/wp-includes/general-template.php0000644000103300000410000017255611126465001021515 0ustar robertwww-data
'; echo apply_filters('get_search_form', $form); } /** * Display the Log In/Out link. * * Displays a link, which allows the user to navigate to the Log In page to log in * or log out depending on whether or not they are currently logged in. * * @since 1.5.0 * @uses apply_filters() Calls 'loginout' hook on HTML link content. */ function wp_loginout() { if ( ! is_user_logged_in() ) $link = '' . __('Log in') . ''; else $link = '' . __('Log out') . ''; echo apply_filters('loginout', $link); } /** * Returns the Log Out URL. * * Returns the URL that allows the user to log out of the site * * @since 2.7 * @uses wp_nonce_url() To protect against CSRF * @uses site_url() To generate the log in URL * * @param string $redirect Path to redirect to on logout. */ function wp_logout_url($redirect = '') { if ( strlen($redirect) ) $redirect = "&redirect_to=$redirect"; return wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); } /** * Returns the Log In URL. * * Returns the URL that allows the user to log in to the site * * @since 2.7 * @uses site_url() To generate the log in URL * * @param string $redirect Path to redirect to on login. */ function wp_login_url($redirect = '') { if ( strlen($redirect) ) $redirect = "?redirect_to=$redirect"; return site_url("wp-login.php$redirect", 'login'); } /** * Display the Registration or Admin link. * * Display a link which allows the user to navigate to the registration page if * not logged in and registration is enabled or to the dashboard if logged in. * * @since 1.5.0 * @uses apply_filters() Calls 'register' hook on register / admin link content. * * @param string $before Text to output before the link (defaults to
  • ). * @param string $after Text to output after the link (defaults to
  • ). */ function wp_register( $before = '
  • ', $after = '
  • ' ) { if ( ! is_user_logged_in() ) { if ( get_option('users_can_register') ) $link = $before . '' . __('Register') . '' . $after; else $link = ''; } else { $link = $before . '' . __('Site Admin') . '' . $after; } echo apply_filters('register', $link); } /** * Theme container function for the 'wp_meta' action. * * The 'wp_meta' action can have several purposes, depending on how you use it, * but one purpose might have been to allow for theme switching. * * @since 1.5.0 * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action. * @uses do_action() Calls 'wp_meta' hook. */ function wp_meta() { do_action('wp_meta'); } /** * Display information about the blog. * * @see get_bloginfo() For possible values for the parameter. * @since 0.71 * * @param string $show What to display. */ function bloginfo($show='') { echo get_bloginfo($show, 'display'); } /** * Retrieve information about the blog. * * Some show parameter values are deprecated and will be removed in future * versions. Care should be taken to check the function contents and know what * the deprecated blog info options are. Options without "// DEPRECATED" are * the preferred and recommended ways to get the information. * * The possible values for the 'show' parameter are listed below. *
      *
    1. url - Blog URI to homepage.
    2. *
    3. wpurl - Blog URI path to WordPress.
    4. *
    5. description - Secondary title
    6. *
    * * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91), * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment * feed) or 'comments_rss2_url' (RSS 2.0 comment feed). * * There are many other options and you should check the function contents: * {@source 32 37} * * @since 0.71 * * @param string $show Blog info to retrieve. * @param string $filter How to filter what is retrieved. * @return string Mostly string values, might be empty. */ function get_bloginfo($show = '', $filter = 'raw') { switch($show) { case 'url' : case 'home' : // DEPRECATED case 'siteurl' : // DEPRECATED $output = get_option('home'); break; case 'wpurl' : $output = get_option('siteurl'); break; case 'description': $output = get_option('blogdescription'); break; case 'rdf_url': $output = get_feed_link('rdf'); break; case 'rss_url': $output = get_feed_link('rss'); break; case 'rss2_url': $output = get_feed_link('rss2'); break; case 'atom_url': $output = get_feed_link('atom'); break; case 'comments_atom_url': $output = get_feed_link('comments_atom'); break; case 'comments_rss2_url': $output = get_feed_link('comments_rss2'); break; case 'pingback_url': $output = get_option('siteurl') .'/xmlrpc.php'; break; case 'stylesheet_url': $output = get_stylesheet_uri(); break; case 'stylesheet_directory': $output = get_stylesheet_directory_uri(); break; case 'template_directory': case 'template_url': $output = get_template_directory_uri(); break; case 'admin_email': $output = get_option('admin_email'); break; case 'charset': $output = get_option('blog_charset'); if ('' == $output) $output = 'UTF-8'; break; case 'html_type' : $output = get_option('html_type'); break; case 'version': global $wp_version; $output = $wp_version; break; case 'language': $output = get_locale(); $output = str_replace('_', '-', $output); break; case 'text_direction': global $wp_locale; $output = $wp_locale->text_direction; break; case 'name': default: $output = get_option('blogname'); break; } $url = true; if (strpos($show, 'url') === false && strpos($show, 'directory') === false && strpos($show, 'home') === false) $url = false; if ( 'display' == $filter ) { if ( $url ) $output = apply_filters('bloginfo_url', $output, $show); else $output = apply_filters('bloginfo', $output, $show); } return $output; } /** * Display or retrieve page title for all areas of blog. * * By default, the page title will display the separator before the page title, * so that the blog title will be before the page title. This is not good for * title display, since the blog title shows up on most tabs and not what is * important, which is the page that the user is looking at. * * There are also SEO benefits to having the blog title after or to the 'right' * or the page title. However, it is mostly common sense to have the blog title * to the right with most browsers supporting tabs. You can achieve this by * using the seplocation parameter and setting the value to 'right'. This change * was introduced around 2.5.0, in case backwards compatibility of themes is * important. * * @since 1.0.0 * * @param string $sep Optional, default is '»'. How to separate the various items within the page title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @param string $seplocation Optional. Direction to display title, 'right'. * @return string|null String on retrieve, null when displaying. */ function wp_title($sep = '»', $display = true, $seplocation = '') { global $wpdb, $wp_locale, $wp_query; $cat = get_query_var('cat'); $tag = get_query_var('tag_id'); $category_name = get_query_var('category_name'); $author = get_query_var('author'); $author_name = get_query_var('author_name'); $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); $day = get_query_var('day'); $title = ''; $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary // If there's a category if ( !empty($cat) ) { // category exclusion if ( !stristr($cat,'-') ) $title = apply_filters('single_cat_title', get_the_category_by_ID($cat)); } elseif ( !empty($category_name) ) { if ( stristr($category_name,'/') ) { $category_name = explode('/',$category_name); if ( $category_name[count($category_name)-1] ) $category_name = $category_name[count($category_name)-1]; // no trailing slash else $category_name = $category_name[count($category_name)-2]; // there was a trailling slash } $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display'); if ( $cat ) $title = apply_filters('single_cat_title', $cat->name); } if ( !empty($tag) ) { $tag = get_term($tag, 'post_tag', OBJECT, 'display'); if ( is_wp_error( $tag ) ) return $tag; if ( ! empty($tag->name) ) $title = apply_filters('single_tag_title', $tag->name); } // If there's an author if ( !empty($author) ) { $title = get_userdata($author); $title = $title->display_name; } if ( !empty($author_name) ) { // We do a direct query here because we don't cache by nicename. $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); } // If there's a month if ( !empty($m) ) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); $my_day = intval(substr($m, 6, 2)); $title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : ""); } if ( !empty($year) ) { $title = $year; if ( !empty($monthnum) ) $title .= "$t_sep" . $wp_locale->get_month($monthnum); if ( !empty($day) ) $title .= "$t_sep" . zeroise($day, 2); } // If there is a post if ( is_single() || ( is_page() && !is_front_page() ) ) { $post = $wp_query->get_queried_object(); $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) ); } // If there's a taxonomy if ( is_tax() ) { $taxonomy = get_query_var( 'taxonomy' ); $tax = get_taxonomy( $taxonomy ); $tax = $tax->label; $term = $wp_query->get_queried_object(); $term = $term->name; $title = "$tax$t_sep$term"; } if ( is_404() ) { $title = __('Page not found'); } $prefix = ''; if ( !empty($title) ) $prefix = " $sep "; // Determines position of the separator and direction of the breadcrumb if ( 'right' == $seplocation ) { // sep on right, so reverse the order $title_array = explode( $t_sep, $title ); $title_array = array_reverse( $title_array ); $title = implode( " $sep ", $title_array ) . $prefix; } else { $title_array = explode( $t_sep, $title ); $title = $prefix . implode( " $sep ", $title_array ); } $title = apply_filters('wp_title', $title, $sep, $seplocation); // Send it out if ( $display ) echo $title; else return $title; } /** * Display or retrieve page title for post. * * This is optimized for single.php template file for displaying the post title. * Only useful for posts, does not support pages for example. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 0.71 * @uses $wpdb * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_post_title($prefix = '', $display = true) { global $wpdb; $p = get_query_var('p'); $name = get_query_var('name'); if ( intval($p) || '' != $name ) { if ( !$p ) $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name)); $post = & get_post($p); $title = $post->post_title; $title = apply_filters('single_post_title', $title); if ( $display ) echo $prefix.strip_tags($title); else return strip_tags($title); } } /** * Display or retrieve page title for category archive. * * This is useful for category template file or files, because it is optimized * for category page title and with less overhead than {@link wp_title()}. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 0.71 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_cat_title($prefix = '', $display = true ) { $cat = intval( get_query_var('cat') ); if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) { $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat)); if ( !empty($my_cat_name) ) { if ( $display ) echo $prefix.strip_tags($my_cat_name); else return strip_tags($my_cat_name); } } else if ( is_tag() ) { return single_tag_title($prefix, $display); } } /** * Display or retrieve page title for tag post archive. * * Useful for tag template files for displaying the tag page title. It has less * overhead than {@link wp_title()}, because of its limited implementation. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 2.3.0 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_tag_title($prefix = '', $display = true ) { if ( !is_tag() ) return; $tag_id = intval( get_query_var('tag_id') ); if ( !empty($tag_id) ) { $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); if ( is_wp_error( $my_tag ) ) return false; $my_tag_name = apply_filters('single_tag_title', $my_tag->name); if ( !empty($my_tag_name) ) { if ( $display ) echo $prefix . $my_tag_name; else return $my_tag_name; } } } /** * Display or retrieve page title for post archive based on date. * * Useful for when the template only needs to display the month and year, if * either are available. Optimized for just this purpose, so if it is all that * is needed, should be better than {@link wp_title()}. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 0.71 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_month_title($prefix = '', $display = true ) { global $wp_locale; $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); if ( !empty($monthnum) && !empty($year) ) { $my_year = $year; $my_month = $wp_locale->get_month($monthnum); } elseif ( !empty($m) ) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); } if ( empty($my_month) ) return false; $result = $prefix . $my_month . $prefix . $my_year; if ( !$display ) return $result; echo $result; } /** * Retrieve archive link content based on predefined or custom code. * * The format can be one of four styles. The 'link' for head element, 'option' * for use in the select element, 'html' for use in list (either ol or ul HTML * elements). Custom content is also supported using the before and after * parameters. * * The 'link' format uses the link HTML element with the archives * relationship. The before and after parameters are not used. The text * parameter is used to describe the link. * * The 'option' format uses the option HTML element for use in select element. * The value is the url parameter and the before and after parameters are used * between the text description. * * The 'html' format, which is the default, uses the li HTML element for use in * the list HTML elements. The before parameter is before the link and the after * parameter is after the closing link. * * The custom format uses the before parameter before the link ('a' HTML * element) and the after parameter after the closing link tag. If the above * three values for the format are not used, then custom format is assumed. * * @since 1.0.0 * @author Orien * @link http://icecode.com/ link navigation hack by Orien * * @param string $url URL to archive. * @param string $text Archive text description. * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom. * @param string $before Optional. * @param string $after Optional. * @return string HTML link content for archive. */ function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { $text = wptexturize($text); $title_text = attribute_escape($text); $url = clean_url($url); if ('link' == $format) $link_html = "\t\n"; elseif ('option' == $format) $link_html = "\t\n"; elseif ('html' == $format) $link_html = "\t
  • $before$text$after
  • \n"; else // custom $link_html = "\t$before$text$after\n"; $link_html = apply_filters( "get_archives_link", $link_html ); return $link_html; } /** * Display archive links based on type and format. * * The 'type' argument offers a few choices and by default will display monthly * archive links. The other options for values are 'daily', 'weekly', 'monthly', * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the * same archive link list, the difference between the two is that 'alpha' * will order by post title and 'postbypost' will order by post date. * * The date archives will logically display dates with links to the archive post * page. The 'postbypost' and 'alpha' values for 'type' argument will display * the post titles. * * The 'limit' argument will only display a limited amount of links, specified * by the 'limit' integer value. By default, there is no limit. The * 'show_post_count' argument will show how many posts are within the archive. * By default, the 'show_post_count' argument is set to false. * * For the 'format', 'before', and 'after' arguments, see {@link * get_archives_link()}. The values of these arguments have to do with that * function. * * @since 1.2.0 * * @param string|array $args Optional. Override defaults. */ function wp_get_archives($args = '') { global $wpdb, $wp_locale; $defaults = array( 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( '' == $type ) $type = 'monthly'; if ( '' != $limit ) { $limit = absint($limit); $limit = ' LIMIT '.$limit; } // this is what will separate dates on weekly archive links $archive_week_separator = '–'; // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride $archive_date_format_over_ride = 0; // options for daily archive (only if you over-ride the general date format) $archive_day_date_format = 'Y/m/d'; // options for weekly archive (only if you over-ride the general date format) $archive_week_start_date_format = 'Y/m/d'; $archive_week_end_date_format = 'Y/m/d'; if ( !$archive_date_format_over_ride ) { $archive_day_date_format = get_option('date_format'); $archive_week_start_date_format = get_option('date_format'); $archive_week_end_date_format = get_option('date_format'); } //filters $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); $join = apply_filters('getarchives_join', "", $r); $output = ''; if ( 'monthly' == $type ) { $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult ) { $url = get_month_link( $arcresult->year, $arcresult->month ); $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); if ( $show_post_count ) $after = ' ('.$arcresult->posts.')' . $afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } elseif ('yearly' == $type) { $query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ($arcresults) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult) { $url = get_year_link($arcresult->year); $text = sprintf('%d', $arcresult->year); if ($show_post_count) $after = ' ('.$arcresult->posts.')' . $afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } elseif ( 'daily' == $type ) { $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult ) { $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth); $text = mysql2date($archive_day_date_format, $date); if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } elseif ( 'weekly' == $type ) { $start_of_week = get_option('start_of_week'); $query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } $arc_w_last = ''; $afterafter = $after; if ( $arcresults ) { foreach ( (array) $arcresults as $arcresult ) { if ( $arcresult->week != $arc_w_last ) { $arc_year = $arcresult->yr; $arc_w_last = $arcresult->week; $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week')); $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); $text = $arc_week_start . $archive_week_separator . $arc_week_end; if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC "; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { foreach ( (array) $arcresults as $arcresult ) { if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { $url = get_permalink($arcresult); $arc_title = $arcresult->post_title; if ( $arc_title ) $text = strip_tags(apply_filters('the_title', $arc_title)); else $text = $arcresult->ID; $output .= get_archives_link($url, $text, $format, $before, $after); } } } } if ( $echo ) echo $output; else return $output; } /** * Get number of days since the start of the week. * * @since 1.5.0 * @usedby get_calendar() * * @param int $num Number of day. * @return int Days since the start of the week. */ function calendar_week_mod($num) { $base = 7; return ($num - $base*floor($num/$base)); } /** * Display calendar with days that have posts as links. * * The calendar is cached, which will be retrieved, if it exists. If there are * no posts for the month, then it will not be displayed. * * @since 1.0.0 * * @param bool $initial Optional, default is true. Use initial calendar names. */ function get_calendar($initial = true) { global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; $key = md5( $m . $monthnum . $year ); if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) { if ( isset( $cache[ $key ] ) ) { echo $cache[ $key ]; return; } } ob_start(); // Quick check. If we have no posts at all, abort! if ( !$posts ) { $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); if ( !$gotsome ) return; } if ( isset($_GET['w']) ) $w = ''.intval($_GET['w']); // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); // Let's figure out when we are if ( !empty($monthnum) && !empty($year) ) { $thismonth = ''.zeroise(intval($monthnum), 2); $thisyear = ''.intval($year); } elseif ( !empty($w) ) { // We need to get the month from MySQL $thisyear = ''.intval(substr($m, 0, 4)); $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); } elseif ( !empty($m) ) { $thisyear = ''.intval(substr($m, 0, 4)); if ( strlen($m) < 6 ) $thismonth = '01'; else $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); } else { $thisyear = gmdate('Y', current_time('timestamp')); $thismonth = gmdate('m', current_time('timestamp')); } $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); // Get the next and previous month and year with at least one post $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date < '$thisyear-$thismonth-01' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date > '$thisyear-$thismonth-01' AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date ASC LIMIT 1"); echo ''; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); echo "\n\t\t"; } echo ' '; if ( $previous ) { echo "\n\t\t".''; } else { echo "\n\t\t".''; } echo "\n\t\t".''; if ( $next ) { echo "\n\t\t".''; } else { echo "\n\t\t".''; } echo ' '; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' AND YEAR(post_date) = '$thisyear' AND post_type = 'post' AND post_status = 'publish' AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); if ( $dayswithposts ) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } } else { $daywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) $ak_title_separator = "\n"; else $ak_title_separator = ', '; $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts " ."WHERE YEAR(post_date) = '$thisyear' " ."AND MONTH(post_date) = '$thismonth' " ."AND post_date < '".current_time('mysql')."' " ."AND post_type = 'post' AND post_status = 'publish'" ); if ( $ak_post_titles ) { foreach ( (array) $ak_post_titles as $ak_post_title ) { $post_title = apply_filters( "the_title", $ak_post_title->post_title ); $post_title = str_replace('"', '"', wptexturize( $post_title )); if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one $ak_titles_for_day["$ak_post_title->dom"] = $post_title; else $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; } } // See how much we should pad in the beginning $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); if ( 0 != $pad ) echo "\n\t\t".''; $daysinmonth = intval(date('t', $unixmonth)); for ( $day = 1; $day <= $daysinmonth; ++$day ) { if ( isset($newrow) && $newrow ) echo "\n\t\n\t\n\t\t"; $newrow = false; if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) echo ''; if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) $newrow = true; } $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); if ( $pad != 0 && $pad != 7 ) echo "\n\t\t".''; echo "\n\t\n\t\n\t
    ' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '
    $day_name
    « ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '  ' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' » 
     
    '; else echo ''; if ( in_array($day, $daywithpost) ) // any posts today? echo '$day"; else echo $day; echo ' 
    "; $output = ob_get_contents(); ob_end_clean(); echo $output; $cache[ $key ] = $output; wp_cache_set( 'get_calendar', $cache, 'calendar' ); } /** * Purge the cached results of get_calendar. * * @see get_calendar * @since 2.1.0 */ function delete_get_calendar_cache() { wp_cache_delete( 'get_calendar', 'calendar' ); } add_action( 'save_post', 'delete_get_calendar_cache' ); add_action( 'delete_post', 'delete_get_calendar_cache' ); add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); /** * Display all of the allowed tags in HTML format with attributes. * * This is useful for displaying in the comment area, which elements and * attributes are supported. As well as any plugins which want to display it. * * @since 1.0.1 * @uses $allowedtags * * @return string HTML allowed tags entity encoded. */ function allowed_tags() { global $allowedtags; $allowed = ''; foreach ( (array) $allowedtags as $tag => $attributes ) { $allowed .= '<'.$tag; if ( 0 < count($attributes) ) { foreach ( $attributes as $attribute => $limits ) { $allowed .= ' '.$attribute.'=""'; } } $allowed .= '> '; } return htmlentities($allowed); } /***** Date/Time tags *****/ /** * Outputs the date in iso8601 format for xml files. * * @since 1.0.0 */ function the_date_xml() { global $post; echo mysql2date('Y-m-d', $post->post_date); } /** * Display or Retrieve the date the post was written. * * Will only output the date if the current post's date is different from the * previous one output. * * @since 0.71 * * @param string $d Optional. PHP date format defaults to the date_format option if not specified. * @param string $before Optional. Output before the date. * @param string $after Optional. Output after the date. * @param bool $echo Optional, default is display. Whether to echo the date or return it. * @return string|null Null if displaying, string if retrieving. */ function the_date($d='', $before='', $after='', $echo = true) { global $post, $day, $previousday; $the_date = ''; if ( $day != $previousday ) { $the_date .= $before; if ( $d=='' ) $the_date .= mysql2date(get_option('date_format'), $post->post_date); else $the_date .= mysql2date($d, $post->post_date); $the_date .= $after; $previousday = $day; } $the_date = apply_filters('the_date', $the_date, $d, $before, $after); if ( $echo ) echo $the_date; else return $the_date; } /** * Display the date on which the post was last modified. * * @since 2.1.0 * * @param string $d Optional. PHP date format. * @return string */ function the_modified_date($d = '') { echo apply_filters('the_modified_date', get_the_modified_date($d), $d); } /** * Retrieve the date on which the post was last modified. * * @since 2.1.0 * * @param string $d Optional. PHP date format. Defaults to the "date_format" option * @return string */ function get_the_modified_date($d = '') { if ( '' == $d ) $the_time = get_post_modified_time(get_option('date_format')); else $the_time = get_post_modified_time($d); return apply_filters('get_the_modified_date', $the_time, $d); } /** * Display the time at which the post was written. * * @since 0.71 * * @param string $d Either 'G', 'U', or php date format. */ function the_time( $d = '' ) { echo apply_filters('the_time', get_the_time( $d ), $d); } /** * Retrieve the time at which the post was written. * * @since 1.5.0 * * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option. * @param int|object $post Optional post ID or object. Default is global $post object. * @return string */ function get_the_time( $d = '', $post = null ) { $post = get_post($post); if ( '' == $d ) $the_time = get_post_time(get_option('time_format'), false, $post); else $the_time = get_post_time($d, false, $post); return apply_filters('get_the_time', $the_time, $d, $post); } /** * Retrieve the time at which the post was written. * * @since 2.0.0 * * @param string $d Either 'G', 'U', or php date format. * @param bool $gmt Whether of not to return the gmt time. * @param int|object $post Optional post ID or object. Default is global $post object. * @return string */ function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp $post = get_post($post); if ( $gmt ) $time = $post->post_date_gmt; else $time = $post->post_date; $time = mysql2date($d, $time); return apply_filters('get_post_time', $time, $d, $gmt); } /** * Display the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option. */ function the_modified_time($d = '') { echo apply_filters('the_modified_time', get_the_modified_time($d), $d); } /** * Retrieve the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option. * @return string */ function get_the_modified_time($d = '') { if ( '' == $d ) $the_time = get_post_modified_time(get_option('time_format')); else $the_time = get_post_modified_time($d); return apply_filters('get_the_modified_time', $the_time, $d); } /** * Retrieve the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Either 'G', 'U', or php date format. * @param bool $gmt Whether of not to return the gmt time. * @return string Returns timestamp */ function get_post_modified_time( $d = 'U', $gmt = false ) { global $post; if ( $gmt ) $time = $post->post_modified_gmt; else $time = $post->post_modified; $time = mysql2date($d, $time); return apply_filters('get_the_modified_time', $time, $d, $gmt); } /** * Display the weekday on which the post was written. * * @since 0.71 * @uses $wp_locale * @uses $post */ function the_weekday() { global $wp_locale, $post; $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date)); $the_weekday = apply_filters('the_weekday', $the_weekday); echo $the_weekday; } /** * Display the weekday on which the post was written. * * Will only output the weekday if the current post's weekday is different from * the previous one output. * * @since 0.71 * * @param string $before output before the date. * @param string $after output after the date. */ function the_weekday_date($before='',$after='') { global $wp_locale, $post, $day, $previousweekday; $the_weekday_date = ''; if ( $day != $previousweekday ) { $the_weekday_date .= $before; $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date)); $the_weekday_date .= $after; $previousweekday = $day; } $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); echo $the_weekday_date; } /** * Fire the wp_head action * * @since 1.2.0 * @uses do_action() Calls 'wp_head' hook. */ function wp_head() { do_action('wp_head'); } /** * Fire the wp_footer action * * @since 1.5.1 * @uses do_action() Calls 'wp_footer' hook. */ function wp_footer() { do_action('wp_footer'); } /** * Display the link to the Really Simple Discovery service endpoint. * * @link http://archipelago.phrasewise.com/rsd * @since 2.0.0 */ function rsd_link() { echo '\n"; } /** * Display the link to the Windows Live Writer manifest file. * * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx * @since 2.3.1 */ function wlwmanifest_link() { echo ' ' . "\n"; } /** * Display a noindex meta tag if required by the blog configuration. * * If a blog is marked as not being public then the noindex meta tag will be * output to tell web robots not to index the page content. * * @since 2.1.0 */ function noindex() { // If the blog is not public, tell robots to go away. if ( '0' == get_option('blog_public') ) echo "\n"; } /** * Determine if TinyMCE is available. * * Checks to see if the user has deleted the tinymce files to slim down there WordPress install. * * @since 2.1.0 * * @return bool Whether of not TinyMCE exists. */ function rich_edit_exists() { global $wp_rich_edit_exists; if ( !isset($wp_rich_edit_exists) ) $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js'); return $wp_rich_edit_exists; } /** * Whether or not the user should have a WYSIWIG editor. * * Checks that the user requires a WYSIWIG editor and that the editor is * supported in the users browser. * * @since 2.0.0 * * @return bool */ function user_can_richedit() { global $wp_rich_edit, $pagenow; if ( !isset( $wp_rich_edit) ) { if ( get_user_option( 'rich_editing' ) == 'true' && ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) && 'comment.php' != $pagenow ) { $wp_rich_edit = true; } else { $wp_rich_edit = false; } } return apply_filters('user_can_richedit', $wp_rich_edit); } /** * Find out which editor should be displayed by default. * * Works out which of the two editors to display as the current editor for a * user. * * @since 2.5.0 * * @return string Either 'tinymce', or 'html', or 'test' */ function wp_default_editor() { $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults if ( $user = wp_get_current_user() ) { // look for cookie $ed = get_user_setting('editor', 'tinymce'); $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; } return apply_filters( 'wp_default_editor', $r ); // filter } /** * Display visual editor forms: TinyMCE, or HTML, or both. * * The amount of rows the text area will have for the content has to be between * 3 and 100 or will default at 12. There is only one option used for all users, * named 'default_post_edit_rows'. * * If the user can not use the rich editor (TinyMCE), then the switch button * will not be displayed. * * @since 2.1.0 * * @param string $content Textarea content. * @param string $id HTML ID attribute value. * @param string $prev_id HTML ID name for switching back and forth between visual editors. * @param bool $media_buttons Optional, default is true. Whether to display media buttons. * @param int $tab_index Optional, default is 2. Tabindex for textarea element. */ function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) { $rows = get_option('default_post_edit_rows'); if (($rows < 3) || ($rows > 100)) $rows = 12; if ( !current_user_can( 'upload_files' ) ) $media_buttons = false; $richedit = user_can_richedit(); $rows = "rows='$rows'"; if ( $richedit || $media_buttons ) { ?>
    \n"); $the_editor_content = apply_filters('the_editor_content', $content); printf($the_editor, $the_editor_content); ?> '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number 'total' => 1, 'current' => 0, 'show_all' => false, 'prev_next' => true, 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'end_size' => 1, 'mid_size' => 2, 'type' => 'plain', 'add_args' => false, // array of query args to add 'add_fragment' => '' ); $args = wp_parse_args( $args, $defaults ); extract($args, EXTR_SKIP); // Who knows what else people pass in $args $total = (int) $total; if ( $total < 2 ) return; $current = (int) $current; $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default. $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2; $add_args = is_array($add_args) ? $add_args : false; $r = ''; $page_links = array(); $n = 0; $dots = false; if ( $prev_next && $current && 1 < $current ) : $link = str_replace('%_%', 2 == $current ? '' : $format, $base); $link = str_replace('%#%', $current - 1, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $link .= $add_fragment; $page_links[] = ""; endif; for ( $n = 1; $n <= $total; $n++ ) : $n_display = number_format_i18n($n); if ( $n == $current ) : $page_links[] = "$n_display"; $dots = true; else : if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : $link = str_replace('%_%', 1 == $n ? '' : $format, $base); $link = str_replace('%#%', $n, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $link .= $add_fragment; $page_links[] = "$n_display"; $dots = true; elseif ( $dots && !$show_all ) : $page_links[] = "..."; $dots = false; endif; endif; endfor; if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) : $link = str_replace('%_%', $format, $base); $link = str_replace('%#%', $current + 1, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $link .= $add_fragment; $page_links[] = ""; endif; switch ( $type ) : case 'array' : return $page_links; break; case 'list' : $r .= "
      \n\t
    • "; $r .= join("
    • \n\t
    • ", $page_links); $r .= "
    • \n
    \n"; break; default : $r = join("\n", $page_links); break; endswitch; return $r; } /** * Registers an admin colour scheme css file. * * Allows a plugin to register a new admin colour scheme. For example: * * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"), * array('#07273E', '#14568A', '#D54E21', '#2683AE')); * * * @since 2.5.0 * * @param string $key The unique key for this theme. * @param string $name The name of the theme. * @param string $url The url of the css file containing the colour scheme. * @param array @colors An array of CSS color definitions which are used to give the user a feel for the theme. */ function wp_admin_css_color($key, $name, $url, $colors = array()) { global $_wp_admin_css_colors; if ( !isset($_wp_admin_css_colors) ) $_wp_admin_css_colors = array(); $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors); } /** * Display the URL of a WordPress admin CSS file. * * @see WP_Styles::_css_href and its style_loader_src filter. * * @since 2.3.0 * * @param string $file file relative to wp-admin/ without its ".css" extension. */ function wp_admin_css_uri( $file = 'wp-admin' ) { if ( defined('WP_INSTALLING') ) { $_file = "./$file.css"; } else { $_file = admin_url("$file.css"); } $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); return apply_filters( 'wp_admin_css_uri', $_file, $file ); } /** * Enqueues or directly prints a stylesheet link to the specified CSS file. * * "Intelligently" decides to enqueue or to print the CSS file. If the * 'wp_print_styles' action has *not* yet been called, the CSS file will be * enqueued. If the wp_print_styles action *has* been called, the CSS link will * be printed. Printing may be forced by passing TRUE as the $force_echo * (second) parameter. * * For backward compatibility with WordPress 2.3 calling method: If the $file * (first) parameter does not correspond to a registered CSS file, we assume * $file is a file relative to wp-admin/ without its ".css" extension. A * stylesheet link to that generated URL is printed. * * @package WordPress * @since 2.3.0 * @uses $wp_styles WordPress Styles Object * * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/ * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. */ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { global $wp_styles; if ( !is_a($wp_styles, 'WP_Styles') ) $wp_styles = new WP_Styles(); // For backward compatibility $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; if ( $wp_styles->query( $handle ) ) { if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately wp_print_styles( $handle ); else // Add to style queue wp_enqueue_style( $handle ); return; } echo apply_filters( 'wp_admin_css', "\n", $file ); if ( 'rtl' == get_bloginfo( 'text_direction' ) ) echo apply_filters( 'wp_admin_css', "\n", "$file-rtl" ); } /** * Enqueues the default ThickBox js and css. * * If any of the settings need to be changed, this can be done with another js * file similar to media-upload.js and theme-preview.js. That file should * require array('thickbox') to ensure it is loaded after. * * @since 2.5.0 */ function add_thickbox() { wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' ); } /** * Display the XHTML generator that is generated on the wp_head hook. * * @since 2.5.0 */ function wp_generator() { the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); } /** * Display the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators overall the the_generator filter. * * @since 2.5.0 * @uses apply_filters() Calls 'the_generator' hook. * * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export). */ function the_generator( $type ) { echo apply_filters('the_generator', get_the_generator($type), $type) . "\n"; } /** * Creates the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators on an individual basis using the * 'get_the_generator_{$type}' filter. * * @since 2.5.0 * @uses apply_filters() Calls 'get_the_generator_$type' hook. * * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). * @return string The HTML content for the generator. */ function get_the_generator( $type ) { switch ($type) { case 'html': $gen = '' . "\n"; break; case 'xhtml': $gen = '' . "\n"; break; case 'atom': $gen = 'WordPress'; break; case 'rss2': $gen = 'http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . ''; break; case 'rdf': $gen = ''; break; case 'comment': $gen = ''; break; case 'export': $gen = ''; break; } return apply_filters( "get_the_generator_{$type}", $gen, $type ); } ?> waterwise-wp/wp-includes/js/0000775000103300000410000000000011144353006016155 5ustar