PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 0.9.9
Page Builder: Pagelayer – Drag and Drop website builder v0.9.9
2.2.1 2.2.0 2.1.9 2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 trunk 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 1.0.0 1.0.2 1.0.3 1.0.4 1.0.5 All 129 releases
pagelayer / init.php

init.php in Page Builder: Pagelayer – Drag and Drop website builder 0.9.9, at init.php

422 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // We need the ABSPATH
4 if (!defined('ABSPATH')) exit;
5
6 define('PAGELAYER_BASE', plugin_basename(__FILE__));
7 define('PAGELAYER_FILE', __FILE__);
8 define('PAGELAYER_VERSION', '0.9.9');
9 define('PAGELAYER_DIR', WP_PLUGIN_DIR.'/'.basename(dirname(PAGELAYER_FILE)));
10 define('PAGELAYER_SLUG', 'pagelayer');
11 define('PAGELAYER_URL', plugins_url('', PAGELAYER_FILE));
12 define('PAGELAYER_CSS', PAGELAYER_URL.'/css');
13 define('PAGELAYER_JS', PAGELAYER_URL.'/js');
14 define('PAGELAYER_PRO_URL', 'https://pagelayer.com/features#compare');
15 define('PAGELAYER_DOCS', 'https://pagelayer.com/docs/');
16 define('PAGELAYER_API', 'https://api.pagelayer.com/');
17 define('PAGELAYER_SC_PREFIX', 'pl');
18 define('PAGELAYER_YOUTUBE_BG', 'https://www.youtube.com/watch?v=Csa6rvCWmLU');
19
20 include_once(PAGELAYER_DIR.'/main/functions.php');
21 include_once(PAGELAYER_DIR.'/main/class.php');
22
23 // Ok so we are now ready to go
24 register_activation_hook(PAGELAYER_FILE, 'pagelayer_activation');
25
26 // Is called when the ADMIN enables the plugin
27 function pagelayer_activation(){
28
29 global $wpdb;
30
31 $sql = array();
32
33 /*$sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."pagelayer_logs`";
34
35 foreach($sql as $sk => $sv){
36 $wpdb->query($sv);
37 }*/
38
39 add_option('pagelayer_version', PAGELAYER_VERSION);
40 add_option('pagelayer_options', array());
41
42 }
43
44 // Checks if we are to update ?
45 function pagelayer_update_check(){
46
47 global $wpdb;
48
49 $sql = array();
50 $current_version = get_option('pagelayer_version');
51 $version = (int) str_replace('.', '', $current_version);
52
53 // No update required
54 if($current_version == PAGELAYER_VERSION){
55 return true;
56 }
57
58 // Is it first run ?
59 if(empty($current_version)){
60
61 // Reinstall
62 pagelayer_activation();
63
64 // Trick the following if conditions to not run
65 $version = (int) str_replace('.', '', PAGELAYER_VERSION);
66
67 }
68
69 // Save the new Version
70 update_option('pagelayer_version', PAGELAYER_VERSION);
71
72 }
73
74 // Add the action to load the plugin
75 add_action('plugins_loaded', 'pagelayer_load_plugin');
76
77 // The function that will be called when the plugin is loaded
78 function pagelayer_load_plugin(){
79
80 global $pagelayer;
81
82 // Check if the installed version is outdated
83 pagelayer_update_check();
84
85 // Set the array
86 $pagelayer = new PageLayer();
87
88 // Is there any ACTION set ?
89 $pagelayer->action = pagelayer_optreq('pagelayer-action');
90
91 // Load settings
92 $options = get_option('pagelayer_options');
93 $pagelayer->settings['post_types'] = empty($options['post_types']) ? array('post', 'page') : $options['post_types'];
94 $pagelayer->settings['css_code'] = empty($options['css_code']) ? '' : $options['css_code'];
95 $pagelayer->settings['animate'] = empty($options['animate']) ? '' : $options['animate'];
96 $pagelayer->settings['max_width'] = empty($options['max_width']) ? 1170 : $options['max_width'];
97
98 // Load the language
99 load_plugin_textdomain('pagelayer', false, PAGELAYER_SLUG.'/languages/');
100
101 // Show the promo
102 pagelayer_maybe_promo([
103 'after' => 1,// In days
104 'interval' => 30,// In days
105 //'pro_url' => 'https://pagelayer.com/themes/wordpress/corporate/Bizworx_Pro',
106 'rating' => 'https://wordpress.org/plugins/pagelayer/#reviews',
107 'twitter' => 'https://twitter.com/pagelayer?status='.rawurlencode('I love #PageLayer Site Builder by @pagelayer team for my #WordPress site - '.home_url()),
108 'facebook' => 'https://www.facebook.com/pagelayer',
109 'website' => '//pagelayer.com',
110 'image' => PAGELAYER_URL.'/images/pagelayer-logo-256.png'
111 ]);
112
113 // Its premium
114 if(defined('PAGELAYER_PREMIUM')){
115 include_once(PAGELAYER_DIR.'/main/template-builder.php');
116 }
117
118 }
119
120 // This adds the left menu in WordPress Admin page
121 add_action('admin_menu', 'pagelayer_admin_menu', 5);
122
123 // Shows the admin menu of Pagelayer
124 function pagelayer_admin_menu() {
125
126 global $wp_version, $pagelayer;
127
128 $capability = 'activate_plugins';// TODO : Capability for accessing this page
129
130 // Add the menu page
131 add_menu_page(__('PageLayer Editor'), __('Pagelayer'), $capability, 'pagelayer', 'pagelayer_page_handler', PAGELAYER_URL.'/images/pagelayer-logo-19.png');
132
133 // Settings Page
134 add_submenu_page('pagelayer', __('PageLayer Editor'), __('Settings'), $capability, 'pagelayer', 'pagelayer_page_handler');
135
136 // Its premium
137 if(defined('PAGELAYER_PREMIUM')){
138
139 // Fonts link
140 add_submenu_page('pagelayer', __('Font Settings'), __('Font Settings'), $capability, 'pagelayer_fonts', 'pagelayer_page_fonts');
141
142 // Add new template
143 add_submenu_page('pagelayer', __('Theme Builder'), __('Theme Builder'), $capability, 'edit.php?post_type=pagelayer-template');
144
145 // Add new template Link
146 //add_submenu_page('pagelayer', __('Add New Template'), __('Add New Template'), $capability, 'edit.php?post_type=pagelayer-template#new');
147
148 // Add new template
149 add_submenu_page('pagelayer', __('Add New Template'), __('Add New Template'), $capability, 'pagelayer_template_wizard', 'pagelayer_builder_template_wizard');
150
151 // Its free
152 }else{
153
154 // Go Pro link
155 add_submenu_page('pagelayer', __('PageLayer Go Pro'), __('Go Pro'), $capability, PAGELAYER_PRO_URL);
156
157 }
158
159 }
160
161 // This function will handle the pages in Pages in PageLayer
162 function pagelayer_page_handler(){
163
164 global $wp_version, $pagelayer;
165
166 wp_enqueue_script( 'pagelayer-admin', PAGELAYER_JS.'/pagelayer-admin.js', array('jquery'), PAGELAYER_VERSION);
167 wp_enqueue_style( 'pagelayer-admin', PAGELAYER_CSS.'/pagelayer-admin.css', array(), PAGELAYER_VERSION);
168
169 include_once(PAGELAYER_DIR.'/main/settings.php');
170
171 // Handle fonts
172 if($pagelayer->action == 'fonts-manager'){
173 include_once(PAGELAYER_DIR.'/main/fonts.php');
174 }
175
176 }
177
178 // Load the Live Body
179 add_action('template_redirect', 'pagelayer_load_live_body', 4);
180
181 function pagelayer_load_live_body(){
182
183 global $post;
184
185 // If its not live editing then stop
186 if(!pagelayer_is_live()){
187 return;
188 }
189
190 // If its the iFRAME then return
191 if(pagelayer_is_live_iframe()){
192 return;
193 }
194
195 // Are you allowed to edit ?
196 if(!pagelayer_user_can_edit()){
197 return;
198 }
199
200 // Load the editor live body
201 include_once(PAGELAYER_DIR.'/main/live-body.php');
202
203 pagelayer_live_body();
204
205 }
206
207 // Add the JS and CSS for Posts and Pages when being viewed ONLY if there is our content called
208 add_action('template_redirect', 'pagelayer_enqueue_frontend', 5);
209
210 function pagelayer_enqueue_frontend($force = false){
211
212 global $post, $pagelayer;
213
214 if(!empty($pagelayer->cache['enqueue_frontend'])){
215 return;
216 }
217
218 if(empty($post->ID)){
219 return;
220 }
221
222 // Enqueue the FRONTEND CSS
223 if(get_post_meta($post->ID , 'pagelayer-data') || $force){
224
225 // We dont need the auto <p> and <br> as they interfere with us
226 remove_filter('the_content', 'wpautop');
227
228 // No need to add curly codes to the content
229 remove_filter('the_content', 'wptexturize');
230
231 pagelayer_load_shortcodes();
232 $pagelayer->cache['enqueue_frontend'] = true;
233
234 // Load the global styles
235 add_action('wp_head', 'pagelayer_global_js', 2);
236
237 $premium_js = '';
238 $premium_css = '';
239 if(defined('PAGELAYER_PREMIUM')){
240 $premium_js = ',chart.min.js,slick.min.js,premium-frontend.js';
241 $premium_css = ',slick.css,slick-theme.css,premium-frontend.css';
242 // Load this For audio widget
243 wp_enqueue_script('wp-mediaelement');
244 wp_enqueue_style( 'wp-mediaelement' );
245 }
246
247 // Enqueue our Editor's Frontend JS
248 wp_register_script('pagelayer-frontend', PAGELAYER_JS.'/givejs.php?give=pagelayer-frontend.js,nivo-lightbox.min.js,wow.min.js,jquery-numerator.js,simpleParallax.min.js,owl.carousel.min.js'.$premium_js, array('jquery'), PAGELAYER_VERSION);
249 wp_enqueue_script('pagelayer-frontend');
250
251 wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/givecss.php?give=pagelayer-frontend.css,nivo-lightbox.css,animate.min.css,owl.carousel.min.css,owl.theme.default.min.css'.$premium_css, array(), PAGELAYER_VERSION);
252 wp_enqueue_style('pagelayer-frontend');
253
254 wp_register_style('font-awesome', PAGELAYER_CSS.'/font-awesome.min.css', array(), PAGELAYER_VERSION);
255 wp_enqueue_style('font-awesome');
256
257 // Load the global styles
258 add_action('wp_head', 'pagelayer_global_styles', 5);
259
260 // Load custom widgets
261 do_action('pagelayer_custom_frontend_enqueue');
262
263 }
264
265 }
266
267 // Load the google fonts
268 add_action('wp_footer', 'pagelayer_enqueue_fonts', 5);
269
270 function pagelayer_enqueue_fonts(){
271 global $pagelayer;
272
273 if(empty($pagelayer->cache['enqueue_frontend'])){
274 return;
275 }
276
277 $url = 'Open Sans:300italic,400italic,600italic,300,400,600&subset=latin,latin-ext';
278 //pagelayer_print($pagelayer->runtime_fonts);die('alpesh');
279
280 foreach($pagelayer->runtime_fonts as $font){
281 $url .= '|'.$font.':100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i';
282 }
283
284 //echo '<link href="https://fonts.googleapis.com/css?family='.$url.'" rel="stylesheet">';
285
286 wp_register_style('pagelayer-google-font', 'https://fonts.googleapis.com/css?family='.rawurlencode($url), array(), PAGELAYER_VERSION);
287 wp_enqueue_style('pagelayer-google-font');
288
289 }
290
291 // Load any header we have
292 function pagelayer_global_js(){
293
294 echo '<script>
295 var pagelayer_ajaxurl = "'.admin_url( 'admin-ajax.php' ).'?";
296 var pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
297 var pagelayer_server_time = '.time().';
298 var pagelayer_facebook_id = "'.get_option('pagelayer-fbapp-id').'";
299 </script>';
300
301 }
302
303 // We need to handle global styles
304 function pagelayer_global_styles(){
305
306 $styles = '<style id="pagelayer-global-styles" type="text/css">';
307
308 $width = get_option('pagelayer_content_width', '1170');
309
310 $styles .= '.pagelayer-row-stretch-auto .pagelayer-row-holder{ max-width: '.$width.'px; margin-left: auto; margin-right: auto;}';
311
312 $styles .= '</style>';
313
314 echo $styles;
315 }
316
317 // Load the live editor if needed
318 add_action('wp_enqueue_scripts', 'pagelayer_load_live', 9999);
319
320 function pagelayer_load_live(){
321
322 global $post;
323
324 // If its not live editing then stop
325 if(!pagelayer_is_live_iframe()){
326 return;
327 }
328
329 // Are you allowed to edit ?
330 if(!pagelayer_user_can_edit()){
331 return;
332 }
333
334 // Load the editor class
335 include_once(PAGELAYER_DIR.'/main/live.php');
336
337 // Call the constructor
338 $pl_editor = new PageLayer_LiveEditor();
339
340 }
341
342 // If we are doing ajax and its a pagelayer ajax
343 if(wp_doing_ajax()){
344 include_once(PAGELAYER_DIR.'/main/ajax.php');
345 }
346
347 // Show the backend editor options
348 add_action('edit_form_after_title', 'pagelayer_after_title', 10);
349 function pagelayer_after_title(){
350
351 global $post;
352
353 // Get the current screen
354 $current_screen = get_current_screen();
355
356 // For gutenberg
357 if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){
358
359 // Add the code in the footer
360 add_action('admin_footer', 'pagelayer_gutenberg_after_title');
361
362 return;
363 }
364
365 $link = pagelayer_shortlink($post->ID).'&pagelayer-live=1';
366
367 echo '
368 <div id="pagelayer-editor-button-row" style="margin-top:15px; display:inline-block;">
369 <a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;">
370 <img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with PageLayer').'</span>
371 </a>
372 </div>';
373
374 }
375
376 function pagelayer_gutenberg_after_title(){
377
378 global $post;
379
380 $link = pagelayer_shortlink($post->ID).'&pagelayer-live=1';
381
382 echo '
383 <div id="pagelayer-editor-button-row" style="margin-left:15px; display:none">
384 <a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;">
385 <img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with PageLayer').'</span>
386 </a>
387 </div>
388
389 <script type="text/javascript">
390 jQuery(document).ready(function(){
391
392 var pagelayer_timer;
393 var pagelayer_button = function(){
394 var button = jQuery("#pagelayer-editor-button-row");
395 var g = jQuery(".edit-post-header-toolbar");
396 if(g.length < 1){
397 return;
398 }
399 button.detach();
400 //console.log(button);
401 g.append(button);
402 button.show();
403 clearInterval(pagelayer_timer);
404 }
405 pagelayer_timer = setInterval(pagelayer_button, 100);
406 });
407 </script>';
408
409 }
410
411 add_filter( 'post_row_actions', 'pagelayer_quick_link', 10, 2 );
412 add_filter( 'page_row_actions', 'pagelayer_quick_link', 10, 2 );
413 function pagelayer_quick_link($actions, $post){
414 $link = pagelayer_shortlink($post->ID).'&pagelayer-live=1';
415
416 $actions['pagelayer'] = '<a href="'.esc_url( $link ).'">'.__( 'Edit using PageLayer', 'pagelayer') .'</a>';
417
418 return $actions;
419 }
420
421 // Pagelayer Template Loading Mechanism
422 include_once(PAGELAYER_DIR.'/main/template.php');