This commit is contained in:
khaccount 2025-03-31 21:42:48 +02:00
parent 101fde590d
commit 85600f2209
640 changed files with 154788 additions and 1297 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[36],{1191:function(e,t,r){"use strict";r.r(t);var l=r(0);function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}var i=l.createElement("g",{filter:"url(#ghost-card-green_svg__filter0_d_4824_80823)"},l.createElement("rect",{width:165,height:90,rx:11,fill:"#fff"}),l.createElement("rect",{x:.5,y:.5,width:164,height:89,rx:10.5,stroke:"#EBEEF0"})),a=l.createElement("rect",{x:16,y:16,width:64,height:8,rx:4,fill:"#EBEEF0"}),o=l.createElement("path",{d:"M16 43c0-5.523 4.477-10 10-10h30c5.523 0 10 4.477 10 10s-4.477 10-10 10H26c-5.523 0-10-4.477-10-10z",fill:"#B8E6CA"}),c=l.createElement("rect",{x:16,y:68,width:133,height:8,rx:4,fill:"#EBEEF0"}),f=l.createElement("path",{d:"M25 46.667l6.593-6.594m0 0L26.392 40m5.201.073l.074 5.202",stroke:"#fff",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),h=l.createElement("rect",{x:38,y:40,width:20,height:6,rx:2,fill:"#fff"}),s=l.createElement("defs",null,l.createElement("filter",{id:"ghost-card-green_svg__filter0_d_4824_80823",x:0,y:0,width:169,height:95,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},l.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),l.createElement("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),l.createElement("feOffset",{dx:4,dy:5}),l.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),l.createElement("feColorMatrix",{values:"0 0 0 0 0.921569 0 0 0 0 0.933333 0 0 0 0 0.941176 0 0 0 1 0"}),l.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_4824_80823"}),l.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_4824_80823",result:"shape"})));t.default=function SvgGhostCardGreen(e){return l.createElement("svg",n({viewBox:"0 0 169 95",fill:"none"},e),i,a,o,c,f,h,s)}}}]);
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[36],{1199:function(e,t,r){"use strict";r.r(t);var l=r(1);function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}var i=l.createElement("g",{filter:"url(#ghost-card-green_svg__filter0_d_4824_80823)"},l.createElement("rect",{width:165,height:90,rx:11,fill:"#fff"}),l.createElement("rect",{x:.5,y:.5,width:164,height:89,rx:10.5,stroke:"#EBEEF0"})),a=l.createElement("rect",{x:16,y:16,width:64,height:8,rx:4,fill:"#EBEEF0"}),o=l.createElement("path",{d:"M16 43c0-5.523 4.477-10 10-10h30c5.523 0 10 4.477 10 10s-4.477 10-10 10H26c-5.523 0-10-4.477-10-10z",fill:"#B8E6CA"}),c=l.createElement("rect",{x:16,y:68,width:133,height:8,rx:4,fill:"#EBEEF0"}),f=l.createElement("path",{d:"M25 46.667l6.593-6.594m0 0L26.392 40m5.201.073l.074 5.202",stroke:"#fff",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),h=l.createElement("rect",{x:38,y:40,width:20,height:6,rx:2,fill:"#fff"}),s=l.createElement("defs",null,l.createElement("filter",{id:"ghost-card-green_svg__filter0_d_4824_80823",x:0,y:0,width:169,height:95,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},l.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),l.createElement("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),l.createElement("feOffset",{dx:4,dy:5}),l.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),l.createElement("feColorMatrix",{values:"0 0 0 0 0.921569 0 0 0 0 0.933333 0 0 0 0 0.941176 0 0 0 1 0"}),l.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_4824_80823"}),l.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_4824_80823",result:"shape"})));t.default=function SvgGhostCardGreen(e){return l.createElement("svg",n({viewBox:"0 0 169 95",fill:"none"},e),i,a,o,c,f,h,s)}}}]);

View file

@ -1 +1 @@
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[37],{1192:function(e,t,r){"use strict";r.r(t);var l=r(0);function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}var n=l.createElement("g",{filter:"url(#ghost-card-red_svg__filter0_d_4824_80809)"},l.createElement("rect",{width:165,height:90,rx:11,fill:"#fff"}),l.createElement("rect",{x:.5,y:.5,width:164,height:89,rx:10.5,stroke:"#EBEEF0"})),a=l.createElement("rect",{x:16,y:16,width:25,height:8,rx:4,fill:"#EBEEF0"}),o=l.createElement("rect",{x:16,y:33,width:50,height:20,rx:10,fill:"#FFDED3"}),c=l.createElement("rect",{x:16,y:68,width:133,height:8,rx:4,fill:"#EBEEF0"}),f=l.createElement("path",{d:"M24.997 40l6.594 6.593m0 0l.073-5.201m-.073 5.201l-5.202.074",stroke:"#fff",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),h=l.createElement("rect",{x:38,y:40,width:20,height:6,rx:2,fill:"#fff"}),d=l.createElement("defs",null,l.createElement("filter",{id:"ghost-card-red_svg__filter0_d_4824_80809",x:0,y:0,width:169,height:95,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},l.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),l.createElement("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),l.createElement("feOffset",{dx:4,dy:5}),l.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),l.createElement("feColorMatrix",{values:"0 0 0 0 0.921569 0 0 0 0 0.933333 0 0 0 0 0.941176 0 0 0 1 0"}),l.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_4824_80809"}),l.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_4824_80809",result:"shape"})));t.default=function SvgGhostCardRed(e){return l.createElement("svg",i({viewBox:"0 0 169 95",fill:"none"},e),n,a,o,c,f,h,d)}}}]);
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[37],{1200:function(e,t,r){"use strict";r.r(t);var l=r(1);function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}var n=l.createElement("g",{filter:"url(#ghost-card-red_svg__filter0_d_4824_80809)"},l.createElement("rect",{width:165,height:90,rx:11,fill:"#fff"}),l.createElement("rect",{x:.5,y:.5,width:164,height:89,rx:10.5,stroke:"#EBEEF0"})),a=l.createElement("rect",{x:16,y:16,width:25,height:8,rx:4,fill:"#EBEEF0"}),o=l.createElement("rect",{x:16,y:33,width:50,height:20,rx:10,fill:"#FFDED3"}),c=l.createElement("rect",{x:16,y:68,width:133,height:8,rx:4,fill:"#EBEEF0"}),f=l.createElement("path",{d:"M24.997 40l6.594 6.593m0 0l.073-5.201m-.073 5.201l-5.202.074",stroke:"#fff",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),h=l.createElement("rect",{x:38,y:40,width:20,height:6,rx:2,fill:"#fff"}),d=l.createElement("defs",null,l.createElement("filter",{id:"ghost-card-red_svg__filter0_d_4824_80809",x:0,y:0,width:169,height:95,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},l.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),l.createElement("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),l.createElement("feOffset",{dx:4,dy:5}),l.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),l.createElement("feColorMatrix",{values:"0 0 0 0 0.921569 0 0 0 0 0.933333 0 0 0 0 0.941176 0 0 0 1 0"}),l.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_4824_80809"}),l.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_4824_80809",result:"shape"})));t.default=function SvgGhostCardRed(e){return l.createElement("svg",i({viewBox:"0 0 169 95",fill:"none"},e),n,a,o,c,f,h,d)}}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[27],{1244:function(t,n,e){"use strict";e.r(n),function(t){var n=e(5),i=e.n(n),s=e(15),o=e.n(s);function a(){return(a=o()(i.a.mark((function n(){return i.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0!==t.IntersectionObserver){n.next=3;break}return n.next=3,e.e(43).then(e.t.bind(null,1277,7));case 3:case"end":return n.stop()}}),n)})))).apply(this,arguments)}e.p="".concat(t._googlesitekitBaseData.assetsURL,"js/"),function(){a.apply(this,arguments)}()}.call(this,e(28))}},[[1244,1,0]]]);
(window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[]).push([[27],{1252:function(t,n,e){"use strict";e.r(n),function(t){var n=e(5),i=e.n(n),s=e(16),o=e.n(s);function a(){return(a=o()(i.a.mark((function n(){return i.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0!==t.IntersectionObserver){n.next=3;break}return n.next=3,e.e(43).then(e.t.bind(null,1285,7));case 3:case"end":return n.stop()}}),n)})))).apply(this,arguments)}e.p="".concat(t._googlesitekitBaseData.assetsURL,"js/"),function(){a.apply(this,arguments)}()}.call(this,e(28))}},[[1252,1,0]]]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
!function(e){function r(r){for(var t,a,c=r[0],u=r[1],p=r[2],f=0,b=[];f<c.length;f++)a=c[f],Object.prototype.hasOwnProperty.call(n,a)&&n[a]&&b.push(n[a][0]),n[a]=0;for(t in u)Object.prototype.hasOwnProperty.call(u,t)&&(e[t]=u[t]);for(i&&i(r);b.length;)b.shift()();return o.push.apply(o,p||[]),_()}function _(){for(var e,r=0;r<o.length;r++){for(var _=o[r],t=!0,a=1;a<_.length;a++){var c=_[a];0!==n[c]&&(t=!1)}t&&(o.splice(r--,1),e=__webpack_require__(__webpack_require__.s=_[0]))}return e}var t={},n={1:0},o=[];function __webpack_require__(r){if(t[r])return t[r].exports;var _=t[r]={i:r,l:!1,exports:{}};return e[r].call(_.exports,_,_.exports,__webpack_require__),_.l=!0,_.exports}__webpack_require__.e=function(e){var r=[],_=n[e];if(0!==_)if(_)r.push(_[2]);else{var t=new Promise((function(r,t){_=n[e]=[r,t]}));r.push(_[2]=t);var o,a=document.createElement("script");a.charset="utf-8",a.timeout=120,__webpack_require__.nc&&a.setAttribute("nonce",__webpack_require__.nc),a.src=function(e){return __webpack_require__.p+""+({}[e]||e)+"-"+{33:"cb81424f70352173937d",34:"965775fce6fa9e3670cf",35:"153ac97e5e5caf4acf51",36:"a4d4f2adc3b533f252a8",37:"718cef57fa7d90296b51",38:"942fe4fbb20a18012159",39:"b5ca1b280e8846039515",40:"950b80c126fcb029b477",41:"c84e4fe5b232dcceae09",42:"69ebbca9a74beb868455",43:"5ff78007cd0d8239997a"}[e]+".js"}(e);var c=new Error;o=function(r){a.onerror=a.onload=null,clearTimeout(u);var _=n[e];if(0!==_){if(_){var t=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+t+": "+o+")",c.name="ChunkLoadError",c.type=t,c.request=o,_[1](c)}n[e]=void 0}};var u=setTimeout((function(){o({type:"timeout",target:a})}),12e4);a.onerror=a.onload=o,document.head.appendChild(a)}return Promise.all(r)},__webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,r,_){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:_})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,r){if(1&r&&(e=__webpack_require__(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var _=Object.create(null);if(__webpack_require__.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var t in e)__webpack_require__.d(_,t,function(r){return e[r]}.bind(null,t));return _},__webpack_require__.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__.oe=function(e){throw console.error(e),e};var a=window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[],c=a.push.bind(a);a.push=r,a=a.slice();for(var u=0;u<a.length;u++)r(a[u]);var i=c;_()}([]);

View file

@ -0,0 +1 @@
!function(e){function r(r){for(var t,o,u=r[0],i=r[1],p=r[2],b=0,f=[];b<u.length;b++)o=u[b],Object.prototype.hasOwnProperty.call(n,o)&&n[o]&&f.push(n[o][0]),n[o]=0;for(t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t]);for(c&&c(r);f.length;)f.shift()();return a.push.apply(a,p||[]),_()}function _(){for(var e,r=0;r<a.length;r++){for(var _=a[r],t=!0,o=1;o<_.length;o++){var u=_[o];0!==n[u]&&(t=!1)}t&&(a.splice(r--,1),e=__webpack_require__(__webpack_require__.s=_[0]))}return e}var t={},n={1:0},a=[];function __webpack_require__(r){if(t[r])return t[r].exports;var _=t[r]={i:r,l:!1,exports:{}};return e[r].call(_.exports,_,_.exports,__webpack_require__),_.l=!0,_.exports}__webpack_require__.e=function(e){var r=[],_=n[e];if(0!==_)if(_)r.push(_[2]);else{var t=new Promise((function(r,t){_=n[e]=[r,t]}));r.push(_[2]=t);var a,o=document.createElement("script");o.charset="utf-8",o.timeout=120,__webpack_require__.nc&&o.setAttribute("nonce",__webpack_require__.nc),o.src=function(e){return __webpack_require__.p+""+({}[e]||e)+"-"+{33:"aea26aaf32eda28b5b03",34:"c8e37ae42d451696b8b7",35:"f5127b73ed0693fc91a5",36:"e7a6de830eea07d009af",37:"19b401e9a1e883d25fdb",38:"61d72bb83fa9d81c52d0",39:"3b8a9e15e996253cae30",40:"97373ec8cb29426a5082",41:"d98585dc8a1a6d27b38d",42:"15292e65ed66384e4c3f",43:"8c7878a4639b343b6ce6"}[e]+".js"}(e);var u=new Error;a=function(r){o.onerror=o.onload=null,clearTimeout(i);var _=n[e];if(0!==_){if(_){var t=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+e+" failed.\n("+t+": "+a+")",u.name="ChunkLoadError",u.type=t,u.request=a,_[1](u)}n[e]=void 0}};var i=setTimeout((function(){a({type:"timeout",target:o})}),12e4);o.onerror=o.onload=a,document.head.appendChild(o)}return Promise.all(r)},__webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,r,_){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:_})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,r){if(1&r&&(e=__webpack_require__(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var _=Object.create(null);if(__webpack_require__.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var t in e)__webpack_require__.d(_,t,function(r){return e[r]}.bind(null,t));return _},__webpack_require__.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__.oe=function(e){throw console.error(e),e};var o=window.__googlesitekit_webpackJsonp=window.__googlesitekit_webpackJsonp||[],u=o.push.bind(o);o.push=r,o=o.slice();for(var i=0;i<o.length;i++)r(o[i]);var c=u;_()}([]);

View file

@ -19,40 +19,40 @@ return array(
'googlesitekit-events-provider-wpforms' => array( "googlesitekit-events-provider-wpforms-b35450445f9cb0eeb855.js", null ),
'analytics-advanced-tracking' => array( "analytics-advanced-tracking-ea84b2c367b69f5c094b.js", null ),
'googlesitekit-i18n' => array( "googlesitekit-i18n-33cdd2dee5d1d1f4fb34.js", null ),
'googlesitekit-admin-css' => array( "googlesitekit-admin-css-0167cbd9e2a4e951c2c2.min.css", null ),
'googlesitekit-admin-css' => array( "googlesitekit-admin-css-1a1b3dd6836e74847e00.min.css", null ),
'googlesitekit-adminbar-css' => array( "googlesitekit-adminbar-css-281d66e21d2b87430998.min.css", null ),
'googlesitekit-authorize-application-css' => array( "googlesitekit-authorize-application-css-ce25e97404abc5a02921.min.css", null ),
'googlesitekit-wp-dashboard-css' => array( "googlesitekit-wp-dashboard-css-55d9d8bb13cf249a2389.min.css", null ),
'googlesitekit-vendor' => array( "googlesitekit-vendor-0e5fcb2614a2df8b4141.js", null ),
'googlesitekit-runtime' => array( "runtime-7900ebf0cb27fa989ac7.js", null ),
'googlesitekit-activation' => array( "googlesitekit-activation-0ff4bb4905875a3af96d.js", null ),
'googlesitekit-ad-blocking-recovery' => array( "googlesitekit-ad-blocking-recovery-1bc5a979d40644f428b9.js", null ),
'googlesitekit-adminbar' => array( "googlesitekit-adminbar-3eb079e3b867b0628d63.js", null ),
'googlesitekit-api' => array( "googlesitekit-api-56127018cb7e490cef83.js", null ),
'googlesitekit-components' => array( array( "googlesitekit-components-gm2-cd1b1b91f7b0b537fb1c.js", null ), array( "googlesitekit-components-gm3-8508ed7feed06dfd7cea.js", null ) ),
'googlesitekit-data' => array( "googlesitekit-data-0a0301705fe2a7e3ea13.js", null ),
'googlesitekit-datastore-forms' => array( "googlesitekit-datastore-forms-38cfea41da192d1bc108.js", null ),
'googlesitekit-datastore-location' => array( "googlesitekit-datastore-location-2a54fd2f0e87dc2c9475.js", null ),
'googlesitekit-datastore-site' => array( "googlesitekit-datastore-site-f7b7542d42fef36c823b.js", null ),
'googlesitekit-datastore-ui' => array( "googlesitekit-datastore-ui-1bf7f3343b392b9d3d36.js", null ),
'googlesitekit-datastore-user' => array( "googlesitekit-datastore-user-7de58a4f6164bf6e0b50.js", null ),
'googlesitekit-entity-dashboard' => array( "googlesitekit-entity-dashboard-41ce7126b0d8da211ca8.js", null ),
'googlesitekit-main-dashboard' => array( "googlesitekit-main-dashboard-4da8f8cf7c833e75c20b.js", null ),
'googlesitekit-metric-selection' => array( "googlesitekit-metric-selection-3ee8a23dcaf39401f05a.js", null ),
'googlesitekit-modules' => array( "googlesitekit-modules-3149aa67bd387f1e1ecc.js", null ),
'googlesitekit-modules-ads' => array( "googlesitekit-modules-ads-eda91d5656699d965a11.js", null ),
'googlesitekit-modules-adsense' => array( "googlesitekit-modules-adsense-60e0039459ccbf52f2dc.js", null ),
'googlesitekit-modules-analytics-4' => array( "googlesitekit-modules-analytics-4-e7215bb257eaff98a241.js", null ),
'googlesitekit-modules-pagespeed-insights' => array( "googlesitekit-modules-pagespeed-insights-7e61c64f50cba689589c.js", null ),
'googlesitekit-modules-reader-revenue-manager' => array( "googlesitekit-modules-reader-revenue-manager-c83637e628e0caaef7d4.js", null ),
'googlesitekit-modules-search-console' => array( "googlesitekit-modules-search-console-ee6b9d229e6d6c34c65c.js", null ),
'googlesitekit-modules-sign-in-with-google' => array( "googlesitekit-modules-sign-in-with-google-ee4e9dd0a0285290e10e.js", null ),
'googlesitekit-modules-tagmanager' => array( "googlesitekit-modules-tagmanager-b2f7e90981d1eabf1a0c.js", null ),
'googlesitekit-notifications' => array( "googlesitekit-notifications-576ef786c988dd3d308a.js", null ),
'googlesitekit-polyfills' => array( "googlesitekit-polyfills-37387dc58c34dd8ec319.js", null ),
'googlesitekit-settings' => array( "googlesitekit-settings-f0011b69cd7c80cd340a.js", null ),
'googlesitekit-splash' => array( "googlesitekit-splash-0e6568b993910dcbfb85.js", null ),
'googlesitekit-user-input' => array( "googlesitekit-user-input-77dfa9da5c9848070722.js", null ),
'googlesitekit-widgets' => array( "googlesitekit-widgets-9f86e66067a4d5d6be4f.js", null ),
'googlesitekit-wp-dashboard' => array( "googlesitekit-wp-dashboard-c774dda1d72e62c09f79.js", null ),
'googlesitekit-vendor' => array( "googlesitekit-vendor-55f6d4109c59b75ef2bd.js", null ),
'googlesitekit-runtime' => array( "runtime-cafb5a04ad2af33b7709.js", null ),
'googlesitekit-activation' => array( "googlesitekit-activation-859303eb6e15c09c3a50.js", null ),
'googlesitekit-ad-blocking-recovery' => array( "googlesitekit-ad-blocking-recovery-ff4f4fe3cc2fc49e0dda.js", null ),
'googlesitekit-adminbar' => array( "googlesitekit-adminbar-9ee6cdb0be43ea55ded4.js", null ),
'googlesitekit-api' => array( "googlesitekit-api-9f1616f40adbca43e6b8.js", null ),
'googlesitekit-components' => array( array( "googlesitekit-components-gm2-7945eb0cdbd7dc3a89c2.js", null ), array( "googlesitekit-components-gm3-f995cfcb85091ab1e560.js", null ) ),
'googlesitekit-data' => array( "googlesitekit-data-590b288a64d1660dbc11.js", null ),
'googlesitekit-datastore-forms' => array( "googlesitekit-datastore-forms-c2f63f0c0adfa5c1bb08.js", null ),
'googlesitekit-datastore-location' => array( "googlesitekit-datastore-location-4bd0ca7dbf15fff9fb97.js", null ),
'googlesitekit-datastore-site' => array( "googlesitekit-datastore-site-dc7146f24a9f4d40e709.js", null ),
'googlesitekit-datastore-ui' => array( "googlesitekit-datastore-ui-7db934d367461124f5b8.js", null ),
'googlesitekit-datastore-user' => array( "googlesitekit-datastore-user-1542da3bbef03cd01780.js", null ),
'googlesitekit-entity-dashboard' => array( "googlesitekit-entity-dashboard-b0eeab16b25065093d82.js", null ),
'googlesitekit-main-dashboard' => array( "googlesitekit-main-dashboard-a4bcd8e2d49c8c193c4e.js", null ),
'googlesitekit-metric-selection' => array( "googlesitekit-metric-selection-70ed1134dac53010fa40.js", null ),
'googlesitekit-modules' => array( "googlesitekit-modules-1a2ef4f5ec6f6f1b060c.js", null ),
'googlesitekit-modules-ads' => array( "googlesitekit-modules-ads-23c0496d89342f02d84d.js", null ),
'googlesitekit-modules-adsense' => array( "googlesitekit-modules-adsense-4c9f3e82ede5101a7eec.js", null ),
'googlesitekit-modules-analytics-4' => array( "googlesitekit-modules-analytics-4-481b89c2cd44559a7bb4.js", null ),
'googlesitekit-modules-pagespeed-insights' => array( "googlesitekit-modules-pagespeed-insights-682896da4133e08c66ab.js", null ),
'googlesitekit-modules-reader-revenue-manager' => array( "googlesitekit-modules-reader-revenue-manager-7ec25dde6792354d0eba.js", null ),
'googlesitekit-modules-search-console' => array( "googlesitekit-modules-search-console-1c6864fceeeff7358e12.js", null ),
'googlesitekit-modules-sign-in-with-google' => array( "googlesitekit-modules-sign-in-with-google-0c7629ea71e0e833b0c2.js", null ),
'googlesitekit-modules-tagmanager' => array( "googlesitekit-modules-tagmanager-c8b6022c7b86c9ad9742.js", null ),
'googlesitekit-notifications' => array( "googlesitekit-notifications-b81ae6975e8afcf98876.js", null ),
'googlesitekit-polyfills' => array( "googlesitekit-polyfills-48e8493ea0e91c0facb6.js", null ),
'googlesitekit-settings' => array( "googlesitekit-settings-0c4ffef12bd5de9a413b.js", null ),
'googlesitekit-splash' => array( "googlesitekit-splash-e5aa53e206c5c1ddcc14.js", null ),
'googlesitekit-user-input' => array( "googlesitekit-user-input-4af8721f3482ada06493.js", null ),
'googlesitekit-widgets' => array( "googlesitekit-widgets-c8a23c2f9e2b270ac4c9.js", null ),
'googlesitekit-wp-dashboard' => array( "googlesitekit-wp-dashboard-80711a59677604d769b2.js", null ),
);

View file

@ -11,7 +11,7 @@
* Plugin Name: Site Kit by Google
* Plugin URI: https://sitekit.withgoogle.com
* Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
* Version: 1.145.0
* Version: 1.146.0
* Requires at least: 5.2
* Requires PHP: 7.4
* Author: Google
@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// Define most essential constants.
define( 'GOOGLESITEKIT_VERSION', '1.145.0' );
define( 'GOOGLESITEKIT_VERSION', '1.146.0' );
define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ );
define( 'GOOGLESITEKIT_PHP_MINIMUM', '7.4.0' );
define( 'GOOGLESITEKIT_WP_MINIMUM', '5.2.0' );

View file

@ -0,0 +1,73 @@
<?php
/**
* Interface Google\Site_Kit\Core\Storage\Meta_Interface
*
* @package Google\Site_Kit\Core\Storage
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Storage;
/**
* Interface for object meta implementations.
*
* @since 1.33.0
* @since 1.146.0 Renamed from Post_Meta_Interface to Meta_Interface.
*
* @access private
* @ignore
*/
interface Meta_Interface {
/**
* Gets object meta.
*
* @since 1.33.0
*
* @param int $object_id Object ID.
* @param string $key Metadata key.
* @param bool $single Whether to return a single value.
* @return mixed Object meta value.
*/
public function get( $object_id, $key, $single = false );
/**
* Updates an object meta field based on the given object ID.
*
* @since 1.33.0
*
* @param int $object_id Object ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value.
* @param mixed $prev_value Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries.
* @return bool TRUE on success, otherwise FALSE.
*/
public function update( $object_id, $key, $value, $prev_value = '' );
/**
* Adds a meta field to the given object.
*
* @since 1.33.0
*
* @param int $object_id Object ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value.
* @param bool $unique Whether the same key should not be added.
* @return int|bool Meta id on success, otherwise FALSE.
*/
public function add( $object_id, $key, $value, $unique = false );
/**
* Deletes an object meta field for the given object ID.
*
* @since 1.33.0
*
* @param int $object_id Object ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value. If provided, rows will only be removed that match the value.
* @return bool TRUE on success, otherwise FALSE.
*/
public function delete( $object_id, $key, $value = '' );
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Class Google\Site_Kit\Core\Storage\Post_Meta_Setting
* Class Google\Site_Kit\Core\Storage\Meta_Setting_Trait
*
* @package Google\Site_Kit\Core\Storage
* @copyright 2021 Google LLC
@ -11,32 +11,22 @@
namespace Google\Site_Kit\Core\Storage;
/**
* Base class for a single post meta setting.
* Base class for a single object meta setting.
*
* @since 1.33.0
* @since 1.146.0 Changed from Post_Meta_Setting to Meta_Setting_Trait.
*
* @access private
* @ignore
*/
abstract class Post_Meta_Setting {
trait Meta_Setting_Trait {
/**
* Post_Meta_Interface implementation.
* Meta_Interface implementation.
*
* @since 1.33.0
* @var Post_Meta_Interface
* @var Meta_Interface
*/
protected $post_meta;
/**
* Post_Meta_Setting constructor.
*
* @since 1.33.0
*
* @param Post_Meta_Interface $post_meta Post_Meta_Interface instance.
*/
public function __construct( Post_Meta_Interface $post_meta ) {
$this->post_meta = $post_meta;
}
protected $meta;
/**
* Gets the meta key for the setting.
@ -48,13 +38,22 @@ abstract class Post_Meta_Setting {
abstract protected function get_meta_key(): string;
/**
* Registers the post setting in WordPress.
* Gets the object type like `post`, `term`, etc.
*
* @since 1.146.0
*
* @return string Object type.
*/
abstract protected function get_object_type(): string;
/**
* Registers the object setting in WordPress.
*
* @since 1.33.0
*/
public function register() {
register_meta(
'post',
$this->get_object_type(),
$this->get_meta_key(),
array(
'type' => $this->get_type(),
@ -111,7 +110,7 @@ abstract class Post_Meta_Setting {
}
/**
* Gets the `show_in_rest` value for this postmeta setting value.
* Gets the `show_in_rest` value for this meta setting value.
*
* @since 1.37.0
*
@ -122,55 +121,59 @@ abstract class Post_Meta_Setting {
}
/**
* Checks whether a post meta exists or not.
* Checks whether meta exists for a given object or not.
*
* @since 1.33.0
* @since 1.146.0 Changed `$post_id` parameter to `$object_id`.
*
* @param int $post_id Post ID.
* @param int $object_id Object ID.
* @return bool True if the meta key exists, otherwise false.
*/
public function has( $post_id ) {
return metadata_exists( 'post', $post_id, $this->get_meta_key() );
public function has( $object_id ) {
return metadata_exists( $this->get_object_type(), $object_id, $this->get_meta_key() );
}
/**
* Gets the value of the setting.
*
* @since 1.33.0
* @since 1.146.0 Changed `$post_id` parameter to `$object_id`.
*
* @param int $post_id Post ID.
* @param int $object_id Object ID.
* @return mixed Value set for the setting, or default if not set.
*/
public function get( $post_id ) {
if ( ! $this->has( $post_id ) ) {
public function get( $object_id ) {
if ( ! $this->has( $object_id ) ) {
return $this->get_default();
}
return $this->post_meta->get( $post_id, $this->get_meta_key(), true );
return $this->meta->get( $object_id, $this->get_meta_key(), true );
}
/**
* Updates the post setting for the given post ID.
* Updates the setting for the given object ID.
*
* @since 1.33.0
* @since 1.146.0 Changed `$post_id` parameter to `$object_id`.
*
* @param int $post_id Post ID.
* @param mixed $value Metadata value.
* @param int $object_id Object ID.
* @param mixed $value Metadata value.
* @return bool TRUE on success, otherwise FALSE.
*/
public function set( $post_id, $value ) {
return $this->post_meta->update( $post_id, $this->get_meta_key(), $value );
public function set( $object_id, $value ) {
return $this->meta->update( $object_id, $this->get_meta_key(), $value );
}
/**
* Deletes the post setting for the given post ID.
* Deletes the setting for the given object ID.
*
* @since 1.33.0
* @since 1.146.0 Changed `$post_id` parameter to `$object_id`.
*
* @param int $post_id Post ID.
* @param int $object_id Object ID.
* @return bool TRUE on success, otherwise FALSE.
*/
public function delete( $post_id ) {
return $this->post_meta->delete( $post_id, $this->get_meta_key() );
public function delete( $object_id ) {
return $this->meta->delete( $object_id, $this->get_meta_key() );
}
}

View file

@ -17,7 +17,7 @@ namespace Google\Site_Kit\Core\Storage;
* @access private
* @ignore
*/
final class Post_Meta implements Post_Meta_Interface {
final class Post_Meta implements Meta_Interface {
/**
* Gets post meta.

View file

@ -1,9 +1,9 @@
<?php
/**
* Interface Google\Site_Kit\Core\Storage\Post_Meta_Interface
* Class Google\Site_Kit\Core\Storage\Term_Meta
*
* @package Google\Site_Kit\Core\Storage
* @copyright 2021 Google LLC
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
@ -11,61 +11,69 @@
namespace Google\Site_Kit\Core\Storage;
/**
* Interface for Post_Meta implementations.
* Term metadata storage class.
*
* @since 1.33.0
* @since 1.146.0
* @access private
* @ignore
*/
interface Post_Meta_Interface {
final class Term_Meta implements Meta_Interface {
/**
* Gets post meta.
* Gets term meta.
*
* @since 1.33.0
* @since 1.146.0
*
* @param int $post_id Post ID.
* @param int $term_id Term ID.
* @param string $key Metadata key.
* @param bool $single Whether to return a single value.
* @return mixed Post meta value.
* @return mixed Term meta value.
*/
public function get( $post_id, $key, $single = false );
public function get( $term_id, $key, $single = false ) {
return get_term_meta( $term_id, $key, $single );
}
/**
* Updates a post meta field based on the given post ID.
* Updates a term meta field based on the given term ID.
*
* @since 1.33.0
* @since 1.146.0
*
* @param int $post_id Post ID.
* @param int $term_id Term ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value.
* @param mixed $prev_value Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries.
* @return bool TRUE on success, otherwise FALSE.
*/
public function update( $post_id, $key, $value, $prev_value = '' );
public function update( $term_id, $key, $value, $prev_value = '' ) {
return update_term_meta( $term_id, $key, $value, $prev_value );
}
/**
* Adds a meta field to the given post.
* Adds a meta field to the given term.
*
* @since 1.33.0
* @since 1.146.0
*
* @param int $post_id Post ID.
* @param int $term_id Term ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value.
* @param bool $unique Whether the same key should not be added.
* @return int|bool Meta id on success, otherwise FALSE.
*/
public function add( $post_id, $key, $value, $unique = false );
public function add( $term_id, $key, $value, $unique = false ) {
return add_term_meta( $term_id, $key, $value, $unique );
}
/**
* Deletes a post meta field for the given post ID.
* Deletes a term meta field for the given term ID.
*
* @since 1.33.0
* @since 1.146.0
*
* @param int $post_id Post ID.
* @param int $term_id Term ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value. If provided, rows will only be removed that match the value.
* @return bool TRUE on success, otherwise FALSE.
*/
public function delete( $post_id, $key, $value = '' );
public function delete( $term_id, $key, $value = '' ) {
return delete_term_meta( $term_id, $key, $value );
}
}

View file

@ -136,8 +136,8 @@ class First_Party_Mode implements Module_With_Debug_Fields {
return array(
'first_party_mode_is_enabled' => array(
'label' => __( 'First-party mode: Enabled', 'google-site-kit' ),
'value' => $this->health_check_debug_field_value( $settings['isEnabled'] ),
'label' => __( 'First-party mode', 'google-site-kit' ),
'value' => ( true === $settings['isEnabled'] ) ? __( 'Enabled', 'google-site-kit' ) : __( 'Disabled', 'google-site-kit' ),
'debug' => $this->health_check_debug_field_debug( $settings['isEnabled'] ),
),
'first_party_mode_is_fpm_healthy' => array(

View file

@ -112,11 +112,13 @@ class Reset {
$this->delete_options( 'site' );
$this->delete_user_options( 'site' );
$this->delete_post_meta( 'site' );
$this->delete_term_meta( 'site' );
if ( $this->context->is_network_mode() ) {
$this->delete_options( 'network' );
$this->delete_user_options( 'network' );
$this->delete_post_meta( 'network' );
$this->delete_term_meta( 'network' );
}
wp_cache_flush();
@ -219,6 +221,41 @@ class Reset {
}
}
/**
* Deletes all Site Kit term meta settings.
*
* @since 1.146.0
*
* @param string $scope Scope of the deletion ('site' or 'network').
*/
private function delete_term_meta( $scope ) {
global $wpdb;
$sites = array();
if ( 'network' === $scope ) {
$sites = get_sites(
array(
'fields' => 'ids',
'number' => 9999999,
)
);
} else {
$sites[] = get_current_blog_id();
}
foreach ( $sites as $site_id ) {
$prefix = $wpdb->get_blog_prefix( $site_id );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$prefix}termmeta WHERE `meta_key` LIKE %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
static::KEY_PATTERN
)
);
}
}
/**
* Gets related REST routes.
*

View file

@ -32,13 +32,15 @@ use Google\Site_Kit\Core\REST_API\Data_Request;
use Google\Site_Kit\Core\REST_API\Exception\Missing_Required_Param_Exception;
use Google\Site_Kit\Core\Site_Health\Debug_Data;
use Google\Site_Kit\Core\Storage\Post_Meta;
use Google\Site_Kit\Core\Storage\Term_Meta;
use Google\Site_Kit\Core\Tags\Guards\Tag_Environment_Type_Guard;
use Google\Site_Kit\Core\Tags\Guards\Tag_Verify_Guard;
use Google\Site_Kit\Core\Util\Feature_Flags;
use Google\Site_Kit\Core\Util\URL;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Post_Product_ID;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Term_Product_ID;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Settings;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Synchronize_OnboardingState;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Synchronize_Publication;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Tag_Guard;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Tag_Matchers;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Web_Tag;
@ -73,21 +75,25 @@ final class Reader_Revenue_Manager extends Module implements Module_With_Scopes,
public function register() {
$this->register_scopes_hook();
$synchronize_onboarding_state = new Synchronize_OnboardingState(
$synchronize_publication = new Synchronize_Publication(
$this,
$this->user_options
);
$synchronize_onboarding_state->register();
$synchronize_publication->register();
if ( Feature_Flags::enabled( 'rrmModuleV2' ) && $this->is_connected() ) {
$post_meta = new Post_Meta();
$publication_id = $this->get_settings()->get()['publicationID'];
$post_product_id = new Post_Product_ID( $post_meta, $publication_id );
$post_product_id->register();
$term_meta = new Term_Meta();
$term_product_id = new Term_Product_ID( $term_meta, $publication_id );
$term_product_id->register();
}
add_action( 'load-toplevel_page_googlesitekit-dashboard', array( $synchronize_onboarding_state, 'maybe_schedule_synchronize_onboarding_state' ) );
add_action( 'load-toplevel_page_googlesitekit-settings', array( $synchronize_onboarding_state, 'maybe_schedule_synchronize_onboarding_state' ) );
add_action( 'load-toplevel_page_googlesitekit-dashboard', array( $synchronize_publication, 'maybe_schedule_synchronize_publication' ) );
add_action( 'load-toplevel_page_googlesitekit-settings', array( $synchronize_publication, 'maybe_schedule_synchronize_publication' ) );
// Reader Revenue Manager tag placement logic.
add_action( 'template_redirect', array( $this, 'register_tag' ) );

View file

@ -11,7 +11,7 @@
namespace Google\Site_Kit\Modules\Reader_Revenue_Manager;
use Google\Site_Kit\Core\Storage\Post_Meta;
use Google\Site_Kit\Core\Storage\Post_Meta_Setting;
use Google\Site_Kit\Core\Storage\Meta_Setting_Trait;
/**
* Class for associating product ID to post meta.
@ -20,7 +20,10 @@ use Google\Site_Kit\Core\Storage\Post_Meta_Setting;
* @access private
* @ignore
*/
class Post_Product_ID extends Post_Meta_Setting {
class Post_Product_ID {
use Meta_Setting_Trait;
/**
* Publication ID.
*
@ -39,8 +42,7 @@ class Post_Product_ID extends Post_Meta_Setting {
* @param string $publication_id Publication ID.
*/
public function __construct( Post_Meta $post_meta, string $publication_id ) {
parent::__construct( $post_meta );
$this->meta = $post_meta;
$this->publication_id = $publication_id;
}
@ -55,6 +57,17 @@ class Post_Product_ID extends Post_Meta_Setting {
return 'googlesitekit_rrm_' . $this->publication_id . ':productID';
}
/**
* Returns the object type.
*
* @since 1.146.0
*
* @return string Object type.
*/
protected function get_object_type(): string {
return 'post';
}
/**
* Gets the `show_in_rest` value for this postmeta setting value.
*

View file

@ -1,9 +1,9 @@
<?php
/**
* Class Google\Site_Kit\Modules\Reader_Revenue_Manager\Synchronize_OnboardingState
* Class Google\Site_Kit\Modules\Reader_Revenue_Manager\Synchronize_Publication
*
* @package Google\Site_Kit\Modules\Reader_Revenue_Manager
* @copyright 2024 Google LLC
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
@ -12,20 +12,23 @@ namespace Google\Site_Kit\Modules\Reader_Revenue_Manager;
use Google\Site_Kit\Core\Permissions\Permissions;
use Google\Site_Kit\Core\Storage\User_Options;
use Google\Site_Kit\Core\Util\Feature_Flags;
use Google\Site_Kit\Modules\Reader_Revenue_Manager;
use Google\Site_Kit_Dependencies\Google\Service\SubscribewithGoogle\Publication;
use Google\Site_Kit_Dependencies\Google\Service\SubscribewithGoogle\PaymentOptions;
/**
* Class for synchronizing the onboarding state.
*
* @since 1.141.0
* @since 1.146.0
* @access private
* @ignore
*/
class Synchronize_OnboardingState {
class Synchronize_Publication {
/**
* Cron event name for synchronizing the onboarding state.
* Cron event name for synchronizing the publication info.
*/
const CRON_SYNCHRONIZE_ONBOARDING_STATE = 'googlesitekit_cron_synchronize_onboarding_state';
const CRON_SYNCHRONIZE_PUBLICATION = 'googlesitekit_cron_synchronize_publication';
/**
* Reader_Revenue_Manager instance.
@ -44,7 +47,7 @@ class Synchronize_OnboardingState {
/**
* Constructor.
*
* @since 1.141.0
* @since 1.146.0
*
* @param Reader_Revenue_Manager $reader_revenue_manager Reader Revenue Manager instance.
* @param User_Options $user_options User_Options instance.
@ -57,13 +60,13 @@ class Synchronize_OnboardingState {
/**
* Registers functionality through WordPress hooks.
*
* @since 1.141.0
* @since 1.146.0
*
* @return void
*/
public function register() {
add_action(
self::CRON_SYNCHRONIZE_ONBOARDING_STATE,
self::CRON_SYNCHRONIZE_PUBLICATION,
function () {
$this->synchronize_publication_data();
}
@ -73,7 +76,7 @@ class Synchronize_OnboardingState {
/**
* Cron callback for synchronizing the publication.
*
* @since 1.141.0
* @since 1.146.0
*
* @return void
*/
@ -82,32 +85,13 @@ class Synchronize_OnboardingState {
$restore_user = $this->user_options->switch_user( $owner_id );
if ( user_can( $owner_id, Permissions::VIEW_AUTHENTICATED_DASHBOARD ) ) {
$this->synchronize_onboarding_state();
}
$connected = $this->reader_revenue_manager->is_connected();
$restore_user();
}
// If not connected, return early.
if ( ! $connected ) {
return;
}
/**
* Synchronizes the onboarding state.
*
* @since 1.141.0
*
* @return void
*/
protected function synchronize_onboarding_state() {
$connected = $this->reader_revenue_manager->is_connected();
// If not connected, return early.
if ( ! $connected ) {
return;
}
$settings = $this->reader_revenue_manager->get_settings()->get();
$publication_id = $settings['publicationID'];
$onboarding_state = $settings['publicationOnboardingState'];
if ( 'ONBOARDING_COMPLETE' !== $onboarding_state ) {
$publications = $this->reader_revenue_manager->get_data( 'publications' );
// If publications is empty, return early.
@ -115,6 +99,9 @@ class Synchronize_OnboardingState {
return;
}
$settings = $this->reader_revenue_manager->get_settings()->get();
$publication_id = $settings['publicationID'];
$filtered_publications = array_filter(
$publications,
function ( $pub ) use ( $publication_id ) {
@ -131,32 +118,95 @@ class Synchronize_OnboardingState {
$filtered_publications = array_values( $filtered_publications );
$publication = $filtered_publications[0];
if ( $publication->getOnboardingState() !== $onboarding_state ) {
$this->reader_revenue_manager->get_settings()->merge(
array(
'publicationOnboardingState' => $publication->getOnboardingState(),
'publicationOnboardingStateChanged' => true,
)
);
$onboarding_state = $settings['publicationOnboardingState'];
$new_onboarding_state = $publication->getOnboardingState();
$new_settings = array(
'publicationOnboardingState' => $new_onboarding_state,
);
// Let the client know if the onboarding state has changed.
if ( $new_onboarding_state !== $onboarding_state ) {
$new_settings['publicationOnboardingStateChanged'] = true;
}
if ( Feature_Flags::enabled( 'rrmModuleV2' ) ) {
$new_settings['productIDs'] = $this->get_product_ids( $publication );
$new_settings['paymentOption'] = $this->get_payment_option( $publication );
}
$this->reader_revenue_manager->get_settings()->merge( $new_settings );
}
$restore_user();
}
/**
* Returns the products IDs for the given publication.
*
* @since 1.146.0
*
* @param Publication $publication Publication object.
* @return array Product IDs.
*/
protected function get_product_ids( Publication $publication ) {
$products = $publication->getProducts();
$product_ids = array();
if ( ! empty( $products ) ) {
foreach ( $products as $product ) {
$name = $product->getName();
// Extract the product ID from the name, which is in
// the format of `publicationID:productID`.
if ( strpos( $name, ':' ) !== false ) {
$product_ids[] = substr( $name, strpos( $name, ':' ) + 1 );
}
}
}
return $product_ids;
}
/**
* Returns the payment option for the given publication.
*
* @since 1.146.0
*
* @param Publication $publication Publication object.
* @return string Payment option.
*/
protected function get_payment_option( Publication $publication ) {
$payment_options = $publication->getPaymentOptions();
$payment_option = '';
if ( $payment_options instanceof PaymentOptions ) {
foreach ( $payment_options as $option => $value ) {
if ( true === $value ) {
$payment_option = $option;
break;
}
}
}
return $payment_option;
}
/**
* Maybe schedule the synchronize onboarding state cron event.
*
* @since 1.141.0
* @since 1.146.0
*
* @return void
*/
public function maybe_schedule_synchronize_onboarding_state() {
public function maybe_schedule_synchronize_publication() {
$connected = $this->reader_revenue_manager->is_connected();
$cron_already_scheduled = wp_next_scheduled( self::CRON_SYNCHRONIZE_ONBOARDING_STATE );
$cron_already_scheduled = wp_next_scheduled( self::CRON_SYNCHRONIZE_PUBLICATION );
if ( $connected && ! $cron_already_scheduled ) {
wp_schedule_single_event(
time() + HOUR_IN_SECONDS,
self::CRON_SYNCHRONIZE_ONBOARDING_STATE
self::CRON_SYNCHRONIZE_PUBLICATION
);
}
}

View file

@ -0,0 +1,81 @@
<?php
/**
* Class Google\Site_Kit\Modules\Reader_Revenue_Manager\Term_Product_ID
*
* @package Google\Site_Kit\Modules\Reader_Revenue_Manager
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Modules\Reader_Revenue_Manager;
use Google\Site_Kit\Core\Storage\Term_Meta;
use Google\Site_Kit\Core\Storage\Meta_Setting_Trait;
/**
* Class for associating product ID to term meta.
*
* @since 1.146.0
* @access private
* @ignore
*/
class Term_Product_ID {
use Meta_Setting_Trait;
/**
* Publication ID.
*
* @since 1.146.0
*
* @var string
*/
private string $publication_id;
/**
* Term_Product_ID constructor.
*
* @since 1.146.0
*
* @param Term_Meta $term_meta Term_Meta instance.
* @param string $publication_id Publication ID.
*/
public function __construct( Term_Meta $term_meta, string $publication_id ) {
$this->meta = $term_meta;
$this->publication_id = $publication_id;
}
/**
* Gets the meta key for the setting.
*
* @since 1.146.0
*
* @return string Meta key.
*/
protected function get_meta_key(): string {
return 'googlesitekit_rrm_' . $this->publication_id . ':productID';
}
/**
* Returns the object type.
*
* @since 1.146.0
*
* @return string Object type.
*/
protected function get_object_type(): string {
return 'term';
}
/**
* Gets the `show_in_rest` value for this termmeta setting value.
*
* @since 1.146.0
*
* @return bool|Array Any valid value for the `show_in_rest`
*/
protected function get_show_in_rest() {
return true;
}
}

View file

@ -80,6 +80,14 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
*/
protected $existing_client_id;
/**
* WooCommerce instance.
*
* @since 1.146.0
* @var WooCommerce
*/
protected $woocommerce;
/**
* Constructor.
*
@ -100,6 +108,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
) {
parent::__construct( $context, $options, $user_options, $authentication, $assets );
$this->existing_client_id = new Existing_Client_ID( $this->options );
$this->woocommerce = new WooCommerce( $this->context );
}
/**
@ -111,7 +120,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
public function register() {
add_filter( 'wp_login_errors', array( $this, 'handle_login_errors' ) );
add_filter( 'googlesitekit_inline_modules_data', $this->get_method_proxy( 'inline_existing_client_id' ), 10 );
add_filter( 'googlesitekit_inline_modules_data', $this->get_method_proxy( 'inline_module_data' ), 10 );
add_action(
'login_form_' . self::ACTION_AUTH,
@ -308,7 +317,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
}
/**
* Renders the Sign in with Google JS script tags, One-tap code, and
* Renders the Sign in with Google JS script tags, One Tap code, and
* buttons.
*
* @since 1.139.0
@ -328,7 +337,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
}
// If this is not the WordPress or WooCommerce login page, check to
// see if "One-tap enabled on all pages" is set first. If it isnt:
// see if "One Tap enabled on all pages" is set first. If it isnt:
// don't render the Sign in with Google JS.
if ( ! $is_wp_login && ! $is_woocommerce_login && ! $settings['oneTapOnAllPages'] ) {
return;
@ -352,6 +361,19 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
// Whether buttons will be rendered/transformed on this page.
$render_buttons = $is_wp_login || $is_woocommerce_login;
$render_one_tap = ! empty( $settings['oneTapEnabled'] ) && ( $is_wp_login || ! is_user_logged_in() );
// If we aren't rendering buttons or One-tap, return early.
if ( ! $render_buttons && ! $render_one_tap ) {
return;
}
// Set the cookie time to live to 5 minutes. If the redirect_to is empty,
// set the cookie to expire immediately.
$cookie_expire_time = 300000;
if ( empty( $redirect_to ) ) {
$cookie_expire_time *= -1;
}
// Render the Sign in with Google script.
ob_start();
@ -368,9 +390,14 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams( response )
} );
if ( res.ok && res.redirected ) {
location.assign( res.url );
}
<?php if ( empty( $redirect_to ) && ! $render_buttons && $render_one_tap ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
location.reload();
<?php else : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
if ( res.ok && res.redirected ) {
location.assign( res.url );
}
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
} catch( error ) {
console.error( error );
}
@ -390,23 +417,25 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
<?php if ( $is_woocommerce_login ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
for ( const login of document.getElementsByClassName( 'login' ) ) {
login.insertBefore( parent, login.firstChild );
parent.classList.add( 'woocommerce-form-row', 'form-row' );
const form = document.querySelector( '.woocommerce-form.login' );
if ( form ) {
form.insertBefore( parent, form.firstChild );
}
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
google.accounts.id.renderButton( parent, <?php echo wp_json_encode( $btn_args ); ?> );
<?php if ( ! empty( $redirect_to ) ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
const expires = new Date();
expires.setTime( expires.getTime() + 300000 );<?php // 5 minutes ?>
document.cookie = "<?php echo esc_js( Authenticator::COOKIE_REDIRECT_TO ); ?>=<?php echo esc_js( $redirect_to ); ?>;expires=" + expires.toUTCString() + ";path=<?php echo esc_js( Authenticator::get_cookie_path() ); ?>";
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
<?php if ( ! empty( $settings['oneTapEnabled'] ) && ( $is_wp_login || ! is_user_logged_in() ) ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
<?php if ( $render_one_tap ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
google.accounts.id.prompt();
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
<?php if ( ! empty( $redirect_to ) ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
const expires = new Date();
expires.setTime( expires.getTime() + <?php echo esc_js( $cookie_expire_time ); ?> );
document.cookie = "<?php echo esc_js( Authenticator::COOKIE_REDIRECT_TO ); ?>=<?php echo esc_js( $redirect_to ); ?>;expires=" + expires.toUTCString() + ";path=<?php echo esc_js( Authenticator::get_cookie_path() ); ?>";
<?php endif; // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>
} )();
<?php
@ -479,7 +508,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
),
'sign_in_with_google_use_snippet' => array(
/* translators: %s: Sign in with Google service name */
'label' => sprintf( __( '%s: One-tap Enabled', 'google-site-kit' ), _x( 'Sign in with Google', 'Service name', 'google-site-kit' ) ),
'label' => sprintf( __( '%s: One Tap Enabled', 'google-site-kit' ), _x( 'Sign in with Google', 'Service name', 'google-site-kit' ) ),
'value' => $settings['oneTapEnabled'] ? __( 'Yes', 'google-site-kit' ) : __( 'No', 'google-site-kit' ),
'debug' => $settings['oneTapEnabled'] ? 'yes' : 'no',
),
@ -529,8 +558,7 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
public function get_content_url() {
$wp_login_url = wp_login_url();
$woo_commerce = new WooCommerce( $this->context );
if ( $woo_commerce->is_active() ) {
if ( $this->woocommerce->is_active() ) {
$wc_login_page_id = wc_get_page_id( 'myaccount' );
$wc_login_url = get_permalink( $wc_login_page_id );
return array(
@ -669,24 +697,31 @@ final class Sign_In_With_Google extends Module implements Module_With_Assets, Mo
}
/**
* Exposes an existing client ID from a previous connection
* to JS via _googlesitekitModulesData.
* Exposes inline module data to JS via _googlesitekitModulesData.
*
* @since 1.142.0
* @since 1.146.0 Added isWooCommerceActive and isWooCommerceRegistrationEnabled to the inline data.
*
* @param array $modules_data Inline modules data.
* @return array Inline modules data.
*/
protected function inline_existing_client_id( $modules_data ) {
$existing_client_id = $this->existing_client_id->get();
protected function inline_module_data( $modules_data ) {
$inline_data = array();
$existing_client_id = $this->existing_client_id->get();
if ( $existing_client_id ) {
// Add the data under the `sign-in-with-google` key to make it clear it's scoped to this module.
$modules_data['sign-in-with-google'] = array(
'existingClientID' => $existing_client_id,
);
$inline_data['existingClientID'] = $existing_client_id;
}
$is_woocommerce_active = $this->woocommerce->is_active();
$woocommerce_registration_enabled = $is_woocommerce_active ? get_option( 'woocommerce_enable_myaccount_registration' ) : null;
$inline_data['isWooCommerceActive'] = $is_woocommerce_active;
$inline_data['isWooCommerceRegistrationEnabled'] = $is_woocommerce_active && 'yes' === $woocommerce_registration_enabled;
// Add the data under the `sign-in-with-google` key to make it clear it's scoped to this module.
$modules_data['sign-in-with-google'] = $inline_data;
return $modules_data;
}
}

View file

@ -133,14 +133,9 @@ class Authenticator implements Authenticator_Interface {
$redirect_to = admin_url();
// If we have the redirect URL in the cookie, use it as the main redirect_to URL.
$cookie_redirect_to = $input->filter( INPUT_COOKIE, self::COOKIE_REDIRECT_TO );
$cookie_redirect_to = $this->get_cookie_redirect( $input );
if ( ! empty( $cookie_redirect_to ) ) {
$redirect_to = $cookie_redirect_to;
if ( ! headers_sent() ) {
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie
setcookie( self::COOKIE_REDIRECT_TO, '', time() - 3600, self::get_cookie_path(), COOKIE_DOMAIN );
}
}
// Redirect to HTTPS if user wants SSL.
@ -334,4 +329,22 @@ class Authenticator implements Authenticator_Interface {
public static function get_cookie_path() {
return dirname( wp_parse_url( wp_login_url(), PHP_URL_PATH ) );
}
/**
* Gets the redirect URL from the cookie and clears the cookie.
*
* @since 1.146.0
*
* @param Input $input Input instance.
* @return string Redirect URL.
*/
protected function get_cookie_redirect( $input ) {
$cookie_redirect_to = $input->filter( INPUT_COOKIE, self::COOKIE_REDIRECT_TO );
if ( ! empty( $cookie_redirect_to ) && ! headers_sent() ) {
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie
setcookie( self::COOKIE_REDIRECT_TO, '', time() - 3600, self::get_cookie_path(), COOKIE_DOMAIN );
}
return $cookie_redirect_to;
}
}

View file

@ -42,13 +42,21 @@ class WooCommerce_Authenticator extends Authenticator {
* Gets the redirect URL after the user signs in with Google.
*
* @since 1.145.0
* @since 1.146.0 Updated to take into account redirect URL from cookie.
*
* @param WP_User $user User object.
* @param Input $input Input instance.
* @return string Redirect URL.
*/
protected function get_redirect_url( $user, $input ) {
$redirect = wc_get_page_permalink( 'myaccount' );
return apply_filters( 'woocommerce_login_redirect', $redirect, $user );
$redirect_to = wc_get_page_permalink( 'myaccount' );
// If we have the redirect URL in the cookie, use it as the main redirect_to URL.
$cookie_redirect_to = $this->get_cookie_redirect( $input );
if ( ! empty( $cookie_redirect_to ) ) {
$redirect_to = $cookie_redirect_to;
}
return apply_filters( 'woocommerce_login_redirect', $redirect_to, $user );
}
}

View file

@ -157,17 +157,18 @@ return array(
'Google\\Site_Kit\\Core\\Storage\\Data_Encryption' => $baseDir . '/Core/Storage/Data_Encryption.php',
'Google\\Site_Kit\\Core\\Storage\\Encrypted_Options' => $baseDir . '/Core/Storage/Encrypted_Options.php',
'Google\\Site_Kit\\Core\\Storage\\Encrypted_User_Options' => $baseDir . '/Core/Storage/Encrypted_User_Options.php',
'Google\\Site_Kit\\Core\\Storage\\Meta_Interface' => $baseDir . '/Core/Storage/Meta_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\Meta_Setting_Trait' => $baseDir . '/Core/Storage/Meta_Setting_Trait.php',
'Google\\Site_Kit\\Core\\Storage\\Options' => $baseDir . '/Core/Storage/Options.php',
'Google\\Site_Kit\\Core\\Storage\\Options_Interface' => $baseDir . '/Core/Storage/Options_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\Post_Meta' => $baseDir . '/Core/Storage/Post_Meta.php',
'Google\\Site_Kit\\Core\\Storage\\Post_Meta_Interface' => $baseDir . '/Core/Storage/Post_Meta_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\Post_Meta_Setting' => $baseDir . '/Core/Storage/Post_Meta_Setting.php',
'Google\\Site_Kit\\Core\\Storage\\Setting' => $baseDir . '/Core/Storage/Setting.php',
'Google\\Site_Kit\\Core\\Storage\\Setting\\List_Setting' => $baseDir . '/Core/Storage/Setting/List_Setting.php',
'Google\\Site_Kit\\Core\\Storage\\Setting_With_Legacy_Keys_Trait' => $baseDir . '/Core/Storage/Setting_With_Legacy_Keys_Trait.php',
'Google\\Site_Kit\\Core\\Storage\\Setting_With_Owned_Keys_Interface' => $baseDir . '/Core/Storage/Setting_With_Owned_Keys_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\Setting_With_Owned_Keys_Trait' => $baseDir . '/Core/Storage/Setting_With_Owned_Keys_Trait.php',
'Google\\Site_Kit\\Core\\Storage\\Setting_With_ViewOnly_Keys_Interface' => $baseDir . '/Core/Storage/Setting_With_ViewOnly_Keys_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\Term_Meta' => $baseDir . '/Core/Storage/Term_Meta.php',
'Google\\Site_Kit\\Core\\Storage\\Transients' => $baseDir . '/Core/Storage/Transients.php',
'Google\\Site_Kit\\Core\\Storage\\User_Aware_Interface' => $baseDir . '/Core/Storage/User_Aware_Interface.php',
'Google\\Site_Kit\\Core\\Storage\\User_Aware_Trait' => $baseDir . '/Core/Storage/User_Aware_Trait.php',
@ -309,9 +310,10 @@ return array(
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager' => $baseDir . '/Modules/Reader_Revenue_Manager.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Post_Product_ID' => $baseDir . '/Modules/Reader_Revenue_Manager/Post_Product_ID.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Settings' => $baseDir . '/Modules/Reader_Revenue_Manager/Settings.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Synchronize_OnboardingState' => $baseDir . '/Modules/Reader_Revenue_Manager/Synchronize_OnboardingState.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Synchronize_Publication' => $baseDir . '/Modules/Reader_Revenue_Manager/Synchronize_Publication.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Tag_Guard' => $baseDir . '/Modules/Reader_Revenue_Manager/Tag_Guard.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Tag_Matchers' => $baseDir . '/Modules/Reader_Revenue_Manager/Tag_Matchers.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Term_Product_ID' => $baseDir . '/Modules/Reader_Revenue_Manager/Term_Product_ID.php',
'Google\\Site_Kit\\Modules\\Reader_Revenue_Manager\\Web_Tag' => $baseDir . '/Modules/Reader_Revenue_Manager/Web_Tag.php',
'Google\\Site_Kit\\Modules\\Search_Console' => $baseDir . '/Modules/Search_Console.php',
'Google\\Site_Kit\\Modules\\Search_Console\\Settings' => $baseDir . '/Modules/Search_Console/Settings.php',

View file

@ -4,7 +4,7 @@ Contributors: google
Requires at least: 5.2
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.145.0
Stable tag: 1.146.0
License: Apache License 2.0
License URI: https://www.apache.org/licenses/LICENSE-2.0
Tags: google, search-console, analytics, adsense, pagespeed-insights
@ -109,29 +109,39 @@ Please create a new topic on our [WordPress.org support forum](https://wordpress
== Changelog ==
= 1.145.0 =
= 1.146.0 =
**Enhanced**
* Add Site Health information for Reader Revenue Manager expansions. See [#9974](https://github.com/google/site-kit-wp/issues/9974).
* Add an empty RRM V2 JavaScript entry point for the WordPress block editor, with functionality to be added in subsequent issues. See [#9957](https://github.com/google/site-kit-wp/issues/9957).
* Add mechanism to store post-level Reader Revenue Manager settings. See [#9955](https://github.com/google/site-kit-wp/issues/9955).
* Update Reader Revenue Manager module settings infrastructure. See [#9951](https://github.com/google/site-kit-wp/issues/9951).
* Add a trigger for a survey when the user sees the FPM setup banner, and one when the user enables FPM, in order to help track usage of the feature. See [#9940](https://github.com/google/site-kit-wp/issues/9940).
* Update copy on disconnect module modal. See [#9935](https://github.com/google/site-kit-wp/issues/9935).
* Standardize the capitalization of "First-party mode" across the plugin for consistency. See [#9902](https://github.com/google/site-kit-wp/issues/9902).
* Ensure the Reader Revenue Manager Setup CTA does not appear alongside other CTAs. See [#9889](https://github.com/google/site-kit-wp/issues/9889).
* Add error handling to the First-party mode setup banner to display errors and prevent premature dismissal when saving settings fail. See [#9846](https://github.com/google/site-kit-wp/issues/9846).
* Update auth error notification to use new notifications infrastructure. See [#9284](https://github.com/google/site-kit-wp/issues/9284).
* Update tooltip tours to display on smaller screen sizes. See [#3003](https://github.com/google/site-kit-wp/issues/3003).
* Add warning to users when Sign in with Google One-tap appears site-wide without open user registrations. See [#10079](https://github.com/google/site-kit-wp/issues/10079).
* Update the Reader Revenue Manager settings view screen to include new settings introduced in Phase 2. See [#10067](https://github.com/google/site-kit-wp/issues/10067).
* Add a reusable chip multi-select component. See [#10064](https://github.com/google/site-kit-wp/issues/10064).
* Update the Reader Revenue Manager setup CTA banner copy to highlight paywall support when the feature flag is enabled. See [#10063](https://github.com/google/site-kit-wp/issues/10063).
* Add mechanism to clear term meta on Site Kit reset. See [#10061](https://github.com/google/site-kit-wp/issues/10061).
* Add mechanism to store term-level Reader Revenue Manager settings. See [#9956](https://github.com/google/site-kit-wp/issues/9956).
* Add mechanism to synchronize Reader Revenue Manager publication information. See [#9954](https://github.com/google/site-kit-wp/issues/9954).
* Add mechanism to reset publication-specific information when the publication is changed. See [#9953](https://github.com/google/site-kit-wp/issues/9953).
* Update Reader Revenue Manager publication selection to populate new settings. See [#9952](https://github.com/google/site-kit-wp/issues/9952).
* Add infrastructure to interface with WordPress term metadata. See [#9949](https://github.com/google/site-kit-wp/issues/9949).
* Improve the styling of the Sign in with Google button on WooCommerce login forms. See [#9932](https://github.com/google/site-kit-wp/issues/9932).
* Update Ads settings view screen to display items in the correct order. See [#9908](https://github.com/google/site-kit-wp/issues/9908).
* Update the First-party mode status in Site Health to use "Enabled" or "Disabled" instead of "Yes" or "No" and update the label from "First-party mode: Enabled" to "First-party mode". See [#9904](https://github.com/google/site-kit-wp/issues/9904).
* Refactor consent mode setup CTA to use new infrastructure. See [#9887](https://github.com/google/site-kit-wp/issues/9887).
* Update the Audience Segmentation Setup CTA so it does not appear alongside other CTAs. See [#9886](https://github.com/google/site-kit-wp/issues/9886).
* Update visitor group card to prevent including `(not set)` in cities with the most visitors. See [#9604](https://github.com/google/site-kit-wp/issues/9604).
**Changed**
* Update the service provisioning URL not to contain the `supportemail` query param. See [#10024](https://github.com/google/site-kit-wp/issues/10024).
* Ensure user is redirected back to original page when using Sign in with Google. See [#10015](https://github.com/google/site-kit-wp/issues/10015).
**Fixed**
* Fix custom dimension metric tiles error when loaded on the KMW widget with the ACR feature flag enabled. See [#9967](https://github.com/google/site-kit-wp/issues/9967).
* Improve redirects when Sign in with Google login fails on WooCommerce pages. See [#9780](https://github.com/google/site-kit-wp/issues/9780).
* Improve reliability of Sign in with Google rendering on WooCommerce account pages. See [#10120](https://github.com/google/site-kit-wp/issues/10120).
* Fix bug that could cause CTA to add new metrics to Analytics. See [#10044](https://github.com/google/site-kit-wp/issues/10044).
* Fix bug that caused the "Top traffic source driving leads" metric to show no data in the "90 days" view. See [#10043](https://github.com/google/site-kit-wp/issues/10043).
* Fix bug that could cause metrics not to update properly if answers were changed several times before saving changes. See [#10034](https://github.com/google/site-kit-wp/issues/10034).
* Ensure suggested metrics include new events. See [#10033](https://github.com/google/site-kit-wp/issues/10033).
* Fix user registration notification dismissal issue on the Sign in with Google settings screen. See [#9933](https://github.com/google/site-kit-wp/issues/9933).
* Fix key metrics setup CTA layout at 960px. See [#9911](https://github.com/google/site-kit-wp/issues/9911).
[See changelog for all versions](https://raw.githubusercontent.com/google/site-kit-wp/main/changelog.txt).

View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -0,0 +1,334 @@
=== TikTok ===
Contributors: tiktokforbusiness, woocommerce, automattic
Tags: tiktok
Requires at least: 5.7.0
Tested up to: 6.7.2
Stable tag: 1.3.1
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Languages: Arabic, Cantonese, Czech, Danish, Dutch, English, Finnish, French, German, Hebrew, Indonesian, Italian, Japanese, Korean, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, Serbian, Simplified Chinese, Spanish, Swedish, Thai, Traditional Chinese, Turkish, Vietnamese
This build seamlessly connects your application to TikTok to enable marketing and sales opportunities.
== Screenshots ==
== Description ==
The official TikTok plugin makes it easy to put your business in front of billions of highly engaged consumers, helping you achieve your marketing and sales objectives by promoting your products or services worldwide. These users arent just browsing; theyre buying, as evidenced by the popular hashtag #TikTokMadeMeBuyIt. And they could become your next customers.
**You can integrate with TikTok directly on WordPress to run Lead Generation Ads to capture leads and improve targeting. If you want to also run other types of ads and unlock additional features, please go to [WooCommerce](https://woo.com/products/tiktok-for-woocommerce/?quid=248069d58a62fa8c7022af8cbf7bb391) to download the official TikTok integration.**
With the official TikTok plugin, you can perform the following:
- Easily install the TikTok Pixel and enable the Events API to track your traffic, measure and optimize your campaign performance, and find new customers.
- Run Lead Generation Ads to capture emails for future campaigns.
- Sync your store catalog to TikTok (available via the WooCommerce integration).
- Create engaging conversion ads from your product catalog (available via the WooCommerce integration).
- Use TikTok Shop to showcase and sell your products directly on the platform (available via the WooCommerce integration in select markets, including the UK and US).
== TikTok Features ==
=== Find new prospects ===
- With TikTok Lead Gen Ads, seamlessly gather new leads on the platform using instant, customizable forms that integrate with your CRM system, simplifying lead qualification and conversion.
=== Connect your catalog === (available via the WooCommerce integration)
- Sync your entire Woo product catalog in minutes to power easy ad creation and simplified selling on TikTok Shop (TikTok Shop is only available in in select markets, including the UK and US).
- Includes all your key product data: names, descriptions, prices, images, videos, and more.
- Customers only see in-stock products on TikTok.
- Our real-time, two-way sync means your products will always be up to date on TikTok.
=== Advertise your products === (available via the WooCommerce integration)
Effortlessly create new ads, do no-stress campaign creation to reach your advertising objectives with:
- One-click Ad Account and Business Center Account creation gets you ready to start advertising quickly.
- Launch new campaigns in minutes: just configure your budget, targeting, and optimization event.
- Choose the creative you want to feature or use your catalog images to automatically create engaging video ads using the embedded Smart Video Generator tool.
- Set automatic targeting when creating a campaign to let the algorithm find your ideal TikTok audience.
**Special, limited-time offer:** Get up to $1,500 in ad credits when you test your first TikTok ad campaign! ([Terms and conditions apply](https://ads.tiktok.com/help/article/woocommerce-coupon-program?lang=en))
=== Measure and improve your ad performance === (available via the WooCommerce integration)
- Install the TikTok Pixel and Events API with a click, enabling browser and server-side connection with automatic updates — no developer needed.
- Enable Advanced Matching to allow for more refined targeting and optimization, which has shown to have a positive impact on campaign performance.
- Measure performance across the customer journey, including payment and checkout pages.
- Make informed decisions using deep insights into your campaign: increase ad performance, capture more leads, and improve targeting.
**Note:** Advertisers with an existing TikTok Pixel can connect it to the TikTok integration. However, we recommend leveraging the new pixel created and installed via the official TikTok for WooCommerce extension for a more seamless setup and event deduplication. If you use an existing custom setup, there may be deduplication work required for accurate reporting. Check out the [TikTok Business Help Center](https://ads.tiktok.com/help/article/event-deduplication?lang=en) for more on deduplication.
=== Sell seamlessly with TikTok Shop === (available via the WooCommerce integration in select markets, including the UK and US)
- Enable TikTok users to buy your products right on TikTok through in-feed videos, LIVEs, or the Store page.
- Increase conversion, reduce cart abandonment, and turn viewers into loyal customers.
- Includes product recommendations, advanced product search, and seamless, mobile-optimized checkout to help shoppers browse and buy better.
- Track your performance and get to know your customers with dashboards for traffic, conversion rate, and transaction data.
- [TikTok Shops Affiliate Program](https://shop.tiktok.com/business/en/affiliate) lets you partner with creators to grow your business.
=== Need support getting started & growing on TikTok? ===
- [TikTok Marketing Partners](https://partners.tiktok.com/pc/en?rid=tk5y9m8vkm) provide expert assistance with campaign management, measurement, and creative production services for every budget and audience.
- Our dedicated TikTok customer support team can provide platform assistance and guidance. If you need help with installing or getting started with the TikTok plugin on WordPress or the TikTok integration on WooCommerce, please [open a support ticket] at (https://wordpress.org/support/plugin/tiktok-for-business/) or (https://woo.com/contact-us/).
=== Creative resources ===
- Learn more about [creative best practices](https://www.tiktok.com/business/en-US/blog/creative-best-practices-top-performing-ads) for TikTok.
- [Get inspiration](https://www.tiktok.com/business/en-US/inspiration) from other small businesses who have found success on TikTok.
== Get started in 3 steps! ==
1. **Download and add the official TikTok integration from the WordPress plugin directory or the WooCommerce store.**
2. **Under the marketing sidebar menu, select TikTok and initiate your setup.**
3. **Follow the prompts to complete the setup and create or connect your TikTok accounts.** Please note: The division between Marketing and Shop tabs is visible in the WooCommerce integration only.
1. **For Marketing:**
1. Sign in or create a new TikTok account.
2. Authorize WordPress or WooCommerce to connect with TikTok for Business.
3. Connect your existing Business Center.
4. Install the pixel and activate Advanced Matching for maximized performance (or connect an existing one).
5. Sync your product catalog (available via the WooCommerce integration).
6. Add your billing & payment info to test your first campaign.
7. [View detailed instructions](https://woocommerce.com/document/tiktok-for-woocommerce/#section-6).
2. **For TikTok Shop:** (available in the US and UK)
1. Sign in or create a new TikTok account.
2. Authorize WooCommerce to connect with a new or existing TikTok for Business.
3. Connect TikTok for Business to TikTok Shop.
4. Upload the necessary documentation for your business.
5. Enter the warehouse information for your business.
6. Sync your product catalog.
7. [View detailed instructions](https://woocommerce.com/document/tiktok-for-woocommerce/).
**Want to learn more before you get started with TikTok? Get in touch with a [TikTok Specialist](https://connectwithtiktokspecialistcommerce.splashthat.com/)!**
== FAQs ==
=== What does the official TikTok integration enable? ===
When you set up the plugin, you will have:
- Easy TikTok For Business and Ad accounts set-up.
- Server and Browser (Pixel) side connection in one click.
Additionally, for installers from WooCommerce:
- Automatic catalog sync to use ad formats like Video Shopping Ads.
- Access to assisted ad-campaign creation within your dashboard.
=== Do I need to have a TikTok account? ===
You will need to connect to a new or existing TikTok account.
=== What events does the TikTok Pixel for WordPress support? ===
The updated integration supports View Content, Start Checkout, Add-to-Cart, Purchase, Add to Wishlist, Click Button, Submit Form, Complete Registration, and Subscribe.
=== Why should I install this now? ===
We recommend advertisers take advantage of the new integration ahead of the busy season to enable more opportunities for measurement, optimization, and targeting to maximize performance on TikTok.
=== Why am I not seeing TikTok in my WordPress Admin? ===
1. Navigate to WordPress > Settings > Advanced > Features.
2. Un-check the "Navigation" option and save the changes.
3. You should now see "TikTok" under the "Marketing" tab.
=== What is Advanced Matching? ===
Advanced Matching is a feature that enables businesses to send customer information to better match website and app events with people on TikTok. This allows advertisers to enhance performance through more robust measurement, optimization, and audience creation capabilities.
=== How can I create ads on TikTok? ===
You may create ads on TikTok Ads Manager or via our TikTok integration (for a lead generation or conversion campaign). For access to all other objectives (such as reach, traffic, app installs, video views, and lead generation), please use TikTok Ads Manager. See how to choose the right objective [here](https://ads.tiktok.com/help/article?aid=9616).
=== Are there any prerequisites before ads creation? ===
You must have your Ad Account in an approved state and have payment methods set up before an ad campaign can start delivery. For more details on account approval, please click [here](https://ads.tiktok.com/help/article?aid=14122).
For more details on accepted payment methods, please click [here](https://ads.tiktok.com/help/article?aid=10007023).
=== Will I be able to see all campaigns implemented via the TikTok for WordPress plugin on TikTok Ads Manager? ===
You will be able to see all campaigns created on the TikTok integration on your TikTok Ads Manager account.
=== Which product categories are allowed for advertising? ===
Click [here](https://ads.tiktok.com/help/article?aid=9550) for a detailed overview of product category restrictions in our advertising.
=== Is the TikTok Shop feature available for any merchants? ===
Both new and existing TikTok Shop sellers can seamlessly connect to TikTok Shop with the TikTok for WooCommerce integration by creating a new account or logging in with their existing TikTok Shop account.
TikTok Shop is currently available in Malaysia, the Philippines, Singapore, Thailand, the United Kingdom, the United States, and Vietnam.
=== What documentation is required to register for TikTok Shop? ===
1. **For an individual seller:** Upload an image of the front and back of your passport, national ID, or driver's license.
2. **For a corporation:** Upload an image of:
1. A government-issued identification document of the legal representative, company director, or person with significant control (PSC).
2. A business license, registration, or similar official documents evidencing your eligibility under applicable law to sell your products/services via TikTok Shop.
=== How do I cancel, manage returns, or refund orders in WooCommerce? ===
Order Cancellations, returns, and refunds can only be managed in [Seller Center.](https://seller-us-accounts.tiktok.com/) Please log into your Seller Center account to manage cancellations, returns and refunds.
=== How do I get help installing the TikTok for the WooCommerce extension? ===
Please [open a support ticket](https://woo.com/contact-us/).
== Changelog ==
2025-02-26 - version 1.3.1
* Update - Updating version
2024-12-11 - version 1.3.0
* Update - Updating catalog sync functionality
2024-10-30 - version 1.2.10
* Fix - WordPress and WooCommerce compatibility
2024-10-28 - version 1.2.9
* Fix - Email Coverage
2024-07-17 - version 1.2.8
* Fix - Order limit
2024-07-10 - version 1.2.7
* Update - CDN link
2024-06-04 - version 1.2.6
* Add - additional MAM parameters
* Add - separate pixel base code partner name for Wordpress users
* Add - page view event server side
* Add - configure button on plugin manager screen
* Fix - AJAX add to cart execution
2024-03-21 - version 1.2.5
* Fix - compatibility error with WooCommerce blocks
2024-01-16 - version 1.2.4
* Update - event tracking payload and parameters
2023-11-29 - version 1.2.3
* Fix - version bump update
* Fix - check woocommerce install on TikTok shop order list functionality
2023-11-06 - version 1.2.2
* Fix - activation and deactivation
2023-10-23 - version 1.2.1
* Fix - CDN link for splash page rendering
2023-10-13 - version 1.2.0
* Add - Event tracking for Submit Form, Contact, and Registration Events
* Add - Compatibility for general Wordpress users
2023-9-27 - version 1.1.7
* Update - Product sync improvement to only send any modifications or new products since last sync
2023-8-09 - version 1.1.6
* Update - always send server to server events for non-plugin pixels
* Fix - compatibility issue with Elementor plug-in
2023-8-02 - version 1.1.5
* Fix - TikTok shop order table formatting
2023-7-24 - version 1.1.4
* Update - migrated to consolidated events API
* Update - migrated to TBP V2 disconnect API
* Fix - type error for TikTok shop order table
2023-7-20 - version 1.1.3
* Add - enabled 3PL for TikTok Shop integration
2023-6-29 - version 1.1.2
* Add - Javascript pixel event tracking
* Add - Server to server pixel event tracking optimizations
2023-6-07 - version 1.1.1
* Add - Declare compatibility with High Performance Order Storage
2023-5-25 - version 1.1.0
* Add - Enable variable products and variations to sync to TikTok catalog
* Add - Enable pixel to support variable products and variations
2023-3-15 - version 1.0.16
* Add - WooCommerce Onboarding task asking users to connect to TikTok
* Update - Setup improvement to allow connection of existing pixels
2023-1-17 - version 1.0.15
* Fix - type conversion when outputting pixel data
2023-1-12 - version 1.0.14
* Update - enhancements to launch page content
* Fix - updates activation logic when WooCommerce is not installed
* Tweak - updates to post-setup page and backend optimizations
2022-12-8 - version 1.0.13
* Fix - Avoid fatal errors when WooCommerce is not installed
2022-11-29 - version 1.0.12
* Update - TTCLID enabled for improved pixel attribution
* Update - Support for up to 10 product images
* Tweak - Product sync improvement to support trash, untrash and deleted products
* Fix - Fix for disconnecting and uninstall logic
* Update - Support for Events API debugging
2022-11-08 - version 1.0.11
* Update - Product sync improvement for inventory and orders
* Update - Onboarding improvement to improve catalog syncing functionality
2022-10-20 - version 1.0.10
* Update - Content ID mapping for pixel and catalog
* Update - Onboarding Improvement for address entry
* Tweak - Improvement to redirect url logic for website URL changes
2022-09-29 - version 1.0.9
* Update - Overview page banner update for campaign support
* Fix - Update to Woo header value to fix paid upgrade bug
* Fix - Log version number for action scheduler product syncing
2022-09-16 - version 1.0.8
* Update - Enable scheduled product sync for better performance
* Update - Onboarding improvements for ad account setup
* Tweak - Update event tracking for launch and post-setup page
2022-08-10 - version 1.0.7
* Fix - Performance issue related to catalog syncing and signal tracking
* Tweak - Remove admin notice for file error
2022-08-03 - version 1.0.6
* Update - Admin notice for file error fix
2022-07-25 - version 1.0.5
* Fix - Disconnection on upgrade error
2022-07-18 - version 1.0.4
* Fix - Catalog syncing issues
* Tweak - Show launch page when Ad Blocker is enabled
* Tweak - Updated signal and event tracking
2022-06-29 - version 1.0.3
* Tweak - Updated signal and event tracking
2022-06-15 - version 1.0.2
* Fix - Update Pixel Event instrumentation to fire correctly
2022-05-24 - version 1.0.1
* Fix - Installation errors
2022-04-15 - version 1.0.0
* Initial release

View file

@ -0,0 +1,254 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die;
}
require_once __DIR__ . '/mapi/Tt4b_Mapi_Class.php';
require_once __DIR__ . '/logging/Logger.php';
require_once __DIR__ . '/catalog/Tt4b_Catalog_Class.php';
require_once __DIR__ . '/pixel/Tt4b_Pixel_Class.php';
require_once __DIR__ . '/admin/tts/common.php';
require_once __DIR__ . '/utils/TBPApi.php';
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
/**
* The plugin loader class
*/
class Tiktokforbusiness {
/**
* The version of TikTok for WooCommerce
*
* @var string[]
*/
private static $current_tiktok_for_woocommerce_version = '1.3.1';
/**
* Whether WooCommerce has been loaded.
*
* @var bool
*/
private static $woocommerce_loaded = false;
/**
* The TT4B instance.
*/
private static $instance = null;
/**
* The constructor.
*/
private function __construct() {
$this->initialize_hooks();
}
/**
* Initializes hooks.
*
* This should be hooked to the 'woocommerce_loaded' action.
*
* @return void
*/
public function initialize_hooks() {
include_once __DIR__ . '/admin/tts/order_list.php';
include_once __DIR__ . '/admin/tts/order_detail.php';
include_once __DIR__ . '/admin/tt4b_menu.php';
include_once __DIR__ . '/pixel/tt4b_pixel.php';
$this->init();
}
/**
* Teardown all action scheduler tasks
*
* @return void
*/
private static function unschedule_scheduled_actions() {
as_unschedule_all_actions( 'tt4b_catalog_sync' );
as_unschedule_all_actions( 'tt4b_catalog_sync_helper' );
as_unschedule_all_actions( 'tt4b_delete_products_helper' );
as_unschedule_all_actions( 'tt4b_variation_sync' );
as_unschedule_all_actions( 'tt4b_variation_sync_helper' );
as_unschedule_all_actions( 'tt4b_trust_signal_collection' );
as_unschedule_all_actions( 'tt4b_trust_signal_collection' );
}
/**
* Initialize most of the plugin logic.
*
* @return void
*/
private function init() {
if ( get_option( 'tt4b_version' ) !== self::$current_tiktok_for_woocommerce_version ) {
update_option( 'tt4b_version', self::$current_tiktok_for_woocommerce_version );
update_option( 'tt4b_last_product_sync_time', 1 );
}
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$catalog = new Tt4b_Catalog_Class( $mapi, $logger );
$mapi->init();
$catalog->init();
// Hook the onboarding task. The hook admin_init is not triggered when the WC fetches the tasks using the endpoint: wp-json/wc-admin/onboarding/tasks and hence hooking into init.
if ( did_action( 'woocommerce_loaded' ) > 0 ) {
add_action( 'init', array( $this, 'add_onboarding_task' ), 20 );
self::$woocommerce_loaded = true;
}
add_filter( 'plugin_action_links_' . plugin_basename( $this->get_plugin_file() ), array( $this, 'plugin_action_links' ) );
}
/**
* Get the plugin file name.
*/
public function get_plugin_file() {
$slug = dirname( plugin_basename( __FILE__ ) );
return trailingslashit( $slug ) . $slug . '.php';
}
/**
* Adds plugin action links.
*/
public function plugin_action_links( $actions ) {
$custom_actions = array();
// settings url(s).
$custom_actions['configure'] = $this->get_settings_link();
// add the links to the front of the actions list.
return array_merge( $custom_actions, $actions );
}
/**
* Gets the configuration link to direct to the plugin set-up.
*/
public function get_settings_link() {
$settings_url = get_admin_url() . 'admin.php?page=tiktok';
if ( $settings_url ) {
return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html__( 'Configure', 'tiktok-for-woocommerce' ) );
}
// no settings.
return '';
}
/**
* Adds the onboarding task to the Tasklists.
*
* @since x.x.x
*/
public function add_onboarding_task() {
include_once __DIR__ . '/admin/Tasks/Onboarding.php';
if ( ! class_exists( TaskLists::class ) ) {
// WC 5.9 backward compatibility.
return;
}
TaskLists::add_task(
'extended',
new Onboarding(
TaskLists::get_list( 'extended' )
)
);
}
/**
* Deactivates plugin.
*
* @return void
*/
public static function tt_plugin_deactivate() {
$external_business_id = get_option( 'tt4b_external_business_id' );
// delete scheduled TikTok-WooCommerce related actions
if ( self::$woocommerce_loaded or did_action( 'woocommerce_loaded' ) > 0 ) {
self::unschedule_scheduled_actions();
}
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$external_data = get_option( 'tt4b_external_data' );
$params = array(
'business_platform' => 'WOO_COMMERCE',
'external_business_id' => $external_business_id,
);
// call disconnect API
$mapi->tbp_post( $external_data, 'business_profile/disconnect', 'v2.0', $params, TBPApi::TBP );
// delete tiktok credentials
delete_option( 'tt4b_app_id' );
delete_option( 'tt4b_secret' );
delete_option( 'tt4b_access_token' );
delete_option( 'tt4b_external_data_key' );
delete_option( 'tt4b_user_country' );
// call tts disconnect
$mapi->tts_shop_disconnect( $external_data );
delete_option( 'tt4b_external_data' );
delete_option( 'tt4b_eligibility_page_total' );
delete_option( 'tt4b_version' );
delete_option( 'tt4b_mapi_total_gmv' );
delete_option( 'tt4b_mapi_total_orders' );
delete_option( 'tt4b_mapi_tenure' );
delete_option( 'tt4b_should_send_s2s_events' );
delete_option( 'tt4b_product_delete_queue' );
delete_option( 'tt4b_product_restore_queue' );
delete_option( 'tt4b_last_product_sync_time' );
delete_option( 'tt4b_full_catalog_sync' );
delete_option( 'tt4b_last_full_sync_time' );
}
/**
* Generates app credentials.
*
* @return void
*/
public static function tt_plugin_activate() {
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$external_business_id = get_option( 'tt4b_external_business_id' );
if ( false === $external_business_id ) {
$external_business_id = uniqid( 'tt4b_woocommerce_' );
update_option( 'tt4b_external_business_id', $external_business_id );
}
add_option( 'tt4b_eligibility_page_total', 0 );
add_option( 'tt4b_version', self::$current_tiktok_for_woocommerce_version );
add_option( 'tt4b_mapi_total_gmv', 0 );
add_option( 'tt4b_mapi_total_orders', 0 );
add_option( 'tt4b_mapi_tenure', 0 );
add_option( 'tt4b_product_delete_queue', array() );
add_option( 'tt4b_product_restore_queue', array() );
add_option( 'tt4b_last_product_sync_time', 1 );
$cleaned_redirect = preg_replace( '/[^A-Za-z0-9\-]/', '', admin_url() );
$smb_id = $external_business_id . $cleaned_redirect;
$app_rsp = $mapi->create_open_source_app( $smb_id, 'PROD', admin_url() );
if ( false !== $app_rsp ) {
$open_source_app_rsp = json_decode( $app_rsp, true );
$secret = $open_source_app_rsp['data']['app_secret'];
$app_id = $open_source_app_rsp['data']['app_id'];
$external_data_key = $open_source_app_rsp['data']['external_data_key'];
update_option( 'tt4b_app_id', $app_id );
update_option( 'tt4b_secret', $secret );
update_option( 'tt4b_external_data_key', $external_data_key );
}
}
/**
* Get the instance of the Tiktokforbusiness class.
*
* @return Tiktokforbusiness
*/
public static function tiktok_for_business_get_instance() {
static $instance = null;
if ( null === $instance ) {
$instance = new Tiktokforbusiness();
}
return $instance;
}
}

View file

@ -0,0 +1,105 @@
<?php
/**
* Setup the TikTok Onboarding Task.
*
* @package TikTok
*/
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
/**
* Onboarding Task class.
*/
class Onboarding extends Task {
/**
* Get the ID of the task.
*
* @return string
*/
public function get_id() {
return 'onboarding-tiktok';
}
/**
* Get the title for the task.
*
* @return string
*/
public function get_title() {
return esc_html__( 'Reach 1 billion users worldwide by advertising your products on TikTok', 'tiktok-for-business' );
}
/**
* Content.
*
* @return string
*/
public function get_content() {
return '';
}
/**
* Get the time required to perform the task.
*
* @return string
*/
public function get_time() {
return '';
}
/**
* Get the action URL for the task.
*
* @return string
*/
public function get_action_url() {
return admin_url( 'admin.php?page=tiktok' );
}
/**
* Check if the task is complete. The task is completed if we are able to connect to TikTok.
*
* @return bool
*/
public function is_complete() {
$is_connected = false;
$access_token = get_option( 'tt4b_access_token' );
if ( false !== $access_token ) {
$logger = new Logger( wc_get_logger() );
$mapi = new Tt4b_Mapi_Class( $logger );
$external_business_id = get_option( 'tt4b_external_business_id' );
// Get business profile information to pass into external data.
$business_profile_rsp = $mapi->get_business_profile( $access_token, $external_business_id );
$business_profile = json_decode( $business_profile_rsp, true );
if ( empty( $business_profile['data'] ) ) {
$is_connected = false;
} elseif ( ! is_null( $business_profile['data']['status'] ) && 2 !== $business_profile['data']['status'] ) {
$is_connected = false;
} else {
$is_connected = true;
}
}
return $is_connected;
}
/**
* Parent ID. This method is abstract in WooCommerce 6.1.x, 6.2.x and 6.3.x. This implementation is for backward compatibility for these versions.
* compatibility-code "WC 6.1.x, WC 6.2.x, WC 6.3.x"
*
* @return string
*/
public function get_parent_id() {
if ( is_callable( 'parent::get_parent_id' ) ) {
return parent::get_parent_id();
}
return 'extended'; // The parent task list id.
}
}

View file

@ -0,0 +1,668 @@
<?php
/**
* Copyright (c) Bytedance, Inc. and its affiliates. All Rights Reserved
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*
* @package TikTok
*/
class Tt4b_Menu_Class {
/**
* Loads the menu.
*
* @return void
*/
public static function tt4b_admin_menu() {
// if on woocommerce, load into woo marketing submenu. Else load into admin dashboard
if ( did_action( 'woocommerce_loaded' ) > 0 ) {
add_submenu_page(
'woocommerce-marketing',
'TikTok',
'TikTok',
'manage_woocommerce',
'tiktok',
array( 'Tt4b_Menu_Class', 'tt4b_admin_menu_main' ),
5
);
} else {
add_menu_page(
'TikTok',
'TikTok',
'manage_options',
'tiktok',
array( 'Tt4b_Menu_Class', 'tt4b_admin_menu_main' ),
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIGZpbGw9IiMwMDAwMDAiIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGlkPSJpY29ucyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNDEyLjE5LDExOC42NmExMDkuMjcsMTA5LjI3LDAsMCwxLTkuNDUtNS41LDEzMi44NywxMzIuODcsMCwwLDEtMjQuMjctMjAuNjJjLTE4LjEtMjAuNzEtMjQuODYtNDEuNzItMjcuMzUtNTYuNDNoLjFDMzQ5LjE0LDIzLjksMzUwLDE2LDM1MC4xMywxNkgyNjcuNjlWMzM0Ljc4YzAsNC4yOCwwLDguNTEtLjE4LDEyLjY5LDAsLjUyLS4wNSwxLS4wOCwxLjU2LDAsLjIzLDAsLjQ3LS4wNS43MSwwLC4wNiwwLC4xMiwwLC4xOGE3MCw3MCwwLDAsMS0zNS4yMiw1NS41Niw2OC44LDY4LjgsMCwwLDEtMzQuMTEsOWMtMzguNDEsMC02OS41NC0zMS4zMi02OS41NC03MHMzMS4xMy03MCw2OS41NC03MGE2OC45LDY4LjksMCwwLDEsMjEuNDEsMy4zOWwuMS04My45NGExNTMuMTQsMTUzLjE0LDAsMCwwLTExOCwzNC41MiwxNjEuNzksMTYxLjc5LDAsMCwwLTM1LjMsNDMuNTNjLTMuNDgsNi0xNi42MSwzMC4xMS0xOC4yLDY5LjI0LTEsMjIuMjEsNS42Nyw0NS4yMiw4Ljg1LDU0Ljczdi4yYzIsNS42LDkuNzUsMjQuNzEsMjIuMzgsNDAuODJBMTY3LjUzLDE2Ny41MywwLDAsMCwxMTUsNDcwLjY2di0uMmwuMi4yQzE1NS4xMSw0OTcuNzgsMTk5LjM2LDQ5NiwxOTkuMzYsNDk2YzcuNjYtLjMxLDMzLjMyLDAsNjIuNDYtMTMuODEsMzIuMzItMTUuMzEsNTAuNzItMzguMTIsNTAuNzItMzguMTJhMTU4LjQ2LDE1OC40NiwwLDAsMCwyNy42NC00NS45M2M3LjQ2LTE5LjYxLDkuOTUtNDMuMTMsOS45NS01Mi41M1YxNzYuNDljMSwuNiwxNC4zMiw5LjQxLDE0LjMyLDkuNDFzMTkuMTksMTIuMyw0OS4xMywyMC4zMWMyMS40OCw1LjcsNTAuNDIsNi45LDUwLjQyLDYuOVYxMzEuMjdDNDUzLjg2LDEzMi4zNyw0MzMuMjcsMTI5LjE3LDQxMi4xOSwxMTguNjZaIi8+PC9zdmc+',
40
);
}
add_action( 'admin_enqueue_scripts', array( 'tt4b_menu_class', 'load_styles' ) );
}
/**
* Loads the plug-in page.
*/
public static function tt4b_admin_menu_main() {
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$request_uri = '';
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
$request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
}
// business profile data, to be replaced with response from business profile endpoint.
$is_connected = false;
$business_platform = 'WOO_COMMERCE';
$external_business_id = get_option( 'tt4b_external_business_id' );
if ( false === $external_business_id ) {
$external_business_id = uniqid( 'tt4b_woocommerce_' );
update_option( 'tt4b_external_business_id', $external_business_id );
}
// to ensure non-null. To be populated with real data.
$advertiser_id = '';
$bc_id = '';
$catalog_id = '';
$pixel_code = '';
$processing = 0;
$approved = 0;
$rejected = 0;
$advanced_matching = false;
$shop_name = get_bloginfo( 'name' );
$redirect_uri = admin_url();
$app_id = get_option( 'tt4b_app_id' );
$secret = get_option( 'tt4b_secret' );
$external_data_key = get_option( 'tt4b_external_data_key' );
if ( false === $app_id || false === $secret || false === $external_data_key ) {
// create open source app.
$cleaned_redirect = preg_replace( '/[^A-Za-z0-9\-]/', '', admin_url() );
$smb_id = $external_business_id . $cleaned_redirect;
$app_rsp = $mapi->create_open_source_app( $smb_id, $business_platform, $redirect_uri );
if ( false !== $app_rsp ) {
$open_source_app_rsp = json_decode( $app_rsp, true );
$app_id = isset( $open_source_app_rsp['data']['app_id'] ) ? $open_source_app_rsp['data']['app_id'] : '';
$secret = isset( $open_source_app_rsp['data']['app_secret'] ) ? $open_source_app_rsp['data']['app_secret'] : '';
$external_data_key = isset( $open_source_app_rsp['data']['external_data_key'] ) ? $open_source_app_rsp['data']['external_data_key'] : '';
$redirect_uri = isset( $open_source_app_rsp['data']['redirect_uri'] ) ? $open_source_app_rsp['data']['redirect_uri'] : '';
update_option( 'tt4b_app_id', $app_id );
update_option( 'tt4b_secret', $secret );
update_option( 'tt4b_external_data_key', $external_data_key );
} else {
wp_die( "An error occurred generating credentials needed for the integration. Please reach out to support <a href='https://ads.tiktok.com/athena/user-feedback/form?identify_key=6a1e079024806640c5e1e695d13db80949525168a052299b4970f9c99cb5ac78&board_id=1705151646989423'>here</a>." );
}
}
$current_tiktok_for_woocommerce_version = get_option( 'tt4b_version' );
$version = '1.5';
$industry_id = '291408';
$locale = strtok( get_locale(), '_' );
$now = new DateTime();
$timestamp = (string) ( $now->getTimestamp() * 1000 );
$timezone = 'GMT+00:00';
$gmt_offset = get_option( 'gmt_offset' );
if ( $gmt_offset > 0 ) {
$timezone = 'GMT+' . $gmt_offset . ':00';
} elseif ( $gmt_offset < 0 ) {
$timezone = 'GMT' . $gmt_offset . ':00';
}
$email = get_option( 'admin_email' );
$shop_url = get_site_url();
$shop_domain = get_site_url();
$hmac_str = 'version=' . $version . '&timestamp=' . $timestamp . '&locale=' . $locale .
'&business_platform=' . $business_platform . '&external_business_id=' . $external_business_id;
$hmac = hash_hmac( 'sha256', $hmac_str, $external_data_key );
$obj = array(
'external_business_id' => $external_business_id,
'business_platform' => $business_platform,
'locale' => $locale,
'version' => $version,
'timestamp' => $timestamp,
'timezone' => $timezone,
'email' => $email,
'industry_id' => $industry_id,
'store_name' => $shop_name,
'website_url' => $shop_url,
'domain' => $shop_domain,
'app_id' => $app_id,
'redirect_uri' => $redirect_uri,
'hmac' => $hmac,
'close_method' => 'redirect_inside_tiktok',
'extra_data' => $current_tiktok_for_woocommerce_version,
);
$obj = self::get_country_and_currency_for_external_data( $obj );
$obj = self::get_eligibility_info_for_external_data( $obj );
$obj = self::get_address_info_for_external_data( $obj );
$obj = self::get_extra_data_for_external_data( $obj );
$external_data = base64_encode( json_encode( $obj, JSON_UNESCAPED_SLASHES ) );
update_option( 'tt4b_external_data', $external_data );
// log the external_data for ease of debugging.
$logger->log( __METHOD__, 'external_data: ' . $external_data );
$access_token = get_option( 'tt4b_access_token' );
if ( false !== $access_token ) {
$is_connected = true;
// get business profile information to pass into external data.
$business_profile_rsp = $mapi->get_business_profile( $access_token, $external_business_id );
$business_profile = json_decode( $business_profile_rsp, true );
// Check connection status against profile status
if ( array() === $business_profile['data'] ) {
$is_connected = false;
delete_option( 'tt4b_access_token' );
} elseif ( ! is_null( $business_profile['data']['status'] ) && 2 !== $business_profile['data']['status'] ) {
$is_connected = false;
} else {
if ( ! is_null( $business_profile['data']['adv_id'] ) ) {
$advertiser_id = $business_profile['data']['adv_id'];
update_option( 'tt4b_advertiser_id', $advertiser_id );
}
if ( ! is_null( $business_profile['data']['bc_id'] ) ) {
$bc_id = $business_profile['data']['bc_id'];
update_option( 'tt4b_bc_id', $bc_id );
}
if ( ! is_null( $business_profile['data']['pixel_code'] ) ) {
$pixel_code = $business_profile['data']['pixel_code'];
update_option( 'tt4b_pixel_code', $pixel_code );
}
if ( ! is_null( $business_profile['data'] ) && array_key_exists( 'catalog_id', $business_profile['data'] ) && ! is_null( $business_profile['data']['catalog_id'] ) ) {
$catalog_id = $business_profile['data']['catalog_id'];
update_option( 'tt4b_catalog_id', $catalog_id );
}
if ( ! is_null( $business_profile['data'] ) && array_key_exists( 'catalog_id', $business_profile['data'] ) && ! is_null( $business_profile['data']['catalog_id'] ) && array_key_exists( 'bc_id', $business_profile['data'] ) && ! is_null( $business_profile['data']['bc_id'] ) ) {
if ( did_action( 'woocommerce_loaded' ) > 0 ) {
$catalog_obj = new Tt4b_Catalog_Class( $mapi, $logger );
$logger->log( __METHOD__, 'initiate catalog sync started' );
$catalog_obj->initiate_catalog_sync( $catalog_id, $bc_id, $shop_name, $access_token );
$product_review_status = $catalog_obj->get_catalog_processing_status( $access_token, $bc_id, $catalog_id );
$processing = $product_review_status['processing'];
$approved = $product_review_status['approved'];
$rejected = $product_review_status['rejected'];
}
}
if ( is_null( $advertiser_id )
|| is_null( $pixel_code )
|| is_null( $access_token )
) {
// set advanced matching to false if the pixel cannot be found.
$advanced_matching = false;
} else {
$pixel_obj = new Tt4b_Pixel_Class();
$pixel_rsp = $pixel_obj->get_pixels(
$access_token,
$advertiser_id,
$pixel_code
);
$pixel = json_decode( $pixel_rsp, true );
if ( '' !== $pixel ) {
$connected_pixel = $pixel['data']['pixels'][0];
$advanced_matching = $connected_pixel['advanced_matching_fields']['email'];
update_option( 'tt4b_advanced_matching', $advanced_matching );
}
}
// update eligibility
$total_gmv = intval( get_option( 'tt4b_mapi_total_gmv' ) );
$total_orders = intval( get_option( 'tt4b_mapi_total_orders' ) );
$days_since_first_order = intval( get_option( 'tt4b_mapi_tenure' ) );
$mapi->update_business_profile( $access_token, $external_business_id, $total_gmv, $total_orders, $days_since_first_order, $current_tiktok_for_woocommerce_version );
}
}
// enqueue js.
echo '<div class="tt4b_wrap" id="tiktok-for-business-root"></div>';
wp_register_script( 'tt4b_cdn', 'https://sf-ttmp.ttcdn-row.com/obj/ttastatic-sg/tiktok-business-plugin/tbp_external_platform-v2.3.11.js', '', 'v1', false );
wp_register_script( 'tt4b_script', plugins_url( '/admin/js/localJs.js', dirname( __DIR__ ) . '/Tiktokforbusiness.php' ), array( 'tt4b_cdn' ), 'v1', false );
wp_enqueue_script( 'tt4b_script' );
wp_localize_script(
'tt4b_script',
'tt4b_script_vars',
array(
'is_connected' => $is_connected,
'external_business_id' => $external_business_id,
'business_platform' => $business_platform,
'base_uri' => $request_uri,
'external_data' => $external_data,
'bc_id' => $bc_id,
'adv_id' => $advertiser_id,
'store_name' => $shop_name,
'pixel_code' => $pixel_code,
'catalog_id' => $catalog_id,
'advanced_matching' => $advanced_matching,
'approved' => $approved,
'processing' => $processing,
'rejected' => $rejected,
'country' => get_option( 'tt4b_user_country' ),
)
);
}
/**
* Populates eligibility for woocommerce merchants.
*/
public static function get_eligibility_info_for_external_data( $external_data ) {
// pull eligibility
// pull eligibility metrics for tt shopping.
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return $external_data;
}
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$mapi->fetch_eligibility();
$total_gmv = intval( get_option( 'tt4b_mapi_total_gmv' ) );
$total_orders = intval( get_option( 'tt4b_mapi_total_orders' ) );
$days_since_first_order = intval( get_option( 'tt4b_mapi_tenure' ) );
$net_gmv = array(
array(
'interval' => 'LIFETIME',
'min' => $total_gmv,
'max' => $total_gmv,
'unit' => 'CURRENCY',
),
);
$net_order_count = array(
array(
'interval' => 'LIFETIME',
'min' => $total_orders,
'max' => $total_orders,
'unit' => 'COUNT',
),
);
$tenure = array(
'min' => $days_since_first_order,
'unit' => 'DAYS',
);
$external_data['is_email_verified'] = true;
$external_data['is_verified'] = true;
$external_data['net_gmv'] = $net_gmv;
$external_data['net_order_count'] = $net_order_count;
$external_data['tenure'] = $tenure;
return $external_data;
}
/**
* Populates the extra data for external data.
*/
public static function get_extra_data_for_external_data( $external_data ) {
$current_tiktok_for_woocommerce_version = get_option( 'tt4b_version' );
$extra_data = array(
'version' => $current_tiktok_for_woocommerce_version,
);
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
$extra_data['plugin_type'] = 'LEAD_GEN';
}
$external_data['extra_data'] = json_encode( $extra_data );
return $external_data;
}
/**
* Populates address info for woocommerce merchants.
*/
public static function get_address_info_for_external_data( $external_data ) {
if ( did_action( 'woocommerce_loaded' ) > 0 ) {
$store_address = get_option( 'woocommerce_store_address' );
$store_address_2 = get_option( 'woocommerce_store_address_2' );
$store_city = get_option( 'woocommerce_store_city' );
$store_postcode = get_option( 'woocommerce_store_postcode' );
// country and state separated.
$store_raw_country = get_option( 'woocommerce_default_country' );
$split_country = explode( ':', $store_raw_country );
$store_state = '';
if ( count( $split_country ) > 1 ) {
$store_state = $split_country[1];
$menu_obj = new Tt4b_Menu_Class();
$store_state = $menu_obj->convert_state( $store_state );
}
$external_data['address_1'] = $store_address;
$external_data['address_2'] = $store_address_2;
$external_data['city'] = $store_city;
$external_data['state'] = $store_state;
$external_data['zip_code'] = $store_postcode;
}
return $external_data;
}
/**
* Populates currency and country_iso for woocommerce merchants.
*/
public static function get_country_and_currency_for_external_data( $external_data ) {
if ( did_action( 'woocommerce_loaded' ) > 0 ) {
$external_data['currency'] = get_woocommerce_currency();
$external_data['country_region'] = WC()->countries->get_base_country();
update_option( 'tt4b_user_country', WC()->countries->get_base_country() );
return $external_data;
}
$country_region = self::get_user_country();
if ( '' !== $country_region ) {
$external_data['country_region'] = $country_region;
}
update_option( 'tt4b_user_country', $country_region );
return $external_data;
}
/**
* Gets the user country.
*
* @return string
*/
private static function get_user_country() {
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$resp = $mapi->get_user_location();
$decoded_resp = json_decode( $resp, true );
if ( ! is_null( $decoded_resp['data'] && ! is_null( $decoded_resp['data']['country_code'] ) ) ) {
return $decoded_resp['data']['country_code'];
}
return '';
}
/**
* Loads content from TikTok CDN into the page head.
*
* @param $hook_suffix string The hook used
*
* @return void
*/
public static function load_styles( $hook_suffix = '' ) {
if ( 'marketing_page_tiktok' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'tt4b_localCss', plugins_url( '/admin/css/main.css', dirname( __DIR__ ) . '/tiktok-for-woocommerce.php' ), '', 'v1' );
}
/**
* Stores the mapi issued access token.
*
* @return void
*/
public static function tt4b_store_access_token() {
$logger = new Logger();
$mapi = new Tt4b_Mapi_Class( $logger );
$url = '';
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
$url = esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) . wp_unslash( $_SERVER['REQUEST_URI'] ) );
}
$auth_code = '';
$split_url = explode( '&', $url );
$split_url_params = count( $split_url );
for ( $i = 0; $i < $split_url_params; $i++ ) {
if ( false !== strpos( $split_url[ $i ], 'auth_code' ) ) {
$auth_code = substr( $split_url[ $i ], strpos( $split_url[ $i ], '=' ) + 1 );
$logger->log( __METHOD__, "auth_code retrieved: $auth_code" );
}
}
if ( '' !== $auth_code ) {
$app_id = get_option( 'tt4b_app_id' );
$secret = get_option( 'tt4b_secret' );
$access_token_rsp = $mapi->get_access_token( $app_id, $secret, $auth_code, 'v1.2' );
$results = json_decode( $access_token_rsp, true );
if ( 'OK' === $results['message'] ) {
// status OK.
$access_token = $results['data']['access_token'];
update_option( 'tt4b_access_token', $access_token );
wp_safe_redirect( get_admin_url() . 'admin.php?page=tiktok' );
}
}
}
/**
* Converts state abbreviation to full state name.
*
* @param string $name The state abbreviation or name
*
* @return string
*/
public static function convert_state( $name ) {
$states = array(
array(
'name' => 'Alabama',
'abbr' => 'AL',
),
array(
'name' => 'Alaska',
'abbr' => 'AK',
),
array(
'name' => 'Arizona',
'abbr' => 'AZ',
),
array(
'name' => 'Arkansas',
'abbr' => 'AR',
),
array(
'name' => 'California',
'abbr' => 'CA',
),
array(
'name' => 'Colorado',
'abbr' => 'CO',
),
array(
'name' => 'Connecticut',
'abbr' => 'CT',
),
array(
'name' => 'District of Columbia',
'abbr' => 'DC',
),
array(
'name' => 'Delaware',
'abbr' => 'DE',
),
array(
'name' => 'Florida',
'abbr' => 'FL',
),
array(
'name' => 'Georgia',
'abbr' => 'GA',
),
array(
'name' => 'Hawaii',
'abbr' => 'HI',
),
array(
'name' => 'Idaho',
'abbr' => 'ID',
),
array(
'name' => 'Illinois',
'abbr' => 'IL',
),
array(
'name' => 'Indiana',
'abbr' => 'IN',
),
array(
'name' => 'Iowa',
'abbr' => 'IA',
),
array(
'name' => 'Kansas',
'abbr' => 'KS',
),
array(
'name' => 'Kentucky',
'abbr' => 'KY',
),
array(
'name' => 'Louisiana',
'abbr' => 'LA',
),
array(
'name' => 'Maine',
'abbr' => 'ME',
),
array(
'name' => 'Maryland',
'abbr' => 'MD',
),
array(
'name' => 'Massachusetts',
'abbr' => 'MA',
),
array(
'name' => 'Michigan',
'abbr' => 'MI',
),
array(
'name' => 'Minnesota',
'abbr' => 'MN',
),
array(
'name' => 'Mississippi',
'abbr' => 'MS',
),
array(
'name' => 'Missouri',
'abbr' => 'MO',
),
array(
'name' => 'Montana',
'abbr' => 'MT',
),
array(
'name' => 'Nebraska',
'abbr' => 'NE',
),
array(
'name' => 'Nevada',
'abbr' => 'NV',
),
array(
'name' => 'New Hampshire',
'abbr' => 'NH',
),
array(
'name' => 'New Jersey',
'abbr' => 'NJ',
),
array(
'name' => 'New Mexico',
'abbr' => 'NM',
),
array(
'name' => 'New York',
'abbr' => 'NY',
),
array(
'name' => 'North Carolina',
'abbr' => 'NC',
),
array(
'name' => 'North Dakota',
'abbr' => 'ND',
),
array(
'name' => 'Ohio',
'abbr' => 'OH',
),
array(
'name' => 'Oklahoma',
'abbr' => 'OK',
),
array(
'name' => 'Oregon',
'abbr' => 'OR',
),
array(
'name' => 'Pennsylvania',
'abbr' => 'PA',
),
array(
'name' => 'Rhode Island',
'abbr' => 'RI',
),
array(
'name' => 'South Carolina',
'abbr' => 'SC',
),
array(
'name' => 'South Dakota',
'abbr' => 'SD',
),
array(
'name' => 'Tennessee',
'abbr' => 'TN',
),
array(
'name' => 'Texas',
'abbr' => 'TX',
),
array(
'name' => 'Utah',
'abbr' => 'UT',
),
array(
'name' => 'Vermont',
'abbr' => 'VT',
),
array(
'name' => 'Virginia',
'abbr' => 'VA',
),
array(
'name' => 'Washington',
'abbr' => 'WA',
),
array(
'name' => 'West Virginia',
'abbr' => 'WV',
),
array(
'name' => 'Wisconsin',
'abbr' => 'WI',
),
array(
'name' => 'Wyoming',
'abbr' => 'WY',
),
array(
'name' => 'Virgin Islands',
'abbr' => 'V.I.',
),
array(
'name' => 'Guam',
'abbr' => 'GU',
),
array(
'name' => 'Puerto Rico',
'abbr' => 'PR',
),
);
$return = '';
$str_len = strlen( $name );
foreach ( $states as $state ) :
if ( $str_len < 2 ) {
return '';
} elseif ( 2 === $str_len ) {
if ( strtolower( $state['abbr'] ) === strtolower( $name ) ) {
$return = $state['name'];
break;
}
} elseif ( strtolower( $state['name'] ) === strtolower( $name ) ) {
$return = strtoupper( $state['abbr'] );
break;
}
endforeach;
return $return;
}
}

View file

@ -0,0 +1,3 @@
.tt4b_wrap {
height: calc(100vh);
}

View file

@ -0,0 +1,3 @@
.tts-order-table-container {
overflow-x: scroll;
}

View file

@ -0,0 +1,280 @@
jQuery(
function ( $ ) {
$( document.body ).on(
'added_to_cart',
function ( e, fragments, cart_hash, thisbutton ) {
// var pixel_code = window.tt4b_script_vars.pixel_code;
// var currency = window.tt4b_script_vars.currency;
// var product_id = thisbutton.data('product_id');
// var product_name = thisbutton.data('product_name');
// var price = thisbutton.data('price');
//
// ttq.instance(pixel_code).track(
// 'AddToCart',
// {
// 'content_id': product_id,
// 'content_name': product_name,
// 'content_type': 'product',
// 'price': price,
// 'value': price,
// 'quantity': 1,
// 'currency': currency
// }
// );
}
);
// add library to help parse phone numbers
let script = document.createElement( 'script' );
script.src = 'https://unpkg.com/libphonenumber-js@1.10.45/bundle/libphonenumber-min.js';
document.head.appendChild( script );
// add library to generate uuid4 for event api
let uuidScript = document.createElement( 'script' );
uuidScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js';
document.head.appendChild( uuidScript );
// advanced matching - will send hashed advanced_matching fields if true, otherwise will exit if advanced_matching value is false or null
function getEmailAndPhone(inputElement, pixelCode, source) {
if (window.tt4b_script_vars.advanced_matching !== '1') {
return;
}
let result = {
email: "",
phone_number: ""
};
if ( ! inputElement) {
return result
}
let form = inputElement.closest( 'form' ) || inputElement.querySelector( 'form' );
if (( ! form || form.length === 0) && source !== 'ninjaforms') {
return;
} else if (( ! form || form.length === 0) && source === 'ninjaforms') {
form = inputElement.first( 'form' )[0];
}
let inputElements = form.querySelectorAll( 'input' );
for (let input of inputElements) {
if (input.type === 'email') {
result.email = input.value;
} else if (input.type === 'tel') {
try {
let phone_number = input.value;
result.phone_number = libphonenumber.parsePhoneNumber( phone_number, window.tt4b_script_vars.country ).number
} catch (error) {
console.warn( "Error occurred while parsing phone number: ", error );
}
}
}
ttq.instance( pixelCode ).identify( result );
}
// Fires a Contact event if AM data present in form, otherwise fires a SubmitForm vent
function firePixelBasedOnFormIntent(inputElement, pixelCode, source) {
let form = inputElement.closest( 'form' ) || inputElement.querySelector( 'form' );
if (( ! form || form.length === 0) && source !== 'ninjaforms') {
return;
} else if (( ! form || form.length === 0) && source === 'ninjaforms') {
form = inputElement.first( 'form' )[0];
}
let inputElements = form.querySelectorAll( 'input' );
let hasAMData = false;
for (let input of inputElements) {
if (input.type === 'email' || input.type === 'tel') {
hasAMData = true;
break;
}
}
let eventType = hasAMData ? 'Contact' : 'SubmitForm'
let event_id = ""
try {
event_id = uuidv4()
} catch (error) {
console.warn( "Error occurred while generating uuidv4: ", error );
}
ttq.instance( pixelCode ).track(
eventType,
{
'source' : source,
'wp_plugin' : source,
"event_id" : event_id
}
)
}
// Some forms will trigger the submit event, even if the form submission is unsuccessful
// In this case we want to make sure the form submission is successful by checking for the success message
// once the message is visible, we will fire the pixel event
function createObserver(source) {
return new MutationObserver(
function (mutations) {
mutations.forEach(
function (mutation) {
if (window.getComputedStyle( mutation.target ).display !== 'none') {
getEmailAndPhone( mutation.target, window.tt4b_script_vars.pixel_code );
firePixelBasedOnFormIntent( mutation.target, window.tt4b_script_vars.pixel_code, source )
}
}
);
}
);
}
// fallback case
document.addEventListener(
'submit',
function (event) {
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "fallback" )
}
);
// ButtonClick Lead Gen Event
$( 'button, :submit' ).on(
'click',
function (event) {
var pixel_code = window.tt4b_script_vars.pixel_code;
// AM based on form inputs when submit clicked
getEmailAndPhone( event.target, pixel_code );
let event_id = ""
try {
event_id = uuidv4()
} catch (error) {
console.warn( "Error occurred while generating uuidv4: ", error );
}
ttq.instance( pixel_code ).track(
'ClickButton',
{
'content': 'SubmitClick',
"event_id": event_id
}
);
}
);
// Contact Lead Gen Event: Contact Form 7
// https://wordpress.org/plugins/contact-form-7/
document.addEventListener(
'wpcf7mailsent',
function (event) {
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "contactform7" )
},
false
);
// Contact Lead Gen Event: MC4WP: Mailchimp for Wordpress
// https://wordpress.org/plugins/mailchimp-for-wp/
var mailchimp_forms = document.querySelectorAll( '.mc4wp-form' );
mailchimp_forms.forEach(
function (form) {
var pixel_code = window.tt4b_script_vars.pixel_code;
form.addEventListener(
'submit',
function (event) {
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "mailchimp4wordpress" )
}
);
}
);
// Contact Lead Gen Event: Jetpack + Mailchimp
// https://jetpack.com/support/jetpack-blocks/mailchimp-block/
var jetpackMailchimpNodes = document.querySelectorAll( '.wp-block-jetpack-mailchimp_success' );
if (jetpackMailchimpNodes.length > 0) {
var jetpackMailchimpObserver = createObserver( 'jetpackmailchimp' );
jetpackMailchimpNodes.forEach(
function (targetNode) {
jetpackMailchimpObserver.observe( targetNode, { attributes: true, childList: true, subtree: true } );
}
);
}
// Contact Lead Get Event: MailPoet
// https://wordpress.org/plugins/mailpoet/
$( 'input.mailpoet_submit' ).on(
'click',
function () {
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "mailpoet" )
}
);
// Contact Lead Gen Event: Spectra
// https://wordpress.org/plugins/ultimate-addons-for-gutenberg/
var spectraForms = document.querySelectorAll( '.uagb-forms-main-form' );
spectraForms.forEach(
function (form) {
var pixel_code = window.tt4b_script_vars.pixel_code;
form.addEventListener(
'submit',
function (event) {
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "spectra" )
}
);
}
);
// Submit Form Lead Gen Event: WPForms
// https://wordpress.org/plugins/wpforms-lite/
$( 'form.wpforms-form' ).on(
'wpformsAjaxSubmitSuccess',
(event) => {
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "wpforms" )
}
)
// Submit Form Lead Gen Events: JetPack
// https://wordpress.org/plugins/jetpack/
if (document.querySelector( '[class*=jetpack-contact-form]' )) {
document.addEventListener(
'submit',
(event) => {
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( event.target, pixel_code );
firePixelBasedOnFormIntent( event.target, pixel_code, "jetpack" )
}
);
}
// Submit Form Lead Gen Events: Ninja Forms
// https://wordpress.org/plugins/ninja-forms/
$( document ).on(
'nfFormSubmitResponse',
(event) => {
event.preventDefault();
var pixel_code = window.tt4b_script_vars.pixel_code;
getEmailAndPhone( $( '.nf-form-layout' ), pixel_code, "ninjaforms" );
firePixelBasedOnFormIntent( $( '.nf-form-layout' ), pixel_code, "ninjaforms" )
}
);
$( document ).on(
'nfFormReady',
(event) => {
event.preventDefault();
$( 'button, :submit, input[type="submit"]' ).on(
'click',
function (event) {
var pixel_code = window.tt4b_script_vars.pixel_code;
// AM based on form inputs when submit clicked
getEmailAndPhone( event.target, pixel_code );
ttq.instance( pixel_code ).track(
'ClickButton',
{
'content': 'SubmitClick'
}
);
}
);
}
)
}
);

View file

@ -0,0 +1,60 @@
async function checkConnectionStatus()
{
return {
isConnected: window.tt4b_script_vars.is_connected,// when accessToken exists
externalData: {
business_platform: window.tt4b_script_vars.business_platform,
external_business_id: window.tt4b_script_vars.external_business_id
},
};
}
async function loadProfile()
{
return {
bcId: window.tt4b_script_vars.bc_id,
businessPlatform: 'WOO_COMMERCE',
bc: {
id: window.tt4b_script_vars.bc_id,
name: ""
},
advId: window.tt4b_script_vars.adv_id,
advertiser: {
id: window.tt4b_script_vars.adv_id,
name: window.tt4b_script_vars.store_name
},
pixelCode: window.tt4b_script_vars.pixel_code,
pixel: {
pixelCode: window.tt4b_script_vars.pixel_code,
pixelName: "",
// advancedMatching is true if both fields below are true and vice versa,
// partial true/false cases should be deemed as dirty data.
advancedMatchingFields: {
email: window.tt4b_script_vars.advanced_matching,
phoneNumber: window.tt4b_script_vars.advanced_matching,
},
},
catalogId: window.tt4b_script_vars.catalog_id,
};
}
async function loadCatalog()
{
return {
approved: window.tt4b_script_vars.approved,
processing: window.tt4b_script_vars.processing,
rejected: window.tt4b_script_vars.rejected,
}
}
window.external_data = window.tt4b_script_vars.external_data;
tbp.render(
{
baseName: window.tt4b_script_vars.base_uri,
checkConnectionStatus,
loadProfile,
loadCatalog,
},
'tiktok-for-business-root'
);

View file

@ -0,0 +1,22 @@
window.onload = () => {
function addWrapWithOrderTable() {
var container = document.querySelector( '#posts-filter' );
var containerWidth = container.clientWidth;
var ttsOrderTable = container.querySelector( '.tts-order-table-container' );
var first = ! ttsOrderTable;
if (first) {
var table = container.querySelector( 'table' );
var div = document.createElement( 'div' );
div.classList.add( 'tts-order-table-container' );
container.insertBefore( div, table );
div.appendChild( table );
div.style.width = containerWidth + 'px';
} else {
ttsOrderTable.style.width = containerWidth + 'px';
}
}
addWrapWithOrderTable();
window.addEventListener( 'resize', addWrapWithOrderTable );
}

View file

@ -0,0 +1,176 @@
<?php
/**
* Copyright (c) Bytedance, Inc. and its affiliates. All Rights Reserved
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*
* @package TikTok
*/
require_once __DIR__ . '/../utils/utilities.php';
require_once 'Tt4b_Menu_Class.php';
add_action( 'admin_menu', array( 'tt4b_menu_class', 'tt4b_admin_menu' ) );
add_action( 'wp_loaded', array( 'tt4b_menu_class', 'tt4b_store_access_token' ) );
add_action( 'before_delete_post', 'tt4b_product_delete', 10, 2 );
add_action( 'wp_trash_post', 'tt4b_product_trashed' );
add_action( 'woocommerce_before_delete_product_variation', 'tt4b_variation_delete' );
add_action( 'untrashed_post', 'tt4b_product_untrashed' );
/**
* Trash a product
*
* @param string $post_id The product_id.
*
* @return void
*/
function tt4b_product_trashed( $post_id ) {
$post = get_post( $post_id );
tt4b_product_delete( $post_id, $post );
}
/**
* Delete or trash a product variation
*
* @param string $post_id The product/variation id to be deleted.
*
* @return void
*/
function tt4b_variation_delete( $post_id ) {
$post = get_post( $post_id );
tt4b_product_delete( $post_id, $post );
}
/**
* Add restore products back to MAPI via upload API vs update
* TODO: Use this during catalog and variation syncing for MAPI - move parent + children over from update to upload
*
* @param $post_id - The product/variation to be restored
*
* @return void
*/
function tt4b_product_untrashed( $post_id ) {
$post = get_post( $post_id );
if ( 'product' !== $post->post_type && 'product_variation' !== $post->post_type ) {
return;
}
$product = wc_get_product( $post_id );
if ( is_null( $product ) ) {
return;
}
$logger = new Logger();
$access_token = get_option( 'tt4b_access_token' );
$catalog_id = get_option( 'tt4b_catalog_id' );
$bc_id = get_option( 'tt4b_bc_id' );
if ( false === $access_token ) {
$logger->log( __METHOD__, 'missing access token for tt4b_product_sync' );
return;
}
if ( '' === $catalog_id ) {
$logger->log( __METHOD__, 'missing catalog_id for tt4b_product_sync' );
return;
}
if ( '' === $bc_id ) {
$logger->log( __METHOD__, 'missing bc_id for tt4b_product_sync' );
return;
}
$product_id = $product->get_id();
$to_restore = (array) get_option( 'tt4b_product_restore_queue', array() );
$to_restore[ $product_id ] = $product_id;
$logger->log( __METHOD__, json_encode( $to_restore ) . ' to restore' );
update_option( 'tt4b_product_restore_queue', $to_restore );
}
/**
* Delete a product or product_variation
*
* @param string $post_id The product_id.
* @param WP_Post $post The post.
*
* @return void
*/
function tt4b_product_delete( $post_id, $post ) {
if ( 'product' !== $post->post_type && 'product_variation' !== $post->post_type ) {
return;
}
$product = wc_get_product( $post_id );
if ( is_null( $product ) ) {
return;
}
$logger = new Logger();
$access_token = get_option( 'tt4b_access_token' );
$catalog_id = get_option( 'tt4b_catalog_id' );
$bc_id = get_option( 'tt4b_bc_id' );
if ( false === $access_token ) {
$logger->log( __METHOD__, 'missing access token for tt4b_product_sync' );
return;
}
if ( '' === $catalog_id ) {
$logger->log( __METHOD__, 'missing catalog_id for tt4b_product_sync' );
return;
}
if ( '' === $bc_id ) {
$logger->log( __METHOD__, 'missing bc_id for tt4b_product_sync' );
return;
}
$sku_id = $product->get_sku();
$id = (string) $product->get_id();
$sku_key = $sku_id;
if ( '' === $sku_key ) {
$sku_key = $id;
}
$product_to_delete = array(
'id' => $id,
'data' => json_encode(
array(
'id' => $id,
'sku' => $sku_id,
)
),
'topic' => 'partner_gw_product_sync',
'tag' => 'delete',
);
// if it's a child product, delete the child product only
if ( $product->get_parent_id() > 0 ) {
$parent_id = $product->get_parent_id();
$product_to_delete = array(
'id' => $id,
'data' => json_encode(
array(
'id' => $id,
'sku' => $sku_id,
'parent_id' => (string) $parent_id,
)
),
'parent_id' => (string) $parent_id,
'topic' => 'partner_gw_product_variation_sync',
'tag' => 'delete',
);
$parent_product = wc_get_product( $parent_id );
$parent_sku = $parent_product->get_sku() ? $parent_product->get_sku() : (string) $parent_product->get_id();
// if the child product sku is the same as the parent product, make sure to use the same concatenation logic as in catalog sync
// otherwise use the unique child product sku for deletion
$sku_key = variation_content_id_helper( Method::DELETE, $parent_sku, $sku_id, $id );
}
// add the sku to array of skus to be deleted - stored as an option to be processed during scheduled syncs & management page syncs
$addToDelete = array(
$sku_key => $product_to_delete,
);
$logger->log(
__METHOD__,
sprintf(
'adding SKU_ID to delete: %s',
$sku_id
)
);
$toDelete = (array) get_option( 'tt4b_product_delete_queue', array() );
$toDelete = array_merge( $addToDelete, $toDelete );
update_option( 'tt4b_product_delete_queue', $toDelete );
}

View file

@ -0,0 +1,102 @@
<?php
/**
* TikTok common code
* such as const, util function
*/
namespace tiktok\admin\tts\common;
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**
* Inserts a new key/value after the key in the array.
*
* If the $needle doesn't exist in the array, the new key and value wil be
* appended to the end of the $haystack array.
*
* @param string $needle The array key to insert the element after
* @param array $haystack An array to insert the element into
* @param string $new_key The key to insert
* @param mixed $new_value An value to insert
*
* @return array The new array.
*/
function array_insert_after( $needle, $haystack, $new_key, $new_value ) {
// If the needle doesn't exist, just append to the end of the array.
if ( ! array_key_exists( $needle, $haystack ) ) {
$haystack[ $new_key ] = $new_value;
return $haystack;
}
$new_array = array();
foreach ( $haystack as $key => $value ) {
$new_array[ $key ] = $value;
if ( $key === $needle ) {
$new_array[ $new_key ] = $new_value;
}
}
return $new_array;
}
/**
* Helper to create links to edit.php with params.
*
* @since 4.4.0
*
* @param string[] $args Associative array of URL parameters for the link.
* @param string $link_text Link text.
* @param string $css_class Optional. Class attribute. Default empty string.
* @return string The formatted link string.
*
* located in wordpress/wp-admin/includes/class-wp-posts-list-talbe.php
*/
function get_edit_link( $args, $link_text, $css_class = '' ) {
$url = add_query_arg( $args, 'edit.php' );
$class_html = '';
$aria_current = '';
if ( ! empty( $css_class ) ) {
$class_html = sprintf(
' class="%s"',
esc_attr( $css_class )
);
if ( 'current' === $css_class ) {
$aria_current = ' aria-current="page"';
}
}
return sprintf(
'<a href="%s"%s%s>%s</a>',
esc_url( $url ),
$class_html,
$aria_current,
$link_text
);
}
/**
* The origin of Tiktok Seller Center in different countries are different
* We need to set the origin according to the country
*/
function get_tts_seller_center_origin() {
$country_origin_map = array(
'GB' => 'uk',
'US' => 'us',
'ID' => 'id',
'TH' => 'th',
'MY' => 'my',
'VN' => 'vn',
'PH' => 'ph',
);
$country = WC()->countries->get_base_country();
return "https://seller-{$country_origin_map[$country]}.tiktok.com";
}

View file

@ -0,0 +1,33 @@
<?php
/**
* Entry of tts code
*/
namespace tiktok\admin\tts\index;
add_action(
'plugins_loaded',
function () {
// check if woocommerce has installed
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
// pretty permalink to allow woocommerce rest api
if ( ! get_option( 'permalink_structure' ) ) {
add_action(
'admin_enqueue_scripts',
function () {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
}
);
}
}
);

View file

@ -0,0 +1,193 @@
<?php
namespace tiktok\admin\tts\order_detail;
use function tiktok\admin\tts\common\get_tts_seller_center_origin;
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**
* The order detail class
*/
class OrderDetail {
/**
* The current order
*
* @var $order
*/
private static $order = null;
/**
* The constructor
*/
public static function init() {
// check for woo install
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
self::disable_edit();
self::notice();
self::hide_tiktok_custom_fields();
}
/**
* Checks whether it is a tiktok order
*/
private static function is_tiktok_order_detail_page() {
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
global $post, $action;
/**
* Some plugin like Jetpack will cause use is_tiktok_order_detail_page() before get_current_screen is defined
*
* So we directly return false in this case
*/
if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}
$screen = get_current_screen();
if ( is_null( $screen ) ) {
return false;
}
// not order detail page
if ( 'shop_order' !== $screen->id
|| 'shop_order' !== $screen->post_type
|| 'edit' !== $action
) {
return false;
}
if ( ! self::$order ) {
self::$order = wc_get_order( $post->ID );
}
// whether tiktok order
return self::$order->get_meta( 'tiktok_order' );
}
/**
* Disables edits on tiktok orders (they should be managed on seller center)
*/
private static function disable_edit() {
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
// make the postbox container interface unclickable
add_action(
'admin_enqueue_scripts',
function () {
if ( ! self::is_tiktok_order_detail_page() ) {
return;
}
?>
<style>
.postbox-container {
pointer-events: none;
}
#poststuff {
cursor: not-allowed;
}
.postbox-container #woocommerce-shipment-tracking {
pointer-events: initial;
cursor: initial;
}
.postbox-container [id*='shipment-tracking'] {
pointer-events: initial;
cursor: initial;
}
.postbox-container [class*='shipment-tracking'] {
pointer-events: initial;
cursor: initial;
}
</style>
<?php
}
);
// prevents an order from being updated if it is a TikTok order
add_action(
'woocommerce_before_order_object_save',
function ( $order ) {
// If the order doesn't yet have an ID, it is new and saving is always allowed.
if ( ! $order->get_id() ) {
return;
}
// Bail early if this isn't a TikTok order.
if ( ! $order->get_meta( 'tiktok_order' ) ) {
return;
}
// Allow for tiktok orders created by API to go through
if ( $order->get_created_via() === 'rest-api' ) {
return;
}
throw new \Exception( esc_html__( 'TikTok orders cannot be modified via the normal interface. Modify on TikTok.' ) );
}
);
}
/**
* Delivers notice that tiktok orders are managed on seller center
*/
private static function notice() {
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
add_action(
'admin_notices',
function () {
if ( ! self::is_tiktok_order_detail_page() ) {
return;
}
?>
<div class="notice notice-warning">
<p>
<?php echo esc_html__( 'Orders generated from TikTok Shop can only be managed through' ); ?>
<a target="_blank" href="<?php echo esc_url( get_tts_seller_center_origin() . '/order/detail?order_no=' . self::$order->get_meta( 'tiktok_order_id' ) ); ?>"><?php echo esc_html__( 'TikTok Seller Center' ); ?></a>
</p>
</div>
<?php
}
);
}
/**
* Because tiktok_order_update meta includes timestamp placeholder
* so we need to hide custom fields by tiktok
* located in wordpress/wp-admin/includes/meta-boxes.php post_custom_meta_box function
*/
private static function hide_tiktok_custom_fields() {
if ( ! did_action( 'woocommerce_loaded' ) > 0 ) {
return;
}
add_filter(
'is_protected_meta',
function ( $protected, $meta_key, $meta_type ) {
if ( ! self::is_tiktok_order_detail_page() || 'post' !== $meta_type || 0 !== strpos( $meta_key, 'tiktok_' ) ) {
return $protected;
}
return true;
},
10,
3
);
}
}
OrderDetail::init();

View file

@ -0,0 +1,261 @@
<?php
namespace tiktok\admin\tts\order_list;
use function tiktok\admin\tts\common\array_insert_after;
use function tiktok\admin\tts\common\get_edit_link;
use function tiktok\admin\tts\common\get_tts_seller_center_origin;
/**
* The order list class
*/
class OrderList {
/**
* The constructor
*/
public static function init() {
// check for woo install
self::modify_table();
// self::add_tiktok_filter();
self::load_style_and_script();
}
public static function load_style_and_script() {
add_action(
'admin_enqueue_scripts',
function ( $hook ) {
if ( 'edit.php' != $hook ) {
return;
}
wp_enqueue_style(
'tts_order_css',
plugins_url( '/css/order.css', dirname( __DIR__ ) . '/tiktok-for-woocommerce.php' ),
'',
'v1'
);
wp_enqueue_script(
'tts_order_js',
plugins_url( '/js/order.js', dirname( __DIR__ ) . '/tiktok-for-woocommerce.php' ),
'',
'v1'
);
}
);
}
/**
* Add Channel adn Update columns
* hook located in wordpress/wp-admin/includes/screen.php get_column_headers function
*/
private static function modify_table() {
add_filter(
'manage_edit-shop_order_columns',
function ( $columns ) {
$new_columns = array_insert_after(
'order_number',
$columns,
'order_channel',
esc_html__( 'Channel' )
);
$new_columns = array_insert_after(
'order_status',
$new_columns,
'order_update',
esc_html__( 'Update' )
);
return $new_columns;
}
);
/**
* Default show all columns in order list page
* hook located in wordpress/wp-admin/includes/screen.php get_hidden_columns function
* set priority greater than woocommerce filter
*/
add_filter(
'default_hidden_columns',
function ( $hidden, $screen ) {
return 'edit-shop_order' === $screen->id ? array() : $hidden;
},
10000,
2
);
/**
* Tiktok order remove action button
* hook located in woocommerce/src/Internal/Admin/Orders/ListTable.php column_wc_actions method
*/
add_filter(
'woocommerce_admin_order_actions',
function ( $actions, $order ) {
return $order->get_meta( 'tiktok_order' ) ? array() : $actions;
},
10,
2
);
/**
* Set the contents for each row of the custom columns
* hook located in wordpress/wp-admin/includes/class-wp-posts-list-table.php column_default method
*/
add_action(
'manage_shop_order_posts_custom_column',
function ( $column ) {
$tts_awaiting_shipment = '111';
$pl_3 = '0';
$pl_4 = '1';
// wc_get_order() defaults to the global $post object, so we don't need to pass a parameter.
global $post;
$order = wc_get_order( $post->ID );
$is_tiktok_order = (bool) $order->get_meta( 'tiktok_order' );
$tiktok_order_id = $order->get_meta( 'tiktok_order_id' );
$tiktok_fulfillment_type = $order->get_meta( 'tiktok_fulfillment_type' );
$is_tiktok_fulfillment_3pl = $tiktok_fulfillment_type === $pl_3;
// $is_tiktok_fulfillment_4pl || ! = $tiktok_fulfillment_type === $pl_4;
$is_highlight_button = $order->get_meta( 'tiktok_order_status' ) === $tts_awaiting_shipment;
/**
* Debug start
*/
// $order_data = $order->get_data();
// $order_id = $order_data['id'];
// $order_status = $order_data['status'];
// if ( 'wc_actions' === $column ) {
// printf('<p>test add button</p>'.$tiktok_order_id.'xxx'.$post->ID);
// printf('<p>tiktok_fulfillment_type</p>'.$order->get_meta( 'tiktok_fulfillment_type' ));
// printf('<p>tiktok_order</p>'.$order->get_meta( 'tiktok_order' ));
// printf('<p>tiktok_order_status</p>'.$order->get_meta( 'tiktok_order_status' ));
// }
/**
* Debug end
*/
if ( 'order_channel' === $column ) {
echo esc_html__( $is_tiktok_order ? 'TikTok' : '-' );
return;
}
if ( 'order_update' === $column ) {
// split text by timestamp
$texts = preg_split(
'/{(\d+)}/',
$is_tiktok_order && $order->get_meta( 'tiktok_order_update' ) ? $order->get_meta( 'tiktok_order_update' ) : '',
-1,
PREG_SPLIT_DELIM_CAPTURE
);
foreach ( $texts as $key => $value ) {
if ( preg_match( '/^\d+$/', $value ) ) {
// need to replace utc timestamp with the time in the corresponding time zone
echo '<span style="color:red">' . esc_html__( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $value ) ) ) . '</span>';
} else {
echo esc_html__( $value );
}
}
return;
}
if ( 'wc_actions' === $column && $is_tiktok_order ) {
if ( $is_tiktok_fulfillment_3pl ) {
$style_string = 'padding:0.3em !important;width:7em;height:auto !important;text-indent:0;text-align:center;line-height:normal;white-space:normal;';
$style_string .= $is_highlight_button ? 'background:yellow' : '';
printf(
'<a class="button" style="%s" target="_blank" href="%s">%s</a>',
esc_attr( $style_string ),
esc_url( get_tts_seller_center_origin() . '/order' ),
esc_html__( $is_highlight_button ? 'Add Tracking Info' : 'Update Tracking Info' )
);
} else {
printf(
'<a class="button" style="%s" target="_blank" href="%s">%s</a>',
'padding:0.3em !important;width:7em;height:auto !important;text-indent:0;text-align:center;line-height:normal;white-space:normal',
esc_url( get_tts_seller_center_origin() . '/order/detail?order_no=' . $tiktok_order_id ),
esc_html__( 'Manage on seller center' )
);
}
}
}
);
}
/**
* Add TikTok views
* hook is located in wordpress/wp-admin/includes/class-wp-list-table.php views method
*/
private static function add_tiktok_filter() {
add_filter(
'views_edit-shop_order',
function ( $views ) {
$screen = get_current_screen();
$curr_page = 1;
$orders = array();
$num_pages = wc_get_orders(
array(
'page' => $curr_page,
'paginate' => true,
'limit' => 10,
'meta_key' => 'tiktok_order',
'type' => 'shop_order',
)
)->max_num_pages;
while ( $curr_page <= $num_pages ) {
$new_orders = wc_get_orders(
array(
'page' => $curr_page,
'limit' => 10,
'meta_key' => 'tiktok_order',
'type' => 'shop_order',
)
);
$orders = array_merge( $orders, $new_orders );
$curr_page++;
}
return array_merge(
$views,
array(
'tiktok' => get_edit_link(
array(
'post_type' => $screen->post_type,
'channel' => 'tiktok',
),
'TikTok <span class="count">(' . number_format_i18n( count( $orders ) ) . ')</span>',
isset( $_REQUEST['channel'] ) && 'tiktok' === $_REQUEST['channel'] ? 'current' : ''
),
)
);
}
);
/**
* Modify query args of WP_Query instance
* need to wait current screen been set
* hook located in wordpress/wp-includes/class-wp-query.php get_posts method
*/
add_action(
'current_screen',
function ( $screen ) {
add_action(
'pre_get_posts',
function ( $query ) use ( $screen ) {
if (
'edit-shop_order' === $screen->id &&
'shop_order' === $screen->post_type &&
isset( $_GET['channel'] ) &&
'tiktok' === $_GET['channel']
) {
$query->query_vars['meta_key'] = 'tiktok_order';
}
}
);
}
);
}
}
OrderList::init();

Some files were not shown because too many files have changed in this diff Show more