PluginProbe ʕ •ᴥ•ʔ
Flex Import / 1.6
Flex Import v1.6
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 year ago includes 1 year ago templates 1 year ago flex-import.php 1 year ago readme.txt 1 year ago
flex-import.php
204 lines
1 <?php
2 /**
3 * Plugin Name: Flex Import
4 * Plugin URI:
5 * Description: A plugin to import demo content for Elementor templates.
6 * Version: 1.6
7 * Requires at least: 5.2
8 * Requires PHP: 7.2
9 * Author: flextheme
10 * Author URI:
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_DIR_FILE', plugin_dir_url(__FILE__));
26 define('FLEXIMP_VER', '1.6');
27
28 // Check Elementor on plugin activation
29 register_activation_hook(__FILE__, 'fleximp_check_elementor_on_activation');
30 function fleximp_check_elementor_on_activation() {
31 set_transient('fleximp_show_elementor_notice', true, 6000);
32 }
33
34
35 add_action('admin_notices', 'fleximp_elementor_admin_notice');
36 function fleximp_elementor_admin_notice() {
37 // if (!get_transient('fleximp_show_elementor_notice')) {
38 // return;
39 // }
40 delete_transient('fleximp_show_elementor_notice');
41
42 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
43 if (is_plugin_active('elementor/elementor.php')) {
44 return;
45 }
46
47 $elementor_installed = file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php');
48 $install_url = wp_nonce_url(
49 self_admin_url('update.php?action=install-plugin&plugin=elementor'),
50 'install-plugin_elementor'
51 );
52 $activate_url = wp_nonce_url(
53 self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
54 'activate-plugin_elementor/elementor.php'
55 );
56
57 ?>
58 <div class="notice notice-warning is-dismissible">
59 <h2> Elementor is required</h2>
60 <p>The <strong>Flex Import</strong> plugin requires <strong>Elementor</strong> to function properly.</p>
61 <?php if (!$elementor_installed) : ?>
62 <p><a href="<?php echo esc_url($install_url); ?>" class="button button-primary">Install Elementor</a></p>
63 <?php else : ?>
64 <p><a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">Activate Elementor</a></p>
65 <?php endif; ?>
66 </div>
67 <?php
68 }
69 //end
70
71 require_once plugin_dir_path(__FILE__) . 'includes/class-template-importer.php';
72
73 //dynamic css
74 function fleximp_enqueue_dynamic_imported_css()
75 {
76 // if (is_front_page()) {
77 $css_url = get_option('fleximp_dynamic_template_css');
78
79 if (!empty($css_url)) {
80 wp_enqueue_style(
81 'fleximp-dynamic-imported-css',
82 esc_url($css_url),
83 array(),
84 null
85 );
86 }
87 // }
88 }
89 add_action('wp_enqueue_scripts', 'fleximp_enqueue_dynamic_imported_css');
90
91
92 // Initialize the plugin
93 function fleximp_init()
94 {
95 $importer = new FLEXIMP_Template_Importer();
96 $importer->init();
97 }
98 add_action('plugins_loaded', 'fleximp_init');
99
100
101 function fleximp_register_nav_menus()
102 {
103 $is_premium_user = get_option('fleximp_is_premium', false);
104
105 if ($is_premium_user) {
106 register_nav_menus(array(
107 'primary-menu' => __('Primary Menu', 'flex-import'),
108 ));
109 }
110 }
111 add_action('after_setup_theme', 'fleximp_register_nav_menus');
112
113
114
115
116 add_action('init', 'create_custom_cf7_forms');
117
118 function create_custom_cf7_forms()
119 {
120 $is_premium_user = get_option('fleximp_is_premium', false);
121 if (!$is_premium_user) {
122 return;
123 }
124
125 $forms = array(
126 array(
127 'title' => 'Newsletter',
128 'content' => '<div class="flex-footer-form">
129 <div class="flex-business-theme-input"> [email* your-email class:email placeholder "Email"]</div>
130 <div class="flex-business-theme-input"> [submit class:flex-submit-btn1 "Submit Now"]</div>
131 </div>',
132 'hash' => 'b256161'
133 ),
134 array(
135 'title' => 'Contact Page Form',
136 'shortcode_title' => 'Contact form 1',
137 'content' => '<div class="row">
138 <div class="flex-business-input">
139 <div class="flex-business-theme-input">[text* text-111 class:name placeholder "Name"]</div>
140 <div class="flex-business-theme-input">[tel* tel-24 class:phone placeholder "Phone"]</div>
141 </div>
142 <div class="flex-business-input">
143 <div class="flex-business-theme-input">[email* email-398 class:email placeholder"Email"]</div>
144 <div class="flex-business-theme-input">[text text-159 class:service placeholder"services"]</div>
145 </div>
146 <div class="flex-business-msg">
147 <div class="flex-business-theme-input"> [text text-521 class:msg placeholder"Message"]</div>
148 </div>
149 <div class="flex-business-btn">
150 <div class="flex-business-theme-input"> [submit class:flex-submit-btn "Submit Now"]</div>
151 </div>
152 </div>',
153 'hash' => '80c5c1a'
154 ),
155 );
156
157 foreach ($forms as $form_data) {
158 $title = $form_data['title'];
159 $existing_form = get_page_by_title($title, OBJECT, 'wpcf7_contact_form');
160
161 if ($existing_form) {
162 continue;
163 }
164
165 $form_post = array(
166 'post_title' => wp_strip_all_tags($title),
167 'post_content' => $form_data['content'],
168 'post_status' => 'publish',
169 'post_type' => 'wpcf7_contact_form',
170 );
171
172 $form_id = wp_insert_post($form_post);
173
174 if (is_wp_error($form_id) || !$form_id) {
175 continue;
176 }
177
178 update_post_meta($form_id, '_form', $form_data['content']);
179
180 $mail_data = array(
181 'subject' => '[_site_title] "[your-subject]"',
182 'sender' => '[_site_title] <support@wpelemento.com>',
183 'body' => 'From: [your-name] <[your-email]>
184 Subject: [your-subject]
185
186 Message Body:
187 [your-message]
188
189 --
190 This e-mail was sent from a contact form on [_site_title] ([_site_url])',
191 'recipient' => '[_site_admin_email]',
192 'additional_headers' => 'Reply-To: [your-email]',
193 'attachments' => '',
194 'use_html' => 0,
195 'exclude_blank' => 0
196 );
197
198 update_post_meta($form_id, '_mail', $mail_data);
199 update_post_meta($form_id, '_hash', $form_data['hash']);
200
201 }
202 }
203
204