From eaf13e3ac9903ef74a687d8e12289ebf41ea5685 Mon Sep 17 00:00:00 2001 From: Daniel Hendricks Date: Sat, 18 Nov 2017 02:34:45 -0600 Subject: [PATCH] Updated compatibility for Carbon Fields 2.1.1 --- README.md | 1 + app/Helpers.php | 8 ++++---- app/Plugin.php | 6 +++--- app/PostTypes/Clients.php | 4 ++-- app/Settings/Carbon_Page.php | 2 +- composer.json | 2 +- readme.txt | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ab98c5f..becbd65 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Release changes are noted on the [Releases](https://github.com/dmhendricks/wordp * Added Carbon Fields [Serialized Datastore](https://github.com/dmhendricks/wordpress-base-plugin/wiki/Features-&-Customization#serialized-data-store) example * Fixed bugs with example widget scope +* Updated compatibility for Carbon Fields 2.1.1 ## Credits diff --git a/app/Helpers.php b/app/Helpers.php index d575867..0fbf0fb 100644 --- a/app/Helpers.php +++ b/app/Helpers.php @@ -158,7 +158,7 @@ public static function get_post_categories($as_slugs = false, $post_id = null) { * @return string * @since 0.1.0 */ - public function get_script_version( $script, $return_minified = false, $script_version = null ) { + public static function get_script_version( $script, $return_minified = false, $script_version = null ) { $version = $script_version ?: self::$config->get( 'plugin/meta/Version' ); if( self::is_production() ) return $version; @@ -185,9 +185,9 @@ public function get_script_version( $script, $return_minified = false, $script_v * @return string The URL or path to minified or regular $script. * @since 0.1.0 */ - public function get_script_path( $script, $return_minified = true, $return_url = false ) { + public static function get_script_path( $script, $return_minified = true, $return_url = false ) { $script = trim( $script, '/' ); - if( $return_minified && strpos( $script, '.' ) && $this->is_production() ) { + if( $return_minified && strpos( $script, '.' ) && self::is_production() ) { $script_parts = explode( '.', $script ); $script_extension = end( $script_parts ); array_pop( $script_parts ); @@ -204,7 +204,7 @@ public function get_script_path( $script, $return_minified = true, $return_url = * @param bool * @since 0.1.0 */ - public function get_script_url( $script, $return_minified = false ) { + public static function get_script_url( $script, $return_minified = false ) { return self::get_script_path( $script, $return_minified, true ); } diff --git a/app/Plugin.php b/app/Plugin.php index 9b2091f..324ffed 100644 --- a/app/Plugin.php +++ b/app/Plugin.php @@ -62,7 +62,7 @@ public function init() { } if( $this->verify_dependencies( 'carbon_fields' ) === true ) { - add_action( 'carbon_fields_loaded', array( $this, 'load_plugin' )); + add_action( 'carbon_fields_fields_registered', array( $this, 'load_plugin' )); } } @@ -206,7 +206,7 @@ public function get_plugin_option( $key, $cache = true ) { * @return string Prefixed string/field value * @since 0.2.0 */ - public function prefix( $field_name = null ) { + public static function prefix( $field_name = null ) { return $field_name !== null ? self::$config->get( 'prefix' ) . $field_name : self::$config->get( 'prefix' ); } @@ -218,7 +218,7 @@ public function prefix( $field_name = null ) { * @return bool * @since 0.1.0 */ - public function is_production() { + public static function is_production() { return ( !defined( 'WP_ENV' ) || ( defined('WP_ENV' ) && !in_array( WP_ENV, array('development', 'staging') ) ) ); } diff --git a/app/PostTypes/Clients.php b/app/PostTypes/Clients.php index 7bad76d..777e206 100644 --- a/app/PostTypes/Clients.php +++ b/app/PostTypes/Clients.php @@ -53,14 +53,14 @@ public function add_post_type_client() { // Add fields Container::make( 'post_meta', __('Client Details', self::$textdomain ) ) - ->show_on_post_type( $cpt->postTypeName ) + ->show_on_post_type( $cpt->name ) ->add_fields( array( Field::make( 'text', $this->prefix( 'name' ), __( 'Name', self::$textdomain ) ), Field::make( 'text', $this->prefix( 'company' ), __( 'Company', self::$textdomain ) ), ) ); Container::make( 'post_meta', 'Contact Info' ) - ->show_on_post_type( $cpt->postTypeName ) + ->show_on_post_type( $cpt->name ) ->add_fields( array( Field::make( 'text', $this->prefix( 'url' ), __( 'Web Site', self::$textdomain ) ), Field::make( 'text', $this->prefix( 'phone' ), __( 'Phone Number', self::$textdomain ) ), diff --git a/app/Settings/Carbon_Page.php b/app/Settings/Carbon_Page.php index 2df3423..9173809 100644 --- a/app/Settings/Carbon_Page.php +++ b/app/Settings/Carbon_Page.php @@ -113,7 +113,7 @@ private function create_tabbed_options_page() { */ private function create_single_options_page() { - Container::make( 'theme_options', self::$config->get( 'plugin/meta/Name' ) ) + $container = Container::make( 'theme_options', self::$config->get( 'plugin/meta/Name' ) ) ->set_page_parent( 'options-general.php' ) ->add_fields( array( Field::make( 'text', $this->prefix( 'your_name' ), __( 'Your Name', self::$textdomain ) ), diff --git a/composer.json b/composer.json index 6e15165..fc1458d 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=5.6.0", "jjgrainger/posttypes": "dev-master", - "tgmpa/tgm-plugin-activation": "^2.6.0", + "tgmpa/tgm-plugin-activation": "^2.6.1", "tareq1988/wordpress-settings-api-class": "dev-master", "dmhendricks/wordpress-toolkit": "dev-master", "composer/installers": "^1.4.0" diff --git a/readme.txt b/readme.txt index b70ff4f..6b474bb 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: hendridm Tags: wordpress,base,plugin,boilerplate,composer,carbonfields Donate link: https://paypal.me/danielhendricks Requires at least: 4.0 -Tested up to: 4.8.2 +Tested up to: 4.9 Stable tag: 0.3.0 License: GPL-2.0 License URI: http://www.gnu.org/licenses/gpl-2.0.html