PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 1.0.5
Page Builder: Pagelayer – Drag and Drop website builder v1.0.5
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 1.0.5, at main/live.php

207 lines 6.6 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 // Build the Shortcodes MD5 for cache
51 $scmd5 = md5(json_encode($pagelayer->shortcodes).json_encode($pagelayer->groups).json_encode($pagelayer->styles));
52
53 // Enqueue our Editor's JS
54 wp_register_script('pagelayer-editor', admin_url( 'admin-ajax.php?action=pagelayer_givejs' ).'&give=pagelayer-editor.js,widgets.js,'.(defined('PAGELAYER_PREMIUM') ? 'premium.js,' : '').'properties.js,base-64.js,slimscroll.js,vanilla-picker.min.js,trumbowyg.js,trumbowyg.fontfamily.js,trumbowyg-pagelayer.js,pen.js,tlite.min.js&pagelayer_nonce=1&scmd5='.$scmd5, array('jquery'), PAGELAYER_VERSION);
55 wp_enqueue_script('pagelayer-editor');
56
57 // Enqueue the Editor's CSS
58 wp_register_style('pagelayer-editor', PAGELAYER_CSS.'/givecss.php?give=pagelayer-editor-frontend.css,pen.css'.(defined('PAGELAYER_PREMIUM') ? ',owl.theme.default.min.css,owl.carousel.min.css' : ''), array(), PAGELAYER_VERSION);
59 wp_enqueue_style('pagelayer-editor');
60
61 // Enqueue the DateTime picker CSS
62 /* wp_register_style('datetime-picker', PAGELAYER_CSS.'/datetime-picker.css', array(), PAGELAYER_VERSION);
63 wp_enqueue_style('datetime-picker'); */
64
65 // Enqueue the media library
66 if(!did_action('wp_enqueue_media')){
67 wp_enqueue_media();
68 }
69
70 // Force the Frontend CSS and JS if not already loaded
71 pagelayer_enqueue_frontend(true);
72
73 // Hide Admin Bar
74 show_admin_bar(false);
75 remove_action('wp_head', '_admin_bar_bump_cb');
76
77 // Load custom widgets
78 do_action('pagelayer_custom_editor_enqueue');
79
80 // Add the footer scripts
81 add_action('wp_footer', array($this, 'wp_footer'), 1);
82
83 }
84
85 // Add our body class
86 function body_class($classes){
87 return array_merge($classes, array('pagelayer-body'));
88 }
89
90 // Header function to add certain things
91 function wp_head(){
92
93 global $pagelayer, $post, $wp_query;
94
95 // Export the post props
96 $_post = clone $post;
97 unset($_post->post_content);
98
99 // Add template type
100 if(!empty($pagelayer->template_editor)){
101 $_post->pagelayer_template_type = get_post_meta($_post->ID, 'pagelayer_template_type', true);
102 }
103
104 $returnURL = (!is_page($post->ID) ? admin_url('edit.php') : admin_url('edit.php?post_type=page') );
105
106 echo '
107 <script type="text/javascript">
108 pagelayer_ver = "'.PAGELAYER_VERSION.'";
109 pagelayer_pro = '.(int)defined('PAGELAYER_PREMIUM').';
110 pagelayer_pro_url = "'.PAGELAYER_PRO_URL.'";
111 pagelayer_api_url = "'.PAGELAYER_API.'";
112 pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?&";
113 pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
114 pagelayer_media_ajax_nonce = "'.wp_create_nonce('media-form').'";
115 pagelayer_preview_nonce = "'. wp_create_nonce( 'post_preview_' . $post->ID ).'";
116 pagelayer_url = "'.PAGELAYER_URL.'";
117 pagelayer_postID = "'.$post->ID.'";
118 pagelayer_post_permalink = "'.get_permalink($post->ID).'";
119 pagelayer_tabs = '.json_encode($pagelayer->tabs).';
120 pagelayer_isDirty = false;
121 pagelayer_returnURL = "'.$returnURL.'";
122 pagelayer_theme_vars = '.json_encode( pagelayer_template_vars() ).';
123 pagelayer_revision_obj = '.json_encode( pagelayer_get_post_revision_by_id( $post->ID ) ).';
124 pagelayer_author = '.json_encode(pagelayer_author_data($post->ID)).';
125 pagelayer_site_logo = '.json_encode(pagelayer_site_logo()).';
126 pagelayer_support_FI = "'. ( current_theme_supports('post-thumbnails') ) .'";
127 pagelayer_editable = ".'.(!empty($pagelayer->template_editor) ? $pagelayer->template_editor : 'entry-content').'";
128 pagelayer_wp_query = '. json_encode($wp_query->query_vars) .';
129 pagelayer_post = '. @json_encode($_post) .';
130 pagelayer_loaded_icons = '.json_encode(pagelayer_enabled_icons()).';
131 pagelayer_social_urls = '.json_encode(pagelayer_get_social_urls()).';
132 pagelayer_shortcodes.pl_post_props.params.post_title.default = "'.pagelayer_escapeHTML($post->post_title).'";
133 pagelayer_shortcodes.pl_post_props.params.post_name.default = "'.pagelayer_escapeHTML($post->post_name).'";
134 pagelayer_shortcodes.pl_post_props.params.post_status.default = "'.$_post->post_status.'";
135 </script>';
136
137
138 do_action('pagelayer_editor_wp_head');
139
140 }
141
142 // Footer function to add certain things
143 function wp_footer(){
144 wp_enqueue_script('heartbeat');
145 _wp_footer_scripts();
146 }
147
148 // Convert to Pagelayer post
149 function check_post(){
150
151 global $post;
152
153 // Is this a Pagelayer post
154 $data = get_post_meta($post->ID, 'pagelayer-data', true);
155
156 if(empty($data)){
157
158 // Is it a Gutenburg Post ?
159 if(false){
160
161 // Regular post
162 }else{
163
164 // Add our surrounding tag
165 $post->post_content = '['.PAGELAYER_SC_PREFIX.'_row]
166 ['.PAGELAYER_SC_PREFIX.'_col col=12]
167 ['.PAGELAYER_SC_PREFIX.'_text]
168 '.$post->post_content.'
169 [/'.PAGELAYER_SC_PREFIX.'_text]
170 [/'.PAGELAYER_SC_PREFIX.'_col]
171 [/'.PAGELAYER_SC_PREFIX.'_row]';
172
173 // Update the post
174 $new_post = array(
175 'ID' => $post->ID,
176 'post_content' => $post->post_content,
177 );
178
179 // Update the post into the database
180 wp_update_post($new_post);
181
182 }
183
184 // Convert to pagelayer accessed post
185 if(!add_post_meta($post->ID, 'pagelayer-data', time(), true)){
186 update_post_meta($post->ID, 'pagelayer-data', time());
187 }
188 }
189
190 }
191
192 // Add certain things
193 function the_content($content) {
194
195 global $post;
196
197 // Check if we're inside the main loop in a single post page.
198 if ( is_single() && in_the_loop() && is_main_query() ) {
199 return $content;
200 }
201
202 return $content;
203
204 }
205
206 }
207