WordPressを読む 36-3 /blog/wp-includes/link-template.php 3
2014/12/18
目次
- 1 /blog/wp-includes/link-template.php 3
- 2 関数 get_search_feed_link()
- 3 関数 get_search_comments_feed_link()
- 4 関数 get_post_type_archive_link()
- 5 関数 get_post_type_archive_feed_link()
- 6 関数 get_edit_post_link()
- 7 関数 edit_post_link()
- 8 関数 get_delete_post_link()
- 9 関数 get_edit_comment_link()
- 10 関数 edit_comment_link()
- 11 関数 get_edit_bookmark_link()
- 12 関数 edit_bookmark_link()
- 13 関数 get_edit_user_link()
- 14 関数 get_previous_post()
- 15 関数 get_next_post()
/blog/wp-includes/link-template.php 3
関数 get_search_feed_link()
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 permalink for the feed of the search results. * * @since 2.5.0 * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string */ function get_search_feed_link($search_query = '', $feed = '') { global $wp_rewrite; $link = get_search_link($search_query); if ( empty($feed) ) $feed = get_default_feed(); $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty($permastruct) ) { $link = add_query_arg('feed', $feed, $link); } else { $link = trailingslashit($link); $link .= "feed/$feed/"; } /** * Filter the search feed link. * * @since 2.5.0 * * @param string $link Search feed link. * @param string $feed Feed type. * @param string $type The search type. One of 'posts' or 'comments'. */ $link = apply_filters( 'search_feed_link', $link, $feed, 'posts' ); return $link; } |
関数 get_search_comments_feed_link()
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 | /** * Retrieve the permalink for the comments feed of the search results. * * @since 2.5.0 * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string */ function get_search_comments_feed_link($search_query = '', $feed = '') { global $wp_rewrite; if ( empty($feed) ) $feed = get_default_feed(); $link = get_search_feed_link($search_query, $feed); $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty($permastruct) ) $link = add_query_arg('feed', 'comments-' . $feed, $link); else $link = add_query_arg('withcomments', 1, $link); /** This filter is documented in wp-includes/link-template.php */ $link = apply_filters('search_feed_link', $link, $feed, 'comments'); return $link; } |
関数 get_post_type_archive_link()
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 | /** * Retrieve the permalink for a post type archive. * * @since 3.1.0 * * @param string $post_type Post type * @return string */ function get_post_type_archive_link( $post_type ) { global $wp_rewrite; if ( ! $post_type_obj = get_post_type_object( $post_type ) ) return false; if ( ! $post_type_obj->has_archive ) return false; if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; if ( $post_type_obj->rewrite['with_front'] ) $struct = $wp_rewrite->front . $struct; else $struct = $wp_rewrite->root . $struct; $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); } else { $link = home_url( '?post_type=' . $post_type ); } /** * Filter the post type archive permalink. * * @since 3.1.0 * * @param string $link The post type archive permalink. * @param string $post_type Post type name. */ return apply_filters( 'post_type_archive_link', $link, $post_type ); } |
関数 get_post_type_archive_feed_link()
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 | /** * Retrieve the permalink for a post type archive feed. * * @since 3.1.0 * * @param string $post_type Post type * @param string $feed Optional. Feed type * @return string */ function get_post_type_archive_feed_link( $post_type, $feed = '' ) { $default_feed = get_default_feed(); if ( empty( $feed ) ) $feed = $default_feed; if ( ! $link = get_post_type_archive_link( $post_type ) ) return false; $post_type_obj = get_post_type_object( $post_type ); if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { $link = trailingslashit( $link ); $link .= 'feed/'; if ( $feed != $default_feed ) $link .= "$feed/"; } else { $link = add_query_arg( 'feed', $feed, $link ); } /** * Filter the post type archive feed link. * * @since 3.1.0 * * @param string $link The post type archive feed link. * @param string $feed Feed type. */ return apply_filters( 'post_type_archive_feed_link', $link, $feed ); } |
関数 get_edit_post_link()
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 | /** * Retrieve edit posts link for post. * * Can be used within the WordPress loop or outside of it. Can be used with * pages, posts, attachments, and revisions. * * @since 2.3.0 * * @param int $id Optional. Post ID. * @param string $context Optional, defaults to display. How to write the '&', defaults to '&'. * @return string */ function get_edit_post_link( $id = 0, $context = 'display' ) { if ( ! $post = get_post( $id ) ) return; if ( 'revision' === $post->post_type ) $action = ''; elseif ( 'display' == $context ) $action = '&action=edit'; else $action = '&action=edit'; $post_type_object = get_post_type_object( $post->post_type ); if ( !$post_type_object ) return; if ( !current_user_can( 'edit_post', $post->ID ) ) return; /** * Filter the post edit link. * * @since 2.3.0 * * @param string $link The edit link. * @param int $post_id Post ID. * @param string $context The link context. If set to 'display' then ampersands * are encoded. */ return apply_filters( 'get_edit_post_link', admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ), $post->ID, $context ); } |
関数 edit_post_link()
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 | /** * Display edit post link for post. * * @since 1.0.0 * * @param string $text Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param int $id Optional. Post ID. */ function edit_post_link( $text = null, $before = '', $after = '', $id = 0 ) { if ( ! $post = get_post( $id ) ) { return; } if ( ! $url = get_edit_post_link( $post->ID ) ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="post-edit-link" href="' . $url . '">' . $text . '</a>'; /** * Filter the post edit link anchor tag. * * @since 2.3.0 * * @param string $link Anchor tag for the edit link. * @param int $post_id Post ID. * @param string $text Anchor text. */ echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; } |
関数 get_delete_post_link()
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 | /** * Retrieve delete posts link for post. * * Can be used within the WordPress loop or outside of it, with any post type. * * @since 2.9.0 * * @param int $id Optional. Post ID. * @param string $deprecated Not used. * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. * @return string */ function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) { if ( ! empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '3.0' ); if ( !$post = get_post( $id ) ) return; $post_type_object = get_post_type_object( $post->post_type ); if ( !$post_type_object ) return; if ( !current_user_can( 'delete_post', $post->ID ) ) return; $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); /** * Filter the post delete link. * * @since 2.9.0 * * @param string $link The delete link. * @param int $post_id Post ID. * @param bool $force_delete Whether to bypass the trash and force deletion. Default false. */ return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); } |
関数 get_edit_comment_link()
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 | /** * Retrieve edit comment link. * * @since 2.3.0 * * @param int $comment_id Optional. Comment ID. * @return string */ function get_edit_comment_link( $comment_id = 0 ) { $comment = get_comment( $comment_id ); if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) return; $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; /** * Filter the comment edit link. * * @since 2.3.0 * * @param string $location The edit link. */ return apply_filters( 'get_edit_comment_link', $location ); } |
関数 edit_comment_link()
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 edit comment link with formatting. * * @since 1.0.0 * * @param string $text Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. */ function edit_comment_link( $text = null, $before = '', $after = '' ) { global $comment; if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $text . '</a>'; /** * Filter the comment edit link anchor tag. * * @since 2.3.0 * * @param string $link Anchor tag for the edit link. * @param int $comment_id Comment ID. * @param string $text Anchor text. */ echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; } |
関数 get_edit_bookmark_link()
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 | /** * Display edit bookmark (literally a URL external to blog) link. * * @since 2.7.0 * * @param int $link Optional. Bookmark ID. * @return string */ function get_edit_bookmark_link( $link = 0 ) { $link = get_bookmark( $link ); if ( !current_user_can('manage_links') ) return; $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; /** * Filter the bookmark (link) edit link. * * @since 2.7.0 * * @param string $location The edit link. * @param int $link_id Bookmark ID. */ return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); } |
関数 edit_bookmark_link()
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 | /** * Display edit bookmark (literally a URL external to blog) link anchor content. * * @since 2.7.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param int $bookmark Optional. Bookmark ID. */ function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { $bookmark = get_bookmark($bookmark); if ( !current_user_can('manage_links') ) return; if ( empty($link) ) $link = __('Edit This'); $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>'; /** * Filter the bookmark edit link anchor tag. * * @since 2.7.0 * * @param string $link Anchor tag for the edit link. * @param int $link_id Bookmark ID. */ echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; } |
関数 get_edit_user_link()
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 | /** * Retrieve edit user link * * @since 3.5.0 * * @param int $user_id Optional. User ID. Defaults to the current user. * @return string URL to edit user page or empty string. */ function get_edit_user_link( $user_id = null ) { if ( ! $user_id ) $user_id = get_current_user_id(); if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) return ''; $user = get_userdata( $user_id ); if ( ! $user ) return ''; if ( get_current_user_id() == $user->ID ) $link = get_edit_profile_url( $user->ID ); else $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); /** * Filter the user edit link. * * @since 3.5.0 * * @param string $link The edit link. * @param int $user_id User ID. */ return apply_filters( 'get_edit_user_link', $link, $user->ID ); } |
関数 get_previous_post()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Navigation links /** * Retrieve previous post that is adjacent to current post. * * @since 1.5.0 * * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. */ function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); } |
関数 get_next_post()
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * Retrieve next post that is adjacent to current post. * * @since 1.5.0 * * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. */ function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); } |