From 7a88e2db29f42c72be893e48142d386334c94cb6 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 17 Jan 2022 17:15:37 +0100 Subject: [PATCH] WIP: Testing Wordpress with prewebs --- .../module_library/module_library_view.php | 4 ++-- .../include/javascript/module_library.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/module_library/module_library_view.php b/pandora_console/godmode/module_library/module_library_view.php index 31553a5352..bdfc29a95c 100644 --- a/pandora_console/godmode/module_library/module_library_view.php +++ b/pandora_console/godmode/module_library/module_library_view.php @@ -156,8 +156,8 @@ var more_details = ''; var total_modules_text = ''; var view_web = ''; var empty_result = ''; -var error_get_token = ''; -var invalid_user = ''; +var error_get_token = ''; +var invalid_user = ''; var error_main = ''; var error_category = ''; var error_categories = ''; diff --git a/pandora_console/include/javascript/module_library.js b/pandora_console/include/javascript/module_library.js index 689fab0533..77afa64e2b 100644 --- a/pandora_console/include/javascript/module_library.js +++ b/pandora_console/include/javascript/module_library.js @@ -14,6 +14,8 @@ Variables from PHP: - error_search */ +const REMOTE_MODULE_LIBRARY_URI = "https://pandorafms.com/library/"; + $(document).ready(function() { // Save categories in sessionStorage to avoid making the request to the API many times. function set_local_categories() { @@ -100,8 +102,7 @@ $(document).ready(function() { // Get all categories from Module library. function get_all_categories() { $.ajax({ - url: - "https://pandorafms.com/library/wp-json/wp/v2/categories?per_page=100", + url: REMOTE_MODULE_LIBRARY_URI + "wp-json/wp/v2/categories?per_page=100", type: "GET", cache: false, crossDomain: true, @@ -127,10 +128,9 @@ $(document).ready(function() { var api_url = ""; if (selector == "search") { - api_url = "https://pandorafms.com/library/wp-json/wp/v2/posts?search="; + api_url = REMOTE_MODULE_LIBRARY_URI + "wp-json/wp/v2/posts?search="; } else if (selector == "category") { - api_url = - "https://pandorafms.com/library/wp-json/wp/v2/posts/?categories="; + api_url = REMOTE_MODULE_LIBRARY_URI + "wp-json/wp/v2/posts/?categories="; } $.ajax({ @@ -238,7 +238,7 @@ $(document).ready(function() { /* Print main page */ function library_main() { $.ajax({ - url: "https://pandorafms.com/library/wp-json/wp/v2/pages/121", + url: REMOTE_MODULE_LIBRARY_URI + "wp-json/wp/v2/pages/121", type: "GET", cache: false, crossDomain: true, @@ -286,6 +286,8 @@ function library_main() { clean_page.splice(0, 1); $.each(clean_page, function(i, v) { + // Clean et_pb_blurb WP tags. + v = v.replace(/([\[et_pb_blurb].*[\]](?=[A-z]))/g, ""); var main_category = $( "#library_main_content div.library_main_category:nth-child(" + i + ")" ); @@ -314,7 +316,7 @@ function library_main() { // Get all data from one category. This is necessary to get the category name. function get_category(id) { $.ajax({ - url: "https://pandorafms.com/library/wp-json/wp/v2/categories/" + id, + url: REMOTE_MODULE_LIBRARY_URI + "wp-json/wp/v2/categories/" + id, type: "GET", cache: false, contentType: "application/json",