Skip to content

Commit 072611e

Browse files
committed
Updated for wordpress-toolkit 0.4.0
1 parent 7c8f6f2 commit 072611e

5 files changed

Lines changed: 16 additions & 32 deletions

File tree

app/Core.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ class Core extends Plugin {
66
function __construct() {
77

88
// Example - Add page, post type and parent classes to <body> tag for selector targeting
9-
add_filter( 'body_class', array( &$this, 'add_body_classes' ) );
9+
add_filter( 'body_class', array( $this, 'add_body_classes' ) );
1010

1111
// Example - Remove Emoji code from header
12-
if( $this->get_carbon_plugin_option( 'remove_header_emojicons' ) ) {
13-
if( !$this->is_ajax() ) add_filter( 'init', array( &$this, 'disable_wp_emojicons' ) );
12+
if( !$this->is_ajax() && $this->get_carbon_plugin_option( 'remove_header_emojicons' ) ) {
13+
add_filter( 'init', array( $this, 'disable_wp_emojicons' ) );
1414
}
1515

1616
// Multisite Example - Change WP Admin footer text
1717
if( is_multisite() && trim( $this->get_carbon_network_option( 'network_site_footer' ) ) ) {
18-
add_filter( 'admin_footer_text', array( &$this, 'set_admin_footer_text' ) );
18+
add_filter( 'admin_footer_text', array( $this, 'set_admin_footer_text' ) );
1919
}
2020

2121
/**
@@ -27,8 +27,8 @@ function __construct() {
2727
*/
2828
if( current_user_can( 'manage_options' ) && $this->get_carbon_plugin_option( 'admin_bar_add_clear_cache' ) ) {
2929
add_action( 'admin_bar_menu', array( $this, 'admin_bar_add_clear_cache' ), 900 );
30-
//add_action( 'wp_ajax_nopriv_clear_object_cache_ajax', array( self::$cache, 'flush' ) );
31-
add_action( 'wp_ajax_clear_object_cache_ajax', array( self::$cache, 'flush' ) );
30+
//add_action( 'wp_ajax_nopriv_clear_object_cache_ajax', array( $this, 'clear_object_cache_ajax' ) );
31+
add_action( 'wp_ajax_clear_object_cache_ajax', array( $this, 'clear_object_cache_ajax' ) );
3232
}
3333

3434
}
@@ -111,11 +111,11 @@ public function admin_bar_add_clear_cache( $wp_admin_bar ) {
111111
*/
112112
public function clear_object_cache_ajax() {
113113

114-
$result = ['success' => true];
114+
$result = [ 'success' => true ];
115115

116116
try {
117117
self::$cache->flush();
118-
} catch (Exception $e) {
118+
} catch ( Exception $e ) {
119119
$result = [ 'success' => false, 'message' => $e->getMessage() ];
120120
}
121121

app/Plugin.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static function get_carbon_plugin_option( $key, $cache = true ) {
201201
// Attempt to get value from cache, else fetch value from database
202202
return self::$cache->get_object( $key, function() use ( &$key ) {
203203
return carbon_get_theme_option( $key );
204-
}, self::$config->get( 'object_cache/group' ), false );
204+
});
205205
} else {
206206
// Return uncached value
207207
return carbon_get_theme_option( $key );
@@ -234,7 +234,7 @@ public static function get_carbon_network_option( $key, $cache = true, $site_id
234234
// Attempt to get value from cache, else fetch value from database
235235
return self::$cache->get_object( $key, function() use ( &$site_id, &$key ) {
236236
return carbon_get_network_option( $site_id, $key );
237-
}, self::$config->get( 'object_cache/group' ), true );
237+
}, null, [ 'network_global' => true ] );
238238
} else {
239239
// Return uncached value
240240
return carbon_get_network_option( $site_id, $key );
@@ -274,20 +274,4 @@ public static function get_wpsac_plugin_option( $key, $group_id = 'options', $ca
274274

275275
}
276276

277-
/**
278-
* Append a field prefix as defined in $config
279-
*
280-
* @param string|null $field_name The string/field to prefix
281-
* @param string $before String to add before the prefix
282-
* @param string $after String to add after the prefix
283-
* @return string Prefixed string/field value
284-
* @since 0.1.0
285-
*/
286-
public static function prefix( $field_name = null, $before = '', $after = '_' ) {
287-
288-
$prefix = $before . self::$config->get( 'prefix' ) . $after;
289-
return $field_name !== null ? $prefix . $field_name : $prefix;
290-
291-
}
292-
293277
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"source": "https://github.com/dmhendricks/wordpress-base-plugin/"
1919
},
2020
"require": {
21-
"php": ">=5.6.0",
22-
"jjgrainger/posttypes": "^2.0",
21+
"php": ">=5.6.4",
22+
"jjgrainger/posttypes": "^2.0.1",
2323
"tgmpa/tgm-plugin-activation": "^2.6.1",
2424
"tareq1988/wordpress-settings-api-class": "dev-master",
25-
"dmhendricks/wordpress-toolkit": "0.3.4",
26-
"inc2734/wp-customizer-framework": "^3.1.0",
25+
"dmhendricks/wordpress-toolkit": "0.4.0",
26+
"inc2734/wp-customizer-framework": "^3.2.3",
2727
"composer/installers": "^1.0.6"
2828
},
2929
"minimum-stability": "dev",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"short_name": "My Plugin",
44
"object_cache": {
55
"group": "wordpress_base_plugin_cache",
6-
"expire_hours": 72
6+
"expire": 86400
77
},
88
"dependencies": {
99
"php": "5.6",

wordpress-base-plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: WordPress Base Plugin
55
* Plugin URI: https://github.com/dmhendricks/wordpress-base-plugin
66
* Description: A boilerplate for WordPress plugins
7-
* Version: 0.5.3
7+
* Version: 0.5.4
88
* Author: Daniel M. Hendricks
99
* Author URI: https://www.danhendricks.com
1010
* License: GPL-2.0

0 commit comments

Comments
 (0)