'stale', 'per_page' => 5, 'paged' => 1, 'orderby' => 'days', 'order' => 'DESC', // Stalest first. ) ); $oldest_items = $query->get_results(); ?>
$config ) { if ( empty( $config['enabled'] ) || ! post_type_exists( $type ) ) { continue; } // Add column header. add_filter( "manage_{$type}_posts_columns", array( $this, 'add_column_header' ) ); // Add column content. add_action( "manage_{$type}_posts_custom_column", array( $this, 'render_column_content' ), 10, 2 ); // Make column sortable. add_filter( "manage_edit-{$type}_sortable_columns", array( $this, 'make_column_sortable' ) ); } } /** * Add "Days since update" column header. * * @param array $columns Existing columns. * @return array */ public function add_column_header( $columns ) { $columns['ocap_days'] = __( 'Days Since Update', 'contentcortex' ); return $columns; } /** * Render "Days since update" cell content. * Shows a badge if stale, empty otherwise. * * @param string $column_name Column name. * @param int $post_id Post ID. */ public function render_column_content( $column_name, $post_id ) { if ( 'ocap_days' !== $column_name && 'sct_days' !== $column_name ) { return; } $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status ) { return; } // Check if excluded. $is_excluded = get_post_meta( $post_id, '_ocap_excluded', true ); if ( '' === $is_excluded ) { $is_excluded = get_post_meta( $post_id, '_sct_excluded', true ); } if ( '1' === (string) $is_excluded ) { echo '' . esc_html__( 'Excluded', 'contentcortex' ) . ''; return; } $basis = ocap_get_setting( 'date_basis', 'modified' ); $days = ocap_calculate_days_since_update( $post_id, $basis ); $limit = ocap_get_post_type_day_limit( $post->post_type ); if ( $days >= $limit ) { $severity = ( $days > 2 * $limit ) ? 'ocap-badge-red' : 'ocap-badge-amber'; printf( '%s', esc_attr( $severity ), /* translators: 1: days since update, 2: day limit */ esc_attr( sprintf( __( '%1$d days since update (limit: %2$d)', 'contentcortex' ), $days, $limit ) ), /* translators: %d: days */ esc_html( sprintf( __( '%d days', 'contentcortex' ), $days ) ) ); } } /** * Make column sortable by modified date. * * @param array $columns Sortable columns. * @return array */ public function make_column_sortable( $columns ) { $columns['ocap_days'] = 'modified'; return $columns; } }