From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- srcs/wordpress/wp-admin/includes/meta-boxes.php | 1580 +++++++++++++++++++++++ 1 file changed, 1580 insertions(+) create mode 100644 srcs/wordpress/wp-admin/includes/meta-boxes.php (limited to 'srcs/wordpress/wp-admin/includes/meta-boxes.php') diff --git a/srcs/wordpress/wp-admin/includes/meta-boxes.php b/srcs/wordpress/wp-admin/includes/meta-boxes.php new file mode 100644 index 0000000..7c5d725 --- /dev/null +++ b/srcs/wordpress/wp-admin/includes/meta-boxes.php @@ -0,0 +1,1580 @@ +post_type; + $post_type_object = get_post_type_object( $post_type ); + $can_publish = current_user_can( $post_type_object->cap->publish_posts ); + ?> +
+ +
+ + +
+ +
+ +
+
+ post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { + $private_style = ''; + if ( 'private' == $post->post_status ) { + $private_style = 'style="display:none"'; + } + ?> + type="submit" name="save" id="save-post" value="" class="button" /> + +post_status && $can_publish ) { ?> + + + +
+ +
+ post_status ) { + $preview_button_text = __( 'Preview Changes' ); + } else { + $preview_button_text = __( 'Preview' ); + } + + $preview_button = sprintf( + '%1$s %2$s', + $preview_button_text, + /* translators: Accessibility text. */ + __( '(opens in a new tab)' ) + ); + ?> + + +
+ + +
+
+ +
+ +
+ + post_status ) { + case 'private': + _e( 'Privately Published' ); + break; + case 'publish': + _e( 'Published' ); + break; + case 'future': + _e( 'Scheduled' ); + break; + case 'pending': + _e( 'Pending Review' ); + break; + case 'draft': + case 'auto-draft': + _e( 'Draft' ); + break; + } + ?> + + post_status || 'private' == $post->post_status || $can_publish ) { + $private_style = ''; + if ( 'private' == $post->post_status ) { + $private_style = 'style="display:none"'; + } + ?> + class="edit-post-status hide-if-no-js" role="button"> + +
+ + + + + +
+ + +
+ +
+ + post_status ) { + $post->post_password = ''; + $visibility = 'private'; + $visibility_trans = __( 'Private' ); + } elseif ( ! empty( $post->post_password ) ) { + $visibility = 'password'; + $visibility_trans = __( 'Password protected' ); + } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { + $visibility = 'public'; + $visibility_trans = __( 'Public, Sticky' ); + } else { + $visibility = 'public'; + $visibility_trans = __( 'Public' ); + } + + echo esc_html( $visibility_trans ); + ?> + + + + +
+ + +ID ) ); ?> /> + + + />
+ +ID ) ); ?> />
+ + />
+
+ />
+ +

+ + +

+
+ + +
+ + ID ) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */ + $stamp = __( 'Scheduled for: %s' ); + } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published + /* translators: Post date information. %s: Date on which the post was published. */ + $stamp = __( 'Published on: %s' ); + } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified + $stamp = __( 'Publish immediately' ); + } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified + /* translators: Post date information. %s: Date on which the post is to be published. */ + $stamp = __( 'Schedule for: %s' ); + } else { // draft, 1 or more saves, date specified + /* translators: Post date information. %s: Date on which the post is to be published. */ + $stamp = __( 'Publish on: %s' ); + } + $date = sprintf( + $date_string, + date_i18n( $date_format, strtotime( $post->post_date ) ), + date_i18n( $time_format, strtotime( $post->post_date ) ) + ); + } else { // draft (no saves, and thus no date specified) + $stamp = __( 'Publish immediately' ); + $date = sprintf( + $date_string, + date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ), + date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) ) + ); + } + + if ( ! empty( $args['args']['revisions_count'] ) ) : + ?> +
+ ' . number_format_i18n( $args['args']['revisions_count'] ) . '' ); + ?> + +
+ +
+ + ' . $date . '' ); ?> + + + + + +
+ + +
+
+ + + post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) : ?> +
+

+ unpublished customization changes. You can edit, but there’s no need to publish now. It will be published automatically with those changes.' ), + esc_url( + add_query_arg( + 'changeset_uuid', + rawurlencode( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ), + admin_url( 'customize.php' ) + ) + ) + ); + ?> +

