PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.5
Flex Import v2.5
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 10 months ago includes 10 months ago templates 10 months ago flex-import.php 10 months ago readme.txt 10 months ago
flex-import.php
218 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.5
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.5');
28
29 add_filter('woocommerce_prevent_automatic_wizard_redirect', '__return_true');
30
31 register_activation_hook(__FILE__, 'fleximp_check_elementor_on_activation');
32 function fleximp_check_elementor_on_activation()
33 {
34 set_transient('fleximp_show_elementor_notice', true, 6000);
35 }
36
37 register_deactivation_hook(__FILE__, 'fleximp_blank_template_on_deactivation');
38 if (!is_multisite()) {
39 add_action('init', 'fleximp_blank_template_on_deactivation');
40 }
41 function fleximp_blank_template_on_deactivation()
42 {
43 if (!function_exists('WP_Filesystem')) {
44 require_once ABSPATH . 'wp-admin/includes/file.php';
45 }
46 global $wp_filesystem;
47 WP_Filesystem();
48
49 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
50 if (empty($fleximp_current_text_domain))
51 return;
52
53 // Multisite-safe: Only blank the template if no site has the option set
54 $should_blank = true;
55 if (is_multisite()) {
56 $sites = get_sites(['fields' => 'ids']);
57 foreach ($sites as $site_id) {
58 switch_to_blog($site_id);
59 $site_text_domain = get_option('fleximp_current_text_domain', true);
60 if ($site_text_domain === $fleximp_current_text_domain) {
61 $should_blank = false;
62 restore_current_blog();
63 break;
64 }
65 restore_current_blog();
66 }
67 } else {
68 $remote_txt_url = get_option('fleximp_dynamic_template_php');
69 if (!empty($remote_txt_url)) {
70 $should_blank = false;
71 }
72 }
73 if (!$should_blank)
74 return;
75
76 $upload_dir = wp_upload_dir();
77
78 $temp_template = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
79 if (file_exists($temp_template)) {
80 if (!$wp_filesystem->put_contents($temp_template, '', FS_CHMOD_FILE)) {
81 return;
82 }
83 }
84 }
85
86 add_action('admin_notices', 'fleximp_elementor_admin_notice');
87 function fleximp_elementor_admin_notice()
88 {
89 delete_transient('fleximp_show_elementor_notice');
90
91 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
92 if (is_plugin_active('elementor/elementor.php')) {
93 return;
94 }
95
96 $elementor_installed = file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php');
97 $install_url = wp_nonce_url(
98 self_admin_url('update.php?action=install-plugin&plugin=elementor'),
99 'install-plugin_elementor'
100 );
101 $activate_url = wp_nonce_url(
102 self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
103 'activate-plugin_elementor/elementor.php'
104 );
105
106 ?>
107 <div class="notice notice-warning is-dismissible">
108 <h2> Elementor is required</h2>
109 <p>The <strong>Flex Import</strong> plugin requires <strong>Elementor</strong> to function properly.</p>
110 <?php if (!$elementor_installed): ?>
111 <p><a href="<?php echo esc_url($install_url); ?>" class="button button-primary">Install Elementor</a></p>
112 <?php else: ?>
113 <p><a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">Activate Elementor</a></p>
114 <?php endif; ?>
115 </div>
116 <?php
117 }
118 //end
119
120 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
121 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
122
123 if (!empty(get_option('fleximp_current_text_domain'))) {
124 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
125
126 $upload_dir = wp_upload_dir();
127 $file_name = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
128
129 if (file_exists($file_name)) {
130 require_once $file_name;
131 }
132 }
133
134 function fleximp_enqueue_dynamic_imported_css()
135 {
136 $css_url = get_option('fleximp_dynamic_template_css');
137
138 if (!empty($css_url)) {
139 wp_enqueue_style(
140 'fleximp-dynamic-imported-css',
141 esc_url($css_url),
142 array(),
143 null
144 );
145 }
146
147 $js_url = get_option('fleximp_dynamic_template_js');
148
149 if (!empty($js_url)) {
150
151 wp_register_script(
152 'fleximp-dynamic-imported-js',
153 esc_url($js_url),
154 array('jquery'),
155 FLEXIMP_VER,
156 true
157 );
158
159 wp_localize_script('fleximp-dynamic-imported-js', 'fleximp_config', [
160 'ajax_url' => admin_url('admin-ajax.php'),
161 'nonce' => wp_create_nonce('fleximp_nonce'),
162 ]);
163
164 wp_enqueue_script('fleximp-dynamic-imported-js');
165 }
166 }
167 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_css');
168
169
170 // Initialize the plugin
171 function fleximp_init()
172 {
173 $importer = new FLEXIMP_Template_Importer();
174 $importer->init();
175 }
176 add_action('plugins_loaded', 'fleximp_init');
177
178
179 function fleximp_register_nav_menus()
180 {
181 $is_premium_user = get_option('fleximp_is_premium', false);
182
183 if ($is_premium_user) {
184 register_nav_menus(array(
185 'primary-menu' => __('Primary Menu', 'flex-import'),
186 ));
187 }
188 }
189 add_action('after_setup_theme', 'fleximp_register_nav_menus');
190
191 add_action('admin_notices', 'fleximp_admin_notice_with_html');
192 function fleximp_admin_notice_with_html()
193 {
194 ?>
195 <div class="notice is-dismissible fleximp"
196 style="background-image: url(<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
197 <div class="fleximp-notice-banner-wrap">
198 <div class="fleximp-left-img-wrap">
199 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-right.png'); ?>">
200 </div>
201 <div class="fleximp-notice-heading">
202 <h1 class="fleximp-main-head">
203 <?php echo esc_html('🎉 Upgrade to Premium Version - Flex Pro WordPress Theme!'); ?>
204 </h1>
205 <p class="fleximp-sub-head">
206 <?php echo esc_html('Go beyond the basics—upgrade to Flex Pro for more customization, more templates, and a smoother, more professional website experience.'); ?>
207 </p>
208 <div class="fleximp-notice-btn">
209 <a class="fleximp-buy-btn fleximp-btn" target="_blank"
210 href="<?php echo esc_url(FLEXIMP_PLUGIN_URL . 'products/flex-pro-wordpress-theme'); ?>"><?php echo esc_html('UPGRADE PRO'); ?></a>
211 <a class="fleximp-buy-btn fleximp-btn" target="_blank"
212 href="<?php echo esc_url(FLEXIMP_DEMO_URL . 'flex-multi-business-pro/'); ?>"><?php echo esc_html('Live Demo'); ?></a>
213 </div>
214 </div>
215 </div>
216 </div>
217 <?php
218 }