/** * WordPress Rewrite API * * @package WordPress * @subpackage Rewrite */ /** * Add a straight rewrite rule. * * @see WP_Rewrite::add_rule() for long description. * @since 2.1.0 * * @param string $regex Regular Expression to match request against. * @param string $redirect Page to redirect to. * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'. */ function add_rewrite_rule($regex, $redirect, $after = 'bottom') { global $wp_rewrite; $wp_rewrite->add_rule($regex, $redirect, $after); } /** * Add a new rewrite tag (like %postname%). * * The $query parameter is optional. If it is omitted you must ensure that * you call this on, or before, the 'init' hook. This is because $query defaults * to "$tag=", and for this to work a new query var has to be added. * * @see WP_Rewrite::add_rewrite_tag() * @since 2.1.0 * * @param string $tag Name of the new rewrite tag. * @param string $regex Regular expression to substitute the tag for in rewrite rules. * @param string $query String to append to the rewritten query. Must end in '='. Optional. */ function add_rewrite_tag( $tag, $regex, $query = '' ) { // validate the tag's name if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' ) return; global $wp_rewrite, $wp; if ( empty( $query ) ) { $qv = trim( $tag, '%' ); $wp->add_query_var( $qv ); $query = $qv . '='; } $wp_rewrite->add_rewrite_tag( $tag, $regex, $query ); } /** * Add permalink structure. * * @see WP_Rewrite::add_permastruct() * @since 3.0.0 * * @param string $name Name for permalink structure. * @param string $struct Permalink structure. * @param array $args Optional configuration for building the rules from the permalink structure, * see {@link WP_Rewrite::add_permastruct()} for full details. */ function add_permastruct( $name, $struct, $args = array() ) { global $wp_rewrite; // backwards compatibility for the old parameters: $with_front and $ep_mask if ( ! is_array( $args ) ) $args = array( 'with_front' => $args ); if ( func_num_args() == 4 ) $args['ep_mask'] = func_get_arg( 3 ); return $wp_rewrite->add_permastruct( $name, $struct, $args ); } /** * Add a new feed type like /atom1/. * * @since 2.1.0 * * @param string $feedname * @param callback $function Callback to run on feed display. * @return string Feed action name. */ function add_feed($feedname, $function) { global $wp_rewrite; if ( ! in_array($feedname, $wp_rewrite->feeds) ) //override the file if it is $wp_rewrite->feeds[] = $feedname; $hook = 'do_feed_' . $feedname; // Remove default function hook remove_action($hook, $hook); add_action($hook, $function, 10, 1); return $hook; } /** * Remove rewrite rules and then recreate rewrite rules. * * @see WP_Rewrite::flush_rules() * @since 3.0.0 * * @param bool $hard Whether to update .htaccess (hard flush) or just update * rewrite_rules transient (soft flush). Default is true (hard). */ function flush_rewrite_rules( $hard = true ) { global $wp_rewrite; $wp_rewrite->flush_rules( $hard ); } /** * Endpoint Mask for default, which is nothing. * * @since 2.1.0 */ define('EP_NONE', 0); /** * Endpoint Mask for Permalink. * * @since 2.1.0 */ define('EP_PERMALINK', 1); /** * Endpoint Mask for Attachment. * * @since 2.1.0 */ define('EP_ATTACHMENT', 2); /** * Endpoint Mask for date. * * @since 2.1.0 */ define('EP_DATE', 4); /** * Endpoint Mask for year * * @since 2.1.0 */ define('EP_YEAR', 8); /** * Endpoint Mask for month. * * @since 2.1.0 */ define('EP_MONTH', 16); /** * Endpoint Mask for day. * * @since 2.1.0 */ define('EP_DAY', 32); /** * Endpoint Mask for root. * * @since 2.1.0 */ define('EP_ROOT', 64); /** * Endpoint Mask for comments. * * @since 2.1.0 */ define('EP_COMMENTS', 128); /** * Endpoint Mask for searches. * * @since 2.1.0 */ define('EP_SEARCH', 256); /** * Endpoint Mask for categories. * * @since 2.1.0 */ define('EP_CATEGORIES', 512); /** * Endpoint Mask for tags. * * @since 2.3.0 */ define('EP_TAGS', 1024); /** * Endpoint Mask for authors. * * @since 2.1.0 */ define('EP_AUTHORS', 2048); /** * Endpoint Mask for pages. * * @since 2.1.0 */ define('EP_PAGES', 4096); /** * Endpoint Mask for all archive views. * * @since 3.7.0 */ define( 'EP_ALL_ARCHIVES', EP_DATE | EP_YEAR | EP_MONTH | EP_DAY | EP_CATEGORIES | EP_TAGS | EP_AUTHORS ); /** * Endpoint Mask for everything. * * @since 2.1.0 */ define( 'EP_ALL', EP_PERMALINK | EP_ATTACHMENT | EP_ROOT | EP_COMMENTS | EP_SEARCH | EP_PAGES | EP_ALL_ARCHIVES ); /** * Add an endpoint, like /trackback/. * * Adding an endpoint creates extra rewrite rules for each of the matching * places specified by the provided bitmask. For example: * * * add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES ); * * * will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct * that describes a permalink (post) or page. This is rewritten to "json=$match" * where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in * "/json/foo/"). * * A new query var with the same name as the endpoint will also be created. * * When specifying $places ensure that you are using the EP_* constants (or a * combination of them using the bitwise OR operator) as their values are not * guaranteed to remain static (especially EP_ALL). * * Be sure to flush the rewrite rules - flush_rewrite_rules() - when your plugin gets * activated and deactivated. * * @since 2.1.0 * @see WP_Rewrite::add_endpoint() * @global object $wp_rewrite * * @param string $name Name of the endpoint. * @param int $places Endpoint mask describing the places the endpoint should be added. * @param string $query_var Name of the corresponding query variable. Defaults to $name. */ function add_rewrite_endpoint( $name, $places, $query_var = null ) { global $wp_rewrite; $wp_rewrite->add_endpoint( $name, $places, $query_var ); } /** * Filter the URL base for taxonomies. * * To remove any manually prepended /index.php/. * * @access private * @since 2.6.0 * * @param string $base The taxonomy base that we're going to filter * @return string */ function _wp_filter_taxonomy_base( $base ) { if ( !empty( $base ) ) { $base = preg_replace( '|^/index\.php/|', '', $base ); $base = trim( $base, '/' ); } return $base; } /** * Examine a url and try to determine the post ID it represents. * * Checks are supposedly from the hosted site blog. * * @since 1.0.0 * * @param string $url Permalink to check. * @return int Post ID, or 0 on failure. */ function url_to_postid($url) { global $wp_rewrite; /** * Filter the URL to derive the post ID from. * * @since 2.2.0 * * @param string $url The URL to derive the post ID from. */ $url = apply_filters( 'url_to_postid', $url ); // First, check to see if there is a 'p=N' or 'page_id=N' to match against if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { $id = absint($values[2]); if ( $id ) return $id; } // Check to see if we are using rewrite rules $rewrite = $wp_rewrite->wp_rewrite_rules(); // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options if ( empty($rewrite) ) return 0; // Get rid of the #anchor $url_split = explode('#', $url); $url = $url_split[0]; // Get rid of URL ?query=string $url_split = explode('?', $url); $url = $url_split[0]; // Add 'www.' if it is absent and should be there if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) $url = str_replace('://', '://www.', $url); // Strip 'www.' if it is present and shouldn't be if ( false === strpos(home_url(), '://www.') ) $url = str_replace('://www.', '://', $url); // Strip 'index.php/' if we're not using path info permalinks if ( !$wp_rewrite->using_index_permalinks() ) $url = str_replace( $wp_rewrite->index . '/', '', $url ); if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) { // Chop off http://domain.com/[path] $url = str_replace(home_url(), '', $url); } else { // Chop off /path/to/blog $home_path = parse_url( home_url( '/' ) ); $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ; $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) ); } // Trim leading and lagging slashes $url = trim($url, '/'); $request = $url; $post_type_query_vars = array(); foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) { if ( ! empty( $t->query_var ) ) $post_type_query_vars[ $t->query_var ] = $post_type; } // Look for matches. $request_match = $request; foreach ( (array)$rewrite as $match => $query) { // If the requesting file is the anchor of the match, prepend it // to the path info. if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) $request_match = $url . '/' . $request; if ( preg_match("#^$match#", $request_match, $matches) ) { if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { // this is a verbose page match, lets check to be sure about it if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) ) continue; } // Got a match. // Trim the query of everything up to the '?'. $query = preg_replace("!^.+\?!", '', $query); // Substitute the substring matches into the query. $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); // Filter out non-public query vars global $wp; parse_str( $query, $query_vars ); $query = array(); foreach ( (array) $query_vars as $key => $value ) { if ( in_array( $key, $wp->public_query_vars ) ){ $query[$key] = $value; if ( isset( $post_type_query_vars[$key] ) ) { $query['post_type'] = $post_type_query_vars[$key]; $query['name'] = $value; } } } // Do the query $query = new WP_Query( $query ); if ( ! empty( $query->posts ) && $query->is_singular ) return $query->post->ID; else return 0; } } return 0; } /** * WordPress Rewrite Component. * * The WordPress Rewrite class writes the rewrite module rules to the .htaccess * file. It also handles parsing the request to get the correct setup for the * WordPress Query class. * * The Rewrite along with WP class function as a front controller for WordPress. * You can add rules to trigger your page view and processing using this * component. The full functionality of a front controller does not exist, * meaning you can't define how the template files load based on the rewrite * rules. * * @since 1.5.0 */ class WP_Rewrite { /** * Permalink structure for posts. * * @since 1.5.0 * @access private * @var string */ var $permalink_structure; /** * Whether to add trailing slashes. * * @since 2.2.0 * @access private * @var bool */ var $use_trailing_slashes; /** * Base for the author permalink structure (example.com/$author_base/authorname). * * @since 1.5.0 * @access private * @var string */ var $author_base = 'author'; /** * Permalink structure for author archives. * * @since 1.5.0 * @access private * @var string */ var $author_structure; /** * Permalink structure for date archives. * * @since 1.5.0 * @access private * @var string */ var $date_structure; /** * Permalink structure for pages. * * @since 1.5.0 * @access private * @var string */ var $page_structure; /** * Base of the search permalink structure (example.com/$search_base/query). * * @since 1.5.0 * @access private * @var string */ var $search_base = 'search'; /** * Permalink structure for searches. * * @since 1.5.0 * @access private * @var string */ var $search_structure; /** * Comments permalink base. * * @since 1.5.0 * @access private * @var string */ var $comments_base = 'comments'; /** * Pagination permalink base. * * @since 3.1.0 * @access private * @var string */ var $pagination_base = 'page'; /** * Feed permalink base. * * @since 1.5.0 * @access private * @var string */ var $feed_base = 'feed'; /** * Comments feed permalink structure. * * @since 1.5.0 * @access private * @var string */ var $comments_feed_structure; /** * Feed request permalink structure. * * @since 1.5.0 * @access private * @var string */ var $feed_structure; /** * The static portion of the post permalink structure. * * If the permalink structure is "/archive/%post_id%" then the front * is "/archive/". If the permalink structure is "/%year%/%postname%/" * then the front is "/". * * @see WP_Rewrite::init() * @since 1.5.0 * @access private * @var string */ var $front; /** * The prefix for all permalink structures. * * If PATHINFO/index permalinks are in use then the root is the value of * {@link WP_Rewrite::$index} with a trailing slash appended. Otherwise * the root will be empty. * * @see WP_Rewrite::init() * @see WP_Rewrite::using_index_permalinks() * @since 1.5.0 * @access private * @var string */ var $root = ''; /** * The name of the index file which is the entry point to all requests. * * @since 1.5.0 * @access public * @var string */ var $index = 'index.php'; /** * Variable name to use for regex matches in the rewritten query. * * @since 1.5.0 * @access private * @var string */ var $matches = ''; /** * Rewrite rules to match against the request to find the redirect or query. * * @since 1.5.0 * @access private * @var array */ var $rules; /** * Additional rules added external to the rewrite class. * * Those not generated by the class, see add_rewrite_rule(). * * @since 2.1.0 * @access private * @var array */ var $extra_rules = array(); /** * Additional rules that belong at the beginning to match first. * * Those not generated by the class, see add_rewrite_rule(). * * @since 2.3.0 * @access private * @var array */ var $extra_rules_top = array(); /** * Rules that don't redirect to WordPress' index.php. * * These rules are written to the mod_rewrite portion of the .htaccess, * and are added by {@link add_external_rule()}. * * @since 2.1.0 * @access private * @var array */ var $non_wp_rules = array(); /** * Extra permalink structures, e.g. categories, added by {@link add_permastruct()}. * * @since 2.1.0 * @access private * @var array */ var $extra_permastructs = array(); /** * Endpoints (like /trackback/) added by {@link add_rewrite_endpoint()}. * * @since 2.1.0 * @access private * @var array */ var $endpoints; /** * Whether to write every mod_rewrite rule for WordPress into the .htaccess file. * * This is off by default, turning it on might print a lot of rewrite rules * to the .htaccess file. * * @see WP_Rewrite::mod_rewrite_rules() * @since 2.0.0 * @access public * @var bool */ var $use_verbose_rules = false; /** * Could post permalinks be confused with those of pages? * * If the first rewrite tag in the post permalink structure is one that could * also match a page name (e.g. %postname% or %author%) then this flag is * set to true. Prior to WordPress 3.3 this flag indicated that every page * would have a set of rules added to the top of the rewrite rules array. * Now it tells {@link WP::parse_request()} to check if a URL matching the * page permastruct is actually a page before accepting it. * * @link http://core.trac.wordpress.org/ticket/16687 * @see WP_Rewrite::init() * @since 2.5.0 * @access public * @var bool */ var $use_verbose_page_rules = true; /** * Rewrite tags that can be used in permalink structures. * * These are translated into the regular expressions stored in * {@link WP_Rewrite::$rewritereplace} and are rewritten to the * query variables listed in {@link WP_Rewrite::$queryreplace}. * * Additional tags can be added with {@link add_rewrite_tag()}. * * @since 1.5.0 * @access private * @var array */ var $rewritecode = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%author%', '%pagename%', '%search%' ); /** * Regular expressions to be substituted into rewrite rules in place * of rewrite tags, see {@link WP_Rewrite::$rewritecode}. * * @since 1.5.0 * @access private * @var array */ var $rewritereplace = array( '([0-9]{4})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([^/]+)', '([0-9]+)', '([^/]+)', '([^/]+?)', '(.+)' ); /** * Query variables that rewrite tags map to, see {@link WP_Rewrite::$rewritecode}. * * @since 1.5.0 * @access private * @var array */ var $queryreplace = array( 'year=', 'monthnum=', 'day=', 'hour=', 'minute=', 'second=', 'name=', 'p=', 'author_name=', 'pagename=', 's=' ); /** * Supported default feeds. * * @since 1.5.0 * @access private * @var array */ var $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); /** * Whether permalinks are being used. * * This can be either rewrite module or permalink in the HTTP query string. * * @since 1.5.0 * @access public * * @return bool True, if permalinks are enabled. */ function using_permalinks() { return ! empty($this->permalink_structure); } /** * Whether permalinks are being used and rewrite module is not enabled. * * Means that permalink links are enabled and index.php is in the URL. * * @since 1.5.0 * @access public * * @return bool */ function using_index_permalinks() { if ( empty($this->permalink_structure) ) return false; // If the index is not in the permalink, we're using mod_rewrite. if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) ) return true; return false; } /** * Whether permalinks are being used and rewrite module is enabled. * * Using permalinks and index.php is not in the URL. * * @since 1.5.0 * @access public * * @return bool */ function using_mod_rewrite_permalinks() { if ( $this->using_permalinks() && ! $this->using_index_permalinks() ) return true; else return false; } /** * Index for matches for usage in preg_*() functions. * * The format of the string is, with empty matches property value, '$NUM'. * The 'NUM' will be replaced with the value in the $number parameter. With * the matches property not empty, the value of the returned string will * contain that value of the matches property. The format then will be * '$MATCHES[NUM]', with MATCHES as the value in the property and NUM the * value of the $number parameter. * * @since 1.5.0 * @access public * * @param int $number Index number. * @return string */ function preg_index($number) { $match_prefix = '$'; $match_suffix = ''; if ( ! empty($this->matches) ) { $match_prefix = '$' . $this->matches . '['; $match_suffix = ']'; } return "$match_prefix$number$match_suffix"; } /** * Retrieve all page and attachments for pages URIs. * * The attachments are for those that have pages as parents and will be * retrieved. * * @since 2.5.0 * @access public * * @return array Array of page URIs as first element and attachment URIs as second element. */ function page_uri_index() { global $wpdb; //get pages in order of hierarchy, i.e. children after parents $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'"); $posts = get_page_hierarchy( $pages ); // If we have no pages get out quick if ( !$posts ) return array( array(), array() ); //now reverse it, because we need parents after children for rewrite rules to work properly $posts = array_reverse($posts, true); $page_uris = array(); $page_attachment_uris = array(); foreach ( $posts as $id => $post ) { // URL => page name $uri = get_page_uri($id); $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id )); if ( !empty($attachments) ) { foreach ( $attachments as $attachment ) { $attach_uri = get_page_uri($attachment->ID); $page_attachment_uris[$attach_uri] = $attachment->ID; } } $page_uris[$uri] = $id; } return array( $page_uris, $page_attachment_uris ); } /** * Retrieve all of the rewrite rules for pages. * * @since 1.5.0 * @access public * * @return array */ function page_rewrite_rules() { // the extra .? at the beginning prevents clashes with other regular expressions in the rules array $this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' ); return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false ); } /** * Retrieve date permalink structure, with year, month, and day. * * The permalink structure for the date, if not set already depends on the * permalink structure. It can be one of three formats. The first is year, * month, day; the second is day, month, year; and the last format is month, * day, year. These are matched against the permalink structure for which * one is used. If none matches, then the default will be used, which is * year, month, day. * * Prevents post ID and date permalinks from overlapping. In the case of * post_id, the date permalink will be prepended with front permalink with * 'date/' before the actual permalink to form the complete date permalink * structure. * * @since 1.5.0 * @access public * * @return bool|string False on no permalink structure. Date permalink structure. */ function get_date_permastruct() { if ( isset($this->date_structure) ) return $this->date_structure; if ( empty($this->permalink_structure) ) { $this->date_structure = ''; return false; } // The date permalink must have year, month, and day separated by slashes. $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%'); $this->date_structure = ''; $date_endian = ''; foreach ( $endians as $endian ) { if ( false !== strpos($this->permalink_structure, $endian) ) { $date_endian= $endian; break; } } if ( empty($date_endian) ) $date_endian = '%year%/%monthnum%/%day%'; // Do not allow the date tags and %post_id% to overlap in the permalink // structure. If they do, move the date tags to $front/date/. $front = $this->front; preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); $tok_index = 1; foreach ( (array) $tokens[0] as $token) { if ( '%post_id%' == $token && ($tok_index <= 3) ) { $front = $front . 'date/'; break; } $tok_index++; } $this->date_structure = $front . $date_endian; return $this->date_structure; } /** * Retrieve the year permalink structure without month and day. * * Gets the date permalink structure and strips out the month and day * permalink structures. * * @since 1.5.0 * @access public * * @return bool|string False on failure. Year structure on success. */ function get_year_permastruct() { $structure = $this->get_date_permastruct(); if ( empty($structure) ) return false; $structure = str_replace('%monthnum%', '', $structure); $structure = str_replace('%day%', '', $structure); $structure = preg_replace('#/+#', '/', $structure); return $structure; } /** * Retrieve the month permalink structure without day and with year. * * Gets the date permalink structure and strips out the day permalink * structures. Keeps the year permalink structure. * * @since 1.5.0 * @access public * * @return bool|string False on failure. Year/Month structure on success. */ function get_month_permastruct() { $structure = $this->get_date_permastruct(); if ( empty($structure) ) return false; $structure = str_replace('%day%', '', $structure); $structure = preg_replace('#/+#', '/', $structure); return $structure; } /** * Retrieve the day permalink structure with month and year. * * Keeps date permalink structure with all year, month, and day. * * @since 1.5.0 * @access public * * @return bool|string False on failure. Year/Month/Day structure on success. */ function get_day_permastruct() { return $this->get_date_permastruct(); } /** * Retrieve the permalink structure for categories. * * If the category_base property has no value, then the category structure * will have the front property value, followed by 'category', and finally * '%category%'. If it does, then the root property will be used, along with * the category_base property value. * * @since 1.5.0 * @access public * * @return bool|string False on failure. Category permalink structure. */ function get_category_permastruct() { return $this->get_extra_permastruct('category'); } /** * Retrieve the permalink structure for tags. * * If the tag_base property has no value, then the tag structure will have * the front property value, followed by 'tag', and finally '%tag%'. If it * does, then the root property will be used, along with the tag_base * property value. * * @since 2.3.0 * @access public * * @return bool|string False on failure. Tag permalink structure. */ function get_tag_permastruct() { return $this->get_extra_permastruct('post_tag'); } /** * Retrieve extra permalink structure by name. * * @since 2.5.0 * @access public * * @param string $name Permalink structure name. * @return string|bool False if not found. Permalink structure string. */ function get_extra_permastruct($name) { if ( empty($this->permalink_structure) ) return false; if ( isset($this->extra_permastructs[$name]) ) return $this->extra_permastructs[$name]['struct']; return false; } /** * Retrieve the author permalink structure. * * The permalink structure is front property, author base, and finally * '/%author%'. Will set the author_structure property and then return it * without attempting to set the value again. * * @since 1.5.0 * @access public * * @return string|bool False if not found. Permalink structure string. */ function get_author_permastruct() { if ( isset($this->author_structure) ) return $this->author_structure; if ( empty($this->permalink_structure) ) { $this->author_structure = ''; return false; } $this->author_structure = $this->front . $this->author_base . '/%author%'; return $this->author_structure; } /** * Retrieve the search permalink structure. * * The permalink structure is root property, search base, and finally * '/%search%'. Will set the search_structure property and then return it * without attempting to set the value again. * * @since 1.5.0 * @access public * * @return string|bool False if not found. Permalink structure string. */ function get_search_permastruct() { if ( isset($this->search_structure) ) return $this->search_structure; if ( empty($this->permalink_structure) ) { $this->search_structure = ''; return false; } $this->search_structure = $this->root . $this->search_base . '/%search%'; return $this->search_structure; } /** * Retrieve the page permalink structure. * * The permalink structure is root property, and '%pagename%'. Will set the * page_structure property and then return it without attempting to set the * value again. * * @since 1.5.0 * @access public * * @return string|bool False if not found. Permalink structure string. */ function get_page_permastruct() { if ( isset($this->page_structure) ) return $this->page_structure; if (empty($this->permalink_structure)) { $this->page_structure = ''; return false; } $this->page_structure = $this->root . '%pagename%'; return $this->page_structure; } /** * Retrieve the feed permalink structure. * * The permalink structure is root property, feed base, and finally * '/%feed%'. Will set the feed_structure property and then return it * without attempting to set the value again. * * @since 1.5.0 * @access public * * @return string|bool False if not found. Permalink structure string. */ function get_feed_permastruct() { if ( isset($this->feed_structure) ) return $this->feed_structure; if ( empty($this->permalink_structure) ) { $this->feed_structure = ''; return false; } $this->feed_structure = $this->root . $this->feed_base . '/%feed%'; return $this->feed_structure; } /** * Retrieve the comment feed permalink structure. * * The permalink structure is root property, comment base property, feed * base and finally '/%feed%'. Will set the comment_feed_structure property * and then return it without attempting to set the value again. * * @since 1.5.0 * @access public * * @return string|bool False if not found. Permalink structure string. */ function get_comment_feed_permastruct() { if ( isset($this->comment_feed_structure) ) return $this->comment_feed_structure; if (empty($this->permalink_structure)) { $this->comment_feed_structure = ''; return false; } $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%'; return $this->comment_feed_structure; } /** * Add or update existing rewrite tags (e.g. %postname%). * * If the tag already exists, replace the existing pattern and query for * that tag, otherwise add the new tag. * * @see WP_Rewrite::$rewritecode * @see WP_Rewrite::$rewritereplace * @see WP_Rewrite::$queryreplace * @since 1.5.0 * @access public * * @param string $tag Name of the rewrite tag to add or update. * @param string $regex Regular expression to substitute the tag for in rewrite rules. * @param string $query String to append to the rewritten query. Must end in '='. */ function add_rewrite_tag( $tag, $regex, $query ) { $position = array_search( $tag, $this->rewritecode ); if ( false !== $position && null !== $position ) { $this->rewritereplace[ $position ] = $regex; $this->queryreplace[ $position ] = $query; } else { $this->rewritecode[] = $tag; $this->rewritereplace[] = $regex; $this->queryreplace[] = $query; } } /** * Generate rewrite rules from a permalink structure. * * The main WP_Rewrite function for building the rewrite rule list. The * contents of the function is a mix of black magic and regular expressions, * so best just ignore the contents and move to the parameters. * * @since 1.5.0 * @access public * * @param string $permalink_structure The permalink structure. * @param int $ep_mask Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE. * @param bool $paged Should archive pagination rules be added for the structure? Default is true. * @param bool $feed Should feed rewrite rules be added for the structure? Default is true. * @param bool $forcomments Should the feed rules be a query for a comments feed? Default is false. * @param bool $walk_dirs Should the 'directories' making up the structure be walked over and rewrite rules * built for each in turn? Default is true. * @param bool $endpoints Should endpoints be applied to the generated rewrite rules? Default is true. * @return array Rewrite rule list. */ function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? $feedregex2 = ''; foreach ( (array) $this->feeds as $feed_name) $feedregex2 .= $feed_name . '|'; $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; //$feedregex is identical but with /feed/ added on as well, so URLs like /feed/atom //and /atom are both possible $feedregex = $this->feed_base . '/' . $feedregex2; //build a regex to match the trackback and page/xx parts of URLs $trackbackregex = 'trackback/?$'; $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$'; $commentregex = 'comment-page-([0-9]{1,})/?$'; //build up an array of endpoint regexes to append => queries to append if ( $endpoints ) { $ep_query_append = array (); foreach ( (array) $this->endpoints as $endpoint) { //match everything after the endpoint name, but allow for nothing to appear there $epmatch = $endpoint[1] . '(/(.*))?/?$'; //this will be appended on to the rest of the query for each dir $epquery = '&' . $endpoint[2] . '='; $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery ); } } //get everything up to the first rewrite tag $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); //build an array of the tags (note that said array ends up being in $tokens[0]) preg_match_all('/%.+?%/', $permalink_structure, $tokens); $num_tokens = count($tokens[0]); $index = $this->index; //probably 'index.php' $feedindex = $index; $trackbackindex = $index; //build a list from the rewritecode and queryreplace arrays, that will look something like //tagname=$matches[i] where i is the current $i for ( $i = 0; $i < $num_tokens; ++$i ) { if ( 0 < $i ) $queries[$i] = $queries[$i - 1] . '&'; else $queries[$i] = ''; $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); $queries[$i] .= $query_token; } //get the structure, minus any cruft (stuff that isn't tags) at the front $structure = $permalink_structure; if ( $front != '/' ) $structure = str_replace($front, '', $structure); //create a list of dirs to walk over, making rewrite rules for each level //so for example, a $structure of /%year%/%monthnum%/%postname% would create //rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname% $structure = trim($structure, '/'); $dirs = $walk_dirs ? explode('/', $structure) : array( $structure ); $num_dirs = count($dirs); //strip slashes from the front of $front $front = preg_replace('|^/+|', '', $front); //the main workhorse loop $post_rewrite = array(); $struct = $front; for ( $j = 0; $j < $num_dirs; ++$j ) { //get the struct for this dir, and trim slashes off the front $struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above $struct = ltrim($struct, '/'); //replace tags with regexes $match = str_replace($this->rewritecode, $this->rewritereplace, $struct); //make a list of tags, and store how many there are in $num_toks $num_toks = preg_match_all('/%.+?%/', $struct, $toks); //get the 'tagname=$matches[i]' $query = ( isset($queries) && is_array($queries) && !empty($num_toks) ) ? $queries[$num_toks - 1] : ''; //set up $ep_mask_specific which is used to match more specific URL types switch ( $dirs[$j] ) { case '%year%': $ep_mask_specific = EP_YEAR; break; case '%monthnum%': $ep_mask_specific = EP_MONTH; break; case '%day%': $ep_mask_specific = EP_DAY; break; default: $ep_mask_specific = EP_NONE; } //create query for /page/xx $pagematch = $match . $pageregex; $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1); //create query for /comment-page-xx $commentmatch = $match . $commentregex; $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1); if ( get_option('page_on_front') ) { //create query for Root /comment-page-xx $rootcommentmatch = $match . $commentregex; $rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1); } //create query for /feed/(feed|atom|rss|rss2|rdf) $feedmatch = $match . $feedregex; $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); //create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex) $feedmatch2 = $match . $feedregex2; $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); //if asked to, turn the feed queries into comment feed ones if ( $forcomments ) { $feedquery .= '&withcomments=1'; $feedquery2 .= '&withcomments=1'; } //start creating the array of rewrites for this dir $rewrite = array(); if ( $feed ) //...adding on /feed/ regexes => queries $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2); if ( $paged ) //...and /page/xx ones $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); //only on pages with comments add ../comment-page-xx/ if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) $rewrite = array_merge($rewrite, array($commentmatch => $commentquery)); else if ( EP_ROOT & $ep_mask && get_option('page_on_front') ) $rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery)); //do endpoints if ( $endpoints ) { foreach ( (array) $ep_query_append as $regex => $ep) { //add the endpoints on if the mask fits if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); } } //if we've got some tags in this dir if ( $num_toks ) { $post = false; $page = false; //check to see if this dir is permalink-level: i.e. the structure specifies an //individual post. Do this by checking it contains at least one of 1) post name, //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and //minute all present). Set these flags now as we need them for the endpoints. if ( strpos($struct, '%postname%') !== false || strpos($struct, '%post_id%') !== false || strpos($struct, '%pagename%') !== false || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false) ) { $post = true; if ( strpos($struct, '%pagename%') !== false ) $page = true; } if ( ! $post ) { // For custom post types, we need to add on endpoints as well. foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) { if ( strpos($struct, "%$ptype%") !== false ) { $post = true; $page = is_post_type_hierarchical( $ptype ); // This is for page style attachment url's break; } } } //if we're creating rules for a permalink, do all the endpoints like attachments etc if ( $post ) { //create query and regex for trackback $trackbackmatch = $match . $trackbackregex; $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; //trim slashes from the end of the regex for this dir $match = rtrim($match, '/'); //get rid of brackets $submatchbase = str_replace( array('(', ')'), '', $match); //add a rule for at attachments, which take the form of /some-text $sub1 = $submatchbase . '/([^/]+)/'; $sub1tb = $sub1 . $trackbackregex; //add trackback regex /trackback/... $sub1feed = $sub1 . $feedregex; //and /feed/(atom|...) $sub1feed2 = $sub1 . $feedregex2; //and /(feed|atom...) $sub1comment = $sub1 . $commentregex; //and /comment-page-xx //add another rule to match attachments in the explicit form: ///attachment/some-text $sub2 = $submatchbase . '/attachment/([^/]+)/'; $sub2tb = $sub2 . $trackbackregex; //and add trackbacks /attachment/trackback $sub2feed = $sub2 . $feedregex; //feeds, /attachment/feed/(atom|...) $sub2feed2 = $sub2 . $feedregex2; //and feeds again on to this /attachment/(feed|atom...) $sub2comment = $sub2 . $commentregex; //and /comment-page-xx //create queries for these extra tag-ons we've just dealt with $subquery = $index . '?attachment=' . $this->preg_index(1); $subtbquery = $subquery . '&tb=1'; $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2); //do endpoints for attachments if ( !empty($endpoints) ) { foreach ( (array) $ep_query_append as $regex => $ep ) { if ( $ep[0] & EP_ATTACHMENT ) { $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(3); $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(3); } } } //now we've finished with endpoints, finish off the $sub1 and $sub2 matches //add a ? as we don't have to match that last slash, and finally a $ so we //match to the end of the URL $sub1 .= '?$'; $sub2 .= '?$'; //post pagination, e.g. /2/ $match = $match . '(/[0-9]+)?/?$'; $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); } else { //not matching a permalink so this is a lot simpler //close the match and finalise the query $match .= '?$'; $query = $index . '?' . $query; } //create the final array for this dir by joining the $rewrite array (which currently //only contains rules/queries for trackback, pages etc) to the main regex/query for //this dir $rewrite = array_merge($rewrite, array($match => $query)); //if we're matching a permalink, add those extras (attachments etc) on if ( $post ) { //add trackback $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite); //add regexes/queries for attachments, attachment trackbacks and so on if ( ! $page ) //require /attachment/stuff form for pages because of confusion with subpages $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery)); $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite); } } //if($num_toks) //add the rules for this dir to the accumulating $post_rewrite $post_rewrite = array_merge($rewrite, $post_rewrite); } //foreach ($dir) return $post_rewrite; //the finished rules. phew! } /** * Generate Rewrite rules with permalink structure and walking directory only. * * Shorten version of {@link WP_Rewrite::generate_rewrite_rules()} that * allows for shorter list of parameters. See the method for longer * description of what generating rewrite rules does. * * @uses WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters. * @since 1.5.0 * @access public * * @param string $permalink_structure The permalink structure to generate rules. * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over. * @return array */ function generate_rewrite_rule($permalink_structure, $walk_dirs = false) { return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs); } /** * Construct rewrite matches and queries from permalink structure. * * Runs the action 'generate_rewrite_rules' with the parameter that is an * reference to the current WP_Rewrite instance to further manipulate the * permalink structures and rewrite rules. Runs the 'rewrite_rules_array' * filter on the full rewrite rule array. * * There are two ways to manipulate the rewrite rules, one by hooking into * the 'generate_rewrite_rules' action and gaining full control of the * object or just manipulating the rewrite rule array before it is passed * from the function. * * @since 1.5.0 * @access public * * @return array An associate array of matches and queries. */ function rewrite_rules() { $rewrite = array(); if ( empty($this->permalink_structure) ) return $rewrite; // robots.txt -only if installed at the root $home_path = parse_url( home_url() ); $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); // Old feed and service files $deprecated_files = array( '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old', '.*wp-app\.php(/.*)?$' => $this->index . '?error=403', ); // Registration rules $registration_pages = array(); if ( is_multisite() && is_main_site() ) { $registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true'; $registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true'; } $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated // Post rewrite rules. $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK ); /** * Filter rewrite rules used for "post" archives. * * @since 1.5.0 * * @param array $post_rewrite The rewrite rules for posts. */ $post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite ); // Date rewrite rules. $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE); /** * Filter rewrite rules used for date archives. * * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/. * * @since 1.5.0 * * @param array $date_rewrite The rewrite rules for date archives. */ $date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite ); // Root-level rewrite rules. $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT); /** * Filter rewrite rules used for root-level archives. * * Likely root-level archives would include pagination rules for the homepage * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/). * * @since 1.5.0 * * @param array $root_rewrite The root-level rewrite rules. */ $root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite ); // Comments rewrite rules. $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false); /** * Filter rewrite rules used for comment feed archives. * * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/. * * @since 1.5.0 * * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds. */ $comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite ); // Search rewrite rules. $search_structure = $this->get_search_permastruct(); $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH); /** * Filter rewrite rules used for search archives. * * Likely search-related archives include /search/search+query/ as well as * pagination and feed paths for a search. * * @since 1.5.0 * * @param array $search_rewrite The rewrite rules for search queries. */ $search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite ); // Author rewrite rules. $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS); /** * Filter rewrite rules used for author archives. * * Likely author archives would include /author/author-name/, as well as * pagination and feed paths for author archives. * * @since 1.5.0 * * @param array $author_rewrite The rewrite rules for author archives. */ $author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite ); // Pages rewrite rules. $page_rewrite = $this->page_rewrite_rules(); /** * Filter rewrite rules used for "page" post type archives. * * @since 1.5.0 * * @param array $page_rewrite The rewrite rules for the "page" post type. */ $page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite ); // Extra permastructs. foreach ( $this->extra_permastructs as $permastructname => $struct ) { if ( is_array( $struct ) ) { if ( count( $struct ) == 2 ) $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); else $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); } else { $rules = $this->generate_rewrite_rules( $struct ); } /** * Filter rewrite rules used for individual permastructs. * * The dynamic portion of the hook name, $permastructname, refers * to the name of the registered permastruct, e.g. 'post_tag' (tags), * 'category' (categories), etc. * * @since 3.1.0 * * @param array $rules The rewrite rules generated for the current permastruct. */ $rules = apply_filters( $permastructname . '_rewrite_rules', $rules ); if ( 'post_tag' == $permastructname ) { /** * Filter rewrite rules used specifically for Tags. * * @since 2.3.0 * @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead * * @param array $rules The rewrite rules generated for tags. */ $rules = apply_filters( 'tag_rewrite_rules', $rules ); } $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); } // Put them together. if ( $this->use_verbose_page_rules ) $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); else $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); /** * Fires after the rewrite rules are generated. * * @since 1.5.0 * * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference. */ do_action_ref_array( 'generate_rewrite_rules', array( &$this ) ); /** * Filter the full set of generated rewrite rules. * * @since 1.5.0 * * @param array $this->rules The compiled array of rewrite rules. */ $this->rules = apply_filters( 'rewrite_rules_array', $this->rules ); return $this->rules; } /** * Retrieve the rewrite rules. * * The difference between this method and {@link * WP_Rewrite::rewrite_rules()} is that this method stores the rewrite rules * in the 'rewrite_rules' option and retrieves it. This prevents having to * process all of the permalinks to get the rewrite rules in the form of * caching. * * @since 1.5.0 * @access public * * @return array Rewrite rules. */ function wp_rewrite_rules() { $this->rules = get_option('rewrite_rules'); if ( empty($this->rules) ) { $this->matches = 'matches'; $this->rewrite_rules(); update_option('rewrite_rules', $this->rules); } return $this->rules; } /** * Retrieve mod_rewrite formatted rewrite rules to write to .htaccess. * * Does not actually write to the .htaccess file, but creates the rules for * the process that will. * * Will add the non_wp_rules property rules to the .htaccess file before * the WordPress rewrite rules one. * * @since 1.5.0 * @access public * * @return string */ function mod_rewrite_rules() { if ( ! $this->using_permalinks() ) return ''; $site_root = parse_url( site_url() ); if ( isset( $site_root['path'] ) ) $site_root = trailingslashit($site_root['path']); $home_root = parse_url(home_url()); if ( isset( $home_root['path'] ) ) $home_root = trailingslashit($home_root['path']); else $home_root = '/'; $rules = "\n"; $rules .= "RewriteEngine On\n"; $rules .= "RewriteBase $home_root\n"; $rules .= "RewriteRule ^index\.php$ - [L]\n"; // Prevent -f checks on index.php. //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all) foreach ( (array) $this->non_wp_rules as $match => $query) { // Apache 1.3 does not support the reluctant (non-greedy) modifier. $match = str_replace('.+?', '.+', $match); // If the match is unanchored and greedy, prepend rewrite conditions // to avoid infinite redirects and eclipsing of real files. //if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) { //nada. //} $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; } if ( $this->use_verbose_rules ) { $this->matches = ''; $rewrite = $this->rewrite_rules(); $num_rules = count($rewrite); $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" . "RewriteCond %{REQUEST_FILENAME} -d\n" . "RewriteRule ^.*$ - [S=$num_rules]\n"; foreach ( (array) $rewrite as $match => $query) { // Apache 1.3 does not support the reluctant (non-greedy) modifier. $match = str_replace('.+?', '.+', $match); // If the match is unanchored and greedy, prepend rewrite conditions // to avoid infinite redirects and eclipsing of real files. //if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) { //nada. //} if ( strpos($query, $this->index) !== false ) $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; else $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; } } else { $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . "RewriteCond %{REQUEST_FILENAME} !-d\n" . "RewriteRule . {$home_root}{$this->index} [L]\n"; } $rules .= "\n"; /** * * Filter the list of rewrite rules formatted for output to an .htaccess file. * * @since 1.5.0 * * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. */ $rules = apply_filters( 'mod_rewrite_rules', $rules ); /** * Filter the list of rewrite rules formatted for output to an .htaccess file. * * @since 1.5.0 * @deprecated 1.5.0 Use the mod_rewrite_rules filter instead. * * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. */ $rules = apply_filters( 'rewrite_rules', $rules ); // Deprecated return $rules; } /** * Retrieve IIS7 URL Rewrite formatted rewrite rules to write to web.config file. * * Does not actually write to the web.config file, but creates the rules for * the process that will. * * @since 2.8.0 * @access public * * @return string */ function iis7_url_rewrite_rules( $add_parent_tags = false ) { if ( ! $this->using_permalinks() ) return ''; $rules = ''; if ( $add_parent_tags ) { $rules .= ' '; } $rules .= ' '; if ( $add_parent_tags ) { $rules .= ' '; } /** * Filter the list of rewrite rules formatted for output to a web.config. * * @since 2.8.0 * * @param string $rules Rewrite rules formatted for IIS web.config. */ $rules = apply_filters( 'iis7_url_rewrite_rules', $rules ); return $rules; } /** * Add a straight rewrite rule. * * Any value in the $after parameter that isn't 'bottom' will be placed at * the top of the rules. * * @since 2.1.0 * @access public * * @param string $regex Regular expression to match against request. * @param string $redirect URL regex redirects to when regex matches request. * @param string $after Optional, default is bottom. Location to place rule. */ function add_rule($regex, $redirect, $after = 'bottom') { //get everything up to the first ? $index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?')); $front = substr($redirect, 0, $index); if ( $front != $this->index ) { //it doesn't redirect to WP's index.php $this->add_external_rule($regex, $redirect); } else { if ( 'bottom' == $after) $this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect)); else $this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect)); //$this->extra_rules[$regex] = $redirect; } } /** * Add a rule that doesn't redirect to index.php. * * Can redirect to any place. * * @since 2.1.0 * @access public * * @param string $regex Regular expression to match against request. * @param string $redirect URL regex redirects to when regex matches request. */ function add_external_rule($regex, $redirect) { $this->non_wp_rules[$regex] = $redirect; } /** * Add an endpoint, like /trackback/. * * @since 2.1.0 * @since 3.9.0 $query_var parameter added. * @access public * * @see add_rewrite_endpoint() for full documentation. * @uses WP::add_query_var() * * @param string $name Name of the endpoint. * @param int $places Endpoint mask describing the places the endpoint should be added. * @param string $query_var Name of the corresponding query variable. Default is value of $name. */ function add_endpoint( $name, $places, $query_var = null ) { global $wp; if ( null === $query_var ) { $query_var = $name; } $this->endpoints[] = array( $places, $name, $query_var ); $wp->add_query_var( $query_var ); } /** * Add a new permalink structure. * * A permalink structure (permastruct) is an abstract definition of a set of rewrite rules; it * is an easy way of expressing a set of regular expressions that rewrite to a set of query strings. * The new permastruct is added to the {@link WP_Rewrite::$extra_permastructs} array. When the * rewrite rules are built by {@link WP_Rewrite::rewrite_rules()} all of these extra permastructs * are passed to {@link WP_Rewrite::generate_rewrite_rules()} which transforms them into the * regular expressions that many love to hate. * * The $args parameter gives you control over how {@link WP_Rewrite::generate_rewrite_rules()} * works on the new permastruct. * * @since 2.5.0 * @access public * * @param string $name Name for permalink structure. * @param string $struct Permalink structure (e.g. category/%category%) * @param array $args Optional configuration for building the rules from the permalink structure: * - with_front (bool) - Should the structure be prepended with WP_Rewrite::$front? Default is true. * - ep_mask (int) - Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE. * - paged (bool) - Should archive pagination rules be added for the structure? Default is true. * - feed (bool) - Should feed rewrite rules be added for the structure? Default is true. * - forcomments (bool) - Should the feed rules be a query for a comments feed? Default is false. * - walk_dirs (bool) - Should the 'directories' making up the structure be walked over and rewrite * rules built for each in turn? Default is true. * - endpoints (bool) - Should endpoints be applied to the generated rewrite rules? Default is true. */ function add_permastruct( $name, $struct, $args = array() ) { // backwards compatibility for the old parameters: $with_front and $ep_mask if ( ! is_array( $args ) ) $args = array( 'with_front' => $args ); if ( func_num_args() == 4 ) $args['ep_mask'] = func_get_arg( 3 ); $defaults = array( 'with_front' => true, 'ep_mask' => EP_NONE, 'paged' => true, 'feed' => true, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => true, ); $args = array_intersect_key( $args, $defaults ); $args = wp_parse_args( $args, $defaults ); if ( $args['with_front'] ) $struct = $this->front . $struct; else $struct = $this->root . $struct; $args['struct'] = $struct; $this->extra_permastructs[ $name ] = $args; } /** * Remove rewrite rules and then recreate rewrite rules. * * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' * exists, it will be called. * * @since 2.0.1 * @access public * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ function flush_rules($hard = true) { delete_option('rewrite_rules'); $this->wp_rewrite_rules(); /** * Filter whether a "hard" rewrite rule flush should be performed when requested. * * A "hard" flush updates .htaccess (Apache) or web.config (IIS). * * @since 3.7.0 * * @param bool $hard Whether to flush rewrite rules "hard". Default true. */ if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { return; } if ( function_exists( 'save_mod_rewrite_rules' ) ) save_mod_rewrite_rules(); if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) iis7_save_url_rewrite_rules(); } /** * Sets up the object's properties. * * The 'use_verbose_page_rules' object property will be set to true if the * permalink structure begins with one of the following: '%postname%', '%category%', * '%tag%', or '%author%'. * * @since 1.5.0 * @access public */ function init() { $this->extra_rules = $this->non_wp_rules = $this->endpoints = array(); $this->permalink_structure = get_option('permalink_structure'); $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); $this->root = ''; if ( $this->using_index_permalinks() ) $this->root = $this->index . '/'; unset($this->author_structure); unset($this->date_structure); unset($this->page_structure); unset($this->search_structure); unset($this->feed_structure); unset($this->comment_feed_structure); $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) $this->use_verbose_page_rules = true; else $this->use_verbose_page_rules = false; } /** * Set the main permalink structure for the blog. * * Will update the 'permalink_structure' option, if there is a difference * between the current permalink structure and the parameter value. Calls * {@link WP_Rewrite::init()} after the option is updated. * * Fires the 'permalink_structure_changed' action once the init call has * processed passing the old and new values * * @since 1.5.0 * @access public * * @param string $permalink_structure Permalink structure. */ function set_permalink_structure($permalink_structure) { if ( $permalink_structure != $this->permalink_structure ) { $old_permalink_structure = $this->permalink_structure; update_option('permalink_structure', $permalink_structure); $this->init(); /** * Fires after the permalink structure is updated. * * @since 2.8.0 * * @param string $old_permalink_structure The previous permalink structure. * @param string $permalink_structure The new permalink structure. */ do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure ); } } /** * Set the category base for the category permalink. * * Will update the 'category_base' option, if there is a difference between * the current category base and the parameter value. Calls * {@link WP_Rewrite::init()} after the option is updated. * * @since 1.5.0 * @access public * * @param string $category_base Category permalink structure base. */ function set_category_base($category_base) { if ( $category_base != get_option('category_base') ) { update_option('category_base', $category_base); $this->init(); } } /** * Set the tag base for the tag permalink. * * Will update the 'tag_base' option, if there is a difference between the * current tag base and the parameter value. Calls * {@link WP_Rewrite::init()} after the option is updated. * * @since 2.3.0 * @access public * * @param string $tag_base Tag permalink structure base. */ function set_tag_base( $tag_base ) { if ( $tag_base != get_option( 'tag_base') ) { update_option( 'tag_base', $tag_base ); $this->init(); } } /** * Constructor - Calls init(), which runs setup. * * @since 1.5.0 * @access public * * @return WP_Rewrite */ function __construct() { $this->init(); } } /** * Deprecated functions from past WordPress versions. You shouldn't use these * functions and look for the alternatives instead. The functions will be * removed in a later version. * * @package WordPress * @subpackage Deprecated */ /* * Deprecated functions come here to die. */ /** * Entire Post data. * * @since 0.71 * @deprecated 1.5.1 * @deprecated Use get_post() * @see get_post() * * @param int $postid * @return array */ function get_postdata($postid) { _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); $post = get_post($postid); $postdata = array ( 'ID' => $post->ID, 'Author_ID' => $post->post_author, 'Date' => $post->post_date, 'Content' => $post->post_content, 'Excerpt' => $post->post_excerpt, 'Title' => $post->post_title, 'Category' => $post->post_category, 'post_status' => $post->post_status, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_password' => $post->post_password, 'to_ping' => $post->to_ping, 'pinged' => $post->pinged, 'post_type' => $post->post_type, 'post_name' => $post->post_name ); return $postdata; } /** * Sets up the WordPress Loop. * * @since 1.0.1 * @deprecated 1.5.0 * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop} */ function start_wp() { global $wp_query; _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') ); // Since the old style loop is being used, advance the query iterator here. $wp_query->next_post(); setup_postdata( get_post() ); } /** * Return or Print Category ID. * * @since 0.71 * @deprecated 0.71 * @deprecated use get_the_category() * @see get_the_category() * * @param bool $echo * @return null|int */ function the_category_ID($echo = true) { _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); // Grab the first cat in the list. $categories = get_the_category(); $cat = $categories[0]->term_id; if ( $echo ) echo $cat; return $cat; } /** * Print category with optional text before and after. * * @since 0.71 * @deprecated 0.71 * @deprecated use get_the_category_by_ID() * @see get_the_category_by_ID() * * @param string $before * @param string $after */ function the_category_head($before='', $after='') { global $currentcat, $previouscat; _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); // Grab the first cat in the list. $categories = get_the_category(); $currentcat = $categories[0]->category_id; if ( $currentcat != $previouscat ) { echo $before; echo get_the_category_by_ID($currentcat); echo $after; $previouscat = $currentcat; } } /** * Prints link to the previous post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use previous_post_link() * @see previous_post_link() * * @param string $format * @param string $previous * @param string $title * @param string $in_same_cat * @param int $limitprev * @param string $excluded_categories */ function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { _deprecated_function( __FUNCTION__, '2.0', 'previous_post_link()' ); if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; else $in_same_cat = true; $post = get_previous_post($in_same_cat, $excluded_categories); if ( !$post ) return; $string = ''.$previous; if ( 'yes' == $title ) $string .= apply_filters('the_title', $post->post_title, $post->ID); $string .= ''; $format = str_replace('%', $string, $format); echo $format; } /** * Prints link to the next post. * * @since 0.71 * @deprecated 2.0.0 * @deprecated Use next_post_link() * @see next_post_link() * * @param string $format * @param string $next * @param string $title * @param string $in_same_cat * @param int $limitnext * @param string $excluded_categories */ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { _deprecated_function( __FUNCTION__, '2.0', 'next_post_link()' ); if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; else $in_same_cat = true; $post = get_next_post($in_same_cat, $excluded_categories); if ( !$post ) return; $string = ''.$next; if ( 'yes' == $title ) $string .= apply_filters('the_title', $post->post_title, $post->ID); $string .= ''; $format = str_replace('%', $string, $format); echo $format; } /** * Whether user can create a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $blog_id Not Used * @param int $category_id Not Used * @return bool */ function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return ($author_data->user_level > 1); } /** * Whether user can create a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $blog_id Not Used * @param int $category_id Not Used * @return bool */ function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return ($author_data->user_level >= 1); } /** * Whether user can edit a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $post_id * @param int $blog_id Not Used * @return bool */ function user_can_edit_post($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $author_data = get_userdata($user_id); $post = get_post($post_id); $post_author_data = get_userdata($post->post_author); if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) || ($author_data->user_level > $post_author_data->user_level) || ($author_data->user_level >= 10) ) { return true; } else { return false; } } /** * Whether user can delete a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $post_id * @param int $blog_id Not Used * @return bool */ function user_can_delete_post($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); // right now if one can edit, one can delete return user_can_edit_post($user_id, $post_id, $blog_id); } /** * Whether user can set new posts' dates. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $blog_id Not Used * @param int $category_id Not Used * @return bool */ function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); } /** * Whether user can delete a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $post_id * @param int $blog_id Not Used * @return bool returns true if $user_id can edit $post_id's date */ function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); } /** * Whether user can delete a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $post_id * @param int $blog_id Not Used * @return bool returns true if $user_id can edit $post_id's comments */ function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); // right now if one can edit a post, one can edit comments made on it return user_can_edit_post($user_id, $post_id, $blog_id); } /** * Whether user can delete a post. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $post_id * @param int $blog_id Not Used * @return bool returns true if $user_id can delete $post_id's comments */ function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); // right now if one can edit comments, one can delete comments return user_can_edit_post_comments($user_id, $post_id, $blog_id); } /** * Can user can edit other user. * * @since 1.5.0 * @deprecated 2.0.0 * @deprecated Use current_user_can() * @see current_user_can() * * @param int $user_id * @param int $other_user * @return bool */ function user_can_edit_user($user_id, $other_user) { _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); $user = get_userdata($user_id); $other = get_userdata($other_user); if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) return true; else return false; } /** * Gets the links associated with category $cat_name. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param string $cat_name Optional. The category name to use. If no match is found uses all. * @param string $before Optional. The html to output before the link. * @param string $after Optional. The html to output after the link. * @param string $between Optional. The html to output between the link/image and its description. Not used if no image or $show_images is true. * @param bool $show_images Optional. Whether to show images (if defined). * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner. * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a * random order. * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. * @param bool $show_rating Optional. Show rating stars/chars. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. * @param int $show_updated Optional. Whether to show last updated timestamp */ function get_linksbyname($cat_name = "noname", $before = '', $after = '
', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $show_rating = false, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); if ( $cat ) $cat_id = $cat->term_id; get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); } /** * Gets the links associated with the named category. * * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use wp_list_bookmarks() * @see wp_list_bookmarks() * * @param string $category The category to use. * @param string $args * @return bool|null */ function wp_get_linksbyname($category, $args = '') { _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()'); $defaults = array( 'after' => '
', 'before' => '', 'categorize' => 0, 'category_after' => '', 'category_before' => '', 'category_name' => $category, 'show_description' => 1, 'title_li' => '', ); $r = wp_parse_args( $args, $defaults ); return wp_list_bookmarks($r); } /** * Gets an array of link objects associated with category $cat_name. * * * $links = get_linkobjectsbyname('fred'); * foreach ($links as $link) { * echo '
  • '.$link->link_name.'
  • '; * } *
    * * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param string $cat_name The category name to use. If no match is found uses all. * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'. * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also * specify 'rand' as the order which will return links in a random order. * @param int $limit Limit to X entries. If not specified, all entries are shown. * @return unknown */ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); if ( $cat ) $cat_id = $cat->term_id; return get_linkobjects($cat_id, $orderby, $limit); } /** * Gets an array of link objects associated with category n. * * Usage: * * $links = get_linkobjects(1); * if ($links) { * foreach ($links as $link) { * echo '
  • '.$link->link_name.'
    '.$link->link_description.'
  • '; * } * } *
    * * Fields are: *
      *
    1. link_id
    2. *
    3. link_url
    4. *
    5. link_name
    6. *
    7. link_image
    8. *
    9. link_target
    10. *
    11. link_category
    12. *
    13. link_description
    14. *
    15. link_visible
    16. *
    17. link_owner
    18. *
    19. link_rating
    20. *
    21. link_updated
    22. *
    23. link_rel
    24. *
    25. link_notes
    26. *
    * * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param int $category The category to use. If no category supplied uses all * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', * 'description', or 'rating'. Or maybe owner. If you start the name with an * underscore the order will be reversed. You can also specify 'rand' as the * order which will return links in a random order. * @param int $limit Limit to X entries. If not specified, all entries are shown. * @return unknown */ function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; $links_array = array(); foreach ($links as $link) $links_array[] = $link; return $links_array; } /** * Gets the links associated with category 'cat_name' and display rating stars/chars. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param string $cat_name The category name to use. If no match is found uses all * @param string $before The html to output before the link * @param string $after The html to output after the link * @param string $between The html to output between the link/image and its description. Not used if no image or show_images is true * @param bool $show_images Whether to show images (if defined). * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', * 'description', or 'rating'. Or maybe owner. If you start the name with an * underscore the order will be reversed. You can also specify 'rand' as the * order which will return links in a random order. * @param bool $show_description Whether to show the description if show_images=false/not defined * @param int $limit Limit to X entries. If not specified, all entries are shown. * @param int $show_updated Whether to show last updated timestamp */ function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); } /** * Gets the links associated with category n and display rating stars/chars. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param int $category The category to use. If no category supplied uses all * @param string $before The html to output before the link * @param string $after The html to output after the link * @param string $between The html to output between the link/image and its description. Not used if no image or show_images == true * @param bool $show_images Whether to show images (if defined). * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', * 'description', or 'rating'. Or maybe owner. If you start the name with an * underscore the order will be reversed. You can also specify 'rand' as the * order which will return links in a random order. * @param bool $show_description Whether to show the description if show_images=false/not defined. * @param string $limit Limit to X entries. If not specified, all entries are shown. * @param int $show_updated Whether to show last updated timestamp */ function get_links_withrating($category = -1, $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); } /** * Gets the auto_toggle setting. * * @since 0.71 * @deprecated 2.1.0 * @deprecated No alternative function available * * @param int $id The category to get. If no category supplied uses 0 * @return int Only returns 0. */ function get_autotoggle($id = 0) { _deprecated_function( __FUNCTION__, '2.1' ); return 0; } /** * @since 0.71 * @deprecated 2.1.0 * @deprecated Use wp_list_categories() * @see wp_list_categories() * * @param int $optionall * @param string $all * @param string $sort_column * @param string $sort_order * @param string $file * @param bool $list * @param int $optiondates * @param int $optioncount * @param int $hide_empty * @param int $use_desc_for_title * @param bool $children * @param int $child_of * @param int $categories * @param int $recurse * @param string $feed * @param string $feed_image * @param string $exclude * @param bool $hierarchical * @return unknown */ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' ); $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); return wp_list_cats($query); } /** * @since 1.2.0 * @deprecated 2.1.0 * @deprecated Use wp_list_categories() * @see wp_list_categories() * * @param string|array $args * @return unknown */ function wp_list_cats($args = '') { _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' ); $r = wp_parse_args( $args ); // Map to new names. if ( isset($r['optionall']) && isset($r['all'])) $r['show_option_all'] = $r['all']; if ( isset($r['sort_column']) ) $r['orderby'] = $r['sort_column']; if ( isset($r['sort_order']) ) $r['order'] = $r['sort_order']; if ( isset($r['optiondates']) ) $r['show_last_update'] = $r['optiondates']; if ( isset($r['optioncount']) ) $r['show_count'] = $r['optioncount']; if ( isset($r['list']) ) $r['style'] = $r['list'] ? 'list' : 'break'; $r['title_li'] = ''; return wp_list_categories($r); } /** * @since 0.71 * @deprecated 2.1.0 * @deprecated Use wp_dropdown_categories() * @see wp_dropdown_categories() * * @param int $optionall * @param string $all * @param string $orderby * @param string $order * @param int $show_last_update * @param int $show_count * @param int $hide_empty * @param bool $optionnone * @param int $selected * @param int $exclude * @return unknown */ function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, $selected = 0, $exclude = 0) { _deprecated_function( __FUNCTION__, '2.1', 'wp_dropdown_categories()' ); $show_option_all = ''; if ( $optionall ) $show_option_all = $all; $show_option_none = ''; if ( $optionnone ) $show_option_none = __('None'); $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); $query = add_query_arg($vars, ''); return wp_dropdown_categories($query); } /** * List authors. * * @since 1.2.0 * @deprecated 2.1.0 * @deprecated Use wp_list_authors() * @see wp_list_authors() * * @param bool $optioncount * @param bool $exclude_admin * @param bool $show_fullname * @param bool $hide_empty * @param string $feed * @param string $feed_image * @return unknown */ function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { _deprecated_function( __FUNCTION__, '2.1', 'wp_list_authors()' ); $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); return wp_list_authors($args); } /** * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use wp_get_post_categories() * @see wp_get_post_categories() * * @param int $blogid Not Used * @param int $post_ID * @return unknown */ function wp_get_post_cats($blogid = '1', $post_ID = 0) { _deprecated_function( __FUNCTION__, '2.1', 'wp_get_post_categories()' ); return wp_get_post_categories($post_ID); } /** * Sets the categories that the post id belongs to. * * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use wp_set_post_categories() * @see wp_set_post_categories() * * @param int $blogid Not used * @param int $post_ID * @param array $post_categories * @return unknown */ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { _deprecated_function( __FUNCTION__, '2.1', 'wp_set_post_categories()' ); return wp_set_post_categories($post_ID, $post_categories); } /** * @since 0.71 * @deprecated 2.1.0 * @deprecated Use wp_get_archives() * @see wp_get_archives() * * @param string $type * @param string $limit * @param string $format * @param string $before * @param string $after * @param bool $show_post_count * @return unknown */ function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { _deprecated_function( __FUNCTION__, '2.1', 'wp_get_archives()' ); $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); return wp_get_archives($args); } /** * Returns or Prints link to the author's posts. * * @since 1.2.0 * @deprecated 2.1.0 * @deprecated Use get_author_posts_url() * @see get_author_posts_url() * * @param bool $echo * @param int $author_id * @param string $author_nicename Optional. * @return string|null */ function get_author_link($echo, $author_id, $author_nicename = '') { _deprecated_function( __FUNCTION__, '2.1', 'get_author_posts_url()' ); $link = get_author_posts_url($author_id, $author_nicename); if ( $echo ) echo $link; return $link; } /** * Print list of pages based on arguments. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use wp_link_pages() * @see wp_link_pages() * * @param string $before * @param string $after * @param string $next_or_number * @param string $nextpagelink * @param string $previouspagelink * @param string $pagelink * @param string $more_file * @return string */ function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { _deprecated_function( __FUNCTION__, '2.1', 'wp_link_pages()' ); $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); return wp_link_pages($args); } /** * Get value based on option. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_option() * @see get_option() * * @param string $option * @return string */ function get_settings($option) { _deprecated_function( __FUNCTION__, '2.1', 'get_option()' ); return get_option($option); } /** * Print the permalink of the current post in the loop. * * @since 0.71 * @deprecated 1.2.0 * @deprecated Use the_permalink() * @see the_permalink() */ function permalink_link() { _deprecated_function( __FUNCTION__, '1.2', 'the_permalink()' ); the_permalink(); } /** * Print the permalink to the RSS feed. * * @since 0.71 * @deprecated 2.3.0 * @deprecated Use the_permalink_rss() * @see the_permalink_rss() * * @param string $deprecated */ function permalink_single_rss($deprecated = '') { _deprecated_function( __FUNCTION__, '2.3', 'the_permalink_rss()' ); the_permalink_rss(); } /** * Gets the links associated with category. * * @see get_links() for argument information that can be used in $args * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use wp_list_bookmarks() * @see wp_list_bookmarks() * * @param string $args a query string * @return null|string */ function wp_get_links($args = '') { _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); if ( strpos( $args, '=' ) === false ) { $cat_id = $args; $args = add_query_arg( 'category', $cat_id, $args ); } $defaults = array( 'after' => '
    ', 'before' => '', 'between' => ' ', 'categorize' => 0, 'category' => '', 'echo' => true, 'limit' => -1, 'orderby' => 'name', 'show_description' => true, 'show_images' => true, 'show_rating' => false, 'show_updated' => true, 'title_li' => '', ); $r = wp_parse_args( $args, $defaults ); return wp_list_bookmarks($r); } /** * Gets the links associated with category by id. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_bookmarks() * @see get_bookmarks() * * @param int $category The category to use. If no category supplied uses all * @param string $before the html to output before the link * @param string $after the html to output after the link * @param string $between the html to output between the link/image and its description. * Not used if no image or show_images == true * @param bool $show_images whether to show images (if defined). * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', * 'description', or 'rating'. Or maybe owner. If you start the name with an * underscore the order will be reversed. You can also specify 'rand' as the order * which will return links in a random order. * @param bool $show_description whether to show the description if show_images=false/not defined. * @param bool $show_rating show rating stars/chars * @param int $limit Limit to X entries. If not specified, all entries are shown. * @param int $show_updated whether to show last updated timestamp * @param bool $echo whether to echo the results, or return them instead * @return null|string */ function get_links($category = -1, $before = '', $after = '
    ', $between = ' ', $show_images = true, $orderby = 'name', $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); $order = 'ASC'; if ( substr($orderby, 0, 1) == '_' ) { $order = 'DESC'; $orderby = substr($orderby, 1); } if ( $category == -1 ) //get_bookmarks uses '' to signify all categories $category = ''; $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); if ( !$results ) return; $output = ''; foreach ( (array) $results as $row ) { if ( !isset($row->recently_updated) ) $row->recently_updated = false; $output .= $before; if ( $show_updated && $row->recently_updated ) $output .= get_option('links_recently_updated_prepend'); $the_link = '#'; if ( !empty($row->link_url) ) $the_link = esc_url($row->link_url); $rel = $row->link_rel; if ( '' != $rel ) $rel = ' rel="' . $rel . '"'; $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); $title = $desc; if ( $show_updated ) if (substr($row->link_updated_f, 0, 2) != '00') $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; if ( '' != $title ) $title = ' title="' . $title . '"'; $alt = ' alt="' . $name . '"'; $target = $row->link_target; if ( '' != $target ) $target = ' target="' . $target . '"'; $output .= ''; if ( $row->link_image != null && $show_images ) { if ( strpos($row->link_image, 'http') !== false ) $output .= "link_image\" $alt $title />"; else // If it's a relative path $output .= "link_image\" $alt $title />"; } else { $output .= $name; } $output .= ''; if ( $show_updated && $row->recently_updated ) $output .= get_option('links_recently_updated_append'); if ( $show_description && '' != $desc ) $output .= $between . $desc; if ($show_rating) { $output .= $between . get_linkrating($row); } $output .= "$after\n"; } // end while if ( !$echo ) return $output; echo $output; } /** * Output entire list of links by category. * * Output a list of all links, listed by category, using the settings in * $wpdb->linkcategories and output it as a nested HTML unordered list. * * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use wp_list_bookmarks() * @see wp_list_bookmarks() * * @param string $order Sort link categories by 'name' or 'id' */ function get_links_list($order = 'name') { _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); $order = strtolower($order); // Handle link category sorting $direction = 'ASC'; if ( '_' == substr($order,0,1) ) { $direction = 'DESC'; $order = substr($order,1); } if ( !isset($direction) ) $direction = ''; $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); // Display each category if ( $cats ) { foreach ( (array) $cats as $cat ) { // Handle each category. // Display the category name echo '
  • ' . apply_filters('link_category', $cat->name ) . "

    \n\t
      \n"; // Call get_links() with all the appropriate params get_links($cat->term_id, '
    • ', "
    • ", "\n", true, 'name', false); // Close the last category echo "\n\t
    \n
  • \n"; } } } /** * Show the link to the links popup and the number of links. * * @since 0.71 * @deprecated 2.1.0 * @deprecated {@internal Use function instead is unknown}} * * @param string $text the text of the link * @param int $width the width of the popup window * @param int $height the height of the popup window * @param string $file the page to open in the popup window * @param bool $count the number of links in the db */ function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { _deprecated_function( __FUNCTION__, '2.1' ); } /** * @since 1.0.1 * @deprecated 2.1.0 * @deprecated Use sanitize_bookmark_field() * @see sanitize_bookmark_field() * * @param object $link * @return unknown */ function get_linkrating($link) { _deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' ); return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); } /** * Gets the name of category by id. * * @since 0.71 * @deprecated 2.1.0 * @deprecated Use get_category() * @see get_category() * * @param int $id The category to get. If no category supplied uses 0 * @return string */ function get_linkcatname($id = 0) { _deprecated_function( __FUNCTION__, '2.1', 'get_category()' ); $id = (int) $id; if ( empty($id) ) return ''; $cats = wp_get_link_cats($id); if ( empty($cats) || ! is_array($cats) ) return ''; $cat_id = (int) $cats[0]; // Take the first cat. $cat = get_category($cat_id); return $cat->name; } /** * Print RSS comment feed link. * * @since 1.0.1 * @deprecated 2.5.0 * @deprecated Use post_comments_feed_link() * @see post_comments_feed_link() * * @param string $link_text */ function comments_rss_link($link_text = 'Comments RSS') { _deprecated_function( __FUNCTION__, '2.5', 'post_comments_feed_link()' ); post_comments_feed_link($link_text); } /** * Print/Return link to category RSS2 feed. * * @since 1.2.0 * @deprecated 2.5.0 * @deprecated Use get_category_feed_link() * @see get_category_feed_link() * * @param bool $echo * @param int $cat_ID * @return string|null */ function get_category_rss_link($echo = false, $cat_ID = 1) { _deprecated_function( __FUNCTION__, '2.5', 'get_category_feed_link()' ); $link = get_category_feed_link($cat_ID, 'rss2'); if ( $echo ) echo $link; return $link; } /** * Print/Return link to author RSS feed. * * @since 1.2.0 * @deprecated 2.5.0 * @deprecated Use get_author_feed_link() * @see get_author_feed_link() * * @param bool $echo * @param int $author_id * @return string|null */ function get_author_rss_link($echo = false, $author_id = 1) { _deprecated_function( __FUNCTION__, '2.5', 'get_author_feed_link()' ); $link = get_author_feed_link($author_id); if ( $echo ) echo $link; return $link; } /** * Return link to the post RSS feed. * * @since 1.5.0 * @deprecated 2.2.0 * @deprecated Use get_post_comments_feed_link() * @see get_post_comments_feed_link() * * @return string */ function comments_rss() { _deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' ); return esc_url( get_post_comments_feed_link() ); } /** * An alias of wp_create_user(). * * @since 2.0.0 * @deprecated 2.0.0 * @deprecated Use wp_create_user() * @see wp_create_user() * * @param string $username The user's username. * @param string $password The user's password. * @param string $email The user's email (optional). * @return int The new user's ID. */ function create_user($username, $password, $email) { _deprecated_function( __FUNCTION__, '2.0', 'wp_create_user()' ); return wp_create_user($username, $password, $email); } /** * Unused function. * * @deprecated 2.5.0 */ function gzip_compression() { _deprecated_function( __FUNCTION__, '2.5' ); return false; } /** * Retrieve an array of comment data about comment $comment_ID. * * @since 0.71 * @deprecated 2.7.0 * @deprecated Use get_comment() * @see get_comment() * * @param int $comment_ID The ID of the comment * @param int $no_cache Whether to use the cache (cast to bool) * @param bool $include_unapproved Whether to include unapproved comments * @return array The comment data */ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { _deprecated_function( __FUNCTION__, '2.7', 'get_comment()' ); return get_comment($comment_ID, ARRAY_A); } /** * Retrieve the category name by the category ID. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use get_cat_name() * @see get_cat_name() * * @param int $cat_ID Category ID * @return string category name */ function get_catname( $cat_ID ) { _deprecated_function( __FUNCTION__, '2.8', 'get_cat_name()' ); return get_cat_name( $cat_ID ); } /** * Retrieve category children list separated before and after the term IDs. * * @since 1.2.0 * @deprecated 2.8.0 * @deprecated Use get_term_children() * @see get_term_children() * * @param int $id Category ID to retrieve children. * @param string $before Optional. Prepend before category term ID. * @param string $after Optional, default is empty string. Append after category term ID. * @param array $visited Optional. Category Term IDs that have already been added. * @return string */ function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { _deprecated_function( __FUNCTION__, '2.8', 'get_term_children()' ); if ( 0 == $id ) return ''; $chain = ''; /** TODO: consult hierarchy */ $cat_ids = get_all_category_ids(); foreach ( (array) $cat_ids as $cat_id ) { if ( $cat_id == $id ) continue; $category = get_category( $cat_id ); if ( is_wp_error( $category ) ) return $category; if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { $visited[] = $category->term_id; $chain .= $before.$category->term_id.$after; $chain .= get_category_children( $category->term_id, $before, $after ); } } return $chain; } /** * Retrieve the description of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('description') * @see get_the_author_meta() * * @return string The author's description. */ function get_the_author_description() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' ); return get_the_author_meta('description'); } /** * Display the description of the author of the current post. * * @since 1.0.0 * @deprecated 2.8.0 * @deprecated Use the_author_meta('description') * @see the_author_meta() */ function the_author_description() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' ); the_author_meta('description'); } /** * Retrieve the login name of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('login') * @see get_the_author_meta() * * @return string The author's login name (username). */ function get_the_author_login() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' ); return get_the_author_meta('login'); } /** * Display the login name of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('login') * @see the_author_meta() */ function the_author_login() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' ); the_author_meta('login'); } /** * Retrieve the first name of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('first_name') * @see get_the_author_meta() * * @return string The author's first name. */ function get_the_author_firstname() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' ); return get_the_author_meta('first_name'); } /** * Display the first name of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('first_name') * @see the_author_meta() */ function the_author_firstname() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' ); the_author_meta('first_name'); } /** * Retrieve the last name of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('last_name') * @see get_the_author_meta() * * @return string The author's last name. */ function get_the_author_lastname() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' ); return get_the_author_meta('last_name'); } /** * Display the last name of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('last_name') * @see the_author_meta() */ function the_author_lastname() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' ); the_author_meta('last_name'); } /** * Retrieve the nickname of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('nickname') * @see get_the_author_meta() * * @return string The author's nickname. */ function get_the_author_nickname() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' ); return get_the_author_meta('nickname'); } /** * Display the nickname of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('nickname') * @see the_author_meta() */ function the_author_nickname() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' ); the_author_meta('nickname'); } /** * Retrieve the email of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('email') * @see get_the_author_meta() * * @return string The author's username. */ function get_the_author_email() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' ); return get_the_author_meta('email'); } /** * Display the email of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('email') * @see the_author_meta() */ function the_author_email() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' ); the_author_meta('email'); } /** * Retrieve the ICQ number of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('icq') * @see get_the_author_meta() * * @return string The author's ICQ number. */ function get_the_author_icq() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' ); return get_the_author_meta('icq'); } /** * Display the ICQ number of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('icq') * @see the_author_meta() */ function the_author_icq() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' ); the_author_meta('icq'); } /** * Retrieve the Yahoo! IM name of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('yim') * @see get_the_author_meta() * * @return string The author's Yahoo! IM name. */ function get_the_author_yim() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' ); return get_the_author_meta('yim'); } /** * Display the Yahoo! IM name of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('yim') * @see the_author_meta() */ function the_author_yim() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' ); the_author_meta('yim'); } /** * Retrieve the MSN address of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('msn') * @see get_the_author_meta() * * @return string The author's MSN address. */ function get_the_author_msn() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' ); return get_the_author_meta('msn'); } /** * Display the MSN address of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('msn') * @see the_author_meta() */ function the_author_msn() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' ); the_author_meta('msn'); } /** * Retrieve the AIM address of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('aim') * @see get_the_author_meta() * * @return string The author's AIM address. */ function get_the_author_aim() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')' ); return get_the_author_meta('aim'); } /** * Display the AIM address of the author of the current post. * * @since 0.71 * @see the_author_meta() * @deprecated 2.8.0 * @deprecated Use the_author_meta('aim') */ function the_author_aim() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' ); the_author_meta('aim'); } /** * Retrieve the specified author's preferred display name. * * @since 1.0.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('display_name') * @see get_the_author_meta() * * @param int $auth_id The ID of the author. * @return string The author's display name. */ function get_author_name( $auth_id = false ) { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' ); return get_the_author_meta('display_name', $auth_id); } /** * Retrieve the URL to the home page of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('url') * @see get_the_author_meta() * * @return string The URL to the author's page. */ function get_the_author_url() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' ); return get_the_author_meta('url'); } /** * Display the URL to the home page of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('url') * @see the_author_meta() */ function the_author_url() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' ); the_author_meta('url'); } /** * Retrieve the ID of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 * @deprecated Use get_the_author_meta('ID') * @see get_the_author_meta() * * @return int The author's ID. */ function get_the_author_ID() { _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' ); return get_the_author_meta('ID'); } /** * Display the ID of the author of the current post. * * @since 0.71 * @deprecated 2.8.0 * @deprecated Use the_author_meta('ID') * @see the_author_meta() */ function the_author_ID() { _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' ); the_author_meta('ID'); } /** * Display the post content for the feed. * * For encoding the html or the $encode_html parameter, there are three possible * values. '0' will make urls footnotes and use make_url_footnote(). '1' will * encode special characters and automatically display all of the content. The * value of '2' will strip all HTML tags from the content. * * Also note that you cannot set the amount of words and not set the html * encoding. If that is the case, then the html encoding will default to 2, * which will strip all HTML tags. * * To restrict the amount of words of the content, you can use the cut * parameter. If the content is less than the amount, then there won't be any * dots added to the end. If there is content left over, then dots will be added * and the rest of the content will be removed. * * @since 0.71 * @uses apply_filters() Calls 'the_content_rss' on the content before processing. * * @deprecated 2.9.0 * @deprecated Use the_content_feed() * @see the_content_feed() * * @param string $more_link_text Optional. Text to display when more content is available but not displayed. * @param int|bool $stripteaser Optional. Default is 0. * @param string $more_file Optional. * @param int $cut Optional. Amount of words to keep for the content. * @param int $encode_html Optional. How to encode the content. */ function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' ); $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters('the_content_rss', $content); if ( $cut && !$encode_html ) $encode_html = 2; if ( 1== $encode_html ) { $content = esc_html($content); $cut = 0; } elseif ( 0 == $encode_html ) { $content = make_url_footnote($content); } elseif ( 2 == $encode_html ) { $content = strip_tags($content); } if ( $cut ) { $blah = explode(' ', $content); if ( count($blah) > $cut ) { $k = $cut; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } /** @todo Check performance, might be faster to use array slice instead. */ for ( $i=0; $i<$k; $i++ ) $excerpt .= $blah[$i].' '; $excerpt .= ($use_dotdotdot) ? '...' : ''; $content = $excerpt; } $content = str_replace(']]>', ']]>', $content); echo $content; } /** * Strip HTML and put links at the bottom of stripped content. * * Searches for all of the links, strips them out of the content, and places * them at the bottom of the content with numbers. * * @since 0.71 * @deprecated 2.9.0 * * @param string $content Content to get links * @return string HTML stripped out of content with links at the bottom. */ function make_url_footnote( $content ) { _deprecated_function( __FUNCTION__, '2.9', '' ); preg_match_all( '/(.+?)<\/a>/', $content, $matches ); $links_summary = "\n"; for ( $i=0; $ipost_type) || !$url = wp_get_attachment_url($_post->ID) ) return __('Missing Attachment'); if ( $permalink ) $url = get_attachment_link($_post->ID); $post_title = esc_attr($_post->post_title); $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); return "$innerHTML"; } /** * Retrieve icon URL and Path. * * @since 2.1.0 * @deprecated 2.5.0 * @deprecated Use wp_get_attachment_image_src() * @see wp_get_attachment_image_src() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional, default to false. Whether to have full image. * @return array Icon URL and full path to file, respectively. */ function get_attachment_icon_src( $id = 0, $fullsize = false ) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; $file = get_attached_file( $post->ID ); if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { // We have a thumbnail desired, specified and existing $src_file = basename($src); $class = 'attachmentthumb'; } elseif ( wp_attachment_is_image( $post->ID ) ) { // We have an image without a thumbnail $src = wp_get_attachment_url( $post->ID ); $src_file = & $file; $class = 'attachmentimage'; } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { // No thumb, no image. We'll look for a mime-related icon instead. $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); $src_file = $icon_dir . '/' . basename($src); } if ( !isset($src) || !$src ) return false; return array($src, $src_file); } /** * Retrieve HTML content of icon attachment image element. * * @since 2.0.0 * @deprecated 2.5.0 * @deprecated Use wp_get_attachment_image() * @see wp_get_attachment_image() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional, default to false. Whether to have full size image. * @param array $max_dims Optional. Dimensions of image. * @return string HTML content. */ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) return false; list($src, $src_file) = $src; // Do we need to constrain the image? if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { $imagesize = getimagesize($src_file); if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { $actual_aspect = $imagesize[0] / $imagesize[1]; $desired_aspect = $max_dims[0] / $max_dims[1]; if ( $actual_aspect >= $desired_aspect ) { $height = $actual_aspect * $max_dims[0]; $constraint = "width='{$max_dims[0]}' "; $post->iconsize = array($max_dims[0], $height); } else { $width = $max_dims[1] / $actual_aspect; $constraint = "height='{$max_dims[1]}' "; $post->iconsize = array($width, $max_dims[1]); } } else { $post->iconsize = array($imagesize[0], $imagesize[1]); $constraint = ''; } } else { $constraint = ''; } $post_title = esc_attr($post->post_title); $icon = "$post_title"; return apply_filters( 'attachment_icon', $icon, $post->ID ); } /** * Retrieve HTML content of image element. * * @since 2.0.0 * @deprecated 2.5.0 * @deprecated Use wp_get_attachment_image() * @see wp_get_attachment_image() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional, default to false. Whether to have full size image. * @param array $max_dims Optional. Dimensions of image. * @return string */ function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) return $innerHTML; $innerHTML = esc_attr($post->post_title); return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); } /** * Retrieve bookmark data based on ID. * * @since 2.0.0 * @deprecated 2.1.0 * @deprecated Use get_bookmark() * @see get_bookmark() * * @param int $bookmark_id ID of link * @param string $output OBJECT, ARRAY_N, or ARRAY_A * @return object|array */ function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' ); return get_bookmark($bookmark_id, $output, $filter); } /** * Performs esc_url() for database or redirect usage. * * @since 2.3.1 * @deprecated 2.8.0 * @deprecated Use esc_url_raw() * @see esc_url_raw() * * @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 ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' ); return esc_url_raw( $url, $protocols ); } /** * Checks and cleans a URL. * * A number of characters are removed from the URL. If the URL is for displaying * (the default behaviour) ampersands are also replaced. The 'clean_url' filter * is applied to the returned cleaned URL. * * @since 1.2.0 * @deprecated 3.0.0 * @deprecated Use esc_url() * @see Alias for esc_url() * * @param string $url The URL to be cleaned. * @param array $protocols Optional. An array of acceptable protocols. * @param string $context Optional. How the URL will be used. Default is 'display'. * @return string The cleaned $url after the 'clean_url' filter is applied. */ function clean_url( $url, $protocols = null, $context = 'display' ) { if ( $context == 'db' ) _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' ); else _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' ); return esc_url( $url, $protocols, $context ); } /** * Escape single quotes, specialchar double quotes, and fix line endings. * * The filter 'js_escape' is also applied by esc_js() * * @since 2.0.4 * @deprecated 2.8.0 * @deprecated Use esc_js() * @see esc_js() * * @param string $text The text to be escaped. * @return string Escaped text. */ function js_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_js()' ); return esc_js( $text ); } /** * Escaping for HTML blocks. * * @deprecated 2.8.0 * @deprecated Use esc_html() * @see esc_html() */ function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_html()' ); if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args $args = func_get_args(); return call_user_func_array( '_wp_specialchars', $args ); } else { return esc_html( $string ); } } /** * Escaping for HTML attributes. * * @since 2.0.6 * @deprecated 2.8.0 * @deprecated Use esc_attr() * @see esc_attr() * * @param string $text * @return string */ function attribute_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' ); return esc_attr( $text ); } /** * Register widget for sidebar with backwards compatibility. * * Allows $name to be an array that accepts either three elements to grab the * first element and the third for the name or just uses the first element of * the array for the name. * * Passes to {@link wp_register_sidebar_widget()} after argument list and * backwards compatibility is complete. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_register_sidebar_widget() * @see wp_register_sidebar_widget() * * @param string|int $name Widget ID. * @param callback $output_callback Run when widget is called. * @param string $classname Classname widget option. * @param mixed $params,... Widget parameters. */ function register_sidebar_widget($name, $output_callback, $classname = '') { _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' ); // Compat if ( is_array($name) ) { if ( count($name) == 3 ) $name = sprintf($name[0], $name[2]); else $name = $name[0]; } $id = sanitize_title($name); $options = array(); if ( !empty($classname) && is_string($classname) ) $options['classname'] = $classname; $params = array_slice(func_get_args(), 2); $args = array($id, $name, $output_callback, $options); if ( !empty($params) ) $args = array_merge($args, $params); call_user_func_array('wp_register_sidebar_widget', $args); } /** * Alias of {@link wp_unregister_sidebar_widget()}. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_unregister_sidebar_widget() * @see wp_unregister_sidebar_widget() * * @param int|string $id Widget ID. */ function unregister_sidebar_widget($id) { _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()' ); return wp_unregister_sidebar_widget($id); } /** * Registers widget control callback for customizing options. * * Allows $name to be an array that accepts either three elements to grab the * first element and the third for the name or just uses the first element of * the array for the name. * * Passes to {@link wp_register_widget_control()} after the argument list has * been compiled. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_register_widget_control() * @see wp_register_widget_control() * * @param int|string $name Sidebar ID. * @param callback $control_callback Widget control callback to display and process form. * @param int $width Widget width. * @param int $height Widget height. */ function register_widget_control($name, $control_callback, $width = '', $height = '') { _deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' ); // Compat if ( is_array($name) ) { if ( count($name) == 3 ) $name = sprintf($name[0], $name[2]); else $name = $name[0]; } $id = sanitize_title($name); $options = array(); if ( !empty($width) ) $options['width'] = $width; if ( !empty($height) ) $options['height'] = $height; $params = array_slice(func_get_args(), 4); $args = array($id, $name, $control_callback, $options); if ( !empty($params) ) $args = array_merge($args, $params); call_user_func_array('wp_register_widget_control', $args); } /** * Alias of {@link wp_unregister_widget_control()}. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_unregister_widget_control() * @see wp_unregister_widget_control() * * @param int|string $id Widget ID. */ function unregister_widget_control($id) { _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_widget_control()' ); return wp_unregister_widget_control($id); } /** * Remove user meta data. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use delete_user_meta() * @see delete_user_meta() * * @param int $user_id User ID. * @param string $meta_key Metadata key. * @param mixed $meta_value Metadata value. * @return bool True deletion completed and false if user_id is not a number. */ function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { _deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if ( is_array($meta_value) || is_object($meta_value) ) $meta_value = serialize($meta_value); $meta_value = trim( $meta_value ); $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur && $cur->umeta_id ) do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( ! empty($meta_value) ) $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); else $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( $cur && $cur->umeta_id ) do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } /** * Retrieve user metadata. * * If $user_id is not a number, then the function will fail over with a 'false' * boolean return value. Other returned values depend on whether there is only * one item to be returned, which be that single item type. If there is more * than one metadata value, then it will be list of metadata values. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use get_user_meta() * @see get_user_meta() * * @param int $user_id User ID * @param string $meta_key Optional. Metadata key. * @return mixed */ function get_usermeta( $user_id, $meta_key = '' ) { _deprecated_function( __FUNCTION__, '3.0', 'get_user_meta()' ); global $wpdb; $user_id = (int) $user_id; if ( !$user_id ) return false; if ( !empty($meta_key) ) { $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $user = wp_cache_get($user_id, 'users'); // Check the cached user object if ( false !== $user && isset($user->$meta_key) ) $metas = array($user->$meta_key); else $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); } else { $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); } if ( empty($metas) ) { if ( empty($meta_key) ) return array(); else return ''; } $metas = array_map('maybe_unserialize', $metas); if ( count($metas) == 1 ) return $metas[0]; else return $metas; } /** * Update metadata of user. * * There is no need to serialize values, they will be serialized if it is * needed. The metadata key can only be a string with underscores. All else will * be removed. * * Will remove the metadata, if the meta value is empty. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use update_user_meta() * @see update_user_meta() * * @param int $user_id User ID * @param string $meta_key Metadata key. * @param mixed $meta_value Metadata value. * @return bool True on successful update, false on failure. */ function update_usermeta( $user_id, $meta_key, $meta_value ) { _deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); /** @todo Might need fix because usermeta data is assumed to be already escaped */ if ( is_string($meta_value) ) $meta_value = stripslashes($meta_value); $meta_value = maybe_serialize($meta_value); if (empty($meta_value)) { return delete_usermeta($user_id, $meta_key); } $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur ) do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( !$cur ) $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); else if ( $cur->meta_value != $meta_value ) $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); else return false; clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( !$cur ) do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); else do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } /** * Get users for the blog. * * For setups that use the multi-blog feature. Can be used outside of the * multi-blog feature. * * @since 2.2.0 * @deprecated 3.1.0 * @uses $wpdb WordPress database object for queries * @uses $blog_id The Blog id of the blog for those that use more than one blog * * @param int $id Blog ID. * @return array List of users that are part of that Blog ID */ function get_users_of_blog( $id = '' ) { _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); global $wpdb, $blog_id; if ( empty($id) ) $id = (int) $blog_id; $blog_prefix = $wpdb->get_blog_prefix($id); $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); return $users; } /** * Enable/disable automatic general feed link outputting. * * @since 2.8.0 * @deprecated 3.0.0 * @deprecated Use add_theme_support( 'automatic-feed-links' ) * * @param boolean $add Optional, default is true. Add or remove links. Defaults to true. */ function automatic_feed_links( $add = true ) { _deprecated_function( __FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )" ); if ( $add ) add_theme_support( 'automatic-feed-links' ); else remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ } /** * Retrieve user data based on field. * * @since 1.5.0 * @deprecated 3.0.0 * @deprecated Use get_the_author_meta() * @see get_the_author_meta() */ function get_profile( $field, $user = false ) { _deprecated_function( __FUNCTION__, '3.0', 'get_the_author_meta()' ); if ( $user ) { $user = get_user_by( 'login', $user ); $user = $user->ID; } return get_the_author_meta( $field, $user ); } /** * Number of posts user has written. * * @since 0.71 * @deprecated 3.0.0 * @deprecated Use count_user_posts() * @see count_user_posts() */ function get_usernumposts( $userid ) { _deprecated_function( __FUNCTION__, '3.0', 'count_user_posts()' ); return count_user_posts( $userid ); } /** * Callback used to change %uXXXX to &#YYY; syntax * * @since 2.8.0 * @access private * @deprecated 3.0.0 * * @param array $matches Single Match * @return string An HTML entity */ function funky_javascript_callback($matches) { return "&#".base_convert($matches[1],16,10).";"; } /** * Fixes javascript bugs in browsers. * * Converts unicode characters to HTML numbered entities. * * @since 1.5.0 * @uses $is_macIE * @uses $is_winIE * @deprecated 3.0.0 * * @param string $text Text to be made safe. * @return string Fixed text. */ function funky_javascript_fix($text) { _deprecated_function( __FUNCTION__, '3.0' ); // Fixes for browsers' javascript bugs global $is_macIE, $is_winIE; if ( $is_winIE || $is_macIE ) $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", "funky_javascript_callback", $text); return $text; } /** * Checks that the taxonomy name exists. * * @since 2.3.0 * @deprecated 3.0.0 * @deprecated Use taxonomy_exists() * @see taxonomy_exists() * * @param string $taxonomy Name of taxonomy object * @return bool Whether the taxonomy exists. */ function is_taxonomy( $taxonomy ) { _deprecated_function( __FUNCTION__, '3.0', 'taxonomy_exists()' ); return taxonomy_exists( $taxonomy ); } /** * Check if Term exists. * * @since 2.3.0 * @deprecated 3.0.0 * @deprecated Use term_exists() * @see term_exists() * * @param int|string $term The term to check * @param string $taxonomy The taxonomy name to use * @param int $parent ID of parent term under which to confine the exists search. * @return mixed Get the term id or Term Object, if exists. */ function is_term( $term, $taxonomy = '', $parent = 0 ) { _deprecated_function( __FUNCTION__, '3.0', 'term_exists()' ); return term_exists( $term, $taxonomy, $parent ); } /** * Is the current admin page generated by a plugin? * * @since 1.5.0 * @deprecated 3.1.0 * @deprecated Use global $plugin_page and/or get_plugin_page_hookname() hooks. * * @global $plugin_page * * @return bool */ function is_plugin_page() { _deprecated_function( __FUNCTION__, '3.1' ); global $plugin_page; if ( isset($plugin_page) ) return true; return false; } /** * Update the categories cache. * * This function does not appear to be used anymore or does not appear to be * needed. It might be a legacy function left over from when there was a need * for updating the category cache. * * @since 1.5.0 * @deprecated 3.1.0 * * @return bool Always return True */ function update_category_cache() { _deprecated_function( __FUNCTION__, '3.1' ); return true; } /** * Check for PHP timezone support * * @since 2.9.0 * @deprecated 3.2.0 * * @return bool */ function wp_timezone_supported() { _deprecated_function( __FUNCTION__, '3.2' ); return true; } /** * Display editor: TinyMCE, HTML, or both. * * @since 2.1.0 * @deprecated 3.3.0 * @deprecated Use wp_editor() * @see wp_editor() * * @param string $content Textarea content. * @param string $id Optional, default is 'content'. HTML ID attribute value. * @param string $prev_id Optional, not used * @param bool $media_buttons Optional, default is true. Whether to display media buttons. * @param int $tab_index Optional, not used */ function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); return; } /** * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users * * @since 3.0.0 * @deprecated 3.3.0 * * @param array $ids User ID numbers list. * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. */ function get_user_metavalues($ids) { _deprecated_function( __FUNCTION__, '3.3' ); $objects = array(); $ids = array_map('intval', $ids); foreach ( $ids as $id ) $objects[$id] = array(); $metas = update_meta_cache('user', $ids); foreach ( $metas as $id => $meta ) { foreach ( $meta as $key => $metavalues ) { foreach ( $metavalues as $value ) { $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); } } } return $objects; } /** * Sanitize every user field. * * If the context is 'raw', then the user object or array will get minimal santization of the int fields. * * @since 2.3.0 * @deprecated 3.3.0 * * @param object|array $user The User Object or Array * @param string $context Optional, default is 'display'. How to sanitize user fields. * @return object|array The now sanitized User Object or Array (will be the same type as $user) */ function sanitize_user_object($user, $context = 'display') { _deprecated_function( __FUNCTION__, '3.3' ); if ( is_object($user) ) { if ( !isset($user->ID) ) $user->ID = 0; if ( !is_a( $user, 'WP_User' ) ) { $vars = get_object_vars($user); foreach ( array_keys($vars) as $field ) { if ( is_string($user->$field) || is_numeric($user->$field) ) $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); } } $user->filter = $context; } else { if ( !isset($user['ID']) ) $user['ID'] = 0; foreach ( array_keys($user) as $field ) $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); $user['filter'] = $context; } return $user; } /** * Get boundary post relational link. * * Can either be start or end post relational link. * * @since 2.8.0 * @deprecated 3.3.0 * * @param string $title Optional. Link title format. * @param bool $in_same_cat Optional. Whether link should be in a same category. * @param string $excluded_categories Optional. Excluded categories IDs. * @param bool $start Optional, default is true. Whether to display link to first or last post. * @return string */ function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { _deprecated_function( __FUNCTION__, '3.3' ); $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); // If there is no post stop. if ( empty($posts) ) return; // Even though we limited get_posts to return only 1 item it still returns an array of objects. $post = $posts[0]; if ( empty($post->post_title) ) $post->post_title = $start ? __('First Post') : __('Last Post'); $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); $title = apply_filters('the_title', $title, $post->ID); $link = $start ? "\n"; $boundary = $start ? 'start' : 'end'; return apply_filters( "{$boundary}_post_rel_link", $link ); } /** * Display relational link for the first post. * * @since 2.8.0 * @deprecated 3.3.0 * * @param string $title Optional. Link title format. * @param bool $in_same_cat Optional. Whether link should be in a same category. * @param string $excluded_categories Optional. Excluded categories IDs. */ function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { _deprecated_function( __FUNCTION__, '3.3' ); echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); } /** * Get site index relational link. * * @since 2.8.0 * @deprecated 3.3.0 * * @return string */ function get_index_rel_link() { _deprecated_function( __FUNCTION__, '3.3' ); $link = "\n"; return apply_filters( "index_rel_link", $link ); } /** * Display relational link for the site index. * * @since 2.8.0 * @deprecated 3.3.0 */ function index_rel_link() { _deprecated_function( __FUNCTION__, '3.3' ); echo get_index_rel_link(); } /** * Get parent post relational link. * * @since 2.8.0 * @deprecated 3.3.0 * * @param string $title Optional. Link title format. * @return string */ function get_parent_post_rel_link($title = '%title') { _deprecated_function( __FUNCTION__, '3.3' ); if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) $post = get_post($GLOBALS['post']->post_parent); if ( empty($post) ) return; $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); $title = apply_filters('the_title', $title, $post->ID); $link = "\n"; return apply_filters( "parent_post_rel_link", $link ); } /** * Display relational link for parent item * * @since 2.8.0 * @deprecated 3.3.0 */ function parent_post_rel_link($title = '%title') { _deprecated_function( __FUNCTION__, '3.3' ); echo get_parent_post_rel_link($title); } /** * Add the "Dashboard"/"Visit Site" menu. * * @since 3.2.0 * @deprecated 3.3.0 */ function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { _deprecated_function( __FUNCTION__, '3.3' ); $user_id = get_current_user_id(); if ( 0 != $user_id ) { if ( is_admin() ) $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); elseif ( is_multisite() ) $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); else $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); } } /** * Checks if the current user belong to a given blog. * * @since MU * @deprecated 3.3.0 * @deprecated Use is_user_member_of_blog() * @see is_user_member_of_blog() * * @param int $blog_id Blog ID * @return bool True if the current users belong to $blog_id, false if not. */ function is_blog_user( $blog_id = 0 ) { _deprecated_function( __FUNCTION__, '3.3', 'is_user_member_of_blog()' ); return is_user_member_of_blog( get_current_user_id(), $blog_id ); } /** * Open the file handle for debugging. * * @since 0.71 * @deprecated Use error_log() * @link http://www.php.net/manual/en/function.error-log.php * @deprecated 3.4.0 */ function debug_fopen( $filename, $mode ) { _deprecated_function( __FUNCTION__, 'error_log()' ); return false; } /** * Write contents to the file used for debugging. * * @since 0.71 * @deprecated Use error_log() instead. * @link http://www.php.net/manual/en/function.error-log.php * @deprecated 3.4.0 */ function debug_fwrite( $fp, $string ) { _deprecated_function( __FUNCTION__, 'error_log()' ); if ( ! empty( $GLOBALS['debug'] ) ) error_log( $string ); } /** * Close the debugging file handle. * * @since 0.71 * @deprecated Use error_log() * @link http://www.php.net/manual/en/function.error-log.php * @deprecated 3.4.0 */ function debug_fclose( $fp ) { _deprecated_function( __FUNCTION__, 'error_log()' ); } /** * Retrieve list of themes with theme data in theme directory. * * The theme is broken, if it doesn't have a parent theme and is missing either * style.css and, or index.php. If the theme has a parent theme then it is * broken, if it is missing style.css; index.php is optional. * * @since 1.5.0 * @deprecated 3.4.0 * @deprecated Use wp_get_themes() * @see wp_get_themes() * * @return array Theme list with theme data. */ function get_themes() { _deprecated_function( __FUNCTION__, '3.4', 'wp_get_themes()' ); global $wp_themes; if ( isset( $wp_themes ) ) return $wp_themes; $themes = wp_get_themes(); $wp_themes = array(); foreach ( $themes as $theme ) { $name = $theme->get('Name'); if ( isset( $wp_themes[ $name ] ) ) $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; else $wp_themes[ $name ] = $theme; } return $wp_themes; } /** * Retrieve theme data. * * @since 1.5.0 * @deprecated 3.4.0 * @deprecated Use wp_get_theme() * @see wp_get_theme() * * @param string $theme Theme name. * @return array|null Null, if theme name does not exist. Theme data, if exists. */ function get_theme( $theme ) { _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme( $stylesheet )' ); $themes = get_themes(); if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) return $themes[ $theme ]; return null; } /** * Retrieve current theme name. * * @since 1.5.0 * @deprecated 3.4.0 * @deprecated Use (string) wp_get_theme() * @see wp_get_theme() * * @return string */ function get_current_theme() { _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); if ( $theme = get_option( 'current_theme' ) ) return $theme; return wp_get_theme()->get('Name'); } /** * 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 * @deprecated 3.4.0 * * @param array|string $matches The array or string * @return string The pre block without paragraph/line-break conversion. */ function clean_pre($matches) { _deprecated_function( __FUNCTION__, '3.4' ); if ( is_array($matches) ) $text = $matches[1] . $matches[2] . ""; else $text = $matches; $text = str_replace(array('
    ', '
    ', '
    '), array('', '', ''), $text); $text = str_replace('

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

    ', '', $text); return $text; } /** * Add callbacks for image header display. * * @since 2.1.0 * @deprecated 3.4.0 * @deprecated Use add_theme_support('custom-header', $args) * @see add_theme_support() * * @param callback $wp_head_callback Call on 'wp_head' action. * @param callback $admin_head_callback Call on custom header administration screen. * @param callback $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. */ function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-header\', $args )' ); $args = array( 'wp-head-callback' => $wp_head_callback, 'admin-head-callback' => $admin_head_callback, ); if ( $admin_preview_callback ) $args['admin-preview-callback'] = $admin_preview_callback; return add_theme_support( 'custom-header', $args ); } /** * Remove image header support. * * @since 3.1.0 * @deprecated 3.4.0 * @deprecated Use remove_theme_support('custom-header') * @see remove_theme_support() * * @return bool Whether support was removed. */ function remove_custom_image_header() { _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-header\' )' ); return remove_theme_support( 'custom-header' ); } /** * Add callbacks for background image display. * * @since 3.0.0 * @deprecated 3.4.0 * @deprecated Use add_theme_support('custom-background, $args) * @see add_theme_support() * * @param callback $wp_head_callback Call on 'wp_head' action. * @param callback $admin_head_callback Call on custom background administration screen. * @param callback $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. */ function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-background\', $args )' ); $args = array(); if ( $wp_head_callback ) $args['wp-head-callback'] = $wp_head_callback; if ( $admin_head_callback ) $args['admin-head-callback'] = $admin_head_callback; if ( $admin_preview_callback ) $args['admin-preview-callback'] = $admin_preview_callback; return add_theme_support( 'custom-background', $args ); } /** * Remove custom background support. * * @since 3.1.0 * @see add_custom_background() * * @return bool Whether support was removed. */ function remove_custom_background() { _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-background\' )' ); return remove_theme_support( 'custom-background' ); } /** * Retrieve theme data from parsed theme file. * * @since 1.5.0 * @deprecated 3.4.0 * @deprecated Use wp_get_theme() * @see wp_get_theme() * * @param string $theme_file Theme file path. * @return array Theme data. */ function get_theme_data( $theme_file ) { _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); $theme_data = array( 'Name' => $theme->get('Name'), 'URI' => $theme->display('ThemeURI', true, false), 'Description' => $theme->display('Description', true, false), 'Author' => $theme->display('Author', true, false), 'AuthorURI' => $theme->display('AuthorURI', true, false), 'Version' => $theme->get('Version'), 'Template' => $theme->get('Template'), 'Status' => $theme->get('Status'), 'Tags' => $theme->get('Tags'), 'Title' => $theme->get('Name'), 'AuthorName' => $theme->get('Author'), ); foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { if ( ! isset( $theme_data[ $extra_header ] ) ) $theme_data[ $extra_header ] = $theme->get( $extra_header ); } return $theme_data; } /** * Alias of update_post_cache(). * * @see update_post_cache() Posts and pages are the same, alias is intentional * * @since 1.5.1 * @deprecated 3.4.0 * * @param array $pages list of page objects */ function update_page_cache( &$pages ) { _deprecated_function( __FUNCTION__, '3.4', 'update_post_cache()' ); update_post_cache( $pages ); } /** * Will clean the page in the cache. * * Clean (read: delete) page from cache that matches $id. Will also clean cache * associated with 'all_page_ids' and 'get_pages'. * * @since 2.0.0 * @deprecated 3.4.0 * * @uses do_action() Will call the 'clean_page_cache' hook action. * * @param int $id Page ID to clean */ function clean_page_cache( $id ) { _deprecated_function( __FUNCTION__, '3.4', 'clean_post_cache()' ); clean_post_cache( $id ); } /** * Retrieve nonce action "Are you sure" message. * * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3. * * @since 2.0.4 * @deprecated 3.4.1 * @deprecated Use wp_nonce_ays() * @see wp_nonce_ays() * * @param string $action Nonce action. * @return string Are you sure message. */ function wp_explain_nonce( $action ) { _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); return __( 'Are you sure you want to do this?' ); } /** * Display "sticky" CSS class, if a post is sticky. * * @since 2.7.0 * @deprecated 3.5.0 * @deprecated Use post_class() * @see post_class() * * @param int $post_id An optional post ID. */ function sticky_class( $post_id = null ) { _deprecated_function( __FUNCTION__, '3.5', 'post_class()' ); if ( is_sticky( $post_id ) ) echo ' sticky'; } /** * Retrieve post ancestors. * * This is no longer needed as WP_Post lazy-loads the ancestors * property with get_post_ancestors(). * * @since 2.3.4 * @deprecated 3.5.0 * @see get_post_ancestors() */ function _get_post_ancestors( &$post ) { _deprecated_function( __FUNCTION__, '3.5' ); } /** * Load an image from a string, if PHP supports it. * * @since 2.1.0 * @deprecated 3.5.0 * @see wp_get_image_editor() * * @param string $file Filename of the image to load. * @return resource The resulting image resource on success, Error string on failure. */ function wp_load_image( $file ) { _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); if ( is_numeric( $file ) ) $file = get_attached_file( $file ); if ( ! is_file( $file ) ) return sprintf(__('File “%s” doesn’t exist?'), $file); if ( ! function_exists('imagecreatefromstring') ) return __('The GD image library is not installed.'); // Set artificially high because GD uses uncompressed images in memory @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); $image = imagecreatefromstring( file_get_contents( $file ) ); if ( !is_resource( $image ) ) return sprintf(__('File “%s” is not an image.'), $file); return $image; } /** * Scale down an image to fit a particular size and save a new copy of the image. * * The PNG transparency will be preserved using the function, as well as the * image type. If the file going in is PNG, then the resized image is going to * be PNG. The only supported image types are PNG, GIF, and JPEG. * * Some functionality requires API to exist, so some PHP version may lose out * support. This is not the fault of WordPress (where functionality is * downgraded, not actual defects), but of your PHP version. * * @since 2.5.0 * @deprecated 3.5.0 * @see wp_get_image_editor() * * @param string $file Image file path. * @param int $max_w Maximum width to resize to. * @param int $max_h Maximum height to resize to. * @param bool $crop Optional. Whether to crop image or resize. * @param string $suffix Optional. File suffix. * @param string $dest_path Optional. New image file path. * @param int $jpeg_quality Optional, default is 90. Image quality percentage. * @return mixed WP_Error on failure. String with new destination path. */ function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); $editor = wp_get_image_editor( $file ); if ( is_wp_error( $editor ) ) return $editor; $editor->set_quality( $jpeg_quality ); $resized = $editor->resize( $max_w, $max_h, $crop ); if ( is_wp_error( $resized ) ) return $resized; $dest_file = $editor->generate_filename( $suffix, $dest_path ); $saved = $editor->save( $dest_file ); if ( is_wp_error( $saved ) ) return $saved; return $dest_file; } /** * Retrieve a single post, based on post ID. * * Has categories in 'post_category' property or key. Has tags in 'tags_input' * property or key. * * @since 1.0.0 * @deprecated 3.5.0 * @see get_post() * * @param int $postid Post ID. * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. * @return object|array Post object or array holding post contents and information */ function wp_get_single_post( $postid = 0, $mode = OBJECT ) { _deprecated_function( __FUNCTION__, '3.5', 'get_post()' ); return get_post( $postid, $mode ); } /** * Check that the user login name and password is correct. * * @since 0.71 * @deprecated 3.5.0 * @deprecated Use wp_authenticate() * @see wp_authenticate() * * @param string $user_login User name. * @param string $user_pass User password. * @return bool False if does not authenticate, true if username and password authenticates. */ function user_pass_ok($user_login, $user_pass) { _deprecated_function( __FUNCTION__, '3.5', 'wp_authenticate()' ); $user = wp_authenticate( $user_login, $user_pass ); if ( is_wp_error( $user ) ) return false; return true; } /** * Callback formerly fired on the save_post hook. No longer needed. * * @since 2.3.0 * @deprecated 3.5.0 */ function _save_post_hook() {} /** * Check if the installed version of GD supports particular image type * * @since 2.9.0 * @deprecated 3.5.0 * @see wp_image_editor_supports() * * @param string $mime_type * @return bool */ function gd_edit_image_support($mime_type) { _deprecated_function( __FUNCTION__, '3.5', 'wp_image_editor_supports()' ); if ( function_exists('imagetypes') ) { switch( $mime_type ) { case 'image/jpeg': return (imagetypes() & IMG_JPG) != 0; case 'image/png': return (imagetypes() & IMG_PNG) != 0; case 'image/gif': return (imagetypes() & IMG_GIF) != 0; } } else { switch( $mime_type ) { case 'image/jpeg': return function_exists('imagecreatefromjpeg'); case 'image/png': return function_exists('imagecreatefrompng'); case 'image/gif': return function_exists('imagecreatefromgif'); } } return false; } /** * Converts an integer byte value to a shorthand byte value. * * @since 2.3.0 * @deprecated 3.6.0 * @deprecated Use size_format() * * @param int $bytes An integer byte value. * @return string A shorthand byte value. */ function wp_convert_bytes_to_hr( $bytes ) { _deprecated_function( __FUNCTION__, '3.6', 'size_format()' ); $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); $log = log( $bytes, 1024 ); $power = (int) $log; $size = pow( 1024, $log - $power ); if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { $unit = $units[ $power ]; } else { $size = $bytes; $unit = $units[0]; } return $size . $unit; } /** * Formerly used internally to tidy up the search terms. * * @access private * @since 2.9.0 * @deprecated 3.7.0 */ function _search_terms_tidy( $t ) { _deprecated_function( __FUNCTION__, '3.7' ); return trim( $t, "\"'\n\r " ); } /** * Determine if TinyMCE is available. * * Checks to see if the user has deleted the tinymce files to slim down * their WordPress install. * * @since 2.1.0 * @deprecated 3.9.0 * * @return bool Whether TinyMCE exists. */ function rich_edit_exists() { global $wp_rich_edit_exists; _deprecated_function( __FUNCTION__, '3.9' ); if ( ! isset( $wp_rich_edit_exists ) ) $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); return $wp_rich_edit_exists; } /** * Old callback for tag link tooltips. * * @since 2.7.0 * @deprecated 3.9.0 * @access private */ function default_topic_count_text( $count ) { return $count; } /** * Formerly used to escape strings before inserting into the DB. * * Has not performed this function for many, many years. Use wpdb::prepare() instead. * * @since 0.71 * @deprecated 3.9.0 * * @param string $content The text to format. * @return string The very same text. */ function format_to_post( $content ) { _deprecated_function( __FUNCTION__, '3.9' ); return $content; } /** * 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. * * Several constants are used to manage the loading, concatenating and compression of scripts and CSS: * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation, * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS, * define('COMPRESS_SCRIPTS', false); disables compression of scripts, * define('COMPRESS_CSS', false); disables compression of CSS, * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate). * * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins * to temporarily override the above settings. Also a compression test is run once and the result is saved * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted. * * @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' ); /** * Register all WordPress scripts. * * Localizes some of them. * args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 ); * when last arg === 1 queues the script for the footer * * @since 2.6.0 * * @param object $scripts WP_Scripts object. */ function wp_default_scripts( &$scripts ) { include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version $develop_src = false !== strpos( $wp_version, '-src' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', $develop_src ); } if ( ! $guessurl = site_url() ) { $guessed_url = true; $guessurl = wp_guess_url(); } $scripts->base_url = $guessurl; $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; $scripts->default_version = get_bloginfo( 'version' ); $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/'); $suffix = SCRIPT_DEBUG ? '' : '.min'; $dev_suffix = $develop_src ? '' : '.min'; $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array( 'url' => (string) SITECOOKIEPATH, 'uid' => (string) get_current_user_id(), 'time' => (string) time(), ) ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array( 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.") ) ); $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array( 'closeAllOpenTags' => esc_attr(__('Close all open tags')), 'closeTags' => esc_attr(__('close tags')), 'enterURL' => __('Enter the URL'), 'enterImageURL' => __('Enter the URL of the image'), 'enterImageDescription' => __('Enter a description of the image'), 'fullscreen' => __('fullscreen'), 'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ), 'textdirection' => esc_attr( __('text direction') ), 'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') ) ) ); $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 ); $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 ); $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 'noPerm' => __('You do not have permission to do that.'), 'broken' => __('An unidentified error has occurred.') ) ); $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 ); did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array( 'dismiss' => __('Dismiss'), ) ); $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), false, 1 ); $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings', /** * Filter the Heartbeat settings. * * @since 3.6.0 * * @param array $settings Heartbeat settings array. */ apply_filters( 'heartbeat_settings', array() ) ); $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array('heartbeat'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array( 'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'), /** * Filter the authentication check interval. * * @since 3.6.0 * * @param int $interval The interval in which to check a user's authentication. * Default 3 minutes in seconds, or 180. */ 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ), ) ); $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source. $scripts->add( 'prototype', '//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1'); $scripts->add( 'scriptaculous-root', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0'); $scripts->add( 'scriptaculous-builder', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0'); $scripts->add( 'scriptaculous-dragdrop', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0'); $scripts->add( 'scriptaculous-effects', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0'); $scripts->add( 'scriptaculous-slider', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0'); $scripts->add( 'scriptaculous-sound', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-controls', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0'); $scripts->add( 'scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls') ); // not used in core, replaced by Jcrop.js $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop') ); // jQuery $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.0' ); $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.0' ); $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.2.1' ); // full jQuery UI $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui/jquery.ui.core.min.js', array('jquery'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-core', '/wp-includes/js/jquery/ui/jquery.ui.effect.min.js', array('jquery'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-blind', '/wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-bounce', '/wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-clip', '/wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-drop', '/wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-explode', '/wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-fade', '/wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-fold', '/wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-highlight', '/wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-pulsate', '/wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-scale', '/wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-shake', '/wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-slide', '/wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-effects-transfer', '/wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js', array('jquery-effects-core'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-accordion', '/wp-includes/js/jquery/ui/jquery.ui.accordion.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-autocomplete', '/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-menu'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui/jquery.ui.button.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-datepicker', '/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js', array('jquery-ui-core'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui/jquery.ui.draggable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui/jquery.ui.droppable.min.js', array('jquery-ui-draggable'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-menu', '/wp-includes/js/jquery/ui/jquery.ui.menu.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 ); $scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui/jquery.ui.mouse.min.js', array('jquery-ui-widget'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui/jquery.ui.position.min.js', array('jquery'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-progressbar', '/wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js', array('jquery-ui-widget'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui/jquery.ui.resizable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui/jquery.ui.selectable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-slider', '/wp-includes/js/jquery/ui/jquery.ui.slider.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui/jquery.ui.sortable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-spinner', '/wp-includes/js/jquery/ui/jquery.ui.spinner.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-button' ), '1.10.4', 1 ); $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 ); $scripts->add( 'jquery-ui-tooltip', '/wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 ); $scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui/jquery.ui.widget.min.js', array('jquery'), '1.10.4', 1 ); // deprecated, not used in core, most functionality is included in jQuery 1.3 $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '3.37.0', 1 ); // jQuery plugins $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 ); $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 ); $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 ); $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 ); $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 ); $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 ); $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 ); $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 ); // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv. // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way. $scripts->add( 'masonry', "/wp-includes/js/masonry.min.js", array(), '3.1.2', 1 ); $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2', 1 ); $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 ); did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( 'next' => __('Next >'), 'prev' => __('< Prev'), 'image' => __('Image'), 'of' => __('of'), 'close' => __('Close'), 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), ) ); $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12'); $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", array(), '2.2-20120417'); // common bits for both uploaders $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post; if ( empty($max_upload_size) ) $max_upload_size = __('not configured'); // error message for both plupload and swfupload $uploader_l10n = array( 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'), 'zero_byte_file' => __('This file is empty. Please try another.'), 'invalid_filetype' => __('This file type is not allowed. Please try another.'), 'not_an_image' => __('This file is not an image. Please try another.'), 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'), 'image_dimensions_exceeded' => __('This is larger than the maximum size. 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.'), 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'), 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'), 'io_error' => __('IO error.'), 'security_error' => __('Security error.'), 'file_cancelled' => __('File canceled.'), 'upload_stopped' => __('Upload stopped.'), 'dismiss' => __('Dismiss'), 'crunching' => __('Crunching…'), 'deleted' => __('moved to the trash.'), 'error_uploading' => __('“%s” has failed to upload.') ); $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.1' ); // Back compat handles: foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' ); } $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) ); did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); // keep 'swfupload' for back-compat. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113'); $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a'); $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201'); $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201'); $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201'); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524'); did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n ); $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23'); $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.6.0', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.1.2', 1 ); $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( 'ajax' => array( 'url' => admin_url( 'admin-ajax.php', 'relative' ), ), ) ); $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 ); $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 ); $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.10', 1 ); $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '2.14.2', 1 ); did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array( 'language' => get_bloginfo( 'language' ), 'strings' => array( 'Close' => __( 'Close' ), 'Fullscreen' => __( 'Fullscreen' ), 'Download File' => __( 'Download File' ), 'Download Video' => __( 'Download Video' ), 'Play/Pause' => __( 'Play/Pause' ), 'Mute Toggle' => __( 'Mute Toggle' ), 'None' => __( 'None' ), 'Turn off Fullscreen' => __( 'Turn off Fullscreen' ), 'Go Fullscreen' => __( 'Go Fullscreen' ), 'Unmute' => __( 'Unmute' ), 'Mute' => __( 'Mute' ), 'Captions/Subtitles' => __( 'Captions/Subtitles' ) ), ) ); $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', array( 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), ) ); $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' ); did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array( 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js', ) ); $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 'empty' => __('Strength indicator'), 'short' => __('Very weak'), 'bad' => __('Weak'), /* translators: password strength */ 'good' => _x('Medium', 'password strength'), 'strong' => __('Strong'), 'mismatch' => __('Mismatch') ) ); $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 ); $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 'title' => __('Insert/edit link'), 'update' => __('Update'), 'save' => __('Add Link'), 'noTitle' => __('(no title)'), 'noMatchesFound' => __('No matches found.') ) ); $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array( /* translators: If your word count is based on single characters (East Asian characters), enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ 'type' => 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w', ) ); $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r7', 1 ); $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 ); $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 ); $scripts->add( 'customize-models', "/wp-includes/js/customize-models.js", array( 'underscore', 'backbone' ), false, 1 ); $scripts->add( 'customize-views', "/wp-includes/js/customize-views.js", array( 'jquery', 'underscore', 'imgareaselect', 'customize-models' ), false, 1 ); $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( 'activate' => __( 'Save & Activate' ), 'save' => __( 'Save & Publish' ), 'saved' => __( 'Saved' ), 'cancel' => __( 'Cancel' ), 'close' => __( 'Close' ), 'cheatin' => __( 'Cheatin’ uh?' ), // Used for overriding the file types allowed in plupload. 'allowedFiles' => __( 'Allowed Files' ), ) ); $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array( 'settings' => array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 'post' => array( 'id' => 0 ), ), ) ); // To enqueue media-views or media-editor, call wp_enqueue_media(). // Both rely on numerous settings, styles, and templates to operate correctly. $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 ); $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 ); if ( is_admin() ) { $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array( 'noPerm' => __('You do not have permission to do that.'), 'broken' => __('An unidentified error has occurred.') )); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 'replyApprove' => __( 'Approve and Reply' ), 'reply' => __( 'Reply' ) ) ); $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 ); $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'heartbeat'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array( 'ok' => __('OK'), 'cancel' => __('Cancel'), 'publishOn' => __('Publish on:'), 'publishOnFuture' => __('Schedule for:'), 'publishOnPast' => __('Published on:'), /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ 'dateFormat' => __('%1$s %2$s, %3$s @ %4$s : %5$s'), 'showcomm' => __('Show more comments'), 'endcomm' => __('No more comments found.'), 'publish' => __('Publish'), 'schedule' => __('Schedule'), 'update' => __('Update'), 'savePending' => __('Save as Pending'), 'saveDraft' => __('Save Draft'), 'private' => __('Private'), 'public' => __('Public'), 'publicSticky' => __('Public, Sticky'), 'password' => __('Password Protected'), 'privatelyPublished' => __('Privately Published'), 'published' => __('Published'), 'comma' => _x( ',', 'tag delimiter' ), 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 'savingText' => __('Saving Draft…'), ) ); $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) ); $scripts->add_data( 'comment', 'group', 1 ); did_action( 'init' ) && $scripts->localize( 'comment', 'commentL10n', array( 'submittedOn' => __('Submitted on:') ) ); $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) ); $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 ); $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone' ), false, 1 ); $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'heartbeat' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.'), 'ntdeltitle' => __('Remove From Bulk Edit'), 'notitle' => __('(no title)'), 'comma' => _x( ',', 'tag delimiter' ), ) ); $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( 'error' => __('Error while saving the changes.') ) ); $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'plugin-install', 'plugininstallL10n', array( 'plugin_information' => __('Plugin Information:'), 'ays' => __('Are you sure you want to install this plugin?') ) ); $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery' ) ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array( 'clear' => __( 'Clear' ), 'defaultString' => __( 'Default' ), 'pick' => __( 'Select Color' ), 'current' => __( 'Current Color' ), ) ); $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 ); $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array( 'error' => __( 'An error has occurred. Please reload the page and try again.' ), )); $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'image-edit', 'imageEditL10n', array( 'error' => __( 'Could not load the preview image. Please reload the page and try again.' ) )); $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array( 'setThumbnail' => __( 'Use as featured image' ), 'saving' => __( 'Saving...' ), 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), 'done' => __( 'Done' ) ) ); // Navigation Menus $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox' ) ); did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array( 'noResultsFound' => _x('No results found.', 'search results'), 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ), 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') ) ); $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 ); } } /** * 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 ) { include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version if ( ! defined( 'SCRIPT_DEBUG' ) ) define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); if ( ! $guessurl = site_url() ) $guessurl = wp_guess_url(); $styles->base_url = $guessurl; $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; $styles->default_version = get_bloginfo( 'version' ); $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/'); $open_sans_font_url = ''; /* translators: If there are characters in your language that are not supported * by Open Sans, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { $subsets = 'latin,latin-ext'; /* translators: To add an additional Open Sans character subset specific to your language, * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); if ( 'cyrillic' == $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; } elseif ( 'greek' == $subset ) { $subsets .= ',greek,greek-ext'; } elseif ( 'vietnamese' == $subset ) { $subsets .= ',vietnamese'; } // Hotlink Open Sans, for now $open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets"; } // Register a stylesheet for the selected admin color scheme. $styles->add( 'colors', true, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) ); $suffix = SCRIPT_DEBUG ? '' : '.min'; // Admin CSS $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array( 'open-sans', 'dashicons' ) ); $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'buttons', 'open-sans', 'dashicons' ) ); $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'buttons', 'open-sans' ) ); $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) ); $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" ); $styles->add_data( 'ie', 'conditional', 'lte IE 7' ); // Common dependencies $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); $styles->add( 'open-sans', $open_sans_font_url ); // Includes CSS $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'open-sans', 'dashicons' ) ); $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); // External libraries and friends $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.13.0' ); $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) ); $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); // Deprecated CSS $styles->add( 'media', "/wp-admin/css/deprecated-media$suffix.css" ); $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u1' ); $styles->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' ); $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. // RTL CSS $rtl_styles = array( // wp-admin 'wp-admin', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'ie', 'login', // wp-includes 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer', 'wp-jquery-ui-dialog', // deprecated 'media', 'farbtastic', ); foreach ( $rtl_styles as $rtl_style ) { $styles->add_data( $rtl_style, 'rtl', 'replace' ); if ( $suffix ) { $styles->add_data( $rtl_style, 'suffix', $suffix ); } } } /** * Reorder JavaScript scripts array to place prototype before jQuery. * * @since 2.3.1 * * @param array $js_array JavaScript scripts array * @return array Reordered array, if needed. */ function wp_prototype_before_jquery( $js_array ) { if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) return $js_array; if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) 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 data on print rather than initialization. * * These localizations require information that may not be loaded even by init. * * @since 2.5.0 */ function wp_just_in_time_script_localization() { wp_localize_script( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => AUTOSAVE_INTERVAL, 'blog_id' => get_current_blog_id(), ) ); } /** * Administration Screen CSS for changing the styles. * * If installing the 'wp-admin/' directory will be replaced with './'. * * The $_wp_admin_css_colors global manages the Administration Screens 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 Screens. */ function wp_style_loader_src( $src, $handle ) { global $_wp_admin_css_colors; if ( defined('WP_INSTALLING') ) return preg_replace( '#^wp-admin/#', './', $src ); if ( 'colors' == $handle ) { $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 ( ! $url ) { return false; } if ( isset($parsed['query']) && $parsed['query'] ) { wp_parse_str( $parsed['query'], $qv ); $url = add_query_arg( $qv, $url ); } return $url; } return $src; } /** * Prints the script queue in the HTML head on admin pages. * * Postpones the scripts that were queued for the footer. * print_footer_scripts() is called in the footer to print these scripts. * * @since 2.8.0 * * @see wp_print_scripts() */ function print_head_scripts() { global $wp_scripts, $concatenate_scripts; if ( ! did_action('wp_print_scripts') ) { /** This action is documented in wp-includes/functions.wp-scripts.php */ do_action( 'wp_print_scripts' ); } if ( !is_a($wp_scripts, 'WP_Scripts') ) $wp_scripts = new WP_Scripts(); script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_head_items(); /** * Filter whether to print the head scripts. * * @since 2.8.0 * * @param bool $print Whether to print the head scripts. Default true. */ if ( apply_filters( 'print_head_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } /** * Prints the scripts that were queued for the footer or too late for the HTML head. * * @since 2.8.0 */ function print_footer_scripts() { global $wp_scripts, $concatenate_scripts; if ( !is_a($wp_scripts, 'WP_Scripts') ) return array(); // No need to run if not instantiated. script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_footer_items(); /** * Filter whether to print the footer scripts. * * @since 2.8.0 * * @param bool $print Whether to print the footer scripts. Default true. */ if ( apply_filters( 'print_footer_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } /** * @internal use */ function _print_scripts() { global $wp_scripts, $compress_scripts; $zip = $compress_scripts ? 1 : 0; if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) $zip = 'gzip'; if ( $concat = trim( $wp_scripts->concat, ', ' ) ) { if ( !empty($wp_scripts->print_code) ) { echo "\n\n"; } $concat = str_split( $concat, 128 ); $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat ); $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&" . $concat . '&ver=' . $wp_scripts->default_version; echo "\n"; } if ( !empty($wp_scripts->print_html) ) echo $wp_scripts->print_html; } /** * Prints the script queue in the HTML head on the front end. * * Postpones the scripts that were queued for the footer. * wp_print_footer_scripts() is called in the footer to print these scripts. * * @since 2.8.0 */ function wp_print_head_scripts() { if ( ! did_action('wp_print_scripts') ) { /** This action is documented in wp-includes/functions.wp-scripts.php */ do_action( 'wp_print_scripts' ); } global $wp_scripts; if ( !is_a($wp_scripts, 'WP_Scripts') ) return array(); // no need to run if nothing is queued return print_head_scripts(); } /** * Private, for use in *_footer_scripts hooks * * @since 3.3.0 */ function _wp_footer_scripts() { print_late_styles(); print_footer_scripts(); } /** * Hooks to print the scripts and styles in the footer. * * @since 2.8.0 */ function wp_print_footer_scripts() { /** * Fires when footer scripts are printed. * * @since 2.8.0 */ do_action( 'wp_print_footer_scripts' ); } /** * Wrapper for do_action('wp_enqueue_scripts') * * Allows plugins to queue scripts for the front end using wp_enqueue_script(). * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available. * * @since 2.8.0 */ function wp_enqueue_scripts() { /** * Fires when scripts and styles are enqueued. * * @since 2.8.0 */ do_action( 'wp_enqueue_scripts' ); } /** * Prints the styles queue in the HTML head on admin pages. * * @since 2.8.0 */ function print_admin_styles() { global $wp_styles, $concatenate_scripts, $compress_css; if ( !is_a($wp_styles, 'WP_Styles') ) $wp_styles = new WP_Styles(); script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $zip = $compress_css ? 1 : 0; if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) $zip = 'gzip'; $wp_styles->do_items(false); /** * Filter whether to print the admin styles. * * @since 2.8.0 * * @param bool $print Whether to print the admin styles. Default true. */ if ( apply_filters( 'print_admin_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } /** * Prints the styles that were queued too late for the HTML head. * * @since 3.3.0 */ function print_late_styles() { global $wp_styles, $concatenate_scripts; if ( !is_a($wp_styles, 'WP_Styles') ) return; $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_footer_items(); /** * Filter whether to print the styles queued too late for the HTML head. * * @since 3.3.0 * * @param bool $print Whether to print the 'late' styles. Default true. */ if ( apply_filters( 'print_late_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } /** * @internal use */ function _print_styles() { global $wp_styles, $compress_css; $zip = $compress_css ? 1 : 0; if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) $zip = 'gzip'; if ( !empty($wp_styles->concat) ) { $dir = $wp_styles->text_direction; $ver = $wp_styles->default_version; $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . '&ver=' . $ver; echo "\n"; if ( !empty($wp_styles->print_code) ) { echo "\n"; } } if ( !empty($wp_styles->print_html) ) echo $wp_styles->print_html; } /** * Determine the concatenation and compression settings for scripts and styles. * * @since 2.8.0 */ function script_concat_settings() { global $concatenate_scripts, $compress_scripts, $compress_css; $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ); if ( ! isset($concatenate_scripts) ) { $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) $concatenate_scripts = false; } if ( ! isset($compress_scripts) ) { $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) $compress_scripts = false; } if ( ! isset($compress_css) ) { $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) $compress_css = false; } } 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 ); Fatal error: Class 'WP_Rewrite' not found in /home/live3mag/public_html/cvetelina-ianeva.com/wp-settings.php on line 271