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