_x( 'Hero slides', 'post type general name', 'aha-hero-slider' ), 'singular_name' => _x( 'Hero slide', 'post type singular name', 'aha-hero-slider' ), 'menu_name' => _x( 'Hero Slider', 'admin menu', 'aha-hero-slider' ), 'add_new' => _x( 'Add New', 'slide', 'aha-hero-slider' ), 'add_new_item' => __( 'Add slide', 'aha-hero-slider' ), 'edit_item' => __( 'Edit slide', 'aha-hero-slider' ), 'new_item' => __( 'New slide', 'aha-hero-slider' ), 'view_item' => __( 'View slide', 'aha-hero-slider' ), 'search_items' => __( 'Search slides', 'aha-hero-slider' ), 'not_found' => __( 'No slides found.', 'aha-hero-slider' ), 'not_found_in_trash' => __( 'No slides found in Trash.', 'aha-hero-slider' ), ); $args = array( 'labels' => $labels, 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => false, 'menu_icon' => 'dashicons-images-alt2', 'query_var' => false, 'rewrite' => false, 'capability_type' => 'post', 'has_archive' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), 'show_in_rest' => false, ); register_post_type( AHA_HERO_SLIDER_CPT, $args ); } /** * Add thumbnail column before the title. * * @param array $columns Existing columns. * @return array */ public function add_thumbnail_column( $columns ) { $new = array(); foreach ( $columns as $key => $label ) { if ( 'title' === $key ) { $new['aha_hero_thumb'] = __( 'Image', 'aha-hero-slider' ); } $new[ $key ] = $label; } return $new; } /** * Render thumbnail column content. * * @param string $column Column key. * @param int $post_id Post ID. */ public function render_thumbnail_column( $column, $post_id ) { if ( 'aha_hero_thumb' !== $column ) { return; } $desktop_id = (int) get_post_meta( $post_id, '_aha_hero_image_desktop_id', true ); if ( $desktop_id ) { $img = wp_get_attachment_image( $desktop_id, array( 80, 45 ), false, array( 'style' => 'display:block;border-radius:4px;object-fit:cover;width:80px;height:45px;' ) ); if ( $img ) { echo $img; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_get_attachment_image output is safe. return; } } $fallback = aha_hero_slider_get_default_slide_image_url(); if ( $fallback !== '' ) { printf( '', esc_url( $fallback ) ); return; } echo ''; } }