| 1 |
<?php |
| 2 |
|
| 3 |
// We need the ABSPATH |
| 4 |
if (!defined('ABSPATH')) exit; |
| 5 |
|
| 6 |
define('PAGELAYER_BASE', plugin_basename(PAGELAYER_FILE)); |
| 7 |
define('PAGELAYER_PRO_BASE', 'pagelayer-pro/pagelayer-pro.php'); |
| 8 |
define('PAGELAYER_VERSION', '1.0.5'); |
| 9 |
define('PAGELAYER_DIR', 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/pricing?from=plugin'); |
| 15 |
define('PAGELAYER_WWW_URL', 'https://pagelayer.com/'); |
| 16 |
define('PAGELAYER_DOCS', 'https://pagelayer.com/docs/'); |
| 17 |
define('PAGELAYER_API', 'https://api.pagelayer.com/'); |
| 18 |
define('PAGELAYER_SC_PREFIX', 'pl'); |
| 19 |
define('PAGELAYER_YOUTUBE_BG', 'https://www.youtube.com/watch?v=Csa6rvCWmLU'); |
| 20 |
@define('PAGELAYER_BRAND_TEXT', 'Pagelayer'); |
| 21 |
@define('PAGELAYER_LOGO', PAGELAYER_URL.'/images/pagelayer-logo-40.png'); |
| 22 |
|
| 23 |
include_once(PAGELAYER_DIR.'/main/functions.php'); |
| 24 |
include_once(PAGELAYER_DIR.'/main/class.php'); |
| 25 |
|
| 26 |
// Ok so we are now ready to go |
| 27 |
register_activation_hook(PAGELAYER_FILE, 'pagelayer_activation'); |
| 28 |
|
| 29 |
// Is called when the ADMIN enables the plugin |
| 30 |
function pagelayer_activation(){ |
| 31 |
|
| 32 |
global $wpdb; |
| 33 |
|
| 34 |
$sql = array(); |
| 35 |
|
| 36 |
/*$sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."pagelayer_logs`"; |
| 37 |
|
| 38 |
foreach($sql as $sk => $sv){ |
| 39 |
$wpdb->query($sv); |
| 40 |
}*/ |
| 41 |
|
| 42 |
add_option('pagelayer_version', PAGELAYER_VERSION); |
| 43 |
add_option('pagelayer_options', array()); |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
// Checks if we are to update ? |
| 48 |
function pagelayer_update_check(){ |
| 49 |
|
| 50 |
global $wpdb; |
| 51 |
|
| 52 |
$sql = array(); |
| 53 |
$current_version = get_option('pagelayer_version'); |
| 54 |
$version = (int) str_replace('.', '', $current_version); |
| 55 |
|
| 56 |
// No update required |
| 57 |
if($current_version == PAGELAYER_VERSION){ |
| 58 |
return true; |
| 59 |
} |
| 60 |
|
| 61 |
// Is it first run ? |
| 62 |
if(empty($current_version)){ |
| 63 |
|
| 64 |
// Reinstall |
| 65 |
pagelayer_activation(); |
| 66 |
|
| 67 |
// Trick the following if conditions to not run |
| 68 |
$version = (int) str_replace('.', '', PAGELAYER_VERSION); |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
// Save the new Version |
| 73 |
update_option('pagelayer_version', PAGELAYER_VERSION); |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
// Add the action to load the plugin |
| 78 |
add_action('plugins_loaded', 'pagelayer_load_plugin'); |
| 79 |
|
| 80 |
// The function that will be called when the plugin is loaded |
| 81 |
function pagelayer_load_plugin(){ |
| 82 |
|
| 83 |
global $pagelayer; |
| 84 |
|
| 85 |
// Check if the installed version is outdated |
| 86 |
pagelayer_update_check(); |
| 87 |
|
| 88 |
// Set the array |
| 89 |
$pagelayer = new PageLayer(); |
| 90 |
|
| 91 |
// Load license |
| 92 |
pagelayer_load_license(); |
| 93 |
|
| 94 |
// Is there any ACTION set ? |
| 95 |
$pagelayer->action = pagelayer_optreq('pagelayer-action'); |
| 96 |
|
| 97 |
// Load settings |
| 98 |
$options = get_option('pagelayer_options'); |
| 99 |
$pagelayer->settings['post_types'] = empty(get_option('pl_support_ept')) ? ['post', 'page'] : get_option('pl_support_ept'); |
| 100 |
$pagelayer->settings['max_width'] = (int) (empty(get_option('pagelayer_content_width')) ? 1170 : get_option('pagelayer_content_width')); |
| 101 |
$pagelayer->settings['tablet_breakpoint'] = (int) (empty(get_option('pagelayer_tablet_breakpoint')) ? 768 : get_option('pagelayer_tablet_breakpoint')); |
| 102 |
$pagelayer->settings['mobile_breakpoint'] = (int) (empty(get_option('pagelayer_mobile_breakpoint')) ? 360 : get_option('pagelayer_mobile_breakpoint')); |
| 103 |
|
| 104 |
// Load the language |
| 105 |
load_plugin_textdomain('pagelayer', false, PAGELAYER_SLUG.'/languages/'); |
| 106 |
|
| 107 |
// Show the promo |
| 108 |
pagelayer_maybe_promo([ |
| 109 |
'after' => 1,// In days |
| 110 |
'interval' => 30,// In days |
| 111 |
'pro_url' => PAGELAYER_PRO_URL, |
| 112 |
'rating' => 'https://wordpress.org/plugins/pagelayer/#reviews', |
| 113 |
'twitter' => 'https://twitter.com/pagelayer?status='.rawurlencode('I love #Pagelayer Site Builder by @pagelayer team for my #WordPress site - '.home_url()), |
| 114 |
'facebook' => 'https://www.facebook.com/pagelayer', |
| 115 |
'website' => PAGELAYER_WWW_URL, |
| 116 |
'image' => PAGELAYER_URL.'/images/pagelayer-logo-256.png' |
| 117 |
]); |
| 118 |
|
| 119 |
// Its premium |
| 120 |
if(defined('PAGELAYER_PREMIUM')){ |
| 121 |
|
| 122 |
// Check for updates |
| 123 |
include_once(PAGELAYER_DIR.'/main/plugin-update-checker.php'); |
| 124 |
$pagelayer_updater = Pagelayer_PucFactory::buildUpdateChecker(PAGELAYER_API.'updates.php?version='.PAGELAYER_VERSION, PAGELAYER_FILE); |
| 125 |
|
| 126 |
// Add the license key to query arguments |
| 127 |
$pagelayer_updater->addQueryArgFilter('pagelayer_updater_filter_args'); |
| 128 |
|
| 129 |
// Show the text to install the license key |
| 130 |
add_filter('puc_manual_final_check_link-pagelayer-pro', 'pagelayer_updater_check_link', 10, 1); |
| 131 |
|
| 132 |
// Load the template builder |
| 133 |
include_once(PAGELAYER_DIR.'/main/template-builder.php'); |
| 134 |
} |
| 135 |
|
| 136 |
} |
| 137 |
|
| 138 |
// Add our license key if ANY |
| 139 |
function pagelayer_updater_filter_args($queryArgs) { |
| 140 |
|
| 141 |
global $pagelayer; |
| 142 |
|
| 143 |
if ( !empty($pagelayer->license['license']) ) { |
| 144 |
$queryArgs['license'] = $pagelayer->license['license']; |
| 145 |
} |
| 146 |
|
| 147 |
return $queryArgs; |
| 148 |
} |
| 149 |
|
| 150 |
// Handle the Check for update link and ask to install license key |
| 151 |
function pagelayer_updater_check_link($final_link){ |
| 152 |
|
| 153 |
global $pagelayer; |
| 154 |
|
| 155 |
if(empty($pagelayer->license['license'])){ |
| 156 |
return '<a href="'.admin_url('admin.php?page=pagelayer_license').'">Install Pagelayer Pro License Key</a>'; |
| 157 |
} |
| 158 |
|
| 159 |
return $final_link; |
| 160 |
} |
| 161 |
|
| 162 |
// This adds the left menu in WordPress Admin page |
| 163 |
add_action('admin_menu', 'pagelayer_admin_menu', 5); |
| 164 |
|
| 165 |
// Shows the admin menu of Pagelayer |
| 166 |
function pagelayer_admin_menu() { |
| 167 |
|
| 168 |
global $wp_version, $pagelayer; |
| 169 |
|
| 170 |
$capability = 'activate_plugins';// TODO : Capability for accessing this page |
| 171 |
|
| 172 |
// Add the menu page |
| 173 |
add_menu_page(__('Pagelayer Editor'), __('Pagelayer'), $capability, 'pagelayer', 'pagelayer_page_handler', PAGELAYER_URL.'/images/pagelayer-logo-19.png'); |
| 174 |
|
| 175 |
// Settings Page |
| 176 |
add_submenu_page('pagelayer', __('Pagelayer Editor'), __('Settings'), $capability, 'pagelayer', 'pagelayer_page_handler'); |
| 177 |
|
| 178 |
// Its premium |
| 179 |
if(defined('PAGELAYER_PREMIUM')){ |
| 180 |
|
| 181 |
// Fonts link |
| 182 |
add_submenu_page('pagelayer', __('Font Settings'), __('Font Settings'), $capability, 'admin.php?page=pagelayer#settings'); |
| 183 |
|
| 184 |
// Add new template |
| 185 |
add_submenu_page('pagelayer', __('Theme Templates'), __('Theme Templates'), $capability, 'edit.php?post_type=pagelayer-template'); |
| 186 |
|
| 187 |
// Add new template Link |
| 188 |
//add_submenu_page('pagelayer', __('Add New Template'), __('Add New Template'), $capability, 'edit.php?post_type=pagelayer-template#new'); |
| 189 |
|
| 190 |
// Add new template |
| 191 |
add_submenu_page('pagelayer', __('Add New Template'), __('Add New Template'), $capability, 'pagelayer_template_wizard', 'pagelayer_builder_template_wizard'); |
| 192 |
|
| 193 |
// Export Template Wizard |
| 194 |
add_submenu_page('pagelayer', __('Export Templates into a Theme'), __('Export Templates'), $capability, 'pagelayer_template_export', 'pagelayer_builder_export'); |
| 195 |
|
| 196 |
// Its free |
| 197 |
}else{ |
| 198 |
|
| 199 |
// Go Pro link |
| 200 |
add_submenu_page('pagelayer', __('Pagelayer Go Pro'), __('Go Pro'), $capability, PAGELAYER_PRO_URL); |
| 201 |
|
| 202 |
} |
| 203 |
|
| 204 |
// License Page |
| 205 |
add_submenu_page('pagelayer', __('Pagelayer Editor'), __('License'), $capability, 'pagelayer_license', 'pagelayer_license_page'); |
| 206 |
|
| 207 |
} |
| 208 |
|
| 209 |
// This function will handle the Settings Pages in PageLayer |
| 210 |
function pagelayer_page_handler(){ |
| 211 |
|
| 212 |
global $wp_version, $pagelayer; |
| 213 |
|
| 214 |
wp_enqueue_script( 'pagelayer-admin', PAGELAYER_JS.'/pagelayer-admin.js', array('jquery'), PAGELAYER_VERSION); |
| 215 |
wp_enqueue_style( 'pagelayer-admin', PAGELAYER_CSS.'/pagelayer-admin.css', array(), PAGELAYER_VERSION); |
| 216 |
|
| 217 |
include_once(PAGELAYER_DIR.'/main/settings.php'); |
| 218 |
|
| 219 |
pagelayer_settings_page(); |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
// This function will handle the Settings Pages in PageLayer |
| 224 |
function pagelayer_license_page(){ |
| 225 |
|
| 226 |
global $wp_version, $pagelayer; |
| 227 |
|
| 228 |
include_once(PAGELAYER_DIR.'/main/license.php'); |
| 229 |
|
| 230 |
pagelayer_license(); |
| 231 |
|
| 232 |
} |
| 233 |
|
| 234 |
// Load the Live Body |
| 235 |
add_action('template_redirect', 'pagelayer_load_live_body', 4); |
| 236 |
|
| 237 |
function pagelayer_load_live_body(){ |
| 238 |
|
| 239 |
global $post; |
| 240 |
|
| 241 |
// If its not live editing then stop |
| 242 |
if(!pagelayer_is_live()){ |
| 243 |
return; |
| 244 |
} |
| 245 |
|
| 246 |
// If its the iFRAME then return |
| 247 |
if(pagelayer_is_live_iframe()){ |
| 248 |
return; |
| 249 |
} |
| 250 |
|
| 251 |
// Are you allowed to edit ? |
| 252 |
if(!pagelayer_user_can_edit()){ |
| 253 |
return; |
| 254 |
} |
| 255 |
|
| 256 |
// Load the editor live body |
| 257 |
include_once(PAGELAYER_DIR.'/main/live-body.php'); |
| 258 |
|
| 259 |
pagelayer_live_body(); |
| 260 |
|
| 261 |
} |
| 262 |
|
| 263 |
// Add the JS and CSS for Posts and Pages when being viewed ONLY if there is our content called |
| 264 |
add_action('template_redirect', 'pagelayer_enqueue_frontend', 5); |
| 265 |
|
| 266 |
function pagelayer_enqueue_frontend($force = false){ |
| 267 |
|
| 268 |
global $post, $pagelayer; |
| 269 |
|
| 270 |
if(!empty($pagelayer->cache['enqueue_frontend'])){ |
| 271 |
return; |
| 272 |
} |
| 273 |
|
| 274 |
if(empty($post->ID) && empty($force)){ |
| 275 |
return; |
| 276 |
} |
| 277 |
|
| 278 |
$is_pagelayer = false; |
| 279 |
$is_audio = false; |
| 280 |
|
| 281 |
// This IF is for Archives mainly as $post->ID is only the first post in the archive |
| 282 |
// and we need to make sure that other posts are pagelayer or not |
| 283 |
if(!empty($GLOBALS['wp_query']->posts) && is_array($GLOBALS['wp_query']->posts)){ |
| 284 |
foreach($GLOBALS['wp_query']->posts as $v){ |
| 285 |
if(get_post_meta($v->ID , 'pagelayer-data')){ |
| 286 |
$is_pagelayer = true; |
| 287 |
} |
| 288 |
|
| 289 |
if(preg_match('/\[pl_audio/is', $v->post_content)){ |
| 290 |
$is_audio = true; |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
// Enqueue the FRONTEND CSS |
| 296 |
if(get_post_meta($post->ID , 'pagelayer-data') || $is_pagelayer || $force){ |
| 297 |
|
| 298 |
// We dont need the auto <p> and <br> as they interfere with us |
| 299 |
remove_filter('the_content', 'wpautop'); |
| 300 |
|
| 301 |
// No need to add curly codes to the content |
| 302 |
remove_filter('the_content', 'wptexturize'); |
| 303 |
|
| 304 |
pagelayer_load_shortcodes(); |
| 305 |
$pagelayer->cache['enqueue_frontend'] = true; |
| 306 |
|
| 307 |
// Load the global styles |
| 308 |
add_action('wp_head', 'pagelayer_global_js', 2); |
| 309 |
|
| 310 |
$premium_js = ''; |
| 311 |
$premium_css = ''; |
| 312 |
if(defined('PAGELAYER_PREMIUM')){ |
| 313 |
$premium_js = ',chart.min.js,slick.min.js,premium-frontend.js'; |
| 314 |
$premium_css = ',slick.css,slick-theme.css,premium-frontend.css'; |
| 315 |
|
| 316 |
// Load this For audio widget |
| 317 |
if($is_audio || pagelayer_is_live_iframe()){ |
| 318 |
wp_enqueue_script('wp-mediaelement'); |
| 319 |
wp_enqueue_style( 'wp-mediaelement' ); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
// Enqueue our Editor's Frontend JS |
| 324 |
wp_register_script('pagelayer-frontend', PAGELAYER_JS.'/givejs.php?give=pagelayer-frontend.js,nivo-lightbox.min.js,wow.min.js,jquery-numerator.js,simpleParallax.min.js,owl.carousel.min.js'.$premium_js, array('jquery'), PAGELAYER_VERSION); |
| 325 |
wp_enqueue_script('pagelayer-frontend'); |
| 326 |
|
| 327 |
wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/givecss.php?give=pagelayer-frontend.css,nivo-lightbox.css,animate.min.css,owl.carousel.min.css,owl.theme.default.min.css'.$premium_css, array(), PAGELAYER_VERSION); |
| 328 |
wp_enqueue_style('pagelayer-frontend'); |
| 329 |
|
| 330 |
// Get list of enabled icons |
| 331 |
$icons = pagelayer_enabled_icons(); |
| 332 |
foreach($icons as $icon){ |
| 333 |
wp_register_style($icon, PAGELAYER_CSS.'/givecss.php?give='.$icon.'.min.css', array(), PAGELAYER_VERSION); |
| 334 |
wp_enqueue_style($icon); |
| 335 |
} |
| 336 |
|
| 337 |
// Load the global styles |
| 338 |
add_action('wp_head', 'pagelayer_global_styles', 5); |
| 339 |
|
| 340 |
// Load custom widgets |
| 341 |
do_action('pagelayer_custom_frontend_enqueue'); |
| 342 |
|
| 343 |
} |
| 344 |
|
| 345 |
} |
| 346 |
|
| 347 |
// Load the google fonts |
| 348 |
add_action('wp_footer', 'pagelayer_enqueue_fonts', 5); |
| 349 |
|
| 350 |
function pagelayer_enqueue_fonts(){ |
| 351 |
global $pagelayer; |
| 352 |
|
| 353 |
if(empty($pagelayer->cache['enqueue_frontend'])){ |
| 354 |
return; |
| 355 |
} |
| 356 |
|
| 357 |
$url = 'Open Sans:300italic,400italic,600italic,300,400,600&subset=latin,latin-ext'; |
| 358 |
//pagelayer_print($pagelayer->runtime_fonts);die('alpesh'); |
| 359 |
|
| 360 |
foreach($pagelayer->runtime_fonts as $font){ |
| 361 |
$url .= '|'.$font.':100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i'; |
| 362 |
} |
| 363 |
|
| 364 |
// Fetch body font if given |
| 365 |
if(get_option('pagelayer_body_font')){ |
| 366 |
$url .= '|'.get_option('pagelayer_body_font').':100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i'; |
| 367 |
} |
| 368 |
|
| 369 |
//echo '<link href="https://fonts.googleapis.com/css?family='.$url.'" rel="stylesheet">'; |
| 370 |
|
| 371 |
wp_register_style('pagelayer-google-font', 'https://fonts.googleapis.com/css?family='.rawurlencode($url), array(), PAGELAYER_VERSION); |
| 372 |
wp_enqueue_style('pagelayer-google-font'); |
| 373 |
|
| 374 |
} |
| 375 |
|
| 376 |
// Load any header we have |
| 377 |
function pagelayer_global_js(){ |
| 378 |
global $pagelayer; |
| 379 |
|
| 380 |
echo '<script> |
| 381 |
var pagelayer_ajaxurl = "'.admin_url( 'admin-ajax.php' ).'?"; |
| 382 |
var pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'"; |
| 383 |
var pagelayer_server_time = '.time().'; |
| 384 |
var pagelayer_facebook_id = "'.get_option('pagelayer-fbapp-id').'"; |
| 385 |
var pagelayer_settings = '.json_encode($pagelayer->settings).'; |
| 386 |
</script>'; |
| 387 |
|
| 388 |
} |
| 389 |
|
| 390 |
// We need to handle global styles |
| 391 |
function pagelayer_global_styles(){ |
| 392 |
|
| 393 |
global $pagelayer; |
| 394 |
|
| 395 |
$styles = '<style id="pagelayer-global-styles" type="text/css">'; |
| 396 |
|
| 397 |
// Style for only child row holder |
| 398 |
$styles .= '.pagelayer-row-stretch-auto > .pagelayer-row-holder, .pagelayer-row-stretch-full > .pagelayer-row-holder.pagelayer-width-auto{ max-width: '.$pagelayer->settings['max_width'].'px; margin-left: auto; margin-right: auto;}'; |
| 399 |
|
| 400 |
if(get_option('pagelayer_body_font')){ |
| 401 |
$styles .= 'body *{font-family:'.get_option("pagelayer_body_font").';}'; |
| 402 |
} |
| 403 |
|
| 404 |
$styles .= '</style>'; |
| 405 |
|
| 406 |
echo $styles; |
| 407 |
} |
| 408 |
|
| 409 |
// Load the live editor if needed |
| 410 |
add_action('wp_enqueue_scripts', 'pagelayer_load_live', 9999); |
| 411 |
|
| 412 |
function pagelayer_load_live(){ |
| 413 |
|
| 414 |
global $post; |
| 415 |
|
| 416 |
// If its not live editing then stop |
| 417 |
if(!pagelayer_is_live_iframe()){ |
| 418 |
return; |
| 419 |
} |
| 420 |
|
| 421 |
// Are you allowed to edit ? |
| 422 |
if(!pagelayer_user_can_edit()){ |
| 423 |
return; |
| 424 |
} |
| 425 |
|
| 426 |
// Load the editor class |
| 427 |
include_once(PAGELAYER_DIR.'/main/live.php'); |
| 428 |
|
| 429 |
// Call the constructor |
| 430 |
$pl_editor = new PageLayer_LiveEditor(); |
| 431 |
|
| 432 |
} |
| 433 |
|
| 434 |
// If we are doing ajax and its a pagelayer ajax |
| 435 |
if(wp_doing_ajax()){ |
| 436 |
include_once(PAGELAYER_DIR.'/main/ajax.php'); |
| 437 |
} |
| 438 |
|
| 439 |
// Show the backend editor options |
| 440 |
add_action('edit_form_after_title', 'pagelayer_after_title', 10); |
| 441 |
function pagelayer_after_title(){ |
| 442 |
|
| 443 |
global $post; |
| 444 |
|
| 445 |
// Get the current screen |
| 446 |
$current_screen = get_current_screen(); |
| 447 |
|
| 448 |
// For gutenberg |
| 449 |
if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){ |
| 450 |
|
| 451 |
// Add the code in the footer |
| 452 |
add_action('admin_footer', 'pagelayer_gutenberg_after_title'); |
| 453 |
|
| 454 |
return; |
| 455 |
} |
| 456 |
|
| 457 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 458 |
|
| 459 |
echo ' |
| 460 |
<div id="pagelayer-editor-button-row" style="margin-top:15px; display:inline-block;"> |
| 461 |
<a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;"> |
| 462 |
<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with Pagelayer').'</span> |
| 463 |
</a> |
| 464 |
</div>'; |
| 465 |
|
| 466 |
} |
| 467 |
|
| 468 |
function pagelayer_gutenberg_after_title(){ |
| 469 |
|
| 470 |
global $post; |
| 471 |
|
| 472 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 473 |
|
| 474 |
echo ' |
| 475 |
<div id="pagelayer-editor-button-row" style="margin-left:15px; display:none"> |
| 476 |
<a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:18px;"> |
| 477 |
<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit with Pagelayer').'</span> |
| 478 |
</a> |
| 479 |
</div> |
| 480 |
|
| 481 |
<script type="text/javascript"> |
| 482 |
jQuery(document).ready(function(){ |
| 483 |
|
| 484 |
var pagelayer_timer; |
| 485 |
var pagelayer_button = function(){ |
| 486 |
var button = jQuery("#pagelayer-editor-button-row"); |
| 487 |
var g = jQuery(".edit-post-header-toolbar"); |
| 488 |
if(g.length < 1){ |
| 489 |
return; |
| 490 |
} |
| 491 |
button.detach(); |
| 492 |
//console.log(button); |
| 493 |
g.append(button); |
| 494 |
button.show(); |
| 495 |
clearInterval(pagelayer_timer); |
| 496 |
} |
| 497 |
pagelayer_timer = setInterval(pagelayer_button, 100); |
| 498 |
}); |
| 499 |
</script>'; |
| 500 |
|
| 501 |
} |
| 502 |
|
| 503 |
// Handle Old Slug URL redirect for live link |
| 504 |
add_filter( 'old_slug_redirect_url', 'pagelayer_old_slug_redirect', 10, 1); |
| 505 |
function pagelayer_old_slug_redirect($link){ |
| 506 |
|
| 507 |
if(pagelayer_optreq('pagelayer-live')){ |
| 508 |
$link = add_query_arg('pagelayer-live', '1', $link); |
| 509 |
} |
| 510 |
|
| 511 |
return $link; |
| 512 |
} |
| 513 |
|
| 514 |
add_filter( 'post_row_actions', 'pagelayer_quick_link', 10, 2 ); |
| 515 |
add_filter( 'page_row_actions', 'pagelayer_quick_link', 10, 2 ); |
| 516 |
function pagelayer_quick_link($actions, $post){ |
| 517 |
$link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 518 |
|
| 519 |
$actions['pagelayer'] = '<a href="'.esc_url( $link ).'">'.__( 'Edit using Pagelayer', 'pagelayer') .'</a>'; |
| 520 |
|
| 521 |
return $actions; |
| 522 |
} |
| 523 |
|
| 524 |
// Add settings link on plugin page |
| 525 |
add_filter('plugin_action_links_pagelayer/pagelayer.php', 'pagelayer_plugin_action_links'); |
| 526 |
function pagelayer_plugin_action_links($links){ |
| 527 |
|
| 528 |
if(!defined('PAGELAYER_PREMIUM')){ |
| 529 |
$links[] = '<a href="'.PAGELAYER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Go Pro', 'Upgrade to Pagelayer Pro for many more features', 'pagelayer').'</a>'; |
| 530 |
} |
| 531 |
|
| 532 |
$settings_link = '<a href="admin.php?page=pagelayer">Settings</a>'; |
| 533 |
array_unshift($links, $settings_link); |
| 534 |
|
| 535 |
return $links; |
| 536 |
} |
| 537 |
|
| 538 |
// Pagelayer Template Loading Mechanism |
| 539 |
include_once(PAGELAYER_DIR.'/main/template.php'); |