Plugin Directory

Changeset 3359694


Ignore:
Timestamp:
09/11/2025 08:49:54 AM (5 months ago)
Author:
wisernotify
Message:

Updating trunk to version 2.3

Location:
wiser-review/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • wiser-review/trunk/assets/css/wiserrw-admin.css

    r3349699 r3359694  
    1 #toplevel_page_wiser-review img {
    2     width: 25px;
    3     padding: 0 !important;
    4     margin-top: 5px;
    5 }
    61.wiserrw_toggle .switch {
    72    position: relative;
     
    7469    background-color: #fff;
    7570}
    76 #wpcontent {
    77     padding-left: 0 !important;
    78 }
     71
    7972.wiserrw_help_text {
    8073    background-color: #fff;
  • wiser-review/trunk/assets/images/icon.svg

    r3296997 r3359694  
    1 <svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
    2 <path d="M11.6108 13.6505L7.82888 8.61685C7.74312 8.50285 7.68133 8.37271 7.64722 8.23425C7.61311 8.0958 7.6074 7.95188 7.63042 7.81116C7.65343 7.67043 7.70471 7.53581 7.78116 7.41539C7.85762 7.29497 7.95766 7.19123 8.07529 7.11041C8.31564 6.94212 8.61176 6.87299 8.9019 6.91746C9.19204 6.96193 9.45378 7.11656 9.63252 7.34909L12.5197 11.1929L13.2994 10.1576C13.4782 9.92512 13.74 9.77055 14.0301 9.72609C14.3202 9.68162 14.6163 9.75068 14.8567 9.91888C14.974 10.0001 15.0739 10.1039 15.1504 10.2243C15.2269 10.3447 15.2784 10.4791 15.3019 10.6197C15.3248 10.7602 15.3189 10.9039 15.2846 11.0421C15.2504 11.1803 15.1885 11.3101 15.1027 11.4238L13.4913 13.568C13.4584 13.6113 13.4225 13.6522 13.3837 13.6903C13.321 13.7661 13.2482 13.8331 13.1673 13.8892C12.9269 14.0574 12.6308 14.1265 12.3407 14.082C12.0506 14.0375 11.7888 13.883 11.61 13.6505H11.6108ZM7.30487 13.6505L3.52176 8.61685C3.43601 8.50283 3.37425 8.37267 3.34017 8.23419C3.30609 8.09572 3.30041 7.95179 3.32346 7.81107C3.34652 7.67035 3.39783 7.53573 3.47432 7.41532C3.55081 7.29491 3.6509 7.1912 3.76856 7.11041C4.0089 6.94212 4.30503 6.87299 4.59517 6.91746C4.8853 6.96193 5.14704 7.11656 5.32578 7.34909L9.10773 12.3824C9.23779 12.5535 9.31226 12.7602 9.32111 12.9748C9.32996 13.1894 9.27278 13.4016 9.15724 13.5828C9.08074 13.7034 8.98078 13.8075 8.86326 13.8888C8.62286 14.0569 8.32678 14.1259 8.0367 14.0815C7.74662 14.037 7.4849 13.8825 7.30604 13.6501L7.30487 13.6505Z" fill="white"/>
    3 <path d="M14.9788 7.31613C14.9032 7.06384 15.188 6.85755 15.4047 7.00763L16.0367 7.44536L16.669 7.00876C16.8859 6.85903 17.1705 7.06596 17.0946 7.31814L16.8731 8.05323L17.4844 8.51897C17.694 8.67872 17.5852 9.01291 17.3216 9.01868L16.5527 9.03551L16.298 9.76018C16.2106 10.0086 15.8587 10.0082 15.7718 9.7596L15.5182 9.03473L14.7497 9.01674C14.4861 9.01057 14.3775 8.67613 14.5873 8.51674L15.1993 8.05196L14.9788 7.31613Z" fill="white"/>
     1<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
     2<path d="M8.0127 0C12.4239 0 16 3.57615 16 7.9873C15.9999 12.4125 12.4125 15.9999 7.9873 16H1.2334C0.552409 16 0 15.4476 0 14.7666V8.0127C0.000108234 3.58745 3.58745 0.000108231 8.0127 0ZM8.02051 4.08008C7.80287 4.08021 7.6087 4.20541 7.51465 4.40625L6.6123 6.32129L4.60059 6.62988C4.39283 6.6618 4.22094 6.80886 4.15234 7.0127C4.082 7.22285 4.13338 7.45114 4.28613 7.6084L5.75 9.11523L5.4043 11.2471C5.36794 11.4716 5.45879 11.6908 5.6416 11.8193C5.73674 11.8861 5.84724 11.9199 5.95801 11.9199C6.04951 11.9199 6.14136 11.8961 6.22559 11.8496L8.01562 10.8506L9.81641 11.8496C10.0023 11.9529 10.2265 11.9416 10.4004 11.8193C10.5832 11.6911 10.6741 11.4714 10.6377 11.2471L10.291 9.11621L11.7559 7.60938C11.9087 7.45208 11.9601 7.22319 11.8896 7.0127C11.8211 6.80871 11.6493 6.66193 11.4414 6.62988L9.42871 6.32031L8.52637 4.40723C8.43227 4.2054 8.23832 4.08008 8.02051 4.08008Z" fill="#9CA2A7"/>
    43</svg>
  • wiser-review/trunk/assets/images/wiser_review.svg

    r3296997 r3359694  
    1 <svg width="162" height="26" viewBox="0 0 162 26" fill="none" xmlns="http://www.w3.org/2000/svg">
    2 <path d="M17.6124 19.6935L9.58843 8.99922C9.40646 8.75703 9.27536 8.48054 9.203 8.18638C9.13063 7.89222 9.11851 7.58646 9.16734 7.28749C9.21618 6.98853 9.32497 6.70252 9.48718 6.44668C9.64938 6.19083 9.86165 5.97043 10.1112 5.79873C10.6211 5.44119 11.2494 5.29434 11.865 5.38881C12.4806 5.48329 13.0359 5.8118 13.4151 6.30581L19.5406 14.4721L21.1951 12.2725C21.5744 11.7787 22.1297 11.4503 22.7452 11.3558C23.3608 11.2614 23.989 11.4081 24.499 11.7654C24.748 11.9379 24.9598 12.1585 25.1221 12.4142C25.2844 12.67 25.3937 12.9557 25.4436 13.2544C25.4921 13.5529 25.4796 13.8582 25.407 14.1517C25.3343 14.4453 25.203 14.7211 25.0209 14.9626L21.6021 19.5181C21.5324 19.6101 21.4561 19.6969 21.3738 19.7778C21.2407 19.939 21.0863 20.0813 20.9146 20.2005C20.4047 20.5579 19.7764 20.7046 19.1609 20.6101C18.5454 20.5157 17.9901 20.1873 17.6108 19.6935H17.6124ZM8.47665 19.6935L0.450188 8.99922C0.268268 8.75698 0.137218 8.48045 0.0649189 8.18625C-0.00738027 7.89206 -0.0194351 7.58628 0.0294791 7.28731C0.0783934 6.98834 0.187266 6.70235 0.349551 6.44653C0.511836 6.19072 0.72418 5.97037 0.973815 5.79873C1.48374 5.44119 2.11202 5.29434 2.72759 5.38881C3.34316 5.48329 3.89849 5.8118 4.27771 6.30581L12.3017 16.9992C12.5776 17.3627 12.7356 17.8019 12.7544 18.2579C12.7732 18.7138 12.6519 19.1646 12.4067 19.5495C12.2444 19.8058 12.0323 20.0269 11.783 20.1997C11.273 20.5569 10.6448 20.7035 10.0293 20.609C9.41389 20.5145 8.8586 20.1863 8.47913 19.6926L8.47665 19.6935Z" fill="#303030"/>
    3 <path d="M24.4977 5.98094C24.3631 5.53078 24.8707 5.16251 25.2568 5.43031L26.8195 6.51417L28.3839 5.43268C28.7704 5.16547 29.2775 5.5345 29.1421 5.98446L28.5942 7.80561L30.1062 8.95918C30.4797 9.2442 30.2855 9.84054 29.8157 9.85083L27.9144 9.8925L27.2845 11.6869C27.1289 12.1303 26.5017 12.1298 26.3467 11.6862L25.7196 9.89084L23.8183 9.84628C23.3485 9.83528 23.1552 9.23865 23.5292 8.9542L25.0429 7.80291L24.4977 5.98094Z" fill="#645CFC"/>
    4 <path d="M39.8355 20.5L36.599 9.04545H39.3508L41.3643 17.0994H41.4687L43.5269 9.04545H46.2489L48.3071 17.0547H48.419L50.4027 9.04545H53.1619L49.9179 20.5H47.1065L44.9588 12.7592H44.8022L42.6544 20.5H39.8355ZM55.0467 20.5V9.04545H57.7463V20.5H55.0467ZM56.404 7.41974C55.9764 7.41974 55.6085 7.27805 55.3003 6.99467C54.9921 6.70632 54.8379 6.36079 54.8379 5.9581C54.8379 5.55043 54.9921 5.2049 55.3003 4.92152C55.6085 4.63317 55.9764 4.48899 56.404 4.48899C56.8365 4.48899 57.2044 4.63317 57.5077 4.92152C57.8159 5.2049 57.97 5.55043 57.97 5.9581C57.97 6.36079 57.8159 6.70632 57.5077 6.99467C57.2044 7.27805 56.8365 7.41974 56.404 7.41974ZM69.5756 12.0732L67.1147 12.3416C67.0451 12.093 66.9233 11.8594 66.7492 11.6406C66.5802 11.4219 66.3515 11.2454 66.0632 11.1112C65.7748 10.9769 65.4218 10.9098 65.0042 10.9098C64.4424 10.9098 63.9701 11.0316 63.5873 11.2752C63.2095 11.5188 63.023 11.8345 63.028 12.2223C63.023 12.5554 63.1448 12.8263 63.3934 13.0352C63.647 13.244 64.0646 13.4155 64.6463 13.5497L66.6001 13.9673C67.6839 14.201 68.4893 14.5714 69.0163 15.0785C69.5483 15.5856 69.8167 16.2493 69.8217 17.0696C69.8167 17.7905 69.6054 18.4268 69.1878 18.9787C68.7752 19.5256 68.2009 19.9531 67.4652 20.2614C66.7294 20.5696 65.8842 20.7237 64.9296 20.7237C63.5277 20.7237 62.3991 20.4304 61.544 19.8438C60.6889 19.2521 60.1793 18.4293 60.0152 17.3754L62.6477 17.1218C62.767 17.6388 63.0206 18.0291 63.4083 18.2926C63.7961 18.5561 64.3007 18.6879 64.9222 18.6879C65.5635 18.6879 66.0781 18.5561 66.4659 18.2926C66.8586 18.0291 67.055 17.7035 67.055 17.3157C67.055 16.9876 66.9282 16.7166 66.6747 16.5028C66.4261 16.2891 66.0383 16.125 65.5113 16.0107L63.5575 15.6005C62.4588 15.3718 61.6459 14.9865 61.1189 14.4446C60.5919 13.8977 60.3309 13.2067 60.3359 12.3714C60.3309 11.6655 60.5223 11.054 60.9101 10.5369C61.3029 10.0149 61.8473 9.61222 62.5433 9.32883C63.2443 9.04048 64.0522 8.89631 64.9669 8.89631C66.3093 8.89631 67.3657 9.18217 68.1363 9.75391C68.9119 10.3256 69.3916 11.0987 69.5756 12.0732ZM77.1187 20.7237C75.9703 20.7237 74.9785 20.4851 74.1432 20.0078C73.313 19.5256 72.6741 18.8445 72.2267 17.9645C71.7793 17.0795 71.5555 16.038 71.5555 14.8398C71.5555 13.6616 71.7793 12.6275 72.2267 11.7376C72.6791 10.8427 73.3105 10.1467 74.1209 9.6495C74.9312 9.14737 75.8833 8.89631 76.9771 8.89631C77.683 8.89631 78.3492 9.01065 78.9756 9.23935C79.607 9.46307 80.1638 9.81108 80.6461 10.2834C81.1333 10.7557 81.5161 11.3572 81.7945 12.0881C82.0729 12.8139 82.2121 13.679 82.2121 14.6832V15.511H72.8233V13.6914H79.6244C79.6195 13.1744 79.5076 12.7145 79.2888 12.3118C79.0701 11.9041 78.7643 11.5835 78.3716 11.3498C77.9838 11.1161 77.5314 10.9993 77.0143 10.9993C76.4625 10.9993 75.9778 11.1335 75.5601 11.402C75.1425 11.6655 74.8169 12.0135 74.5832 12.446C74.3545 12.8736 74.2377 13.3434 74.2327 13.8555V15.4439C74.2327 16.1101 74.3545 16.6818 74.5981 17.1591C74.8418 17.6314 75.1823 17.9943 75.6198 18.2479C76.0573 18.4964 76.5694 18.6207 77.156 18.6207C77.5488 18.6207 77.9043 18.5661 78.2224 18.4567C78.5406 18.3423 78.8165 18.1758 79.0502 17.957C79.2839 17.7383 79.4604 17.4673 79.5797 17.1442L82.1003 17.4276C81.9412 18.0937 81.6379 18.6754 81.1905 19.1726C80.748 19.6648 80.1812 20.0476 79.4902 20.321C78.7991 20.5895 78.0087 20.7237 77.1187 20.7237ZM84.496 20.5V9.04545H87.1135V10.9545H87.2328C87.4416 10.2933 87.7996 9.78374 88.3067 9.42578C88.8188 9.06285 89.4029 8.88139 90.0592 8.88139C90.2083 8.88139 90.3749 8.88885 90.5588 8.90376C90.7477 8.91371 90.9043 8.93111 91.0286 8.95597V11.4393C90.9143 11.3995 90.7328 11.3647 90.4842 11.3349C90.2406 11.3001 90.0045 11.2827 89.7758 11.2827C89.2836 11.2827 88.8411 11.3896 88.4484 11.6033C88.0606 11.8121 87.7548 12.103 87.5311 12.4759C87.3074 12.8487 87.1955 13.2788 87.1955 13.766V20.5H84.496ZM92.8221 20.5V9.04545H95.4397V10.9545H95.559C95.7678 10.2933 96.1258 9.78374 96.6329 9.42578C97.1449 9.06285 97.7291 8.88139 98.3853 8.88139C98.5345 8.88139 98.701 8.88885 98.885 8.90376C99.0739 8.91371 99.2305 8.93111 99.3548 8.95597V11.4393C99.2405 11.3995 99.059 11.3647 98.8104 11.3349C98.5668 11.3001 98.3307 11.2827 98.102 11.2827C97.6098 11.2827 97.1673 11.3896 96.7745 11.6033C96.3868 11.8121 96.081 12.103 95.8573 12.4759C95.6336 12.8487 95.5217 13.2788 95.5217 13.766V20.5H92.8221ZM105.748 20.7237C104.599 20.7237 103.607 20.4851 102.772 20.0078C101.942 19.5256 101.303 18.8445 100.856 17.9645C100.408 17.0795 100.184 16.038 100.184 14.8398C100.184 13.6616 100.408 12.6275 100.856 11.7376C101.308 10.8427 101.939 10.1467 102.75 9.6495C103.56 9.14737 104.512 8.89631 105.606 8.89631C106.312 8.89631 106.978 9.01065 107.605 9.23935C108.236 9.46307 108.793 9.81108 109.275 10.2834C109.762 10.7557 110.145 11.3572 110.423 12.0881C110.702 12.8139 110.841 13.679 110.841 14.6832V15.511H101.452V13.6914H108.253C108.248 13.1744 108.136 12.7145 107.918 12.3118C107.699 11.9041 107.393 11.5835 107 11.3498C106.613 11.1161 106.16 10.9993 105.643 10.9993C105.091 10.9993 104.607 11.1335 104.189 11.402C103.771 11.6655 103.446 12.0135 103.212 12.446C102.983 12.8736 102.867 13.3434 102.862 13.8555V15.4439C102.862 16.1101 102.983 16.6818 103.227 17.1591C103.471 17.6314 103.811 17.9943 104.249 18.2479C104.686 18.4964 105.198 18.6207 105.785 18.6207C106.178 18.6207 106.533 18.5661 106.851 18.4567C107.17 18.3423 107.445 18.1758 107.679 17.957C107.913 17.7383 108.089 17.4673 108.209 17.1442L110.729 17.4276C110.57 18.0937 110.267 18.6754 109.819 19.1726C109.377 19.6648 108.81 20.0476 108.119 20.321C107.428 20.5895 106.638 20.7237 105.748 20.7237ZM123.028 9.04545L118.949 20.5H115.966L111.887 9.04545H114.765L117.398 17.5543H117.517L120.157 9.04545H123.028ZM124.896 20.5V9.04545H127.596V20.5H124.896ZM126.254 7.41974C125.826 7.41974 125.458 7.27805 125.15 6.99467C124.842 6.70632 124.688 6.36079 124.688 5.9581C124.688 5.55043 124.842 5.2049 125.15 4.92152C125.458 4.63317 125.826 4.48899 126.254 4.48899C126.686 4.48899 127.054 4.63317 127.357 4.92152C127.666 5.2049 127.82 5.55043 127.82 5.9581C127.82 6.36079 127.666 6.70632 127.357 6.99467C127.054 7.27805 126.686 7.41974 126.254 7.41974ZM135.443 20.7237C134.295 20.7237 133.303 20.4851 132.467 20.0078C131.637 19.5256 130.998 18.8445 130.551 17.9645C130.103 17.0795 129.88 16.038 129.88 14.8398C129.88 13.6616 130.103 12.6275 130.551 11.7376C131.003 10.8427 131.635 10.1467 132.445 9.6495C133.255 9.14737 134.208 8.89631 135.301 8.89631C136.007 8.89631 136.673 9.01065 137.3 9.23935C137.931 9.46307 138.488 9.81108 138.97 10.2834C139.458 10.7557 139.84 11.3572 140.119 12.0881C140.397 12.8139 140.536 13.679 140.536 14.6832V15.511H131.148V13.6914H137.949C137.944 13.1744 137.832 12.7145 137.613 12.3118C137.394 11.9041 137.089 11.5835 136.696 11.3498C136.308 11.1161 135.856 10.9993 135.339 10.9993C134.787 10.9993 134.302 11.1335 133.884 11.402C133.467 11.6655 133.141 12.0135 132.907 12.446C132.679 12.8736 132.562 13.3434 132.557 13.8555V15.4439C132.557 16.1101 132.679 16.6818 132.922 17.1591C133.166 17.6314 133.507 17.9943 133.944 18.2479C134.382 18.4964 134.894 18.6207 135.48 18.6207C135.873 18.6207 136.228 18.5661 136.547 18.4567C136.865 18.3423 137.141 18.1758 137.374 17.957C137.608 17.7383 137.785 17.4673 137.904 17.1442L140.424 17.4276C140.265 18.0937 139.962 18.6754 139.515 19.1726C139.072 19.6648 138.505 20.0476 137.814 20.321C137.123 20.5895 136.333 20.7237 135.443 20.7237ZM145.123 20.5L141.886 9.04545H144.638L146.651 17.0994H146.756L148.814 9.04545H151.536L153.594 17.0547H153.706L155.69 9.04545H158.449L155.205 20.5H152.394L150.246 12.7592H150.089L147.942 20.5H145.123Z" fill="#303030"/>
     1<svg width="166" height="28" viewBox="0 0 166 28" fill="none" xmlns="http://www.w3.org/2000/svg">
     2<path d="M0 14.0226C0 6.27812 6.27812 0 14.0226 0V0C21.7421 0 28 6.25791 28 13.9774V13.9774C28 21.7219 21.7219 28 13.9774 28H2.15782C0.966089 28 0 27.0339 0 25.8422V14.0226Z" fill="#645CFC"/>
     3<path d="M20.8058 12.2709C20.6858 11.9137 20.3859 11.6574 20.0218 11.6016L16.5002 11.0611L14.9219 7.71246C14.7573 7.35917 14.4177 7.14014 14.0365 7.14014C13.6553 7.14014 13.3157 7.35966 13.151 7.71148L11.5723 11.0616L8.05064 11.6021C7.68706 11.6579 7.38669 11.9147 7.26664 12.2714C7.14316 12.6394 7.23283 13.0397 7.50037 13.3151L10.0631 15.9523L9.45743 19.6822C9.39373 20.0752 9.55249 20.4583 9.87246 20.6832C10.0391 20.8004 10.2321 20.8596 10.4262 20.8596C10.5864 20.8596 10.7466 20.819 10.8941 20.7376L14.0281 18.9893L17.1793 20.7376C17.5047 20.9184 17.8962 20.8974 18.2005 20.6832C18.5205 20.4588 18.6792 20.0752 18.6155 19.6827L18.0099 15.9528L20.5726 13.3156C20.8401 13.0402 20.9298 12.6404 20.8063 12.2719L20.8058 12.2709Z" fill="white"/>
     4<path d="M40.9747 21L36.7795 6.33818H40.1657L42.5926 16.5256H42.7143L45.3918 6.33818H48.2913L50.9616 16.547H51.0905L53.5174 6.33818H56.9037L52.7084 21H49.6873L46.8953 11.414H46.7807L43.9958 21H40.9747ZM58.5055 21V10.0036H61.5553V21H58.5055ZM60.0376 8.58613C59.5841 8.58613 59.1952 8.43579 58.8706 8.13511C58.5509 7.82966 58.391 7.46454 58.391 7.03977C58.391 6.61977 58.5509 6.25943 58.8706 5.95875C59.1952 5.65329 59.5841 5.50057 60.0376 5.50057C60.491 5.50057 60.8776 5.65329 61.1973 5.95875C61.5219 6.25943 61.6841 6.61977 61.6841 7.03977C61.6841 7.46454 61.5219 7.82966 61.1973 8.13511C60.8776 8.43579 60.491 8.58613 60.0376 8.58613ZM73.1476 13.1393L70.3556 13.3111C70.3079 13.0725 70.2053 12.8577 70.0478 12.6668C69.8903 12.4711 69.6826 12.316 69.4249 12.2015C69.172 12.0822 68.8689 12.0225 68.5157 12.0225C68.0432 12.0225 67.6447 12.1227 67.3201 12.3232C66.9956 12.5189 66.8333 12.7814 66.8333 13.1107C66.8333 13.3732 66.9383 13.5951 67.1483 13.7765C67.3583 13.9578 67.7187 14.1034 68.2293 14.2132L70.2196 14.6141C71.2887 14.8336 72.0857 15.1868 72.6107 15.6736C73.1357 16.1605 73.3982 16.8 73.3982 17.5923C73.3982 18.313 73.1858 18.9453 72.7611 19.4894C72.3411 20.0335 71.7636 20.4583 71.0286 20.7637C70.2983 21.0644 69.4559 21.2148 68.5014 21.2148C67.0457 21.2148 65.8859 20.9117 65.0221 20.3056C64.163 19.6947 63.6595 18.8642 63.5115 17.8142L66.5112 17.6567C66.6018 18.1006 66.8214 18.4394 67.1698 18.6733C67.5182 18.9024 67.9645 19.0169 68.5085 19.0169C69.0431 19.0169 69.4726 18.9143 69.7972 18.7091C70.1265 18.4991 70.2936 18.2294 70.2983 17.9001C70.2936 17.6233 70.1766 17.3966 69.9475 17.22C69.7184 17.0386 69.3653 16.9002 68.888 16.8048L66.9837 16.4253C65.9098 16.2106 65.1104 15.8383 64.5854 15.3085C64.0651 14.7787 63.805 14.1034 63.805 13.2825C63.805 12.5761 63.9959 11.9676 64.3778 11.4569C64.7643 10.9462 65.306 10.5525 66.0029 10.2757C66.7045 9.99886 67.5254 9.86045 68.4656 9.86045C69.8545 9.86045 70.9474 10.154 71.7445 10.741C72.5463 11.3281 73.014 12.1275 73.1476 13.1393ZM80.33 21.2148C79.1989 21.2148 78.2252 20.9857 77.4091 20.5275C76.5977 20.0645 75.9725 19.4107 75.5334 18.5659C75.0943 17.7164 74.8748 16.7117 74.8748 15.5519C74.8748 14.4208 75.0943 13.4281 75.5334 12.5737C75.9725 11.7194 76.5906 11.0536 77.3876 10.5764C78.1894 10.0991 79.1297 9.86045 80.2083 9.86045C80.9337 9.86045 81.6091 9.97739 82.2343 10.2112C82.8643 10.4403 83.4132 10.7864 83.8809 11.2493C84.3534 11.7123 84.7209 12.2945 84.9834 12.9961C85.2459 13.693 85.3772 14.5091 85.3772 15.4445V16.2822H76.0918V14.3922H82.5064C82.5064 13.9531 82.4109 13.5641 82.22 13.2252C82.0291 12.8864 81.7642 12.6215 81.4253 12.4306C81.0912 12.2349 80.7023 12.137 80.2584 12.137C79.7955 12.137 79.385 12.2444 79.027 12.4592C78.6739 12.6692 78.397 12.9532 78.1966 13.3111C77.9961 13.6643 77.8935 14.0581 77.8887 14.4924V16.2893C77.8887 16.8334 77.989 17.3035 78.1894 17.6997C78.3947 18.0958 78.6834 18.4012 79.0557 18.616C79.428 18.8308 79.8694 18.9382 80.3801 18.9382C80.719 18.9382 81.0292 18.8905 81.3108 18.795C81.5924 18.6995 81.8334 18.5564 82.0339 18.3655C82.2343 18.1745 82.387 17.9407 82.492 17.6639L85.3127 17.85C85.1695 18.5277 84.876 19.1195 84.4322 19.6255C83.9931 20.1266 83.4251 20.518 82.7283 20.7995C82.0362 21.0764 81.2368 21.2148 80.33 21.2148ZM87.3674 21V10.0036H90.3241V11.9223H90.4386C90.6391 11.2398 90.9756 10.7243 91.4481 10.3759C91.9206 10.0227 92.4647 9.84614 93.0803 9.84614C93.2331 9.84614 93.3977 9.85568 93.5743 9.87477C93.7509 9.89386 93.906 9.92011 94.0397 9.95352V12.6597C93.8965 12.6167 93.6984 12.5785 93.4455 12.5451C93.1925 12.5117 92.961 12.495 92.751 12.495C92.3024 12.495 91.9015 12.5928 91.5483 12.7885C91.1999 12.9794 90.9231 13.2467 90.7178 13.5903C90.5174 13.934 90.4172 14.3301 90.4172 14.7787V21H87.3674ZM95.6737 21V6.33818H101.458C102.566 6.33818 103.511 6.53625 104.293 6.93238C105.081 7.32375 105.68 7.87977 106.09 8.60045C106.505 9.31636 106.713 10.1587 106.713 11.1276C106.713 12.1012 106.503 12.9389 106.083 13.6405C105.663 14.3373 105.055 14.8718 104.257 15.2441C103.465 15.6164 102.506 15.8025 101.38 15.8025H97.5065V13.3111H100.878C101.47 13.3111 101.962 13.23 102.353 13.0677C102.745 12.9055 103.036 12.662 103.227 12.3375C103.422 12.013 103.52 11.6097 103.52 11.1276C103.52 10.6408 103.422 10.2303 103.227 9.89625C103.036 9.56216 102.742 9.3092 102.346 9.13739C101.955 8.96079 101.461 8.8725 100.864 8.8725H98.7736V21H95.6737ZM103.592 14.3277L107.236 21H103.814L100.248 14.3277H103.592ZM113.681 21.2148C112.549 21.2148 111.576 20.9857 110.76 20.5275C109.948 20.0645 109.323 19.4107 108.884 18.5659C108.445 17.7164 108.225 16.7117 108.225 15.5519C108.225 14.4208 108.445 13.4281 108.884 12.5737C109.323 11.7194 109.941 11.0536 110.738 10.5764C111.54 10.0991 112.48 9.86045 113.559 9.86045C114.284 9.86045 114.96 9.97739 115.585 10.2112C116.215 10.4403 116.764 10.7864 117.232 11.2493C117.704 11.7123 118.072 12.2945 118.334 12.9961C118.597 13.693 118.728 14.5091 118.728 15.4445V16.2822H109.442V14.3922H115.857C115.857 13.9531 115.762 13.5641 115.571 13.2252C115.38 12.8864 115.115 12.6215 114.776 12.4306C114.442 12.2349 114.053 12.137 113.609 12.137C113.146 12.137 112.736 12.2444 112.378 12.4592C112.024 12.6692 111.748 12.9532 111.547 13.3111C111.347 13.6643 111.244 14.0581 111.239 14.4924V16.2893C111.239 16.8334 111.34 17.3035 111.54 17.6997C111.745 18.0958 112.034 18.4012 112.406 18.616C112.779 18.8308 113.22 18.9382 113.731 18.9382C114.07 18.9382 114.38 18.8905 114.661 18.795C114.943 18.6995 115.184 18.5564 115.384 18.3655C115.585 18.1745 115.738 17.9407 115.843 17.6639L118.663 17.85C118.52 18.5277 118.227 19.1195 117.783 19.6255C117.344 20.1266 116.776 20.518 116.079 20.7995C115.387 21.0764 114.587 21.2148 113.681 21.2148ZM130.675 10.0036L126.83 21H123.394L119.549 10.0036H122.771L125.055 17.8715H125.169L127.446 10.0036H130.675ZM132.235 21V10.0036H135.285V21H132.235ZM133.767 8.58613C133.314 8.58613 132.925 8.43579 132.6 8.13511C132.281 7.82966 132.121 7.46454 132.121 7.03977C132.121 6.61977 132.281 6.25943 132.6 5.95875C132.925 5.65329 133.314 5.50057 133.767 5.50057C134.221 5.50057 134.607 5.65329 134.927 5.95875C135.252 6.25943 135.414 6.61977 135.414 7.03977C135.414 7.46454 135.252 7.82966 134.927 8.13511C134.607 8.43579 134.221 8.58613 133.767 8.58613ZM142.739 21.2148C141.608 21.2148 140.635 20.9857 139.818 20.5275C139.007 20.0645 138.382 19.4107 137.943 18.5659C137.504 17.7164 137.284 16.7117 137.284 15.5519C137.284 14.4208 137.504 13.4281 137.943 12.5737C138.382 11.7194 139 11.0536 139.797 10.5764C140.599 10.0991 141.539 9.86045 142.618 9.86045C143.343 9.86045 144.018 9.97739 144.644 10.2112C145.274 10.4403 145.823 10.7864 146.29 11.2493C146.763 11.7123 147.13 12.2945 147.393 12.9961C147.655 13.693 147.787 14.5091 147.787 15.4445V16.2822H138.501V14.3922H144.916C144.916 13.9531 144.82 13.5641 144.629 13.2252C144.438 12.8864 144.174 12.6215 143.835 12.4306C143.501 12.2349 143.112 12.137 142.668 12.137C142.205 12.137 141.794 12.2444 141.436 12.4592C141.083 12.6692 140.806 12.9532 140.606 13.3111C140.406 13.6643 140.303 14.0581 140.298 14.4924V16.2893C140.298 16.8334 140.398 17.3035 140.599 17.6997C140.804 18.0958 141.093 18.4012 141.465 18.616C141.837 18.8308 142.279 18.9382 142.789 18.9382C143.128 18.9382 143.439 18.8905 143.72 18.795C144.002 18.6995 144.243 18.5564 144.443 18.3655C144.644 18.1745 144.796 17.9407 144.901 17.6639L147.722 17.85C147.579 18.5277 147.285 19.1195 146.842 19.6255C146.402 20.1266 145.834 20.518 145.138 20.7995C144.446 21.0764 143.646 21.2148 142.739 21.2148ZM151.867 21L148.875 10.0036H151.96L153.664 17.3918H153.764L155.54 10.0036H158.568L160.372 17.3489H160.465L162.141 10.0036H165.219L162.234 21H159.005L157.115 14.0843H156.979L155.089 21H151.867Z" fill="#303030"/>
    55</svg>
  • wiser-review/trunk/assets/js/wiserw-js.js

    r3352566 r3359694  
    242242    var request = {
    243243        action: 'wiserrw_reset_products',
    244         security: jQuery('.wiserrw_exporter').val(),
     244        wiserrw_security: wiserrw_ajax_var.wiserrw_security,
    245245    };
    246246    jQuery.post(ajaxurl, request).done(function (data_raw) {
     
    256256    var request = {
    257257        action: 'wiserrw_sync_products',
    258         security: jQuery('.wiserrw_exporter').val(),
     258        wiserrw_security: wiserrw_ajax_var.wiserrw_security,
    259259        page: page,
    260260        per_page: per_page
  • wiser-review/trunk/readme.txt

    r3354674 r3359694  
    66Tested up to: 6.8
    77Requires PHP: 7.4
    8 Stable tag: 2.2
     8Stable tag: 2.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    127127= 2.2 =
    128128Rich snippt & SEO improvement with reviews.
     129
     130= 2.3 =
     131Optimize performance, logo, css fixed & Star rating rendering at server side.
  • wiser-review/trunk/views/wiserw-plugin-settings.php

    r3354674 r3359694  
    99    exit;
    1010}
    11 include_once WP_PLUGIN_DIR . '/' . WISERRW_PLUGIN_DIR . '/views/wiserw-header.php';
     11include_once  WISERRW_PLUGIN_DIR . 'views/wiserw-header.php';
     12
    1213
    1314if ( isset( $_POST['wiserrw_plugin_settings'] ) ) {
     
    261262        $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    262263        $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    263         $api_data = wiserrw_validate_api( $api_key );
    264         $wsid = $api_data->data->wsid;
    265264    ?>
    266265    <form action="#" method="post" name="wiserrw_products_form" id="wiserrw_products_form">
  • wiser-review/trunk/wiser-review.php

    r3354674 r3359694  
    44 * Plugin URI: https://wiserreview.com
    55 * Description: Wiser Review module helps you collect and display product reviews, star ratings, and nudges. It also automates review requests via email to boost custom engagement and conversions.
    6  * Version: 2.2
     6 * Version: 2.3
    77 * Author: Wiser Notify
    88 * Requires Plugins: woocommerce
     
    2222define( 'WISERRW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2323define( 'WISERRW_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    24 define( 'WISERRW_PLUGIN_VERSION', 1.8 );
     24define( 'WISERRW_PLUGIN_VERSION', 2.3 );
    2525define( 'WISERRW_API_HOST', 'https://api.wiserreview.com/api/woocommerce/' );
    2626
     
    2929     * Plugin styles and scripts.
    3030     */
    31     function wiserrw_scripts() {
    32         wp_enqueue_style( 'wiserrw-admin-styles', plugins_url( '/assets/css/wiserrw-admin.css', WISERRW_PLUGIN_FILE ), array(), time() );
    33         wp_register_script( 'wiserrw-admin-script', plugins_url( '/assets/js/wiserw-js.js', WISERRW_PLUGIN_FILE ), array(), time() );
     31    function wiserrw_scripts( $hook ) {
     32        $allowed_screens = array(
     33            'toplevel_page_wiser-review'
     34        );
     35        $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
     36        $screen_id = $screen ? $screen->id : $hook;
     37        if ( ! in_array( $screen_id, $allowed_screens, true ) ) {
     38            return;
     39        }
     40       
     41        wp_enqueue_style( 'wiserrw-admin-styles', plugins_url( '/assets/css/wiserrw-admin.css', WISERRW_PLUGIN_FILE ), array(), WISERRW_PLUGIN_VERSION );
     42        wp_register_script( 'wiserrw-admin-script', plugins_url( '/assets/js/wiserw-js.js', WISERRW_PLUGIN_FILE ), array(), WISERRW_PLUGIN_VERSION   );
    3443        wp_localize_script(
    3544            'wiserrw-admin-script',
     
    95104 * @return bool
    96105 */
     106
    97107function wiserrw_validate_api( $api_key ) {
    98     $url  = 'https://api.wiserreview.com/api/woocommerce/verify?key=' . $api_key.'&wiserrw_hook_url='.get_site_url().'/wp-json/wiserrw/v1/reviews';
     108    $wiserrw_api_data = get_option( 'wiserrw_api_data', false );
     109    $url  = 'https://api.wiserreview.com/api/woocommerce/verify?key=' . $api_key.'&wiserrw_hook_url='.get_site_url().'/wp-json/wiserrw/v1/reviews';
    99110    $args = array(
    100111        'method'    => 'GET',
     112        'timeout'   => 20
    101113    );
    102 
    103114    $request  = wp_remote_post( $url, $args );
    104115    $response = json_decode( wp_remote_retrieve_body( $request ) );
    105     return $response;
     116    if (is_object($response) && isset($response->data) && isset($response->data->wsid)) {
     117        update_option( 'wiserrw_wsid', $response->data->wsid  );
     118        update_option( 'wiserrw_automation_id', $response->data->automation_id  );
     119    }
     120    return $response;
    106121}
    107122
     
    112127    $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    113128    if ( isset($wiserrw_api_settings['wiserrw_product_review_enabled']) && '1' === $wiserrw_api_settings['wiserrw_product_review_enabled'] ) {
    114     echo do_shortcode( '[wiserrw_product_review]' );
    115 }
    116 }
    117 add_action( 'woocommerce_after_single_product_summary', 'wiserrw_show_product_review' );
     129        echo do_shortcode( '[wiserrw_product_review]' );
     130    }
     131}
     132add_action( 'woocommerce_after_single_product_summary', 'wiserrw_show_product_review', 14 );
    118133// fix for the kadence theme
    119134add_action( 'kadence_after_short_description_block', 'wiserrw_show_product_review' );
     
    128143        $wiserrw_api_data = get_option( 'wiserrw_api_data' );
    129144        if ( isset($wiserrw_api_settings['wiserrw_product_card_enabled']) && '1' === $wiserrw_api_settings['wiserrw_product_card_enabled'] ) {
    130         echo do_shortcode( '[wiserrw_rating_count]' );
    131     }
    132 }
    133 add_action( 'woocommerce_after_shop_loop_item', 'wiserrw_show_product_rating_on_collection' );
     145            echo do_shortcode( '[wiserrw_rating_count]' );
     146        }
     147}
     148add_action( 'woocommerce_after_shop_loop_item_title', 'wiserrw_show_product_rating_on_collection', 5 );
    134149
    135150/**
     
    138153function wiserr_review_script() {
    139154    $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    140 if ( isset($wiserrw_api_settings['wiserrw_live_mode_checkbox']) && '1' === $wiserrw_api_settings['wiserrw_live_mode_checkbox'] ) {
    141         $wiserrw_api_data = get_option( 'wiserrw_api_data' );
    142         $header_pixel = $wiserrw_api_data->header_pixel;
    143         $allowed_tags = array(
    144             'script' => array(
    145                 'src' => true,
    146                 'type' => true,
    147                 'async' => true,
    148                 'defer' => true,
    149             ),
    150         );
    151         echo wp_kses( $header_pixel, $allowed_tags );
    152     }
    153 }
     155    if ( isset($wiserrw_api_settings['wiserrw_live_mode_checkbox']) && '1' === $wiserrw_api_settings['wiserrw_live_mode_checkbox'] ) {
     156            $wiserrw_api_data = get_option( 'wiserrw_api_data' );
     157            $header_pixel = $wiserrw_api_data->header_pixel;
     158            $allowed_tags = array(
     159                'script' => array(
     160                    'src' => true,
     161                    'type' => true,
     162                    'async' => true,
     163                    'defer' => true,
     164                ),
     165            );
     166            echo wp_kses( $header_pixel, $allowed_tags );
     167        }
     168    }
    154169add_action( 'wp_footer', 'wiserr_review_script' );
    155170
     
    162177    $wiserrw_api_data = get_option( 'wiserrw_api_data' );
    163178    if ( isset($wiserrw_api_settings['wiserrw_star_rating_enabled']) && '1' === $wiserrw_api_settings['wiserrw_star_rating_enabled'] ) {
    164     echo do_shortcode( '[wiserrw_rating_count]' );
     179       echo do_shortcode( '[wiserrw_rating_count]' );
    165180    }   
    166181}
    167 add_action( 'woocommerce_single_product_summary', 'wiserrw_show_rating_count', 5 );
     182add_action( 'woocommerce_single_product_summary', 'wiserrw_show_rating_count', 9 );
    168183// fix for the kadence theme
    169184if ( wp_get_theme()->get( 'Name' ) === 'Kadence' ) {
     
    197212    $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    198213    if ( $wiserrw_api_settings && '1' === $wiserrw_api_settings['wiserrw_live_mode_checkbox'] ) {
     214       
    199215        $wiserrw_api_data = get_option( 'wiserrw_api_data' );
    200216        $product_rating_count_pid = preg_replace( "/data-pid='(.*?)'/", "data-pid='$product_id'", $wiserrw_api_data->product_rating_count );
     
    209225            ),
    210226        );
    211         echo $product_rating_count;
     227       
     228        $parent_html = '';
     229        if ( preg_match( '/<div\b[^>]*>/i', $product_rating_count, $matches ) ) {
     230            $wiser_open_tag = $matches[0];
     231        }
     232        $product_rating_count = get_post_meta( $product_id, 'wiserrw_star_rating_html', true );
     233
     234        echo $wiser_open_tag;
     235        if( $product_rating_count ) {
     236           
     237            echo $product_rating_count;
     238           
     239        }
     240         echo "</div>";
    212241        $output = ob_get_contents();
    213242        return ob_get_clean();
     
    312341add_shortcode( 'wiserrw_product_nudges', 'wiserrw_product_nudges' );
    313342
    314 add_action( 'admin_init', 'test_wiser' );
    315 function test_wiser() {
    316     if( isset( $_GET['test_wiser'] ) ) {
    317         $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    318         $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    319         $api_data = wiserrw_validate_api( $api_key );
    320         if (!is_object($api_data) || !isset($api_data->data) || !isset($api_data->data->wsid)) {
    321             return;
    322         }
    323         $date_from = strtotime( '-7 days' );
    324         $all_orders = wc_get_orders(
    325             array(
    326                 'status'        => array( 'completed', 'processing' ),
    327                 'date_created'  => '>' . gmdate( 'Y-m-d H:i:s', $date_from ),
    328                 'limit'         => -1,
    329             )
    330         );
    331     }
    332 }
     343
    333344/**
    334345 * Send WooCommercer Order Data.
     
    343354
    344355    $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    345     $api_data = wiserrw_validate_api($api_key);
    346     if (!$api_data || !isset($api_data->data->wsid) || !isset($api_data->data->automation_id)) {
     356    $wsid = get_option( 'wiserrw_wsid', true );
     357    $automation_id = get_option( 'wiserrw_automation_id', true );
     358    if (!isset($wsid) || !isset($automation_id)) {
    347359        return; // Exit if invalid API data
    348360    }
     
    353365    }
    354366
    355     $wsid = $api_data->data->wsid;
    356     $automation_id = $api_data->data->automation_id;
    357367    $api_endpoint = 'https://api.wiserreview.com/api/woocommerce/webhook?wsid=' . $wsid . '&atmid=' . $automation_id;
    358368
     
    449459function wiserrw_export_orders() {
    450460    check_ajax_referer( 'wiserrw_export_orders_nonce', 'wiserrw_security' );
     461    if ( ! current_user_can( 'manage_woocommerce' ) ) {
     462        wp_send_json_error( array( 'message' => 'You are not allowed to perform this action.' ), 403 );
     463    }
    451464    $from_date  = isset( $_POST['start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) : '';
    452465    $to_date    = isset( $_POST['end_date'] ) ? sanitize_text_field( wp_unslash( $_POST['end_date'] ) ) : '';
     
    578591    check_ajax_referer( 'wiserrw_export_orders_nonce', 'wiserrw_security' );
    579592
     593    if ( ! current_user_can( 'manage_woocommerce' ) ) {
     594        wp_send_json_error( array( 'message' => 'You are not allowed to perform this action.' ), 403 );
     595    }
    580596    $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    581597    $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    582     $api_data = wiserrw_validate_api( $api_key );
    583     if (!$api_data || !isset($api_data->data->wsid) || !isset($api_data->data->automation_id)) {
    584         return; // Exit if invalid API data
    585     }
     598    $wsid = get_option( 'wiserrw_wsid', true );
     599    $automation_id = get_option( 'wiserrw_automation_id', true );
     600    if (!isset($wsid) || !isset($automation_id)) {
     601        return; // Exit if invalid API data
     602    }
    586603    $wiserrw_order_data = array();
    587604    $wiserrw_line_items = array();
    588605    $customer_data = array();
    589     $wsid = $api_data->data->wsid;
    590     $automation_id = $api_data->data->automation_id;
    591606    $api_endpoint = 'https://api.wiserreview.com/api/woocommerce/webhook?wsid=' . $wsid . '&atmid=' . $automation_id;
    592607
     
    658673
    659674        foreach ( $chunk_ids as $order ) {
     675            // Skip if this is a refund
     676            if ($order instanceof WC_Order_Refund) {
     677                continue;
     678            }
    660679            $order_id = $order->get_id();
    661680
     681                     
    662682            /* Order Details */
    663683            $wiserrw_order_data['oid'] = $order->get_id();
     
    755775
    756776/**
    757  * Bulk Orders API.
     777 * Bulk Orders count API.
    758778 */
    759779function wiserrw_fetch_order_count() {
    760780    check_ajax_referer( 'wiserrw_export_orders_nonce', 'wiserrw_security' );
    761 
     781    if ( ! current_user_can( 'manage_woocommerce' ) ) {
     782        wp_send_json_error( array( 'message' => 'You are not allowed to perform this action.' ), 403 );
     783    }
    762784    $duration  = isset( $_POST['duration'] ) ? sanitize_text_field( wp_unslash( $_POST['duration'] ) ) : '';
    763785    $from_date  = isset( $_POST['start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) : '';
     
    840862        ", $offset, $per_page ), ARRAY_A );
    841863}
     864
     865
    842866function wiserrw_sync_products() {
    843     $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    844     $full_product_synced = get_option( 'wiserrw_all_products_synced' );
    845     $api_host = constant( 'WISERRW_API_HOST' );
    846     $per_page = isset($_REQUEST['per_page']) ? intval($_REQUEST['per_page']) : 50;
    847     $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    848     $api_data = wiserrw_validate_api( $api_key );
    849     if (!is_object($api_data) || !isset($api_data->data) || !isset($api_data->data->wsid)) {
    850         return;
    851     }
    852     $wsid = $api_data->data->wsid;
    853    
    854     if ( isset( $_REQUEST['total_pages'] ) ) {
    855         $total_pages = (int) sanitize_text_field( wp_unslash($_REQUEST['total_pages']) );
    856     } else {
    857         $count       = wiserrw_count_products_with_reviews();
    858         $total_pages = $count / $per_page;
    859         $total_pages = (int) $total_pages;
    860         if ( $count % $per_page ) {
    861             $total_pages++;
    862         }
    863     }
    864 
    865     $page     = isset($_REQUEST['page']) ? (int) sanitize_text_field( wp_unslash($_REQUEST['page']) ) : 1;
    866     $finished = 0;
    867        
    868     if ( $page <= $total_pages ) {
    869         $message = "Synced $page / $total_pages pages";
    870 
    871         $products      = wiserrw_get_products( $page, $per_page );
    872         $products_json = array();
    873 
    874         foreach ( $products as $prod ) {
    875             // Reset SKU array for each product
    876             $arrsku = array();
    877            
    878             $p_id = $prod['ID'];
    879             $registered = get_post_meta( $p_id, '_wiserrw_product_registered' );
    880             if ( ! empty( $registered ) ) {
    881                 continue;
    882             }
    883            
    884             $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'shop_single' );
    885             $small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'thumbnail' );
    886             $medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'shop_catalog' );
    887 
    888             $terms = get_the_terms( $p_id, 'product_tag' );
    889             $term_array = array();
    890             if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    891                 foreach ( $terms as $term ) {
    892                     $term_array[] = $term->name;
    893                 }
    894             }
    895 
    896             $pr = wc_get_product( $p_id );
    897             if (!$pr) {
    898                 continue; // Skip if product doesn't exist
    899             }
    900            
    901             $variants = array();
    902             $gtin = '';
    903 
    904             if ( $pr->is_type( 'variable' ) ) {
    905                 $prod_variation = new WC_Product_Variable( $p_id );
    906                 foreach ( $prod_variation->get_available_variations() as $variation ) {
    907                     $variant = array();
    908 
    909                     $gtin = get_post_meta( $variation['variation_id'], 'hwp_var_gtin', 1 ) ?:
    910                            get_post_meta( $p_id, 'hwp_product_gtin', 1 ) ?:
    911                            $pr->get_attribute('GTIN') ?:
    912                            $pr->get_attribute('EAN') ?:
    913                            $pr->get_attribute('ISBN') ?:
    914                            get_post_meta( $p_id, '_global_unique_id', 1 );
    915 
    916                     if ( ! empty( $gtin ) ) {
    917                         $variant['barcode'] = $gtin;
    918                     }
    919 
    920                     if ( ! empty( $variation['sku'] ) ) {
    921                         $variant['sku'] = $variation['sku'];
    922                         $arrsku[] = $variation['sku'];
    923                     }
    924 
    925                     if ( ! empty( $variant) ) {
    926                         $variants[] = $variant;
    927                     }
    928                 }
    929             } else {
    930                 $pr_sku = $pr->get_sku();
    931                 $variant = array();
    932                 $gtin = get_post_meta( $p_id, 'hwp_product_gtin', 1 ) ?:
    933                        $pr->get_attribute('GTIN') ?:
    934                        $pr->get_attribute('EAN') ?:
    935                        $pr->get_attribute('ISBN') ?:
    936                        get_post_meta( $p_id, '_global_unique_id', 1 );
    937 
    938                 if ( $pr_sku != '' ) {
    939                     $arrsku[] = $pr_sku;   
    940                 }
    941                
    942                 if ( ! empty( $gtin ) ) {
    943                     $variant['barcode'] = $gtin;
    944                 }
    945 
    946                 if ( ! empty( $pr_sku ) ) {
    947                     $variant['sku'] = $pr_sku;
    948                 }
    949 
    950                 if ( ! empty($variant) ) {
    951                     $variants[] = $variant;
    952                 }
    953             }
    954 
    955             $vendor = get_bloginfo( 'name' );
    956             $domain = isset($domain) ? $domain : parse_url(home_url(), PHP_URL_HOST);
    957             if ( empty( $vendor ) ) {
    958                 $vendor = $domain;
    959             }
    960 
    961             $cats = get_the_terms( $p_id, 'product_cat' );
    962             $cat = $vendor;
    963             if ( ! empty( $cats ) && ! is_wp_error( $cats ) ) {
    964                 $cat = $cats[0]->name;
    965             }
    966 
    967             $title = $prod['title'];
    968             if ( empty($title) ) {
    969                 $title = $cat;
    970             }
    971 
    972             // Get product URL with fallback for draft products
    973             $product_url = get_permalink($p_id);
    974             if (!$product_url || $prod['post_status'] === 'draft') {
    975                 if ($prod['post_status'] === 'draft') {
    976                     $product_url = home_url('/?post_type=product&p=' . $prod['ID']);
    977                 } else {
    978                     $shop_page_url = get_permalink(wc_get_page_id('shop'));
    979                     $product_url = $shop_page_url ? $shop_page_url : home_url('/product/');
    980                     $product_url = trailingslashit($product_url) . sanitize_title($prod['title']);
    981                 }
    982             }
    983 
    984             // Get image URL with fallback
    985             $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($p_id), 'shop_single');
    986             if (!$image_url) {
    987                 $image_url = array(wc_placeholder_img_src('shop_single'));
    988             }
    989 
    990             $product_json = array(
    991                 'pid'    => $prod['ID'],
    992                 'arrsku' => $arrsku,
    993                 'shp'    => get_site_url(),
    994                 'wsid'   => $wsid,
    995                 'pn'     => $title,
    996                 'piu'    => isset($image_url[0]) ? esc_url($image_url[0]) : wc_placeholder_img_src('shop_single'),
    997                 'pu'     => esc_url($product_url),
    998                 'barcode'=> $gtin,
    999                 'variants' => $variants
    1000             );
    1001 
    1002             $products_json[] = $product_json;
    1003             update_post_meta( $p_id, '_wiserrw_product_registered', '1' );
    1004         }
    1005 
    1006         if (!empty($products_json)) {
    1007             $data = array(
    1008                 'method'   => 'POST',
    1009                 'blocking' => true,
    1010                 'headers'  => array( 'Content-Type' => 'application/json' ),
    1011                 'body'     => json_encode( array(
    1012                     'products' => $products_json
    1013                 ) )
    1014             );
    1015             $url = $api_host . 'productWebhook?wsid=' . $wsid . '&key=' . $api_key;   
    1016             $response = wp_safe_remote_post( $url, $data );
    1017            
    1018             if (is_wp_error($response)) {
    1019                 $error_message = $response->get_error_message();
    1020                 error_log(sprintf(
    1021                     'WiserReview Product Sync API Error: %s',
    1022                     $error_message
    1023                 ));
    1024             } else {
    1025                 $response_code = wp_remote_retrieve_response_code($response);
    1026                 if ($response_code !== 200) {
    1027                     $response_body = wp_remote_retrieve_body($response);
    1028                     error_log(sprintf(
    1029                         'WiserReview Product Sync API Non-200 Response: Code %d - %s',
    1030                         $response_code,
    1031                         $response_body
    1032                     ));
    1033                 }
    1034             }
    1035         }
    1036        
    1037     } else {
    1038         $message  = 'Finished';
    1039         $finished = 1;
    1040     }
    1041 
    1042     if ( $page == $total_pages ) {
    1043         update_option( 'wiserrw_all_products_synced', 1 );
    1044     }
    1045 
    1046     $page++;
     867    $wiserrw_api_settings   = get_option( 'wiserrw_api_settings' );
     868    $full_product_synced    = get_option( 'wiserrw_all_products_synced' );
     869    $api_host               = constant( 'WISERRW_API_HOST' );
     870    $per_page               = isset( $_REQUEST['per_page'] ) ? intval( $_REQUEST['per_page'] ) : 50;
     871    $api_key                = $wiserrw_api_settings['wiserrw_api_key'];
     872    $wsid                   = get_option( 'wiserrw_wsid', true );
     873    $automation_id          = get_option( 'wiserrw_automation_id', true );
     874
     875    if ( ! $wsid || ! $automation_id ) {
     876        wp_die();
     877    }
     878
     879    if ( isset( $_REQUEST['total_pages'] ) ) {
     880        $total_pages = (int) sanitize_text_field( wp_unslash( $_REQUEST['total_pages'] ) );
     881    } else {
     882        $count       = wiserrw_count_products_with_reviews();
     883        $total_pages = (int) ceil( $count / max( 1, $per_page ) );
     884    }
     885
     886    $page     = isset( $_REQUEST['page'] ) ? (int) sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : 1;
     887    $finished = 0;
     888
     889    if ( $page <= $total_pages ) {
     890        $message       = "Synced $page / $total_pages pages";
     891        $products      = wiserrw_get_products( $page, $per_page );
     892        $products_json = array();
     893
     894        foreach ( $products as $prod ) {
     895            $p_id       = (int) $prod['ID'];
     896            $registered = get_post_meta( $p_id, '_wiserrw_product_registered', true );
     897            if ( $registered ) {
     898                continue;
     899            }
     900
     901            $arrsku = array();
     902            $pr     = wc_get_product( $p_id );
     903            if ( ! $pr ) {
     904                continue;
     905            }
     906
     907            // Collect SKUs similar to your original
     908            if ( $pr->is_type( 'variable' ) ) {
     909                $prod_variation = new WC_Product_Variable( $p_id );
     910                foreach ( $prod_variation->get_children() as $vid ) {
     911                    $vsku = (string) get_post_meta( $vid, '_sku', true );
     912                    if ( $vsku !== '' ) {
     913                        $arrsku[] = $vsku;
     914                    }
     915                }
     916            } else {
     917                $pr_sku = (string) $pr->get_sku();
     918                if ( $pr_sku !== '' ) {
     919                    $arrsku[] = $pr_sku;
     920                }
     921            }
     922
     923            // Representative barcode (same idea you used)
     924            $gtin = get_post_meta( $p_id, 'hwp_product_gtin', true )
     925                ?: $pr->get_attribute( 'GTIN' )
     926                ?: $pr->get_attribute( 'EAN' )
     927                ?: $pr->get_attribute( 'ISBN' )
     928                ?: get_post_meta( $p_id, '_global_unique_id', true );
     929
     930            // Title and URL fallbacks
     931            $title = $prod['title'];
     932            if ( empty( $title ) ) {
     933                $cats = get_the_terms( $p_id, 'product_cat' );
     934                $title = ( ! empty( $cats ) && ! is_wp_error( $cats ) ) ? $cats[0]->name : get_bloginfo( 'name' );
     935            }
     936
     937            $product_url = get_permalink( $p_id );
     938            if ( ! $product_url || $prod['post_status'] === 'draft' ) {
     939                if ( $prod['post_status'] === 'draft' ) {
     940                    $product_url = home_url( '/?post_type=product&p=' . $p_id );
     941                } else {
     942                    $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
     943                    $product_url   = $shop_page_url ? $shop_page_url : home_url( '/product/' );
     944                    $product_url   = trailingslashit( $product_url ) . sanitize_title( $title );
     945                }
     946            }
     947
     948            // Image URL with placeholder fallback
     949            $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'shop_single' );
     950            $img_url = ( is_array( $img_src ) && isset( $img_src[0] ) ) ? $img_src[0] : wc_placeholder_img_src( 'shop_single' );
     951
     952            $product_json = array(
     953                'pid'      => $p_id,
     954                'arrsku'   => $arrsku,
     955                'shp'      => get_site_url(),
     956                'wsid'     => $wsid,
     957                'pn'       => $title,
     958                'piu'      => esc_url( $img_url ),
     959                'pu'       => esc_url( $product_url ),
     960                'barcode'  => (string) $gtin,
     961            );
     962
     963            $products_json[] = $product_json;
     964
     965            // Mark as registered (like your original)
     966            update_post_meta( $p_id, '_wiserrw_product_registered', '1' );
     967        }
     968
     969        if ( ! empty( $products_json ) ) {
     970            $data = array(
     971                'method'   => 'POST',
     972                'blocking' => true,
     973                'headers'  => array( 'Content-Type' => 'application/json' ),
     974                'body'     => wp_json_encode( array( 'products' => $products_json ) ),
     975            );
     976            $url      = $api_host . 'productWebhook?wsid=' . $wsid . '&key=' . $api_key;
     977            $response = wp_safe_remote_post( $url, $data );
     978
     979            // (Silent on errors, like your original; you can log if you want)
     980        }
     981    } else {
     982        $message  = 'Finished';
     983        $finished = 1;
     984    }
     985
     986    if ( $page == $total_pages ) {
     987        update_option( 'wiserrw_all_products_synced', 1 );
     988    }
     989
     990    $page++;
     991    $result = array(
     992        'next_page'   => $page,
     993        'total_pages' => $total_pages,
     994        'message'     => $message,
     995        'finished'    => $finished,
     996    );
     997
     998    echo wp_json_encode( $result );
     999    wp_die();
     1000}
     1001
     1002add_action( 'wp_ajax_wiserrw_sync_products', 'wiserrw_sync_products' );
     1003add_action( 'wp_ajax_nopriv_wiserrw_sync_products', 'wiserrw_sync_products' );
     1004
     1005
     1006function wiserrw_reset_products() {
     1007    global $wpdb;   
     1008
     1009    check_ajax_referer( 'wiserrw_export_orders_nonce', 'wiserrw_security' );
     1010    if ( ! current_user_can( 'manage_woocommerce' ) ) {
     1011        wp_send_json_error( array( 'message' => 'You are not allowed to perform this action.' ), 403 );
     1012    }
     1013    // Clear only the "registered" flag for all products
     1014    $wpdb->query(
     1015        $wpdb->prepare(
     1016            "DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
     1017            '_wiserrw_product_registered'
     1018        )
     1019    );
     1020
     1021    // JSON response (unchanged style)
    10471022    $result = array(
    1048         'next_page'   => $page,
    1049         'total_pages' => $total_pages,
    1050         'message'     => $message,
    1051         'url'         => isset($url) ? $url : '',
    1052         'response'    => isset($response) ? $response : '',
    1053         'products'    => isset($products_json) ? $products_json : array(),
    1054         'finished'    => $finished,
     1023        'message' => 'All Products Sync Status Cleared',
    10551024    );
    1056 
    10571025    echo wp_json_encode( $result );
    10581026    wp_die();
    10591027}
    1060 add_action( 'wp_ajax_wiserrw_sync_products', 'wiserrw_sync_products' );
    1061 add_action( 'wp_ajax_nopriv_wiserrw_sync_products', 'wiserrw_sync_products' );
    1062 
    1063 function wiserrw_reset_products() {
    1064     global $wpdb;
    1065     $sql = $wpdb->prepare( "DELETE FROM {$wpdb->prefix}postmeta WHERE meta_key = %s", '_wiserrw_product_registered' );
    1066     $wpdb->query( $sql );
    1067     $message = 'All Products Sync Status Cleared';
    1068     $result = array(
    1069         'message'     => $message,
    1070     );
    1071     echo wp_json_encode( $result );   
    1072     wp_die();
    1073 }
    1074 // Register the AJAX action only once
    1075 add_action('wp_ajax_wiserrw_reset_products', 'wiserrw_reset_products');
     1028
     1029// Register the AJAX action
     1030add_action( 'wp_ajax_wiserrw_reset_products', 'wiserrw_reset_products' );
    10761031add_action( 'wp_ajax_nopriv_wiserrw_reset_products', 'wiserrw_reset_products' );
     1032
     1033
    10771034
    10781035function wiserrw_product_delete_hook( $p_id ) {
     
    10811038        $api_host = constant( 'WISERRW_API_HOST' );
    10821039        $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    1083         $api_data = wiserrw_validate_api( $api_key );
    1084         if (!is_object($api_data) || !isset($api_data->data) || !isset($api_data->data->wsid)) {
    1085             return;
    1086         }
    1087         $wsid = $api_data->data->wsid;
     1040        $wsid = get_option( 'wiserrw_wsid', true );
     1041        $automation_id = get_option( 'wiserrw_automation_id', true );
     1042        if (!isset($wsid) || !isset($automation_id)) {
     1043            return; // Exit if invalid API data
     1044        }
    10881045        $url = $api_host . 'productWebhook/'.$p_id.'?wsid='.$wsid.'&key='.$api_key;   
    10891046        $data = array(
     
    10971054add_action( 'trashed_post', 'wiserrw_product_delete_hook' );
    10981055
     1056/* -------------------- Product Update Hook -------------------- */
     1057
     1058// Only send when name / slug / image / SKU / barcode changed.
     1059
     1060
     1061add_action( 'woocommerce_after_product_object_save', 'wiserrw_product_update_hook', 99, 1 );
     1062
    10991063function wiserrw_product_update_hook( $product ) {
    1100     $p_id = $product->get_id();
    1101     delete_post_meta( $p_id, '_wiserrw_product_registered' );
    1102     if ( wp_is_post_autosave( $p_id ) || wp_is_post_revision( $p_id ) ) {
    1103         return;
    1104     }
    1105     $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
    1106     $api_host = constant( 'WISERRW_API_HOST' );
    1107     $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    1108     $api_data = wiserrw_validate_api( $api_key );
    1109     if ( !$api_data || !isset($api_data->data->wsid) ) {
    1110         return; // Exit if invalid API data
    1111     }
    1112     $wsid = $api_data->data->wsid;
    1113     $url = $api_host . 'productWebhook?wsid='.$wsid.'&key='.$api_key;
    1114     $registered = get_post_meta( $p_id, '_wiserrw_product_registered', true );
    1115     $arrsku = array();
    1116     $pr = wc_get_product( $p_id );
    1117 
    1118 
    1119     $image_url        = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'shop_single' );
    1120     $small_image_url  = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'thumbnail' );
    1121     $medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $p_id ), 'shop_catalog' );
    1122            
    1123     if ( $pr->is_type( 'variable' ) ) {
    1124         $prod_variation = new WC_Product_Variable( $p_id );
    1125         foreach ( $prod_variation->get_available_variations() as $variation ) {
    1126             $variant = array();
    1127 
    1128             $gtin = get_post_meta( $variation['variation_id'], 'hwp_var_gtin', 1 ) ?: get_post_meta( $p_id, 'hwp_product_gtin', 1 ) ?: $pr->get_attribute('GTIN') ?: $pr->get_attribute('EAN') ?: $pr->get_attribute('ISBN') ?: get_post_meta( $p_id, '_global_unique_id', 1 );
    1129 
    1130             if ( ! empty( $gtin ) ) {
    1131                 $variant['barcode'] = $gtin;
    1132             }
    1133    
    1134             if ( ! empty( $variation['sku'] ) ) {
    1135                 $variant['sku'] = $variation['sku'];
    1136                 $arrsku[] = $variation['sku'];
    1137             }
    1138    
    1139             if ( ! empty( $variant) ) {
    1140                 $variants[] = $variant;
    1141             }
    1142         }
    1143     } else {
    1144         $pr_sku = $pr->get_sku();
    1145         $variant = array();
    1146         $gtin = get_post_meta( $p_id, 'hwp_product_gtin', 1 ) ?: $pr->get_attribute('GTIN') ?: $pr->get_attribute('EAN') ?: $pr->get_attribute('ISBN') ?: get_post_meta( $p_id, '_global_unique_id', 1 );
    1147        
    1148         if( $pr_sku != '' ){
    1149             $arrsku[] = $pr_sku;   
    1150         }
    1151        
    1152         if ( ! empty( $gtin ) ) {
    1153             $variant['barcode'] = $gtin;
    1154         }
    1155    
    1156         if ( ! empty( $pr_sku ) ) {
    1157             $variant['sku'] = $pr_sku;
    1158         }
    1159    
    1160         if ( ! empty($variant) ) {
    1161             $variants[] = $variant;
    1162         }
    1163     }
    1164    
    1165 
    1166     $cats   = get_the_terms( $p_id, 'product_cat' );
    1167     $cat = $vendor;
    1168     if ( ! empty( $cats ) && ! is_wp_error( $cats ) ) {
    1169         $cat = $cats[0]->name;
    1170     }
    1171    
    1172     $title = $pr->get_name();
    1173     if ( empty($title) ) {
    1174         $title = $cat;
    1175     }
    1176    
    1177     $product_json = array(
    1178         'pid'  => (string)$p_id,
    1179         'arrsku' => $arrsku,
    1180         'shp' => get_site_url(),
    1181         'wsid' => $wsid,
    1182         'pn' => $title,
    1183         'piu' => $image_url[0],
    1184         'pu' => get_permalink($p_id),
    1185         'barcode' => $gtin,
    1186     );
    1187     $products_json[] = $product_json;
    1188     $data = array(
     1064    if ( ! $product instanceof WC_Product ) {
     1065        return;
     1066    }
     1067
     1068    $p_id = $product->get_id();
     1069
     1070    // Skip autosaves / revisions
     1071    if ( wp_is_post_autosave( $p_id ) || wp_is_post_revision( $p_id ) ) {
     1072        return;
     1073    }
     1074
     1075    $is_variation = $product instanceof WC_Product_Variation;
     1076    $parent_id    = $is_variation ? $product->get_parent_id() : $p_id;
     1077
     1078    // --- Current values we watch ---
     1079    $name      = (string) $product->get_name();
     1080    $permalink = (string) get_permalink( $is_variation ? $parent_id : $p_id );
     1081
     1082    // Effective image id (variation image, else parent/simple image)
     1083    $effective_image_id = (int) $product->get_image_id();
     1084    if ( ! $effective_image_id ) {
     1085        $effective_image_id = (int) get_post_thumbnail_id( $is_variation ? $parent_id : $p_id );
     1086    }
     1087    $image_id = (string) $effective_image_id;
     1088
     1089    // SKU fingerprint (simple/variation = own SKU, variable parent = all child SKUs)
     1090    if ( $product->is_type( 'variable' ) && ! $is_variation ) {
     1091        $child_skus = array();
     1092        foreach ( $product->get_children() as $vid ) {
     1093            $vsku = (string) get_post_meta( $vid, '_sku', true );
     1094            if ( $vsku !== '' ) {
     1095                $child_skus[] = $vsku;
     1096            }
     1097        }
     1098        sort( $child_skus, SORT_NATURAL | SORT_FLAG_CASE );
     1099        $sku_fingerprint = implode( ',', $child_skus );
     1100    } else {
     1101        $sku_fingerprint = (string) $product->get_sku();
     1102    }
     1103
     1104    // Barcode / GTIN (variation gets its own; others use product/attributes)
     1105    if ( $is_variation ) {
     1106        $barcode = get_post_meta( $p_id, 'hwp_var_gtin', true )
     1107            ?: get_post_meta( $parent_id, 'hwp_product_gtin', true )
     1108            ?: $product->get_attribute( 'GTIN' )
     1109            ?: $product->get_attribute( 'EAN' )
     1110            ?: $product->get_attribute( 'ISBN' )
     1111            ?: get_post_meta( $p_id, '_global_unique_id', true );
     1112    } else {
     1113        $barcode = get_post_meta( $p_id, 'hwp_product_gtin', true )
     1114            ?: $product->get_attribute( 'GTIN' )
     1115            ?: $product->get_attribute( 'EAN' )
     1116            ?: $product->get_attribute( 'ISBN' )
     1117            ?: get_post_meta( $p_id, '_global_unique_id', true );
     1118    }
     1119    $barcode = (string) $barcode;
     1120
     1121    // Fingerprint of watched fields (name, URL, image, SKU(s), barcode)
     1122    $new_hash = md5( $name . '|' . $permalink . '|' . $image_id . '|' . $sku_fingerprint . '|' . $barcode );
     1123    $old_hash = (string) get_post_meta( $p_id, '_wiserrw_watch_hash', true );
     1124
     1125    // If nothing important changed, exit
     1126    if ( $new_hash === $old_hash ) {
     1127        return;
     1128    }
     1129
     1130    // --- Prepare payload (aligned with your original) ---
     1131    $wiserrw_api_settings = get_option( 'wiserrw_api_settings' );
     1132    if ( empty( $wiserrw_api_settings['wiserrw_api_key'] ) ) {
     1133        return;
     1134    }
     1135    $api_host      = constant( 'WISERRW_API_HOST' );
     1136    $api_key       = $wiserrw_api_settings['wiserrw_api_key'];
     1137    $wsid          = get_option( 'wiserrw_wsid', true );
     1138    $automation_id = get_option( 'wiserrw_automation_id', true );
     1139    if ( ! $wsid || ! $automation_id ) {
     1140        return;
     1141    }
     1142
     1143    // arrsku (mirror your original behavior)
     1144    $arrsku = array();
     1145    if ( $product->is_type( 'variable' ) && ! $is_variation ) {
     1146        foreach ( $product->get_children() as $vid ) {
     1147            $vsku = (string) get_post_meta( $vid, '_sku', true );
     1148            if ( $vsku !== '' ) {
     1149                $arrsku[] = $vsku;
     1150            }
     1151        }
     1152    } else {
     1153        if ( $sku_fingerprint !== '' ) {
     1154            $arrsku[] = $sku_fingerprint;
     1155        }
     1156    }
     1157
     1158    // Image URL from effective image id, with placeholder fallback
     1159    $thumb_id  = $effective_image_id;
     1160    $img_src   = $thumb_id ? wp_get_attachment_image_src( $thumb_id, 'shop_single' ) : false;
     1161    $img_url   = ( is_array( $img_src ) && isset( $img_src[0] ) ) ? $img_src[0] : wc_placeholder_img_src( 'shop_single' );
     1162
     1163    $product_json = array(
     1164        'pid'     => (string) $p_id,
     1165        'arrsku'  => $arrsku,
     1166        'shp'     => get_site_url(),
     1167        'wsid'    => $wsid,
     1168        'pn'      => $name ?: get_the_title( $parent_id ),
     1169        'piu'     => $img_url,
     1170        'pu'      => $permalink, // product URL
     1171        'barcode' => $barcode,
     1172    );
     1173
     1174    $args = array(
    11891175        'method'   => 'POST',
    11901176        'blocking' => true,
    11911177        'headers'  => array( 'Content-Type' => 'application/json' ),
    1192         'body'     => json_encode( array(
    1193             'products'    => $products_json
    1194         ) )
     1178        'body'     => wp_json_encode( array( 'products' => array( $product_json ) ) ),
    11951179    );
    1196     $url = $api_host . 'productWebhook?wsid='.$wsid.'&key='.$api_key;   
    1197     $response = wp_safe_remote_post( $url, $data );
    1198 }
    1199 add_action( 'woocommerce_after_product_object_save', 'wiserrw_product_update_hook', 99, 1  );
     1180
     1181    // Clear flag before send (like your original flow)
     1182    delete_post_meta( $p_id, '_wiserrw_product_registered' );
     1183
     1184    $response = wp_safe_remote_post( $api_host . 'productWebhook?wsid=' . $wsid . '&key=' . $api_key, $args );
     1185    if ( is_wp_error( $response ) ) {
     1186        return;
     1187    }
     1188
     1189    if ( (int) wp_remote_retrieve_response_code( $response ) === 200 ) {
     1190        update_post_meta( $p_id, '_wiserrw_product_registered', '1' );
     1191        update_post_meta( $p_id, '_wiserrw_watch_hash', $new_hash );
     1192    }
     1193}
     1194
     1195
     1196
     1197
     1198
     1199
     1200
    12001201
    12011202function wiserrw_custom_endpoints() {
     
    12171218
    12181219function wiserrw_api_auth( WP_REST_Request $request ) {
    1219     $provided = $request->get_header( 'wiserrw-api-key' );
     1220    $provided = $request->get_header( 'wiserrw-wsid' );
    12201221    if ( ! $provided ) {
    1221         $provided = $request->get_param( 'wiserrw_api_key' );
     1222        $provided = $request->get_param( 'wiserrw_wsid' );
    12221223    }
    12231224
     
    12311232   
    12321233    $wiserrw_api_settings = get_option( 'wiserrw_api_settings', array() );
    1233     if (!is_array($wiserrw_api_settings) || empty($wiserrw_api_settings['wiserrw_api_key'])) {
     1234    $wiserrw_wsid = get_option( 'wiserrw_wsid', true );
     1235    if ($wiserrw_wsid == '') {
    12341236        return new WP_Error(
    12351237            'wiserrw_auth_config',
     
    12391241    }
    12401242   
    1241     $api_key = $wiserrw_api_settings['wiserrw_api_key'];
     1243    $api_key = $wiserrw_wsid;
    12421244    $valid_keys = array($api_key);
    12431245
     
    12701272function wiserrw_api_response_callback( $request ) {
    12711273    $data = $request->get_json_params() ?: $request->get_params();
     1274
     1275     $query_params = $request->get_params();
     1276    if (empty($data) || !is_array($data)) {
     1277        return;
     1278    }
     1279    $verify = $query_params['verify_api'];
     1280    $wsid_param = $query_params['wiserrw_wsid'];
     1281    $wsid = get_option( 'wiserrw_wsid', '' );
     1282     // Verify API key if 'verify_api' is true and 'wiserrw_wsid' matches
     1283    if ( $verify && $wsid !== '' && $wsid == $wsid_param ) {
     1284        $wiserrw_api_settings = get_option('wiserrw_api_settings', array());
     1285        $api_key = $wiserrw_api_settings['wiserrw_api_key'];
     1286        wiserrw_validate_api( $api_key );       
     1287    }
     1288
     1289
    12721290    if (empty($data) || !is_array($data)) {
    12731291        return;
     
    12991317
    13001318    $api_key = $wiserrw_api_settings['wiserrw_api_key'];
    1301     $api_data = wiserrw_validate_api( $api_key );
    1302    
    1303     if (!is_object($api_data) || !isset($api_data->data) || !isset($api_data->data->wsid)) {
    1304         return;
     1319    $wsid = get_option( 'wiserrw_wsid', true );
     1320    $automation_id = get_option( 'wiserrw_automation_id', true );
     1321    if (!isset($wsid) || !isset($automation_id)) {
     1322        return; // Exit if invalid API data
    13051323    }
    13061324
    13071325    $p_id_arr = array($p_id); // Initialize array properly
    1308     $wsid = $api_data->data->wsid;
    13091326    $url = 'https://rs.wiserreview.com/api/getData';
     1327
    13101328   
    13111329    for( $i=0; $i<count($p_id_arr); $i++ ){
     
    13141332            continue;
    13151333        }
     1334        $arrPid[] = (string)$p_id_arr[$i];
    13161335        $schema_array = array();
    13171336        $body = array(
    1318             'arrType' => array('main'),
     1337            'arrType' => array('main','star_rating'),
    13191338            'pid'     => (string)$p_id_arr[$i],
     1339            'arrPid' => $arrPid,
     1340            'isFrom' => 'woocommerce',
    13201341            'wsid'    => $wsid,
    13211342        );
     1343   
    13221344        $response = wp_remote_post(
    13231345            $url,
     
    13351357            $data = json_decode( $json, true );
    13361358            foreach( $data['data'] as $row ) {
     1359                $wdtyp = $row['wdtyp'];
     1360                if( $wdtyp == 'main' ){
     1361
    13371362                $schema_array['@context'] = "https://schema.org";
    13381363                $schema_array['@type'] = "Product";
     
    13461371                    'worstRating' => '1',
    13471372                );
     1373            }
     1374                if( $wdtyp == 'star_rating' ) {
     1375                    $star_rating_html = $row['dataRating'][0]['html'];
     1376                   
     1377                    update_post_meta( $p_id_arr[$i], 'wiserrw_star_rating_html', $star_rating_html );
     1378                }
    13481379                foreach( $row['data'] as $review_row ) {
     1380                   
     1381                   
    13491382                   $review = array(
    13501383                        "@type" => "Review",
     
    13681401                }
    13691402                $json_schema = json_encode($schema_array,JSON_UNESCAPED_SLASHES);
     1403               
    13701404                update_post_meta( $p_id_arr[$i], 'wiserrw_schema_json', $json_schema );
    13711405            }
    13721406        }
     1407        wiserrw_send_product_update_on_save_post( $p_id_arr[$i] );
    13731408    }
    13741409}
     
    13941429
    13951430function wiserrw_check_rest_api() {
    1396     $response = wp_remote_get( home_url( '/wp-json/' ) );
     1431    add_filter('https_ssl_verify', '__return_false');
     1432   
     1433    $response = wp_remote_get( home_url( '/wp-json/' ) );
    13971434
    13981435    if ( is_wp_error( $response ) ) {
     
    14101447
    14111448function wiserrw_clear_wp_cache() {
    1412     if( isset( $_GET['wiser_clear_cache'] ) ) {
     1449    if( isset( $_GET['wiser_clear_cache'] ) && ( current_user_can( 'administrator' ) || current_user_can( 'editor' ) ) ) {
     1450   
    14131451        global $wp_fastest_cache;
    14141452       
     
    14751513}
    14761514add_action( 'admin_init', 'wiserrw_clear_wp_cache' );
     1515
     1516function wiserrw_send_product_update_on_save_post( $post_ID ) {
     1517   
     1518    // WooCommerce must be available
     1519    if ( ! class_exists( 'WooCommerce' ) ) return;
     1520   
     1521    $product = wc_get_product( $post_ID );
     1522    if ( ! $product ) return;
     1523   
     1524    $wsid = get_option('wiserrw_wsid',true);
     1525    $data = array(
     1526        'wsid' => $wsid,
     1527        'pid' => $post_ID
     1528    );
     1529    // Make the request
     1530    $response = wp_remote_post(
     1531        'https://rs.wiserreview.com/api/wp/updSchema',
     1532        array(
     1533            'method' => 'POST',
     1534            'headers' => array(
     1535                'Content-Type' => 'application/json',
     1536            ),
     1537            'timeout' => 45,
     1538            'redirection' => 5,
     1539            'httpversion' => '1.0',
     1540            'blocking' => true,
     1541            'body'    => wp_json_encode( $data ),
     1542        )
     1543    );
     1544   
     1545    update_option( 'wiserrw__update_hook',wp_remote_retrieve_body($response) );
     1546
     1547}
Note: See TracChangeset for help on using the changeset viewer.