PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.2
Flex Import v2.2
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 templates-content 11 months ago flex-import.php 11 months ago readme.txt 11 months ago
flex-import.php
200 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.2
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.2');
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)) 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) return;
72
73 $temp_template = trailingslashit(FLEXIMP_PLUGIN_FILE) . 'templates-content/'. $fleximp_current_text_domain .'.php';
74 if (file_exists($temp_template)) {
75 if (!$wp_filesystem->put_contents($temp_template, '', FS_CHMOD_FILE)) {
76 return;
77 }
78 }
79 }
80
81 add_action('admin_notices', 'fleximp_elementor_admin_notice');
82 function fleximp_elementor_admin_notice() {
83 delete_transient('fleximp_show_elementor_notice');
84
85 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
86 if (is_plugin_active('elementor/elementor.php')) {
87 return;
88 }
89
90 $elementor_installed = file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php');
91 $install_url = wp_nonce_url(
92 self_admin_url('update.php?action=install-plugin&plugin=elementor'),
93 'install-plugin_elementor'
94 );
95 $activate_url = wp_nonce_url(
96 self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
97 'activate-plugin_elementor/elementor.php'
98 );
99
100 ?>
101 <div class="notice notice-warning is-dismissible">
102 <h2> Elementor is required</h2>
103 <p>The <strong>Flex Import</strong> plugin requires <strong>Elementor</strong> to function properly.</p>
104 <?php if (!$elementor_installed) : ?>
105 <p><a href="<?php echo esc_url($install_url); ?>" class="button button-primary">Install Elementor</a></p>
106 <?php else : ?>
107 <p><a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">Activate Elementor</a></p>
108 <?php endif; ?>
109 </div>
110 <?php
111 }
112 //end
113
114 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
115 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
116
117 if (!empty(get_option('fleximp_current_text_domain'))) {
118 $fleximp_current_text_domain = get_option('fleximp_current_text_domain', true);
119 $file_name = plugin_dir_path(__FILE__) . 'templates-content/'. $fleximp_current_text_domain .'.php';
120
121 if (file_exists($file_name)) {
122 require_once $file_name;
123 }
124
125 }
126 // require_once plugin_dir_path(__FILE__) . 'templates-content/fleximp-temp-template.php';
127
128 function fleximp_enqueue_dynamic_imported_css(){
129 $css_url = get_option('fleximp_dynamic_template_css');
130
131 if (!empty($css_url)) {
132 wp_enqueue_style(
133 'fleximp-dynamic-imported-css',
134 esc_url($css_url),
135 array(),
136 null
137 );
138 }
139
140 $js_url = get_option('fleximp_dynamic_template_js');
141
142 if (!empty($js_url)) {
143
144 wp_register_script( 'fleximp-dynamic-imported-js',
145 esc_url($js_url),
146 array('jquery'),
147 FLEXIMP_VER,
148 true
149 );
150
151 wp_localize_script('fleximp-dynamic-imported-js', 'fleximp_config', [
152 'ajax_url' => admin_url('admin-ajax.php'),
153 'nonce' => wp_create_nonce('fleximp_nonce'),
154 ]);
155
156 wp_enqueue_script( 'fleximp-dynamic-imported-js');
157 }
158 }
159 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_css');
160
161
162 // Initialize the plugin
163 function fleximp_init() {
164 $importer = new FLEXIMP_Template_Importer();
165 $importer->init();
166 }
167 add_action('plugins_loaded', 'fleximp_init');
168
169
170 function fleximp_register_nav_menus() {
171 $is_premium_user = get_option('fleximp_is_premium', false);
172
173 if ($is_premium_user) {
174 register_nav_menus(array(
175 'primary-menu' => __('Primary Menu', 'flex-import'),
176 ));
177 }
178 }
179 add_action('after_setup_theme', 'fleximp_register_nav_menus');
180
181 add_action('admin_notices', 'fleximp_admin_notice_with_html');
182 function fleximp_admin_notice_with_html() {
183 ?>
184 <div class="notice is-dismissible fleximp" style="background-image: url(<?php echo esc_url( FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
185 <div class="fleximp-notice-banner-wrap" >
186 <div class="fleximp-left-img-wrap">
187 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-right.png'); ?>">
188 </div>
189 <div class="fleximp-notice-heading">
190 <h1 class="fleximp-main-head"><?php echo esc_html('🎉 Upgrade to Premium Version - Flex Pro WordPress Theme!');?></h1>
191 <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>
192 <div class="fleximp-notice-btn">
193 <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>
194 <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>
195 </div>
196 </div>
197 </div>
198 </div>
199 <?php
200 }