WC_Email::delete_template_action()protectedWC 1.0

Delete template action.

Method of the class: WC_Email{}

Hooks from the method

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->delete_template_action( $template_type );
$template_type(string) (required)
Template type.

WC_Email::delete_template_action() code WC 9.3.1

<?php
protected function delete_template_action( $template_type ) {
	$template = $this->get_template( $template_type );

	if ( $template ) {
		if ( ! empty( $template ) ) {
			$theme_file = $this->get_theme_template_file( $template );

			if ( file_exists( $theme_file ) ) {
				unlink( $theme_file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink

				/**
				 * Action hook fired after deleting template file.
				 *
				 * @param string $template The deleted template type
				 * @param string $email The email object
				 */
				do_action( 'woocommerce_delete_email_template', $template_type, $this );
				?>
				<div class="updated">
					<p><?php echo esc_html__( 'Template file deleted from theme.', 'woocommerce' ); ?></p>
				</div>
				<?php
			}
		}
	}
}