效果图
注意 :本教程适用于子比主题,其它程序或主题请自行适配!!!
教程开始
首先在后台自定义CSS代码中添加以下代码
.ignore:hover{color:var(--theme-color);transition:color .2s,transform .3s;}#translate {display:none;}
后台自定义javascript代码
translate.setAutoDiscriminateLocalLanguage();
translate.language.setLocal('chinese_simplified');
translate.service.use('client.edge');
function executeTranslation() {
translate.execute();
}
executeTranslation();
$(document).ajaxComplete(function() {
executeTranslation();
});
接着在主题目录下新建func.php或将代码添加到functions.php文件中
/*翻译功能*/
function custom_modify_radius_button($original_content, $user_id) {
$new_button = '<span class="hover-show inline-block ml10">
<a href="javascript:translate.changeLanguage(\'english\');" rel="external nofollow" rel="external nofollow" class="toggle-radius">
<svg t="1724977740957" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4360" width="200" height="200"><path d="M397.098798 9.33046l23.267096 42.164231c2.208603 4.015641 3.354241 7.629718 3.425106 10.865852 1.653499 114.80009-4.015641 232.316644 2.598356 346.289985 2.055063 35.668341-11.810709 64.793549-41.573696 87.399245-174.798492 1.33461-280.811415 1.33461-318.06239 0-40.98316-1.535392-57.518152-36.140769-58.344902-74.998001C6.684004 325.148816 6.365115 211.565228 7.463511 80.31282c0.472428-49.250656 25.747345-70.864253 75.234216-71.691003 104.725556-1.736174 209.521976-1.49996 314.401071 0.708643z m-99.446169 321.487496a6.259676 6.259676 0 0 1-1.889714-8.858032 326.022808 326.022808 0 0 0 50.667941-121.886515c0.82675-4.216423 3.791238-7.239965 6.968319-7.086426l16.180671 0.82675c5.598276 0.307078 9.212353 0.035432 10.865852-0.82675 27.637059-14.019311 30.518872-31.534593 8.621817-52.557654a15.731864 15.731864 0 0 0-10.393423-4.251855l-90.351923-2.716464a6.200622 6.200622 0 0 1-6.023462-6.023461c-0.625968-40.002871-18.023142-51.104937-52.203333-33.306199a11.125688 11.125688 0 0 0-5.669141 8.739924l-3.070784 25.274917a6.909265 6.909265 0 0 1-6.732104 6.023462l-89.052745 2.244035c-4.180991 0.070864-7.960418 1.417285-10.629638 3.779427-19.99553 17.397174-19.133348 33.778627 2.598356 49.132549 3.011731 2.066874 6.802968 3.188891 10.865852 3.188891l145.035505-0.118107c3.803048 0 7.393504 1.759796 9.590296 4.724283 2.208603 2.952677 2.716463 6.720293 1.393664 10.039103l-27.400845 68.14779a3.921155 3.921155 0 0 1-3.106216 2.385763 4.747905 4.747905 0 0 1-3.980209-1.322799c-30.235415-28.428376-49.368763-22.251376-57.400046 18.542813-0.519671 2.362142 0.708643 6.023462 3.306999 9.802888l12.283137 17.952278a5.078605 5.078605 0 0 1 0.49605 4.488069 7.558854 7.558854 0 0 1-3.33062 4.015641 298.314885 298.314885 0 0 1-90.233816 35.195913 12.176841 12.176841 0 0 0-8.621817 6.49589c-17.243635 36.613198 11.220173 50.667941 42.872873 43.699623 34.806159-7.724204 67.439148-21.696272 97.910777-41.928017a8.444657 8.444657 0 0 1 9.684781 0.118107 279.087051 279.087051 0 0 0 98.146991 41.80991c33.66052 7.204532 63.187293-12.046923 38.621018-48.069586a13.629558 13.629558 0 0 0-9.33046-5.66914 229.186806 229.186806 0 0 1-86.690603-32.007021z" fill="#6E80D5" p-id="4361"></path><path d="M397.098798 9.33046c62.596757-13.818529 99.682383 14.409065 99.80049 77.360143 0.236214 114.398526 0.200782 228.336435-0.118107 341.801916-0.236214 65.31322-54.919796 72.63586-111.965521 67.557254 29.762986-22.605697 43.628759-51.730905 41.573696-87.399245-6.613997-113.973341-0.944857-231.489894-2.598356-346.289985-0.070864-3.236134-1.216503-6.850211-3.425106-10.865852L397.098798 9.33046z" fill="#5169CC" p-id="4362"></path><path d="M940.391407 312.038929a884.102425 884.102425 0 0 1-65.077006 144.799291 2053.527955 2053.527955 0 0 1-69.092647-38.975339c-39.683982-23.385204-19.251455-76.887715 20.904954-66.258077 8.432846 2.279467 10.511531-0.401564 6.259676-8.031282-53.691483-95.513203-133.295661-157.247778-238.812534-185.191916a18.767216 18.767216 0 0 1-9.448567-5.905354c-23.148989-27.802409-17.786928-48.624689 16.062564-62.47865 3.366052-1.452717 7.287207-1.653499 11.102067-0.590536 128.665863 34.014842 226.293182 113.418237 292.90558 238.221999a3.779427 3.779427 0 0 0 6.613997 0.236214c4.724284-7.487989 14.255526-12.755566 28.581916-15.82635z" fill="#28D1B3" p-id="4363"></path><path d="M940.391407 312.038929c22.369483-2.291278 35.786448 9.047003 40.274517 34.014842 0.696832 3.67313 0.118107 7.653339-1.653499 11.33828-23.030882 48.305799-46.6523 130.62644-103.698024 99.446169a884.102425 884.102425 0 0 0 65.077006-144.799291z" fill="#22B69F" p-id="4364"></path><path d="M903.778209 530.418936c27.011091 16.298778 40.711514 40.428057 41.101267 72.399646 1.417285 118.343303 1.346421 236.722038-0.236214 355.148016-0.153539 14.798818-10.865852 33.66052-32.125128 56.573296-164.168854 4.16918-276.087131 4.086505-335.778454-0.236214-49.604977-3.66132-49.250656-73.462609-49.486871-107.359344a8150.865474 8150.865474 0 0 1 2.125928-270.465234c1.535392-62.47865 0.354321-106.650701 73.344502-107.359344 100.79259-0.873992 201.136372-0.436996 301.05497 1.299178z m-93.068386 164.523175l68.14779-1.181071a11.373713 11.373713 0 0 0 9.33046-4.960497c24.920596-38.502911 3.425106-60.352722-37.558054-59.880295-56.844942 0.708643-113.689884 1.015721-170.546636 0.944857-25.81821-0.082675-34.132949 17.007421-24.920596 51.258477 1.889713 7.00375 7.854121 11.905195 14.645279 12.046923l63.187292 1.653499a6.023462 6.023462 0 0 1 6.023462 5.905355 7340.473683 7340.473683 0 0 0 2.244035 190.742948c0.472428 21.412815 16.617667 27.82603 48.423906 19.251456a19.723884 19.723884 0 0 0 14.409065-18.897135l0.708642-190.861055a6.023462 6.023462 0 0 1 5.905355-6.023462z" fill="#F1EFF2" p-id="4365"></path><path d="M903.778209 530.418936c67.675362-4.842391 112.79227-1.771606 112.674163 77.005822 0 97.709995 0.236214 195.419989 0.708642 293.141795 0.354321 77.950679-9.684781 132.27994-104.64288 113.973341 21.259276-22.912775 31.971589-41.774477 32.125128-56.573296 1.582635-118.425978 1.653499-236.804713 0.236214-355.148016-0.389753-31.971589-14.090176-56.100867-41.101267-72.399646z" fill="#DDEBF0" p-id="4366"></path><path d="M223.599484 671.556908c-41.018592-37.168301-87.670892-63.187293-139.9569-78.068786 20.550633-66.13997 88.46221-15.590136 131.807511 10.039102 31.6527 18.66092 36.967519 42.518552 8.149389 68.029684z" fill="#22B69F" p-id="4367"></path><path d="M83.642584 593.488122c52.286008 14.881493 98.938308 40.900485 139.9569 78.068786l-28.109487 5.196712a4.216423 4.216423 0 0 0-3.070785 2.279466 3.944777 3.944777 0 0 0 0.118107 3.743995c50.47897 89.596038 124.331333 149.12201 221.568899 178.577918 27.282738 8.267496 51.022262 24.802489 34.251056 55.156011-9.365892 17.007421-23.385204 22.747425-42.046124 17.243635-132.587018-39.613118-228.182896-118.744867-286.764011-237.395249a4.369962 4.369962 0 0 0-6.850212-1.299178c-31.48735 28.263026-54.010372 23.101747-67.557254-15.472028a14.231904 14.231904 0 0 1 0.708642-11.102067l37.794269-74.998001z" fill="#28D1B3" p-id="4368"></path><path d="M297.652629 330.817956a229.186806 229.186806 0 0 0 86.690603 32.007021c3.921155 0.590535 7.299018 2.645599 9.33046 5.66914 24.566274 36.022662-4.960498 55.274118-38.621018 48.069586a279.087051 279.087051 0 0 1-98.146991-41.80991 8.444657 8.444657 0 0 0-9.684781-0.118107c-30.471629 20.231744-63.104618 34.203813-97.910777 41.928017-31.6527 6.968318-60.116508-7.086425-42.872873-43.699623 1.570824-3.283377 4.759716-5.692762 8.621817-6.49589a298.314885 298.314885 0 0 0 90.233816-35.195913 7.558854 7.558854 0 0 0 3.33062-4.015641 5.078605 5.078605 0 0 0-0.49605-4.488069l-12.283137-17.952278c-2.598356-3.779427-3.82667-7.440747-3.306999-9.802888 8.031282-40.794189 27.16463-46.971189 57.400046-18.542813 1.062964 1.039342 2.562924 1.535392 3.980209 1.322799a3.921155 3.921155 0 0 0 3.106216-2.385763l27.400845-68.14779a10.32256 10.32256 0 0 0-1.393664-10.039103c-2.196792-2.964488-5.787247-4.724284-9.590296-4.724283l-145.035505 0.118107c-4.062884 0-7.854121-1.122017-10.865852-3.188891-21.731704-15.353922-22.593886-31.735375-2.598356-49.132549 2.66922-2.362142 6.448647-3.708563 10.629638-3.779427l89.052745-2.244035a6.909265 6.909265 0 0 0 6.732104-6.023462l3.070784-25.274917a11.125688 11.125688 0 0 1 5.669141-8.739924c34.180192-17.798738 51.577366-6.696672 52.203333 33.306199 0.070864 3.247945 2.716463 5.905354 6.023462 6.023461l90.351923 2.716464c4.027452 0.153539 7.736014 1.66531 10.393423 4.251855 21.897054 21.023062 19.015241 38.538343-8.621817 52.557654-1.653499 0.862182-5.267576 1.133828-10.865852 0.82675l-16.180671-0.82675c-3.177081-0.153539-6.141569 2.870002-6.968319 7.086426a326.022808 326.022808 0 0 1-50.667941 121.886515 6.259676 6.259676 0 0 0 1.889714 8.858032z" fill="#F1EFF2" p-id="4369"></path><path d="M804.804468 700.965573l-0.708642 190.861055a19.723884 19.723884 0 0 1-14.409065 18.897135c-31.806239 8.574575-47.951478 2.16136-48.423906-19.251456a7340.473683 7340.473683 0 0 1-2.244035-190.742948 6.023462 6.023462 0 0 0-6.023462-5.905355l-63.187292-1.653499c-6.791158-0.141729-12.755566-5.043173-14.645279-12.046923-9.212353-34.251056-0.897614-51.341152 24.920596-51.258477 56.856753 0.070864 113.701695-0.236214 170.546636-0.944857 40.98316-0.472428 62.47865 21.377383 37.558054 59.880295a11.373713 11.373713 0 0 1-9.33046 4.960497l-68.14779 1.181071a6.023462 6.023462 0 0 0-5.905355 6.023462z" fill="#7A6D79" p-id="4370"></path></svg>
</a>
<div class="hover-show-con dropdown-menu drop-newadd">
<a rel="nofollow" class="btn-newadd" href="javascript:translate.changeLanguage(\'chinese_simplified\');" rel="external nofollow" >
<icon class="c-red">
<svg t="1721624071609" class="icon" viewBox="0 0 1027 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="33018" width="200" height="200"><path d="M0 166.144h1026.702v694.3H0v-694.3z" fill="#DE2910" p-id="33019"></path><path d="M170.268 245.077l21.647 67.584h70.343l-56.832 41.814 21.646 67.726-56.832-41.813-56.832 41.813 21.646-67.726-56.832-41.814h70.343l21.703-67.584z m183.211-35.3l-1.365 23.382 21.418 8.59-22.442 5.831-1.508 23.382-12.373-19.94-22.329 5.831 14.791-17.977-12.373-19.825 21.418 8.59 14.763-17.863z m78.933 75.748l-10.552 20.85 16.384 16.612-22.813-3.783-10.667 20.85-3.555-23.268-22.813-3.67 20.623-10.666-3.499-23.126 16.27 16.612 20.622-10.41z m-23.608 94.863l6.997 22.328h23.154l-18.688 13.74 6.997 22.214-18.688-13.852-18.688 13.738 7.111-22.1-18.688-13.74h23.154l7.339-22.328z m-55.439 71.367l-1.479 23.381 21.419 8.59-22.329 5.831-1.48 23.382-12.372-19.826-22.443 5.831 14.791-17.977-12.373-19.826 21.532 8.59 14.734-17.976z" fill="#FFDE00" p-id="33020"></path></svg>
</icon>
<text class="ignore">简体中文</text>
</a>
<a rel="nofollow" class="btn-newadd" href="javascript:translate.changeLanguage(\'english\');" rel="external nofollow" rel="external nofollow" >
<icon class="c-blue">
<svg t="1721624135832" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="36359" width="200" height="200"><path d="M0 512a512 512 0 1 0 1024 0A512 512 0 1 0 0 512z" fill="#F0F0F0" p-id="36360"></path><path d="M489.74 512H1024c0-46.212-6.16-90.98-17.638-133.566H489.74V512z m0-267.13h459.112a514.7 514.7 0 0 0-118.14-133.566H489.74V244.87zM512 1024c120.498 0 231.252-41.648 318.712-111.304H193.288C280.748 982.352 391.502 1024 512 1024zM75.148 779.13h873.704a508.948 508.948 0 0 0 57.51-133.566H17.638a508.948 508.948 0 0 0 57.51 133.566z" fill="#D80027" p-id="36361"></path><path d="M237.168 79.956h46.658l-43.4 31.53 16.578 51.018-43.398-31.53-43.398 31.53 14.32-44.074a514.814 514.814 0 0 0-99.304 110.674h14.95l-27.626 20.07A511.16 511.16 0 0 0 60.16 271.05l13.192 40.602L48.74 293.77a507.134 507.134 0 0 0-16.744 39.746l14.534 44.736h53.644l-43.4 31.53L73.352 460.8l-43.398-31.53-25.996 18.888A516.936 516.936 0 0 0 0 512h512V0C410.856 0 316.57 29.34 237.168 79.956zM257.004 460.8l-43.398-31.53-43.398 31.53 16.578-51.018-43.4-31.53h53.644l16.576-51.018 16.576 51.018h53.644l-43.4 31.53 16.578 51.018z m-16.578-200.166l16.578 51.018-43.398-31.53-43.398 31.53 16.578-51.018-43.4-31.53h53.644l16.576-51.018 16.576 51.018h53.644l-43.4 31.53zM440.656 460.8l-43.398-31.53-43.398 31.53 16.578-51.018-43.4-31.53h53.644l16.576-51.018 16.576 51.018h53.644l-43.4 31.53 16.578 51.018z m-16.578-200.166l16.578 51.018-43.398-31.53-43.398 31.53 16.578-51.018-43.4-31.53h53.644l16.576-51.018 16.576 51.018h53.644l-43.4 31.53z m0-149.148l16.578 51.018-43.398-31.53-43.398 31.53 16.578-51.018-43.4-31.53h53.644l16.576-51.018 16.576 51.018h53.644l-43.4 31.53z" fill="#0052B4" p-id="36362"></path></svg>
</icon>
<text class="ignore">English</text>
</a>
<a rel="nofollow" class="btn-newadd" href="javascript:translate.changeLanguage(\'japanese\');" rel="external nofollow" >
<icon class="c-yellow">
<svg t="1721624155578" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="37966" width="200" height="200"><path d="M957 512c0-245-198-443.7-442.6-445h-4.7C265 68.3 67 267 67 512s198 443.7 442.6 445h4.7C759 955.7 957 757 957 512z m-709 0c0-145.9 118.2-264.1 264.1-264.1 145.8 0 264 118.2 264 264.1 0 145.8-118.2 264-264 264C366.2 776 248 657.8 248 512z" fill="#FFFFFF" p-id="37967"></path><path d="M776 512c0-145.9-118.2-264.1-264-264.1-145.8 0.1-264 118.3-264 264.1s118.2 264 264.1 264C657.8 776 776 657.8 776 512z" fill="#EB0000" p-id="37968"></path></svg>
</icon>
<text class="ignore">日本語</text>
</a>
<a rel="nofollow" class="btn-newadd" href="javascript:translate.changeLanguage(\'korean\');" rel="external nofollow" >
<icon class="c-green">
<svg t="1721624182737" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="39278" width="200" height="200"><path d="M0.1024 0h1024v1024H0.1024z" fill="#FFFFFF" p-id="39279"></path><path d="M513.150493 515.29434m-205.789468 18.764523a206.6432 206.6432 0 1 0 411.578935-37.529047 206.6432 206.6432 0 1 0-411.578935 37.529047Z" fill="#CE1126" p-id="39280"></path><path d="M336.384 408.576a103.2192 103.2192 0 1 0 176.5376 107.008 103.1168 103.1168 0 0 1 176.4352 106.9056A206.336 206.336 0 1 1 336.384 408.576" fill="#003F87" p-id="39281"></path><path d="M73.95328 348.89728l116.0192-171.86816 26.80832 18.10432L100.7616 367.0016zM115.24096 376.77056l116.11136-171.80672 26.80832 18.1248-116.10112 171.79648zM156.5696 404.6848l26.8288 18.0224 115.9168-171.9296-26.8288-18.0224-115.9168 171.9296zM789.20704 687.60576l53.76-79.60576 26.81856 18.11456-53.76 79.59552zM727.00928 779.8272l53.62688-79.68768 26.84928 18.06336-53.62688 79.68768zM830.43328 715.49952l53.79072-79.5648 26.80832 18.11456-53.79072 79.5648zM768.3072 807.6288l26.7264 18.1248 53.76-79.6672-26.8288-18.0224-53.6576 79.5648zM871.80288 743.31136l53.6576-79.6672 26.74688 18.0224-53.6576 79.6672zM809.5744 835.60448l53.57568-79.72864 26.85952 18.05312-53.56544 79.7184zM884.224 394.752l26.8288-17.92-115.9168-171.9296-26.8288 18.0224 115.9168 171.8272zM810.77248 195.34848l26.85952-18.1248 53.79072 79.72864-26.85952 18.1248zM871.8336 287.5392l26.80832-18.1248 53.8112 79.5648-26.79808 18.1248zM727.04 250.7264l26.75712-18.0224 53.6576 79.6672-26.75712 18.0224zM789.18656 343.07072l26.74688-18.0224 53.68832 79.63648-26.73664 18.0224zM156.54912 626.08384l26.8288-18.09408 115.95776 171.90912-26.8288 18.09408zM74.01472 681.65632l26.74688-18.03264 115.95776 171.90912-26.74688 18.03264zM115.93728 654.336l26.84928-18.1248 53.79072 79.7184-26.85952 18.1248zM231.2192 825.6512l26.8288-18.0224-53.6576-79.5648-26.8288 18.0224 53.6576 79.5648z" fill="" p-id="39282"></path></svg>
</icon>
<text class="ignore">한국어</text>
</a>
<a rel="nofollow" class="btn-newadd" href="javascript:translate.changeLanguage(\'vietnamese\');" rel="external nofollow" >
<icon class="c-purple">
<svg t="1721624194731" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="40331" width="200" height="200"><path d="M0 512a512 512 0 1 0 1024 0 512 512 0 0 0-1024 0z" fill="#F42F4C" p-id="40332"></path><path d="M512 630.848l168.96 120.128-64.256-195.285333 168.32-124.629334H576.853333L512 238.976l-62.954667 192.085333h-210.069333l167.68 124.629334-63.616 195.285333L512 630.848z" fill="#FFE62E" p-id="40333"></path></svg>
</icon>
<text class="ignore">Việt Nam</text>
</a>
</div>
</span>';
// 将原始内容和新按钮结合
$modified_content = $original_content . $new_button;
// 返回修改后的内容
return $modified_content;
}
// 将自定义函数添加到 zib_nav_radius_button 筛选器上
add_filter('zib_nav_radius_button', 'custom_modify_radius_button', 10, 2);
最后将附件里的文件上传至服务器,将代码放在后台自定义头部HTM
<script src="上传的目录/translate.min.js"></script>
温馨提示:
本文最后更新于2024-09-22 19:44:21
,某些文章具有时效性。
若有解压密错误或链接已失效,请在下方留言或在 微信公众号留言。
获取解压密码方式:
搜索并关注公众号【资源星球ResourceStar】
回复关键字【皓月星辰】即可免费获取
喜欢就支持一下吧
暂无评论内容