• Resolved subedinfo

    (@subedinfo)


    Hi,

    After updating to PHP 8.1 we started on the lookout for issues and conflicts. One of this issues comes from the RankMath plugin.

    We have the following block on our functions.php theme file:

    /**
     * Allows developers to change the OpenGraph image within theme.
     * The dynamic part of the hook name. $network, is the network slug. Can be facebook or twitter.
     * @param string $attachment_url The image we are about to add.
     */
    add_filter( "rank_math/opengraph/{$network}/image", function( $attachment_url ) {
    	return $attachment_url;
    });

    And this results in the continued error on the logs:

    [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:47:57 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:48:15 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:48:37 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:49:03 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:49:04 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:49:21 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:49:39 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:50:02 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
    [03-Jan-2023 14:50:37 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @subedinfo,

    Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.

    The implementation of your filter code is incorrect.

    You need to ensure that you have provided a value for the variable $network and it could be either “facebook” or “twitter”

    Here’s an example for a correct hook:

    “rank_math/opengraph/facebook/image”

    or

    “rank_math/opengraph/twitter/image”

    Hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘PHP 8.1 – PHP Warning: Undefined variable $network in (…)’ is closed to new replies.