Merge pull request #6892 from SiR-DanieL/patch-2
Introduced filters for copy/delete templates
This commit is contained in:
commit
6cd9faf79c
|
@ -506,15 +506,17 @@ class WC_Email extends WC_Settings_API {
|
|||
if ( ! empty( $_GET['move_template'] ) && ( $template = esc_attr( basename( $_GET['move_template'] ) ) ) ) {
|
||||
|
||||
if ( ! empty( $this->$template ) ) {
|
||||
|
||||
$template_folder = '/' . trim( apply_filters( 'woocommerce_copy_to_theme_folder', 'woocommerce', $this->template ), '/' ) . '/';
|
||||
|
||||
if ( wp_mkdir_p( dirname( get_stylesheet_directory() . '/woocommerce/' . $this->$template ) ) && ! file_exists( get_stylesheet_directory() . '/woocommerce/' . $this->$template ) ) {
|
||||
if ( wp_mkdir_p( dirname( get_stylesheet_directory() . $template_folder . $this->$template ) ) && ! file_exists( get_stylesheet_directory() . $template_folder . $this->$template ) ) {
|
||||
|
||||
// Locate template file
|
||||
$core_file = $this->template_base . $this->$template;
|
||||
$template_file = apply_filters( 'woocommerce_locate_core_template', $core_file, $this->$template, $this->template_base );
|
||||
|
||||
// Copy template file
|
||||
copy( $template_file, get_stylesheet_directory() . '/woocommerce/' . $this->$template );
|
||||
copy( $template_file, get_stylesheet_directory() . $template_folder . $this->$template );
|
||||
|
||||
/**
|
||||
* woocommerce_copy_email_template action hook
|
||||
|
@ -532,9 +534,11 @@ class WC_Email extends WC_Settings_API {
|
|||
if ( ! empty( $_GET['delete_template'] ) && ( $template = esc_attr( basename( $_GET['delete_template'] ) ) ) ) {
|
||||
|
||||
if ( ! empty( $this->$template ) ) {
|
||||
|
||||
$template_folder = '/' . trim( apply_filters( 'woocommerce_delete_from_theme_folder', 'woocommerce', $this->template ), '/' ) . '/';
|
||||
|
||||
if ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $this->$template ) ) {
|
||||
unlink( get_stylesheet_directory() . '/woocommerce/' . $this->$template );
|
||||
if ( file_exists( get_stylesheet_directory() . $template_folder . $this->$template ) ) {
|
||||
unlink( get_stylesheet_directory() . $template_folder . $this->$template );
|
||||
|
||||
/**
|
||||
* woocommerce_delete_email_template action hook
|
||||
|
|
Loading…
Reference in New Issue