const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const page = urlParams.get("page"); var btn_scanner = document.getElementById('scanner-btn'); var btn_remove_all_transients = document.getElementById('btn_remove_all_transients'); init_load_data(); function init_load_data() { jQuery.ajax({ timeout: 100000, type: "post", url: ajax_var_load_data.url, data: "action=" + ajax_var_load_data.action + "&nonce=" + ajax_var_load_data.nonce + "&page=" + page, success: function (response) { var response = JSON.parse(response); if( response.status_loading.data_loop.is_finish == true || response.status_loading.cache == true){ init_display_data(response); btn_scanner.disabled = false; btn_remove_all_transients.disabled = false; }else{ init_load_data(); } }, error: function (jqXHR, textStatus, errorThrown) { console.log("error"); console.log(errorThrown); console.log(jqXHR.responseText); }, }); } function init_display_data(response){ if(wpdbt_admin_vars.data.current_page == 'options' || wpdbt_admin_vars.data.current_page == 'transients'){ display_size(response.size) } // This set to load data is ending plugins = response.plugins; themes = response.themes; var list_values = response.data; var choices_values = response.origins; list.add(list_values, function (items) { console.log("All " + items.length + " were added!"); btn_all.innerHTML += "(" + items.length + ")"; var count_uncategorized = 0; var count_plugin = 0; var count_theme = 0; var count_core = 0; let origin_type = ''; items.forEach(function (item) { if(typeof item._values.origin == 'undefined'){ // Do something }else{ origin_type = item._values.origin.type; if (origin_type == "uncategorized" || item._values.origin.warning === 'yes' ) { count_uncategorized++; } if (origin_type == "plugin") { count_plugin++; } if (origin_type == "theme") { count_theme++; } if (origin_type == "core") { count_core++; } } }); btn_uncategorized.innerHTML += "(" + count_uncategorized + ")"; btn_plugin.innerHTML += "(" + count_plugin + ")"; btn_theme.innerHTML += "(" + count_theme + ")"; btn_core.innerHTML += "(" + count_core + ")"; load_status = 100; elem_load.style.width = 100 + "%"; filterAll(); }); var current_number_page = document.querySelector("li.active a"); var current_number = current_number_page.getAttribute("data-i"); // Set get parameter filter let current_element = select_choice._currentState.items.find( (selection) => selection.active === true ); select_choice.setChoices(choices_values); if($_GET_origin != null && $_GET_origin != encodeString(current_element.value)){ select_choice._currentState.choices.forEach( function(valor, indice, array) { if(encodeString(array[indice].value) === $_GET_origin){ select_choice.setChoiceByValue(array[indice].value); } }); } } function display_size(size){ let el_size_total = document.getElementById('info-size-total'); let el_size_autoload = document.getElementById('info-size-autoload'); el_size_total.innerHTML = size['total']['format']['size'] + size['total']['format']['type']; el_size_autoload.classList.add(size['autoload']['indicator']); el_size_autoload.innerHTML = size['autoload']['format']['size'] + size['autoload']['format']['type']; }