PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.1
Flex Import v2.1
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
164 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.1
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.1');
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 add_action('init', 'fleximp_blank_template_on_deactivation');
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
45 global $wp_filesystem;
46 WP_Filesystem();
47
48 $temp_template = trailingslashit(FLEXIMP_PLUGIN_FILE) . 'templates-content/fleximp-temp-template.php';
49
50 $remote_txt_url = get_option('fleximp_dynamic_template_php');
51 if (!empty($remote_txt_url)) return;
52
53 if (file_exists($temp_template)) {
54 if (!$wp_filesystem->put_contents($temp_template, '', FS_CHMOD_FILE)) {
55 return;
56 }
57 }
58 }
59
60 add_action('admin_notices', 'fleximp_elementor_admin_notice');
61 function fleximp_elementor_admin_notice() {
62 // if (!get_transient('fleximp_show_elementor_notice')) {
63 // return;
64 // }
65 delete_transient('fleximp_show_elementor_notice');
66
67 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
68 if (is_plugin_active('elementor/elementor.php')) {
69 return;
70 }
71
72 $elementor_installed = file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php');
73 $install_url = wp_nonce_url(
74 self_admin_url('update.php?action=install-plugin&plugin=elementor'),
75 'install-plugin_elementor'
76 );
77 $activate_url = wp_nonce_url(
78 self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
79 'activate-plugin_elementor/elementor.php'
80 );
81
82 ?>
83 <div class="notice notice-warning is-dismissible">
84 <h2> Elementor is required</h2>
85 <p>The <strong>Flex Import</strong> plugin requires <strong>Elementor</strong> to function properly.</p>
86 <?php if (!$elementor_installed) : ?>
87 <p><a href="<?php echo esc_url($install_url); ?>" class="button button-primary">Install Elementor</a></p>
88 <?php else : ?>
89 <p><a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">Activate Elementor</a></p>
90 <?php endif; ?>
91 </div>
92 <?php
93 }
94 //end
95
96 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
97 require_once plugin_dir_path(__FILE__) . 'templates/additional-template.php';
98 require_once plugin_dir_path(__FILE__) . 'templates-content/fleximp-temp-template.php';
99
100 function fleximp_enqueue_dynamic_imported_css(){
101 $css_url = get_option('fleximp_dynamic_template_css');
102
103 if (!empty($css_url)) {
104 wp_enqueue_style(
105 'fleximp-dynamic-imported-css',
106 esc_url($css_url),
107 array(),
108 null
109 );
110 }
111
112 $js_url = get_option('fleximp_dynamic_template_js');
113
114 if (!empty($js_url)) {
115 wp_enqueue_script( 'fleximp-dynamic-imported-js',
116 esc_url($js_url),
117 array('jquery'),
118 FLEXIMP_VER,
119 true
120 );
121 }
122 }
123 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_css');
124
125
126 // Initialize the plugin
127 function fleximp_init() {
128 $importer = new FLEXIMP_Template_Importer();
129 $importer->init();
130 }
131 add_action('plugins_loaded', 'fleximp_init');
132
133
134 function fleximp_register_nav_menus() {
135 $is_premium_user = get_option('fleximp_is_premium', false);
136
137 if ($is_premium_user) {
138 register_nav_menus(array(
139 'primary-menu' => __('Primary Menu', 'flex-import'),
140 ));
141 }
142 }
143 add_action('after_setup_theme', 'fleximp_register_nav_menus');
144
145 add_action('admin_notices', 'fleximp_admin_notice_with_html');
146 function fleximp_admin_notice_with_html() {
147 ?>
148 <div class="notice is-dismissible fleximp" style="background-image: url(<?php echo esc_url( FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-bg.png'); ?>)">
149 <div class="fleximp-notice-banner-wrap" >
150 <div class="fleximp-left-img-wrap">
151 <img src="<?php echo esc_url(FLEXIMP_PLUGIN_DIR_FILE . 'assets/images/banner-right.png'); ?>">
152 </div>
153 <div class="fleximp-notice-heading">
154 <h1 class="fleximp-main-head"><?php echo esc_html('🎉 Upgrade to Premium Version - Flex Pro WordPress Theme!');?></h1>
155 <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>
156 <div class="fleximp-notice-btn">
157 <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>
158 <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>
159 </div>
160 </div>
161 </div>
162 </div>
163 <?php
164 }