WC_Email::save_template( string $template_code, string $template_path )
Save the email templates.
Description Description
Parameters Parameters
- $template_code
-
(Required) Template code.
- $template_path
-
(Required) Template path.
Source Source
File: includes/emails/class-wc-email.php
protected function save_template( $template_code, $template_path ) { if ( current_user_can( 'edit_themes' ) && ! empty( $template_code ) && ! empty( $template_path ) ) { $saved = false; $file = get_stylesheet_directory() . '/' . WC()->template_path() . $template_path; $code = wp_unslash( $template_code ); if ( is_writeable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writeable $f = fopen( $file, 'w+' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen if ( false !== $f ) { fwrite( $f, $code ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite fclose( $f ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose $saved = true; } } if ( ! $saved ) { $redirect = add_query_arg( 'wc_error', rawurlencode( __( 'Could not write to template file.', 'woocommerce' ) ) ); wp_safe_redirect( $redirect ); exit; } } }
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Introduced. |