PluginProbe ʕ •ᴥ•ʔ
Flex Import / trunk
Flex Import vtrunk
2.9 trunk 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
flex-import / flex-import.php
flex-import Last commit date
assets 3 weeks ago includes 3 months ago templates 3 months ago flex-import.php 3 weeks ago readme.txt 3 weeks ago
flex-import.php
182 lines
1 <?php
2 /**
3 * Plugin Name: Flex Import
4 * Plugin URI: https://www.flextheme.net/products/flex-pro-wordpress-theme
5 * Description: Flex Import is a powerful one-click demo importer plugin built to supercharge your website setup experience.
6 * Version: 2.9
7 * Requires at least: 5.2
8 * Requires PHP: 7.2
9 * Author: flextheme
10 * Author URI: https://www.flextheme.net/
11 * License: GPL v2 or later
12 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 * Text Domain: flex-import
14 */
15
16 if (!defined('ABSPATH')) {
17 exit; // Exit if accessed directly.
18 }
19
20 define('FLEXIMP_PLUGIN_FILE', plugin_dir_path(__FILE__));
21 define('FLEXIMP_MAIN_URL', 'https://license.flextheme.net/');
22 define('FLEXIMP_LICENSE_URL', 'https://app.flextheme.net/api/public/');
23 define('FLEXIMP_JSON_DATA_URL', 'https://license.flextheme.net/index.php/wp-json/flex-theme/v2/');
24 define('FLEXIMP_PLUGIN_URL', 'https://www.flextheme.net/');
25 define('FLEXIMP_DEMO_URL', 'https://demo.flextheme.net/');
26 define('FLEXIMP_PLUGIN_DIR_FILE', plugin_dir_url(__FILE__));
27 define('FLEXIMP_VER', '2.9');
28 define('FLEXIMP_LIVE_DEMO_URL', 'https://demo.flextheme.net/flex-multi-business-pro/');
29 define('FLEXIMP_DOC_URL', 'https://docs.flextheme.net/');
30 define('FLEXIMP_UPGRADE_PRO_URL', 'https://www.flextheme.net/products/wordpress-theme-bundle');
31 define('FLEXIMP_THEMES_URL', 'https://www.flextheme.net/collections/premium-wordpress-themes');
32
33 add_filter('woocommerce_prevent_automatic_wizard_redirect', '__return_true');
34
35 register_deactivation_hook(__FILE__, 'fleximp_blank_template_on_deactivation');
36 if (!is_multisite()) {
37 add_action('init', 'fleximp_blank_template_on_deactivation');
38 }
39 function fleximp_blank_template_on_deactivation() {
40 if (!function_exists('WP_Filesystem')) {
41 require_once ABSPATH . 'wp-admin/includes/file.php';
42 }
43 global $wp_filesystem;
44 WP_Filesystem();
45
46 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
47 if (empty($fleximp_current_text_domain))
48 return;
49
50 // Multisite-safe: Only blank the template if no site has the option set
51 $should_blank = true;
52 if (is_multisite()) {
53 $sites = get_sites(['fields' => 'ids']);
54 foreach ($sites as $site_id) {
55 switch_to_blog($site_id);
56 $site_text_domain = get_option('fleximp_current_text_domain', true);
57 if ($site_text_domain === $fleximp_current_text_domain) {
58 $should_blank = false;
59 restore_current_blog();
60 break;
61 }
62 restore_current_blog();
63 }
64 } else {
65 $remote_txt_url = get_option('fleximp_dynamic_template_php');
66 if (!empty($remote_txt_url)) {
67 $should_blank = false;
68 }
69 }
70 if (!$should_blank)
71 return;
72
73 $upload_dir = wp_upload_dir();
74
75 $temp_template = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
76 if (file_exists($temp_template)) {
77 if (!$wp_filesystem->put_contents($temp_template, '', FS_CHMOD_FILE)) {
78 return;
79 }
80 }
81 }
82
83 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
84 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
85
86 if (!empty(get_option('fleximp_current_text_domain'))) {
87 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
88
89 $upload_dir = wp_upload_dir();
90 $file_name = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
91
92 if (file_exists($file_name)) {
93 require_once $file_name;
94 }
95 }
96
97 function fleximp_enqueue_dynamic_imported_assets() {
98 $css_url = get_option('fleximp_dynamic_template_css');
99
100 if (!empty($css_url)) {
101 wp_enqueue_style(
102 'fleximp-dynamic-imported-css',
103 esc_url($css_url),
104 array(),
105 null
106 );
107 }
108
109 $js_url = get_option('fleximp_dynamic_template_js');
110
111 if (!empty($js_url)) {
112
113 wp_register_script(
114 'fleximp-dynamic-imported-js',
115 esc_url($js_url),
116 array('jquery'),
117 FLEXIMP_VER,
118 true
119 );
120
121 wp_localize_script('fleximp-dynamic-imported-js', 'fleximp_config', [
122 'ajax_url' => admin_url('admin-ajax.php'),
123 'nonce' => wp_create_nonce('fleximp_nonce'),
124 ]);
125
126 wp_enqueue_script('fleximp-dynamic-imported-js');
127 }
128 }
129 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_assets');
130
131 function fleximp_init() {
132 $importer = new FLEXIMP_Template_Importer();
133 $importer->init();
134 }
135 add_action('plugins_loaded', 'fleximp_init');
136
137
138 function fleximp_register_nav_menus() {
139 $is_premium_user = get_option('fleximp_is_premium', false);
140
141 if ($is_premium_user) {
142 register_nav_menus(array(
143 'primary-menu' => __('Primary Menu', 'flex-import'),
144 ));
145 }
146 }
147 add_action('after_setup_theme', 'fleximp_register_nav_menus');
148
149 add_action('admin_notices', 'fleximp_admin_notice_with_html');
150 function fleximp_admin_notice_with_html() {
151 ?>
152 <div class="notice is-dismissible fleximp">
153 <div class="notice-info" style="background-image: url(<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
154 <div class="notice-icon">
155 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/icon.png'); ?>" alt="<?php esc_attr_e('Notice Logo', 'flex-import'); ?>" style="width:100%; height:100%">
156 </div>
157 <div class="fleximp-notice-banner-wrap">
158 <div class="fleximp-notice-heading">
159 <h1 class="fleximp-main-head">
160 <?php echo esc_html('WORDPRESS THEME BUNDLE'); ?>
161 </h1>
162 <p class="fleximp-sub-head">
163 <?php echo esc_html('GET ACCESS TO ALL OUR PREMIUM ELEMENTOR WORDPRESS THEMES FOR JUST $69'); ?>
164 </p>
165 <div class="notice-buttons">
166 <div class="fleximp-notice-coupon-btn" data-coupon="FLEXPRO" onclick="navigator.clipboard.writeText('FLEXPRO'); alert('Coupon Copied!');">
167 <?php echo esc_html('Use Coupon Code "FLEXPRO" to Get 20% OFF'); ?>
168 <span class="custom-coupon-banner-code">FLEXPRO</span>
169 </div>
170 <div class="fleximp-notice-btn">
171 <a class="fleximp-buy-btn fleximp-btn" target="_blank" href="<?php echo esc_url(FLEXIMP_UPGRADE_PRO_URL); ?>"><?php echo esc_html('BUY NOW'); ?></a>
172 </div>
173 </div>
174 </div>
175 <div class="fleximp-left-img-wrap">
176 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/bundle-banner.png'); ?>" alt="<?php esc_attr_e('Plugin Logo', 'flex-import'); ?>" style="width:100%; height:100%">
177 </div>
178 </div>
179 </div>
180 </div>
181 <?php
182 }