Skip to content

Commit

Permalink
Missed short-array syntax updates for PHP < 5.3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefrosty committed Jun 25, 2017
1 parent a5384c1 commit 2ac779c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 65 deletions.
35 changes: 5 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ Follow the steps below to install the plugin.

## Changelog

### Version 0.3.2 (06/26/17) =

* Missed short-array syntax updates for PHP < 5.4 compatibility.

### Version 0.3.1 (06/26/17)

* Fix for PHP versions < 5.4.
Expand Down Expand Up @@ -166,33 +170,4 @@ Follow the steps below to install the plugin.
## Upgrade Notice

### 0.3

* Code cleanup, compatibility updates for WordPress 4.8, quick edit no longer collapses the columns and the settings actually toggle post_types on/off!

### 0.2.2

* Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 4.1 and post type settings.

### 0.2.1

* Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 3.8 and PHP 5.3+ compat.

### 0.1.9

* Happy 311 day! Finally fixed duplicate image output. Yay for cache array().

### 0.1.7

* Working on fixed repeating images.

### 0.1.6

* Cleaned up code thanks to Chris @ iThemes. All errors should be suppressed and clear.

### 0.1.2

* Code cleanup, attempt at fixing a fatal error when no posts exist (still in progress).

### 0.1.1

* Adds support for public $post_type's that support 'post-thumbnails'.
Code cleanup, compatibility updates for WordPress 4.8, quick edit no longer collapses the columns and the settings actually toggle post_types on/off!
38 changes: 19 additions & 19 deletions featured-image-column.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Featured Image Column
* Plugin URI: http://austin.passy.co/wordpress-plugins/featured-image-column
* Description: Adds a column to the edit screen with the featured image if it exists.
* Version: 0.3.1
* Version: 0.3.2
* Author: Austin Passy
* Author URI: http://austin.passy.co
*
Expand All @@ -30,24 +30,23 @@
class Featured_Image_Column {

const ID = 'featured-image';
const VERSION = '0.3.1';

/**
* Ensures that the rest of the code only runs on edit.php pages
*
* @since 0.3
*/
public function add_hooks() {
add_action( 'admin_menu', [ $this, 'admin_menu' ] );
add_action( 'admin_init', [ $this, 'admin_init' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'style' ] );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'style' ) );
}

/**
* Activation hook, to add our default settings.
*/
public function activation_hook() {
$post_types = [];
$post_types = array();
foreach ( $this->get_post_types() as $key => $post_type ) {
if ( post_type_supports( $post_type, 'thumbnail' ) ) {
$post_types[ $post_type ] = $post_type;
Expand All @@ -67,7 +66,7 @@ public function admin_menu() {
'Featured Image Col',
'manage_options',
'featured-image-column',
[ $this, 'settings_page' ]
array( $this, 'settings_page' )
);
}

Expand All @@ -91,7 +90,8 @@ public function admin_init() {
}

// Make sure we've got some post_types saved via our settings.
if ( empty( ( $post_types = get_option( 'featured_image_column', [] ) ) ) ) {
$post_types = get_option( 'featured_image_column', array() );
if ( empty( $post_types ) ) {
return;
}

Expand All @@ -100,9 +100,9 @@ public function admin_init() {
if ( ! post_type_supports( $post_type, 'thumbnail' ) ) {
continue;
}
add_filter( "manage_{$post_type}_posts_columns", [ $this, 'columns' ] );
add_filter( "manage_{$post_type}_posts_columns", array( $this, 'columns' ) );
add_action( "manage_{$post_type}_posts_custom_column",
[ $this, 'column_data' ], 10, 2 );
array( $this, 'column_data' ), 10, 2 );
}
}

Expand All @@ -114,7 +114,7 @@ public function admin_init() {
public function settings_page() {
$post_types = get_option( 'featured_image_column', false );
if ( $post_types === false ) {
$post_types = [];
$post_types = array();
foreach ( $this->get_post_types() as $key => $post_type ) {
if ( post_type_supports( $post_type, 'thumbnail' ) ) {
$post_types[ $post_type ] = $post_type;
Expand Down Expand Up @@ -154,8 +154,8 @@ public function style( $hook ) {
wp_register_style(
'featured-image-column',
apply_filters( 'featured_image_column_css', plugin_dir_url( __FILE__ ) . 'css/column.css' ),
[],
self::VERSION
array(),
'20170625'
);

if ( $hook === 'edit.php' ) {
Expand All @@ -172,10 +172,10 @@ public function style( $hook ) {
*/
public function columns( array $columns ) {
if ( ! is_array( $columns ) ) {
$columns = [];
$columns = array();
}

$new_columns = [];
$new_columns = array();
foreach ( $columns as $key => $title ) {
// Put the Thumbnail column before the Title column
if ( $key == 'title' ) {
Expand Down Expand Up @@ -217,7 +217,7 @@ protected function register_settings() {
register_setting(
'featured_image_column_post_types',
'featured_image_column',
[ $this, 'sanitize_callback' ]
array( $this, 'sanitize_callback' )
);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ protected function get_the_image( $post_id ) {
* @return array
*/
protected function get_settings() {
return get_option( 'featured_image_column', [] );
return get_option( 'featured_image_column', array() );
}

/**
Expand All @@ -262,10 +262,10 @@ protected function get_settings() {
* @return array
*/
protected function get_post_types() {
return get_post_types( [ 'public' => true ] );
return get_post_types( array( 'public' => true ) );
}
}

$featured_image_column = new Featured_Image_Column();
$featured_image_column->add_hooks();
register_activation_hook( __FILE__, [ $featured_image_column, 'activation_hook' ] );
register_activation_hook( __FILE__, array( $featured_image_column, 'activation_hook' ) );
28 changes: 12 additions & 16 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Follow the steps below to install the plugin.

== Changelog ==

= Version 0.3.2 (06/26/17) =

* Missed short-array syntax updates for PHP < 5.4 compatibility.

= Version 0.3.1 (06/26/17) =

* Fix for PHP versions < 5.4.
Expand Down Expand Up @@ -158,33 +162,25 @@ Follow the steps below to install the plugin.
== Upgrade Notice ==

= 0.3 =

* Code cleanup, compatibility updates for WordPress 4.8, quick edit no longer collapses the columns and the settings actually toggle post_types on/off!
Code cleanup, compatibility updates for WordPress 4.8, quick edit no longer collapses the columns and the settings actually toggle post_types on/off!

= 0.2.2 =

* Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 4.1 and post type settings.
Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 4.1 and post type settings.

= 0.2.1 =

* Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 3.8 and PHP 5.3+ compat.
Happy holidays! If you like the updates please consider donating. PayPal: austin@thefrosty.com. WP 3.8 and PHP 5.3+ compat.

= 0.1.9 =

* Happy 311 day! Finally fixed duplicate image output. Yay for cache array().
Happy 311 day! Finally fixed duplicate image output. Yay for cache array().

= 0.1.7 =

* Working on fixed repeating images.
Working on fixed repeating images.

= 0.1.6 =

* Cleaned up code thanks to Chris @ iThemes. All errors should be suppressed and clear.
Cleaned up code thanks to Chris @ iThemes. All errors should be suppressed and clear.

= 0.1.2 =

* Code cleanup, attempt at fixing a fatal error when no posts exist (still in progress).
Code cleanup, attempt at fixing a fatal error when no posts exist (still in progress).

= 0.1.1 =

* Adds support for public $post_type's that support 'post-thumbnails'.
Adds support for public $post_type's that support 'post-thumbnails'.

0 comments on commit 2ac779c

Please sign in to comment.