| 1 |
<?php |
| 2 |
|
| 3 |
// We need the ABSPATH |
| 4 |
if (!defined('ABSPATH')) exit; |
| 5 |
|
| 6 |
define('PAGELAYER_BASE', plugin_basename(__FILE__)); |
| 7 |
define('PAGELAYER_FILE', __FILE__); |
| 8 |
define('PAGELAYER_VERSION', '0.9.3'); |
| 9 |
define('PAGELAYER_DIR', WP_PLUGIN_DIR.'/'.basename(dirname(PAGELAYER_FILE))); |
| 10 |
define('PAGELAYER_SLUG', 'pagelayer'); |
| 11 |
define('PAGELAYER_URL', plugins_url('', PAGELAYER_FILE)); |
| 12 |
define('PAGELAYER_CSS', PAGELAYER_URL.'/css'); |
| 13 |
define('PAGELAYER_JS', PAGELAYER_URL.'/js'); |
| 14 |
define('PAGELAYER_PRO_URL', 'https://pagelayer.com/features#compare'); |
| 15 |
define('PAGELAYER_DOCS', 'https://pagelayer.com/docs/'); |
| 16 |
define('PAGELAYER_API', 'https://api.pagelayer.com/'); |
| 17 |
define('PAGELAYER_SC_PREFIX', 'pl'); |
| 18 |
define('PAGELAYER_YOUTUBE_BG', 'https://www.youtube.com/watch?v=Csa6rvCWmLU'); |
| 19 |
|
| 20 |
include_once(PAGELAYER_DIR.'/main/functions.php'); |
| 21 |
include_once(PAGELAYER_DIR.'/main/class.php'); |
| 22 |
|
| 23 |
// Ok so we are now ready to go |
| 24 |
register_activation_hook(PAGELAYER_FILE, 'pagelayer_activation'); |
| 25 |
|
| 26 |
// Is called when the ADMIN enables the plugin |
| 27 |
function pagelayer_activation(){ |
| 28 |
|
| 29 |
global $wpdb; |
| 30 |
|
| 31 |
$sql = array(); |
| 32 |
|
| 33 |
/*$sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."pagelayer_logs`"; |
| 34 |
|
| 35 |
foreach($sql as $sk => $sv){ |
| 36 |
$wpdb->query($sv); |
| 37 |
}*/ |
| 38 |
|
| 39 |
add_option('pagelayer_version', PAGELAYER_VERSION); |
| 40 |
add_option('pagelayer_options', array()); |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
// Checks if we are to update ? |
| 45 |
function pagelayer_update_check(){ |
| 46 |
|
| 47 |
global $wpdb; |
| 48 |
|
| 49 |
$sql = array(); |
| 50 |
$current_version = get_option('pagelayer_version'); |
| 51 |
$version = (int) str_replace('.', '', $current_version); |
| 52 |
|
| 53 |
// No update required |
| 54 |
if($current_version == PAGELAYER_VERSION){ |
| 55 |
return true; |
| 56 |
} |
| 57 |
|
| 58 |
// Is it first run ? |
| 59 |
if(empty($current_version)){ |
| 60 |
|
| 61 |
// Reinstall |
| 62 |
pagelayer_activation(); |
| 63 |
|
| 64 |
// Trick the following if conditions to not run |
| 65 |
$version = (int) str_replace('.', '', PAGELAYER_VERSION); |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
// Save the new Version |
| 70 |
update_option('pagelayer_version', PAGELAYER_VERSION); |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
// Add the action to load the plugin |
| 75 |
add_action('plugins_loaded', 'pagelayer_load_plugin'); |
| 76 |
|
| 77 |
// The function that will be called when the plugin is loaded |
| 78 |
function pagelayer_load_plugin(){ |
| 79 |
|
| 80 |
global $pagelayer; |
| 81 |
|
| 82 |
// Check if the installed version is outdated |
| 83 |
pagelayer_update_check(); |
| 84 |
|
| 85 |
// Set the array |
| 86 |
$pagelayer = new PageLayer(); |
| 87 |
|
| 88 |
// Is there any ACTION set ? |
| 89 |
$pagelayer->action = pagelayer_optreq('pagelayer-action'); |
| 90 |
|
| 91 |
// Load settings |
| 92 |
$options = get_option('pagelayer_options'); |
| 93 |
$pagelayer->settings['post_types'] = empty($options['post_types']) ? array('post', 'page') : $options['post_types']; |
| 94 |
$pagelayer->settings['css_code'] = empty($options['css_code']) ? '' : $options['css_code']; |
| 95 |
$pagelayer->settings['animate'] = empty($options['animate']) ? '' : $options['animate']; |
| 96 |
$pagelayer->settings['max_width'] = empty($options['max_width']) ? 1170 : $options['max_width']; |
| 97 |
|
| 98 |
// Load the language |
| 99 |
load_plugin_textdomain('pagelayer', false, PAGELAYER_SLUG.'/languages/'); |
| 100 |
|
| 101 |
// Show the promo |
| 102 |
pagelayer_maybe_promo([ |
| 103 |
'after' => 1,// In days |
| 104 |
'interval' => 30,// In days |
| 105 |
//'pro_url' => 'https://pagelayer.com/themes/wordpress/corporate/Bizworx_Pro', |
| 106 |
'rating' => 'https://wordpress.org/plugins/pagelayer/#reviews', |
| 107 |
'twitter' => 'https://twitter.com/pagelayer?status='.rawurlencode('I love #PageLayer Site Builder by @pagelayer team for my #WordPress site - '.home_url()), |
| 108 |
'facebook' => 'https://www.facebook.com/pagelayer', |
| 109 |
'website' => '//pagelayer.com', |
| 110 |
'image' => PAGELAYER_URL.'/images/pagelayer-logo-256.png' |
| 111 |
]); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
// This adds the left menu in WordPress Admin page |
| 116 |
add_action('admin_menu', 'pagelayer_admin_menu'); |
| 117 |
|
| 118 |
// Shows the admin menu of Pagelayer |
| 119 |
function pagelayer_admin_menu() { |
| 120 |
|
| 121 |
global $wp_version, $pagelayer; |
| 122 |
|
| 123 |
$capability = 'activate_plugins';// TODO : Capability for accessing this page |
| 124 |
|
| 125 |
// Add the menu page |
| 126 |
add_menu_page(__('PageLayer Editor'), __('PageLayer'), $capability, 'pagelayer', 'pagelayer_page_handler', PAGELAYER_URL.'/images/pagelayer-logo-19.png'); |
| 127 |
|
| 128 |
// Settings Page |
| 129 |
add_submenu_page('pagelayer', __('PageLayer Editor'), __('Settings'), $capability, 'pagelayer', 'pagelayer_page_handler'); |
| 130 |
|
| 131 |
// Its premium |
| 132 |
if(defined('PAGELAYER_PREMIUM')){ |
| 133 |
|
| 134 |
// Fonts link |
| 135 |
add_submenu_page('pagelayer', __('PageLayer Font Settings'), __('PageLayer Font Settings'), $capability, 'pagelayer_fonts', 'pagelayer_page_fonts'); |
| 136 |
|
| 137 |
// Its free |
| 138 |
}else{ |
| 139 |
|
| 140 |
// Go Pro link |
| 141 |
add_submenu_page('pagelayer', __('PageLayer Go Pro'), __('Go Pro'), $capability, PAGELAYER_PRO_URL); |
| 142 |
|
| 143 |
} |
| 144 |
|
| 145 |
} |
| 146 |
|
| 147 |
// This function will handle the pages in Pages in PageLayer |
| 148 |
function pagelayer_page_handler(){ |
| 149 |
|
| 150 |
global $wp_version, $pagelayer; |
| 151 |
|
| 152 |
include_once(PAGELAYER_DIR.'/main/settings.php'); |
| 153 |
|
| 154 |
// Handle fonts |
| 155 |
if($pagelayer->action == 'fonts-manager'){ |
| 156 |
include_once(PAGELAYER_DIR.'/main/fonts.php'); |
| 157 |
} |
| 158 |
|
| 159 |
} |
| 160 |
|
| 161 |
// Enqueue JS and CSS in Admin Panel for settings |
| 162 |
add_action( 'admin_enqueue_scripts', 'pagelayer_admin_script' ); |
| 163 |
function pagelayer_admin_script() { |
| 164 |
wp_enqueue_script( 'pagelayer-admin', PAGELAYER_JS.'/pagelayer-admin.js', array('jquery'), PAGELAYER_VERSION); |
| 165 |
wp_enqueue_style( 'pagelayer-admin', PAGELAYER_CSS.'/pagelayer-admin.css', array(), PAGELAYER_VERSION); |
| 166 |
} |
| 167 |
|
| 168 |
// Load the Live Body |
| 169 |
add_action('template_redirect', 'pagelayer_load_live_body', 4); |
| 170 |
|
| 171 |
function pagelayer_load_live_body(){ |
| 172 |
|
| 173 |
global $post; |
| 174 |
|
| 175 |
// If its not live editing then stop |
| 176 |
if(!pagelayer_is_live()){ |
| 177 |
return; |
| 178 |
} |
| 179 |
|
| 180 |
// If its the iFRAME then return |
| 181 |
if(pagelayer_is_live_iframe()){ |
| 182 |
return; |
| 183 |
} |
| 184 |
|
| 185 |
// Are you allowed to edit ? |
| 186 |
if(!pagelayer_user_can_edit()){ |
| 187 |
return; |
| 188 |
} |
| 189 |
|
| 190 |
// Load the editor live body |
| 191 |
include_once(PAGELAYER_DIR.'/main/live-body.php'); |
| 192 |
|
| 193 |
pagelayer_live_body(); |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
// Add the JS and CSS for Posts and Pages when being viewed ONLY if there is our content called |
| 198 |
add_action('template_redirect', 'pagelayer_enqueue_frontend', 5); |
| 199 |
|
| 200 |
function pagelayer_enqueue_frontend($force = false){ |
| 201 |
|
| 202 |
global $post, $pagelayer; |
| 203 |
|
| 204 |
if(!empty($pagelayer->cache['enqueue_frontend'])){ |
| 205 |
return; |
| 206 |
} |
| 207 |
|
| 208 |
if(empty($post->ID)){ |
| 209 |
return; |
| 210 |
} |
| 211 |
|
| 212 |
// Enqueue the FRONTEND CSS |
| 213 |
if(get_post_meta($post->ID , 'pagelayer-data') || $force){ |
| 214 |
|
| 215 |
// We dont need the auto <p> and <br> as they interfere with us |
| 216 |
remove_filter('the_content', 'wpautop'); |
| 217 |
|
| 218 |
// No need to add curly codes to the content |
| 219 |
remove_filter('the_content', 'wptexturize'); |
| 220 |
|
| 221 |
pagelayer_load_shortcodes(); |
| 222 |
$pagelayer->cache['enqueue_frontend'] = true; |
| 223 |
|
| 224 |
// Enqueue our Editor's Frontend JS |
| 225 |
wp_register_script('pagelayer-frontend', PAGELAYER_JS.'/givejs.php?give=pagelayer-frontend.js,nivo-lightbox.min.js,slippry.min.js,wow.min.js,jquery-numerator.js,simpleParallax.min.js', array('jquery'), PAGELAYER_VERSION); |
| 226 |
wp_enqueue_script('pagelayer-frontend'); |
| 227 |
|
| 228 |
wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/givecss.php?give=pagelayer-frontend.css,nivo-lightbox.css,slippry.css,animate.min.css', array(), PAGELAYER_VERSION); |
| 229 |
wp_enqueue_style('pagelayer-frontend'); |
| 230 |
|
| 231 |
wp_register_style('font-awesome', PAGELAYER_CSS.'/font-awesome.min.css', array(), PAGELAYER_VERSION); |
| 232 |
wp_enqueue_style('font-awesome'); |
| 233 |
|
| 234 |
// Load the global styles |
| 235 |
add_action('wp_head', 'pagelayer_global_styles', 5); |
| 236 |
|
| 237 |
// Load custom widgets |
| 238 |
do_action('pagelayer_custom_frontend_enqueue'); |
| 239 |
|
| 240 |
} |
| 241 |
|
| 242 |
} |
| 243 |
|
| 244 |
// Load the google fonts |
| 245 |
add_action('wp_footer', 'pagelayer_enqueue_fonts', 5); |
| 246 |
|
| 247 |
function pagelayer_enqueue_fonts(){ |
| 248 |
global $pagelayer; |
| 249 |
|
| 250 |
if(empty($pagelayer->cache['enqueue_frontend'])){ |
| 251 |
return; |
| 252 |
} |
| 253 |
|
| 254 |
$url = 'Open Sans:300italic,400italic,600italic,300,400,600&subset=latin,latin-ext'; |
| 255 |
//pagelayer_print($pagelayer->runtime_fonts);die('alpesh'); |
| 256 |
|
| 257 |
foreach($pagelayer->runtime_fonts as $font){ |
| 258 |
$url .= '|'.$font.':100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i'; |
| 259 |
} |
| 260 |
|
| 261 |
//echo '<link href="https://fonts.googleapis.com/css?family='.$url.'" rel="stylesheet">'; |
| 262 |
|
| 263 |
wp_register_style('pagelayer-google-font', 'https://fonts.googleapis.com/css?family='.rawurlencode($url), array(), PAGELAYER_VERSION); |
| 264 |
wp_enqueue_style('pagelayer-google-font'); |
| 265 |
|
| 266 |
} |
| 267 |
|
| 268 |
// We need to handle global styles |
| 269 |
function pagelayer_global_styles(){ |
| 270 |
|
| 271 |
$styles = '<style id="pagelayer-global-styles" type="text/css">'; |
| 272 |
|
| 273 |
$width = get_option('pagelayer_content_width', '1170'); |
| 274 |
|
| 275 |
$styles .= '.pagelayer-row-stretch-auto .pagelayer-row-holder{ max-width: '.$width.'px; margin-left: auto; margin-right: auto;}'; |
| 276 |
|
| 277 |
$styles .= '</style>'; |
| 278 |
|
| 279 |
echo $styles; |
| 280 |
} |
| 281 |
|
| 282 |
// Load the live editor if needed |
| 283 |
add_action('wp_enqueue_scripts', 'pagelayer_load_live', 9999); |
| 284 |
|
| 285 |
function pagelayer_load_live(){ |
| 286 |
|
| 287 |
global $post; |
| 288 |
|
| 289 |
// If its not live editing then stop |
| 290 |
if(!pagelayer_is_live_iframe()){ |
| 291 |
return; |
| 292 |
} |
| 293 |
|
| 294 |
// Are you allowed to edit ? |
| 295 |
if(!pagelayer_user_can_edit()){ |
| 296 |
return; |
| 297 |
} |
| 298 |
|
| 299 |
// Load the editor class |
| 300 |
include_once(PAGELAYER_DIR.'/main/live.php'); |
| 301 |
|
| 302 |
// Call the constructor |
| 303 |
$pl_editor = new PageLayer_LiveEditor(); |
| 304 |
|
| 305 |
} |
| 306 |
|
| 307 |
// Show the backend editor options |
| 308 |
add_action('edit_form_after_title', 'pagelayer_after_title'); |
| 309 |
function pagelayer_after_title(){ |
| 310 |
|
| 311 |
global $post; |
| 312 |
|
| 313 |
// Get the current screen |
| 314 |
$current_screen = get_current_screen(); |
| 315 |
|
| 316 |
// For gutenberg |
| 317 |
if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){ |
| 318 |
|
| 319 |
// Add the code in the footer |
| 320 |
add_action('admin_footer', 'pagelayer_gutenberg_after_title'); |
| 321 |
|
| 322 |
return; |
| 323 |
} |
| 324 |
|
| 325 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 326 |
|
| 327 |
echo ' |
| 328 |
<div id="pagelayer-editor-button-row" style="margin-top:15px"> |
| 329 |
<a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;"> |
| 330 |
<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with PageLayer').'</span> |
| 331 |
</a> |
| 332 |
</div>'; |
| 333 |
|
| 334 |
} |
| 335 |
|
| 336 |
function pagelayer_gutenberg_after_title(){ |
| 337 |
|
| 338 |
global $post; |
| 339 |
|
| 340 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 341 |
|
| 342 |
echo ' |
| 343 |
<div id="pagelayer-editor-button-row" style="margin-left:15px; display:none"> |
| 344 |
<a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;"> |
| 345 |
<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with PageLayer').'</span> |
| 346 |
</a> |
| 347 |
</div> |
| 348 |
|
| 349 |
<script type="text/javascript"> |
| 350 |
jQuery(document).ready(function(){ |
| 351 |
|
| 352 |
var pagelayer_timer; |
| 353 |
var pagelayer_button = function(){ |
| 354 |
var button = jQuery("#pagelayer-editor-button-row"); |
| 355 |
var g = jQuery(".edit-post-header-toolbar"); |
| 356 |
if(g.length < 1){ |
| 357 |
return; |
| 358 |
} |
| 359 |
button.detach(); |
| 360 |
//console.log(button); |
| 361 |
g.append(button); |
| 362 |
button.show(); |
| 363 |
clearInterval(pagelayer_timer); |
| 364 |
} |
| 365 |
pagelayer_timer = setInterval(pagelayer_button, 100); |
| 366 |
}); |
| 367 |
</script>'; |
| 368 |
|
| 369 |
} |
| 370 |
|
| 371 |
add_filter( 'post_row_actions', 'pagelayer_quick_link', 10, 2 ); |
| 372 |
add_filter( 'page_row_actions', 'pagelayer_quick_link', 10, 2 ); |
| 373 |
function pagelayer_quick_link($actions, $post){ |
| 374 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 375 |
|
| 376 |
$actions['pagelayer'] = '<a href="'.esc_url( $link ).'">'.__( 'Edit using PageLayer', 'pagelayer') .'</a>'; |
| 377 |
|
| 378 |
return $actions; |
| 379 |
} |
| 380 |
|
| 381 |
// The ajax handler |
| 382 |
add_action('wp_ajax_pagelayer_wp_widget', 'pagelayer_wp_widget_ajax'); |
| 383 |
function pagelayer_wp_widget_ajax(){ |
| 384 |
|
| 385 |
global $pagelayer; |
| 386 |
|
| 387 |
// Some AJAX security |
| 388 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 389 |
|
| 390 |
pagelayer_load_shortcodes(); |
| 391 |
|
| 392 |
header('Content-Type: application/json'); |
| 393 |
|
| 394 |
$ret = []; |
| 395 |
$tag = @$_POST['tag']; |
| 396 |
//pagelayer_print($pagelayer->shortcodes[$tag]); |
| 397 |
|
| 398 |
// No tag ? |
| 399 |
if(empty($pagelayer->shortcodes[$tag])){ |
| 400 |
$ret['error'][] = 'No Tag'; |
| 401 |
echo json_encode($ret); |
| 402 |
wp_die(); |
| 403 |
} |
| 404 |
|
| 405 |
// Include the widgets |
| 406 |
include_once(ABSPATH . 'wp-admin/includes/widgets.php'); |
| 407 |
|
| 408 |
$class = $pagelayer->shortcodes[$tag]['widget']; |
| 409 |
|
| 410 |
// Check the widget class exists ? |
| 411 |
if(empty($class) || !class_exists($class)){ |
| 412 |
$ret['error'][] = 'No Widget Class'; |
| 413 |
echo json_encode($ret); |
| 414 |
wp_die(); |
| 415 |
} |
| 416 |
|
| 417 |
$instance = []; |
| 418 |
$widget = new $class(); |
| 419 |
$widget->_set('pagelayer-widget-1234567890'); |
| 420 |
|
| 421 |
// Is there any existing data ? |
| 422 |
if(!empty($_POST['widget_data'])){ |
| 423 |
$json = json_decode(stripslashes($_POST['widget_data']), true); |
| 424 |
//pagelayer_print($json);die(); |
| 425 |
if(!empty($json)){ |
| 426 |
$instance = $json; |
| 427 |
} |
| 428 |
} |
| 429 |
|
| 430 |
// Are there any form values ? |
| 431 |
if(!empty($_POST['values'])){ |
| 432 |
parse_str(stripslashes($_POST['values']), $data); |
| 433 |
//pagelayer_print($data);die(); |
| 434 |
|
| 435 |
// Any data ? |
| 436 |
if(!empty($data)){ |
| 437 |
|
| 438 |
// First key is useless |
| 439 |
$data = current($data); |
| 440 |
|
| 441 |
// Do we still have valid data ? |
| 442 |
if(!empty($data)){ |
| 443 |
|
| 444 |
// 2nd key is useless and just over-ride instance |
| 445 |
$instance = current($data); |
| 446 |
|
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
// Get the form |
| 452 |
ob_start(); |
| 453 |
$widget->form($instance); |
| 454 |
$ret['form'] = ob_get_contents(); |
| 455 |
ob_end_clean(); |
| 456 |
|
| 457 |
// Get the html |
| 458 |
ob_start(); |
| 459 |
$widget->widget([], $instance); |
| 460 |
$ret['html'] = ob_get_contents(); |
| 461 |
ob_end_clean(); |
| 462 |
|
| 463 |
// Widget data to set |
| 464 |
if(!empty($instance)){ |
| 465 |
$ret['widget_data'] = $instance; |
| 466 |
} |
| 467 |
|
| 468 |
echo json_encode($ret); |
| 469 |
wp_die(); |
| 470 |
|
| 471 |
} |
| 472 |
|
| 473 |
// Update Post content |
| 474 |
add_action('wp_ajax_pagelayer_save_content', 'pagelayer_save_content'); |
| 475 |
function pagelayer_save_content(){ |
| 476 |
|
| 477 |
// Some AJAX security |
| 478 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 479 |
|
| 480 |
$content = $_POST['pagelayer_update_content']; |
| 481 |
|
| 482 |
$postID = (int) $_GET['postID']; |
| 483 |
|
| 484 |
if(empty($postID)){ |
| 485 |
$msg['error'] = 'Invalid post ID'; |
| 486 |
} |
| 487 |
|
| 488 |
// Check if the post exists |
| 489 |
|
| 490 |
if(!empty($postID) && !empty($content)){ |
| 491 |
|
| 492 |
$post = array( |
| 493 |
'ID' => $postID, |
| 494 |
'post_content' => $content, |
| 495 |
); |
| 496 |
|
| 497 |
// Update the post into the database |
| 498 |
wp_update_post($post); |
| 499 |
|
| 500 |
if (is_wp_error($postID)) { |
| 501 |
$msg['error'] = 'Unable to update the Post Content for some reason'; |
| 502 |
}else{ |
| 503 |
$msg['success'] = 'Post Content was updated successfully!'; |
| 504 |
} |
| 505 |
|
| 506 |
}else{ |
| 507 |
$msg['error'] = "Unable to update the Post Content for some reason"; |
| 508 |
} |
| 509 |
|
| 510 |
echo json_encode($msg); |
| 511 |
wp_die(); |
| 512 |
|
| 513 |
} |
| 514 |
|
| 515 |
// Shortcodes Widget Handler |
| 516 |
add_action('wp_ajax_pagelayer_do_shortcodes', 'pagelayer_do_shortcodes'); |
| 517 |
function pagelayer_do_shortcodes(){ |
| 518 |
|
| 519 |
// Some AJAX security |
| 520 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 521 |
|
| 522 |
$data = ''; |
| 523 |
if(isset($_REQUEST['shortcode_data'])){ |
| 524 |
$data = stripslashes($_REQUEST['shortcode_data']); |
| 525 |
} |
| 526 |
|
| 527 |
echo do_shortcode($data); |
| 528 |
wp_die(); |
| 529 |
|
| 530 |
} |
| 531 |
|
| 532 |
// Get the Site Title |
| 533 |
add_action('wp_ajax_pagelayer_fetch_site_title', 'pagelayer_fetch_site_title'); |
| 534 |
function pagelayer_fetch_site_title(){ |
| 535 |
|
| 536 |
// Some AJAX security |
| 537 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 538 |
|
| 539 |
echo get_bloginfo('name'); |
| 540 |
wp_die(); |
| 541 |
} |
| 542 |
|
| 543 |
// Update the Site Title |
| 544 |
add_action('wp_ajax_pagelayer_update_site_title', 'pagelayer_update_site_title'); |
| 545 |
function pagelayer_update_site_title(){ |
| 546 |
global $wpdb; |
| 547 |
|
| 548 |
// Some AJAX security |
| 549 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 550 |
|
| 551 |
$site_title = $_POST['site_title']; |
| 552 |
|
| 553 |
update_option('blogname', $site_title); |
| 554 |
|
| 555 |
$wpdb->query("UPDATE `sm_sitemeta` |
| 556 |
SET meta_value = '".$site_title."' |
| 557 |
WHERE meta_key = 'site_name'"); |
| 558 |
wp_die(); |
| 559 |
} |
| 560 |
|
| 561 |
// Show the SideBars |
| 562 |
add_action('wp_ajax_pagelayer_fetch_sidebar', 'pagelayer_fetch_sidebar'); |
| 563 |
function pagelayer_fetch_sidebar(){ |
| 564 |
|
| 565 |
global $wp_registered_sidebars; |
| 566 |
|
| 567 |
// Some AJAX security |
| 568 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 569 |
|
| 570 |
// Create a list |
| 571 |
$pagelayer_wp_widgets = array(); |
| 572 |
|
| 573 |
foreach($wp_registered_sidebars as $v){ |
| 574 |
$pagelayer_wp_widgets[$v['id']] = $v['name']; |
| 575 |
} |
| 576 |
|
| 577 |
$id = @$_REQUEST['sidebar']; |
| 578 |
|
| 579 |
if(function_exists('dynamic_sidebar') && !empty($pagelayer_wp_widgets[$id])) { |
| 580 |
ob_start(); |
| 581 |
dynamic_sidebar($id); |
| 582 |
$result = ob_get_clean(); |
| 583 |
}else{ |
| 584 |
$result = 'No such Widget Area !'; |
| 585 |
} |
| 586 |
|
| 587 |
echo $result; |
| 588 |
wp_die(); |
| 589 |
|
| 590 |
} |
| 591 |
|
| 592 |
// Show the primary menu ! |
| 593 |
add_action('wp_ajax_pagelayer_fetch_primary_menu', 'pagelayer_fetch_primary_menu'); |
| 594 |
function pagelayer_fetch_primary_menu(){ |
| 595 |
|
| 596 |
// Some AJAX security |
| 597 |
check_ajax_referer('pagelayer_ajax', 'nonce'); |
| 598 |
|
| 599 |
echo wp_nav_menu( array( |
| 600 |
'menu' => 'primary-menu', |
| 601 |
'menu_id' => 'pagelayer-header-menu', |
| 602 |
'theme_location' => 'primary', |
| 603 |
'menu_class' => 'primary-menu', |
| 604 |
) ); |
| 605 |
|
| 606 |
wp_die(); |
| 607 |
} |
| 608 |
|