How to fix the Gravity Form error “Call to a member function can_be_used() on bool”

This article is more for my future self, but it may help others.

Following the upgrade to Gravity Form 2.6.2, I found myself on several sites I maintain with a fatal error looking like:

[06-May-2022 20:30:52 UTC] PHP Fatal error: Uncaught Error: Call to a member function can_be_used() on bool in /var/www/my-great-website/wp-content/plugins/gravityforms/common.php:2813
Stack trace:

I didn’t dig too much to know the cause… I’ll do that later… when a client site is down… we correct it quickly 😉

To correct this error I just added

define( 'GF_CACHE_DEBUG', true );

in the `wp-config.php` and then go to resave the form settings (without changing anything)

This error occurs when the license verification fails. The developers of Gravity Forms are studying the issue and will soon publish a new version.

The added constant allows to validate the license without taking into account the cached data.

Tell me in comments if you had this error and this tip helped you!

Easily post your Facebook page feed.

I had a simple need these last few days… to display the feed of a Facebook page on a client site. Of course, I looked at the existing extensions and… I must admit that there are a ton of them!

A ton is good… but nothing really corresponded to my needs, because it was too complex to set up, required a Facebook account to create an application. In short, what I needed was simply what Facebook offers on its “plugin page”.

So of course… I could have coded my thing in my corner… and I said to myself… if I have the need, then surely others too… so make an extension my brave Séb !

A new extension by thivinfo.com

It is a very simple extension, there is a shortcode and a block for the new editor (thanks to Marie Comet).
The shortcode [\simple_wall] waits for at least one slug
parameter which waits for the slug of your Facebook page…

Example : the short code [\simple_wall slug="MotoGP"] (without the slash which has been added so that WP doesn’t interpret it) should display the feed of the Facebook page dedicated to this sport of which we are world champion (how do I get away from that ?).

Here it is in action:
[simple_wall slug=’MotoGP’]

The Gutenberg block “Simple Wall” is available in the list of blocks and also waits for the slug of the page to display.

The 2 other optional parameters are the width and the height of display.

The planned evolutions…

I use Twitter more (which is quite simple since I don’t have a FB account) and I wonder if I could evolve the extension to display the Twitter feed as well… tell me in comments if you’re interested.

Add custom icons to your ACF with ACF projects: FontAwesome Field

If you’re used to creating your own web icons, you must be familiar with Icomoon. For a client project already using FontAwesome, I needed to add 2 customs icons from using the Icomoon service.

In this blog post, I’m using Icomoon, but you should be able to reproduce the same behaviour with another icon provider, maybe with some adaptation.

FontAwesome icons were used on menu items thanks to Advanced Custom Fields and Advanced Custom Fields: Font Awesome Field. The goal is to add to the list of FontAwesome icons, my 2 or 3 customs icomoon icons.

Show Icomoon icons in the ACF FontAwesome field

Advanced Custom Fields: Font Awesome Field that I will name ACFFA from now offers a filter to modify the list of icons:

ACFFA_get_icons
add_filter( 'ACFFA_get_icons', 'cot_test' );
function cot_test( $icons ) {
$icomoon = array(
'cierge' => array(
'name' => 'cierge',
'hex' => '\e90e',
'unicode' => ''
),
'calice' => array(
'name' => 'calice',
'hex' => '\e90f',
'unicode' => ''
),
);
foreach ( $icomoon as $ico ) {
$icons['list']['far'][ 'far ' . $ico['name'] ] = '<i class="icon-' . $ico['name'] . '"></i> ' . ucfirst(
$ico['name'] );
$icons['details']['far']['far ' . $ico['name']]['hex'] = $ico['hex'];
$icons['details']['far']['far ' . $ico['name']]['unicode'] = $ico['unicode'];
}

return $icons;
}

Here we filter the existing list of FA icons to add our custom icons. Unfortunately, since the Matt Keys extension is developed for FA, only the FontAwesome categories are available, namely Brand (fab), Regular (far), Style (fas). I decided to add my icons in the Regular or Far categories. This is purely arbitrary.

DéLet’s break down the code above

array(
'cierge' => array(
'name' => 'cierge',
'hex' => '\e90e',
'unicode' => '&#xe90e;'
),

Here I declare the Icomoon icons I’m going to want to use:

  • name: the name of the icon in the list
  • hex: the hexadecimal code provided by Icomoon
  • unicode: the unicode of the Icomoon icon

Then, with a foreach loop, I’m going to feed the $icons array containing the FontAwesome icons

Exemple d'icône personalisé dans le champs ACF

Display icons in the back office and front office

To display the icons in back-office, the Icomoon CSS sheet with all the icons will have to be loaded on the back-end side.

For that, we’re going to add this code:

add_action( 'admin_print_styles', 'cot_load_icomoon_css' );

If you are used to developing your themes you know the WordPress action hook wp_enqueue_scripts that allows you to load stylesheets and scripts in the frontend. There is also an equivalent for the back office called admin_print_styles.

add_action( 'admin_print_styles', 'cot_load_icomoon_css' );
add_action( 'wp_enqueue_scripts', 'cot_load_icomoon_css', 9, 1 );
function cot_load_icomoon_css(){
wp_enqueue_style( 'font-icomoon', get_template_directory_uri() . '/css/iconmoon.css');
}

So here I load the CSS sheet in front and back office.

I put a priority 9 at the front loading in order to pass just before the loading of the theme stylesheet and to be able to use them afterwards in my theme. By default an add_action() has a priority of 10.

Display the icons in front-office

In front-office, the ACF FontAwesome extension returns HTML markup formatted for FA (normal!). In some cases, we want to load another font (the one generated by Icomoon) in our custom icon.

Icomoon provided me with 4 font files (.eot, .svg, .ttf and .woff) that I placed in my projects. The icomoon.css file does a @font-face so that the fonts are loaded

The problem lies in the fact that the Matt Keys extension generates an HTML FA markup and it will be necessary to “trick” to hijack the operation only for Icomoon icons. And yes, we want to be able to continue to use FontAwesome normally.

<i class="far cierge" aria-hidden="true"></i>

We find the far class of FA which will load the FontAwesome font then the cierge class generated from the name given in the list of extensions to insert.

To make the site load my font instead of FontAwesome’s, I created a CSS sheet modifying the style of these classes:

.far.cierge:before {
font-family: "my-icomoon-font";
content: "\e90e";
}

For each custom icon I ask WordPress to load my-icomoon-font and use the content with the hex code corresponding to my icon.