WordPressを読む 35-5 /blog/wp-includes/general-template.php 5
2014/12/18
目次
- 1 /blog/wp-includes/general-template.php 5
- 2 関数 get_post_time()
- 3 関数 the_modified_time()
- 4 関数 get_the_modified_time()
- 5 関数 get_post_modified_time()
- 6 関数 the_weekday()
- 7 関数 the_weekday_date()
- 8 関数 wp_head()
- 9 関数 wp_footer()
- 10 関数 feed_links()
- 11 関数 feed_links_extra()
- 12 関数 rsd_link()
- 13 関数 wlwmanifest_link()
- 14 関数 noindex()
- 15 関数 wp_no_robots()
- 16 関数 user_can_richedit()
- 17 関数 wp_default_editor()
- 18 関数 wp_editor()
- 19 関数 get_search_query()
- 20 関数 the_search_query()
/blog/wp-includes/general-template.php 5
関数 get_post_time()
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 | /** * Retrieve the time at which the post was written. * * @since 2.0.0 * * @param string $d Optional. Format to use for retrieving the time the post * was written. Either 'G', 'U', or php date format. Default 'U'. * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. * @param int|WP_Post $post WP_Post object or ID. Default is global $post object. * @param bool $translate Whether to translate the time string. Default false. * @return string|int|bool Formatted date string or Unix timestamp. False on failure. */ function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { $post = get_post($post); if ( ! $post ) { return false; } if ( $gmt ) $time = $post->post_date_gmt; else $time = $post->post_date; $time = mysql2date($d, $time, $translate); /** * Filter the localized time a post was written. * * @since 2.6.0 * * @param string $time The formatted time. * @param string $d Format to use for retrieving the time the post was written. * Accepts 'G', 'U', or php date format. Default 'U'. * @param bool $gmt Whether to retrieve the GMT time. Default false. */ return apply_filters( 'get_post_time', $time, $d, $gmt ); } |
関数 the_modified_time()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /** * Display the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option. */ function the_modified_time($d = '') { /** * Filter the localized time a post was last modified, for display. * * @since 2.0.0 * * @param string $get_the_modified_time The formatted time. * @param string $d The time format. Accepts 'G', 'U', * or php date format. Defaults to value * specified in 'time_format' option. */ echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d ); } |
関数 get_the_modified_time()
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 | /** * Retrieve the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option. * @return string */ function get_the_modified_time($d = '') { if ( '' == $d ) $the_time = get_post_modified_time(get_option('time_format'), null, null, true); else $the_time = get_post_modified_time($d, null, null, true); /** * Filter the localized time a post was last modified. * * @since 2.0.0 * * @param string $the_time The formatted time. * @param string $d Format to use for retrieving the time the post was * written. Accepts 'G', 'U', or php date format. Defaults * to value specified in 'time_format' option. */ return apply_filters( 'get_the_modified_time', $the_time, $d ); } |
関数 get_post_modified_time()
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 | /** * Retrieve the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Optional. Format to use for retrieving the time the post * was modified. Either 'G', 'U', or php date format. Default 'U'. * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. * @param int|WP_Post $post WP_Post object or ID. Default is global $post object. * @param bool $translate Whether to translate the time string. Default false. * @return string|int|bool Formatted date string or Unix timestamp. False on failure. */ function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { $post = get_post($post); if ( ! $post ) { return false; } if ( $gmt ) $time = $post->post_modified_gmt; else $time = $post->post_modified; $time = mysql2date($d, $time, $translate); /** * Filter the localized time a post was last modified. * * @since 2.8.0 * * @param string $time The formatted time. * @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'. * @param bool $gmt Whether to return the GMT time. Default false. */ return apply_filters( 'get_post_modified_time', $time, $d, $gmt ); } |
関数 the_weekday()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /** * Display the weekday on which the post was written. * * @since 0.71 * @uses $wp_locale * @uses $post */ function the_weekday() { global $wp_locale; $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); /** * Filter the weekday on which the post was written, for display. * * @since 0.71 * * @param string $the_weekday */ $the_weekday = apply_filters( 'the_weekday', $the_weekday ); echo $the_weekday; } |
関数 the_weekday_date()
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 | /** * Display the weekday on which the post was written. * * Will only output the weekday if the current post's weekday is different from * the previous one output. * * @since 0.71 * * @param string $before Optional Output before the date. * @param string $after Optional Output after the date. */ function the_weekday_date($before='',$after='') { global $wp_locale, $currentday, $previousweekday; $the_weekday_date = ''; if ( $currentday != $previousweekday ) { $the_weekday_date .= $before; $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); $the_weekday_date .= $after; $previousweekday = $currentday; } /** * Filter the localized date on which the post was written, for display. * * @since 0.71 * * @param string $the_weekday_date * @param string $before The HTML to output before the date. * @param string $after The HTML to output after the date. */ $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after ); echo $the_weekday_date; } |
関数 wp_head()
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * Fire the wp_head action * * @since 1.2.0 */ function wp_head() { /** * Print scripts or data in the head tag on the front end. * * @since 1.5.0 */ do_action( 'wp_head' ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * Fire the wp_footer action * * @since 1.5.1 */ function wp_footer() { /** * Print scripts or data before the closing body tag on the front end. * * @since 1.5.1 */ do_action( 'wp_footer' ); } |
関数 feed_links()
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 | /** * Display the links to the general feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links( $args = array() ) { if ( !current_theme_supports('automatic-feed-links') ) return; $defaults = array( /* translators: Separator between blog name and feed type in feed links */ 'separator' => _x('»', 'feed link'), /* translators: 1: blog title, 2: separator (raquo) */ 'feedtitle' => __('%1$s %2$s Feed'), /* translators: 1: blog title, 2: separator (raquo) */ 'comstitle' => __('%1$s %2$s Comments Feed'), ); $args = wp_parse_args( $args, $defaults ); echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n"; echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n"; } |
関数 feed_links_extra()
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /** * Display the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra( $args = array() ) { $defaults = array( /* translators: Separator between blog name and feed type in feed links */ 'separator' => _x('»', 'feed link'), /* translators: 1: blog name, 2: separator(raquo), 3: post title */ 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: category name */ 'cattitle' => __('%1$s %2$s %3$s Category Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: tag name */ 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: author name */ 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */ 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: post type name */ 'posttypetitle' => __('%1$s %2$s %3$s Feed'), ); $args = wp_parse_args( $args, $defaults ); if ( is_singular() ) { $id = 0; $post = get_post( $id ); if ( comments_open() || pings_open() || $post->comment_count > 0 ) { $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); $href = get_post_comments_feed_link( $post->ID ); } } elseif ( is_post_type_archive() ) { $post_type = get_query_var( 'post_type' ); if ( is_array( $post_type ) ) $post_type = reset( $post_type ); $post_type_obj = get_post_type_object( $post_type ); $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name ); $href = get_post_type_archive_feed_link( $post_type_obj->name ); } elseif ( is_category() ) { $term = get_queried_object(); if ( $term ) { $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); $href = get_category_feed_link( $term->term_id ); } } elseif ( is_tag() ) { $term = get_queried_object(); if ( $term ) { $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); $href = get_tag_feed_link( $term->term_id ); } } elseif ( is_author() ) { $author_id = intval( get_query_var('author') ); $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); $href = get_author_feed_link( $author_id ); } elseif ( is_search() ) { $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); $href = get_search_feed_link(); } elseif ( is_post_type_archive() ) { $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); $post_type_obj = get_queried_object(); if ( $post_type_obj ) $href = get_post_type_archive_feed_link( $post_type_obj->name ); } if ( isset($title) && isset($href) ) echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n"; } |
関数 rsd_link()
1 2 3 4 5 6 7 8 9 | /** * Display the link to the Really Simple Discovery service endpoint. * * @link http://archipelago.phrasewise.com/rsd * @since 2.0.0 */ function rsd_link() { echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n"; } |
関数 wlwmanifest_link()
1 2 3 4 5 6 7 8 9 10 | /** * Display the link to the Windows Live Writer manifest file. * * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx * @since 2.3.1 */ function wlwmanifest_link() { echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="', includes_url( 'wlwmanifest.xml' ), '" /> ', "\n"; } |
関数 noindex()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Display a noindex meta tag if required by the blog configuration. * * If a blog is marked as not being public then the noindex meta tag will be * output to tell web robots not to index the page content. Add this to the wp_head action. * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' ); * * @see wp_no_robots * * @since 2.1.0 */ function noindex() { // If the blog is not public, tell robots to go away. if ( '0' == get_option('blog_public') ) wp_no_robots(); } |
関数 wp_no_robots()
1 2 3 4 5 6 7 8 9 10 11 | /** * Display a noindex meta tag. * * Outputs a noindex meta tag that tells web robots not to index the page content. * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' ); * * @since 3.3.0 */ function wp_no_robots() { echo "<meta name='robots' content='noindex,follow' />\n"; } |
関数 user_can_richedit()
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 | /** * Whether the user should have a WYSIWIG editor. * * Checks that the user requires a WYSIWIG editor and that the editor is * supported in the users browser. * * @since 2.0.0 * * @return bool */ function user_can_richedit() { global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE; if ( !isset($wp_rich_edit) ) { $wp_rich_edit = false; if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); } elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) { $wp_rich_edit = true; } } } /** * Filter whether the user can access the rich (Visual) editor. * * @since 2.1.0 * * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor. */ return apply_filters( 'user_can_richedit', $wp_rich_edit ); } |
関数 wp_default_editor()
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 | /** * Find out which editor should be displayed by default. * * Works out which of the two editors to display as the current editor for a * user. The 'html' setting is for the "Text" editor tab. * * @since 2.5.0 * * @return string Either 'tinymce', or 'html', or 'test' */ function wp_default_editor() { $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults if ( wp_get_current_user() ) { // look for cookie $ed = get_user_setting('editor', 'tinymce'); $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; } /** * Filter which editor should be displayed by default. * * @since 2.5.0 * * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'. */ return apply_filters( 'wp_default_editor', $r ); } |
関数 wp_editor()
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 | /** * Renders an editor. * * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144. * * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used. * On the post edit screen several actions can be used to include additional editors * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'. * See http://core.trac.wordpress.org/ticket/19173 for more information. * * @see wp-includes/class-wp-editor.php * @since 3.3.0 * * @param string $content Initial content for the editor. * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/. * @param array $settings See _WP_Editors::editor(). */ function wp_editor( $content, $editor_id, $settings = array() ) { if ( ! class_exists( '_WP_Editors' ) ) require( ABSPATH . WPINC . '/class-wp-editor.php' ); _WP_Editors::editor($content, $editor_id, $settings); } |
関数 get_search_query()
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 | /** * Retrieve the contents of the search WordPress query variable. * * The search query string is passed through {@link esc_attr()} * to ensure that it is safe for placing in an html attribute. * * @since 2.3.0 * @uses esc_attr() * * @param bool $escaped Whether the result is escaped. Default true. * Only use when you are later escaping it. Do not use unescaped. * @return string */ function get_search_query( $escaped = true ) { /** * Filter the contents of the search query variable. * * @since 2.3.0 * * @param mixed $search Contents of the search query variable. */ $query = apply_filters( 'get_search_query', get_query_var( 's' ) ); if ( $escaped ) $query = esc_attr( $query ); return $query; } |
関数 the_search_query()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Display the contents of the search query variable. * * The search query string is passed through {@link esc_attr()} * to ensure that it is safe for placing in an html attribute. * * @uses esc_attr() * @since 2.1.0 */ function the_search_query() { /** * Filter the contents of the search query variable for display. * * @since 2.3.0 * * @param mixed $search Contents of the search query variable. */ echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); } |