Skip to content

Commit

Permalink
Updated for wordpress-toolkit 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmhendricks committed Aug 25, 2018
1 parent 7c8f6f2 commit 072611e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
16 changes: 8 additions & 8 deletions app/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class Core extends Plugin {
function __construct() {

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

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

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

/**
Expand All @@ -27,8 +27,8 @@ function __construct() {
*/
if( current_user_can( 'manage_options' ) && $this->get_carbon_plugin_option( 'admin_bar_add_clear_cache' ) ) {
add_action( 'admin_bar_menu', array( $this, 'admin_bar_add_clear_cache' ), 900 );
//add_action( 'wp_ajax_nopriv_clear_object_cache_ajax', array( self::$cache, 'flush' ) );
add_action( 'wp_ajax_clear_object_cache_ajax', array( self::$cache, 'flush' ) );
//add_action( 'wp_ajax_nopriv_clear_object_cache_ajax', array( $this, 'clear_object_cache_ajax' ) );
add_action( 'wp_ajax_clear_object_cache_ajax', array( $this, 'clear_object_cache_ajax' ) );
}

}
Expand Down Expand Up @@ -111,11 +111,11 @@ public function admin_bar_add_clear_cache( $wp_admin_bar ) {
*/
public function clear_object_cache_ajax() {

$result = ['success' => true];
$result = [ 'success' => true ];

try {
self::$cache->flush();
} catch (Exception $e) {
} catch ( Exception $e ) {
$result = [ 'success' => false, 'message' => $e->getMessage() ];
}

Expand Down
20 changes: 2 additions & 18 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static function get_carbon_plugin_option( $key, $cache = true ) {
// Attempt to get value from cache, else fetch value from database
return self::$cache->get_object( $key, function() use ( &$key ) {
return carbon_get_theme_option( $key );
}, self::$config->get( 'object_cache/group' ), false );
});
} else {
// Return uncached value
return carbon_get_theme_option( $key );
Expand Down Expand Up @@ -234,7 +234,7 @@ public static function get_carbon_network_option( $key, $cache = true, $site_id
// Attempt to get value from cache, else fetch value from database
return self::$cache->get_object( $key, function() use ( &$site_id, &$key ) {
return carbon_get_network_option( $site_id, $key );
}, self::$config->get( 'object_cache/group' ), true );
}, null, [ 'network_global' => true ] );
} else {
// Return uncached value
return carbon_get_network_option( $site_id, $key );
Expand Down Expand Up @@ -274,20 +274,4 @@ public static function get_wpsac_plugin_option( $key, $group_id = 'options', $ca

}

/**
* Append a field prefix as defined in $config
*
* @param string|null $field_name The string/field to prefix
* @param string $before String to add before the prefix
* @param string $after String to add after the prefix
* @return string Prefixed string/field value
* @since 0.1.0
*/
public static function prefix( $field_name = null, $before = '', $after = '_' ) {

$prefix = $before . self::$config->get( 'prefix' ) . $after;
return $field_name !== null ? $prefix . $field_name : $prefix;

}

}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"source": "https://github.com/dmhendricks/wordpress-base-plugin/"
},
"require": {
"php": ">=5.6.0",
"jjgrainger/posttypes": "^2.0",
"php": ">=5.6.4",
"jjgrainger/posttypes": "^2.0.1",
"tgmpa/tgm-plugin-activation": "^2.6.1",
"tareq1988/wordpress-settings-api-class": "dev-master",
"dmhendricks/wordpress-toolkit": "0.3.4",
"inc2734/wp-customizer-framework": "^3.1.0",
"dmhendricks/wordpress-toolkit": "0.4.0",
"inc2734/wp-customizer-framework": "^3.2.3",
"composer/installers": "^1.0.6"
},
"minimum-stability": "dev",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "My Plugin",
"object_cache": {
"group": "wordpress_base_plugin_cache",
"expire_hours": 72
"expire": 86400
},
"dependencies": {
"php": "5.6",
Expand Down
2 changes: 1 addition & 1 deletion wordpress-base-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: WordPress Base Plugin
* Plugin URI: https://github.com/dmhendricks/wordpress-base-plugin
* Description: A boilerplate for WordPress plugins
* Version: 0.5.3
* Version: 0.5.4
* Author: Daniel M. Hendricks
* Author URI: https://www.danhendricks.com
* License: GPL-2.0
Expand Down

0 comments on commit 072611e

Please sign in to comment.