VIWEC_NAME, 'php_version' => $this->php_version_require, 'wp_version' => $this->wp_version_require, 'require_plugins' => [ [ 'slug' => 'woocommerce', 'name' => 'WooCommerce', 'defined_version' => 'WC_VERSION', 'version' => $this->wc_version_require, ], ] ] ); if ( $environment->has_error() ) { return; } if ( is_file( VIWEC_INCLUDES . 'init.php' ) ) { require_once VIWEC_INCLUDES . 'init.php'; } add_action( 'init', [ $this, 'viwec_init' ] ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_actions_link' ) ); } ); } public function viwec_init() { $check_exist = get_posts( [ 'post_type' => 'viwec_template', 'numberposts' => 1 ] ); $check_default = get_option( 'viwec_email_default_setting', false ); if ( empty( $check_exist ) && ! $check_default ) { $default_subject = \VIWEC\INC\Email_Samples::default_subject(); $templates = \VIWEC\INC\Email_Samples::sample_templates(); $site_title = get_option( 'blogname' ); foreach ( $templates as $key => $template ) { $args = [ 'post_title' => $default_subject[ $key ] ? str_replace( '{site_title}', $site_title, $default_subject[ $key ] ) : '', 'post_status' => 'publish', 'post_type' => 'viwec_template', ]; $post_id = wp_insert_post( $args ); $template = $template['basic']['data']; $template = str_replace( '\\', '\\\\', $template ); update_post_meta( $post_id, 'viwec_settings_type', $key ); update_post_meta( $post_id, 'viwec_email_structure', $template ); } update_option( 'viwec_email_update_button', true, 'no' ); update_option( 'viwec_email_default_setting', true, 'no' ); } } public function plugin_actions_link( $links ) { if ( ! $this->err_message ) { $settings_link = '' . __( 'Settings', 'viwec-email-template-customizer' ) . ''; array_unshift( $links, $settings_link ); } return $links; } } new Woo_Email_Template_Customizer(); }