This commit is contained in:
2025-06-08 20:07:38 +09:00
parent 3b2966ebe2
commit a372bb62c7
2479 changed files with 1059113 additions and 1057157 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,169 +1,169 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// class.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
// PageLayer Class
class PageLayer{
// All Settings
var $settings = array();
// Cache
var $cache = array();
// Common Styles Params
var $styles = array();
// All Shortcodes
var $shortcodes = array();
// All Shortcodes Groups
var $groups = array();
// Builder definition
var $builder = array();
// The Lang Strings
var $l = array();
// Runtime fonts
var $runtime_fonts = array();
var $fonts_sent = array();
var $system_fonts = array();
var $typo_props = array();
// Array of all the template paths
var $all_template_paths = array();
// Tabs visible in the left panel
var $tabs = ['settings', 'options'];
// Tabs visible in the left panel
var $screens = ['desktop' => '', 'tablet' => 'tablet', 'mobile' => 'mobile'];
// Icons set
var $icons = ['font-awesome5'];
// For exporting templates
var $media_to_export = array();
// For global widget
var $global_widgets = array();
// For global section
var $global_sections = array();
// For saved sections
var $saved_sections = array();
// For saved default params
var $default_params = array();
// Youtube API
var $append_yt_api = false;
var $css = array();
var $css_settings = array();
// Customizer options
var $customizer_mods = array();
var $customizer_params = array();
var $data_attr = array();
var $sc_audio_enqueued = 0;
var $support = 'http://pagelayer.deskuss.com';
// Global colors and typographies
var $global_colors = array();
var $global_fonts = array();
function __construct() {
// Load the langs
$this->l = @file_get_contents(PAGELAYER_DIR.'/languages/en.json');
$this->l = @json_decode($this->l, true);
// Add after plugins_loaded
add_action('plugins_loaded', [ $this, 'load_extra_languages' ], 11);
// Array of font options
$this->css_settings = ['body' => ['name' => 'Body', 'key' => 'pagelayer_body_typography'],
'header' => ['name' => 'Site Header', 'sel' => '> header'],
'main' => ['name' => 'Site Main', 'sel' => '.site-main'],
'footer' => ['name' => 'Site Footer', 'sel' => '> footer'],
'entry-header' => ['name' => 'Content Header', 'sel' => '.entry-header'],
'entry-content' => ['name' => 'Content', 'sel' => '.entry-content'],
'entry-footer' => ['name' => 'Content Footer', 'sel' => '.entry-footer'],
'p' => ['name' => 'Paragraph'],
'aside' => ['name' => 'Sidebar'],
'a' => ['name' => 'Link'],
'a-hover' => ['name' => 'Link Hover', 'sel' => 'a:hover'],
'h1' => ['name' => 'H1', 'key' => 'pagelayer_h1_typography'],
'h2' => ['name' => 'H2', 'key' => 'pagelayer_h2_typography'],
'h3' => ['name' => 'H3', 'key' => 'pagelayer_h3_typography'],
'h4' => ['name' => 'H4', 'key' => 'pagelayer_h4_typography'],
'h5' => ['name' => 'H5', 'key' => 'pagelayer_h5_typography'],
'h6' => ['name' => 'H6', 'key' => 'pagelayer_h6_typography'],
'b' => ['name' => 'Bold', 'sel' => 'strong, body.pagelayer-body b'],
'i' => ['name' => 'Italics', 'sel' => 'em, body.pagelayer-body i:not(.fa, .fas, .far, .fab)'],
];
$this->system_fonts = ['Arial', 'Arial Black', 'Courier', 'Georgia', 'Helvetica', 'impact', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana'];
$this->customizer_mods = get_option('pagelayer_customizer_mods', []);
$this->support = (defined('SITEPAD') ? 'http://sitepad.deskuss.com' : $this->support);
$this->typo_props = ['font-family', 'font-size', 'font-style', 'font-weight', 'font-variant', 'text-decoration-line', 'text-decoration-style', 'line-height', 'text-transform', 'letter-spacing', 'word-spacing'];
}
function default_font_styles( $args = array()){
$default_font_styles = [
'font-family' => 'Open Sans',
'font-size' => '',
'font-style' => '',
'font-variant' => '',
'font-weight' => '',
'letter-spacing' => '',
'line-height' => '',
'text-decoration-line' => '',
'text-decoration-style' => '',
'text-transform' => '',
'word-spacing' => ''
];
return array_merge($default_font_styles, $args);
}
function load_extra_languages(){
if(defined('SITEPAD')){
$this->l['email_desc'] = 'To change the email, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
$this->l['CMA_desc'] = 'To change text, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
}
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// class.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
// PageLayer Class
class PageLayer{
// All Settings
var $settings = array();
// Cache
var $cache = array();
// Common Styles Params
var $styles = array();
// All Shortcodes
var $shortcodes = array();
// All Shortcodes Groups
var $groups = array();
// Builder definition
var $builder = array();
// The Lang Strings
var $l = array();
// Runtime fonts
var $runtime_fonts = array();
var $fonts_sent = array();
var $system_fonts = array();
var $typo_props = array();
// Array of all the template paths
var $all_template_paths = array();
// Tabs visible in the left panel
var $tabs = ['settings', 'options'];
// Tabs visible in the left panel
var $screens = ['desktop' => '', 'tablet' => 'tablet', 'mobile' => 'mobile'];
// Icons set
var $icons = ['font-awesome5'];
// For exporting templates
var $media_to_export = array();
// For global widget
var $global_widgets = array();
// For global section
var $global_sections = array();
// For saved sections
var $saved_sections = array();
// For saved default params
var $default_params = array();
// Youtube API
var $append_yt_api = false;
var $css = array();
var $css_settings = array();
// Customizer options
var $customizer_mods = array();
var $customizer_params = array();
var $data_attr = array();
var $sc_audio_enqueued = 0;
var $support = 'http://pagelayer.deskuss.com';
// Global colors and typographies
var $global_colors = array();
var $global_fonts = array();
function __construct() {
// Load the langs
$this->l = @file_get_contents(PAGELAYER_DIR.'/languages/en.json');
$this->l = @json_decode($this->l, true);
// Add after plugins_loaded
add_action('plugins_loaded', [ $this, 'load_extra_languages' ], 11);
// Array of font options
$this->css_settings = ['body' => ['name' => 'Body', 'key' => 'pagelayer_body_typography'],
'header' => ['name' => 'Site Header', 'sel' => '> header'],
'main' => ['name' => 'Site Main', 'sel' => '.site-main'],
'footer' => ['name' => 'Site Footer', 'sel' => '> footer'],
'entry-header' => ['name' => 'Content Header', 'sel' => '.entry-header'],
'entry-content' => ['name' => 'Content', 'sel' => '.entry-content'],
'entry-footer' => ['name' => 'Content Footer', 'sel' => '.entry-footer'],
'p' => ['name' => 'Paragraph'],
'aside' => ['name' => 'Sidebar'],
'a' => ['name' => 'Link'],
'a-hover' => ['name' => 'Link Hover', 'sel' => 'a:hover'],
'h1' => ['name' => 'H1', 'key' => 'pagelayer_h1_typography'],
'h2' => ['name' => 'H2', 'key' => 'pagelayer_h2_typography'],
'h3' => ['name' => 'H3', 'key' => 'pagelayer_h3_typography'],
'h4' => ['name' => 'H4', 'key' => 'pagelayer_h4_typography'],
'h5' => ['name' => 'H5', 'key' => 'pagelayer_h5_typography'],
'h6' => ['name' => 'H6', 'key' => 'pagelayer_h6_typography'],
'b' => ['name' => 'Bold', 'sel' => 'strong, body.pagelayer-body b'],
'i' => ['name' => 'Italics', 'sel' => 'em, body.pagelayer-body i:not(.fa, .fas, .far, .fab)'],
];
$this->system_fonts = ['Arial', 'Arial Black', 'Courier', 'Georgia', 'Helvetica', 'impact', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana'];
$this->customizer_mods = get_option('pagelayer_customizer_mods', []);
$this->support = (defined('SITEPAD') ? 'http://sitepad.deskuss.com' : $this->support);
$this->typo_props = ['font-family', 'font-size', 'font-style', 'font-weight', 'font-variant', 'text-decoration-line', 'text-decoration-style', 'line-height', 'text-transform', 'letter-spacing', 'word-spacing'];
}
function default_font_styles( $args = array()){
$default_font_styles = [
'font-family' => 'Open Sans',
'font-size' => '',
'font-style' => '',
'font-variant' => '',
'font-weight' => '',
'letter-spacing' => '',
'line-height' => '',
'text-decoration-line' => '',
'text-decoration-style' => '',
'text-transform' => '',
'word-spacing' => ''
];
return array_merge($default_font_styles, $args);
}
function load_extra_languages(){
if(defined('SITEPAD')){
$this->l['email_desc'] = 'To change the email, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
$this->l['CMA_desc'] = 'To change text, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
}
}
}

View File

@@ -1,296 +1,296 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// custom_fonts.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
// This function will handle the custom fonts pages in PageLayer
add_action('init', 'pagelayer_custom_fonts_page', 9999);
function pagelayer_custom_fonts_page() {
global $pagelayer;
// Custom fonts supports
$supports = array(
'title', // post title
);
// Add custom fonts lables
$labels = array(
'name' => _x('Custom Fonts', 'plural'),
'singular_name' => _x('Custom Font', 'singular'),
'menu_name' => _x('Custom Fonts', 'admin menu'),
'name_admin_bar' => _x('Custom Fonts', 'admin bar'),
'add_new' => _x('Add New', 'Add'),
'add_new_item' => __('Add New'),
'new_item' => __('New Font'),
'edit_item' => __('Edit Font'),
'view_item' => __('View Font'),
'all_items' => __('All Fonts'),
'search_items' => __('Search Fonts'),
'not_found' => __('No Pagelayer custom fonts found'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => false,
'show_in_menu' => false,
'publicly_queryable' => true,
'show_ui' => true,
'exclude_from_search' => true,
'show_in_nav_menus' => false,
'has_archive' => false,
'rewrite' => false,
);
// Register custom post type
register_post_type(PAGELAYER_FONT_POST_TYPE, $args);
remove_post_type_support( PAGELAYER_FONT_POST_TYPE, 'editor');
}
// Removing extra columns
add_filter( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_columns', 'pagelayer_add_custom_columns' );
function pagelayer_add_custom_columns($columns){
unset( $columns['author'] );
unset( $columns['date'] );
$columns['pl-preview'] = __('Preview');
return $columns;
}
// Adding preview column data
add_action( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_custom_column' , 'pagelayer_add_custom_columns_data', 10, 2 );
function pagelayer_add_custom_columns_data( $column, $post_id ){
if($column == __('pl-preview')){
$font_link = get_post_meta( $post_id, 'pagelayer_font_link', true );
echo '<style>@font-face { font-family: "'.get_the_title($post_id).'"; src: url("'.wp_unslash( $font_link ).'"); }</style>';
echo '<span style="font-family:\''.get_the_title($post_id).'\'; font-size:16px" >Preview of the CUSTOM font</span>';
}
}
// Removing row actions
add_filter( 'post_row_actions', 'pagelayer_remove_row_actions', 10, 1 );
function pagelayer_remove_row_actions( $actions ){
if( get_post_type() === PAGELAYER_FONT_POST_TYPE ){
foreach($actions as $action => $html){
if($action == 'edit' || $action == 'trash' || $action == 'clone' || $action == 'untrash' || $action == 'delete'){
continue;
}else{
unset($actions[$action]);
}
}
}
return $actions;
}
// Removing Screen options
add_filter('screen_options_show_screen', 'pagelayer_remove_screen_options');
function pagelayer_remove_screen_options() {
if(get_post_type() == PAGELAYER_FONT_POST_TYPE) {
return false;
}
return true;
}
// Removing all other metaboxes.
add_action('admin_init', function() {pagelayer_remove_all_metaboxes(PAGELAYER_FONT_POST_TYPE);});
function pagelayer_remove_all_metaboxes($type) {
add_filter("get_user_option_meta-box-order_{$type}", function() use($type) {
global $wp_meta_boxes;
$publishbox = $wp_meta_boxes[$type]['side']['core']['submitdiv'];
$fontsBox = $wp_meta_boxes[$type]['normal']['default']['pl-fonts-link-box'];
$wp_meta_boxes[$type] = array(
'side' => array(
'core' => array(
'submitdiv' => $publishbox
)
),
'normal' => array(
'default' => array(
'pl-fonts-link-box' => $fontsBox
)
)
);
return array();
}, PHP_INT_MAX);
}
// Hiding extra options of publish metabox
add_action( 'admin_head', 'pagelayer_hide_publish_options' );
function pagelayer_hide_publish_options() {
if(get_post_type() == PAGELAYER_FONT_POST_TYPE){
echo '<style>.submitbox #minor-publishing{ display: none; }</style>';
}
}
// Adding source metabox
add_action('add_meta_boxes', 'pagelayer_add_meta_box');
function pagelayer_add_meta_box(){
add_meta_box( 'pl-fonts-link-box', _x('Source', 'font source'), 'pagelayer_font_link_metabox', PAGELAYER_FONT_POST_TYPE, 'normal', 'default', null);
}
function pagelayer_font_link_metabox($object){
wp_enqueue_media();
wp_nonce_field('pagelayer-font-post', 'pagelayer');
$link = get_post_meta($object->ID, 'pagelayer_font_link', true);
?>
<div>
<table width="100%">
<tr>
<th valign="top" style="text-align:right; padding-right:20px; width:20%;"><?php echo __('Font File');?> : </th>
<td>
<div>
<input type="text" class="pagelayer_font_input" id="pl_font_link" name="pagelayer_font_link" onclick="fontUpload(event)" style="width:70%" value="<?php echo wp_unslash($link); ?>" autocomplete="false" readonly="true"/>
<button type="button" class="button button-light" onclick="fontUpload(event)">Upload Font</button>
</div>
</td>
</tr>
</table>
</div>
<script>
window.onload = function(){
jQuery('#submitdiv').on('click', '#publish', function(e){
if(jQuery('#title').val()==''){
alert('Please insert title of the page');
return false;
}else{
if(jQuery('#pl_font_link').val()==''){
alert('Please insert link of the font');
return false;
}else{
return true;
}
}
});
}
function fontUpload(e){
var allowed_mime_type = ['.ttf', '.woff', '.woff2','.otf'];
var allClear = false;
var custom_uploader = wp.media({
title: 'Upload Font',
library : {
type : 'font'
},
button: {
text: 'Select Font' // button label text
},
multiple: false
}).on('select', function() { // it also has "open" and "close" events
var attachment = custom_uploader.state().get('selection').first().toJSON();
for(var i=0; i<allowed_mime_type.length; i++){
if(attachment['filename'].indexOf(allowed_mime_type[i]) != -1){
allClear=true;
break;
}
}
if(allClear){
jQuery('.pagelayer_font_input').val(attachment['url']);
}else{
alert('Kindly insert a correct font file. Allowed font file types are (otf|ttf|woff|woff2)');
}
}).open();
}
</script>
<?php }
// Saving source metabox content
add_action('save_post', 'pagelayer_save_source_meta_box', 10, 3);
function pagelayer_save_source_meta_box($post_id, $post, $update){
if(PAGELAYER_FONT_POST_TYPE != $post->post_type){
return $post_id;
}
// DO an admin referrer check
if(!empty($_POST)){
check_admin_referer('pagelayer-font-post', 'pagelayer');
}else{
return $post_id;
}
$meta_box_link_value = '';
if(isset($_POST['pagelayer_font_link'])){
$meta_box_link_value = wp_unslash($_POST['pagelayer_font_link']);
}
update_post_meta($post_id, 'pagelayer_font_link', $meta_box_link_value );
}
// Adding custom mime type
add_filter('upload_mimes', 'pagelayer_custom_mime_types', 1, 1);
function pagelayer_custom_mime_types($mime_types = array()){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
$mime_types[$key]=$value;
}
return $mime_types;
}
// Adding custom mime type
add_filter( 'mime_types', 'pagelayer_mime_types' );
function pagelayer_mime_types($default_mimes){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
$default_mimes[$key]=$value;
}
return $default_mimes;
}
// Adding custom mime type
add_filter( 'wp_check_filetype_and_ext', 'pagelayer_check_filetype_and_ext', 10, 5 );
function pagelayer_check_filetype_and_ext( $types, $file, $filename, $mimes, $real_mime = false ){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
if ( false !== strpos( $filename, '.'.$key ) ) {
$types['ext'] = $key;
$types['type'] = $value;
}
}
return $types;
}
// Removing notification.
add_filter( 'post_updated_messages', 'pagelayer_delete_notification' );
function pagelayer_delete_notification( $messages ){
if(get_post_type() == PAGELAYER_FONT_POST_TYPE){
unset($messages['post'][1]);
unset($messages['post'][6]);
return $messages;
}
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// custom_fonts.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
// This function will handle the custom fonts pages in PageLayer
add_action('init', 'pagelayer_custom_fonts_page', 9999);
function pagelayer_custom_fonts_page() {
global $pagelayer;
// Custom fonts supports
$supports = array(
'title', // post title
);
// Add custom fonts lables
$labels = array(
'name' => _x('Custom Fonts', 'plural'),
'singular_name' => _x('Custom Font', 'singular'),
'menu_name' => _x('Custom Fonts', 'admin menu'),
'name_admin_bar' => _x('Custom Fonts', 'admin bar'),
'add_new' => _x('Add New', 'Add'),
'add_new_item' => __('Add New'),
'new_item' => __('New Font'),
'edit_item' => __('Edit Font'),
'view_item' => __('View Font'),
'all_items' => __('All Fonts'),
'search_items' => __('Search Fonts'),
'not_found' => __('No Pagelayer custom fonts found'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => false,
'show_in_menu' => false,
'publicly_queryable' => true,
'show_ui' => true,
'exclude_from_search' => true,
'show_in_nav_menus' => false,
'has_archive' => false,
'rewrite' => false,
);
// Register custom post type
register_post_type(PAGELAYER_FONT_POST_TYPE, $args);
remove_post_type_support( PAGELAYER_FONT_POST_TYPE, 'editor');
}
// Removing extra columns
add_filter( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_columns', 'pagelayer_add_custom_columns' );
function pagelayer_add_custom_columns($columns){
unset( $columns['author'] );
unset( $columns['date'] );
$columns['pl-preview'] = __('Preview');
return $columns;
}
// Adding preview column data
add_action( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_custom_column' , 'pagelayer_add_custom_columns_data', 10, 2 );
function pagelayer_add_custom_columns_data( $column, $post_id ){
if($column == __('pl-preview')){
$font_link = get_post_meta( $post_id, 'pagelayer_font_link', true );
echo '<style>@font-face { font-family: "'.get_the_title($post_id).'"; src: url("'.wp_unslash( $font_link ).'"); }</style>';
echo '<span style="font-family:\''.get_the_title($post_id).'\'; font-size:16px" >Preview of the CUSTOM font</span>';
}
}
// Removing row actions
add_filter( 'post_row_actions', 'pagelayer_remove_row_actions', 10, 1 );
function pagelayer_remove_row_actions( $actions ){
if( get_post_type() === PAGELAYER_FONT_POST_TYPE ){
foreach($actions as $action => $html){
if($action == 'edit' || $action == 'trash' || $action == 'clone' || $action == 'untrash' || $action == 'delete'){
continue;
}else{
unset($actions[$action]);
}
}
}
return $actions;
}
// Removing Screen options
add_filter('screen_options_show_screen', 'pagelayer_remove_screen_options');
function pagelayer_remove_screen_options() {
if(get_post_type() == PAGELAYER_FONT_POST_TYPE) {
return false;
}
return true;
}
// Removing all other metaboxes.
add_action('admin_init', function() {pagelayer_remove_all_metaboxes(PAGELAYER_FONT_POST_TYPE);});
function pagelayer_remove_all_metaboxes($type) {
add_filter("get_user_option_meta-box-order_{$type}", function() use($type) {
global $wp_meta_boxes;
$publishbox = $wp_meta_boxes[$type]['side']['core']['submitdiv'];
$fontsBox = $wp_meta_boxes[$type]['normal']['default']['pl-fonts-link-box'];
$wp_meta_boxes[$type] = array(
'side' => array(
'core' => array(
'submitdiv' => $publishbox
)
),
'normal' => array(
'default' => array(
'pl-fonts-link-box' => $fontsBox
)
)
);
return array();
}, PHP_INT_MAX);
}
// Hiding extra options of publish metabox
add_action( 'admin_head', 'pagelayer_hide_publish_options' );
function pagelayer_hide_publish_options() {
if(get_post_type() == PAGELAYER_FONT_POST_TYPE){
echo '<style>.submitbox #minor-publishing{ display: none; }</style>';
}
}
// Adding source metabox
add_action('add_meta_boxes', 'pagelayer_add_meta_box');
function pagelayer_add_meta_box(){
add_meta_box( 'pl-fonts-link-box', _x('Source', 'font source'), 'pagelayer_font_link_metabox', PAGELAYER_FONT_POST_TYPE, 'normal', 'default', null);
}
function pagelayer_font_link_metabox($object){
wp_enqueue_media();
wp_nonce_field('pagelayer-font-post', 'pagelayer');
$link = get_post_meta($object->ID, 'pagelayer_font_link', true);
?>
<div>
<table width="100%">
<tr>
<th valign="top" style="text-align:right; padding-right:20px; width:20%;"><?php echo __('Font File');?> : </th>
<td>
<div>
<input type="text" class="pagelayer_font_input" id="pl_font_link" name="pagelayer_font_link" onclick="fontUpload(event)" style="width:70%" value="<?php echo wp_unslash($link); ?>" autocomplete="false" readonly="true"/>
<button type="button" class="button button-light" onclick="fontUpload(event)">Upload Font</button>
</div>
</td>
</tr>
</table>
</div>
<script>
window.onload = function(){
jQuery('#submitdiv').on('click', '#publish', function(e){
if(jQuery('#title').val()==''){
alert('Please insert title of the page');
return false;
}else{
if(jQuery('#pl_font_link').val()==''){
alert('Please insert link of the font');
return false;
}else{
return true;
}
}
});
}
function fontUpload(e){
var allowed_mime_type = ['.ttf', '.woff', '.woff2','.otf'];
var allClear = false;
var custom_uploader = wp.media({
title: 'Upload Font',
library : {
type : 'font'
},
button: {
text: 'Select Font' // button label text
},
multiple: false
}).on('select', function() { // it also has "open" and "close" events
var attachment = custom_uploader.state().get('selection').first().toJSON();
for(var i=0; i<allowed_mime_type.length; i++){
if(attachment['filename'].indexOf(allowed_mime_type[i]) != -1){
allClear=true;
break;
}
}
if(allClear){
jQuery('.pagelayer_font_input').val(attachment['url']);
}else{
alert('Kindly insert a correct font file. Allowed font file types are (otf|ttf|woff|woff2)');
}
}).open();
}
</script>
<?php }
// Saving source metabox content
add_action('save_post', 'pagelayer_save_source_meta_box', 10, 3);
function pagelayer_save_source_meta_box($post_id, $post, $update){
if(PAGELAYER_FONT_POST_TYPE != $post->post_type){
return $post_id;
}
// DO an admin referrer check
if(!empty($_POST)){
check_admin_referer('pagelayer-font-post', 'pagelayer');
}else{
return $post_id;
}
$meta_box_link_value = '';
if(isset($_POST['pagelayer_font_link'])){
$meta_box_link_value = wp_unslash($_POST['pagelayer_font_link']);
}
update_post_meta($post_id, 'pagelayer_font_link', $meta_box_link_value );
}
// Adding custom mime type
add_filter('upload_mimes', 'pagelayer_custom_mime_types', 1, 1);
function pagelayer_custom_mime_types($mime_types = array()){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
$mime_types[$key]=$value;
}
return $mime_types;
}
// Adding custom mime type
add_filter( 'mime_types', 'pagelayer_mime_types' );
function pagelayer_mime_types($default_mimes){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
$default_mimes[$key]=$value;
}
return $default_mimes;
}
// Adding custom mime type
add_filter( 'wp_check_filetype_and_ext', 'pagelayer_check_filetype_and_ext', 10, 5 );
function pagelayer_check_filetype_and_ext( $types, $file, $filename, $mimes, $real_mime = false ){
global $pagelayer;
forEach($pagelayer->allowed_mime_type as $key => $value){
if ( false !== strpos( $filename, '.'.$key ) ) {
$types['ext'] = $key;
$types['type'] = $value;
}
}
return $types;
}
// Removing notification.
add_filter( 'post_updated_messages', 'pagelayer_delete_notification' );
function pagelayer_delete_notification( $messages ){
if(get_post_type() == PAGELAYER_FONT_POST_TYPE){
unset($messages['post'][1]);
unset($messages['post'][6]);
return $messages;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,261 +1,261 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// getting_started.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
$app = (!defined('SITEPAD') ? 'Pagelayer' : BRAND_SM);
?>
<link rel="stylesheet" href="<?php echo PAGELAYER_CSS.'/font-awesome5.min.css';?>">
<div class="pagelayer-getting-started">
<div class="pagelayer-getting-started-container">
<div class="pagelayer-getting-started-block">
<div class="pagelayer-getting-started-logo">
<?php echo (!defined('SITEPAD')) ? '<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-256.png'.'"/>' : '<img src="'.BRAND_SM_LOGO.'" style="width:auto"/>' ?>
</div>
<div class="pagelayer-getting-started-desc">
<h1><?php echo __pl('welcome_to').$app;?></h1>
<h6><?php echo (!defined('SITEPAD')) ? __pl('choose_pagelayer') : __pl('choose_sitepad');?></h6>
</div>
<div class="pagelayer-getting-started-video">
<?php echo (!defined('SITEPAD')) ? '<iframe width="700" height="400" src="https://www.youtube.com/embed/t8Iz-v-qce8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' : '<iframe height="400" width="700" src="https://www.youtube.com/embed/8e3ROkKoFwA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';?>
</div>
<div class="pagelayer-getting-started-desc">
<h6><?php echo (!defined('SITEPAD')) ? __pl('pagelayer_desc') : __pl('sitepad_desc');?></h6>
<div class="pagelayer-getting-started-btn">
<a href="<?php echo admin_url('/post-new.php?post_type=page')?>" class="button button-primary btn-sc"><?php echo __pl('first_page');?></a>
<a href="<?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL.'getting-started' : "https://sitepad.com/docs/getting-started/"; ?>" class="button button-secondary btn-sc" target="_blank"><?php echo __pl('watch_guide');?></a>
</div>
</div>
</div>
<div class="pagelayer-features">
<div class="pagelayer-getting-started-desc">
<h1><?php echo $app.' '.__pl('feature_style');?></h1>
<h6><?php echo $app.__pl('brand_feature_text');?></h6>
<div class="pagelayer-features-list">
<?php $style = (defined('SITEPAD')) ? 'style="width:30%; height: 265px"' : ''; ?>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fas fa-mouse-pointer" aria-hidden="true">' : '<i class="fas fa-paper-plane" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('dragdrop') : __pl('oneclick')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('dragdrop_desc') : __pl('oneclick_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-th-list" aria-hidden="true">' : '<i class="fas fa-random" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('widgets') : __pl('static_pages')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('widgets_desc') : __pl('static_pages_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-pencil" aria-hidden="true">' : '<i class="fas fa-mobile-alt" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('inline_edit') : __pl('responsive_styles')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('inline_edit_desc') : __pl('responsive_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-clone" aria-hidden="true">' : '<i class="fas fa-share-square" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('duplicate') : __pl('social_media')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('duplicate_desc') : __pl('social_media_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-snowflake-o fa-spin" aria-hidden="true">' : '<i class="fas fa-check" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('animation') : __pl('easy_use')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('animation_desc') : __pl('easy_use_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-text-width" aria-hidden="true">' : '<i class="fas fa-cog" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('style_option') : __pl('cpanel_integrate')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('style_option_desc') : __pl('cpanel_integrate_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-paint-brush" aria-hidden="true">' : '<i class="fas fa-th-large" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('real_design') : __pl('multisites')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('real_design_desc') : __pl('multisites_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-font" aria-hidden="true">' : '<i class="fas fa-copy" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('typography') : __pl('replicate_obj')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('typography_desc') : __pl('replicate_obj_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-cubes" aria-hidden="true">' : '<i class="fas fa-shopping-cart" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('easy_customize') : __pl('whmcs')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('easy_customize_desc') : __pl('whmcs_desc');?></p>
</div>
</div>
<div class="pagelayer-getting-started-btn">
<a href=" <?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL : "http://sitepad.com/"?>" class="button button-secondary btn-sc" target="_blank" style="margin-top:20px;"><?php echo __pl('why').' '.$app.'?';?></a>
</div>
</div>
</div>
</div>
</div>
<style>
.pagelayer-getting-started{
padding-top: 50px;
}
.pagelayer-getting-started-container{
margin: 0 auto;
max-width: 1000px;
padding: 0;
text-align: center;
}
.pagelayer-getting-started-block{
background-color: #fff;
border: 2px solid #e1e1e1;
border-radius: 2px;
margin-bottom: 30px;
position: relative;
padding-top: 40px;
}
.pagelayer-getting-started-logo img{
width: 10%;
height: auto;
}
.pagelayer-getting-started-desc{
padding: 40px;
}
.pagelayer-getting-started-desc h1{
color: #222;
font-size: 24px;
margin: 0 0 24px 0;
}
.pagelayer-getting-started-desc h6{
font-size: 16px;
font-weight: 400;
line-height: 1.6;
margin: 0 85px 0 85px;
}
.pagelayer-getting-started-btn{
max-width: 600px;
margin: 0 auto 0 auto;
margin-top: 36px !important;
}
.btn-sc{
font-size: 14px !important;
min-height: 46px !important;
line-height: 3.14285714 ! important;
padding: 0px 36px !important;
}
.button-primary{
margin-right: 20px !important;
border-radius: 3px !important;
}
.pagelayer-features{
background-color: #fff;
border: 2px solid #e1e1e1;
border-radius: 2px 2px 0 0;
position: relative;
}
.feature-block-card{
width: 25%;
display: inline-block;
margin: 60px 10px 0 10px;
vertical-align: top;
box-shadow: 0px 0px 20px 0px rgba(0,0,0,.1);
padding: 20px;
height: 220px;
}
.feature-block{
background: linear-gradient(to right, rgb(116, 116, 191), rgb(52, 138, 199));
border-radius: 50%;
width: 54px;
height: 54px;
position: relative;
display: inline-block;
}
.feature-block i{
font-size: 30px;
color: #fff;
position: absolute;
top: 13px;
left: 0;
right: 0;
}
.feature-block-content h5{
color: #222;
font-size: 20px;
margin: 10px 0 0 0;
}
.feature-block-content p{
color: #222;
font-size: 16px;
margin-top: 10px;
}
.fa-spin{
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// getting_started.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
$app = (!defined('SITEPAD') ? 'Pagelayer' : BRAND_SM);
?>
<link rel="stylesheet" href="<?php echo PAGELAYER_CSS.'/font-awesome5.min.css';?>">
<div class="pagelayer-getting-started">
<div class="pagelayer-getting-started-container">
<div class="pagelayer-getting-started-block">
<div class="pagelayer-getting-started-logo">
<?php echo (!defined('SITEPAD')) ? '<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-256.png'.'"/>' : '<img src="'.BRAND_SM_LOGO.'" style="width:auto"/>' ?>
</div>
<div class="pagelayer-getting-started-desc">
<h1><?php echo __pl('welcome_to').$app;?></h1>
<h6><?php echo (!defined('SITEPAD')) ? __pl('choose_pagelayer') : __pl('choose_sitepad');?></h6>
</div>
<div class="pagelayer-getting-started-video">
<?php echo (!defined('SITEPAD')) ? '<iframe width="700" height="400" src="https://www.youtube.com/embed/t8Iz-v-qce8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' : '<iframe height="400" width="700" src="https://www.youtube.com/embed/8e3ROkKoFwA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';?>
</div>
<div class="pagelayer-getting-started-desc">
<h6><?php echo (!defined('SITEPAD')) ? __pl('pagelayer_desc') : __pl('sitepad_desc');?></h6>
<div class="pagelayer-getting-started-btn">
<a href="<?php echo admin_url('/post-new.php?post_type=page')?>" class="button button-primary btn-sc"><?php echo __pl('first_page');?></a>
<a href="<?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL.'getting-started' : "https://sitepad.com/docs/getting-started/"; ?>" class="button button-secondary btn-sc" target="_blank"><?php echo __pl('watch_guide');?></a>
</div>
</div>
</div>
<div class="pagelayer-features">
<div class="pagelayer-getting-started-desc">
<h1><?php echo $app.' '.__pl('feature_style');?></h1>
<h6><?php echo $app.__pl('brand_feature_text');?></h6>
<div class="pagelayer-features-list">
<?php $style = (defined('SITEPAD')) ? 'style="width:30%; height: 265px"' : ''; ?>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fas fa-mouse-pointer" aria-hidden="true">' : '<i class="fas fa-paper-plane" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('dragdrop') : __pl('oneclick')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('dragdrop_desc') : __pl('oneclick_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-th-list" aria-hidden="true">' : '<i class="fas fa-random" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('widgets') : __pl('static_pages')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('widgets_desc') : __pl('static_pages_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-pencil" aria-hidden="true">' : '<i class="fas fa-mobile-alt" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('inline_edit') : __pl('responsive_styles')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('inline_edit_desc') : __pl('responsive_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-clone" aria-hidden="true">' : '<i class="fas fa-share-square" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('duplicate') : __pl('social_media')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('duplicate_desc') : __pl('social_media_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-snowflake-o fa-spin" aria-hidden="true">' : '<i class="fas fa-check" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('animation') : __pl('easy_use')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('animation_desc') : __pl('easy_use_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-text-width" aria-hidden="true">' : '<i class="fas fa-cog" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('style_option') : __pl('cpanel_integrate')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('style_option_desc') : __pl('cpanel_integrate_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-paint-brush" aria-hidden="true">' : '<i class="fas fa-th-large" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('real_design') : __pl('multisites')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('real_design_desc') : __pl('multisites_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-font" aria-hidden="true">' : '<i class="fas fa-copy" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('typography') : __pl('replicate_obj')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('typography_desc') : __pl('replicate_obj_desc');?></p>
</div>
</div>
<div class="feature-block-card" <?php echo $style; ?>>
<div class="feature-block">
<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-cubes" aria-hidden="true">' : '<i class="fas fa-shopping-cart" aria-hidden="true">' ?></i>
</div>
<div class="feature-block-content">
<h5><?php echo (!defined('SITEPAD')) ? __pl('easy_customize') : __pl('whmcs')?></h5>
<p><?php echo (!defined('SITEPAD')) ? __pl('easy_customize_desc') : __pl('whmcs_desc');?></p>
</div>
</div>
<div class="pagelayer-getting-started-btn">
<a href=" <?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL : "http://sitepad.com/"?>" class="button button-secondary btn-sc" target="_blank" style="margin-top:20px;"><?php echo __pl('why').' '.$app.'?';?></a>
</div>
</div>
</div>
</div>
</div>
<style>
.pagelayer-getting-started{
padding-top: 50px;
}
.pagelayer-getting-started-container{
margin: 0 auto;
max-width: 1000px;
padding: 0;
text-align: center;
}
.pagelayer-getting-started-block{
background-color: #fff;
border: 2px solid #e1e1e1;
border-radius: 2px;
margin-bottom: 30px;
position: relative;
padding-top: 40px;
}
.pagelayer-getting-started-logo img{
width: 10%;
height: auto;
}
.pagelayer-getting-started-desc{
padding: 40px;
}
.pagelayer-getting-started-desc h1{
color: #222;
font-size: 24px;
margin: 0 0 24px 0;
}
.pagelayer-getting-started-desc h6{
font-size: 16px;
font-weight: 400;
line-height: 1.6;
margin: 0 85px 0 85px;
}
.pagelayer-getting-started-btn{
max-width: 600px;
margin: 0 auto 0 auto;
margin-top: 36px !important;
}
.btn-sc{
font-size: 14px !important;
min-height: 46px !important;
line-height: 3.14285714 ! important;
padding: 0px 36px !important;
}
.button-primary{
margin-right: 20px !important;
border-radius: 3px !important;
}
.pagelayer-features{
background-color: #fff;
border: 2px solid #e1e1e1;
border-radius: 2px 2px 0 0;
position: relative;
}
.feature-block-card{
width: 25%;
display: inline-block;
margin: 60px 10px 0 10px;
vertical-align: top;
box-shadow: 0px 0px 20px 0px rgba(0,0,0,.1);
padding: 20px;
height: 220px;
}
.feature-block{
background: linear-gradient(to right, rgb(116, 116, 191), rgb(52, 138, 199));
border-radius: 50%;
width: 54px;
height: 54px;
position: relative;
display: inline-block;
}
.feature-block i{
font-size: 30px;
color: #fff;
position: absolute;
top: 13px;
left: 0;
right: 0;
}
.feature-block-content h5{
color: #222;
font-size: 20px;
margin: 10px 0 0 0;
}
.feature-block-content p{
color: #222;
font-size: 16px;
margin-top: 10px;
}
.fa-spin{
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -1,200 +1,200 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// license.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
include_once(PAGELAYER_DIR.'/main/settings.php');
// The License Page
function pagelayer_license(){
global $pl_error;
if(!empty($_REQUEST['install_pro'])){
pagelayer_install_pro();
return;
}
if(isset($_REQUEST['save_pl_license'])){
check_admin_referer('pagelayer-options');
}
// Is there a license key ?
if(isset($_POST['save_pl_license'])){
$license = pagelayer_optpost('pagelayer_license');
// Check if its a valid license
if(empty($license)){
$pl_error['lic_invalid'] = __('The license key was not submitted', 'pagelayer');
return pagelayer_license_T();
}
$resp = wp_remote_get(PAGELAYER_API.'license.php?license='.$license, array('timeout' => 30));
if(is_array($resp)){
$json = json_decode($resp['body'], true);
//print_r($json);
}else{
$pl_error['resp_invalid'] = __('The response was malformed<br>'.var_export($resp, true), 'pagelayer');
return pagelayer_license_T();
}
// Save the License
if(empty($json['license'])){
$pl_error['lic_invalid'] = __('The license key is invalid', 'pagelayer');
return pagelayer_license_T();
}else{
update_option('pagelayer_license', $json);
// Load license
pagelayer_load_license();
// Mark as saved
$GLOBALS['pl_saved'] = true;
}
}
pagelayer_license_T();
}
// The License Page - THEME
function pagelayer_license_T(){
global $pagelayer, $pl_error;
pagelayer_page_header('Pagelayer License');
// Saved ?
if(!empty($GLOBALS['pl_saved'])){
echo '<div class="notice notice-success"><p>'. __('The settings were saved successfully', 'pagelayer'). '</p></div><br />';
}
// If the license is active and you are the free version, then suggest to install the pro
if(!empty($pagelayer->license['status']) && !defined('PAGELAYER_PREMIUM') && empty($_REQUEST['install_pro'])){
echo '<div class="updated"><p>'. __('You have activated the license, but are using the Free version ! <a href="'.admin_url('admin.php?page=pagelayer_license&install_pro=1').'" class="button button-primary">Install Pro Now</a>', 'pagelayer'). '</p></div><br />';
}
if(date('Ymd') <= 20200331 && !defined('PAGELAYER_PREMIUM')){
echo '<div class="updated"><p><span style="font-size: 14px"><b>Promotional Offer</b></span> : If you buy <a href="'.PAGELAYER_PRO_URL.'"><b>Pagelayer Pro</b></a> before <b>31st March, 2020</b> then you will get an additional year free and your license will expire on <b>31st March, 2022</b></p></div><br />.';
}
// Any errors ?
if(!empty($pl_error)){
pagelayer_report_error($pl_error);echo '<br />';
}
?>
<div class="postbox">
<button class="handlediv button-link" aria-expanded="true" type="button">
<span class="screen-reader-text"><?php _e('Toggle panel: System Information');?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
<h2 class="hndle ui-sortable-handle">
<span><?php echo __('System Information', 'pagelayer'); ?></span>
</h2>
<div class="inside">
<form action="" method="post" enctype="multipart/form-data">
<?php wp_nonce_field('pagelayer-options'); ?>
<table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
<?php
echo '
<tr>
<th align="left" width="25%">'.__('Pagelayer Version', 'pagelayer').'</th>
<td>'.PAGELAYER_VERSION.(defined('PAGELAYER_PREMIUM') ? ' (PRO Version)' : '').'</td>
</tr>';
echo '
<tr>
<th align="left" valign="top">'.__('Pagelayer License', 'pagelayer').'</th>
<td align="left">
'.(defined('PAGELAYER_PREMIUM') && empty($pagelayer->license) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
<input type="text" name="pagelayer_license" value="'.(empty($pagelayer->license) ? '' : $pagelayer->license['license']).'" size="30" placeholder="e.g. PAGEL-11111-22222-33333-44444" style="width:300px;" /> &nbsp;
<input name="save_pl_license" class="button button-primary" value="Update License" type="submit" />';
if(!empty($pagelayer->license)){
$expires = $pagelayer->license['expires'];
$expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
echo '<div style="margin-top:10px;">License Status : '.(empty($pagelayer->license['status_txt']) ? 'N.A.' : $pagelayer->license['status_txt']).' &nbsp; &nbsp; &nbsp;
License Expires : '.($pagelayer->license['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
</div>';
}
echo
'</td>
</tr>';
echo '<tr>
<th align="left">'.__('URL', 'pagelayer').'</th>
<td>'.get_site_url().'</td>
</tr>
<tr>
<th align="left">'.__('Path', 'pagelayer').'</th>
<td>'.ABSPATH.'</td>
</tr>
<tr>
<th align="left">'.__('Server\'s IP Address', 'pagelayer').'</th>
<td>'.$_SERVER['SERVER_ADDR'].'</td>
</tr>
<tr>
<th align="left">'.__('wp-config.php is writable', 'pagelayer').'</th>
<td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
</tr>';
if(file_exists(ABSPATH.'/.htaccess')){
echo '
<tr>
<th align="left">'.__('.htaccess is writable', 'pagelayer').'</th>
<td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
</tr>';
}
?>
</table>
</form>
</div>
</div>
<?php
pagelayer_page_footer();
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// license.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
include_once(PAGELAYER_DIR.'/main/settings.php');
// The License Page
function pagelayer_license(){
global $pl_error;
if(!empty($_REQUEST['install_pro'])){
pagelayer_install_pro();
return;
}
if(isset($_REQUEST['save_pl_license'])){
check_admin_referer('pagelayer-options');
}
// Is there a license key ?
if(isset($_POST['save_pl_license'])){
$license = pagelayer_optpost('pagelayer_license');
// Check if its a valid license
if(empty($license)){
$pl_error['lic_invalid'] = __('The license key was not submitted', 'pagelayer');
return pagelayer_license_T();
}
$resp = wp_remote_get(PAGELAYER_API.'license.php?license='.$license, array('timeout' => 30));
if(is_array($resp)){
$json = json_decode($resp['body'], true);
//print_r($json);
}else{
$pl_error['resp_invalid'] = __('The response was malformed<br>'.var_export($resp, true), 'pagelayer');
return pagelayer_license_T();
}
// Save the License
if(empty($json['license'])){
$pl_error['lic_invalid'] = __('The license key is invalid', 'pagelayer');
return pagelayer_license_T();
}else{
update_option('pagelayer_license', $json);
// Load license
pagelayer_load_license();
// Mark as saved
$GLOBALS['pl_saved'] = true;
}
}
pagelayer_license_T();
}
// The License Page - THEME
function pagelayer_license_T(){
global $pagelayer, $pl_error;
pagelayer_page_header('Pagelayer License');
// Saved ?
if(!empty($GLOBALS['pl_saved'])){
echo '<div class="notice notice-success"><p>'. __('The settings were saved successfully', 'pagelayer'). '</p></div><br />';
}
// If the license is active and you are the free version, then suggest to install the pro
if(!empty($pagelayer->license['status']) && !defined('PAGELAYER_PREMIUM') && empty($_REQUEST['install_pro'])){
echo '<div class="updated"><p>'. __('You have activated the license, but are using the Free version ! <a href="'.admin_url('admin.php?page=pagelayer_license&install_pro=1').'" class="button button-primary">Install Pro Now</a>', 'pagelayer'). '</p></div><br />';
}
if(date('Ymd') <= 20200331 && !defined('PAGELAYER_PREMIUM')){
echo '<div class="updated"><p><span style="font-size: 14px"><b>Promotional Offer</b></span> : If you buy <a href="'.PAGELAYER_PRO_URL.'"><b>Pagelayer Pro</b></a> before <b>31st March, 2020</b> then you will get an additional year free and your license will expire on <b>31st March, 2022</b></p></div><br />.';
}
// Any errors ?
if(!empty($pl_error)){
pagelayer_report_error($pl_error);echo '<br />';
}
?>
<div class="postbox">
<button class="handlediv button-link" aria-expanded="true" type="button">
<span class="screen-reader-text"><?php _e('Toggle panel: System Information');?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
<h2 class="hndle ui-sortable-handle">
<span><?php echo __('System Information', 'pagelayer'); ?></span>
</h2>
<div class="inside">
<form action="" method="post" enctype="multipart/form-data">
<?php wp_nonce_field('pagelayer-options'); ?>
<table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
<?php
echo '
<tr>
<th align="left" width="25%">'.__('Pagelayer Version', 'pagelayer').'</th>
<td>'.PAGELAYER_VERSION.(defined('PAGELAYER_PREMIUM') ? ' (PRO Version)' : '').'</td>
</tr>';
echo '
<tr>
<th align="left" valign="top">'.__('Pagelayer License', 'pagelayer').'</th>
<td align="left">
'.(defined('PAGELAYER_PREMIUM') && empty($pagelayer->license) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
<input type="text" name="pagelayer_license" value="'.(empty($pagelayer->license) ? '' : $pagelayer->license['license']).'" size="30" placeholder="e.g. PAGEL-11111-22222-33333-44444" style="width:300px;" /> &nbsp;
<input name="save_pl_license" class="button button-primary" value="Update License" type="submit" />';
if(!empty($pagelayer->license)){
$expires = $pagelayer->license['expires'];
$expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
echo '<div style="margin-top:10px;">License Status : '.(empty($pagelayer->license['status_txt']) ? 'N.A.' : $pagelayer->license['status_txt']).' &nbsp; &nbsp; &nbsp;
License Expires : '.($pagelayer->license['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
</div>';
}
echo
'</td>
</tr>';
echo '<tr>
<th align="left">'.__('URL', 'pagelayer').'</th>
<td>'.get_site_url().'</td>
</tr>
<tr>
<th align="left">'.__('Path', 'pagelayer').'</th>
<td>'.ABSPATH.'</td>
</tr>
<tr>
<th align="left">'.__('Server\'s IP Address', 'pagelayer').'</th>
<td>'.$_SERVER['SERVER_ADDR'].'</td>
</tr>
<tr>
<th align="left">'.__('wp-config.php is writable', 'pagelayer').'</th>
<td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
</tr>';
if(file_exists(ABSPATH.'/.htaccess')){
echo '
<tr>
<th align="left">'.__('.htaccess is writable', 'pagelayer').'</th>
<td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
</tr>';
}
?>
</table>
</form>
</div>
</div>
<?php
pagelayer_page_footer();
}

View File

@@ -1,283 +1,283 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
function pagelayer_live_body(){
global $post, $pagelayer;
$icons = pagelayer_enabled_icons();
$icons_list = array();
// Load all icons
foreach($icons as $icon){
$icons_list[] = $icon.'.min.css';
}
$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
if(pagelayer_enable_giver()){
$css_url = PAGELAYER_CSS.'/givecss.php?';
}
$dark_mode = get_option('pagelayer_enable_dark_mode');
$body_class = '';
if(!empty($dark_mode)){
$body_class = 'pagelayer-dark';
};
if(defined('SITEPAD')){
$body_class .= ' sitepad-body';
}
$shortcut_groups = [
'general_shortcuts' => [
'undo' => 'Ctrl+Z',
'redo' => 'Ctrl+Y',
'save_post' => 'Ctrl+S',
'copy_widget' => 'Ctrl+C',
'paste_widget' => 'Ctrl+V',
'duplicate_widget' => 'Ctrl+D',
'delete_widget' => 'Delete'
]
];
echo '
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<link rel="stylesheet" href="'.$css_url.'give=pagelayer-editor.css,trumbowyg.min.css,pagelayer-icons.css,'.implode(',' ,$icons_list).'&ver='.PAGELAYER_VERSION.'">';
do_action('pagelayer_live_body_head');
// Brand Name
$brand = strtoupper($pagelayer->BRAND_TEXT);
$brand = str_split($brand);
echo '
<style>
/*Set responsive variables*/
.pagelayer-screen-tablet{
width: '. $pagelayer->settings['tablet_breakpoint'] .'px;
}
.pagelayer-screen-mobile{
width: '. $pagelayer->settings['mobile_breakpoint'] .'px;
}
.pagelayer-errorBox-support{
text-decoration:none;
}
</style>
</head>
<body class="pagelayer-normalize pagelayer-body '.$body_class.'">
<div class="pagelayer-errorBox">
<div class="pagelayer-errorBox-close"><i class="fas fa-times"></i></div>
<div class="pagelayer-errorBox-main">
<h2><i class="fas fa-times"></i>'.__pl('error').'</h2>
<div class="pagelayer-errorBox-content"></div>
</div>
<div class="pagelayer-errorBox-resolve">
<p>'.__pl('error_submitting').'</p>
<button type="button" class="pagelayer-errorBox-copy" onclick="pagelayer_copy_error(event)">'.__pl('copy').'</button>
<a type="button" class="pagelayer-errorBox-support" href="'. $pagelayer->support .'" target="_bank">'.__pl('support').'</a>
</div>
</div>
<div id="pagelayer-loader-wrapper">
<div class="pagelayer-animation-section">
<div class="pagelayer-loader">
<div class="pagelayer-percent-parent">
<div class="pagelayer-percent">10<sup>%</sup></div>
</div>
</div>
<div class="pagelayer-txt-loading">';
foreach($brand as $k => $v){
echo '<span data-text-preloader="'.$v.'" class="letters-loading">'.$v.'</span>';
}
echo '</div>
</div>
</div>
<table class="pagelayer-normalize pagelayer-body-table" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="270" class="pagelayer-leftbar-table">
<table class="pagelayer-normalize" cellpadding="0" cellspacing="0">
<tr class="pagelayer-close-bar">
<td>
<div class="pagelayer-close-bar-icons">
<i class="pagelayer-leftbar-minimize fa fa-minus"></i>
<i class="pagelayer-leftbar-close fa fa-close"></i>
</div>
</td>
</tr>
<tr height="45">
<td class="pagelayer-topbar-holder" valign="middle" align="center">
<span class="pagelayer-options-icon pli pli-menu"></span>
<div class="pagelayer-elpd-header" style="display:none">
<div class="pagelayer-elpd-close"><i class="pli pli-cross" aria-hidden="true"></i></div>
<div class="pagelayer-elpd-title pagelayer-topbar-mover">Edit</div>
</div>
<div class="pagelayer-logo">
<img src="'.$pagelayer->LOGO.'" width="28" /><span class="pagelayer-logo-text pagelayer-topbar-mover">'.$pagelayer->BRAND_TEXT.(defined('PAGELAYER_PREMIUM') && strtolower($pagelayer->BRAND_TEXT) == 'pagelayer' ? '<sup style="margin: 3px; font-size: 12px; letter-spacing: 1px; font-family: "Roboto";">Pro</sup>' : '').'</span>
<span class="pagelayer-settings-icon pli pli-service" aria-hidden="true"></span>
</div>
</td>
</tr>
<tr height="*" valign="top">
<td style="position: relative;"><div class="pagelayer-leftbar-holder"></div></td>
</tr>
<tr height="35" class="pagelayer-bottombar-row">
<td><div class="pagelayer-bottombar-holder"></div></td>
</tr>
</table>
<div class="pagelayer-leftbar-toggle">&lsaquo;</div>
</td>
<td class="pagelayer-iframe" valign="top">
<div class="pagelayer-iframe-top-bar">';
do_action('pagelayer_iframe_top_bar');
echo '
</div>
<div class="pagelayer-iframe-holder">
<iframe src="'.(pagelayer_shortlink(0).'&pagelayer-iframe=1&'.$_SERVER['QUERY_STRING']).'" class="pagelayer-normalize skip-lazy" id="pagelayer-iframe"></iframe>
</div>
</td>
</tr>
</table>
<div class="pagelayer-pro-notice">';
pagelayer_show_pro_div('Premium Feature<span class="pli pli-cross pagelayer-pro-x"></span>', '', 0);
echo '</div>
<div class="pagelayer-editor-notice"></div>
<div class="pagelayer-props-modal">
<div class="pagelayer-props-holder">
<div class="pagelayer-props-wrap">
<div class="pagelayer-props-loading-screen"></div>
<i class="pagelayer-props-modal-close pli pli-cross" aria-hidden="true"></i>
</div>
</div>
</div>
<script>
var pagelayer_iframe_cw = document.getElementById("pagelayer-iframe").contentWindow;
var start_time = new Date().getTime();
// Show loading progress
function loader(ran) {
var inner = document.getElementsByClassName("pagelayer-percent")[0];
var w = 0;
var t = setInterval(function() {
w = w + 1;
inner.innerHTML = (w+"<sup>%</sup>");
if (w === ran || inner.getAttribute("loaded") == "1"){
clearInterval(t);
w = 0;
}
}, 50);
}
loader(90);
function $p(sel){
return pagelayer_iframe_cw.pagelayer.$$(sel);
}
// Load the window if necessary i.e. an error in the JS of the iframe
function onIframeLoad(){
setTimeout(function(){
force_pagelayer_start();
}, 5000);
}
function force_pagelayer_start(){
try{
if(pagelayer_iframe_cw.pagelayer.loaded == 1){
return;
}
pagelayer_iframe_cw.pagelayer_start();
var end_time = new Date().getTime();
var diff = (end_time - start_time) / 1000;
console.log("['.$pagelayer->BRAND_TEXT.'] Live Body had to load after : "+diff+" seconds");
// If this fails, lets just hide the loader
}catch(e){
alert("Fatal error within the '.$pagelayer->BRAND_TEXT.' iFrame as pagelayer object not found ! Please contact '.$pagelayer->BRAND_TEXT.' support");
document.getElementById("pagelayer-loader-wrapper").remove();
}
}
document.getElementById("pagelayer-iframe").onload = onIframeLoad;
// ErrorBox content copy function
function pagelayer_copy_error(){
var tempInput = document.createElement("textarea");
tempInput.value = document.querySelector(".pagelayer-errorBox-content").innerText;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("'.__pl('copy_success').'");
}
</script>
<div class="pagelayer-editor-modal pagelayer-shortcuts-modal">
<div class="pagelayer-editor-modal-wrap">
<div class="pagelayer-editor-modal-header">
<h2>'.__pl('keyboard_shortcuts').'</h2>
<span class="pagelayer-editor-modal-close-icon"><i class="fas fa-times"></i></span>
</div>
<div class="pagelayer-editor-modal-body">';
foreach($shortcut_groups as $grp_name => $group){
if(empty($group)) {
return;
}
echo '<div class="pagelayer-edt-modal-block">'. (!empty($grp_name) ? '<h3>'.__pl($grp_name).'</h3>' :'' ) .'<ul>';
foreach($group as $desc => $shortcut) {
echo '<li><span class="pagelayer-keyboard-shortcut-desc">'.__pl($desc).'</span>
<span class="pagelayer-keyboard-shortcut-keys">';
//Considering the whole shortcut as a single key
$key = '<span>'.$shortcut.'</span>';
//replacing "+" and "," from the string to put it inside <span>
$key = preg_replace('/\+/', '</span> + <span>', $key);
$key = preg_replace('/\,/', '</span><span style="display:block; margin-top:10px;">', $key);
echo $key.'</span></li>';
}
echo '</ul></div>';
}
echo '</div>
</div>
</div>
</body>';
die();
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
function pagelayer_live_body(){
global $post, $pagelayer;
$icons = pagelayer_enabled_icons();
$icons_list = array();
// Load all icons
foreach($icons as $icon){
$icons_list[] = $icon.'.min.css';
}
$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
if(pagelayer_enable_giver()){
$css_url = PAGELAYER_CSS.'/givecss.php?';
}
$dark_mode = get_option('pagelayer_enable_dark_mode');
$body_class = '';
if(!empty($dark_mode)){
$body_class = 'pagelayer-dark';
};
if(defined('SITEPAD')){
$body_class .= ' sitepad-body';
}
$shortcut_groups = [
'general_shortcuts' => [
'undo' => 'Ctrl+Z',
'redo' => 'Ctrl+Y',
'save_post' => 'Ctrl+S',
'copy_widget' => 'Ctrl+C',
'paste_widget' => 'Ctrl+V',
'duplicate_widget' => 'Ctrl+D',
'delete_widget' => 'Delete'
]
];
echo '
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<link rel="stylesheet" href="'.$css_url.'give=pagelayer-editor.css,trumbowyg.min.css,pagelayer-icons.css,'.implode(',' ,$icons_list).'&ver='.PAGELAYER_VERSION.'">';
do_action('pagelayer_live_body_head');
// Brand Name
$brand = strtoupper($pagelayer->BRAND_TEXT);
$brand = str_split($brand);
echo '
<style>
/*Set responsive variables*/
.pagelayer-screen-tablet{
width: '. $pagelayer->settings['tablet_breakpoint'] .'px;
}
.pagelayer-screen-mobile{
width: '. $pagelayer->settings['mobile_breakpoint'] .'px;
}
.pagelayer-errorBox-support{
text-decoration:none;
}
</style>
</head>
<body class="pagelayer-normalize pagelayer-body '.$body_class.'">
<div class="pagelayer-errorBox">
<div class="pagelayer-errorBox-close"><i class="fas fa-times"></i></div>
<div class="pagelayer-errorBox-main">
<h2><i class="fas fa-times"></i>'.__pl('error').'</h2>
<div class="pagelayer-errorBox-content"></div>
</div>
<div class="pagelayer-errorBox-resolve">
<p>'.__pl('error_submitting').'</p>
<button type="button" class="pagelayer-errorBox-copy" onclick="pagelayer_copy_error(event)">'.__pl('copy').'</button>
<a type="button" class="pagelayer-errorBox-support" href="'. $pagelayer->support .'" target="_bank">'.__pl('support').'</a>
</div>
</div>
<div id="pagelayer-loader-wrapper">
<div class="pagelayer-animation-section">
<div class="pagelayer-loader">
<div class="pagelayer-percent-parent">
<div class="pagelayer-percent">10<sup>%</sup></div>
</div>
</div>
<div class="pagelayer-txt-loading">';
foreach($brand as $k => $v){
echo '<span data-text-preloader="'.$v.'" class="letters-loading">'.$v.'</span>';
}
echo '</div>
</div>
</div>
<table class="pagelayer-normalize pagelayer-body-table" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="270" class="pagelayer-leftbar-table">
<table class="pagelayer-normalize" cellpadding="0" cellspacing="0">
<tr class="pagelayer-close-bar">
<td>
<div class="pagelayer-close-bar-icons">
<i class="pagelayer-leftbar-minimize fa fa-minus"></i>
<i class="pagelayer-leftbar-close fa fa-close"></i>
</div>
</td>
</tr>
<tr height="45">
<td class="pagelayer-topbar-holder" valign="middle" align="center">
<span class="pagelayer-options-icon pli pli-menu"></span>
<div class="pagelayer-elpd-header" style="display:none">
<div class="pagelayer-elpd-close"><i class="pli pli-cross" aria-hidden="true"></i></div>
<div class="pagelayer-elpd-title pagelayer-topbar-mover">Edit</div>
</div>
<div class="pagelayer-logo">
<img src="'.$pagelayer->LOGO.'" width="28" /><span class="pagelayer-logo-text pagelayer-topbar-mover">'.$pagelayer->BRAND_TEXT.(defined('PAGELAYER_PREMIUM') && strtolower($pagelayer->BRAND_TEXT) == 'pagelayer' ? '<sup style="margin: 3px; font-size: 12px; letter-spacing: 1px; font-family: "Roboto";">Pro</sup>' : '').'</span>
<span class="pagelayer-settings-icon pli pli-service" aria-hidden="true"></span>
</div>
</td>
</tr>
<tr height="*" valign="top">
<td style="position: relative;"><div class="pagelayer-leftbar-holder"></div></td>
</tr>
<tr height="35" class="pagelayer-bottombar-row">
<td><div class="pagelayer-bottombar-holder"></div></td>
</tr>
</table>
<div class="pagelayer-leftbar-toggle">&lsaquo;</div>
</td>
<td class="pagelayer-iframe" valign="top">
<div class="pagelayer-iframe-top-bar">';
do_action('pagelayer_iframe_top_bar');
echo '
</div>
<div class="pagelayer-iframe-holder">
<iframe src="'.(pagelayer_shortlink(0).'&pagelayer-iframe=1&'.$_SERVER['QUERY_STRING']).'" class="pagelayer-normalize skip-lazy" id="pagelayer-iframe"></iframe>
</div>
</td>
</tr>
</table>
<div class="pagelayer-pro-notice">';
pagelayer_show_pro_div('Premium Feature<span class="pli pli-cross pagelayer-pro-x"></span>', '', 0);
echo '</div>
<div class="pagelayer-editor-notice"></div>
<div class="pagelayer-props-modal">
<div class="pagelayer-props-holder">
<div class="pagelayer-props-wrap">
<div class="pagelayer-props-loading-screen"></div>
<i class="pagelayer-props-modal-close pli pli-cross" aria-hidden="true"></i>
</div>
</div>
</div>
<script>
var pagelayer_iframe_cw = document.getElementById("pagelayer-iframe").contentWindow;
var start_time = new Date().getTime();
// Show loading progress
function loader(ran) {
var inner = document.getElementsByClassName("pagelayer-percent")[0];
var w = 0;
var t = setInterval(function() {
w = w + 1;
inner.innerHTML = (w+"<sup>%</sup>");
if (w === ran || inner.getAttribute("loaded") == "1"){
clearInterval(t);
w = 0;
}
}, 50);
}
loader(90);
function $p(sel){
return pagelayer_iframe_cw.pagelayer.$$(sel);
}
// Load the window if necessary i.e. an error in the JS of the iframe
function onIframeLoad(){
setTimeout(function(){
force_pagelayer_start();
}, 5000);
}
function force_pagelayer_start(){
try{
if(pagelayer_iframe_cw.pagelayer.loaded == 1){
return;
}
pagelayer_iframe_cw.pagelayer_start();
var end_time = new Date().getTime();
var diff = (end_time - start_time) / 1000;
console.log("['.$pagelayer->BRAND_TEXT.'] Live Body had to load after : "+diff+" seconds");
// If this fails, lets just hide the loader
}catch(e){
alert("Fatal error within the '.$pagelayer->BRAND_TEXT.' iFrame as pagelayer object not found ! Please contact '.$pagelayer->BRAND_TEXT.' support");
document.getElementById("pagelayer-loader-wrapper").remove();
}
}
document.getElementById("pagelayer-iframe").onload = onIframeLoad;
// ErrorBox content copy function
function pagelayer_copy_error(){
var tempInput = document.createElement("textarea");
tempInput.value = document.querySelector(".pagelayer-errorBox-content").innerText;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("'.__pl('copy_success').'");
}
</script>
<div class="pagelayer-editor-modal pagelayer-shortcuts-modal">
<div class="pagelayer-editor-modal-wrap">
<div class="pagelayer-editor-modal-header">
<h2>'.__pl('keyboard_shortcuts').'</h2>
<span class="pagelayer-editor-modal-close-icon"><i class="fas fa-times"></i></span>
</div>
<div class="pagelayer-editor-modal-body">';
foreach($shortcut_groups as $grp_name => $group){
if(empty($group)) {
return;
}
echo '<div class="pagelayer-edt-modal-block">'. (!empty($grp_name) ? '<h3>'.__pl($grp_name).'</h3>' :'' ) .'<ul>';
foreach($group as $desc => $shortcut) {
echo '<li><span class="pagelayer-keyboard-shortcut-desc">'.__pl($desc).'</span>
<span class="pagelayer-keyboard-shortcut-keys">';
//Considering the whole shortcut as a single key
$key = '<span>'.$shortcut.'</span>';
//replacing "+" and "," from the string to put it inside <span>
$key = preg_replace('/\+/', '</span> + <span>', $key);
$key = preg_replace('/\,/', '</span><span style="display:block; margin-top:10px;">', $key);
echo $key.'</span></li>';
}
echo '</ul></div>';
}
echo '</div>
</div>
</div>
</body>';
die();
}

View File

@@ -1,409 +1,409 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
class PageLayer_LiveEditor{
// The constructor
function __construct() {
global $pagelayer;
// Convert the post to a PageLayer Post first
$this->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'), 999999);
// Skip do_blocks for invalid blocks
add_filter( 'pre_render_block', array($this, 'pre_do_render_block'), 10, 3 );
// Skip do_shortcode for invalid shortcodes
add_filter( 'pre_do_shortcode_tag', array($this, 'pre_do_shortcode_tag'), 10, 4 );
// 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.min.js,slimscroll.js,vanilla-picker.min.js,trumbowyg.js,trumbowyg.fontfamily.js,trumbowyg-pagelayer.js,tlite.min.js,pagelayer-pen.js,&pagelayer_nonce=1&scmd5='.$scmd5, array('jquery'), PAGELAYER_VERSION);
wp_enqueue_script('pagelayer-editor');
$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
if(pagelayer_enable_giver()){
$css_url = PAGELAYER_CSS.'/givecss.php?';
}
// Enqueue the Editor's CSS
wp_register_style('pagelayer-editor', $css_url.'give=pagelayer-editor-frontend.css,pagelayer-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, $_wp_post_type_features;
// Export the post props
$_post = clone $post;
unset($_post->post_content);
// Add template type
if(!empty($pagelayer->template_editor)){
$_post->pagelayer_template_type = get_post_meta($_post->ID, 'pagelayer_template_type', true);
}
$returnURL = ($_post->post_type == 'post' ? admin_url('edit.php') : admin_url('edit.php?post_type='.$_post->post_type) );
// Get CAPTCHA site key
$pagelayer_recaptch_site_key = get_option('pagelayer_google_captcha');
$pro_url = defined('POPULARFX_PRO_URL') ? POPULARFX_PRO_URL : PAGELAYER_PRO_URL;
$pro_txt = defined('POPULARFX_PRO_URL') ? 'PopularFX Pro' : 'Pagelayer Pro';
$post_type = get_post_type_object($post->post_type);
$post_type_name = (!empty($post_type->labels->singular_name)) ? $post_type->labels->singular_name : ucfirst($post_type->name);
// Create list of nav menus and it's items list
$pagelayer_menus_items_list = array();
$menus = wp_get_nav_menus();
foreach($menus as $menu){
if(!is_nav_menu($menu)){
continue;
}
$pagelayer_menus_items_list[$menu->term_id] = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
}
echo '
<script type="text/javascript">
pagelayer_ver = "'.PAGELAYER_VERSION.'";
pagelayer_block_prefix = "'.PAGELAYER_BLOCK_PREFIX.'";
pagelayer_pro = '.(int)defined('PAGELAYER_PREMIUM').';
pagelayer_pro_url = "'.PAGELAYER_PRO_URL.'";
pagelayer_pro_txt = "'.addslashes('This feature is a part of <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a>. You will need purchase <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a> to use this feature.').'";
pagelayer_api_url = "'.PAGELAYER_API.'";
pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?&";
pagelayer_post_props = "'.admin_url( 'admin.php?page=pagelayer_meta_setting&post=' ).$post->ID.'";
pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
pagelayer_media_ajax_nonce = "'.wp_create_nonce('media-form').'";
pagelayer_internal_linking_nonce = "'.wp_create_nonce('internal-linking').'";
pagelayer_preview_nonce = "'. wp_create_nonce( 'post_preview_' . $post->ID ).'";
pagelayer_url = "'.PAGELAYER_URL.'";
pagelayer_postID = "'.$post->ID.'";
pagelayer_permalink_structure = "'.(empty(get_option('permalink_structure')) ? 0 : 1).'";
pagelayer_post_permalink = "'.get_permalink($post->ID).'";
pagelayer_tabs = '.json_encode($pagelayer->tabs).';
pagelayer_isDirty = false;
pagelayer_returnURL = "'.$returnURL.'";
pagelayer_theme_vars = '.json_encode( pagelayer_template_vars() ).';
pagelayer_revision_obj = '.json_encode( pagelayer_get_post_revision_by_id( $post->ID ) ).';
pagelayer_author = '.json_encode(pagelayer_author_data($post->ID)).';
pagelayer_site_logo = '.json_encode(pagelayer_site_logo()).';
pagelayer_support_FI = "'. ( current_theme_supports('post-thumbnails') ) .'";
pagelayer_editable = ".'.(!empty($pagelayer->template_editor) ? $pagelayer->template_editor : 'pagelayer-editable-area').'";
pagelayer_recaptch_site_key = "'.(!empty($pagelayer_recaptch_site_key) ? $pagelayer_recaptch_site_key : '').'";
pagelayer_post = '. @json_encode($_post) .';
pagelayer_loaded_icons = '.json_encode(pagelayer_enabled_icons()).';
pagelayer_social_urls = '.json_encode(pagelayer_get_social_urls()).';
pagelayer_global_widgets = '.json_encode($pagelayer->global_widgets).';
pagelayer_saved_sections = '.json_encode($pagelayer->saved_sections).';
pagelayer_global_sections = '.json_encode($pagelayer->global_sections).';
pagelayer_brand = "'.addslashes($pagelayer->BRAND_TEXT).'";
pagelayer_post_type_features = '.json_encode(@$_wp_post_type_features[$post->post_type]).';
pagelayer_post_categories = '.json_encode(pagelayer_post_cats($post)).';
pagelayer_post_tags = '.json_encode(pagelayer_post_tags($post)).';
pagelayer_shortcodes.pl_post_props.name = "'.ucfirst($post_type_name).' '. __pl('Settings').'";
pagelayer_shortcodes.pl_post_props.params.post_author.list = '.json_encode(pagelayer_post_authors_by_type($post->post_type)).';
pagelayer_shortcodes.pl_post_props.pageParent.post_parent.list = '.json_encode(pagelayer_parent_post_prop($post)).';
pagelayer_gmaps_key = "'.get_option('pagelayer-gmaps-api-key').'";
pagelayer_ajax_post_data = {};
pagelayer_menus_items_list = '.json_encode($pagelayer_menus_items_list).';
pagelayer_customizer_values = '.json_encode(pagelayer_get_customizer_options()).';
pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
pagelayer_customizer_url = "'.admin_url("/customize.php?return=").urlencode($_SERVER['HTTP_REFERER']).'";
pagelayer_support_url = "'.$pagelayer->support .'";';
if(defined('PAGELAYER_PREMIUM')){
echo 'pagelayer_shortcodes.pl_popup.advance_options.popup_cookie_name.default = "popup_cookie_'.rand(100, 999).'";';
}
// Detect JS via givejs for better performance
if(empty($pagelayer->settings['enable_giver'])){
echo '
jQuery(document).ready(function(){
var test_giver = -1;
return jQuery.ajax({
url: "'.PAGELAYER_JS.'/givejs.php?test=1",
type: "GET",
dataType: "text",
success:function(data){
if(data !== "1"){
return;
}
test_giver = 1;
},
complete:function(data){
jQuery.ajax({
type: "POST",
url: pagelayer_ajax_url+"&action=pagelayer_set_jscss_giver",
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
set : test_giver
},
error: function(errorThrown){
console.log("Error saving giver data");
console.log(errorThrown);
}
});
}
});
});
';
}
echo '
</script>';
echo '<style>
@media (min-width: '.($pagelayer->settings['tablet_breakpoint'] + 1).'px){
.pagelayer-hide-desktop{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-desktop *{
filter:blur(2px);
}
}
@media (max-width: '.$pagelayer->settings['tablet_breakpoint'].'px) and (min-width: '.($pagelayer->settings['mobile_breakpoint'] + 1).'px){
.pagelayer-hide-tablet{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-tablet *{
filter:blur(2px);
}
}
@media (max-width: '.$pagelayer->settings['mobile_breakpoint'].'px){
.pagelayer-hide-mobile{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-mobile *{
filter:blur(2px);
}
}
</style>';
do_action('pagelayer_editor_wp_head');
}
// Footer function to add certain things
function wp_footer(){
global $pagelayer;
echo '<script>
pagelayer_default_params = '.json_encode($pagelayer->default_params, JSON_FORCE_OBJECT).';
pagelayer.el = '.json_encode($pagelayer->data_attr, JSON_FORCE_OBJECT).';
</script>';
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(!empty($post->post_content)){
// Add our surrounding tag
$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {col=12} -->
'.$post->post_content.'
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->';
// Regular post, but its empty so we will add our blocks !
}else{
// Add our surrounding tag
$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row {"stretch":"auto","col_gap":"10","width_content":"auto","row_height":"default","overlay_hover_delay":"400","row_shape_top_color":"#227bc3","row_shape_top_width":"100","row_shape_top_height":"100","row_shape_bottom_color":"#e44993","row_shape_bottom_width":"100","row_shape_bottom_height":"100","pagelayer-id":""} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {"overlay_hover_delay":"400","pagelayer-id":""} -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_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, $pagelayer;
if(empty($pagelayer->dont_make_editable)){
$content = '<div class="pagelayer-editable-area">'.$content.'</div>';
}
// 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;
}
// Skip do_shortcode for invalid shortcodes
function pre_do_shortcode_tag($return, $tag, $attr, $m){
if(!empty($pagelayer->dont_make_editable) || ! doing_filter('the_content')){
return $return;
}
$prefixes = ['pl_'];
$prefixes = apply_filters( 'pagelayer_valid_shortcode_tag', $prefixes);
$vailid = false;
foreach($prefixes as $prefix) {
if (strpos($tag, $prefix) === 0) {
$vailid = true;
break;
}
}
if($vailid){
return $return;
}
return $m[0];
}
// Skip do_blocks for invalid blocks
function pre_do_render_block($return, $parsed_block = [], $parent_block = null){
if(!empty($pagelayer->dont_make_editable) || ! doing_filter('the_content') || empty($parsed_block['blockName'])){
return $return;
}
$prefixes = ['pagelayer/'];
$prefixes = apply_filters( 'pagelayer_valid_block_tag', $prefixes);
$vailid = false;
foreach($prefixes as $prefix) {
if (strpos($parsed_block['blockName'], $prefix) === 0) {
$vailid = true;
break;
}
}
if($vailid){
return $return;
}
$serialize_block = serialize_block($parsed_block);
$parsed_block['blockName'] = 'pagelayer/pl_missing';
$parsed_block['innerHTML'] = $serialize_block;
$parsed_block['attrs'] = [];
return render_block($parsed_block);
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
class PageLayer_LiveEditor{
// The constructor
function __construct() {
global $pagelayer;
// Convert the post to a PageLayer Post first
$this->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'), 999999);
// Skip do_blocks for invalid blocks
add_filter( 'pre_render_block', array($this, 'pre_do_render_block'), 10, 3 );
// Skip do_shortcode for invalid shortcodes
add_filter( 'pre_do_shortcode_tag', array($this, 'pre_do_shortcode_tag'), 10, 4 );
// 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.min.js,slimscroll.js,vanilla-picker.min.js,trumbowyg.js,trumbowyg.fontfamily.js,trumbowyg-pagelayer.js,tlite.min.js,pagelayer-pen.js,&pagelayer_nonce=1&scmd5='.$scmd5, array('jquery'), PAGELAYER_VERSION);
wp_enqueue_script('pagelayer-editor');
$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
if(pagelayer_enable_giver()){
$css_url = PAGELAYER_CSS.'/givecss.php?';
}
// Enqueue the Editor's CSS
wp_register_style('pagelayer-editor', $css_url.'give=pagelayer-editor-frontend.css,pagelayer-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, $_wp_post_type_features;
// Export the post props
$_post = clone $post;
unset($_post->post_content);
// Add template type
if(!empty($pagelayer->template_editor)){
$_post->pagelayer_template_type = get_post_meta($_post->ID, 'pagelayer_template_type', true);
}
$returnURL = ($_post->post_type == 'post' ? admin_url('edit.php') : admin_url('edit.php?post_type='.$_post->post_type) );
// Get CAPTCHA site key
$pagelayer_recaptch_site_key = get_option('pagelayer_google_captcha');
$pro_url = defined('POPULARFX_PRO_URL') ? POPULARFX_PRO_URL : PAGELAYER_PRO_URL;
$pro_txt = defined('POPULARFX_PRO_URL') ? 'PopularFX Pro' : 'Pagelayer Pro';
$post_type = get_post_type_object($post->post_type);
$post_type_name = (!empty($post_type->labels->singular_name)) ? $post_type->labels->singular_name : ucfirst($post_type->name);
// Create list of nav menus and it's items list
$pagelayer_menus_items_list = array();
$menus = wp_get_nav_menus();
foreach($menus as $menu){
if(!is_nav_menu($menu)){
continue;
}
$pagelayer_menus_items_list[$menu->term_id] = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
}
echo '
<script type="text/javascript">
pagelayer_ver = "'.PAGELAYER_VERSION.'";
pagelayer_block_prefix = "'.PAGELAYER_BLOCK_PREFIX.'";
pagelayer_pro = '.(int)defined('PAGELAYER_PREMIUM').';
pagelayer_pro_url = "'.PAGELAYER_PRO_URL.'";
pagelayer_pro_txt = "'.addslashes('This feature is a part of <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a>. You will need purchase <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a> to use this feature.').'";
pagelayer_api_url = "'.PAGELAYER_API.'";
pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?&";
pagelayer_post_props = "'.admin_url( 'admin.php?page=pagelayer_meta_setting&post=' ).$post->ID.'";
pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
pagelayer_media_ajax_nonce = "'.wp_create_nonce('media-form').'";
pagelayer_internal_linking_nonce = "'.wp_create_nonce('internal-linking').'";
pagelayer_preview_nonce = "'. wp_create_nonce( 'post_preview_' . $post->ID ).'";
pagelayer_url = "'.PAGELAYER_URL.'";
pagelayer_postID = "'.$post->ID.'";
pagelayer_permalink_structure = "'.(empty(get_option('permalink_structure')) ? 0 : 1).'";
pagelayer_post_permalink = "'.get_permalink($post->ID).'";
pagelayer_tabs = '.json_encode($pagelayer->tabs).';
pagelayer_isDirty = false;
pagelayer_returnURL = "'.$returnURL.'";
pagelayer_theme_vars = '.json_encode( pagelayer_template_vars() ).';
pagelayer_revision_obj = '.json_encode( pagelayer_get_post_revision_by_id( $post->ID ) ).';
pagelayer_author = '.json_encode(pagelayer_author_data($post->ID)).';
pagelayer_site_logo = '.json_encode(pagelayer_site_logo()).';
pagelayer_support_FI = "'. ( current_theme_supports('post-thumbnails') ) .'";
pagelayer_editable = ".'.(!empty($pagelayer->template_editor) ? $pagelayer->template_editor : 'pagelayer-editable-area').'";
pagelayer_recaptch_site_key = "'.(!empty($pagelayer_recaptch_site_key) ? $pagelayer_recaptch_site_key : '').'";
pagelayer_post = '. @json_encode($_post) .';
pagelayer_loaded_icons = '.json_encode(pagelayer_enabled_icons()).';
pagelayer_social_urls = '.json_encode(pagelayer_get_social_urls()).';
pagelayer_global_widgets = '.json_encode($pagelayer->global_widgets).';
pagelayer_saved_sections = '.json_encode($pagelayer->saved_sections).';
pagelayer_global_sections = '.json_encode($pagelayer->global_sections).';
pagelayer_brand = "'.addslashes($pagelayer->BRAND_TEXT).'";
pagelayer_post_type_features = '.json_encode(@$_wp_post_type_features[$post->post_type]).';
pagelayer_post_categories = '.json_encode(pagelayer_post_cats($post)).';
pagelayer_post_tags = '.json_encode(pagelayer_post_tags($post)).';
pagelayer_shortcodes.pl_post_props.name = "'.ucfirst($post_type_name).' '. __pl('Settings').'";
pagelayer_shortcodes.pl_post_props.params.post_author.list = '.json_encode(pagelayer_post_authors_by_type($post->post_type)).';
pagelayer_shortcodes.pl_post_props.pageParent.post_parent.list = '.json_encode(pagelayer_parent_post_prop($post)).';
pagelayer_gmaps_key = "'.get_option('pagelayer-gmaps-api-key').'";
pagelayer_ajax_post_data = {};
pagelayer_menus_items_list = '.json_encode($pagelayer_menus_items_list).';
pagelayer_customizer_values = '.json_encode(pagelayer_get_customizer_options()).';
pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
pagelayer_customizer_url = "'.admin_url("/customize.php?return=").urlencode($_SERVER['HTTP_REFERER']).'";
pagelayer_support_url = "'.$pagelayer->support .'";';
if(defined('PAGELAYER_PREMIUM')){
echo 'pagelayer_shortcodes.pl_popup.advance_options.popup_cookie_name.default = "popup_cookie_'.rand(100, 999).'";';
}
// Detect JS via givejs for better performance
if(empty($pagelayer->settings['enable_giver'])){
echo '
jQuery(document).ready(function(){
var test_giver = -1;
return jQuery.ajax({
url: "'.PAGELAYER_JS.'/givejs.php?test=1",
type: "GET",
dataType: "text",
success:function(data){
if(data !== "1"){
return;
}
test_giver = 1;
},
complete:function(data){
jQuery.ajax({
type: "POST",
url: pagelayer_ajax_url+"&action=pagelayer_set_jscss_giver",
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
set : test_giver
},
error: function(errorThrown){
console.log("Error saving giver data");
console.log(errorThrown);
}
});
}
});
});
';
}
echo '
</script>';
echo '<style>
@media (min-width: '.($pagelayer->settings['tablet_breakpoint'] + 1).'px){
.pagelayer-hide-desktop{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-desktop *{
filter:blur(2px);
}
}
@media (max-width: '.$pagelayer->settings['tablet_breakpoint'].'px) and (min-width: '.($pagelayer->settings['mobile_breakpoint'] + 1).'px){
.pagelayer-hide-tablet{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-tablet *{
filter:blur(2px);
}
}
@media (max-width: '.$pagelayer->settings['mobile_breakpoint'].'px){
.pagelayer-hide-mobile{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-mobile *{
filter:blur(2px);
}
}
</style>';
do_action('pagelayer_editor_wp_head');
}
// Footer function to add certain things
function wp_footer(){
global $pagelayer;
echo '<script>
pagelayer_default_params = '.json_encode($pagelayer->default_params, JSON_FORCE_OBJECT).';
pagelayer.el = '.json_encode($pagelayer->data_attr, JSON_FORCE_OBJECT).';
</script>';
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(!empty($post->post_content)){
// Add our surrounding tag
$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {col=12} -->
'.$post->post_content.'
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->';
// Regular post, but its empty so we will add our blocks !
}else{
// Add our surrounding tag
$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row {"stretch":"auto","col_gap":"10","width_content":"auto","row_height":"default","overlay_hover_delay":"400","row_shape_top_color":"#227bc3","row_shape_top_width":"100","row_shape_top_height":"100","row_shape_bottom_color":"#e44993","row_shape_bottom_width":"100","row_shape_bottom_height":"100","pagelayer-id":""} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {"overlay_hover_delay":"400","pagelayer-id":""} -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_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, $pagelayer;
if(empty($pagelayer->dont_make_editable)){
$content = '<div class="pagelayer-editable-area">'.$content.'</div>';
}
// 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;
}
// Skip do_shortcode for invalid shortcodes
function pre_do_shortcode_tag($return, $tag, $attr, $m){
if(!empty($pagelayer->dont_make_editable) || ! doing_filter('the_content')){
return $return;
}
$prefixes = ['pl_'];
$prefixes = apply_filters( 'pagelayer_valid_shortcode_tag', $prefixes);
$vailid = false;
foreach($prefixes as $prefix) {
if (strpos($tag, $prefix) === 0) {
$vailid = true;
break;
}
}
if($vailid){
return $return;
}
return $m[0];
}
// Skip do_blocks for invalid blocks
function pre_do_render_block($return, $parsed_block = [], $parent_block = null){
if(!empty($pagelayer->dont_make_editable) || ! doing_filter('the_content') || empty($parsed_block['blockName'])){
return $return;
}
$prefixes = ['pagelayer/'];
$prefixes = apply_filters( 'pagelayer_valid_block_tag', $prefixes);
$vailid = false;
foreach($prefixes as $prefix) {
if (strpos($parsed_block['blockName'], $prefix) === 0) {
$vailid = true;
break;
}
}
if($vailid){
return $return;
}
$serialize_block = serialize_block($parsed_block);
$parsed_block['blockName'] = 'pagelayer/pl_missing';
$parsed_block['innerHTML'] = $serialize_block;
$parsed_block['attrs'] = [];
return render_block($parsed_block);
}
}

View File

@@ -1,303 +1,303 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// nav_walker.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
if ( ! class_exists( 'Pagelayer_Walker_Nav_Menu' ) ) {
class Pagelayer_Walker_Nav_Menu extends Walker_Nav_Menu{
// Starts the list before the elements are added.
public function start_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
// Default class.
$classes = array( 'sub-menu' );
// Filters the CSS class(es) applied to a menu list element.
$class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
$output .= "{$n}{$indent}<ul$class_names>{$n}";
}
// Ends the list of after the elements are added.
public function end_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
$output .= "$indent</ul>{$n}";
}
// Starts the element output.
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
// Menu setting keys
$keys = array('_pagelayer_content');
foreach($keys as $key){
$menu_item_setting = get_post_meta( $item->ID, $key, true );
if(!empty($menu_item_setting)){
$item->$key = $menu_item_setting;
}
}
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
// Get custom setting data
$item_content = $this->get_item_data($item, '_pagelayer_content');
$settings = array();
$pagelayer_has_content = 0;
if(!empty($item_content) && has_blocks($item_content)){
$blocks = parse_blocks($item_content);
$attrs = array();
foreach($blocks as $index => $block){
if($block['blockName'] != 'pagelayer/pl_nav_menu_item'){
continue;
}
// Overrig the menu ID to apply css and others
foreach($item as $kk => $vv){
if($kk == '_pagelayer_content'){
continue;
}
$block['attrs'][$kk] = $vv;
}
$settings = $block['attrs'];
// Add settings to $item
foreach($settings as $skey => $sval){
if(isset($item->$skey)){
continue;
}
$item->$skey = $sval;
}
if(!empty($block['innerBlocks'])){
$pagelayer_has_content = $this->has_block_content($block['innerBlocks']);
}
$blocks[$index] = $block;
}
$item_content = serialize_blocks($blocks);
}
$pagelayer_has_content = pagelayer_is_live() ? 1 : $pagelayer_has_content;
// Get menu type
$menu_type = $this->get_item_data($item, 'menu_type');
if(!empty($menu_type) && $menu_type == 'mega' && $depth == 0 && !empty($pagelayer_has_content)){
$classes[] = 'pagelayer-mega-menu-item';
}
if(!empty($menu_type) && $menu_type == 'column' && $depth == 0){
$classes[] = 'pagelayer-mega-column-item';
}
$menu_icon_class = $this->get_item_data($item, 'icon_position');
if(!empty($menu_icon_class)){
$classes[] = 'pagelayer-nav-menu-icon-'.$menu_icon_class;
}
// Filters the arguments for a single nav menu item.
$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
// Filters the CSS classes applied to a menu item's list item element.
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
// Filters the ID applied to a menu item's list item element.
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names . '>';
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
if ( '_blank' === $item->target && empty( $item->xfn ) ) {
$atts['rel'] = 'noopener';
} else {
$atts['rel'] = $item->xfn;
}
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['aria-current'] = $item->current ? 'page' : '';
// Filters the HTML attributes applied to a menu item's anchor element.
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
// Get disable links
$disable_link = $this->get_item_data($item, 'disable_link');
if ( 'href' === $attr && !empty($disable_link) ) {
$value = 'javascript:void(0)';
}
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
/** This filter is documented in wp-includes/post-template.php */
$title = $this->get_item_data($item, 'title');
$title = apply_filters( 'the_title', $title, $item->ID );
// Filters a menu item's title.
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
$item_output = $args->before;
$item_output .= '<a' . $attributes . '>';
// Add menu icon
$menu_icon = $this->get_item_data($item, 'menu_icon');
if (!empty($menu_icon)) {
$item_output .= '<i class="pagelayer-menu-icon '.$menu_icon.'"></i>';
}
$item_output .= '<span class="pagelayer-nav-menu-title">' . $args->link_before . $title . $args->link_after .'</span>';
// Add highlight lable
$highlight_label = $this->get_item_data($item, 'highlight_label');
if (!empty($highlight_label)) {
$item_output .= '<span class="pagelayer-menu-highlight">'.$highlight_label.'</span>';
}
$item_output .= '</a>';
$item_output .= $args->after;
$mega_class = 'pagelayer-mega-editor-'.$item->ID;
$item_output .= '<div class="pagelayer-mega-menu '.$mega_class.'">';
// Add mega menu
if(!empty($item_content)){
$item_content = pagelayer_the_content($item_content, true);
// Change the pagelayer ID
$item_output .= pagelayer_change_id($item_content);
}
$item_output .= '</div>';
// Filters a menu item's starting output.
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
// Ends the element output, if needed.
public function end_el( &$output, $item, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$output .= "</li>{$n}";
}
// Get the post value
public function get_item_data( $item, $name ) {
if(pagelayer_is_live() && isset($_REQUEST['pagelayer_nav_items']) && isset($_REQUEST['pagelayer_nav_items'][$item->ID][$name]) ){
$data = $_REQUEST['pagelayer_nav_items'][$item->ID][$name];
// If Title is empty
if(empty($data) && $name == 'title'){
$_item = clone $item;
$_item->post_title = '';
$_item = wp_setup_nav_menu_item($_item);
return $_item->title;
}
if(!empty($data) && $name == '_pagelayer_content'){
$data = base64_decode($data);
}
return stripslashes_deep($data);
}
return @$item->$name;
}
// Check the block has inner block
public function has_block_content( $blocks ) {
$tags = array('pagelayer/pl_row', 'pagelayer/pl_inner_row', 'pagelayer/pl_col', 'pagelayer/pl_inner_col');
$has_content = 0;
foreach($blocks as $block){
if(!in_array( $block['blockName'], $tags) || !empty($has_content)){
$has_content = 1;
break;
}
if(empty($block['innerBlocks']) ){
continue;
}
$has_content = $this->has_block_content($block['innerBlocks']);
}
return $has_content;
}
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// nav_walker.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
if ( ! class_exists( 'Pagelayer_Walker_Nav_Menu' ) ) {
class Pagelayer_Walker_Nav_Menu extends Walker_Nav_Menu{
// Starts the list before the elements are added.
public function start_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
// Default class.
$classes = array( 'sub-menu' );
// Filters the CSS class(es) applied to a menu list element.
$class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
$output .= "{$n}{$indent}<ul$class_names>{$n}";
}
// Ends the list of after the elements are added.
public function end_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
$output .= "$indent</ul>{$n}";
}
// Starts the element output.
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
// Menu setting keys
$keys = array('_pagelayer_content');
foreach($keys as $key){
$menu_item_setting = get_post_meta( $item->ID, $key, true );
if(!empty($menu_item_setting)){
$item->$key = $menu_item_setting;
}
}
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
// Get custom setting data
$item_content = $this->get_item_data($item, '_pagelayer_content');
$settings = array();
$pagelayer_has_content = 0;
if(!empty($item_content) && has_blocks($item_content)){
$blocks = parse_blocks($item_content);
$attrs = array();
foreach($blocks as $index => $block){
if($block['blockName'] != 'pagelayer/pl_nav_menu_item'){
continue;
}
// Overrig the menu ID to apply css and others
foreach($item as $kk => $vv){
if($kk == '_pagelayer_content'){
continue;
}
$block['attrs'][$kk] = $vv;
}
$settings = $block['attrs'];
// Add settings to $item
foreach($settings as $skey => $sval){
if(isset($item->$skey)){
continue;
}
$item->$skey = $sval;
}
if(!empty($block['innerBlocks'])){
$pagelayer_has_content = $this->has_block_content($block['innerBlocks']);
}
$blocks[$index] = $block;
}
$item_content = serialize_blocks($blocks);
}
$pagelayer_has_content = pagelayer_is_live() ? 1 : $pagelayer_has_content;
// Get menu type
$menu_type = $this->get_item_data($item, 'menu_type');
if(!empty($menu_type) && $menu_type == 'mega' && $depth == 0 && !empty($pagelayer_has_content)){
$classes[] = 'pagelayer-mega-menu-item';
}
if(!empty($menu_type) && $menu_type == 'column' && $depth == 0){
$classes[] = 'pagelayer-mega-column-item';
}
$menu_icon_class = $this->get_item_data($item, 'icon_position');
if(!empty($menu_icon_class)){
$classes[] = 'pagelayer-nav-menu-icon-'.$menu_icon_class;
}
// Filters the arguments for a single nav menu item.
$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
// Filters the CSS classes applied to a menu item's list item element.
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
// Filters the ID applied to a menu item's list item element.
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names . '>';
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
if ( '_blank' === $item->target && empty( $item->xfn ) ) {
$atts['rel'] = 'noopener';
} else {
$atts['rel'] = $item->xfn;
}
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['aria-current'] = $item->current ? 'page' : '';
// Filters the HTML attributes applied to a menu item's anchor element.
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
// Get disable links
$disable_link = $this->get_item_data($item, 'disable_link');
if ( 'href' === $attr && !empty($disable_link) ) {
$value = 'javascript:void(0)';
}
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
/** This filter is documented in wp-includes/post-template.php */
$title = $this->get_item_data($item, 'title');
$title = apply_filters( 'the_title', $title, $item->ID );
// Filters a menu item's title.
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
$item_output = $args->before;
$item_output .= '<a' . $attributes . '>';
// Add menu icon
$menu_icon = $this->get_item_data($item, 'menu_icon');
if (!empty($menu_icon)) {
$item_output .= '<i class="pagelayer-menu-icon '.$menu_icon.'"></i>';
}
$item_output .= '<span class="pagelayer-nav-menu-title">' . $args->link_before . $title . $args->link_after .'</span>';
// Add highlight lable
$highlight_label = $this->get_item_data($item, 'highlight_label');
if (!empty($highlight_label)) {
$item_output .= '<span class="pagelayer-menu-highlight">'.$highlight_label.'</span>';
}
$item_output .= '</a>';
$item_output .= $args->after;
$mega_class = 'pagelayer-mega-editor-'.$item->ID;
$item_output .= '<div class="pagelayer-mega-menu '.$mega_class.'">';
// Add mega menu
if(!empty($item_content)){
$item_content = pagelayer_the_content($item_content, true);
// Change the pagelayer ID
$item_output .= pagelayer_change_id($item_content);
}
$item_output .= '</div>';
// Filters a menu item's starting output.
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
// Ends the element output, if needed.
public function end_el( &$output, $item, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$output .= "</li>{$n}";
}
// Get the post value
public function get_item_data( $item, $name ) {
if(pagelayer_is_live() && isset($_REQUEST['pagelayer_nav_items']) && isset($_REQUEST['pagelayer_nav_items'][$item->ID][$name]) ){
$data = $_REQUEST['pagelayer_nav_items'][$item->ID][$name];
// If Title is empty
if(empty($data) && $name == 'title'){
$_item = clone $item;
$_item->post_title = '';
$_item = wp_setup_nav_menu_item($_item);
return $_item->title;
}
if(!empty($data) && $name == '_pagelayer_content'){
$data = base64_decode($data);
}
return stripslashes_deep($data);
}
return @$item->$name;
}
// Check the block has inner block
public function has_block_content( $blocks ) {
$tags = array('pagelayer/pl_row', 'pagelayer/pl_inner_row', 'pagelayer/pl_col', 'pagelayer/pl_inner_col');
$has_content = 0;
foreach($blocks as $block){
if(!in_array( $block['blockName'], $tags) || !empty($has_content)){
$has_content = 1;
break;
}
if(empty($block['innerBlocks']) ){
continue;
}
$has_content = $this->has_block_content($block['innerBlocks']);
}
return $has_content;
}
}
}

View File

@@ -1,108 +1,108 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
function pagelayer_do_shortcode_to_block( $content, $ignore_html = false ) {
global $shortcode_tags;
if ( false === strpos( $content, '[' ) ) {
return $content;
}
// Find all registered tag names in $content.
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
if( empty( $tagnames ) ){
return $content;
}
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
$pattern = get_shortcode_regex( $tagnames );
$content = preg_replace_callback( "/$pattern/", 'pagelayer_do_shortcode_tag', $content );
return $content;
}
function pagelayer_do_shortcode_tag($m){
// Allow [[foo]] syntax for escaping a tag.
if ( '[' === $m[1] && ']' === $m[6] ) {
return substr( $m[0], 1, -1 );
}
$tag = $m[2];
$attr = shortcode_parse_atts( $m[3] );
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . pagelayer_shortcode_to_block( $attr, $content, $tag ) . $m[6];
return $output;
}
function pagelayer_shortcode_to_block($attr, $content, $tag){
if($tag == 'pl_post_props'){
return '';
}
if($tag == 'pl_inner_col'){
$tag = 'pl_col';
}
if($tag == 'pl_inner_row'){
$tag = 'pl_row';
}
$block_name = 'pagelayer/'.str_replace('_', '-', $tag);
$func = 'pagelayer_fix_block_'.$tag;
// Is there a function of the tag ?
if(function_exists($func)){
call_user_func_array($func, array(&$block_name, &$attr, &$content));
}
$content = pagelayer_do_shortcode_to_block($content);
return get_comment_delimited_block_content( $block_name, $attr, $content );
}
function pagelayer_fix_block_pl_accordion_item(&$block_name, &$attr, &$content){
if(pagelayer_has_blocks($content) || false !== strpos( $content, '[pl_' )){
return;
}
pagelayer_content_to_block($content);
}
function pagelayer_content_to_block(&$content){
$content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row {"stretch":"auto"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col {"overlay_hover_delay":"400"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->'.$content.'<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row -->';
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
function pagelayer_do_shortcode_to_block( $content, $ignore_html = false ) {
global $shortcode_tags;
if ( false === strpos( $content, '[' ) ) {
return $content;
}
// Find all registered tag names in $content.
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
if( empty( $tagnames ) ){
return $content;
}
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
$pattern = get_shortcode_regex( $tagnames );
$content = preg_replace_callback( "/$pattern/", 'pagelayer_do_shortcode_tag', $content );
return $content;
}
function pagelayer_do_shortcode_tag($m){
// Allow [[foo]] syntax for escaping a tag.
if ( '[' === $m[1] && ']' === $m[6] ) {
return substr( $m[0], 1, -1 );
}
$tag = $m[2];
$attr = shortcode_parse_atts( $m[3] );
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . pagelayer_shortcode_to_block( $attr, $content, $tag ) . $m[6];
return $output;
}
function pagelayer_shortcode_to_block($attr, $content, $tag){
if($tag == 'pl_post_props'){
return '';
}
if($tag == 'pl_inner_col'){
$tag = 'pl_col';
}
if($tag == 'pl_inner_row'){
$tag = 'pl_row';
}
$block_name = 'pagelayer/'.str_replace('_', '-', $tag);
$func = 'pagelayer_fix_block_'.$tag;
// Is there a function of the tag ?
if(function_exists($func)){
call_user_func_array($func, array(&$block_name, &$attr, &$content));
}
$content = pagelayer_do_shortcode_to_block($content);
return get_comment_delimited_block_content( $block_name, $attr, $content );
}
function pagelayer_fix_block_pl_accordion_item(&$block_name, &$attr, &$content){
if(pagelayer_has_blocks($content) || false !== strpos( $content, '[pl_' )){
return;
}
pagelayer_content_to_block($content);
}
function pagelayer_content_to_block(&$content){
$content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row {"stretch":"auto"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col {"overlay_hover_delay":"400"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->'.$content.'<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row -->';
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,213 +1,213 @@
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// template.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
//function is called first to select the route
function pagelayer_replace_page(){
global $pl_error;
if(!current_user_can('upload_files')){
wp_die(esc_html__('You do not have permission to upload files.', 'pagelayer'));
}
$post_id = (int) $_GET['id'];
if(empty($post_id)){
wp_die(esc_html__('ID not found .', 'pagelayer'));
}
// Load the attachment
$post = get_post($post_id);
if(empty($post) || is_wp_error($post)){
wp_die(esc_html__('ID not found .', 'pagelayer'));
}
// Process the POST !
if(isset($_FILES['userfile'])){
if(!check_admin_referer()){
wp_die('Invalid Nonce');
}
/** Check if file is uploaded properly **/
if(!is_uploaded_file($_FILES['userfile']['tmp_name'])){
$pl_error['upload_error'] = __('No file was uploaded ! Please try again.');
pagelayer_media_replace_theme();
return;
}
if(isset($_FILES['userfile']['error']) && $_FILES['userfile']['error'] > 0){
$pl_error['upload_error'] = __('There was some error uploading the file ! Please try again.');
pagelayer_media_replace_theme();
return;
}
$filedata = wp_check_filetype_and_ext($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
if ($filedata['ext'] == false){
$pl_error['ext_error'] = __('The File type could not be determined. Please upload a permitted file type.');
pagelayer_media_replace_theme();
return;
}
$result = pagelayer_replace_attachment($_FILES['userfile']['tmp_name'], $post_id, $err);
if(empty($result)){
$pl_error['replace_error'] = $err;
pagelayer_media_replace_theme();
return;
}
$redirect_success = admin_url('post.php');
$redirect_success = add_query_arg(array(
'action' => 'edit',
'post' => $post_id,
), $redirect_success);
echo '<meta http-equiv="refresh" content="0;url='.$redirect_success.'" />';
}
// Show the theme
pagelayer_media_replace_theme();
}
// Theme of the page
function pagelayer_media_replace_theme(){
global $pl_error;
pagelayer_report_error($pl_error);echo '<br />';
$id = (int) $_GET['id'];
?>
<div class="wrap">
<h1><?php echo esc_html__("Replace Media File", 'pagelayer'); ?></h1>
<form enctype="multipart/form-data" method="POST">
<div class="editor-wrapper">
<section class="image_chooser wrapper">
<input type="hidden" name="ID" id="ID" value="<?php echo $id ?>" />
<p><?php echo esc_html__("Choose a file to upload from your computer", 'pagelayer'); ?></p>
<div class="drop-wrapper">
<p><input type="file" name="userfile" id="userfile" /></p>
<?php wp_nonce_field(); ?>
</div>
</section>
<section class="form_controls wrapper">
<input id="submit" type="submit" class="button button-primary" name="submit" value="<?php echo esc_attr__("Upload", 'pagelayer');?>" />
</section>
</div>
</form>
<?php
}
// Replace the uploaded media with the new one
function pagelayer_replace_attachment($file, $post_id, &$error = ''){
if(function_exists('wp_get_original_image_path')){
$targetFile = wp_get_original_image_path($post_id);
}else{
$targetFile = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
}
$fileparts = pathinfo($targetFile);
$filePath = isset($fileparts['dirname']) ? trailingslashit($fileparts['dirname']) : '';
$fileName = isset($fileparts['basename']) ? $fileparts['basename'] : '';
$filedata = wp_check_filetype_and_ext($targetFile, $fileName);
$fileMime = (isset($filedata['type'])) ? $filedata['type'] : false;
if(empty($targetFile)){
return false;
}
if(empty($filePath)){
$error = 'No folder for the target found !';
return false;
}
// Remove the files of the original attachment
pagelayer_remove_attahment_files($post_id);
$result_moved = move_uploaded_file($file, $targetFile);
if (false === $result_moved){
$error = sprintf( esc_html__('The uploaded file could not be moved to %1$s. This is most likely an issue with permissions, or upload failed.', 'pagelayer'), $targetFile );
return false;
}
$permissions = fileperms($targetFile) & 0777;
if ($permissions > 0){
chmod( $targetFile, $permissions ); // restore permissions
}
$updated = update_attached_file($post_id, $targetFile);
$target_url = wp_get_attachment_url($post_id);
// Run the filter, so other plugins can hook if needed.
$filtered = apply_filters( 'wp_handle_upload', array(
'file' => $targetFile,
'url' => $target_url,
'type' => $fileMime,
), 'sideload');
// Check if file changed during filter. Set changed to attached file meta properly.
if (isset($filtered['file']) && $filtered['file'] != $targetFile ){
update_attached_file($post_id, $filtered['file']);
}
$metadata = wp_generate_attachment_metadata($post_id, $targetFile);
wp_update_attachment_metadata($post_id, $metadata);
return true;
}
function pagelayer_remove_attahment_files($post_id){
$meta = wp_get_attachment_metadata( $post_id );
if (function_exists('wp_get_original_image_path')){ // WP 5.3+
$fullfilepath = wp_get_original_image_path($post_id);
}else{
$fullFilePath = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
}
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$file = $fullFilePath;
$result = wp_delete_attachment_files($post_id, $meta, $backup_sizes, $file );
// If attached file is not the same path as file, this indicates a -scaled images is in play.
$attached_file = get_attached_file($post_id);
if ($file !== $attached_file && file_exists($attached_file)){
@unlink($attached_file);
}
}
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// template.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date: 23rd Jan 2017
// Time: 23:00 hrs
// Site: http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////
// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
exit('Hacking Attempt !');
}
//function is called first to select the route
function pagelayer_replace_page(){
global $pl_error;
if(!current_user_can('upload_files')){
wp_die(esc_html__('You do not have permission to upload files.', 'pagelayer'));
}
$post_id = (int) $_GET['id'];
if(empty($post_id)){
wp_die(esc_html__('ID not found .', 'pagelayer'));
}
// Load the attachment
$post = get_post($post_id);
if(empty($post) || is_wp_error($post)){
wp_die(esc_html__('ID not found .', 'pagelayer'));
}
// Process the POST !
if(isset($_FILES['userfile'])){
if(!check_admin_referer()){
wp_die('Invalid Nonce');
}
/** Check if file is uploaded properly **/
if(!is_uploaded_file($_FILES['userfile']['tmp_name'])){
$pl_error['upload_error'] = __('No file was uploaded ! Please try again.');
pagelayer_media_replace_theme();
return;
}
if(isset($_FILES['userfile']['error']) && $_FILES['userfile']['error'] > 0){
$pl_error['upload_error'] = __('There was some error uploading the file ! Please try again.');
pagelayer_media_replace_theme();
return;
}
$filedata = wp_check_filetype_and_ext($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
if ($filedata['ext'] == false){
$pl_error['ext_error'] = __('The File type could not be determined. Please upload a permitted file type.');
pagelayer_media_replace_theme();
return;
}
$result = pagelayer_replace_attachment($_FILES['userfile']['tmp_name'], $post_id, $err);
if(empty($result)){
$pl_error['replace_error'] = $err;
pagelayer_media_replace_theme();
return;
}
$redirect_success = admin_url('post.php');
$redirect_success = add_query_arg(array(
'action' => 'edit',
'post' => $post_id,
), $redirect_success);
echo '<meta http-equiv="refresh" content="0;url='.$redirect_success.'" />';
}
// Show the theme
pagelayer_media_replace_theme();
}
// Theme of the page
function pagelayer_media_replace_theme(){
global $pl_error;
pagelayer_report_error($pl_error);echo '<br />';
$id = (int) $_GET['id'];
?>
<div class="wrap">
<h1><?php echo esc_html__("Replace Media File", 'pagelayer'); ?></h1>
<form enctype="multipart/form-data" method="POST">
<div class="editor-wrapper">
<section class="image_chooser wrapper">
<input type="hidden" name="ID" id="ID" value="<?php echo $id ?>" />
<p><?php echo esc_html__("Choose a file to upload from your computer", 'pagelayer'); ?></p>
<div class="drop-wrapper">
<p><input type="file" name="userfile" id="userfile" /></p>
<?php wp_nonce_field(); ?>
</div>
</section>
<section class="form_controls wrapper">
<input id="submit" type="submit" class="button button-primary" name="submit" value="<?php echo esc_attr__("Upload", 'pagelayer');?>" />
</section>
</div>
</form>
<?php
}
// Replace the uploaded media with the new one
function pagelayer_replace_attachment($file, $post_id, &$error = ''){
if(function_exists('wp_get_original_image_path')){
$targetFile = wp_get_original_image_path($post_id);
}else{
$targetFile = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
}
$fileparts = pathinfo($targetFile);
$filePath = isset($fileparts['dirname']) ? trailingslashit($fileparts['dirname']) : '';
$fileName = isset($fileparts['basename']) ? $fileparts['basename'] : '';
$filedata = wp_check_filetype_and_ext($targetFile, $fileName);
$fileMime = (isset($filedata['type'])) ? $filedata['type'] : false;
if(empty($targetFile)){
return false;
}
if(empty($filePath)){
$error = 'No folder for the target found !';
return false;
}
// Remove the files of the original attachment
pagelayer_remove_attahment_files($post_id);
$result_moved = move_uploaded_file($file, $targetFile);
if (false === $result_moved){
$error = sprintf( esc_html__('The uploaded file could not be moved to %1$s. This is most likely an issue with permissions, or upload failed.', 'pagelayer'), $targetFile );
return false;
}
$permissions = fileperms($targetFile) & 0777;
if ($permissions > 0){
chmod( $targetFile, $permissions ); // restore permissions
}
$updated = update_attached_file($post_id, $targetFile);
$target_url = wp_get_attachment_url($post_id);
// Run the filter, so other plugins can hook if needed.
$filtered = apply_filters( 'wp_handle_upload', array(
'file' => $targetFile,
'url' => $target_url,
'type' => $fileMime,
), 'sideload');
// Check if file changed during filter. Set changed to attached file meta properly.
if (isset($filtered['file']) && $filtered['file'] != $targetFile ){
update_attached_file($post_id, $filtered['file']);
}
$metadata = wp_generate_attachment_metadata($post_id, $targetFile);
wp_update_attachment_metadata($post_id, $metadata);
return true;
}
function pagelayer_remove_attahment_files($post_id){
$meta = wp_get_attachment_metadata( $post_id );
if (function_exists('wp_get_original_image_path')){ // WP 5.3+
$fullfilepath = wp_get_original_image_path($post_id);
}else{
$fullFilePath = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
}
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$file = $fullFilePath;
$result = wp_delete_attachment_files($post_id, $meta, $backup_sizes, $file );
// If attached file is not the same path as file, this indicates a -scaled images is in play.
$attached_file = get_attached_file($post_id);
if ($file !== $attached_file && file_exists($attached_file)){
@unlink($attached_file);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff