add_meta
函数
add_meta ( $post_ID )
- 参数
-
-
(int)
$post_ID- Required: 是
-
(int)
- 返回值
-
- (int|bool)
- 定义位置
-
-
wp-admin/includes/post.php
, line 939
-
wp-admin/includes/post.php
- 引入
- 1.2.0
- 弃用
- –
Adds post meta data defined in the `$_POST` superglobal for a post with given ID.
function add_meta( $post_ID ) { $post_ID = (int) $post_ID; $metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; $metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; $metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : ''; if ( is_string( $metavalue ) ) { $metavalue = trim( $metavalue ); } if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { /* * We have a key/value pair. If both the select and the input * for the key have data, the input takes precedence. */ if ( '#NONE#' !== $metakeyselect ) { $metakey = $metakeyselect; } if ( $metakeyinput ) { $metakey = $metakeyinput; // Default. } if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { return false; } $metakey = wp_slash( $metakey ); return add_post_meta( $post_ID, $metakey, $metavalue ); } return false; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。