[ 'id' => 1, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::NEW_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/1/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/1/content.json', ], 'template-2' => [ 'id' => 2, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::CANCELLED_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/2/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/2/content.json', ], 'template-3' => [ 'id' => 3, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::FAILED_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/3/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/3/content.json', ], 'template-4' => [ 'id' => 4, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::ORDER_ON_HOLD, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/4/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/4/content.json', ], 'template-5' => [ 'id' => 5, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::PROCESSING_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/5/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/5/content.json', ], 'template-6' => [ 'id' => 6, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::COMPLETED_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/6/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/6/content.json' ], 'template-7' => [ 'id' => 7, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::REFUNDED_ORDER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/7/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/7/content.json' ], 'template-8' => [ 'id' => 8, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::CUSTOMER_INVOICE_OR_ORDER_DETAILS, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/8/preview-thumb.svg', 'demo-url' => 'https://products.wpmet.com/metform/job-listing-form/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/8/content.json' ], 'template-9' => [ 'id' => 9, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::CUSTOMER_NOTE, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/9/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/9/content.json' ], 'template-10' => [ 'id' => 10, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::NEW_ACCOUNT, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/10/content.json' ], 'template-11' => [ 'id' => 11, 'package' => 'free', 'mail_type' => 'woocomerce-email', 'title' => EmailLists::RESET_PASSWORD, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/11/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/11/content.json' ], 'template-12' => [ 'id' => 12, 'package' => 'pro', 'mail_type' => 'wordpress-email', 'title' => EmailLists::WP_NEW_REGISTER, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => '', ], 'template-13' => [ 'id' => 13, 'package' => 'pro', 'mail_type' => 'wordpress-email', 'title' => EmailLists::WP_RESET_PASSWORD, 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg', 'demo-url' => 'https://wpmet.com/', 'file' => '' ], ]; return apply_filters( 'emailkit/editor/templates', $template_list ); } /** * Get template list by form type * * @param string $mail_type * @return array */ public function get_templates_by_mail_type( $mail_type ) { $templates_list = []; // array filter $templates_list = array_filter( $this->get_templates(), function( $template ) use ( $mail_type ) { if(isset($template['mail_type'])){ return $template['mail_type'] === $mail_type; } return true; } ); return $templates_list; } public function get_template_contents($id){ if(!array_key_exists($id, $this->get_templates()) || !file_exists($this->get_templates()[$id]['file'])){ return null; } $template_file_url = self::abs_path_to_url($this->get_templates()[$id]['file']); $content = wp_remote_get($template_file_url, ['sslverify' => false]); $content = json_decode(wp_remote_retrieve_body($content)); return (!isset($content->content)) ? null : $content->content; } public static function abs_path_to_url( $path = '' ) { $url = str_replace( wp_normalize_path( untrailingslashit( ABSPATH ) ), site_url(), wp_normalize_path( $path ) ); return esc_url_raw( $url ); } }