Our website with error turned on (plugin activated):
Example URLs with error: https://www.live-karikaturen.ch/downloads/1-august-fahnen-schwingen-nationalfeiertag-schweiz/ https://www.live-karikaturen.ch/webshop-gratisbilder-free-cartoon-comic-images/ https://www.live-karikaturen.ch/downloads/auto-suv-autofan-abgase-umweltverschmutzung/
UPDATE INCOMPATIBILITY: I updated from a very old PHP version to 7.4
I use this EXTREMLY important plugin, which is horrible outdated (4 years last Update): https://wordpress.org/support/plugin/creative-commons-configurator-1/
Now I get this error and I think it's maybe very easy to solve, but I know almost nothing about PHP, but I try to learn it a bit, so thank you very much in advance.
ERROR: *
Warning: preg_match_all(): Compilation failed: escape sequence is invalid in character class at offset 18 in /home/clients/f9abb707fe4ac1215fe0f0a9c0b0ae21/www.live-karikaturen-ch/wp-content/plugins/creative-commons-configurator-1/creative-commons-configurator-1.php on line 821
I copy the code from the .php file here
CODE:This is line 821:
if ( ! preg_match_all( $pattern_images_no_caption, $post_content, $matches ) ) {
return $post_content;
}
CODE From line 803 - 828 (don't know who to copy the line numbers):
function bccl_separate_licensing_on_images_without_caption( $post_content ) {
// Plugin options
$options = get_option('cc_settings');
if ( $options === false || $options['cc_enable_individual_media_licensing'] == '0' ) {
return $post_content;
}
$post = get_queried_object();
if ( apply_filters('bccl_exclude_license', false, $post) ) {
return $post_content;
}
// Pattern that matches images without caption
//$pattern_images_no_caption = '#<p>[\s\R]*(<img [^>]+>)#';
$pattern_images_no_caption = '#<(?:p|h[\d]+)>[\s\R]*(<img [^>]+>)#';
$pattern_images_no_caption = apply_filters('bccl_pattern_match_images_without_caption' , $pattern_images_no_caption);
**if ( ! preg_match_all( $pattern_images_no_caption, $post_content, $matches ) ) {
return $post_content;
}**
//var_dump($matches[1]);
// Iterate over the found images and add licensing metadata
foreach ( $matches[1] as $image_html ) {
Is there a simple way how to fix this error?
THANK YOU VERY MUCH FOR YOUR ANSWER & HELP!
THAAAANK you very much, you are AMAZING! :) I tried it out and it works, at least there is no error anymore.
FIRST I am just not sure which version of the corrected code I should take. I guess Nr. 1 is ok, without []. That mean, as Toto wrote above I replaced [\s\R] with a simple \s.
Nr. 1.) without []
//$pattern_images_no_caption = '#
\s*(<img [^>]+>)#'; $pattern_images_no_caption = '#<(?:p|h[\d]+)>\s*(<img [^>]+>)#';
Nr. 2.) with []
SECOND I searched the whole creative-commons-configurator.php plugin code for \R and found further in line 979 this:
All lines together of this part are this:
QUESTION: In the moment I don't get any error, but I wonder if this will produce one and I have to delete or replace the "evil" \R?