| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: YeeMail — Email Template Builder & Customizer |
| 4 |
* Description: Customizing the design and content of your email |
| 5 |
* Version: 2.2 |
| 6 |
* Author: add-ons.org |
| 7 |
* Plugin URI: https://wordpress.org/plugins/yeemail/ |
| 8 |
* Author URI: https://add-ons.org/ |
| 9 |
* License: GPL v2 or later |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
define( 'YEEMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 15 |
define( 'YEEMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 16 |
define( 'YEEMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 17 |
if (function_exists('is_plugin_active')) { |
| 18 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
| 19 |
} |
| 20 |
class Yeemail_Template_Customizer_Init{ |
| 21 |
function __construct(){ |
| 22 |
register_activation_hook( __FILE__, array($this,'activation') ); |
| 23 |
$dir = new RecursiveDirectoryIterator(YEEMAIL_PLUGIN_PATH."backend"); |
| 24 |
$ite = new RecursiveIteratorIterator($dir); |
| 25 |
$files = new RegexIterator($ite, "/\.php/", RegexIterator::MATCH); |
| 26 |
foreach ($files as $file) { |
| 27 |
if (!$file->isDir()){ |
| 28 |
require_once $file->getPathname(); |
| 29 |
} |
| 30 |
} |
| 31 |
$dir = new RecursiveDirectoryIterator(YEEMAIL_PLUGIN_PATH."includes"); |
| 32 |
$ite = new RecursiveIteratorIterator($dir); |
| 33 |
$files = new RegexIterator($ite, "/\.php/", RegexIterator::MATCH); |
| 34 |
if (!function_exists('str_get_html')) { |
| 35 |
include YEEMAIL_PLUGIN_PATH."libs/simple_html_dom.php"; |
| 36 |
} |
| 37 |
foreach ($files as $file) { |
| 38 |
if (!$file->isDir()){ |
| 39 |
require_once $file->getPathname(); |
| 40 |
} |
| 41 |
} |
| 42 |
include_once YEEMAIL_PLUGIN_PATH."frontend/index.php"; |
| 43 |
include_once YEEMAIL_PLUGIN_PATH."frontend/functions.php"; |
| 44 |
do_action( "yeemail/loaded"); |
| 45 |
} |
| 46 |
function activation() { |
| 47 |
global $wpdb; |
| 48 |
$check = get_option( "yeemail_setup",array() ); |
| 49 |
if( count($check) < 1){ |
| 50 |
$string = file_get_contents(YEEMAIL_PLUGIN_PATH."backend/demo/default.json"); |
| 51 |
$id_map_email_id = array(); |
| 52 |
$datas_templates = explode("\n", $string); |
| 53 |
foreach( $datas_templates as $datas_template ){ |
| 54 |
$settings_datas = explode("|||yeemail_data|||",$datas_template); |
| 55 |
if(count($settings_datas) > 1){ |
| 56 |
$template_content = $settings_datas[1]; |
| 57 |
$settings_data = explode(",",$settings_datas[0]); |
| 58 |
foreach ($settings_data as $setting){ |
| 59 |
$main_settings = explode(":",$setting); |
| 60 |
switch($main_settings[0]){ |
| 61 |
case "type": |
| 62 |
$type = $main_settings[1]; |
| 63 |
break; |
| 64 |
case "title": |
| 65 |
$title = $main_settings[1]; |
| 66 |
break; |
| 67 |
case "email": |
| 68 |
$email = $main_settings[1]; |
| 69 |
break; |
| 70 |
case "status": |
| 71 |
$status = $main_settings[1]; |
| 72 |
break; |
| 73 |
} |
| 74 |
} |
| 75 |
$my_template = array( |
| 76 |
'post_title' => $title, |
| 77 |
'post_content' => "", |
| 78 |
'post_status' => 'publish', |
| 79 |
'post_type' => 'yeemail_template' |
| 80 |
); |
| 81 |
$id_template = wp_insert_post( $my_template ); |
| 82 |
$id_map_email_id[$email] = $id_template; |
| 83 |
add_post_meta($id_template,"data_email",$settings_datas[1]); |
| 84 |
add_post_meta($id_template,"_mail_type",$type); |
| 85 |
add_post_meta($id_template,"_mail_template",$email); |
| 86 |
add_post_meta($id_template,"_status",$status); |
| 87 |
if($email == "yeemail_pro"){ |
| 88 |
update_option( "yemail_pro_id", $id_template ); |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
update_option( "yeemail_setup",$id_map_email_id ); |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
new Yeemail_Template_Customizer_Init; |