Hallo zusammen,
ich habe folgendes Problem, wo ich nicht weiterkomme:
In einer Plugin-Datei soll der String
durch diesen String
ersetzt werden. Das Script kommt in die functions.php oder ein Snippet-Plugin rein.
Dieses Muster habe ich gefunden
PHP
$path_to_file = 'path/to/the/file';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace("\nH",",H",$file_contents);
file_put_contents($path_to_file,$file_contents);
und so angepasst:
PHP
$path_to_file = WP_PLUGIN_DIR . '/happyforms/core/templates/parts/frontend-checkbox.php';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace("<?php echo esc_attr( $option['label'] ); ?>","<?php echo html_entity_decode( $option['label'] ); ?>",$file_contents);
file_put_contents($path_to_file,$file_contents);
Es kommt folgende Fehlermeldung:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\LWS\laragon\www\HappyForms\wp-content\plugins\wp-h-snippets\wphs.php on line 34
Jetzt komme ich nicht weiter und bitte um einen guten Tipp.
Die Variable "$option['label']" ist vermutlich noch leer.
Vielen Dank!