+
+ + + +
+
+
+ +
+ +
+ ID ) ) { + if ( ! EMPTY_TRASH_DAYS ) { + $delete_text = __( 'Delete Permanently' ); + } else { + $delete_text = __( 'Move to Trash' ); + } + ?> + + +
+ +
+ + post_status, array( 'publish', 'future', 'private' ) ) || 0 == $post->ID ) { + if ( $can_publish ) : + if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : + ?> + + + + + + + + + + + + +
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ + post_date ) ), + /* translators: Publish box time format, see https://secure.php.net/date */ + date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) ) + ); + /* translators: Attachment information. %s: Date the attachment was uploaded. */ + printf( __( 'Uploaded on: %s' ), '' . $uploaded_on . '' ); + ?> + +
+ + +
+
+
+ +
+
+ ID ) ) { + if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { + echo "" . __( 'Move to Trash' ) . ''; + } else { + $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; + echo "" . __( 'Delete Permanently' ) . ''; + } + } + ?> +
+ +
+ + + +
+
+
+ +
+ + post_type, 'post-formats' ) ) : + $post_formats = get_theme_support( 'post-formats' ); + + if ( is_array( $post_formats[0] ) ) : + $post_format = get_post_format( $post->ID ); + if ( ! $post_format ) { + $post_format = '0'; + } + // Add in the current one if it isn't there yet, in case the current theme doesn't support it + if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) { + $post_formats[0][] = $post_format; + } + ?> +
+
+ + /> + +
/> + +
+
+ 'post_tag' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { + $args = array(); + } else { + $args = $box['args']; + } + $parsed_args = wp_parse_args( $args, $defaults ); + $tax_name = esc_attr( $parsed_args['taxonomy'] ); + $taxonomy = get_taxonomy( $parsed_args['taxonomy'] ); + $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); + $comma = _x( ',', 'tag delimiter' ); + $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); + if ( ! is_string( $terms_to_edit ) ) { + $terms_to_edit = ''; + } + ?> +
+
+
+ +

+
+ +
+ + + +
+

labels->separate_items_with_commas; ?>

+ +

labels->no_terms; ?>

+ +
+ +
+ +

+ + 'category' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { + $args = array(); + } else { + $args = $box['args']; + } + $parsed_args = wp_parse_args( $args, $defaults ); + $tax_name = esc_attr( $parsed_args['taxonomy'] ); + $taxonomy = get_taxonomy( $parsed_args['taxonomy'] ); + ?> +
+ + + + +
+ "; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. + ?> +
    + ID, + array( + 'taxonomy' => $tax_name, + 'popular_cats' => $popular_ids, + ) + ); + ?> +
+
+ cap->edit_terms ) ) : ?> +
+ + labels->add_new_item ); + ?> + +

+ + + + $tax_name, + 'hide_empty' => 0, + 'name' => 'new' . $tax_name . '_parent', + 'orderby' => 'name', + 'hierarchical' => 1, + 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', + ); + + /** + * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. + * + * @since 4.4.0 + * + * @param array $parent_dropdown_args { + * Optional. Array of arguments to generate parent dropdown. + * + * @type string $taxonomy Name of the taxonomy to retrieve. + * @type bool $hide_if_empty True to skip generating markup if no + * categories are found. Default 0. + * @type string $name Value for the 'name' attribute + * of the select element. + * Default "new{$tax_name}_parent". + * @type string $orderby Which column to use for ordering + * terms. Default 'name'. + * @type bool|int $hierarchical Whether to traverse the taxonomy + * hierarchy. Default 1. + * @type string $show_option_none Text to display for the "none" option. + * Default "— {$parent} —", + * where `$parent` is 'parent_item' + * taxonomy label. + * } + */ + $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); + + wp_dropdown_categories( $parent_dropdown_args ); + ?> + + + +

+
+ +
+ + +

+ Learn more about manual excerpts.' ), + __( 'https://wordpress.org/support/article/excerpt/' ) + ); + ?> +

+ to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; + if ( '' != $post->pinged ) { + $pings = '

' . __( 'Already pinged:' ) . '

'; + } + + ?> +

+ + +

+

+

+ pingbacks, no other action necessary.' ), + __( 'https://wordpress.org/support/article/introduction-to-blogging/#comments' ) + ); + ?> +

+ +
+
+ ID ); + foreach ( $metadata as $key => $value ) { + if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) { + unset( $metadata[ $key ] ); + } + } + list_meta( $metadata ); + meta_form( $post ); + ?> +
+

