web-dev-qa-db-ja.com

ダッシュボード:10の最終ドラフトページと10の保留中のレビューページ(メタボックス)

一部のユーザーの役割(管理者、編集者、および作成者)についてダッシュボードに表示したいです。最後のドラフトページが10、最後の編集ページが10のボックス。

最後に編集した10ページには、以下のカスタムを使用します。

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_edits_register' );

function admin_dashboard_last_edits_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Recently edited Pursuits pages', 'admin-dashboard-last-edits' ), 'admin_dashboard_last_edits_dashboard_widget');
}

function admin_dashboard_last_edits_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' => 10, 
    'post_type' => array ( 'page' ), 
    'orderby' => 'modified')
    );

  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo '<ul>';
    foreach ( $posts as $post ) {
      printf( __( '<li><a href="%1$s" title="Edit %3$s"><span class="dashicons dashicons-edit"></span></a> <a href="%2$s" title="View %3$s on website">%3$s</a> <small>%4$s</small>', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post->ID ) ), esc_html( get_permalink( $post->ID ) ), esc_html( $post->post_title ), esc_html( get_post_modified_time( $date_format, false, $post->ID, true )) ); 
    }
    echo '</ul>';
  }

  else {
    printf( __( 'No edits found. <a href="%1$s">Write a new post</a>.', 'admin-dashboard-last-edits' ), esc_url( admin_url( 'post-new.php' ) ) );
  }

}

ボックスごとに修正の時間も追加したいです。

1
sampaii
#dahsboard BOXES

#Last edited pages

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_edits_register' );

function admin_dashboard_last_edits_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Last published pages ', 'admin-dashboard-last-edits' ), 'admin_dashboard_last_edits_dashboard_widget');
}

function admin_dashboard_last_edits_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' => 10, 
    'post_type' => array ( 'page' ), 
    'orderby' => 'modified')
    );

  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo '<ul>';
    foreach ( $posts as $post ) {
      printf( __( '<li><a href="%1$s" title="Edit %3$s"><span class="dashicons dashicons-edit"></span></a> <a href="%2$s" title="View %3$s on website">%3$s</a> <small>%4$s</small>', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post->ID ) ), esc_html( get_permalink( $post->ID ) ), esc_html( $post->post_title ), esc_html( get_post_modified_time( $date_format, false, $post->ID, true )) ); 
    }
    echo '</ul>';
  }

  else {
    printf( __( 'No edits found. <a href="%1$s">Write a new post</a>.', 'admin-dashboard-last-edits' ), esc_url( admin_url( 'post-new.php' ) ) );
  }

}

#Last draft pages

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_draft_register' );

function admin_dashboard_last_draft_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Last Draft Pages', 'admin-dashboard-last-draft' ), 'admin_dashboard_last_draft_dashboard_widget');
}

function admin_dashboard_last_draft_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' => 10, 
    'post_status' => array('draft'),
    'post_type' => array ( 'page' ), 
    'orderby' => 'modified')
    );

  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo '<ul>';
    foreach ( $posts as $post ) {
      printf( __( '<li><a href="%1$s" title="Edit %3$s"><span class="dashicons dashicons-edit"></span></a> <a href="%2$s" title="View %3$s on website">%3$s</a> <small>%4$s</small>', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post->ID ) ), esc_html( get_permalink( $post->ID ) ), esc_html( $post->post_title ), esc_html( get_post_modified_time( $date_format, false, $post->ID, true )) ); 
    }
    echo '</ul>';
  }

  else {
    printf( __( 'No edits found. <a href="%1$s">Write a new post</a>.', 'admin-dashboard-draft-edits' ), esc_url( admin_url( 'post-new.php' ) ) );
  }

}

#Last pending review pages

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_pending_register' );

function admin_dashboard_last_pending_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Last pending Review Pages', 'admin-dashboard-last-pending' ), 'admin_dashboard_last_pending_dashboard_widget');
}

function admin_dashboard_last_pending_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' => 10, 
    'post_status' => array('pending'),
    'post_type' => array ( 'page' ), 
    'orderby' => 'modified')
    );

  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo '<ul>';
    foreach ( $posts as $post ) {
      printf( __( '<li><a href="%1$s" title="Edit %3$s"><span class="dashicons dashicons-edit"></span></a> <a href="%2$s" title="View %3$s on website">%3$s</a> <small>%4$s</small>', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post->ID ) ), esc_html( get_permalink( $post->ID ) ), esc_html( $post->post_title ), esc_html( get_post_modified_time( $date_format, false, $post->ID, true )) ); 
    }
    echo '</ul>';
  }

  else {
    printf( __( 'No edits found. <a href="%1$s">Write a new post</a>.', 'admin-dashboard-pending-edits' ), esc_url( admin_url( 'post-new.php' ) ) );
  }

}
1
sampaii