ap_post_status_btn_args( mixed $_post = null )
Description #
Output chnage post status button.
Parameters #
- $_postmixed (Optional) Post. Default value: null
Source #
File: includes/theme.php
function ap_post_status_btn_args( $_post = null ) {
$_post = ap_get_post( $_post );
$args = array();
if ( 'trash' === $_post->post_status ) {
return $args;
}
if ( ap_user_can_change_status( $_post->ID ) ) {
global $wp_post_statuses;
$allowed_status = array( 'publish', 'private_post', 'moderate' );
$status_labels = array();
foreach ( (array) $allowed_status as $s ) {
if ( isset( $wp_post_statuses[ $s ] ) ) {
$status_labels[ $s ] = esc_attr( $wp_post_statuses[ $s ]->label );
}
}
foreach ( (array) $status_labels as $slug => $label ) {
$can = true;
if ( 'moderate' === $slug && ! ap_user_can_change_status_to_moderate() ) {
$can = false;
}
if ( $can ) {
$args[] = array(
'cb' => 'status',
'active' => ( $slug === $_post->post_status ),
'query' => array(
'status' => $slug,
'__nonce' => wp_create_nonce( 'change-status-' . $slug . '-' . $_post->ID ),
'post_id' => $_post->ID,
),
'label' => esc_attr( $label ),
);
}
}
return $args;
}
}
Expand full source code Collapse full source code View on GitHub: includes/theme.php:855
Add your comment