+ use in your theme.' ), + __( 'https://wordpress.org/support/article/custom-fields/' ) + ); + ?> +

+ + +

+
+ + +

+ +

+ $post->ID, + 'number' => 1, + 'count' => true, + ) + ); + $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' ); + $wp_list_table->display( true ); + + if ( 1 > $total ) { + echo '

' . __( 'No comments yet.' ) . '

'; + } else { + $hidden = get_hidden_meta_boxes( get_current_screen() ); + if ( ! in_array( 'commentsdiv', $hidden ) ) { + ?> + + +

+ post_name, $post ); + ?> + + + + 'authors', + 'name' => 'post_author_override', + 'selected' => empty( $post->ID ) ? $user_ID : $post->post_author, + 'include_selected' => true, + 'show' => 'display_name_with_login', + ) + ); +} + +/** + * Display list of revisions. + * + * @since 2.6.0 + * + * @param object $post + */ +function post_revisions_meta_box( $post ) { + wp_list_post_revisions( $post ); +} + +// -- Page related Meta Boxes + +/** + * Display page attributes form fields. + * + * @since 2.7.0 + * + * @param object $post + */ +function page_attributes_meta_box( $post ) { + if ( is_post_type_hierarchical( $post->post_type ) ) : + $dropdown_args = array( + 'post_type' => $post->post_type, + 'exclude_tree' => $post->ID, + 'selected' => $post->post_parent, + 'name' => 'parent_id', + 'show_option_none' => __( '(no parent)' ), + 'sort_column' => 'menu_order, post_title', + 'echo' => 0, + ); + + /** + * Filters the arguments used to generate a Pages drop-down element. + * + * @since 3.3.0 + * + * @see wp_dropdown_pages() + * + * @param array $dropdown_args Array of arguments used to generate the pages drop-down. + * @param WP_Post $post The current post. + */ + $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); + $pages = wp_dropdown_pages( $dropdown_args ); + if ( ! empty( $pages ) ) : + ?> +

+ + 0 && get_option( 'page_for_posts' ) != $post->ID ) : + $template = ! empty( $post->page_template ) ? $post->page_template : false; + ?> +

+ +

+ + + post_type, 'page-attributes' ) ) : ?> +

+ + + post_type && get_current_screen()->get_help_tabs() ) : ?> +

+ + + +
+ + +
+
    + link_id ) ) { + wp_link_category_checklist( $link->link_id ); + } else { + wp_link_category_checklist(); + } + ?> +
+
+ + + +
+ + +
+
+ +
+

+

+

+
+

+ link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; + $rels = preg_split( '/\s+/', $link_rel ); + + if ( '' != $value && in_array( $value, $rels ) ) { + echo ' checked="checked"'; + } + + if ( '' == $value ) { + if ( 'family' == $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) { + echo ' checked="checked"'; + } + if ( 'friendship' == $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) { + echo ' checked="checked"'; + } + if ( 'geographical' == $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) { + echo ' checked="checked"'; + } + if ( 'identity' == $class && in_array( 'me', $rels ) ) { + echo ' checked="checked"'; + } + } +} + +/** + * Display xfn form fields. + * + * @since 2.6.0 + * + * @param object $link + */ +function link_xfn_meta_box( $link ) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

XFN.' ); ?>

