| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | if (!defined('ABSPATH')) exit; |
| 5 | 5 | |
| 6 | 6 | define('PAGELAYER_BASE', plugin_basename(PAGELAYER_FILE)); |
| 7 | 7 | define('PAGELAYER_PREMIUM_BASE', 'pagelayer-pro/pagelayer-pro.php'); |
| 8 | -define('PAGELAYER_VERSION', '2.1.6'); | |
| 8 | +define('PAGELAYER_VERSION', '2.2.0'); | |
| 9 | 9 | define('PAGELAYER_DIR', dirname(PAGELAYER_FILE)); |
| 10 | 10 | define('PAGELAYER_SLUG', 'pagelayer'); |
| 11 | 11 | define('PAGELAYER_URL', plugins_url('', PAGELAYER_FILE)); |
| 12 | 12 | define('PAGELAYER_CSS', PAGELAYER_URL.'/css'); |
| @@ -25,8 +25,9 @@ | ||
| 25 | 25 | define('PAGELAYER_FONT_POST_TYPE', 'pagelayer-fonts'); |
| 26 | 26 | |
| 27 | 27 | include_once(PAGELAYER_DIR.'/main/functions.php'); |
| 28 | 28 | include_once(PAGELAYER_DIR.'/main/class.php'); |
| 29 | +include_once(PAGELAYER_DIR.'/main/ai-controller.php'); | |
| 29 | 30 | |
| 30 | 31 | function pagelayer_died(){ |
| 31 | 32 | print_r(error_get_last()); |
| 32 | 33 | } |
| @@ -146,8 +147,12 @@ | ||
| 146 | 147 | |
| 147 | 148 | // The function that will be called when the plugin is loaded |
| 148 | 149 | function pagelayer_load_plugin(){ |
| 149 | 150 | |
| 151 | + // Init MCP Abilities | |
| 152 | + add_action('wp_abilities_api_categories_init', 'pagelayer_wp_abilities_api_categories_init'); | |
| 153 | + add_action('wp_abilities_api_init', 'pagelayer_wp_abilities_api_init'); | |
| 154 | + | |
| 150 | 155 | global $pagelayer; |
| 151 | 156 | |
| 152 | 157 | // Check if the installed version is outdated |
| 153 | 158 | pagelayer_update_check(); |
| @@ -283,8 +288,25 @@ | ||
| 283 | 288 | 'docs_url' => esc_url(PAGELAYER_DOCS), |
| 284 | 289 | 'admin_url' => admin_url(), |
| 285 | 290 | 'is_sitepad' => defined('SITEPAD') ? 1 : 0, |
| 286 | 291 | )); |
| 292 | + | |
| 293 | + if(strpos($hook, "pagelayer_ai_agents") !== false){ | |
| 294 | + include_once(PAGELAYER_DIR.'/main/abilities.php'); | |
| 295 | + wp_enqueue_style("pagelayer-abilities", PAGELAYER_CSS."/pagelayer-abilities.css", array(), PAGELAYER_VERSION); | |
| 296 | + wp_enqueue_script("pagelayer-abilities", PAGELAYER_JS."/pagelayer-abilities.js", array("jquery"), PAGELAYER_VERSION, true); | |
| 297 | + | |
| 298 | + $site_url = trailingslashit(rtrim(home_url(), '/')); | |
| 299 | + $username = function_exists('wp_get_current_user') ? wp_get_current_user()->user_login : ''; | |
| 300 | + $mcp_server_url = $site_url . ltrim(Pagelayer_Abilities::$MCP_SERVER_ENDPOINT, '/'); | |
| 301 | + | |
| 302 | + wp_localize_script("pagelayer-abilities", "pagelayer_abilities_data", array( | |
| 303 | + 'siteUrl' => $site_url, | |
| 304 | + 'mcpServerUrl' => $mcp_server_url, | |
| 305 | + 'username' => $username, | |
| 306 | + 'nonce' => wp_create_nonce('pagelayer_mcp_nonce') | |
| 307 | + )); | |
| 308 | + } | |
| 287 | 309 | } |
| 288 | 310 | |
| 289 | 311 | function pagelayer_admin_menu() { |
| 290 | 312 | |
| @@ -321,8 +343,11 @@ | ||
| 321 | 343 | |
| 322 | 344 | // Register Tools Submenu page under pagelayer |
| 323 | 345 | add_submenu_page('pagelayer', __('Tools'), __('Tools'), $capability, 'pagelayer_tools', 'pagelayer_tools_page_handler'); |
| 324 | 346 | |
| 347 | + // AI Agents Connection | |
| 348 | + add_submenu_page('pagelayer', __('AI Agents', 'pagelayer'), __('AI Agents', 'pagelayer') . ' <span style="vertical-align:middle;background:#d63638;font-size:9px;padding:0 6px;border-radius:10px;line-height:18px;color:#fff;">New!</span>' , $capability, 'pagelayer_ai_agents', 'pagelayer_ai_agents_page_handler'); | |
| 349 | + | |
| 325 | 350 | // Getting Started |
| 326 | 351 | add_submenu_page('pagelayer', __('Getting Started'), __('Getting Started'), $capability, 'pagelayer_getting_started', 'pagelayer_getting_started'); |
| 327 | 352 | |
| 328 | 353 | // Its Free |
| @@ -353,8 +378,30 @@ | ||
| 353 | 378 | pagelayer_website_settings(); |
| 354 | 379 | |
| 355 | 380 | } |
| 356 | 381 | |
| 382 | +function pagelayer_wp_abilities_api_categories_init(){ | |
| 383 | + include_once(PAGELAYER_DIR.'/main/abilities.php'); | |
| 384 | + include_once(PAGELAYER_DIR.'/main/abilitiesregister.php'); | |
| 385 | + if(class_exists('Pagelayer_Abilities_Register')){ | |
| 386 | + Pagelayer_Abilities_Register::register_categories(); | |
| 387 | + } | |
| 388 | +} | |
| 389 | + | |
| 390 | +function pagelayer_wp_abilities_api_init(){ | |
| 391 | + include_once(PAGELAYER_DIR.'/main/abilities.php'); | |
| 392 | + include_once(PAGELAYER_DIR.'/main/abilitiesregister.php'); | |
| 393 | + if(class_exists('Pagelayer_Abilities_Register')){ | |
| 394 | + Pagelayer_Abilities_Register::register_abilities(); | |
| 395 | + } | |
| 396 | +} | |
| 397 | + | |
| 398 | +// This function handles the AI Agents page | |
| 399 | +function pagelayer_ai_agents_page_handler(){ | |
| 400 | + include_once(PAGELAYER_DIR.'/main/abilities.php'); | |
| 401 | + Pagelayer_Abilities::render_page(); | |
| 402 | +} | |
| 403 | + | |
| 357 | 404 | // Getting Started |
| 358 | 405 | function pagelayer_getting_started(){ |
| 359 | 406 | |
| 360 | 407 | global $wp_version, $pagelayer; |
| @@ -495,18 +542,12 @@ | ||
| 495 | 542 | $blocks = parse_blocks( wp_unslash($content) ); |
| 496 | 543 | $output = ''; |
| 497 | 544 | |
| 498 | 545 | foreach ( $blocks as $block ) { |
| 499 | - $block_name = $block['blockName']; | |
| 500 | 546 | |
| 501 | - // Is pagelayer block | |
| 502 | - if ( is_string( $block_name ) && 0 === strpos( $block_name, 'pagelayer/' ) ) { | |
| 503 | - $_block = pagelayer_sanitize_blocks_save_pre($block); | |
| 504 | - $output .= serialize_block($_block); | |
| 505 | - continue; | |
| 506 | - } | |
| 507 | - | |
| 508 | - $output .= serialize_block($block); | |
| 547 | + // Sanitize Pagelayer blocks at any depth, they can be nested inside | |
| 548 | + // any other block | |
| 549 | + $output .= serialize_block( pagelayer_sanitize_block_tree( $block ) ); | |
| 509 | 550 | } |
| 510 | 551 | |
| 511 | 552 | return wp_slash($output); |
| 512 | 553 | } |
| @@ -976,14 +1017,20 @@ | ||
| 976 | 1017 | $styles .= ':root{'; |
| 977 | 1018 | |
| 978 | 1019 | // Set global colors |
| 979 | 1020 | foreach($pagelayer->global_colors as $gk => $gv){ |
| 980 | - $styles .= '--pagelayer-color-'.$gk.':'.$gv['value'].';'; | |
| 1021 | + if (isset($gv['value'])) { | |
| 1022 | + $styles .= '--pagelayer-color-'.$gk.':'.$gv['value'].';'; | |
| 1023 | + } | |
| 981 | 1024 | } |
| 982 | 1025 | |
| 983 | 1026 | // Set global fonts |
| 984 | 1027 | foreach($pagelayer->global_fonts as $gk => $gv){ |
| 985 | 1028 | |
| 1029 | + if (empty($gv['value']) || !is_array($gv['value'])) { | |
| 1030 | + continue; | |
| 1031 | + } | |
| 1032 | + | |
| 986 | 1033 | foreach($gv['value'] as $fk => $fv){ |
| 987 | 1034 | |
| 988 | 1035 | if(empty($fv)){ |
| 989 | 1036 | continue; |
| @@ -1378,9 +1425,9 @@ | ||
| 1378 | 1425 | $link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; |
| 1379 | 1426 | |
| 1380 | 1427 | echo ' |
| 1381 | 1428 | <div id="pagelayer-editor-button-row" style="margin-left:15px; display:none"> |
| 1382 | - <a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; padding:4px 8px; font-size:13px; display:flex; align-items:center;width: max-content;"> | |
| 1429 | + <a id="pagelayer-editor-button" href="'.$link.'" class="button button-primary button-large" style="height:auto; font-size:13px; display:flex; align-items:center;width: max-content;"> | |
| 1383 | 1430 | <img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="22" style="margin-right:4px"/> <span>'.__('Edit with Pagelayer').'</span> |
| 1384 | 1431 | </a> |
| 1385 | 1432 | </div> |
| 1386 | 1433 | |