Skip to content

Commit f79e7ce

Browse files
committed
Fixed: Non-static method should not be called statically
1 parent 67ae20c commit f79e7ce

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.DS_Store
2+
__MACOSX
3+
Thumbs.db
24
*.bak
35
*.log
6+
*.swp
7+
*~

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
### master
3+
### 0.9.0
44

55
- Fixed: Firing sequence of `common_toolkit_loaded` hook
6+
- Fixed: Non-static method should not be called statically
67
- Added: `ctk_environment` filter
78
- Added: Ability to change or remove Howdy from admin bar
89
- Added: Ability to change/remove login errors

common-toolkit.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Common Toolkit
44
* Plugin URI: https://github.com/dmhendricks/wordpress-mu-common-toolkit/
55
* Description: A must use (MU) plugin for WordPress that contains helper functions and snippets.
6-
* Version: 0.8.0
6+
* Version: 0.9.0
77
* Author: Daniel M. Hendricks
88
* Author URI: https://www.danhendricks.com/
99
*/
@@ -12,7 +12,7 @@
1212
class CommonToolkit {
1313

1414
private static $instance;
15-
private static $version = '0.8.0';
15+
private static $version = '0.9.0';
1616
private static $cache = [ 'key' => 'config_registry', 'group' => 'common_toolkit' ];
1717
protected static $config = [];
1818
protected static $environment = [];
@@ -31,7 +31,7 @@ final public static function init() {
3131
if( is_array( CTK_CONFIG ) ) {
3232
self::$config['common_toolkit'] = CTK_CONFIG;
3333
} else if( is_string( CTK_CONFIG ) ) {
34-
self::$config = self::get_cache_object( $cache[ 'key' ], function() {
34+
self::$config = self::get_cache_object( self::$cache[ 'key' ], function() {
3535
return @json_decode( file_get_contents( realpath( ABSPATH . CTK_CONFIG ) ), true ) ?: [];
3636
});
3737
}
@@ -240,7 +240,7 @@ public static function ctk_environment_filter( $key = null ) {
240240
*
241241
* @since 0.8.0
242242
*/
243-
public function disable_emojis() {
243+
public static function disable_emojis() {
244244

245245
remove_action( 'admin_print_styles', 'print_emoji_styles' );
246246
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
@@ -262,7 +262,7 @@ public function disable_emojis() {
262262
*
263263
* @since 0.9.0
264264
*/
265-
public function disable_updates() {
265+
public static function disable_updates() {
266266

267267
global $wp_version;
268268
return (object) array( 'last_checked' => time(), 'version_checked' => $wp_version );
@@ -274,7 +274,7 @@ public function disable_updates() {
274274
*
275275
* @since 0.9.0
276276
*/
277-
public function disable_search( $query, $error = true ) {
277+
public static function disable_search( $query, $error = true ) {
278278

279279
if ( is_search() ) {
280280

@@ -294,7 +294,7 @@ public function disable_search( $query, $error = true ) {
294294
*
295295
* @since 0.8.0
296296
*/
297-
public function change_admin_bar_color() {
297+
public static function change_admin_bar_color() {
298298

299299
printf( '<style type="text/css">#wpadminbar { background: %s; ?> !important; }</style>', CTK_CONFIG['admin_bar_color'] );
300300

@@ -310,7 +310,7 @@ public function change_admin_bar_color() {
310310
* @see http://php.net/manual/en/domdocument.loadhtml.php
311311
* @see http://php.net/manual/en/domelement.setattribute.php
312312
*/
313-
public function defer_async_scripts( $tag, $handle, $src ) {
313+
public static function defer_async_scripts( $tag, $handle, $src ) {
314314

315315
// Return if no modification needed
316316
if( !strpos( $src, '#async' ) && !strpos( $src, '#defer' ) && !strpos( $src, 'custom_attribute' ) ) return $tag;
@@ -419,7 +419,7 @@ public static function set_default_atts( $pairs, $atts ) {
419419
* @since 0.9.0
420420
* @see https://codex.wordpress.org/Function_Reference/wp_heartbeat_settings
421421
*/
422-
public function modify_heartbeat( $settings ) {
422+
public static function modify_heartbeat( $settings ) {
423423

424424
$heartbeat = intval( self::get_config( 'common_toolkit/heartbeat' ) );
425425
if( !$heartbeat ) return $settings;
@@ -435,7 +435,7 @@ public function modify_heartbeat( $settings ) {
435435
* @since 0.9.0
436436
* @see https://codex.wordpress.org/Plugin_API/Filter_Reference/login_errors#Example
437437
*/
438-
public function set_login_errors( $error ) {
438+
public static function set_login_errors( $error ) {
439439

440440
global $errors;
441441
$err_codes = $errors->get_error_codes();
@@ -463,7 +463,7 @@ public function set_login_errors( $error ) {
463463
*
464464
* @since 0.9.0
465465
*/
466-
public function admin_bar_howdy( $wp_admin_bar ) {
466+
public static function admin_bar_howdy( $wp_admin_bar ) {
467467

468468
$message = trim( self::get_config( 'common_toolkit/howdy_message' ) ) ?: '';
469469
$my_account = $wp_admin_bar->get_node( 'my-account' );
@@ -479,7 +479,7 @@ public function admin_bar_howdy( $wp_admin_bar ) {
479479
*
480480
* @since 0.8.0
481481
*/
482-
public function modify_meta_generator_tags( $current, $type ) {
482+
public static function modify_meta_generator_tags( $current, $type ) {
483483

484484
$meta_generator = self::get_config( 'common_toolkit/meta_generator' );
485485
switch( true ) {
@@ -506,7 +506,7 @@ public function modify_meta_generator_tags( $current, $type ) {
506506
* @since 0.8.0
507507
* @see https://php.net/date
508508
*/
509-
public function shortcode_get_datetime( $atts ) {
509+
public static function shortcode_get_datetime( $atts ) {
510510

511511
$atts = shortcode_atts( [
512512
'format' => get_option( 'date_format' ) . ' ' . get_option( 'time_format' )
@@ -536,19 +536,19 @@ private function strip_extra_dom_elements( $element ) {
536536
* @return mixed
537537
* @since 0.9.0
538538
*/
539-
public function get_cache_object( $key, $callback, $force = false ) {
539+
public static function get_cache_object( $key, $callback, $force = false ) {
540540

541541
if( $force ) return $callback();
542542

543543
$cache_expire = defined( 'CTK_CACHE_EXPIRE' ) && is_int( CTK_CACHE_EXPIRE ) ? intval( CTK_CACHE_EXPIRE ) : false;
544544
if( !is_int( $cache_expire ) ) return $callback();
545545

546-
$result = unserialize( wp_cache_get( $key, $cache[ 'group' ], false, $cache_hit ) );
546+
$result = unserialize( wp_cache_get( $key, self::$cache[ 'group' ], false, $cache_hit ) );
547547

548548
if( !$cache_hit ) {
549549

550550
$result = $callback();
551-
wp_cache_set( $key, serialize( $result ), $cache[ 'group' ], $cache_expire );
551+
wp_cache_set( $key, serialize( $result ), self::$cache[ 'group' ], $cache_expire );
552552

553553
} else {
554554

@@ -565,9 +565,9 @@ public function get_cache_object( $key, $callback, $force = false ) {
565565
*
566566
* @since 0.8.0
567567
*/
568-
public function delete_config_cache() {
568+
public static function delete_config_cache() {
569569

570-
wp_cache_delete( $cache[ 'group' ], $cache[ 'group' ] );
570+
wp_cache_delete( self::$cache[ 'group' ], self::$cache[ 'group' ] );
571571

572572
}
573573

@@ -582,4 +582,4 @@ public function __toString() {
582582

583583
}
584584

585-
CommonToolkit::init();
585+
CommonToolkit::init();

sample-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"disable_xmlrpc": false,
1111
"feed_links": true,
1212
"heartbeat": null,
13-
"howdy_message": "Welcome,",
14-
"login_errors": true,
13+
"howdy_message": "Hello,",
14+
"set_login_errors": null,
1515
"meta_generator": "Atari 2600",
1616
"script_attributes": true,
1717
"shortcodes": false,

0 commit comments

Comments
 (0)