Changeset 4937 for sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php
- Timestamp:
- 02/19/2017 02:49:41 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php
r3656 r4937 35 35 add_filter( 'manage_edit-' . $this->post_type . '_sortable_columns', [ $this, 'showcase_sortable_columns' ], 10, 0 ); 36 36 add_filter( 'sharing_meta_box_show', [ $this, 'disable_sharing_meta_box' ], 10, 2 ); 37 add_theme_support( 'post-thumbnails', [ 'showcase' ] ); 38 add_image_size( 'showcase-thumbnail', 440, 330, true ); 37 39 } 38 40 … … 42 44 public function register_post_type() { 43 45 $labels = [ 44 'name' => _x( 'Showcase', 'post type general name', 'rosetta' ), 45 'singular_name' => _x( 'Showcase Site', 'post type singular name', 'rosetta' ), 46 'add_new' => _x( 'Add New', 'showcase item', 'rosetta' ), 47 'add_new_item' => __( 'Add New Site', 'rosetta' ), 48 'edit_item' => __( 'Edit Site', 'rosetta' ), 49 'new_item' => __( 'New Site', 'rosetta' ), 50 'view_item' => __( 'View Site', 'rosetta' ), 51 'search_items' => __( 'Search Showcase', 'rosetta' ), 52 'not_found' => __( 'Nothing found', 'rosetta' ), 53 'not_found_in_trash' => __( 'Nothing found in Trash', 'rosetta' ), 46 'name' => _x( 'Showcase', 'post type general name', 'rosetta' ), 47 'singular_name' => _x( 'Showcase Site', 'post type singular name', 'rosetta' ), 48 'add_new' => _x( 'Add New', 'showcase item', 'rosetta' ), 49 'add_new_item' => __( 'Add New Site', 'rosetta' ), 50 'edit_item' => __( 'Edit Site', 'rosetta' ), 51 'new_item' => __( 'New Site', 'rosetta' ), 52 'view_item' => __( 'View Site', 'rosetta' ), 53 'search_items' => __( 'Search Showcase', 'rosetta' ), 54 'not_found' => __( 'Nothing found', 'rosetta' ), 55 'not_found_in_trash' => __( 'Nothing found in Trash', 'rosetta' ), 56 'featured_image' => __( 'Website Screenshot', 'rosetta' ), 57 'set_featured_image' => __( 'Set website screenshot', 'rosetta' ), 58 'remove_featured_image' => __( 'Remove website screenshot', 'rosetta' ), 59 'use_featured_image' => __( 'Use as website screenshot', 'rosetta' ), 54 60 ]; 55 61 … … 66 72 'can_export' => false, 67 73 'exclude_from_search' => true, 68 'supports' => [ 'title', 'excerpt' ],74 'supports' => [ 'title', 'excerpt', 'thumbnail' ], 69 75 'menu_icon' => 'dashicons-slides', 70 76 'register_meta_box_cb' => [ $this, 'register_showcase_meta_box' ], … … 208 214 209 215 case 'description' : 210 the_excerpt(); 216 if ( has_excerpt() ) { 217 the_excerpt(); 218 } else { 219 echo '—'; 220 } 211 221 break; 212 222 213 223 case 'url' : 214 224 $url = get_post_meta( $post_id, '_rosetta_showcase_url', true ); 215 echo '<a href="' . esc_url( $url ) . '">' . esc_url_raw( $url ) . '</a>'; 225 if ( $url ) { 226 echo '<a href="' . esc_url( $url ) . '">' . esc_url_raw( $url ) . '</a>'; 227 } else { 228 echo '—'; 229 } 216 230 break; 217 231 218 232 case 'shot' : 219 233 $url = esc_url( get_post_meta( $post_id, '_rosetta_showcase_url', true ) ); 220 if ( $url ) { 221 echo '<a href="' . esc_url( $url ) . '" target="_blank"><img width="200" src="https://wordpress.com/mshots/v1/' . urlencode( $url ) . '?w=400" /></a>'; 234 235 $image_url = ''; 236 if ( has_post_thumbnail( $post_id ) ) { 237 $image_url = get_the_post_thumbnail_url( $post_id, 'showcase-thumbnail' ); 238 } elseif ( $url ) { 239 $image_url = 'https://wordpress.com/mshots/v1/' . urlencode( $url ) . '?w=440'; 240 } 241 242 if ( $image_url ) { 243 echo '<a href="' . esc_url( $url ) . '" target="_blank"><img src="' . esc_url( $image_url ) . '" width="200" alt=""></a>'; 222 244 } 223 245 break;
Note: See TracChangeset
for help on using the changeset viewer.