PluginProbe
Ovation Elements / 1.2.0
Ovation Elements v1.2.0
1.2.7 1.2.6 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 27 releases
ovation-elements / ovation-elements.php

ovation-elements.php in Ovation Elements 1.2.0, at ovation-elements.php

301 lines 14.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Ovation Elements
4 * Plugin URI: https://www.ovationthemes.com/products/ovation-elements-pro
5 * Description: Transform your site with captivating sliders. Perfect for beginners and advanced users. Create and customize with our ultimate slider plugin.
6 * Version: 1.2.0
7 * Requires at least: 5.2
8 * Requires PHP: 7.2
9 * Author: pewilliams
10 * Author URI: https://www.ovationthemes.com/
11 * License: GPL v2 or later
12 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 * Text Domain: ovation-elements
14 */
15
16 if (!defined('ABSPATH')) {
17 exit; // Exit if accessed directly.
18 }
19
20 define('OVA_ELEMS_FILE', __FILE__);
21 define('OVA_ELEMS_BASE', plugin_basename(OVA_ELEMS_FILE));
22 define('OVA_ELEMS_DIR', plugin_dir_path(OVA_ELEMS_FILE));
23 define('OVA_ELEMS_URL', plugins_url('/', OVA_ELEMS_FILE));
24 define('OVA_ELEMS_LICENSE_ENDPOINT', 'https://license.ovationthemes.com/api/public/');
25 define('OVA_ELEMS_VER', '1.2.0');
26
27 // Include necessary files
28 include(plugin_dir_path(__FILE__) . 'includes/admin-settings.php');
29 include(plugin_dir_path(__FILE__) . 'includes/slider-shortcode.php');
30 include(plugin_dir_path(__FILE__) . 'ajax/ajax.php');
31
32 //enqueue script start
33 function ova_elems_admin_scripts($hook) {
34 $is_premium_user = get_option('ovation_slider_is_premium', false);
35
36 // Define all admin pages
37 $admin_pages = [
38 'toplevel_page_ovation_elements',
39 'ovation-elements_page_select-template',
40 'admin_page_edit-slider-template-template1',
41 'admin_page_edit-slider-template-template2',
42 'admin_page_edit-slider-template-template3',
43 'admin_page_edit-slider-template-template4',
44 'admin_page_edit-slider-template-template5',
45 'admin_page_edit-slider-template-template6',
46 'admin_page_edit-slider-template-template7',
47 'admin_page_edit-slider-template-template8',
48 'admin_page_edit-slider-template-template9',
49 'ot-elements_page_select-template',
50 'edit.php?post_type=ova_elems'
51 ];
52
53 if (in_array($hook, $admin_pages) || ($hook === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] === 'ova_elems')) {
54 // Enqueue common styles and scripts for admin pages
55 wp_enqueue_style('ova-elems-mod-bootstrap-css', plugin_dir_url(__FILE__) . 'assets/css/bootstrap.min.css', [], OVA_ELEMS_VER);
56 wp_enqueue_script('ova-elems-mod-bootstrap-js', plugin_dir_url(__FILE__) . 'assets/js/bootstrap.bundle.min.js', ['jquery'], OVA_ELEMS_VER, true);
57 wp_enqueue_style('ova-elems-admin-css-slider', plugin_dir_url(__FILE__) . 'assets/css/preview-slider.css', [], OVA_ELEMS_VER);
58 wp_enqueue_media();
59 }
60 wp_enqueue_style('ova-elems-admin-css', plugin_dir_url(__FILE__) . 'assets/css/slider-admin.css', [], OVA_ELEMS_VER);
61
62 // Define template-specific scripts
63 $templates = [
64 'admin_page_edit-slider-template-template1' => 'template-1-scripts',
65 'admin_page_edit-slider-template-template2' => 'template-2-scripts',
66 'admin_page_edit-slider-template-template3' => 'template-3-scripts',
67 'admin_page_edit-slider-template-template4' => 'template-4-scripts',
68 'admin_page_edit-slider-template-template5' => 'template-5-scripts',
69 'admin_page_edit-slider-template-template6' => 'template-6-scripts',
70 'admin_page_edit-slider-template-template7' => 'template-7-scripts',
71 'admin_page_edit-slider-template-template8' => 'template-8-scripts',
72 'admin_page_edit-slider-template-template9' => 'template-9-scripts',
73 ];
74
75 if (array_key_exists($hook, $templates)) {
76 $script_handle = 'ova-elems-' . $templates[$hook];
77 $script_path = plugin_dir_url(__FILE__) . 'assets/js/admin/' . $templates[$hook] . '.js';
78
79 wp_enqueue_script($script_handle, $script_path, ['jquery'], OVA_ELEMS_VER, true);
80
81 wp_localize_script($script_handle, 'sliderData', [
82 'isPremiumUser' => $is_premium_user,
83 'maxSlides' => 2,
84 ]);
85
86 // Localize script
87 if ($hook == 'admin_page_edit-slider-template-template1') {
88 wp_localize_script($script_handle, 'wpVars', [
89 'ajaxUrl' => admin_url('admin-ajax.php'),
90 'nonce' => wp_create_nonce('upload_cropped_image_nonce'),
91 ]);
92 }
93
94 if ($hook == 'admin_page_edit-slider-template-template2') {
95 wp_localize_script($script_handle, 'OvimageData', [
96 'plugin_url' => plugin_dir_url(__FILE__),
97 'nonce' => wp_create_nonce('ova_elems_ajax_nonce'),
98 ]);
99 }
100
101 if ($hook == 'admin_page_edit-slider-template-template4' || $hook == 'admin_page_edit-slider-template-template7') {
102 wp_localize_script($script_handle, 'ova_elems_template_script', [
103 'ajaxurl' => admin_url('admin-ajax.php'),
104 'nonce' => wp_create_nonce('ova_elems_ajax_nonce'),
105 ]);
106 }
107
108 if ($hook == 'admin_page_edit-slider-template-template6') {
109 wp_enqueue_script('ova-elems-bootstrap-js', plugin_dir_url(__FILE__) . 'assets/js/bootstrap.bundle.min.js', ['jquery'], OVA_ELEMS_VER, true);
110 }
111 }
112 }
113
114 add_action('admin_enqueue_scripts', 'ova_elems_admin_scripts');
115
116
117 //enqueue scripts end
118 function ova_elems_admin_enqueue_scripts($hook_suffix) {
119 if ($hook_suffix !== 'toplevel_page_ova-elems') {
120 return;
121 }
122
123 wp_enqueue_script('jquery');
124 }
125 add_action('admin_enqueue_scripts', 'ova_elems_admin_enqueue_scripts');
126
127
128 //for enque
129 function ova_elems_enqueue_scripts($hook) {
130
131 // Enqueue Font Awesome
132 wp_enqueue_style('ova-elems-font-awesome', plugin_dir_url(__FILE__) . 'assets/css/font.all.min.css', array(), OVA_ELEMS_VER);
133 wp_enqueue_style('ova-elems-modal-css', OVA_ELEMS_URL . 'assets/css/modal.css', array(), OVA_ELEMS_VER);
134
135 wp_enqueue_script(
136 'ova-elems-redirect-js',
137 OVA_ELEMS_URL . 'assets/js/redirect.js',
138 array('jquery'),
139 OVA_ELEMS_VER,
140 true
141 );
142
143 // Enqueue Bootstrap CSS
144 wp_enqueue_script('jquery');
145 if (isset($_GET['page']) && $_GET['page'] == 'ovation_elements') {
146
147 wp_enqueue_style('ova-elems-bootstrap-css', plugin_dir_url(__FILE__) . 'assets/css/bootstrap.min.css', [], OVA_ELEMS_VER);
148 // Enqueue Bootstrap JS and its dependency Popper.js
149 wp_enqueue_script('ova-elems-popper-js', plugin_dir_url(__FILE__) . 'assets/js/popper.min.js', ['jquery'], OVA_ELEMS_VER, true);
150 wp_enqueue_script('ova-elems-dash-bootstrap-js', plugin_dir_url(__FILE__) . 'assets/js/bootstrap.min.js', array('jquery', 'ova-elems-popper-js'), OVA_ELEMS_VER, true);
151 wp_enqueue_script('ova-elems-admin-operations', plugin_dir_url(__FILE__) . 'assets/js/admin/ova-elems-admin.js', ['jquery'], OVA_ELEMS_VER, true);
152 }
153 }
154 add_action('admin_enqueue_scripts', 'ova_elems_enqueue_scripts');
155
156 // Register activation hook
157 register_activation_hook(__FILE__, 'ova_elems_activate');
158
159 function ova_elems_activate() {
160 // Activation code here
161 ova_elems_post_type();
162 flush_rewrite_rules();
163 }
164
165 // Register deactivation hook
166 register_deactivation_hook(__FILE__, 'ova_elems_deactivate');
167
168 function ova_elems_deactivate() {
169 // Deactivation code here
170 flush_rewrite_rules();
171 }
172
173 function ova_elems_enqueue_block_editor_assets(){
174
175 wp_enqueue_style('ova-elems-modal-css', OVA_ELEMS_URL . 'assets/css/modal.css', array(), OVA_ELEMS_VER);
176
177 wp_register_script(
178 'ova-elems-modal-js',
179 OVA_ELEMS_URL . 'assets/js/modal.js',
180 array('jquery'),
181 OVA_ELEMS_VER,
182 true
183 );
184
185 $theme = wp_get_theme();
186 $theme_author = $theme->get('Author');
187 $theme_text_domain = $theme->get('TextDomain');
188
189 $theme_directory = get_stylesheet_directory_uri();
190 $screenshot_url = $theme_directory . '/screenshot.png';
191
192 $demo_btn = strtoupper(str_replace("-", "_", $theme_text_domain)) . '_LIVE_DEMO';
193 $buy_pro = strtoupper(str_replace("-", "_", $theme_text_domain)) . '_BUY_PRO';
194 $free_doc = strtoupper(str_replace("-", "_", $theme_text_domain)) . '_FREE_DOC';
195
196 $is_demo_defined = defined($demo_btn);
197 $is_buy_pro_defined = defined($buy_pro);
198 $is_free_doc_defined = defined($free_doc);
199
200 $localize_arr = array(
201 'admin_ajax' => admin_url('admin-ajax.php'),
202 'search_icon' => OVA_ELEMS_URL . 'assets/images/search.png',
203 'is_author' => $theme_author === 'pewilliams' ? true : false,
204 'bundle_image' => OVA_ELEMS_URL . 'assets/images/bundle-images.png',
205 'nonce' => wp_create_nonce('ova_elems_ajax_nonce')
206 );
207
208 if ($theme_author === 'pewilliams') {
209 $localize_arr['screenshot_url'] = $screenshot_url;
210
211 $localize_arr['demo_btn'] = $is_demo_defined ? constant($demo_btn) : 'https://www.ovationthemes.com/collections/professional-wordpress-themes';
212 $localize_arr['buy_pro'] = $is_buy_pro_defined ? constant($buy_pro) : 'https://www.ovationthemes.com/products/wordpress-bundle';
213 $localize_arr['free_doc'] = $is_free_doc_defined ? constant($free_doc) : 'https://www.ovationthemes.com/';
214 }
215
216 wp_localize_script(
217 'ova-elems-modal-js',
218 'ova_elems_modal_js',
219 $localize_arr
220 );
221 wp_enqueue_script('ova-elems-modal-js');
222 }
223 add_action('enqueue_block_editor_assets', 'ova_elems_enqueue_block_editor_assets');
224
225 // Register block script.
226 function ova_elems_register_block()
227 {
228 wp_register_script(
229 'ova-elems-block',
230 plugins_url('build/index.js', __FILE__),
231 array('wp-blocks', 'wp-element', 'wp-editor', 'wp-components'),
232 OVA_ELEMS_VER,
233 true
234 );
235 register_block_type(
236 'ova-elems/ovation-sliders',
237 array(
238 'editor_script' => 'ova-elems-block',
239 'style' => 'ova-elems-style',
240 'editor_style' => 'ova-elems-editor-style',
241 'attributes' => array(
242 'selectedPost' => array(
243 'type' => 'number',
244 'default' => null,
245 ),
246 ),
247 'render_callback' => 'ova_elems_render_slider_block'
248 )
249 );
250 }
251 add_action('init', 'ova_elems_register_block');
252
253 function ova_elems_render_slider_block($attributes){
254
255 $id = isset($attributes['selectedPost']) ? $attributes['selectedPost'] : null;
256
257 if (!$id) {
258 return '';
259 }
260
261 return do_shortcode('[ova-elems-slider-template id="' . intval($id) . '"]');
262 }
263
264 add_filter('block_categories_all', function ($categories, $post) {
265 return array_merge(
266 array(
267 array(
268 'slug' => 'Ovation Sliders',
269 'title' => 'Ovation Sliders',
270 'icon' => '<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.56 22.07"><defs><style>{`.cls-1 {fill: #cee1f2;}.cls-2 {fill: none;stroke: #0023c4;stroke-width: .5px;}.cls-2, .cls-3 {stroke-miterlimit: 10;}.cls-4 {fill: #0023c4;}.cls-5, .cls-3 {fill: #ff5cf4;}.cls-3 {stroke: #ff5cf4;stroke-width: .25px;}`}</style></defs><g id="Layer_1-2" data-name="Layer_1"><path class="cls-4" d="M19.76,0h-5.52c-1.33,0-2.41,1.08-2.41,2.42v8.62c0,1.33,1.08,2.41,2.41,2.41h5.52c1.33,0,2.41-1.08,2.41-2.41V3.11l-2.41-3.11ZM20.44,11.03c0,.38-.31.69-.69.69h-5.52c-.38,0-.69-.31-.69-.69V2.42c0-.38.31-.69.69-.69h5.03v.91c0,.26.19.48.43.48h.75v7.92Z"/><path class="cls-1" d="M3.45,19.65v-7.07c0-.86.7-1.55,1.55-1.55h-2.59c-.86,0-1.55.7-1.55,1.55v7.07c0,.86.7,1.55,1.55,1.55h2.59c-.86,0-1.55-.7-1.55-1.55Z"/><path class="cls-4" d="M2.41,7.28h5.34c1.33,0,2.41-.91,2.41-2.04v-3.2c0-1.12-1.08-2.04-2.41-2.04H2.41C1.08,0,0,.91,0,2.04v3.2c0,1.12,1.08,2.04,2.41,2.04ZM1.72,2.04c0-.32.31-.58.69-.58h5.34c.38,0,.69.26.69.58v3.2c0,.32-.31.58-.69.58H2.41c-.38,0-.69-.26-.69-.58v-3.2Z"/><path class="cls-4" d="M2.41,22.07h5.34c1.33,0,2.41-1.08,2.41-2.41v-7.07c0-1.33-1.08-2.41-2.41-2.41H2.41c-1.33,0-2.41,1.08-2.41,2.41v7.07c0,1.33,1.08,2.41,2.41,2.41ZM1.72,12.59c0-.38.31-.69.69-.69h5.34c.38,0,.69.31.69.69v7.07c0,.38-.31.69-.69.69H2.41c-.38,0-.69-.31-.69-.69v-7.07Z"/><circle class="cls-4" cx="5.21" cy="8.75" r=".69"/><circle class="cls-2" cx="2.85" cy="8.75" r=".56"/><circle class="cls-2" cx="7.57" cy="8.75" r=".56"/><path class="cls-5" d="M21.01,19.09c-.4,0-.72.28-.72.62v.32c0,.44-.3.79-.67.79h-5.98c-.37,0-.67-.36-.67-.79v-1.88c0-.44.3-.79.67-.79h1.61c.4,0,.72-.28.72-.62h0c0-.34-.32-.62-.72-.62h-2c-.98,0-1.78.94-1.78,2.11v1.72c0,1.17.8,2.11,1.78,2.11h6.78c.98,0,1.78-.94,1.78-2.11v-.24c0-.34-.32-.62-.72-.62h-.07Z"/><path class="cls-5" d="M22.49,16.25l-2.14-2.22c-.07-.07-.18-.1-.27-.06-.09.04-.15.13-.15.23v1.07h-.08c-1.77,0-3.21,1.44-3.21,3.21v.49c0,.11.08.21.19.24.02,0,.04,0,.05,0,.09,0,.18-.05.23-.14.46-.93,1.4-1.5,2.43-1.5h.39v1.07c0,.1.06.19.15.23.09.04.2.01.27-.06l2.14-2.22c.09-.1.09-.25,0-.34Z"/><path class="cls-3" d="M7.59,3.77l.28-.28-.28-.28s-.02-.05,0-.06c.02-.02.04-.02.06,0l.31.31s.02.05,0,.06l-.31.31s-.05.02-.06,0c-.02-.02-.02-.04,0-.06h0Z"/><path class="cls-3" d="M2.41,3.77s.02.04,0,.06c-.02.02-.05.02-.06,0l-.31-.31s-.02-.05,0-.06l.31-.31s.04-.02.06,0c.02.02.02.05,0,.06l-.28.28.28.28h0Z"/></g></svg>'
271 ),
272 ),
273 $categories
274 );
275 }, 99999, 2);
276
277 add_action('admin_notices', 'ova_elems_admin_notice_with_html');
278
279 function ova_elems_admin_notice_with_html(){
280 ?>
281 <div class="notice is-dismissible ova-elems">
282 <div class="ova-elems-notice-banner-wrap">
283 <div class="ova-elems-notice-left-img">
284 <img src="<?php echo esc_url(OVA_ELEMS_URL . 'assets/images/notice-background.png'); ?>" alt="">
285 </div>
286 <div class="ova-elems-notice-heading">
287 <h1 class="ova-elems-main-head"><?php echo esc_html('WORDPRESS THEME BUNDLE'); ?></h1>
288 <h4 class="ova-elems-sub-head">
289 <?php echo esc_html('Access 125+ Gutenberg Block WordPress themes at Just $89'); ?></h4>
290 </div>
291 <div class="ova-elems-notice-btn">
292 <a class="ova-elems-buy-btn" target="_blank"
293 href="<?php echo esc_url('https://www.ovationthemes.com/products/wordpress-bundle'); ?>"><?php echo esc_html('BUY NOW'); ?></a>
294 </div>
295 <div class="notice-right-img">
296 <img src="<?php echo esc_url(OVA_ELEMS_URL . 'assets/images/bundle-package.png'); ?>" alt="">
297 </div>
298 </div>
299 </div>
300 <?php
301 }