• Resolved almendron

    (@almendron)


    PHP 8.1.12
    Jetpack 11.9.1
    Debug enabled
    Server local
    Error message:

    Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in C:\wamp64\www\artehistoria\wp-content\plugins\jetpack\modules\sharedaddy\sharing-sources.php on line 1151

    All “preg_replace” chains should be reviewed. It is possible that some of them are affected.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Jen H. (a11n)

    (@jenhooks)

    Hi @almendron,

    Can you tell us more about your site? Your site URL, the plugins you use, and if you use any plugin(s) that modify the output of Twitter Cards by hooking into the jetpack_sharing_twitter_via filter?

    If you’d rather take this straight to our developers, you could create an issue on the Jetpack Github repo with the details requested above.

    Thanks!

    Thread Starter almendron

    (@almendron)

    I found out what the problem was


    Social module: deactivated
    Share module: activated
    Twitter site tag: no relevance
    Filter on archive functions.php. This is what causes the error

    add_filter ( 'jetpack_sharing_twitter_via', 'afn_add_twitterhandle_via' );
    function afn_add_twitterhandle_via() {
    	if (!is_user_logged_in() ):
    		return 'XXXXXXXX';
    	endif;
    }

    It should be changed to

    add_filter ( 'jetpack_sharing_twitter_via', 'afn_add_twitterhandle_via' );
    function afn_add_twitterhandle_via() {
    	if (is_user_logged_in() ):
    		return '';
    	else :
    		return 'XXXXXXXX';
    	endif;
    }

    sharing-sources.php:

    $twitter_site_tag_value = apply_filters( 'jetpack_sharing_twitter_via', $twitter_site_tag_value, $post->ID );
    return preg_replace( '/[^\da-z_]+/i', '', $twitter_site_tag_value );

    If the value of the variable “$twitter_site_tag_value” is null or empty, then “preg_replace” fails.

    Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @almendron

    Thanks for letting us know this is resolved and sharing the solution in case others run into a similar

    I’m going to mark this thread as resolved. If you have additional questions about Jetpack in the future, feel free to open a new thread.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Deprecated: preg_replace():’ is closed to new replies.