PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.3
Flex Import v2.3
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 11 months ago includes 11 months ago templates 11 months ago flex-import.php 11 months ago readme.txt 11 months ago
flex-import.php
205 lines
1 <?php
2 /**
3 * Plugin Name: Flex Import
4 * Plugin URI: https://www.flextheme.net/products/flex-pro-wordpress-theme
5 * Description: A plugin to import demo content for Elementor templates.
6 * Version: 2.3
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 error_reporting(E_ALL);
22 ini_set('display_errors', '1');
23
24 define('FLEXIMP_PLUGIN_FILE', plugin_dir_path(__FILE__));
25 define('FLEXIMP_MAIN_URL', 'https://license.flextheme.net/');
26 define('FLEXIMP_LICENSE_URL', 'https://app.flextheme.net/api/public/');
27 define('FLEXIMP_JSON_DATA_URL', 'https://license.flextheme.net/index.php/wp-json/flex-theme/v2/');
28 define('FLEXIMP_PLUGIN_URL', 'https://www.flextheme.net/');
29 define('FLEXIMP_DEMO_URL', 'https://demo.flextheme.net/');
30 define('FLEXIMP_PLUGIN_DIR_FILE', plugin_dir_url(__FILE__));
31 define('FLEXIMP_VER', '2.3');
32
33 add_filter( 'woocommerce_prevent_automatic_wizard_redirect', '__return_true' );
34
35 register_activation_hook(__FILE__, 'fleximp_check_elementor_on_activation');
36 function fleximp_check_elementor_on_activation() {
37 set_transient('fleximp_show_elementor_notice', true, 6000);
38 }
39
40 register_deactivation_hook(__FILE__, 'fleximp_blank_template_on_deactivation');
41 if (!is_multisite()) {
42 add_action('init', 'fleximp_blank_template_on_deactivation');
43 }
44 function fleximp_blank_template_on_deactivation() {
45 if (!function_exists('WP_Filesystem')) {
46 require_once ABSPATH . 'wp-admin/includes/file.php';
47 }
48 global $wp_filesystem;
49 WP_Filesystem();
50
51 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
52 if (empty($fleximp_current_text_domain)) return;
53
54 // Multisite-safe: Only blank the template if no site has the option set
55 $should_blank = true;
56 if (is_multisite()) {
57 $sites = get_sites(['fields' => 'ids']);
58 foreach ($sites as $site_id) {
59 switch_to_blog($site_id);
60 $site_text_domain = get_option('fleximp_current_text_domain', true);
61 if ($site_text_domain === $fleximp_current_text_domain) {
62 $should_blank = false;
63 restore_current_blog();
64 break;
65 }
66 restore_current_blog();
67 }
68 } else {
69 $remote_txt_url = get_option('fleximp_dynamic_template_php');
70 if (!empty($remote_txt_url)) {
71 $should_blank = false;
72 }
73 }
74 if (!$should_blank) 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 delete_transient('fleximp_show_elementor_notice');
89
90 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
91 if (is_plugin_active('elementor/elementor.php')) {
92 return;
93 }
94
95 $elementor_installed = file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php');
96 $install_url = wp_nonce_url(
97 self_admin_url('update.php?action=install-plugin&plugin=elementor'),
98 'install-plugin_elementor'
99 );
100 $activate_url = wp_nonce_url(
101 self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
102 'activate-plugin_elementor/elementor.php'
103 );
104
105 ?>
106 <div class="notice notice-warning is-dismissible">
107 <h2> Elementor is required</h2>
108 <p>The <strong>Flex Import</strong> plugin requires <strong>Elementor</strong> to function properly.</p>
109 <?php if (!$elementor_installed) : ?>
110 <p><a href="<?php echo esc_url($install_url); ?>" class="button button-primary">Install Elementor</a></p>
111 <?php else : ?>
112 <p><a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">Activate Elementor</a></p>
113 <?php endif; ?>
114 </div>
115 <?php
116 }
117 //end
118
119 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
120 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
121
122 if (!empty(get_option('fleximp_current_text_domain'))) {
123 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
124
125 $upload_dir = wp_upload_dir();
126 $file_name = $upload_dir['basedir'] . '/' . $fleximp_current_text_domain . '.php';
127
128 if (file_exists($file_name)) {
129 require_once $file_name;
130 }
131 }
132
133 function fleximp_enqueue_dynamic_imported_css(){
134 $css_url = get_option('fleximp_dynamic_template_css');
135
136 if (!empty($css_url)) {
137 wp_enqueue_style(
138 'fleximp-dynamic-imported-css',
139 esc_url($css_url),
140 array(),
141 null
142 );
143 }
144
145 $js_url = get_option('fleximp_dynamic_template_js');
146
147 if (!empty($js_url)) {
148
149 wp_register_script( '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" style="background-image: url(<?php echo esc_url( FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
190 <div class="fleximp-notice-banner-wrap" >
191 <div class="fleximp-left-img-wrap">
192 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-right.png'); ?>">
193 </div>
194 <div class="fleximp-notice-heading">
195 <h1 class="fleximp-main-head"><?php echo esc_html('🎉 Upgrade to Premium Version - Flex Pro WordPress Theme!');?></h1>
196 <p class="fleximp-sub-head"><?php echo esc_html('Go beyond the basics—upgrade to Flex Pro for more customization, more templates, and a smoother, more professional website experience.');?></p>
197 <div class="fleximp-notice-btn">
198 <a class="fleximp-buy-btn fleximp-btn" target="_blank" href="<?php echo esc_url( FLEXIMP_PLUGIN_URL . 'products/flex-pro-wordpress-theme' ); ?>"><?php echo esc_html('UPGRADE PRO');?></a>
199 <a class="fleximp-buy-btn fleximp-btn" target="_blank" href="<?php echo esc_url( FLEXIMP_DEMO_URL . 'flex-multi-business-pro/' ); ?>"><?php echo esc_html('Live Demo');?></a>
200 </div>
201 </div>
202 </div>
203 </div>
204 <?php
205 }