I’ve updated my plugin, Disable Blogging, to the latest version which is available in the WordPress repository.
Everything works as it should. However, one of my users has encountered an error when updating my plugin.
Fatal error: Can’t use function return value in write context in
.../wp-content/plugins/disable-blogging/includes/functions-extra.php
on line 74
They run this plugin on two other sites that they own and there is no issue. The only difference is the PHP version:
- The one that has the error is a GoDaddy server and it might be PHP 5.4.45
- The others are on Digital Ocean and PHP 5.6.25
Looking into my source code, here’s the referring code on line 74 that’s part of a function:
'meta' => array( 'class' => empty( get_avatar( get_current_user_id(), 28 ) ) ? '' : 'with-avatar', ),
But here is the full code to that function. This function simply removes the “Howdy” greeting in the admin bar.
public function admin_greeting( $wp_admin_bar ) {
# Remove admin greeting in all languages
if ( 0 != get_current_user_id() ) {
$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => wp_get_current_user()->display_name . get_avatar( get_current_user_id(), 28 ),
'href' => get_edit_profile_url( get_current_user_id() ),
'meta' => array( 'class' => empty( get_avatar( get_current_user_id(), 28 ) ) ? '' : 'with-avatar', ),
) );
}
}
From my guess, this could be a compatibility issue with PHP 5.4? I’ve been developing the plugin on 5.6 and according to PHP, version 5.4 is no longer being supported.
If thats the case, I’d like to have confirmation on that. This way I can relay that back to the user and even add a function to check the PHP version of any WordPress site before it’s activated.