Changeset 54961
- Timestamp:
- 12/13/2022 12:01:08 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r54953 r54961 2020 2020 * @access private 2021 2021 * 2022 * @param object $ objectA custom-something object.2022 * @param object $data_object A custom-something object. 2023 2023 * @param array $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels. 2024 2024 * @return object Object containing labels for the given custom-something object. 2025 2025 */ 2026 function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) { 2027 $object->labels = (array) $object->labels; 2028 2029 if ( isset( $object->label ) && empty( $object->labels['name'] ) ) { 2030 $object->labels['name'] = $object->label; 2031 } 2032 2033 if ( ! isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) { 2034 $object->labels['singular_name'] = $object->labels['name']; 2035 } 2036 2037 if ( ! isset( $object->labels['name_admin_bar'] ) ) { 2038 $object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name; 2039 } 2040 2041 if ( ! isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) { 2042 $object->labels['menu_name'] = $object->labels['name']; 2043 } 2044 2045 if ( ! isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) { 2046 $object->labels['all_items'] = $object->labels['menu_name']; 2047 } 2048 2049 if ( ! isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) { 2050 $object->labels['archives'] = $object->labels['all_items']; 2026 function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) { 2027 $data_object->labels = (array) $data_object->labels; 2028 2029 if ( isset( $data_object->label ) && empty( $data_object->labels['name'] ) ) { 2030 $data_object->labels['name'] = $data_object->label; 2031 } 2032 2033 if ( ! isset( $data_object->labels['singular_name'] ) && isset( $data_object->labels['name'] ) ) { 2034 $data_object->labels['singular_name'] = $data_object->labels['name']; 2035 } 2036 2037 if ( ! isset( $data_object->labels['name_admin_bar'] ) ) { 2038 $data_object->labels['name_admin_bar'] = 2039 isset( $data_object->labels['singular_name'] ) 2040 ? $data_object->labels['singular_name'] 2041 : $data_object->name; 2042 } 2043 2044 if ( ! isset( $data_object->labels['menu_name'] ) && isset( $data_object->labels['name'] ) ) { 2045 $data_object->labels['menu_name'] = $data_object->labels['name']; 2046 } 2047 2048 if ( ! isset( $data_object->labels['all_items'] ) && isset( $data_object->labels['menu_name'] ) ) { 2049 $data_object->labels['all_items'] = $data_object->labels['menu_name']; 2050 } 2051 2052 if ( ! isset( $data_object->labels['archives'] ) && isset( $data_object->labels['all_items'] ) ) { 2053 $data_object->labels['archives'] = $data_object->labels['all_items']; 2051 2054 } 2052 2055 2053 2056 $defaults = array(); 2054 2057 foreach ( $nohier_vs_hier_defaults as $key => $value ) { 2055 $defaults[ $key ] = $object->hierarchical ? $value[1] : $value[0]; 2056 } 2057 $labels = array_merge( $defaults, $object->labels ); 2058 $object->labels = (object) $object->labels; 2058 $defaults[ $key ] = $data_object->hierarchical ? $value[1] : $value[0]; 2059 } 2060 2061 $labels = array_merge( $defaults, $data_object->labels ); 2062 $data_object->labels = (object) $data_object->labels; 2059 2063 2060 2064 return (object) $labels; … … 6324 6328 * @param string|array $args Arguments for inserting an attachment. 6325 6329 * @param string|false $file Optional. Filename. 6326 * @param int $parent 6330 * @param int $parent_post Optional. Parent post ID. 6327 6331 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 6328 6332 * @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true. 6329 6333 * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. 6330 6334 */ 6331 function wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false, $fire_after_hooks = true ) {6335 function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error = false, $fire_after_hooks = true ) { 6332 6336 $defaults = array( 6333 6337 'file' => $file, … … 6337 6341 $data = wp_parse_args( $args, $defaults ); 6338 6342 6339 if ( ! empty( $parent ) ) {6340 $data['post_parent'] = $parent ;6343 if ( ! empty( $parent_post ) ) { 6344 $data['post_parent'] = $parent_post; 6341 6345 } 6342 6346
Note: See TracChangeset
for help on using the changeset viewer.