PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 0.9.2
Page Builder: Pagelayer – Drag and Drop website builder v0.9.2
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 / main / live.php

live.php in Page Builder: Pagelayer – Drag and Drop website builder 0.9.2, at main/live.php

174 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //////////////////////////////////////////////////////////////
4 //===========================================================
5 // live.php
6 //===========================================================
7 // PAGELAYER
8 // Inspired by the DESIRE to be the BEST OF ALL
9 // ----------------------------------------------------------
10 // Started by: Pulkit Gupta
11 // Date: 23rd Jan 2017
12 // Time: 23:00 hrs
13 // Site: http://pagelayer.com/wordpress (PAGELAYER)
14 // ----------------------------------------------------------
15 // Please Read the Terms of use at http://pagelayer.com/tos
16 // ----------------------------------------------------------
17 //===========================================================
18 // (c)Pagelayer Team
19 //===========================================================
20 //////////////////////////////////////////////////////////////
21
22 // Are we being accessed directly ?
23 if(!defined('PAGELAYER_VERSION')) {
24 exit('Hacking Attempt !');
25 }
26
27
28 class PageLayer_LiveEditor{
29
30 // The constructor
31 function __construct() {
32
33 global $pagelayer;
34
35 $GLOBALS['concatenate_scripts'] = true;
36
37 // Convert the post to a PageLayer Post first
38 $this->check_post();
39
40 // Add the shortcodes
41 // TODO : Make a json file
42 add_action('wp_head', array($this, 'wp_head'), 999);
43
44 // Add the Body Class Filter
45 //add_filter('body_class', array($this, 'body_class'));
46
47 // Add the content handler
48 add_filter('the_content', array($this, 'the_content'));
49
50 // Enqueue our Editor's JS
51 wp_register_script('pagelayer-editor', PAGELAYER_JS.'/givejs.php?give=pagelayer-editor.js,widgets.js,'.(defined('PAGELAYER_PREMIUM') ? 'premium.js,' : '').'properties.js,base64.js,slimscroll.js,vanilla-picker.min.js,trumbowyg.js,trumbowyg-pagelayer.js,pen.js', array('jquery'), PAGELAYER_VERSION);
52 wp_enqueue_script('pagelayer-editor');
53
54 // Enqueue the Editor's CSS
55 wp_register_style('pagelayer-editor', PAGELAYER_CSS.'/givecss.php?give=pagelayer-editor-frontend.css,pen.css', array(), PAGELAYER_VERSION);
56 wp_enqueue_style('pagelayer-editor');
57
58 // Enqueue the DateTime picker CSS
59 /* wp_register_style('datetime-picker', PAGELAYER_CSS.'/datetime-picker.css', array(), PAGELAYER_VERSION);
60 wp_enqueue_style('datetime-picker'); */
61
62 // Enqueue the media library
63 if(!did_action('wp_enqueue_media')){
64 wp_enqueue_media();
65 }
66
67 // Force the Frontend CSS and JS if not already loaded
68 pagelayer_enqueue_frontend(true);
69
70 // Hide Admin Bar
71 show_admin_bar(false);
72
73 // Load custom widgets
74 do_action('pagelayer_custom_editor_enqueue');
75
76 // Add the footer scripts
77 add_action('wp_footer', array($this, 'wp_footer'), 1);
78
79 }
80
81 // Add our body class
82 function body_class($classes){
83 return array_merge($classes, array('pagelayer-body'));
84 }
85
86 // Header function to add certain things
87 function wp_head(){
88
89 global $pagelayer, $post;
90
91 $returnURL = (!is_page($post->ID) ? admin_url('edit.php') : admin_url('edit.php?post_type=page') );
92
93 echo '
94 <script type="text/javascript">
95 pagelayer_ver = "'.PAGELAYER_VERSION .'";
96 pagelayer_shortcodes = '.json_encode($pagelayer->shortcodes).';
97 pagelayer_styles = '.json_encode($pagelayer->styles).';
98 pagelayer_groups = '.json_encode($pagelayer->groups).';
99 pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'";
100 pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
101 pagelayer_url = "'.PAGELAYER_URL.'";
102 pagelayer_postID = "'.$post->ID.'";
103 pagelayer_tabs = '.json_encode($pagelayer->tabs).';
104 pagelayer_isDirty = false;
105 pagelayer_returnURL = "'.$returnURL.'";
106 </script>';
107 }
108
109 // Footer function to add certain things
110 function wp_footer(){
111 wp_enqueue_script('heartbeat');
112 _wp_footer_scripts();
113 }
114
115 // Convert to Pagelayer post
116 function check_post(){
117
118 global $post;
119
120 // Is this a Pagelayer post
121 $data = get_post_meta($post->ID, 'pagelayer-data', true);
122
123 if(empty($data)){
124
125 // Is it a Gutenburg Post ?
126 if(false){
127
128 // Regular post
129 }else{
130
131 // Add our surrounding tag
132 $post->post_content = '['.PAGELAYER_SC_PREFIX.'_row]
133 ['.PAGELAYER_SC_PREFIX.'_col col=12]
134 ['.PAGELAYER_SC_PREFIX.'_text]
135 '.$post->post_content.'
136 [/'.PAGELAYER_SC_PREFIX.'_text]
137 [/'.PAGELAYER_SC_PREFIX.'_col]
138 [/'.PAGELAYER_SC_PREFIX.'_row]';
139
140 // Update the post
141 $new_post = array(
142 'ID' => $post->ID,
143 'post_content' => $post->post_content,
144 );
145
146 // Update the post into the database
147 wp_update_post($new_post);
148
149 }
150
151 // Convert to pagelayer accessed post
152 if(!add_post_meta($post->ID, 'pagelayer-data', time(), true)){
153 update_post_meta($post->ID, 'pagelayer-data', time());
154 }
155 }
156
157 }
158
159 // Add certain things
160 function the_content($content) {
161
162 global $post;
163
164 // Check if we're inside the main loop in a single post page.
165 if ( is_single() && in_the_loop() && is_main_query() ) {
166 return $content;
167 }
168
169 return $content;
170
171 }
172
173 }
174