Last active
October 11, 2024 13:58
-
-
Save mkdizajn/7552958e196ad7b995af92afab163fe8 to your computer and use it in GitHub Desktop.
wordpress_multicategory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// level 1 cats | |
var c1 = ["Africa", | |
"Antarctica", | |
"Asia", | |
"Australasia", | |
"Caribbean", | |
"Central America", | |
"Europe", | |
"Indian Ocean", | |
"Middle East", | |
"North America", | |
"South America", | |
"UK" | |
]; | |
// level 2 cats | |
var c2 = [ | |
["Africa","Cape Verde"], | |
["Africa","Egypt"], | |
["Africa","Kenya"], | |
["Africa","Mauritius"], | |
["Africa","Morocco"], | |
["Africa","Namibia"], | |
["Africa","Seychelles"], | |
["Africa","South Africa"], | |
["Africa","Tanzania"], | |
["Asia","Cambodia"], | |
["Asia","China"], | |
["Asia","Hong Kong"], | |
["Asia","India"], | |
["Asia","Indonesia"], | |
["Asia","Japan"], | |
["Asia","Malaysia"], | |
["Asia","Maldives"], | |
["Asia","Mongolia"], | |
["Asia","Philippines"], | |
["Asia","Singapore"], | |
["Asia","South Korea"], | |
["Asia","Sri Lanka"], | |
["Asia","Thailand"], | |
["Asia","Uzbekistan"], | |
["Asia","Vietnam"], | |
["Australasia","Australia"], | |
["Australasia","New Zealand"], | |
["Caribbean","Anguilla"], | |
["Caribbean","Antigua"], | |
["Caribbean","Bahamas"], | |
["Caribbean","Barbados"], | |
["Caribbean","British Virgin Islands"], | |
["Caribbean","Cayman Islands"], | |
["Caribbean","Cuba"], | |
["Caribbean","Dominica"], | |
["Caribbean","Dominican Republic"], | |
["Caribbean","Grenada"], | |
["Caribbean","Jamaica"], | |
["Caribbean","St Barts"], | |
["Caribbean","St Lucia"], | |
["Caribbean","Turks and Caicos"], | |
["Central America","Belize"], | |
["Central America","Costa Rica"], | |
["Central America","Mexico"], | |
["Central America","Panama"], | |
["Europe","Albania"], | |
["Europe","Austria"], | |
["Europe","Belgium"], | |
["Europe","Channel Islands"], | |
["Europe","Croatia"], | |
["Europe","Cyprus"], | |
["Europe","Czech Republic"], | |
["Europe","Denmark"], | |
["Europe","Finland"], | |
["Europe","France"], | |
["Europe","Georgia"], | |
["Europe","Germany"], | |
["Europe","Gibraltar"], | |
["Europe","Greece"], | |
["Europe","Hungary"], | |
["Europe","Iceland"], | |
["Europe","Ireland"], | |
["Europe","Italy"], | |
["Europe","Lapland"], | |
["Europe","Latvia"], | |
["Europe","Malta"], | |
["Europe","Monaco"], | |
["Europe","Montenegro"], | |
["Europe","Netherlands"], | |
["Europe","Norway"], | |
["Europe","Poland"], | |
["Europe","Portugal"], | |
["Europe","Russia"], | |
["Europe","Slovenia"], | |
["Europe","Spain"], | |
["Europe","Sweden"], | |
["Europe","Switzerland"], | |
["Europe","Turkey"], | |
["Europe","Wales"], | |
["Middle East","Iran"], | |
["Middle East","Israel"], | |
["Middle East","Jordan"], | |
["Middle East","Oman"], | |
["Middle East","Qatar"], | |
["Middle East","UAE"], | |
["North America","Bermuda"], | |
["North America","Canada"], | |
["North America","US"], | |
["North America","Vietnam"], | |
["South America","Argentina"], | |
["South America","Brazil"], | |
["South America","Chile"], | |
["South America","Colombia"], | |
["South America","Ecuador"], | |
["South America","Peru"], | |
["UK","England"], | |
["UK","Northern Ireland"], | |
["UK","Scotland"], | |
["UK","Wales"], | |
]; | |
// level 3 cats | |
var c3 = [ | |
["UAE","Abu Dhabi"], | |
["Portugal","Algarve"], | |
["Italy","Amalfi Coast"], | |
["Netherlands","Amsterdam"], | |
["Spain","Andalusia"], | |
["Turkey","Antalya"], | |
["Greece","Athens"], | |
["Portugal","Azores"], | |
["Indonesia","Bali"], | |
["Thailand","Bangkok"], | |
["Spain","Barcelona"], | |
["England","Bath"], | |
["China","Beijing"], | |
["Northern Ireland","Belfast"], | |
["Germany","Berlin"], | |
["England","Birmingham"], | |
["Turkey","Bodrum"], | |
["France","Bordeaux"], | |
["Vietnam","Boston"], | |
["England","Brighton"], | |
["Australia","Brisbane"], | |
["England","Bristol"], | |
["Canada","British Columbia"], | |
["Belgium","Bruges"], | |
["Belgium","Brussels"], | |
["Hungary","Budapest"], | |
["US","California"], | |
["England","Cambridge"], | |
["Spain","Canary Islands"], | |
["Mexico","Cancun"], | |
["South Africa","Cape Town"], | |
["Wales","Cardiff"], | |
["US","Colorado"], | |
["Portugal","Comporta"], | |
["Denmark","Copenhagen"], | |
["Greece","Corfu"], | |
["England","Cornwall"], | |
["France","Corsica"], | |
["England","Cotswolds"], | |
["France","Courchevel"], | |
["Greece","Crete"], | |
["India","Delhi"], | |
["England","Dorset"], | |
["UAE","Dubai"], | |
["Ireland","Dublin"], | |
["Croatia","Dubrovnik"], | |
["South Africa","Durban"], | |
["England","Durham"], | |
["Scotland","Edinburgh"], | |
["Denmark","Faroe Islands"], | |
["Turkey","Fethiye"], | |
["Italy","Florence"], | |
["US","Florida"], | |
["Spain","Formentera"], | |
["Switzerland","Geneva"], | |
["Scotland","Glasgow"], | |
["India","Goa"], | |
["Malta","Gozo"], | |
["Spain","Gran Canaria"], | |
["Spain","Granada"], | |
["Channel Islands","Guernsey"], | |
["Vietnam","Hanoi"], | |
["Cuba","Havana"], | |
["US","Hawaii"], | |
["Hong Kong","Hong Kong"], | |
["US","Houston"], | |
["Greece","Hydra"], | |
["Spain","Ibiza"], | |
["England","Isles of Scilly"], | |
["Turkey","Istanbul"], | |
["Channel Islands","Jersey"], | |
["South Africa","Johannesburg"], | |
["Greece","Kefalonia"], | |
["England","Kent"], | |
["Greece","Kos"], | |
["Poland","Krakow"], | |
["Japan","Kyoto"], | |
["England","Lake District"], | |
["Spain","Lanzarote"], | |
["US","Las Vegas"], | |
["England","Leeds"], | |
["France","Les Arcs"], | |
["France","Les Deux Alpes"], | |
["England","Lincoln"], | |
["Portugal","Lisbon"], | |
["England","Liverpool"], | |
["England","London"], | |
["US","Los Angeles"], | |
["France","Lyons"], | |
["Spain","Madrid"], | |
["Spain","Mallorca"], | |
["England","Manchester"], | |
["Morocco","Marrakesh"], | |
["France","Marseilles"], | |
["Australia","Melbourne"], | |
["Spain","Menorca"], | |
["US","Miami"], | |
["Italy","Milan"], | |
["Canada","Montreal"], | |
["India","Mumbai"], | |
["Germany","Munich"], | |
["Greece","Mykonos"], | |
["Italy","Naples"], | |
["US","Nashville"], | |
["Greece","Naxos"], | |
["England","New Forest"], | |
["US","New Orleans"], | |
["US","New York City"], | |
["England","Newcastle"], | |
["France","Nice"], | |
["England","Norfolk"], | |
["Scotland","Orkney"], | |
["US","Orlando"], | |
["Japan","Osaka"], | |
["Norway","Oslo"], | |
["England","Oxford"], | |
["US","Palm Springs"], | |
["France","Paris"], | |
["England","Peak District"], | |
["Australia","Perth"], | |
["Thailand","Phuket"], | |
["Portugal","Porto"], | |
["Czech Republic","Prague"], | |
["Italy","Puglia"], | |
["Iceland","Reykjavik"], | |
["Greece","Rhodes"], | |
["Italy","Rome"], | |
["Netherlands","Rotterdam"], | |
["US","San Francisco"], | |
["Spain","San Sebastian"], | |
["Greece","Santorini"], | |
["Italy","Sardinia"], | |
["South Korea","Seoul"], | |
["Spain","Seville"], | |
["China","Shanghai"], | |
["Italy","Sicily"], | |
["Greece","Skiathos"], | |
["Austria","St Anton"], | |
["Sweden","Stockholm"], | |
["Norway","Svalbard"], | |
["Australia","Sydney"], | |
["Israel","Tel Aviv"], | |
["Spain","Tenerife"], | |
["Spain","The Duoro River"], | |
["France","Tignes"], | |
["Japan","Tokyo"], | |
["Canada","Toronto"], | |
["Mexico","Tulum"], | |
["Italy","Tuscany"], | |
["France","Val d’Isère"], | |
["France","Val Thorens"], | |
["Spain","Valencia"], | |
["Malta","Valletta"], | |
["Canada","Vancouver"], | |
["Italy","Venice"], | |
["Austria","Vienna"], | |
["US","Washington DC"], | |
["England","Windsor"], | |
["England","York"], | |
["England","Yorkshire"] | |
]; | |
var rc1 = [], rc2 = [], rc3 = []; | |
var url = "https://travel.local:442/wp-admin/admin-ajax.php"; | |
// fetch function | |
function call(tag, parent, lvl, ix) { | |
fetch( url, { | |
"headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, | |
"body": "action=add-tag&screen=edit-theme&taxonomy=theme&post_type=article&_wpnonce_add-tag=4e4125fdf3&_wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dtheme%26post_type%3Darticle&tag-name=" + tag + "&slug=&parent=" + parent + "&description=", | |
"method": "POST", | |
}).then(res => res.text()) | |
.then(res => { | |
id = res.match(/id="tag-(\d+)"/g); | |
id = id[0].replaceAll("\"", "").replace("id=tag-", ""); | |
if( lvl == "1") { rc1.push([tag,id]); cma((ix + 1)) } | |
if( lvl == "2") { rc2.push([tag,id]); cmb((ix + 1)) } | |
if( lvl == "3") { rc3.push([tag,id]); cmc((ix + 1)) } | |
}); | |
} | |
// init calls | |
function cma(ix){ call(c1[ix], "-1", "1", ix) } | |
function cmb(ix){ par = rc1.filter( rc => c2[ix][0] == rc[0] )[0][1]; call( c2[ix][1], par, "2", ix ) } | |
function cmc(ix){ par = rc2.filter( rc => c3[ix][0] == rc[0] )[0][1]; call( c3[ix][1], par, "3", ix ) } | |
// start L1, L2, L3 each separatelly - wait till finish | |
cma(0) | |
cmb(0) | |
cmc(0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment