@@ -10,7 +10,7 @@ |
||
| 10 | 10 | **/ |
| 11 | 11 | |
| 12 | 12 | if ( !defined( 'ABSPATH' ) || preg_match('#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'])) { |
| 13 | - die( "Hey, dude! What are you doing here?" ); |
|
| 13 | + die( "Hey, dude! What are you doing here?" ); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | if ( !class_exists( 'Simple_Featured_Image_Column' ) ) { |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * License: GPLv2+ |
| 10 | 10 | **/ |
| 11 | 11 | |
| 12 | - if ( !defined( 'ABSPATH' ) || preg_match('#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'])) { |
|
| 13 | - die( "Hey, dude! What are you doing here?" ); |
|
| 12 | + if (!defined('ABSPATH') || preg_match('#'.basename(__FILE__).'#', $_SERVER['PHP_SELF'])) { |
|
| 13 | + die("Hey, dude! What are you doing here?"); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - if ( !class_exists( 'Simple_Featured_Image_Column' ) ) { |
|
| 16 | + if (!class_exists('Simple_Featured_Image_Column')) { |
|
| 17 | 17 | |
| 18 | 18 | class Simple_Featured_Image_Column { |
| 19 | 19 | |
@@ -21,28 +21,28 @@ discard block |
||
| 21 | 21 | add_action('admin_init', array($this, 'init')); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - function init(){ |
|
| 24 | + function init() { |
|
| 25 | 25 | |
| 26 | 26 | $post_types = apply_filters('Simple_Featured_Image_Column_post_types', get_post_types(array('public' => true))); |
| 27 | - if(empty($post_types)) return; |
|
| 27 | + if (empty($post_types)) return; |
|
| 28 | 28 | |
| 29 | - add_action('admin_head', function(){ |
|
| 29 | + add_action('admin_head', function() { |
|
| 30 | 30 | echo '<style>th#featured-image { width: 100px; }</style>'."\r\n"; |
| 31 | 31 | }); |
| 32 | 32 | |
| 33 | - foreach($post_types as $post_type){ |
|
| 34 | - if(!post_type_supports($post_type, 'thumbnail')) continue; |
|
| 35 | - add_filter( "manage_{$post_type}_posts_columns", array($this, 'columns')); |
|
| 36 | - add_action( "manage_{$post_type}_posts_custom_column", array($this, 'column_data'), 10, 2); |
|
| 33 | + foreach ($post_types as $post_type) { |
|
| 34 | + if (!post_type_supports($post_type, 'thumbnail')) continue; |
|
| 35 | + add_filter("manage_{$post_type}_posts_columns", array($this, 'columns')); |
|
| 36 | + add_action("manage_{$post_type}_posts_custom_column", array($this, 'column_data'), 10, 2); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - function columns($columns){ |
|
| 40 | + function columns($columns) { |
|
| 41 | 41 | |
| 42 | - if(!is_array($columns)) $columns = array(); |
|
| 42 | + if (!is_array($columns)) $columns = array(); |
|
| 43 | 43 | $new = array(); |
| 44 | - foreach($columns as $key => $title){ |
|
| 45 | - if($key == 'title') $new['featured-image'] = __('Image', 'wordpress'); |
|
| 44 | + foreach ($columns as $key => $title) { |
|
| 45 | + if ($key == 'title') $new['featured-image'] = __('Image', 'wordpress'); |
|
| 46 | 46 | $new[$key] = $title; |
| 47 | 47 | } |
| 48 | 48 | return $new; |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | function column_data($column_name, $post_id) { |
| 52 | 52 | |
| 53 | - if('featured-image' != $column_name) return; |
|
| 53 | + if ('featured-image' != $column_name) return; |
|
| 54 | 54 | $style = 'display: block; max-width: 100px; height: auto; border: 1px solid #e5e5e5;'; |
| 55 | 55 | $style = apply_filters('Simple_Featured_Image_Column_image_style', $style); |
| 56 | 56 | |
| 57 | - if(has_post_thumbnail($post_id)){ |
|
| 57 | + if (has_post_thumbnail($post_id)) { |
|
| 58 | 58 | $size = 'thumbnail'; |
| 59 | 59 | echo get_the_post_thumbnail($post_id, $size, 'style='.$style); |
| 60 | 60 | } else { |
| 61 | - echo '<img style="'. $style .'" src="'. esc_url(plugins_url( 'images/default.png', __FILE__ )) .'" />'; |
|
| 61 | + echo '<img style="'.$style.'" src="'.esc_url(plugins_url('images/default.png', __FILE__)).'" />'; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -24,14 +24,18 @@ discard block |
||
| 24 | 24 | function init(){ |
| 25 | 25 | |
| 26 | 26 | $post_types = apply_filters('Simple_Featured_Image_Column_post_types', get_post_types(array('public' => true))); |
| 27 | - if(empty($post_types)) return; |
|
| 27 | + if(empty($post_types)) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | add_action('admin_head', function(){ |
| 30 | 32 | echo '<style>th#featured-image { width: 100px; }</style>'."\r\n"; |
| 31 | 33 | }); |
| 32 | 34 | |
| 33 | 35 | foreach($post_types as $post_type){ |
| 34 | - if(!post_type_supports($post_type, 'thumbnail')) continue; |
|
| 36 | + if(!post_type_supports($post_type, 'thumbnail')) { |
|
| 37 | + continue; |
|
| 38 | + } |
|
| 35 | 39 | add_filter( "manage_{$post_type}_posts_columns", array($this, 'columns')); |
| 36 | 40 | add_action( "manage_{$post_type}_posts_custom_column", array($this, 'column_data'), 10, 2); |
| 37 | 41 | } |
@@ -39,10 +43,14 @@ discard block |
||
| 39 | 43 | |
| 40 | 44 | function columns($columns){ |
| 41 | 45 | |
| 42 | - if(!is_array($columns)) $columns = array(); |
|
| 46 | + if(!is_array($columns)) { |
|
| 47 | + $columns = array(); |
|
| 48 | + } |
|
| 43 | 49 | $new = array(); |
| 44 | 50 | foreach($columns as $key => $title){ |
| 45 | - if($key == 'title') $new['featured-image'] = __('Image', 'wordpress'); |
|
| 51 | + if($key == 'title') { |
|
| 52 | + $new['featured-image'] = __('Image', 'wordpress'); |
|
| 53 | + } |
|
| 46 | 54 | $new[$key] = $title; |
| 47 | 55 | } |
| 48 | 56 | return $new; |
@@ -50,7 +58,9 @@ discard block |
||
| 50 | 58 | |
| 51 | 59 | function column_data($column_name, $post_id) { |
| 52 | 60 | |
| 53 | - if('featured-image' != $column_name) return; |
|
| 61 | + if('featured-image' != $column_name) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 54 | 64 | $style = 'display: block; max-width: 100px; height: auto; border: 1px solid #e5e5e5;'; |
| 55 | 65 | $style = apply_filters('Simple_Featured_Image_Column_image_style', $style); |
| 56 | 66 | |