check_post(); // Add the shortcodes // TODO : Make a json file add_action('wp_head', array($this, 'wp_head'), 999); // Add the Body Class Filter //add_filter('body_class', array($this, 'body_class')); // Add the content handler add_filter('the_content', array($this, 'the_content')); // Build the Shortcodes MD5 for cache $scmd5 = md5(json_encode($pagelayer->shortcodes).json_encode($pagelayer->groups).json_encode($pagelayer->styles)); // Enqueue our Editor's JS 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,trumbowyg.fontsize.min.js,pen.js,tlite.min.js&pagelayer_nonce=1&scmd5='.$scmd5, array('jquery'), PAGELAYER_VERSION); wp_enqueue_script('pagelayer-editor'); // Enqueue the Editor's CSS 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); wp_enqueue_style('pagelayer-editor'); // Enqueue the DateTime picker CSS /* wp_register_style('datetime-picker', PAGELAYER_CSS.'/datetime-picker.css', array(), PAGELAYER_VERSION); wp_enqueue_style('datetime-picker'); */ // Enqueue the media library if(!did_action('wp_enqueue_media')){ wp_enqueue_media(); } // Force the Frontend CSS and JS if not already loaded pagelayer_enqueue_frontend(true); // Hide Admin Bar show_admin_bar(false); remove_action('wp_head', '_admin_bar_bump_cb'); // Load custom widgets do_action('pagelayer_custom_editor_enqueue'); // Add the footer scripts add_action('wp_footer', array($this, 'wp_footer'), 1); } // Add our body class function body_class($classes){ return array_merge($classes, array('pagelayer-body')); } // Header function to add certain things function wp_head(){ global $pagelayer, $post, $wp_query; // Export the post props $_post = clone $post; unset($_post->post_content); $returnURL = (!is_page($post->ID) ? admin_url('edit.php') : admin_url('edit.php?post_type=page') ); echo ' '; do_action('pagelayer_editor_wp_head'); } // Footer function to add certain things function wp_footer(){ wp_enqueue_script('heartbeat'); _wp_footer_scripts(); } // Convert to Pagelayer post function check_post(){ global $post; // Is this a Pagelayer post $data = get_post_meta($post->ID, 'pagelayer-data', true); if(empty($data)){ // Is it a Gutenburg Post ? if(false){ // Regular post }else{ // Add our surrounding tag $post->post_content = '['.PAGELAYER_SC_PREFIX.'_row] ['.PAGELAYER_SC_PREFIX.'_col col=12] ['.PAGELAYER_SC_PREFIX.'_text] '.$post->post_content.' [/'.PAGELAYER_SC_PREFIX.'_text] [/'.PAGELAYER_SC_PREFIX.'_col] [/'.PAGELAYER_SC_PREFIX.'_row]'; // Update the post $new_post = array( 'ID' => $post->ID, 'post_content' => $post->post_content, ); // Update the post into the database wp_update_post($new_post); } // Convert to pagelayer accessed post if(!add_post_meta($post->ID, 'pagelayer-data', time(), true)){ update_post_meta($post->ID, 'pagelayer-data', time()); } } } // Add certain things function the_content($content) { global $post; // Check if we're inside the main loop in a single post page. if ( is_single() && in_the_loop() && is_main_query() ) { return $content; } return $content; } }