+ + + + + + + + + + + + + + + + + + + + ID, '_thumbnail_id', true ); + echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); +} + +/** + * Display fields for ID3 data + * + * @since 3.9.0 + * + * @param WP_Post $post A post object. + */ +function attachment_id3_data_meta_box( $post ) { + $meta = array(); + if ( ! empty( $post->ID ) ) { + $meta = wp_get_attachment_metadata( $post->ID ); + } + + foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : + $value = ''; + if ( ! empty( $meta[ $key ] ) ) { + $value = $meta[ $key ]; + } + ?> +

+
+ +

+ post_type; + $post_type_object = get_post_type_object( $post_type ); + + $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); + if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { + if ( wp_attachment_is( 'audio', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); + } elseif ( wp_attachment_is( 'video', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); + } + } + + $publish_callback_args = array( '__back_compat_meta_box' => true ); + if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { + $revisions = wp_get_post_revisions( $post->ID ); + + // We should aim to show the revisions meta box only when there are revisions. + if ( count( $revisions ) > 1 ) { + reset( $revisions ); // Reset pointer for key() + $publish_callback_args = array( + 'revisions_count' => count( $revisions ), + 'revision_id' => key( $revisions ), + '__back_compat_meta_box' => true, + ); + add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + } + + if ( 'attachment' == $post_type ) { + wp_enqueue_script( 'image-edit' ); + wp_enqueue_style( 'imgareaselect' ); + add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); + add_action( 'edit_form_after_title', 'edit_form_image_editor' ); + + if ( wp_attachment_is( 'audio', $post ) ) { + add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + } else { + add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); + } + + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { + add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); + } + + // all taxonomies + foreach ( get_object_taxonomies( $post ) as $tax_name ) { + $taxonomy = get_taxonomy( $tax_name ); + if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { + continue; + } + + $label = $taxonomy->labels->name; + + if ( ! is_taxonomy_hierarchical( $tax_name ) ) { + $tax_meta_box_id = 'tagsdiv-' . $tax_name; + } else { + $tax_meta_box_id = $tax_name . 'div'; + } + + add_meta_box( + $tax_meta_box_id, + $label, + $taxonomy->meta_box_cb, + null, + 'side', + 'core', + array( + 'taxonomy' => $tax_name, + '__back_compat_meta_box' => true, + ) + ); + } + + if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { + add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); + } + + if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { + add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low', array( '__back_compat_meta_box' => true ) ); + } + + if ( post_type_supports( $post_type, 'excerpt' ) ) { + add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + + if ( post_type_supports( $post_type, 'trackbacks' ) ) { + add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + + if ( post_type_supports( $post_type, 'custom-fields' ) ) { + add_meta_box( + 'postcustom', + __( 'Custom Fields' ), + 'post_custom_meta_box', + null, + 'normal', + 'core', + array( + '__back_compat_meta_box' => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), + '__block_editor_compatible_meta_box' => true, + ) + ); + } + + /** + * Fires in the middle of built-in meta box registration. + * + * @since 2.1.0 + * @deprecated 3.7.0 Use 'add_meta_boxes' instead. + * + * @param WP_Post $post Post object. + */ + do_action( 'dbx_post_advanced', $post ); + + // Allow the Discussion meta box to show up if the post type supports comments, + // or if comments or pings are open. + if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + + $stati = get_post_stati( array( 'public' => true ) ); + if ( empty( $stati ) ) { + $stati = array( 'publish' ); + } + $stati[] = 'private'; + + if ( in_array( get_post_status( $post ), $stati ) ) { + // If the post type support comments, or the post has comments, allow the + // Comments meta box. + if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + } + + if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { + add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + + if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { + add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); + } + + /** + * Fires after all built-in meta boxes have been added. + * + * @since 3.0.0 + * + * @param string $post_type Post type. + * @param WP_Post $post Post object. + */ + do_action( 'add_meta_boxes', $post_type, $post ); + + /** + * Fires after all built-in meta boxes have been added, contextually for the given post type. + * + * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. + * + * @since 3.0.0 + * + * @param WP_Post $post Post object. + */ + do_action( "add_meta_boxes_{$post_type}", $post ); + + /** + * Fires after meta boxes have been added. + * + * Fires once for each of the default meta box contexts: normal, advanced, and side. + * + * @since 3.0.0 + * + * @param string $post_type Post type of the post on Edit Post screen, 'link' on Edit Link screen, + * 'dashboard' on Dashboard screen. + * @param string $context Meta box context. Possible values include 'normal', 'advanced', 'side'. + * @param WP_Post|object|string $post Post object on Edit Post screen, link object on Edit Link screen, + * an empty string on Dashboard screen. + */ + do_action( 'do_meta_boxes', $post_type, 'normal', $post ); + /** This action is documented in wp-admin/includes/meta-boxes.php */ + do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); + /** This action is documented in wp-admin/includes/meta-boxes.php */ + do_action( 'do_meta_boxes', $post_type, 'side', $post ); +} -- cgit