PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.8
Flex Import v2.8
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 1 month ago includes 1 month ago templates 1 month ago flex-import.php 1 month ago readme.txt 1 month ago
flex-import.php
179 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.8
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.8');
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 {
41 if (!function_exists('WP_Filesystem')) {
42 require_once ABSPATH . 'wp-admin/includes/file.php';
43 }
44 global $wp_filesystem;
45 WP_Filesystem();
46
47 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
48 if (empty($fleximp_current_text_domain))
49 return;
50
51 // Multisite-safe: Only blank the template if no site has the option set
52 $should_blank = true;
53 if (is_multisite()) {
54 $sites = get_sites(['fields' => 'ids']);
55 foreach ($sites as $site_id) {
56 switch_to_blog($site_id);
57 $site_text_domain = get_option('fleximp_current_text_domain', true);
58 if ($site_text_domain === $fleximp_current_text_domain) {
59 $should_blank = false;
60 restore_current_blog();
61 break;
62 }
63 restore_current_blog();
64 }
65 } else {
66 $remote_txt_url = get_option('fleximp_dynamic_template_php');
67 if (!empty($remote_txt_url)) {
68 $should_blank = false;
69 }
70 }
71 if (!$should_blank)
72 return;
73
74 $upload_dir = wp_upload_dir();
75
76 $temp_template = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
77 if (file_exists($temp_template)) {
78 if (!$wp_filesystem->put_contents($temp_template, '', FS_CHMOD_FILE)) {
79 return;
80 }
81 }
82 }
83
84 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
85 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
86
87 if (!empty(get_option('fleximp_current_text_domain'))) {
88 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
89
90 $upload_dir = wp_upload_dir();
91 $file_name = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
92
93 if (file_exists($file_name)) {
94 require_once $file_name;
95 }
96 }
97
98 function fleximp_enqueue_dynamic_imported_assets()
99 {
100 $css_url = get_option('fleximp_dynamic_template_css');
101
102 if (!empty($css_url)) {
103 wp_enqueue_style(
104 'fleximp-dynamic-imported-css',
105 esc_url($css_url),
106 array(),
107 null
108 );
109 }
110
111 $js_url = get_option('fleximp_dynamic_template_js');
112
113 if (!empty($js_url)) {
114
115 wp_register_script(
116 'fleximp-dynamic-imported-js',
117 esc_url($js_url),
118 array('jquery'),
119 FLEXIMP_VER,
120 true
121 );
122
123 wp_localize_script('fleximp-dynamic-imported-js', 'fleximp_config', [
124 'ajax_url' => admin_url('admin-ajax.php'),
125 'nonce' => wp_create_nonce('fleximp_nonce'),
126 ]);
127
128 wp_enqueue_script('fleximp-dynamic-imported-js');
129 }
130 }
131 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_assets');
132
133 function fleximp_init()
134 {
135 $importer = new FLEXIMP_Template_Importer();
136 $importer->init();
137 }
138 add_action('plugins_loaded', 'fleximp_init');
139
140
141 function fleximp_register_nav_menus()
142 {
143 $is_premium_user = get_option('fleximp_is_premium', false);
144
145 if ($is_premium_user) {
146 register_nav_menus(array(
147 'primary-menu' => __('Primary Menu', 'flex-import'),
148 ));
149 }
150 }
151 add_action('after_setup_theme', 'fleximp_register_nav_menus');
152
153 add_action('admin_notices', 'fleximp_admin_notice_with_html');
154 function fleximp_admin_notice_with_html()
155 {
156 ?>
157 <div class="notice is-dismissible fleximp"
158 style="background-image: url(<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
159 <div class="fleximp-notice-banner-wrap">
160 <div class="fleximp-left-img-wrap">
161 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-right.png'); ?>">
162 </div>
163 <div class="fleximp-notice-heading">
164 <h1 class="fleximp-main-head">
165 <?php echo esc_html('🔥 Upgrade to Flex Theme Bundle'); ?>
166 </h1>
167 <p class="fleximp-sub-head">
168 <?php echo esc_html('Everything you need to create fast, modern, and professional WordPress sites in one bundle.'); ?>
169 </p>
170 <div class="fleximp-notice-btn">
171 <a class="fleximp-buy-btn fleximp-btn" target="_blank"
172 href="<?php echo esc_url(FLEXIMP_PLUGIN_URL . 'collections/premium-wordpress-themes'); ?>"><?php echo esc_html('View All Themes'); ?></a>
173 <a class="fleximp-buy-btn fleximp-btn" target="_blank" href="<?php echo esc_url(FLEXIMP_UPGRADE_PRO_URL); ?>"><?php echo esc_html('Get Bundle'); ?></a>
174 </div>
175 </div>
176 </div>
177 </div>
178 <?php
179 }