prefix."pagelayer_logs`"; foreach($sql as $sk => $sv){ $wpdb->query($sv); }*/ add_option('pagelayer_version', PAGELAYER_VERSION); add_option('pagelayer_options', array()); } // Checks if we are to update ? function pagelayer_update_check(){ global $wpdb; $sql = array(); $current_version = get_option('pagelayer_version'); $version = (int) str_replace('.', '', $current_version); // No update required if($current_version == PAGELAYER_VERSION){ return true; } // Is it first run ? if(empty($current_version)){ // Reinstall pagelayer_activation(); // Trick the following if conditions to not run $version = (int) str_replace('.', '', PAGELAYER_VERSION); } // Save the new Version update_option('pagelayer_version', PAGELAYER_VERSION); } // Add the action to load the plugin add_action('plugins_loaded', 'pagelayer_load_plugin'); // The function that will be called when the plugin is loaded function pagelayer_load_plugin(){ global $pagelayer; // Check if the installed version is outdated pagelayer_update_check(); // Set the array $pagelayer = new PageLayer(); // Is there any ACTION set ? $pagelayer->action = pagelayer_optreq('pagelayer-action'); // Load settings $options = get_option('pagelayer_options'); $pagelayer->settings['post_types'] = empty($options['post_types']) ? array('post', 'page') : $options['post_types']; $pagelayer->settings['css_code'] = empty($options['css_code']) ? '' : $options['css_code']; $pagelayer->settings['animate'] = empty($options['animate']) ? '' : $options['animate']; $pagelayer->settings['max_width'] = empty($options['max_width']) ? 1170 : $options['max_width']; // Load the language load_plugin_textdomain('pagelayer', false, PAGELAYER_SLUG.'/languages/'); // Show the promo pagelayer_maybe_promo([ 'after' => 1,// In days 'interval' => 30,// In days //'pro_url' => 'https://pagelayer.com/themes/wordpress/corporate/Bizworx_Pro', 'rating' => 'https://wordpress.org/plugins/pagelayer/#reviews', 'twitter' => 'https://twitter.com/pagelayer?status='.rawurlencode('I love #PageLayer Site Builder by @pagelayer team for my #WordPress site - '.home_url()), 'facebook' => 'https://www.facebook.com/pagelayer', 'website' => '//pagelayer.com', 'image' => PAGELAYER_URL.'/images/pagelayer-logo-256.png' ]); } // This adds the left menu in WordPress Admin page add_action('admin_menu', 'pagelayer_admin_menu'); // Shows the admin menu of Pagelayer function pagelayer_admin_menu() { global $wp_version, $pagelayer; $capability = 'activate_plugins';// TODO : Capability for accessing this page // Add the menu page add_menu_page(__('PageLayer Editor'), __('PageLayer'), $capability, 'pagelayer', 'pagelayer_page_handler', PAGELAYER_URL.'/images/pagelayer-logo-19.png'); // Settings Page add_submenu_page('pagelayer', __('PageLayer Editor'), __('Settings'), $capability, 'pagelayer', 'pagelayer_page_handler'); // Its premium if(defined('PAGELAYER_PREMIUM')){ // Fonts link add_submenu_page('pagelayer', __('PageLayer Font Settings'), __('PageLayer Font Settings'), $capability, 'pagelayer_fonts', 'pagelayer_page_fonts'); // Its free }else{ // Go Pro link add_submenu_page('pagelayer', __('PageLayer Go Pro'), __('Go Pro'), $capability, PAGELAYER_PRO_URL); } } // This function will handle the pages in Pages in PageLayer function pagelayer_page_handler(){ global $wp_version, $pagelayer; include_once(PAGELAYER_DIR.'/main/settings.php'); // Handle fonts if($pagelayer->action == 'fonts-manager'){ include_once(PAGELAYER_DIR.'/main/fonts.php'); } } // Enqueue JS and CSS in Admin Panel for settings add_action( 'admin_enqueue_scripts', 'pagelayer_admin_script' ); function pagelayer_admin_script() { wp_enqueue_script( 'pagelayer-admin', PAGELAYER_JS.'/pagelayer-admin.js', array('jquery'), PAGELAYER_VERSION); wp_enqueue_style( 'pagelayer-admin', PAGELAYER_CSS.'/pagelayer-admin.css', array(), PAGELAYER_VERSION); } // Load the Live Body add_action('template_redirect', 'pagelayer_load_live_body', 4); function pagelayer_load_live_body(){ global $post; // If its not live editing then stop if(!pagelayer_is_live()){ return; } // If its the iFRAME then return if(pagelayer_is_live_iframe()){ return; } // Are you allowed to edit ? if(!pagelayer_user_can_edit()){ return; } // Load the editor live body include_once(PAGELAYER_DIR.'/main/live-body.php'); pagelayer_live_body(); } // Add the JS and CSS for Posts and Pages when being viewed ONLY if there is our content called add_action('template_redirect', 'pagelayer_enqueue_frontend', 5); function pagelayer_enqueue_frontend($force = false){ global $post, $pagelayer; if(!empty($pagelayer->cache['enqueue_frontend'])){ return; } if(empty($post->ID)){ return; } // Enqueue the FRONTEND CSS if(get_post_meta($post->ID , 'pagelayer-data') || $force){ // We dont need the auto
and
as they interfere with us
remove_filter('the_content', 'wpautop');
// No need to add curly codes to the content
remove_filter('the_content', 'wptexturize');
pagelayer_load_shortcodes();
$pagelayer->cache['enqueue_frontend'] = true;
// Enqueue our Editor's Frontend JS
wp_register_script('pagelayer-frontend', PAGELAYER_JS.'/givejs.php?give=pagelayer-frontend.js,nivo-lightbox.min.js,slippry.min.js,wow.min.js,jquery-numerator.js,simpleParallax.min.js', array('jquery'), PAGELAYER_VERSION);
wp_enqueue_script('pagelayer-frontend');
wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/givecss.php?give=pagelayer-frontend.css,nivo-lightbox.css,slippry.css,animate.min.css', array(), PAGELAYER_VERSION);
wp_enqueue_style('pagelayer-frontend');
wp_register_style('font-awesome', PAGELAYER_CSS.'/font-awesome.min.css', array(), PAGELAYER_VERSION);
wp_enqueue_style('font-awesome');
// Load the global styles
add_action('wp_head', 'pagelayer_global_styles', 5);
// Load custom widgets
do_action('pagelayer_custom_frontend_enqueue');
}
}
// Load the google fonts
add_action('wp_footer', 'pagelayer_enqueue_fonts', 5);
function pagelayer_enqueue_fonts(){
global $pagelayer;
if(empty($pagelayer->cache['enqueue_frontend'])){
return;
}
$url = 'Open Sans:300italic,400italic,600italic,300,400,600&subset=latin,latin-ext';
//pagelayer_print($pagelayer->runtime_fonts);die('alpesh');
foreach($pagelayer->runtime_fonts as $font){
$url .= '|'.$font.':100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i';
}
//echo '';
wp_register_style('pagelayer-google-font', 'https://fonts.googleapis.com/css?family='.rawurlencode($url), array(), PAGELAYER_VERSION);
wp_enqueue_style('pagelayer-google-font');
}
// We need to handle global styles
function pagelayer_global_styles(){
$styles = '';
echo $styles;
}
// Load the live editor if needed
add_action('wp_enqueue_scripts', 'pagelayer_load_live', 9999);
function pagelayer_load_live(){
global $post;
// If its not live editing then stop
if(!pagelayer_is_live_iframe()){
return;
}
// Are you allowed to edit ?
if(!pagelayer_user_can_edit()){
return;
}
// Load the editor class
include_once(PAGELAYER_DIR.'/main/live.php');
// Call the constructor
$pl_editor = new PageLayer_LiveEditor();
}
// Show the backend editor options
add_action('edit_form_after_title', 'pagelayer_after_title');
function pagelayer_after_title(){
global $post;
// Get the current screen
$current_screen = get_current_screen();
// For gutenberg
if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){
// Add the code in the footer
add_action('admin_footer', 'pagelayer_gutenberg_after_title');
return;
}
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1';
echo '