WordPressを読む 10-21 /blog/wp-includes/functions.php 21
2014/11/29
目次
/blog/wp-includes/functions.php 21
読込元 : /blog/wp-settings.php
読込元 : /blog/wp-load.php
関数
_wp_mysql_week()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * Return a MySQL expression for selecting the week number based on the start_of_week option. * * @internal * @since 3.0.0 * * @param string $column Database column. * @return string SQL clause. */ function _wp_mysql_week( $column ) { switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { case 1 : return "WEEK( $column, 1 )"; case 2 : case 3 : case 4 : case 5 : case 6 : return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; case 0 : default : return "WEEK( $column, 0 )"; } } |
関数
wp_find_hierarchy_loop()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /** * Find hierarchy loops using a callback function that maps object IDs to parent IDs. * * @since 3.1.0 * @access private * * @param callback $callback Function that accepts ( ID, $callback_args ) and outputs parent_ID. * @param int $start The ID to start the loop check at. * @param int $start_parent The parent_ID of $start to use instead of calling $callback( $start ). * Use null to always use $callback * @param array $callback_args Optional. Additional arguments to send to $callback. * @return array IDs of all members of loop. */ function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) return array(); return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); } |
関数
wp_find_hierarchy_loop_tortoise_hare()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /** * Use the "The Tortoise and the Hare" algorithm to detect loops. * * For every step of the algorithm, the hare takes two steps and the tortoise one. * If the hare ever laps the tortoise, there must be a loop. * * @since 3.1.0 * @access private * * @param callback $callback Function that accepts ( ID, callback_arg, ... ) and outputs parent_ID. * @param int $start The ID to start the loop check at. * @param array $override Optional. An array of ( ID => parent_ID, ... ) to use instead of $callback. * Default empty array. * @param array $callback_args Optional. Additional arguments to send to $callback. Default empty array. * @param bool $_return_loop Optional. Return loop members or just detect presence of loop? Only set * to true if you already know the given $start is part of a loop (otherwise * the returned array might include branches). Default false. * @return mixed Scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if * $_return_loop */ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { $tortoise = $hare = $evanescent_hare = $start; $return = array(); // Set evanescent_hare to one past hare // Increment hare two steps while ( $tortoise && ( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) && ( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) ) { if ( $_return_loop ) $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; // tortoise got lapped - must be a loop if ( $tortoise == $evanescent_hare || $tortoise == $hare ) return $_return_loop ? $return : $tortoise; // Increment tortoise by one step $tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); } return false; } |
関数
send_frame_options_header()
1 2 3 4 5 6 7 8 9 10 | /** * Send a HTTP header to limit rendering of pages to same origin iframes. * * @since 3.1.3 * * @see https://developer.mozilla.org/en/the_x-frame-options_response_header */ function send_frame_options_header() { @header( 'X-Frame-Options: SAMEORIGIN' ); } |
関数
wp_allowed_protocols()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /** * Retrieve a list of protocols to allow in HTML attributes. * * @since 3.3.0 * * @see wp_kses() * @see esc_url() * * @return array Array of allowed protocols. */ function wp_allowed_protocols() { static $protocols; if ( empty( $protocols ) ) { $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp' ); /** * Filter the list of protocols allowed in HTML attributes. * * @since 3.0.0 * * @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more. */ $protocols = apply_filters( 'kses_allowed_protocols', $protocols ); } return $protocols; } |
関数
wp_debug_backtrace_summary()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /** * Return a comma-separated string of functions that have been called to get * to the current point in code. * * @since 3.4.0 * * @see http://core.trac.wordpress.org/ticket/19589 * * @param string $ignore_class Optional. A class to ignore all function calls within - useful * when you want to just give info about the callee. Default null. * @param int $skip_frames Optional. A number of stack frames to skip - useful for unwinding * back to the source of the issue. Default 0. * @param bool $pretty Optional. Whether or not you want a comma separated string or raw * array returned. Default true. * @return string|array Either a string containing a reversed comma separated trace or an array * of individual calls. */ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) $trace = debug_backtrace( false ); else $trace = debug_backtrace(); $caller = array(); $check_class = ! is_null( $ignore_class ); $skip_frames++; // skip this function foreach ( $trace as $call ) { if ( $skip_frames > 0 ) { $skip_frames--; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class == $call['class'] ) continue; // Filter out calls $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; } else { if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')"; } else { $caller[] = $call['function']; } } } if ( $pretty ) return join( ', ', array_reverse( $caller ) ); else return $caller; } |
関数
_get_non_cached_ids()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /** * Retrieve ids that are not already present in the cache. * * @since 3.4.0 * @access private * * @param array $object_ids ID list. * @param string $cache_key The cache bucket to check against. * * @return array List of ids not present in the cache. */ function _get_non_cached_ids( $object_ids, $cache_key ) { $clean = array(); foreach ( $object_ids as $id ) { $id = (int) $id; if ( !wp_cache_get( $id, $cache_key ) ) { $clean[] = $id; } } return $clean; } |