Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: post.php
'description' => __( 'Global styles to include in themes.' ),
[500] Fix | Delete
'public' => false,
[501] Fix | Delete
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
[502] Fix | Delete
'_edit_link' => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
[503] Fix | Delete
'show_ui' => false,
[504] Fix | Delete
'show_in_rest' => true,
[505] Fix | Delete
'rewrite' => false,
[506] Fix | Delete
'rest_base' => 'global-styles',
[507] Fix | Delete
'rest_controller_class' => 'WP_REST_Global_Styles_Controller',
[508] Fix | Delete
'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
[509] Fix | Delete
'late_route_registration' => true,
[510] Fix | Delete
'capabilities' => array(
[511] Fix | Delete
'read' => 'edit_posts',
[512] Fix | Delete
'create_posts' => 'edit_theme_options',
[513] Fix | Delete
'edit_posts' => 'edit_theme_options',
[514] Fix | Delete
'edit_published_posts' => 'edit_theme_options',
[515] Fix | Delete
'delete_published_posts' => 'edit_theme_options',
[516] Fix | Delete
'edit_others_posts' => 'edit_theme_options',
[517] Fix | Delete
'delete_others_posts' => 'edit_theme_options',
[518] Fix | Delete
),
[519] Fix | Delete
'map_meta_cap' => true,
[520] Fix | Delete
'supports' => array(
[521] Fix | Delete
'title',
[522] Fix | Delete
'editor',
[523] Fix | Delete
'revisions',
[524] Fix | Delete
),
[525] Fix | Delete
)
[526] Fix | Delete
);
[527] Fix | Delete
// Disable autosave endpoints for global styles.
[528] Fix | Delete
remove_post_type_support( 'wp_global_styles', 'autosave' );
[529] Fix | Delete
[530] Fix | Delete
$navigation_post_edit_link = 'site-editor.php?' . build_query(
[531] Fix | Delete
array(
[532] Fix | Delete
'postId' => '%s',
[533] Fix | Delete
'postType' => 'wp_navigation',
[534] Fix | Delete
'canvas' => 'edit',
[535] Fix | Delete
)
[536] Fix | Delete
);
[537] Fix | Delete
[538] Fix | Delete
register_post_type(
[539] Fix | Delete
'wp_navigation',
[540] Fix | Delete
array(
[541] Fix | Delete
'labels' => array(
[542] Fix | Delete
'name' => _x( 'Navigation Menus', 'post type general name' ),
[543] Fix | Delete
'singular_name' => _x( 'Navigation Menu', 'post type singular name' ),
[544] Fix | Delete
'add_new' => __( 'Add Navigation Menu' ),
[545] Fix | Delete
'add_new_item' => __( 'Add Navigation Menu' ),
[546] Fix | Delete
'new_item' => __( 'New Navigation Menu' ),
[547] Fix | Delete
'edit_item' => __( 'Edit Navigation Menu' ),
[548] Fix | Delete
'view_item' => __( 'View Navigation Menu' ),
[549] Fix | Delete
'all_items' => __( 'Navigation Menus' ),
[550] Fix | Delete
'search_items' => __( 'Search Navigation Menus' ),
[551] Fix | Delete
'parent_item_colon' => __( 'Parent Navigation Menu:' ),
[552] Fix | Delete
'not_found' => __( 'No Navigation Menu found.' ),
[553] Fix | Delete
'not_found_in_trash' => __( 'No Navigation Menu found in Trash.' ),
[554] Fix | Delete
'archives' => __( 'Navigation Menu archives' ),
[555] Fix | Delete
'insert_into_item' => __( 'Insert into Navigation Menu' ),
[556] Fix | Delete
'uploaded_to_this_item' => __( 'Uploaded to this Navigation Menu' ),
[557] Fix | Delete
'filter_items_list' => __( 'Filter Navigation Menu list' ),
[558] Fix | Delete
'items_list_navigation' => __( 'Navigation Menus list navigation' ),
[559] Fix | Delete
'items_list' => __( 'Navigation Menus list' ),
[560] Fix | Delete
),
[561] Fix | Delete
'description' => __( 'Navigation menus that can be inserted into your site.' ),
[562] Fix | Delete
'public' => false,
[563] Fix | Delete
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
[564] Fix | Delete
'_edit_link' => $navigation_post_edit_link, /* internal use only. don't use this when registering your own post type. */
[565] Fix | Delete
'has_archive' => false,
[566] Fix | Delete
'show_ui' => true,
[567] Fix | Delete
'show_in_menu' => false,
[568] Fix | Delete
'show_in_admin_bar' => false,
[569] Fix | Delete
'show_in_rest' => true,
[570] Fix | Delete
'rewrite' => false,
[571] Fix | Delete
'map_meta_cap' => true,
[572] Fix | Delete
'capabilities' => array(
[573] Fix | Delete
'edit_others_posts' => 'edit_theme_options',
[574] Fix | Delete
'delete_posts' => 'edit_theme_options',
[575] Fix | Delete
'publish_posts' => 'edit_theme_options',
[576] Fix | Delete
'create_posts' => 'edit_theme_options',
[577] Fix | Delete
'read_private_posts' => 'edit_theme_options',
[578] Fix | Delete
'delete_private_posts' => 'edit_theme_options',
[579] Fix | Delete
'delete_published_posts' => 'edit_theme_options',
[580] Fix | Delete
'delete_others_posts' => 'edit_theme_options',
[581] Fix | Delete
'edit_private_posts' => 'edit_theme_options',
[582] Fix | Delete
'edit_published_posts' => 'edit_theme_options',
[583] Fix | Delete
'edit_posts' => 'edit_theme_options',
[584] Fix | Delete
),
[585] Fix | Delete
'rest_base' => 'navigation',
[586] Fix | Delete
'rest_controller_class' => 'WP_REST_Posts_Controller',
[587] Fix | Delete
'supports' => array(
[588] Fix | Delete
'title',
[589] Fix | Delete
'editor',
[590] Fix | Delete
'revisions',
[591] Fix | Delete
),
[592] Fix | Delete
)
[593] Fix | Delete
);
[594] Fix | Delete
[595] Fix | Delete
register_post_type(
[596] Fix | Delete
'wp_font_family',
[597] Fix | Delete
array(
[598] Fix | Delete
'labels' => array(
[599] Fix | Delete
'name' => __( 'Font Families' ),
[600] Fix | Delete
'singular_name' => __( 'Font Family' ),
[601] Fix | Delete
),
[602] Fix | Delete
'public' => false,
[603] Fix | Delete
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
[604] Fix | Delete
'hierarchical' => false,
[605] Fix | Delete
'capabilities' => array(
[606] Fix | Delete
'read' => 'edit_theme_options',
[607] Fix | Delete
'read_private_posts' => 'edit_theme_options',
[608] Fix | Delete
'create_posts' => 'edit_theme_options',
[609] Fix | Delete
'publish_posts' => 'edit_theme_options',
[610] Fix | Delete
'edit_posts' => 'edit_theme_options',
[611] Fix | Delete
'edit_others_posts' => 'edit_theme_options',
[612] Fix | Delete
'edit_published_posts' => 'edit_theme_options',
[613] Fix | Delete
'delete_posts' => 'edit_theme_options',
[614] Fix | Delete
'delete_others_posts' => 'edit_theme_options',
[615] Fix | Delete
'delete_published_posts' => 'edit_theme_options',
[616] Fix | Delete
),
[617] Fix | Delete
'map_meta_cap' => true,
[618] Fix | Delete
'query_var' => false,
[619] Fix | Delete
'rewrite' => false,
[620] Fix | Delete
'show_in_rest' => true,
[621] Fix | Delete
'rest_base' => 'font-families',
[622] Fix | Delete
'rest_controller_class' => 'WP_REST_Font_Families_Controller',
[623] Fix | Delete
'supports' => array( 'title' ),
[624] Fix | Delete
)
[625] Fix | Delete
);
[626] Fix | Delete
[627] Fix | Delete
register_post_type(
[628] Fix | Delete
'wp_font_face',
[629] Fix | Delete
array(
[630] Fix | Delete
'labels' => array(
[631] Fix | Delete
'name' => __( 'Font Faces' ),
[632] Fix | Delete
'singular_name' => __( 'Font Face' ),
[633] Fix | Delete
),
[634] Fix | Delete
'public' => false,
[635] Fix | Delete
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
[636] Fix | Delete
'hierarchical' => false,
[637] Fix | Delete
'capabilities' => array(
[638] Fix | Delete
'read' => 'edit_theme_options',
[639] Fix | Delete
'read_private_posts' => 'edit_theme_options',
[640] Fix | Delete
'create_posts' => 'edit_theme_options',
[641] Fix | Delete
'publish_posts' => 'edit_theme_options',
[642] Fix | Delete
'edit_posts' => 'edit_theme_options',
[643] Fix | Delete
'edit_others_posts' => 'edit_theme_options',
[644] Fix | Delete
'edit_published_posts' => 'edit_theme_options',
[645] Fix | Delete
'delete_posts' => 'edit_theme_options',
[646] Fix | Delete
'delete_others_posts' => 'edit_theme_options',
[647] Fix | Delete
'delete_published_posts' => 'edit_theme_options',
[648] Fix | Delete
),
[649] Fix | Delete
'map_meta_cap' => true,
[650] Fix | Delete
'query_var' => false,
[651] Fix | Delete
'rewrite' => false,
[652] Fix | Delete
'show_in_rest' => true,
[653] Fix | Delete
'rest_base' => 'font-families/(?P<font_family_id>[\d]+)/font-faces',
[654] Fix | Delete
'rest_controller_class' => 'WP_REST_Font_Faces_Controller',
[655] Fix | Delete
'supports' => array( 'title' ),
[656] Fix | Delete
)
[657] Fix | Delete
);
[658] Fix | Delete
[659] Fix | Delete
register_post_status(
[660] Fix | Delete
'publish',
[661] Fix | Delete
array(
[662] Fix | Delete
'label' => _x( 'Published', 'post status' ),
[663] Fix | Delete
'public' => true,
[664] Fix | Delete
'_builtin' => true, /* internal use only. */
[665] Fix | Delete
/* translators: %s: Number of published posts. */
[666] Fix | Delete
'label_count' => _n_noop(
[667] Fix | Delete
'Published <span class="count">(%s)</span>',
[668] Fix | Delete
'Published <span class="count">(%s)</span>'
[669] Fix | Delete
),
[670] Fix | Delete
)
[671] Fix | Delete
);
[672] Fix | Delete
[673] Fix | Delete
register_post_status(
[674] Fix | Delete
'future',
[675] Fix | Delete
array(
[676] Fix | Delete
'label' => _x( 'Scheduled', 'post status' ),
[677] Fix | Delete
'protected' => true,
[678] Fix | Delete
'_builtin' => true, /* internal use only. */
[679] Fix | Delete
/* translators: %s: Number of scheduled posts. */
[680] Fix | Delete
'label_count' => _n_noop(
[681] Fix | Delete
'Scheduled <span class="count">(%s)</span>',
[682] Fix | Delete
'Scheduled <span class="count">(%s)</span>'
[683] Fix | Delete
),
[684] Fix | Delete
)
[685] Fix | Delete
);
[686] Fix | Delete
[687] Fix | Delete
register_post_status(
[688] Fix | Delete
'draft',
[689] Fix | Delete
array(
[690] Fix | Delete
'label' => _x( 'Draft', 'post status' ),
[691] Fix | Delete
'protected' => true,
[692] Fix | Delete
'_builtin' => true, /* internal use only. */
[693] Fix | Delete
/* translators: %s: Number of draft posts. */
[694] Fix | Delete
'label_count' => _n_noop(
[695] Fix | Delete
'Draft <span class="count">(%s)</span>',
[696] Fix | Delete
'Drafts <span class="count">(%s)</span>'
[697] Fix | Delete
),
[698] Fix | Delete
'date_floating' => true,
[699] Fix | Delete
)
[700] Fix | Delete
);
[701] Fix | Delete
[702] Fix | Delete
register_post_status(
[703] Fix | Delete
'pending',
[704] Fix | Delete
array(
[705] Fix | Delete
'label' => _x( 'Pending', 'post status' ),
[706] Fix | Delete
'protected' => true,
[707] Fix | Delete
'_builtin' => true, /* internal use only. */
[708] Fix | Delete
/* translators: %s: Number of pending posts. */
[709] Fix | Delete
'label_count' => _n_noop(
[710] Fix | Delete
'Pending <span class="count">(%s)</span>',
[711] Fix | Delete
'Pending <span class="count">(%s)</span>'
[712] Fix | Delete
),
[713] Fix | Delete
'date_floating' => true,
[714] Fix | Delete
)
[715] Fix | Delete
);
[716] Fix | Delete
[717] Fix | Delete
register_post_status(
[718] Fix | Delete
'private',
[719] Fix | Delete
array(
[720] Fix | Delete
'label' => _x( 'Private', 'post status' ),
[721] Fix | Delete
'private' => true,
[722] Fix | Delete
'_builtin' => true, /* internal use only. */
[723] Fix | Delete
/* translators: %s: Number of private posts. */
[724] Fix | Delete
'label_count' => _n_noop(
[725] Fix | Delete
'Private <span class="count">(%s)</span>',
[726] Fix | Delete
'Private <span class="count">(%s)</span>'
[727] Fix | Delete
),
[728] Fix | Delete
)
[729] Fix | Delete
);
[730] Fix | Delete
[731] Fix | Delete
register_post_status(
[732] Fix | Delete
'trash',
[733] Fix | Delete
array(
[734] Fix | Delete
'label' => _x( 'Trash', 'post status' ),
[735] Fix | Delete
'internal' => true,
[736] Fix | Delete
'_builtin' => true, /* internal use only. */
[737] Fix | Delete
/* translators: %s: Number of trashed posts. */
[738] Fix | Delete
'label_count' => _n_noop(
[739] Fix | Delete
'Trash <span class="count">(%s)</span>',
[740] Fix | Delete
'Trash <span class="count">(%s)</span>'
[741] Fix | Delete
),
[742] Fix | Delete
'show_in_admin_status_list' => true,
[743] Fix | Delete
)
[744] Fix | Delete
);
[745] Fix | Delete
[746] Fix | Delete
register_post_status(
[747] Fix | Delete
'auto-draft',
[748] Fix | Delete
array(
[749] Fix | Delete
'label' => 'auto-draft',
[750] Fix | Delete
'internal' => true,
[751] Fix | Delete
'_builtin' => true, /* internal use only. */
[752] Fix | Delete
'date_floating' => true,
[753] Fix | Delete
)
[754] Fix | Delete
);
[755] Fix | Delete
[756] Fix | Delete
register_post_status(
[757] Fix | Delete
'inherit',
[758] Fix | Delete
array(
[759] Fix | Delete
'label' => 'inherit',
[760] Fix | Delete
'internal' => true,
[761] Fix | Delete
'_builtin' => true, /* internal use only. */
[762] Fix | Delete
'exclude_from_search' => false,
[763] Fix | Delete
)
[764] Fix | Delete
);
[765] Fix | Delete
[766] Fix | Delete
register_post_status(
[767] Fix | Delete
'request-pending',
[768] Fix | Delete
array(
[769] Fix | Delete
'label' => _x( 'Pending', 'request status' ),
[770] Fix | Delete
'internal' => true,
[771] Fix | Delete
'_builtin' => true, /* internal use only. */
[772] Fix | Delete
/* translators: %s: Number of pending requests. */
[773] Fix | Delete
'label_count' => _n_noop(
[774] Fix | Delete
'Pending <span class="count">(%s)</span>',
[775] Fix | Delete
'Pending <span class="count">(%s)</span>'
[776] Fix | Delete
),
[777] Fix | Delete
'exclude_from_search' => false,
[778] Fix | Delete
)
[779] Fix | Delete
);
[780] Fix | Delete
[781] Fix | Delete
register_post_status(
[782] Fix | Delete
'request-confirmed',
[783] Fix | Delete
array(
[784] Fix | Delete
'label' => _x( 'Confirmed', 'request status' ),
[785] Fix | Delete
'internal' => true,
[786] Fix | Delete
'_builtin' => true, /* internal use only. */
[787] Fix | Delete
/* translators: %s: Number of confirmed requests. */
[788] Fix | Delete
'label_count' => _n_noop(
[789] Fix | Delete
'Confirmed <span class="count">(%s)</span>',
[790] Fix | Delete
'Confirmed <span class="count">(%s)</span>'
[791] Fix | Delete
),
[792] Fix | Delete
'exclude_from_search' => false,
[793] Fix | Delete
)
[794] Fix | Delete
);
[795] Fix | Delete
[796] Fix | Delete
register_post_status(
[797] Fix | Delete
'request-failed',
[798] Fix | Delete
array(
[799] Fix | Delete
'label' => _x( 'Failed', 'request status' ),
[800] Fix | Delete
'internal' => true,
[801] Fix | Delete
'_builtin' => true, /* internal use only. */
[802] Fix | Delete
/* translators: %s: Number of failed requests. */
[803] Fix | Delete
'label_count' => _n_noop(
[804] Fix | Delete
'Failed <span class="count">(%s)</span>',
[805] Fix | Delete
'Failed <span class="count">(%s)</span>'
[806] Fix | Delete
),
[807] Fix | Delete
'exclude_from_search' => false,
[808] Fix | Delete
)
[809] Fix | Delete
);
[810] Fix | Delete
[811] Fix | Delete
register_post_status(
[812] Fix | Delete
'request-completed',
[813] Fix | Delete
array(
[814] Fix | Delete
'label' => _x( 'Completed', 'request status' ),
[815] Fix | Delete
'internal' => true,
[816] Fix | Delete
'_builtin' => true, /* internal use only. */
[817] Fix | Delete
/* translators: %s: Number of completed requests. */
[818] Fix | Delete
'label_count' => _n_noop(
[819] Fix | Delete
'Completed <span class="count">(%s)</span>',
[820] Fix | Delete
'Completed <span class="count">(%s)</span>'
[821] Fix | Delete
),
[822] Fix | Delete
'exclude_from_search' => false,
[823] Fix | Delete
)
[824] Fix | Delete
);
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
/**
[828] Fix | Delete
* Retrieves attached file path based on attachment ID.
[829] Fix | Delete
*
[830] Fix | Delete
* By default the path will go through the {@see 'get_attached_file'} filter, but
[831] Fix | Delete
* passing `true` to the `$unfiltered` argument will return the file path unfiltered.
[832] Fix | Delete
*
[833] Fix | Delete
* The function works by retrieving the `_wp_attached_file` post meta value.
[834] Fix | Delete
* This is a convenience function to prevent looking up the meta name and provide
[835] Fix | Delete
* a mechanism for sending the attached filename through a filter.
[836] Fix | Delete
*
[837] Fix | Delete
* @since 2.0.0
[838] Fix | Delete
*
[839] Fix | Delete
* @param int $attachment_id Attachment ID.
[840] Fix | Delete
* @param bool $unfiltered Optional. Whether to skip the {@see 'get_attached_file'} filter.
[841] Fix | Delete
* Default false.
[842] Fix | Delete
* @return string|false The file path to where the attached file should be, false otherwise.
[843] Fix | Delete
*/
[844] Fix | Delete
function get_attached_file( $attachment_id, $unfiltered = false ) {
[845] Fix | Delete
$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
[846] Fix | Delete
[847] Fix | Delete
// If the file is relative, prepend upload dir.
[848] Fix | Delete
if ( $file && ! str_starts_with( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
[849] Fix | Delete
$uploads = wp_get_upload_dir();
[850] Fix | Delete
if ( false === $uploads['error'] ) {
[851] Fix | Delete
$file = $uploads['basedir'] . "/$file";
[852] Fix | Delete
}
[853] Fix | Delete
}
[854] Fix | Delete
[855] Fix | Delete
if ( $unfiltered ) {
[856] Fix | Delete
return $file;
[857] Fix | Delete
}
[858] Fix | Delete
[859] Fix | Delete
/**
[860] Fix | Delete
* Filters the attached file based on the given ID.
[861] Fix | Delete
*
[862] Fix | Delete
* @since 2.1.0
[863] Fix | Delete
*
[864] Fix | Delete
* @param string|false $file The file path to where the attached file should be, false otherwise.
[865] Fix | Delete
* @param int $attachment_id Attachment ID.
[866] Fix | Delete
*/
[867] Fix | Delete
return apply_filters( 'get_attached_file', $file, $attachment_id );
[868] Fix | Delete
}
[869] Fix | Delete
[870] Fix | Delete
/**
[871] Fix | Delete
* Updates attachment file path based on attachment ID.
[872] Fix | Delete
*
[873] Fix | Delete
* Used to update the file path of the attachment, which uses post meta name
[874] Fix | Delete
* `_wp_attached_file` to store the path of the attachment.
[875] Fix | Delete
*
[876] Fix | Delete
* @since 2.1.0
[877] Fix | Delete
*
[878] Fix | Delete
* @param int $attachment_id Attachment ID.
[879] Fix | Delete
* @param string $file File path for the attachment.
[880] Fix | Delete
* @return int|bool Meta ID if the `_wp_attached_file` key didn't exist for the attachment.
[881] Fix | Delete
* True on successful update, false on failure or if the `$file` value passed
[882] Fix | Delete
* to the function is the same as the one that is already in the database.
[883] Fix | Delete
*/
[884] Fix | Delete
function update_attached_file( $attachment_id, $file ) {
[885] Fix | Delete
if ( ! get_post( $attachment_id ) ) {
[886] Fix | Delete
return false;
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
/**
[890] Fix | Delete
* Filters the path to the attached file to update.
[891] Fix | Delete
*
[892] Fix | Delete
* @since 2.1.0
[893] Fix | Delete
*
[894] Fix | Delete
* @param string $file Path to the attached file to update.
[895] Fix | Delete
* @param int $attachment_id Attachment ID.
[896] Fix | Delete
*/
[897] Fix | Delete
$file = apply_filters( 'update_attached_file', $file, $attachment_id );
[898] Fix | Delete
[899] Fix | Delete
$file = _wp_relative_upload_path( $file );
[900] Fix | Delete
if ( $file ) {
[901] Fix | Delete
return update_post_meta( $attachment_id, '_wp_attached_file', $file );
[902] Fix | Delete
} else {
[903] Fix | Delete
return delete_post_meta( $attachment_id, '_wp_attached_file' );
[904] Fix | Delete
}
[905] Fix | Delete
}
[906] Fix | Delete
[907] Fix | Delete
/**
[908] Fix | Delete
* Returns relative path to an uploaded file.
[909] Fix | Delete
*
[910] Fix | Delete
* The path is relative to the current upload dir.
[911] Fix | Delete
*
[912] Fix | Delete
* @since 2.9.0
[913] Fix | Delete
* @access private
[914] Fix | Delete
*
[915] Fix | Delete
* @param string $path Full path to the file.
[916] Fix | Delete
* @return string Relative path on success, unchanged path on failure.
[917] Fix | Delete
*/
[918] Fix | Delete
function _wp_relative_upload_path( $path ) {
[919] Fix | Delete
$new_path = $path;
[920] Fix | Delete
[921] Fix | Delete
$uploads = wp_get_upload_dir();
[922] Fix | Delete
if ( str_starts_with( $new_path, $uploads['basedir'] ) ) {
[923] Fix | Delete
$new_path = str_replace( $uploads['basedir'], '', $new_path );
[924] Fix | Delete
$new_path = ltrim( $new_path, '/' );
[925] Fix | Delete
}
[926] Fix | Delete
[927] Fix | Delete
/**
[928] Fix | Delete
* Filters the relative path to an uploaded file.
[929] Fix | Delete
*
[930] Fix | Delete
* @since 2.9.0
[931] Fix | Delete
*
[932] Fix | Delete
* @param string $new_path Relative path to the file.
[933] Fix | Delete
* @param string $path Full path to the file.
[934] Fix | Delete
*/
[935] Fix | Delete
return apply_filters( '_wp_relative_upload_path', $new_path, $path );
[936] Fix | Delete
}
[937] Fix | Delete
[938] Fix | Delete
/**
[939] Fix | Delete
* Retrieves all children of the post parent ID.
[940] Fix | Delete
*
[941] Fix | Delete
* Normally, without any enhancements, the children would apply to pages. In the
[942] Fix | Delete
* context of the inner workings of WordPress, pages, posts, and attachments
[943] Fix | Delete
* share the same table, so therefore the functionality could apply to any one
[944] Fix | Delete
* of them. It is then noted that while this function does not work on posts, it
[945] Fix | Delete
* does not mean that it won't work on posts. It is recommended that you know
[946] Fix | Delete
* what context you wish to retrieve the children of.
[947] Fix | Delete
*
[948] Fix | Delete
* Attachments may also be made the child of a post, so if that is an accurate
[949] Fix | Delete
* statement (which needs to be verified), it would then be possible to get
[950] Fix | Delete
* all of the attachments for a post. Attachments have since changed since
[951] Fix | Delete
* version 2.5, so this is most likely inaccurate, but serves generally as an
[952] Fix | Delete
* example of what is possible.
[953] Fix | Delete
*
[954] Fix | Delete
* The arguments listed as defaults are for this function and also of the
[955] Fix | Delete
* get_posts() function. The arguments are combined with the get_children defaults
[956] Fix | Delete
* and are then passed to the get_posts() function, which accepts additional arguments.
[957] Fix | Delete
* You can replace the defaults in this function, listed below and the additional
[958] Fix | Delete
* arguments listed in the get_posts() function.
[959] Fix | Delete
*
[960] Fix | Delete
* The 'post_parent' is the most important argument and important attention
[961] Fix | Delete
* needs to be paid to the $args parameter. If you pass either an object or an
[962] Fix | Delete
* integer (number), then just the 'post_parent' is grabbed and everything else
[963] Fix | Delete
* is lost. If you don't specify any arguments, then it is assumed that you are
[964] Fix | Delete
* in The Loop and the post parent will be grabbed for from the current post.
[965] Fix | Delete
*
[966] Fix | Delete
* The 'post_parent' argument is the ID to get the children. The 'numberposts'
[967] Fix | Delete
* is the amount of posts to retrieve that has a default of '-1', which is
[968] Fix | Delete
* used to get all of the posts. Giving a number higher than 0 will only
[969] Fix | Delete
* retrieve that amount of posts.
[970] Fix | Delete
*
[971] Fix | Delete
* The 'post_type' and 'post_status' arguments can be used to choose what
[972] Fix | Delete
* criteria of posts to retrieve. The 'post_type' can be anything, but WordPress
[973] Fix | Delete
* post types are 'post', 'pages', and 'attachments'. The 'post_status'
[974] Fix | Delete
* argument will accept any post status within the write administration panels.
[975] Fix | Delete
*
[976] Fix | Delete
* @since 2.0.0
[977] Fix | Delete
*
[978] Fix | Delete
* @see get_posts()
[979] Fix | Delete
* @todo Check validity of description.
[980] Fix | Delete
*
[981] Fix | Delete
* @global WP_Post $post Global post object.
[982] Fix | Delete
*
[983] Fix | Delete
* @param mixed $args Optional. User defined arguments for replacing the defaults. Default empty.
[984] Fix | Delete
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
[985] Fix | Delete
* correspond to a WP_Post object, an associative array, or a numeric array,
[986] Fix | Delete
* respectively. Default OBJECT.
[987] Fix | Delete
* @return WP_Post[]|array[]|int[] Array of post objects, arrays, or IDs, depending on `$output`.
[988] Fix | Delete
*/
[989] Fix | Delete
function get_children( $args = '', $output = OBJECT ) {
[990] Fix | Delete
$kids = array();
[991] Fix | Delete
if ( empty( $args ) ) {
[992] Fix | Delete
if ( isset( $GLOBALS['post'] ) ) {
[993] Fix | Delete
$args = array( 'post_parent' => (int) $GLOBALS['post']->post_parent );
[994] Fix | Delete
} else {
[995] Fix | Delete
return $kids;
[996] Fix | Delete
}
[997] Fix | Delete
} elseif ( is_object( $args ) ) {
[998] Fix | Delete
$args = array( 'post_parent' => (int) $args->post_parent );
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function