Plugin Directory

Changeset 3840376


Ignore:
Timestamp:
12/02/2026 03:17:04 PM (less than one hour ago)
Author:
dropui
Message:

Release DropUI 1.0.7 with WooCommerce integration

Location:
dropui
Files:
16 added
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dropui/tags/1.0.7/assets/css/admin.css

    r3689562 r3840376  
     1body.toplevel_page_dropui {
     2    --dropui-account-manager-width: 320px;
     3    background: #fff;
     4}
     5
    16.dropui-admin {
    2     max-width: 1080px;
    3     color: #1d2327;
    4     letter-spacing: 0;
    5 }
    6 
    7 .dropui-admin:lang(ko) {
    8     word-break: keep-all;
     7    --dropui-ink: #202124;
     8    --dropui-muted: #62666d;
     9    --dropui-surface: #fff;
     10    --dropui-hover: #f0f1f3;
     11    --dropui-border: #e2e4e8;
     12    --dropui-control-border: #d4d7dc;
     13    --dropui-control-hover: #b5bac3;
     14    --dropui-primary-hover: #383b40;
     15    --dropui-focus: #2463b3;
     16    --dropui-focus-ring: rgb(36 99 179 / 12%);
     17    --dropui-error: #b42332;
     18    --dropui-whatsapp-brand: #25d366;
     19    --dropui-shadow: 0 12px 36px rgb(24 30 40 / 14%);
     20    max-width: 960px;
     21    margin: 0 auto;
     22    padding: 76px 32px 64px;
     23    color: var(--dropui-ink);
     24    font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
     25    overflow-wrap: anywhere;
    926}
    1027
    … …  
    1532}
    1633
     34.dropui-admin:lang(ko) {
     35    word-break: keep-all;
     36}
     37
     38.dropui-admin h1,
     39.dropui-admin h2,
     40.dropui-admin h3,
     41.dropui-admin p {
     42    margin: 0;
     43    padding: 0;
     44    color: inherit;
     45    line-height: inherit;
     46}
     47
     48.dropui-admin h1 {
     49    max-width: 720px;
     50    font-size: 32px;
     51    font-weight: 500;
     52    line-height: 1.25;
     53    letter-spacing: -.025em;
     54    text-wrap: balance;
     55}
     56
     57.dropui-admin h2 {
     58    font-size: 18px;
     59    font-weight: 600;
     60    line-height: 1.4;
     61    letter-spacing: -.015em;
     62}
     63
     64.dropui-admin h3 {
     65    font-size: 14px;
     66    font-weight: 600;
     67}
     68
     69.dropui-admin p + p {
     70    margin-top: 8px;
     71}
     72
     73.dropui-admin .dropui-help {
     74    color: var(--dropui-muted);
     75    font-size: 12px;
     76}
     77
     78.dropui-admin a:not(.dropui-button) {
     79    color: var(--dropui-ink);
     80    font-weight: 500;
     81    text-underline-offset: 3px;
     82    text-decoration-color: var(--dropui-control-border);
     83}
     84
     85.dropui-admin a:not(.dropui-button):hover {
     86    text-decoration-color: currentColor;
     87}
     88
     89.dropui-admin :is(a, button, input, summary):focus-visible {
     90    outline: 2px solid var(--dropui-focus);
     91    outline-offset: 2px;
     92    box-shadow: 0 0 0 2px var(--dropui-focus-ring);
     93}
     94
    1795.dropui-intro {
    18     padding: 16px 0 24px;
    19 }
    20 
    21 .dropui-admin .dropui-brand {
     96    display: grid;
     97    justify-items: center;
     98    gap: 12px;
     99    margin-bottom: 40px;
     100    text-align: center;
     101}
     102
     103.dropui-brand {
     104    display: block;
     105    object-fit: contain;
     106}
     107
     108.dropui-admin .dropui-intro-summary {
     109    max-width: 62ch;
     110    color: var(--dropui-muted);
     111    line-height: 1.65;
     112    text-wrap: pretty;
     113}
     114
     115.dropui-page-flow {
     116    display: grid;
     117    gap: 32px;
     118}
     119
     120.dropui-section {
     121    display: grid;
     122    align-content: start;
     123    min-width: 0;
     124    gap: 16px;
     125}
     126
     127.dropui-sync-help {
     128    max-width: 70ch;
     129}
     130
     131.dropui-woo-summary {
     132    padding: 16px 18px;
     133    border-radius: 8px;
     134    color: #0b2230;
     135    background-color: #e6f4f9;
     136    background-image: linear-gradient(90deg, #c1e7f9, #d0edf9 14%, #e1f3f9 36%, #e6f4f9 65%, #e4f3f9 78%, #dbeef9 90%, #c5e9f8);
     137    box-shadow: inset 0 0 0 1px rgb(68 131 205 / 32%);
     138}
     139
     140.dropui-admin .dropui-woo-summary p {
     141    font-size: 14px;
     142    line-height: 1.5;
     143}
     144
     145.dropui-woo-summary strong {
     146    font-weight: 600;
     147}
     148
     149@media (max-width: 600px) {
     150    .dropui-woo-summary {
     151        padding: 16px;
     152    }
     153}
     154
     155.dropui-columns {
     156    display: grid;
     157    grid-template-columns: repeat(2, minmax(0, 1fr));
     158    gap: 20px 24px;
     159}
     160
     161.dropui-data-fields {
     162    margin: 0;
     163}
     164
     165.dropui-data-fields > div {
     166    display: grid;
     167    align-content: start;
     168    gap: 6px;
     169}
     170
     171.dropui-data-fields dt {
     172    color: var(--dropui-muted);
     173    font-size: 12px;
     174}
     175
     176.dropui-data-fields dd {
     177    margin: 0;
     178    line-height: 1.6;
     179}
     180
     181.dropui-connection-actions {
     182    display: flex;
     183    flex-wrap: wrap;
     184    align-items: center;
     185    gap: 8px;
     186}
     187
     188.dropui-admin:has(.dropui-account-manager) {
     189    padding-bottom: 92px;
     190}
     191
     192.dropui-account-manager {
     193    position: fixed;
     194    right: max(16px, env(safe-area-inset-right));
     195    bottom: max(16px, env(safe-area-inset-bottom));
     196    left: max(16px, env(safe-area-inset-left));
     197    z-index: 110;
     198    max-width: var(--dropui-account-manager-width);
     199    margin-left: auto;
     200    pointer-events: none;
     201}
     202
     203#wpwrap.wp-responsive-open .dropui-account-manager {
     204    display: none;
     205}
     206
     207.dropui-admin .dropui-button.dropui-account-manager__trigger {
     208    display: flex;
     209    width: fit-content;
     210    min-height: 64px;
     211    gap: 12px;
     212    margin-left: auto;
     213    padding: 9px 20px 9px 9px;
     214    border-color: transparent;
     215    border-radius: 999px;
     216    background: var(--dropui-whatsapp-brand);
     217    box-shadow: var(--dropui-shadow);
     218    list-style: none;
     219    pointer-events: auto;
     220}
     221
     222.dropui-admin .dropui-button.dropui-account-manager__trigger:hover {
     223    border-color: transparent;
     224    background: color-mix(in srgb, var(--dropui-whatsapp-brand) 92%, var(--dropui-ink));
     225}
     226
     227.dropui-account-manager__trigger::-webkit-details-marker {
     228    display: none;
     229}
     230
     231.dropui-account-manager img {
     232    flex: none;
     233    border-radius: 50%;
     234    object-fit: cover;
     235}
     236
     237.dropui-account-manager__identity {
     238    display: grid;
     239    gap: 1px;
     240    font-size: 13px;
     241    line-height: 1.25;
     242    text-align: left;
     243}
     244
     245.dropui-account-manager__identity strong {
     246    font-size: 15px;
     247    font-weight: 600;
     248}
     249
     250.dropui-account-manager__card {
     251    position: absolute;
     252    right: 0;
     253    bottom: calc(100% + 12px);
     254    width: 100%;
     255    max-height: calc(100dvh - 104px - env(safe-area-inset-bottom));
     256    overflow-y: auto;
     257    padding: 16px;
     258    border: 1px solid var(--dropui-border);
     259    border-radius: 12px;
     260    background: var(--dropui-surface);
     261    box-shadow: var(--dropui-shadow);
     262    pointer-events: auto;
     263}
     264
     265.dropui-account-manager__header {
    22266    display: flex;
    23267    align-items: center;
    24268    gap: 12px;
    25     margin: 0;
    26     padding: 0;
    27     font-size: 22px;
    28     font-weight: 600;
    29     line-height: 1.4;
    30     overflow-wrap: anywhere;
    31 }
    32 
    33 .dropui-brand > span {
    34     min-width: 0;
    35 }
    36 
    37 .dropui-admin .dropui-intro-summary {
    38     max-width: 80ch;
    39     margin: 14px 0 0;
    40     color: #50575e;
    41     font-size: 14px;
    42     line-height: 1.7;
    43 }
    44 
    45 .dropui-brand img {
    46     flex: 0 0 40px;
    47     border-radius: 8px;
    48 }
    49 
    50 .dropui-admin h2 {
    51     margin: 0 0 12px;
    52     font-size: 20px;
    53     line-height: 1.4;
    54 }
    55 
    56 .dropui-admin h3 {
    57     margin: 0 0 12px;
    58     font-size: 15px;
    59     line-height: 1.5;
    60 }
    61 
    62 .dropui-admin p,
    63 .dropui-admin dd,
    64 .dropui-admin a,
    65 .dropui-admin h2,
    66 .dropui-admin h3 {
    67     overflow-wrap: anywhere;
    68 }
    69 
    70 .dropui-connection {
    71     display: grid;
    72     grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    73     gap: 40px;
    74     padding: 28px 0 32px;
    75     border-block: 1px solid #c3c4c7;
    76 }
    77 
    78 .dropui-admin .dropui-status {
    79     display: flex;
     269}
     270
     271.dropui-admin .dropui-account-manager__header h2 {
     272    font-size: 16px;
     273    letter-spacing: 0;
     274}
     275
     276.dropui-admin .dropui-account-manager__card p {
     277    margin: 12px 0 8px;
     278    color: var(--dropui-muted);
     279    font-size: 13px;
     280    line-height: 1.55;
     281}
     282
     283.dropui-account-manager__links {
     284    display: grid;
     285    justify-items: start;
     286}
     287
     288.dropui-account-manager__links a {
     289    display: inline-flex;
    80290    align-items: center;
    81     gap: 6px;
    82     margin: 0 0 12px;
    83     font-size: 13px;
    84     font-weight: 600;
    85 }
    86 
    87 .dropui-status--connected,
    88 .dropui-free {
    89     color: #12633b;
    90 }
    91 
    92 .dropui-status--incomplete {
    93     color: #8a4b00;
    94 }
    95 
    96 .dropui-summary {
    97     max-width: 56ch;
    98     margin: 0 0 22px;
    99     font-size: 15px;
    100     line-height: 1.6;
    101 }
    102 
    103 .dropui-site {
    104     margin: 0 0 22px;
    105     padding-inline-start: 12px;
    106     border-inline-start: 3px solid #c3c4c7;
    107 }
    108 
    109 .dropui-site dt {
    110     margin-bottom: 4px;
    111     color: #50575e;
    112     font-size: 12px;
    113 }
    114 
    115 .dropui-site dd {
    116     margin: 0;
    117     font-size: 14px;
    118     font-weight: 600;
    119     line-height: 1.6;
    120 }
    121 
    122 .dropui-site .dropui-site-url {
    123     color: #50575e;
    124     font-size: 13px;
    125     font-weight: 400;
    126 }
    127 
    128 .dropui-admin .dropui-connect-button {
     291    gap: 8px;
     292    min-height: 38px;
     293}
     294
     295.dropui-icon {
     296    flex: none;
     297}
     298
     299.dropui-admin .dropui-button {
    129300    display: inline-flex;
    130301    align-items: center;
    131302    justify-content: center;
    132     gap: 10px;
    133     min-height: 44px;
     303    gap: 6px;
    134304    max-width: 100%;
    135     padding: 8px 18px;
    136     font-size: 14px;
    137     line-height: 1.5;
    138     white-space: normal;
    139 }
    140 
    141 .dropui-admin .dashicons {
    142     flex: 0 0 20px;
    143 }
    144 
    145 .dropui-admin .description {
    146     margin-top: 10px;
    147     color: #50575e;
    148     font-style: normal;
    149     line-height: 1.6;
    150 }
    151 
    152 .dropui-account {
    153     padding-inline-start: 32px;
    154     border-inline-start: 1px solid #c3c4c7;
    155 }
    156 
    157 .dropui-account p {
    158     line-height: 1.7;
    159 }
    160 
    161 .dropui-free,
    162 .dropui-checklist li {
     305    min-height: 38px;
     306    padding: 8px 14px;
     307    border: 1px solid var(--dropui-control-border);
     308    border-radius: 8px;
     309    background: var(--dropui-surface);
     310    color: var(--dropui-ink);
     311    font: inherit;
     312    font-size: 13px;
     313    font-weight: 500;
     314    line-height: 1.4;
     315    text-align: center;
     316    text-decoration: none;
     317    cursor: pointer;
     318    transition: background-color 120ms ease, border-color 120ms ease;
     319}
     320
     321.dropui-admin .dropui-button:hover {
     322    border-color: var(--dropui-control-hover);
     323    background: var(--dropui-hover);
     324}
     325
     326.dropui-admin .dropui-button--primary {
     327    border-color: var(--dropui-ink);
     328    background: var(--dropui-ink);
     329    color: var(--dropui-surface);
     330}
     331
     332.dropui-admin .dropui-button--primary:hover {
     333    border-color: var(--dropui-primary-hover);
     334    background: var(--dropui-primary-hover);
     335    color: var(--dropui-surface);
     336}
     337
     338.dropui-admin .dropui-button--disconnect {
     339    color: var(--dropui-error);
     340}
     341
     342.dropui-feedback {
     343    margin-bottom: 16px;
     344    padding: 12px 16px;
     345    border-radius: 8px;
     346}
     347
     348.dropui-feedback--success {
     349    background: #ecf7f1;
     350    color: #176b4d;
     351}
     352
     353.dropui-feedback--warning {
     354    background: #fff8e8;
     355    color: #85530b;
     356}
     357
     358.dropui-feedback--error {
     359    background: #fff0f1;
     360    color: var(--dropui-error);
     361}
     362
     363.dropui-settings form {
     364    display: grid;
     365    align-content: start;
     366    justify-items: start;
     367    gap: 12px;
     368}
     369
     370.dropui-settings .dropui-help {
     371    margin: 0;
     372}
     373
     374.dropui-check {
    163375    display: flex;
    164376    align-items: flex-start;
    165377    gap: 8px;
    166 }
    167 
    168 .dropui-admin .dropui-free {
    169     margin: 12px 0 0;
    170     line-height: 1.6;
    171 }
    172 
    173 .dropui-checklist {
    174     margin: 20px 0;
    175 }
    176 
    177 .dropui-checklist li {
    178     margin-bottom: 16px;
    179     line-height: 1.6;
    180 }
    181 
    182 .dropui-guidance {
    183     display: grid;
    184     grid-template-columns: repeat(2, minmax(0, 1fr));
    185     gap: 32px;
    186     padding: 28px 0;
    187 }
    188 
    189 .dropui-guidance h2 {
    190     font-size: 18px;
    191 }
    192 
    193 .dropui-guidance p {
    194     margin: 0;
    195     color: #50575e;
    196     font-size: 14px;
    197     line-height: 1.7;
    198 }
    199 
    200 .dropui-guidance p + p {
    201     margin-top: 10px;
    202 }
    203 
    204 .dropui-support {
    205     display: flex;
    206     align-items: center;
    207     justify-content: space-between;
    208     gap: 24px;
    209     padding: 24px 0;
    210     border-top: 1px solid #c3c4c7;
    211 }
    212 
    213 .dropui-support h2 {
    214     font-size: 15px;
    215 }
    216 
    217 .dropui-support .button {
    218     max-width: 100%;
    219     white-space: normal;
    220 }
    221 
    222 @media (max-width: 960px) {
    223     .dropui-connection {
    224         gap: 24px;
    225     }
    226 
    227     .dropui-account {
    228         padding-inline-start: 24px;
    229     }
    230 }
    231 
    232 @media (max-width: 600px) {
    233     .dropui-connection,
    234     .dropui-guidance {
     378    cursor: pointer;
     379}
     380
     381.dropui-check input[type="checkbox"] {
     382    display: inline-grid;
     383    flex: none;
     384    place-content: center;
     385    width: 16px;
     386    height: 16px;
     387    margin: 2px 0 0;
     388    border-color: var(--dropui-control-border);
     389    border-radius: 4px;
     390}
     391
     392.dropui-check input[type="checkbox"]:checked {
     393    border-color: var(--dropui-ink);
     394    background: var(--dropui-ink);
     395}
     396
     397.dropui-check input[type="checkbox"]:checked::before {
     398    float: none;
     399    width: 5px;
     400    height: 8px;
     401    margin: -1px 0 0;
     402    border: solid var(--dropui-surface);
     403    border-width: 0 2px 2px 0;
     404    transform: rotate(45deg);
     405    content: "";
     406}
     407
     408@media (forced-colors: active) {
     409    .dropui-check input[type="checkbox"]:checked {
     410        border-color: Highlight;
     411        background: Highlight;
     412        forced-color-adjust: none;
     413    }
     414
     415    .dropui-check input[type="checkbox"]:checked::before {
     416        border-color: HighlightText;
     417    }
     418}
     419
     420@media (min-width: 783px) {
     421    body.toplevel_page_dropui:has(.dropui-account-manager) #wpfooter {
     422        padding-inline-end: calc(var(--dropui-account-manager-width) + 28px);
     423    }
     424}
     425
     426@media (max-width: 782px) {
     427    .dropui-admin {
     428        padding: 72px 16px 40px;
     429    }
     430
     431    .dropui-intro {
     432        margin-bottom: 32px;
     433    }
     434
     435    .dropui-admin h1 {
     436        font-size: 26px;
     437    }
     438
     439    .dropui-admin .dropui-button,
     440    .dropui-account-manager__links a {
     441        min-height: 44px;
     442    }
     443
     444    .dropui-columns {
    235445        grid-template-columns: minmax(0, 1fr);
    236446    }
    237 
    238     .dropui-account {
    239         padding: 24px 0 0;
    240         border-inline-start: 0;
    241         border-top: 1px solid #c3c4c7;
    242     }
    243 
    244     .dropui-support {
    245         align-items: flex-start;
    246         flex-direction: column;
    247     }
    248 }
     447}
  • dropui/tags/1.0.7/assets/js/admin.js

    r3664245 r3840376  
    2020    }
    2121
     22    const accountManager = adminPage.querySelector('[data-dropui-account-manager]');
     23    if (accountManager) {
     24        const closeOutside = function (event) {
     25            if (accountManager.open && !accountManager.contains(event.target)) {
     26                accountManager.open = false;
     27            }
     28        };
     29        document.addEventListener('pointerdown', closeOutside);
     30        document.addEventListener('focusin', closeOutside);
     31        accountManager.addEventListener('keydown', function (event) {
     32            if (event.key !== 'Escape' || !accountManager.open) {
     33                return;
     34            }
     35            event.preventDefault();
     36            event.stopPropagation();
     37            accountManager.open = false;
     38            accountManager.querySelector('summary').focus({ preventScroll: true });
     39        });
     40    }
     41
    2242    const disconnectButton = adminPage.querySelector(
    2343        '[data-dropui-disconnect-confirm]'
  • dropui/tags/1.0.7/assets/js/exchange-callback.js

    r3664245 r3840376  
    44
    55if (callbackPage) {
    6     try {
    7         localStorage.setItem(
    8             'dropui_connection_updated',
    9             String(Date.now())
    10         );
    11     } catch (error) {
    12         // Ignore localStorage errors.
    13     }
     6    if (callbackPage.dataset.dropuiRefreshTabs !== '0') {
     7        try {
     8            localStorage.setItem(
     9                'dropui_connection_updated',
     10                String(Date.now())
     11            );
     12        } catch (error) {
     13            // Ignore localStorage errors.
     14        }
    1415
    15     if (window.opener && !window.opener.closed) {
    16         window.opener.location.reload();
     16        if (window.opener && !window.opener.closed) {
     17            window.opener.location.reload();
     18        }
    1719    }
    1820
  • dropui/tags/1.0.7/config/dropui.php

    r3664245 r3840376  
    11<?php
    22
    3 return [
    4     'base_url' => 'https://app.dropui.com/',
    5 ];
     3return ['base_url' => 'https://app.dropui.com/'];
  • dropui/tags/1.0.7/dropui-wordpress-app.php

    r3689562 r3840376  
    55Plugin URI: https://dropui.com/integrations/wordpress
    66Description: Connect your WordPress site to DropUI and manage your campaigns from your DropUI account.
    7 Version: 1.0.6
     7Version: 1.0.7
    88Requires at least: 6.3
    99Requires PHP: 7.4
    … …  
    2121
    2222if (!defined('DROPUI_VERSION')) {
    23     define('DROPUI_VERSION', '1.0.6');
     23    define('DROPUI_VERSION', '1.0.7');
    2424}
    2525
    … …  
    2929use DropUI\Admin\ExchangeCallbackHandler;
    3030use DropUI\Frontend\MasterScriptLoader;
     31use DropUI\Service\WooCommerceBridge;
     32use DropUI\Service\WooCommerceSmsConsent;
    3133
    3234(new MasterScriptLoader())->register();
     35
     36add_action('admin_post_nopriv_dropui_commerce_read', [new WooCommerceBridge(), 'handle']);
     37add_action('admin_post_dropui_commerce_read', [new WooCommerceBridge(), 'handle']);
     38add_action('woocommerce_checkout_create_order', [new WooCommerceBridge(), 'captureCartToken']);
     39add_action('woocommerce_store_api_checkout_update_order_meta', [new WooCommerceBridge(), 'captureCartToken']);
     40$dropuiSmsConsent = new WooCommerceSmsConsent();
     41add_action('woocommerce_init', [$dropuiSmsConsent, 'registerBlockField']);
     42add_action('woocommerce_after_order_notes', [$dropuiSmsConsent, 'renderClassicField']);
     43add_action('woocommerce_checkout_create_order', [$dropuiSmsConsent, 'captureClassic']);
     44add_action('woocommerce_store_api_checkout_update_order_from_request', [$dropuiSmsConsent, 'readBlockSubmission'], 10, 2);
     45add_action('woocommerce_store_api_checkout_order_processed', [$dropuiSmsConsent, 'captureBlock']);
     46add_filter('wp_consent_api_registered_' . plugin_basename(__FILE__), '__return_true');
     47add_action('before_woocommerce_init', function () {
     48    if (class_exists('Automattic\\WooCommerce\\Utilities\\FeaturesUtil')) {
     49        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
     50            'custom_order_tables', __FILE__, true
     51        );
     52    }
     53});
     54
     55// WooCommerce registers checkout fields at init priority 0.
     56add_action('init', function () {
     57    load_plugin_textdomain('dropui', false, dirname(plugin_basename(__FILE__)) . '/languages');
     58
     59    if (determine_locale() === 'pl_PL') {
     60        // Keep WordPress.org translations and supplement them with bundled Polish strings.
     61        get_translations_for_domain('dropui');
     62        load_textdomain('dropui', __DIR__ . '/languages/dropui-pl_PL.mo', 'pl_PL');
     63    }
     64}, -1);
    3365
    3466add_action('admin_enqueue_scripts', function ($hook) {
    … …  
    4072        'dropui-admin',
    4173        plugin_dir_url(__FILE__) . 'assets/css/admin.css',
    42         ['dashicons'],
     74        [],
    4375        DROPUI_VERSION
    4476    );
    … …  
    74106// run, so this happens once and never again.
    75107add_action('admin_init', function () {
    76     if (!get_option('dropui_activation_redirect')) {
     108    if ((defined('WP_CLI') && WP_CLI) || wp_doing_ajax() || is_network_admin() ||
     109        !current_user_can('manage_options') || !get_option('dropui_activation_redirect')) {
    77110        return;
    78111    }
    … …  
    86119    }
    87120
    88     if (wp_doing_ajax() || is_network_admin()) {
    89         return;
    90     }
    91 
    92     if (!current_user_can('manage_options')) {
    93         return;
    94     }
    95 
    96121    wp_safe_redirect(admin_url('admin.php?page=dropui'));
    97122    exit;
    … …  
    99124
    100125add_action('admin_post_dropui_exchange_callback', function () {
    101     wp_enqueue_script(
    102         'dropui-exchange-callback',
    103         plugin_dir_url(__FILE__) . 'assets/js/exchange-callback.js',
    104         [],
    105         DROPUI_VERSION,
    106         true
    107     );
    108 
    109126    (new ExchangeCallbackHandler())->handle();
    110127});
  • dropui/tags/1.0.7/languages/dropui.pot

    r3689562 r3840376  
    174174
    175175#: src/Admin/AdminPage.php
    176 msgid "Start with one campaign"
    177 msgstr ""
    178 
    179 #: src/Admin/AdminPage.php
    180176msgid "After connecting your website, you will create and publish campaigns in the DropUI dashboard."
    181177msgstr ""
    … …  
    285281msgid "Unable to encode DropUI auth secret."
    286282msgstr ""
     283
     284#: src/Admin/AdminPage.php
     285msgid "Open DropUI and start synchronization"
     286msgstr ""
     287
     288#: src/Admin/AdminPage.php
     289msgid "Connecting synchronizes products, orders and customer contact details with DropUI. Existing marketing consents are not imported automatically."
     290msgstr ""
     291
     292#: src/Admin/AdminPage.php
     293msgid "Cart tracking requires an explicit marketing decision from a consent manager compatible with WP Consent API or a configured consent integration."
     294msgstr ""
     295
     296#: src/Admin/AdminPage.php
     297msgid "Synchronize MailPoet newsletter subscriptions"
     298msgstr ""
     299
     300#: src/Admin/AdminPage.php
     301msgid "I confirm that these lists contain permission to send this store’s marketing emails."
     302msgstr ""
     303
     304#: src/Admin/AdminPage.php
     305msgid "Save settings"
     306msgstr ""
     307
     308#: src/Admin/AdminPage.php
     309msgid "Settings saved."
     310msgstr ""
     311
     312#: src/Admin/AdminPage.php
     313msgid "Confirm the marketing permission before enabling synchronization."
     314msgstr ""
     315
     316#: src/Admin/AdminPage.php
     317msgid "Ask for SMS marketing consent at checkout"
     318msgstr ""
     319
     320#: src/Admin/AdminPage.php
     321msgid "SMS marketing in DropUI supports Polish phone numbers."
     322msgstr ""
     323
     324#: src/Admin/AdminPage.php
     325msgid "Update WooCommerce to collect SMS consent in the Checkout block."
     326msgstr ""
     327
     328#: src/Service/WooCommerceSmsConsent.php
     329msgid "I agree to receive marketing text messages from this store at the phone number provided."
     330msgstr ""
     331
     332#: src/Admin/AdminPage.php
     333msgid "Your WooCommerce store is connected"
     334msgstr ""
     335
     336#: src/Admin/AdminPage.php
     337msgid "Your WordPress site is connected"
     338msgstr ""
     339
     340#: src/Admin/AdminPage.php
     341msgid "WooCommerce detected."
     342msgstr ""
     343
     344#: src/Admin/AdminPage.php
     345msgid "Start synchronization to import products, orders and customer contact details."
     346msgstr ""
     347
     348#: src/Admin/AdminPage.php
     349msgid "Marketing consents"
     350msgstr ""
     351
     352#: src/Admin/AdminPage.php
     353msgid "SMS at checkout"
     354msgstr ""
     355
     356#: src/Admin/AdminPage.php
     357msgid "Customers decide whether to subscribe. DropUI supports Polish phone numbers for SMS marketing."
     358msgstr ""
     359
     360#: src/Admin/AdminPage.php
     361msgid "Save SMS settings"
     362msgstr ""
     363
     364#: src/Admin/AdminPage.php
     365msgid "Email from MailPoet"
     366msgstr ""
     367
     368#: src/Admin/AdminPage.php
     369msgid "Save MailPoet settings"
     370msgstr ""
     371
     372#: src/Admin/AdminPage.php
     373msgid "Connect your store"
     374msgstr ""
     375
     376#: src/Admin/AdminPage.php
     377msgid "Your store"
     378msgstr ""
     379
     380#: src/Admin/AdminPage.php
     381msgid "Grow sales in your WooCommerce store"
     382msgstr ""
     383
     384#: src/Admin/AdminPage.php
     385msgid "Collect contacts on your WordPress site"
     386msgstr ""
     387
     388#: src/Admin/AdminPage.php
     389msgid "Connect your store to DropUI to recommend products based on purchase history and encourage repeat orders."
     390msgstr ""
     391
     392#: src/Admin/AdminPage.php
     393msgid "Add a newsletter signup form. You will see new signups in DropUI."
     394msgstr ""
     395
     396#: src/Admin/AdminPage.php
     397msgid "After you connect, DropUI imports products, orders and customer contact details."
     398msgstr ""
     399
     400#: src/Admin/AdminPage.php
     401msgid "Site name"
     402msgstr ""
     403
     404#: src/Admin/AdminPage.php
     405msgid "Site address"
     406msgstr ""
     407
     408#: src/Admin/AdminPage.php
     409msgid "Your account manager"
     410msgstr ""
     411
     412#: src/Admin/AdminPage.php
     413msgid "I can help you connect your store, choose a plan or launch a campaign. Email me."
     414msgstr ""
     415
     416msgid "This domain already has a WooCommerce store connected to DropUI. Use a separate domain or subdomain for this store."
     417msgstr ""
     418
     419msgid "WooCommerce synchronization could not start. Try again or contact your account manager."
     420msgstr ""
  • dropui/tags/1.0.7/readme.txt

    r3689562 r3840376  
    33Tags: popup, lead generation, abandoned cart, marketing automation, woocommerce
    44Requires at least: 6.3
    5 Tested up to: 7.0
     5Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.6
     7Stable tag: 1.0.7
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7474The plugin requires WordPress 6.3 or newer and PHP 7.4 or newer.
    7575
    76 The plugin has been tested up to WordPress 7.0.
     76The plugin has been tested with WordPress 7.1.5.
    7777
    7878In a WordPress Multisite network, each site connects to DropUI independently and has its own configuration and campaigns.
    … …  
    143143
    144144If the website uses WooCommerce, the processed context may also include product, category, variation, coupon, cart contents, cart value, and checkout stage.
     145
     146When an administrator connects a WooCommerce site or starts synchronization from the plugin, DropUI also reads product data, order details and customer contact details from the store. Disconnecting the plugin stops further synchronization.
     147
     148Commerce tracking requires an explicit marketing decision through WP Consent API or an explicitly configured consent integration. Without it, cart tracking and personalized recommendations based on browsing remain inactive.
    145149
    146150The exact scope of processed information depends on the website configuration, enabled features, and active campaigns.
    … …  
    174178== Changelog ==
    175179
     180= 1.0.7 =
     181
     182* Added synchronization of WooCommerce products, orders and customer contact details.
     183* Simplified the connection screen for WordPress sites and WooCommerce stores.
     184
    176185= 1.0.6 =
    177186
  • dropui/tags/1.0.7/src/Admin/AdminPage.php

    r3689562 r3840376  
    55use DropUI\Service\DropuiService;
    66use DropUI\Service\StoreService;
     7use DropUI\Service\WooCommerceSmsConsent;
    78
    89class AdminPage
    … …  
    2021
    2122        $isConnected = $storeService->hasCompleteConnection();
     23        $isWooCommerce = $storeService->getPlatform() === 'woocommerce';
     24        $wasCommerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     25        $wasConnected = $isConnected;
    2226
    2327        if (
    … …  
    4751        );
    4852
    49         $submitButtonLabel = __('Connect to DropUI', 'dropui');
     53        $connectButtonLabel = $isWooCommerce ? __('Connect your store', 'dropui') : __('Connect to DropUI', 'dropui');
     54        $submitButtonLabel = $connectButtonLabel;
     55
     56        if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && isset($_POST['dropui_save_woo_sms'])) {
     57            $nonce = isset($_POST['dropui_woo_sms_nonce']) ? sanitize_text_field(wp_unslash($_POST['dropui_woo_sms_nonce'])) : '';
     58            if (!current_user_can('manage_options') || !wp_verify_nonce($nonce, 'dropui_save_woo_sms') ||
     59                !$isConnected || !$storeService->hasCommerceSync()) {
     60                $result = ['status' => 'error', 'message' => __('Form security check failed.', 'dropui')];
     61            } else {
     62                update_option(WooCommerceSmsConsent::OPTION, isset($_POST['dropui_woo_sms_checkout']) ? '1' : '0', false);
     63                $result = ['status' => 'success', 'message' => __('Settings saved.', 'dropui')];
     64            }
     65        }
     66
     67        if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && isset($_POST['dropui_save_mailpoet'])) {
     68            $nonce = isset($_POST['dropui_mailpoet_nonce']) ? sanitize_text_field(wp_unslash($_POST['dropui_mailpoet_nonce'])) : '';
     69            if (!current_user_can('manage_options') || !wp_verify_nonce($nonce, 'dropui_save_mailpoet') ||
     70                !$isConnected || !$storeService->hasCommerceSync() || !class_exists('MailPoet\\API\\API')) {
     71                $result = ['status' => 'error', 'message' => __('Form security check failed.', 'dropui')];
     72            } elseif (isset($_POST['dropui_mailpoet_sync']) && !isset($_POST['dropui_mailpoet_confirm'])) {
     73                $result = ['status' => 'error', 'message' => __('Confirm the marketing permission before enabling synchronization.', 'dropui')];
     74            } else {
     75                $enabled = isset($_POST['dropui_mailpoet_sync']);
     76                update_option('dropui_mailpoet_sync_enabled', $enabled ? '1' : '0', false);
     77                $result = ['status' => 'success', 'message' => __('Settings saved.', 'dropui')];
     78            }
     79        }
    5080
    5181        if ($isConnected) {
    5282            $submitButtonLabel = __('Open DropUI dashboard', 'dropui');
     83            if ($isWooCommerce && !$storeService->hasCommerceSync()) {
     84                $submitButtonLabel = __('Open DropUI and start synchronization', 'dropui');
     85            }
    5386        } elseif ($isConnectionIncomplete) {
    5487            $submitButtonLabel = __('Reconnect to DropUI', 'dropui');
    … …  
    83116                    $isConnected = false;
    84117                    $isConnectionIncomplete = false;
    85                     $submitButtonLabel = __('Connect to DropUI', 'dropui');
     118                    $submitButtonLabel = $connectButtonLabel;
    86119                }
    87120            }
    … …  
    119152
    120153                if (($result['status'] ?? '') === 'redirect' && !empty($result['redirect_url'])) {
    121                     wp_add_inline_script(
    122                         'dropui-admin',
    123                         'window.location.href = ' . wp_json_encode($result['redirect_url']) . ';'
    124                     );
     154                    $commerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     155                    ExchangeCallbackHandler::enqueueCompletionScript();
    125156
    126157                    ?>
    127                     <div class="wrap dropui-admin" data-dropui-admin>
    128                         <h1>DropUI</h1>
    129                         <div class="dropui-connection">
    130                             <h2><?php esc_html_e('Redirecting to DropUI...', 'dropui'); ?></h2>
    131                             <p>
    132                                 <a class="button button-primary" href="<?php echo esc_url($result['redirect_url']); ?>">
    133                                     <?php esc_html_e('Open DropUI', 'dropui'); ?>
    134                                 </a>
    135                             </p>
    136                         </div>
     158                    <div
     159                        class="wrap dropui-admin"
     160                        data-dropui-exchange-callback
     161                        data-dropui-redirect-url="<?php echo esc_url($result['redirect_url']); ?>"
     162                        data-dropui-refresh-tabs="<?php echo esc_attr($wasCommerceSyncEnabled !== $commerceSyncEnabled ? '1' : '0'); ?>"
     163                    >
     164                        <h1><?php esc_html_e('Redirecting to DropUI...', 'dropui'); ?></h1>
     165                        <p>
     166                            <a class="dropui-button dropui-button--primary" href="<?php echo esc_url($result['redirect_url']); ?>">
     167                                <?php esc_html_e('Open DropUI', 'dropui'); ?>
     168                            </a>
     169                        </p>
    137170                    </div>
    138171                    <?php
    … …  
    145178            ? sanitize_text_field(wp_unslash($_GET['dropui_status']))
    146179            : '';
     180        if (!empty($result['notice'])) {
     181            $dropuiStatus = $result['notice'];
     182            $submitButtonLabel = __('Open DropUI and start synchronization', 'dropui');
     183        }
    147184
    148185        $dropuiStatusMessages = [
    149186            'connected' => [
    150                 'class' => 'notice-success',
     187                'tone' => 'success',
    151188                'message' => __('The WordPress site has been connected to DropUI.', 'dropui'),
    152189            ],
    153190            'connected_login_failed' => [
    154                 'class' => 'notice-warning',
     191                'tone' => 'warning',
    155192                'message' => __('The WordPress site has been connected to DropUI, but automatic login failed. Try going to DropUI again.', 'dropui'),
    156193            ],
     194            DropuiService::WOOCOMMERCE_SCOPE_CONFLICT => [
     195                'tone' => 'error',
     196                'message' => __('This domain already has a WooCommerce store connected to DropUI. Use a separate domain or subdomain for this store.', 'dropui'),
     197            ],
     198            DropuiService::WOOCOMMERCE_BRIDGE_UNAVAILABLE => [
     199                'tone' => 'error',
     200                'message' => __('WooCommerce synchronization could not start. Try again or contact your account manager.', 'dropui'),
     201            ],
    157202            'missing_exchange_params' => [
    158                 'class' => 'notice-error',
     203                'tone' => 'error',
    159204                'message' => __('The callback data from DropUI is missing.', 'dropui'),
    160205            ],
    161206            'store_mismatch' => [
    162                 'class' => 'notice-error',
     207                'tone' => 'error',
    163208                'message' => __('The site identifier does not match this WordPress site.', 'dropui'),
    164209            ],
    165210            'exchange_failed' => [
    166                 'class' => 'notice-error',
     211                'tone' => 'error',
    167212                'message' => __('Could not retrieve complete connection data from DropUI.', 'dropui'),
    168213            ],
    … …  
    170215
    171216        $dropuiStatusNotice = $dropuiStatusMessages[$dropuiStatus] ?? null;
    172         $isPolish = substr(determine_locale(), 0, 2) === 'pl';
    173         $pricingUrl = $isPolish ? 'https://dropui.com/pl/cennik' : 'https://dropui.com/en/pricing';
    174         $scenariosUrl = $isPolish ? 'https://dropui.com/pl/scenariusze' : 'https://dropui.com/en/scenarios';
    175217        $formUrl = admin_url('admin.php?page=dropui');
    176         $iconUrl = plugins_url('assets/images/dropui-icon.png', dirname(__DIR__, 2) . '/dropui-wordpress-app.php');
     218        $pluginFile = dirname(__DIR__, 2) . '/dropui-wordpress-app.php';
     219        $logoUrl = plugins_url('assets/images/dropui-logo.svg', $pluginFile);
     220        $panelIconsUrl = plugins_url('assets/images/panel-icons.svg', $pluginFile);
     221        $accountManagerName = 'Kornel Szwaja';
     222        $accountManagerPhotoUrl = plugins_url('assets/images/kornel-szwaja.png', $pluginFile);
     223        $commerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     224        $connectionChanged = $wasConnected !== $isConnected || $wasCommerceSyncEnabled !== $commerceSyncEnabled;
     225        if ($connectionChanged) {
     226            ExchangeCallbackHandler::enqueueCompletionScript();
     227        }
    177228
    178229        if ($isConnected) {
    179230            $connectionState = 'connected';
    180             $statusLabel = __('Connected', 'dropui');
    181             $heading = __('Your website is connected', 'dropui');
    182             $summary = __('Open the DropUI dashboard to create and publish campaigns.', 'dropui');
     231            $heading = $isWooCommerce && $commerceSyncEnabled
     232                ? __('Your WooCommerce store is connected', 'dropui')
     233                : __('Your WordPress site is connected', 'dropui');
     234            $summary = '';
    183235        } elseif ($isConnectionIncomplete) {
    184236            $connectionState = 'incomplete';
    185             $statusLabel = __('Connection incomplete', 'dropui');
    186237            $heading = __('Complete your connection', 'dropui');
    187238            $summary = __('Some connection details are missing. Your website is not fully connected to DropUI yet.', 'dropui');
    188239        } else {
    189240            $connectionState = 'disconnected';
    190             $statusLabel = __('Not connected', 'dropui');
    191             $heading = __('Connect your website', 'dropui');
    192             $summary = __('Sign in or create a free DropUI account to connect your website.', 'dropui');
     241            $heading = $isWooCommerce
     242                ? __('Grow sales in your WooCommerce store', 'dropui')
     243                : __('Collect contacts on your WordPress site', 'dropui');
     244            $summary = $isWooCommerce
     245                ? __('Connect your store to DropUI to recommend products based on purchase history and encourage repeat orders.', 'dropui')
     246                : __('Add a newsletter signup form. You will see new signups in DropUI.', 'dropui');
    193247        }
    194248
    … …  
    197251            class="wrap dropui-admin"
    198252            data-dropui-admin
     253            <?php if ($connectionChanged): ?>data-dropui-exchange-callback<?php endif; ?>
    199254            data-connection-state="<?php echo esc_attr($connectionState); ?>"
    200255            data-refresh-opener="<?php echo esc_attr(in_array($dropuiStatus, ['connected', 'connected_login_failed'], true) ? '1' : '0'); ?>"
    201256        >
    202257            <header class="dropui-intro">
    203                 <h1 class="dropui-brand">
    204                     <img src="<?php echo esc_url($iconUrl); ?>" width="40" height="40" alt="">
    205                     <span><?php esc_html_e('DropUI - More Sales from the Traffic You Already Have', 'dropui'); ?></span>
    206                 </h1>
    207                 <p class="dropui-intro-summary"><?php esc_html_e('Capture leads, recover abandoned carts and grow sales. Reach visitors with relevant offers while they browse your site and after they leave.', 'dropui'); ?></p>
     258                <img class="dropui-brand" src="<?php echo esc_url($logoUrl); ?>" width="100" height="30" alt="DropUI">
     259                <h1><?php echo esc_html($heading); ?></h1>
     260                <?php if ($summary !== ''): ?>
     261                    <p class="dropui-intro-summary"><?php echo esc_html($summary); ?></p>
     262                <?php endif; ?>
    208263            </header>
    209264
    210265            <?php if ($dropuiStatusNotice): ?>
    211                 <div class="notice <?php echo esc_attr($dropuiStatusNotice['class']); ?> is-dismissible">
     266                <div class="dropui-feedback dropui-feedback--<?php echo esc_attr($dropuiStatusNotice['tone']); ?>" role="status">
    212267                    <p><?php echo esc_html($dropuiStatusNotice['message']); ?></p>
    213268                </div>
    … …  
    215270
    216271            <?php if ($hasAdminEmailChanged): ?>
    217                 <div class="notice notice-warning">
     272                <div class="dropui-feedback dropui-feedback--warning" role="status">
     273                    <p><?php esc_html_e('The WordPress administrator email address has changed since the site was connected to DropUI.', 'dropui'); ?></p>
    218274                    <p>
    219                         <strong><?php esc_html_e('Warning:', 'dropui'); ?></strong>
    220                         <?php esc_html_e('The WordPress administrator email address has changed since the site was connected to DropUI.', 'dropui'); ?>
     275                        <?php esc_html_e('Email used when connecting:', 'dropui'); ?>
     276                        <strong><?php echo esc_html($connectedAdminEmail); ?></strong>
    221277                    </p>
    222278                    <p>
    223                         <?php esc_html_e('Email used when connecting:', 'dropui'); ?>
    224                         <strong><?php echo esc_html($connectedAdminEmail); ?></strong><br>
    225279                        <?php esc_html_e('Current WordPress email:', 'dropui'); ?>
    226280                        <strong><?php echo esc_html($currentAdminEmail); ?></strong>
    227281                    </p>
    228                     <p>
    229                         <?php esc_html_e('If this change was intentional, disconnect the integration and reconnect the WordPress site.', 'dropui'); ?>
    230                     </p>
     282                    <p><?php esc_html_e('If this change was intentional, disconnect the integration and reconnect the WordPress site.', 'dropui'); ?></p>
    231283                </div>
    232284            <?php endif; ?>
    233285
    234286            <?php if ($result && !empty($result['message'])): ?>
    235                 <div class="notice <?php echo esc_attr(($result['status'] ?? '') === 'error' ? 'notice-error' : 'notice-success'); ?> is-dismissible">
     287                <?php $resultIsError = ($result['status'] ?? '') === 'error'; ?>
     288                <div class="dropui-feedback dropui-feedback--<?php echo esc_attr($resultIsError ? 'error' : 'success'); ?>" role="<?php echo esc_attr($resultIsError ? 'alert' : 'status'); ?>">
    236289                    <p><?php echo esc_html($result['message']); ?></p>
    237290                </div>
    238291            <?php endif; ?>
    239292
    240             <section class="dropui-connection" aria-labelledby="dropui-heading">
    241                 <div class="dropui-connection-main">
    242                     <p class="dropui-status dropui-status--<?php echo esc_attr($connectionState); ?>">
    243                         <span class="dashicons <?php echo esc_attr($isConnected ? 'dashicons-yes-alt' : 'dashicons-admin-links'); ?>" aria-hidden="true"></span>
    244                         <?php echo esc_html($statusLabel); ?>
    245                     </p>
    246                     <h2 id="dropui-heading"><?php echo esc_html($heading); ?></h2>
    247                     <?php if ($summary): ?>
    248                         <p class="dropui-summary"><?php echo esc_html($summary); ?></p>
     293            <div class="dropui-page-flow">
     294                <section class="dropui-section" aria-labelledby="dropui-site-heading">
     295                    <h2 id="dropui-site-heading"><?php echo esc_html($isWooCommerce ? __('Your store', 'dropui') : __('Website', 'dropui')); ?></h2>
     296                    <dl class="dropui-columns dropui-data-fields">
     297                        <div>
     298                            <dt><?php esc_html_e('Site name', 'dropui'); ?></dt>
     299                            <dd><?php echo esc_html(get_bloginfo('name')); ?></dd>
     300                        </div>
     301                        <div>
     302                            <dt><?php esc_html_e('Site address', 'dropui'); ?></dt>
     303                            <dd><?php echo esc_html(home_url('/')); ?></dd>
     304                        </div>
     305                    </dl>
     306
     307                    <?php if ($isWooCommerce && !$commerceSyncEnabled): ?>
     308                        <?php if ($isConnected): ?>
     309                            <p class="dropui-sync-help"><?php esc_html_e('Start synchronization to import products, orders and customer contact details.', 'dropui'); ?></p>
     310                        <?php else: ?>
     311                            <div class="dropui-woo-summary">
     312                                <p>
     313                                    <strong><?php esc_html_e('WooCommerce detected.', 'dropui'); ?></strong>
     314                                    <?php esc_html_e('After you connect, DropUI imports products, orders and customer contact details.', 'dropui'); ?>
     315                                </p>
     316                            </div>
     317                        <?php endif; ?>
    249318                    <?php endif; ?>
    250319
    251                     <dl class="dropui-site">
    252                         <dt><?php esc_html_e('Website', 'dropui'); ?></dt>
    253                         <dd><?php echo esc_html(get_bloginfo('name')); ?></dd>
    254                         <dd class="dropui-site-url"><?php echo esc_html(home_url('/')); ?></dd>
    255                     </dl>
    256 
    257                     <form action="<?php echo esc_url($formUrl); ?>" method="post" target="_blank">
    258                         <?php wp_nonce_field('dropui_connect_store', 'dropui_nonce'); ?>
    259                         <input type="hidden" name="connect_store" value="1">
    260                         <button class="button button-primary dropui-connect-button" type="submit" aria-describedby="<?php echo esc_attr($isConnected ? 'dropui-connection-note' : 'dropui-free-note dropui-connection-note'); ?>">
    261                             <?php echo esc_html($submitButtonLabel); ?>
    262                             <span class="dashicons dashicons-external" aria-hidden="true"></span>
    263                         </button>
    264                         <?php if (!$isConnected): ?>
    265                             <p class="dropui-free" id="dropui-free-note"><span class="dashicons dashicons-yes" aria-hidden="true"></span><?php esc_html_e('No credit card required', 'dropui'); ?></p>
     320                    <div class="dropui-connection-actions">
     321                        <form action="<?php echo esc_url($formUrl); ?>" method="post" target="_blank">
     322                            <?php wp_nonce_field('dropui_connect_store', 'dropui_nonce'); ?>
     323                            <input type="hidden" name="connect_store" value="1">
     324                            <button class="dropui-button dropui-button--primary dropui-connect-button" type="submit" aria-describedby="dropui-connection-note">
     325                                <?php echo esc_html($submitButtonLabel); ?>
     326                            </button>
     327                            <span class="screen-reader-text" id="dropui-connection-note">
     328                                <?php esc_html_e('Opens in a new tab. Your WordPress panel stays open.', 'dropui'); ?>
     329                            </span>
     330                        </form>
     331                        <?php if ($isConnected): ?>
     332                            <form action="<?php echo esc_url($formUrl); ?>" method="post">
     333                                <?php wp_nonce_field('dropui_disconnect_store', 'dropui_disconnect_nonce'); ?>
     334                                <button type="submit" name="disconnect_store" value="1" class="dropui-button dropui-button--disconnect"
     335                                    data-dropui-disconnect-confirm="<?php esc_attr_e('Are you sure you want to disconnect this WordPress site from your DropUI account?', 'dropui'); ?>">
     336                                    <?php esc_html_e('Disconnect DropUI integration', 'dropui'); ?>
     337                                </button>
     338                            </form>
    266339                        <?php endif; ?>
    267                         <p class="description" id="dropui-connection-note">
    268                             <?php esc_html_e('Opens in a new tab. Your WordPress panel stays open.', 'dropui'); ?>
    269                         </p>
    270                     </form>
    271                 </div>
    272 
    273                 <aside class="dropui-account" aria-labelledby="dropui-account-heading">
    274                     <?php if ($isConnected): ?>
    275                         <h3 id="dropui-account-heading"><?php esc_html_e('Campaigns and results', 'dropui'); ?></h3>
    276                         <ul class="dropui-checklist">
    277                             <li><span class="dashicons dashicons-layout" aria-hidden="true"></span><?php esc_html_e('Campaign editor and AI Assistant', 'dropui'); ?></li>
    278                             <li><span class="dashicons dashicons-filter" aria-hidden="true"></span><?php esc_html_e('Audiences and display rules', 'dropui'); ?></li>
    279                             <li><span class="dashicons dashicons-chart-bar" aria-hidden="true"></span><?php esc_html_e('Statistics and A/B tests', 'dropui'); ?></li>
    280                         </ul>
    281                     <?php else: ?>
    282                         <h3 id="dropui-account-heading"><?php esc_html_e('Start with the Free plan', 'dropui'); ?></h3>
    283                         <p class="description"><?php esc_html_e('Free plan limits apply. WhatsApp is billed separately.', 'dropui'); ?></p>
    284                     <?php endif; ?>
    285                     <a href="<?php echo esc_url($pricingUrl); ?>" target="_blank" rel="noopener noreferrer">
    286                         <?php esc_html_e('Plans and limits', 'dropui'); ?>
    287                         <span class="screen-reader-text"><?php esc_html_e('(opens in a new tab)', 'dropui'); ?></span>
    288                     </a>
    289                 </aside>
    290             </section>
    291 
    292             <div class="dropui-guidance">
    293                 <section aria-labelledby="dropui-first-campaign-heading">
    294                     <h2 id="dropui-first-campaign-heading"><?php esc_html_e('Start with one campaign', 'dropui'); ?></h2>
    295                     <?php if (!$isConnected): ?>
    296                         <p><?php esc_html_e('After connecting your website, you will create and publish campaigns in the DropUI dashboard.', 'dropui'); ?></p>
    297                     <?php endif; ?>
    298                     <p>
    299                         <?php
    300                         /* translators: %s: link to the ready-made campaign scenarios. */
    301                         printf(
    302                             esc_html__('Choose a %s, use the AI Assistant or create your own campaign. Based on your description, the Assistant suggests copy, a layout and calls to action.', 'dropui'),
    303                             '<a href="' . esc_url($scenariosUrl) . '" target="_blank" rel="noopener noreferrer">'
    304                             . esc_html__('ready-made scenario', 'dropui')
    305                             . '<span class="screen-reader-text"> ' . esc_html__('(opens in a new tab)', 'dropui') . '</span></a>'
    306                         );
    307                         ?>
    308                     </p>
     340                    </div>
    309341                </section>
    310                 <section aria-labelledby="dropui-onboarding-heading">
    311                     <h2 id="dropui-onboarding-heading"><?php esc_html_e('Help from an onboarding specialist', 'dropui'); ?></h2>
    312                     <p><?php esc_html_e('On the Start plan and above, a specialist helps you set up DropUI, create and launch campaigns, and review results. You also get advice on improvements and next steps.', 'dropui'); ?></p>
     342
     343                <?php if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && $commerceSyncEnabled): ?>
     344                    <section class="dropui-section" aria-labelledby="dropui-consents-heading">
     345                        <h2 id="dropui-consents-heading"><?php esc_html_e('Marketing consents', 'dropui'); ?></h2>
     346                        <div class="dropui-columns dropui-settings">
     347                            <form method="post" aria-labelledby="dropui-sms-heading">
     348                                <h3 id="dropui-sms-heading"><?php esc_html_e('SMS at checkout', 'dropui'); ?></h3>
     349                                <?php wp_nonce_field('dropui_save_woo_sms', 'dropui_woo_sms_nonce'); ?>
     350                                <label class="dropui-check">
     351                                    <input type="checkbox" name="dropui_woo_sms_checkout" value="1" <?php checked(get_option(WooCommerceSmsConsent::OPTION), '1'); ?>>
     352                                    <span><?php esc_html_e('Ask for SMS marketing consent at checkout', 'dropui'); ?></span>
     353                                </label>
     354                                <p class="dropui-help"><?php esc_html_e('Customers decide whether to subscribe. DropUI supports Polish phone numbers for SMS marketing.', 'dropui'); ?></p>
     355                                <?php if (!function_exists('woocommerce_register_additional_checkout_field')): ?>
     356                                    <p class="dropui-help"><?php esc_html_e('Update WooCommerce to collect SMS consent in the Checkout block.', 'dropui'); ?></p>
     357                                <?php endif; ?>
     358                                <button type="submit" name="dropui_save_woo_sms" value="1" class="dropui-button"><?php esc_html_e('Save SMS settings', 'dropui'); ?></button>
     359                            </form>
     360
     361                            <?php if (class_exists('MailPoet\\API\\API')): ?>
     362                                <form method="post" aria-labelledby="dropui-mailpoet-heading">
     363                                    <h3 id="dropui-mailpoet-heading"><?php esc_html_e('Email from MailPoet', 'dropui'); ?></h3>
     364                                    <?php wp_nonce_field('dropui_save_mailpoet', 'dropui_mailpoet_nonce'); ?>
     365                                    <label class="dropui-check">
     366                                        <input type="checkbox" name="dropui_mailpoet_sync" value="1" <?php checked(get_option('dropui_mailpoet_sync_enabled'), '1'); ?>>
     367                                        <span><?php esc_html_e('Synchronize MailPoet newsletter subscriptions', 'dropui'); ?></span>
     368                                    </label>
     369                                    <label class="dropui-check">
     370                                        <input type="checkbox" name="dropui_mailpoet_confirm" value="1">
     371                                        <span><?php esc_html_e('I confirm that these lists contain permission to send this store’s marketing emails.', 'dropui'); ?></span>
     372                                    </label>
     373                                    <button type="submit" name="dropui_save_mailpoet" value="1" class="dropui-button"><?php esc_html_e('Save MailPoet settings', 'dropui'); ?></button>
     374                                </form>
     375                            <?php endif; ?>
     376                        </div>
     377                    </section>
     378                <?php endif; ?>
     379            </div>
     380
     381            <details class="dropui-account-manager" data-dropui-account-manager>
     382                <summary class="dropui-button dropui-account-manager__trigger" aria-controls="dropui-account-manager-card">
     383                    <img src="<?php echo esc_url($accountManagerPhotoUrl); ?>" alt="" width="44" height="44">
     384                    <span class="dropui-account-manager__identity">
     385                        <strong><?php echo esc_html($accountManagerName); ?></strong>
     386                        <span><?php esc_html_e('Your account manager', 'dropui'); ?></span>
     387                    </span>
     388                </summary>
     389                <section class="dropui-account-manager__card" id="dropui-account-manager-card" aria-labelledby="dropui-account-manager-name">
     390                    <header class="dropui-account-manager__header">
     391                        <img src="<?php echo esc_url($accountManagerPhotoUrl); ?>" alt="" width="48" height="48">
     392                        <h2 id="dropui-account-manager-name"><?php echo esc_html($accountManagerName); ?></h2>
     393                    </header>
     394                    <p><?php esc_html_e('I can help you connect your store, choose a plan or launch a campaign. Email me.', 'dropui'); ?></p>
     395                    <div class="dropui-account-manager__links">
     396                        <a href="mailto:kornel@dropui.com">
     397                            <svg class="dropui-icon" width="20" height="20" aria-hidden="true" focusable="false">
     398                                <use href="<?php echo esc_url($panelIconsUrl . '#email'); ?>"></use>
     399                            </svg>
     400                            <span>kornel@dropui.com</span>
     401                        </a>
     402                    </div>
    313403                </section>
    314             </div>
    315 
    316             <footer class="dropui-support">
    317                 <div>
    318                     <h2><?php esc_html_e('Support', 'dropui'); ?></h2>
    319                     <a href="mailto:support@dropui.com">support@dropui.com</a>
    320                 </div>
    321                 <?php if ($isConnected): ?>
    322                     <form action="<?php echo esc_url($formUrl); ?>" method="post">
    323                         <?php wp_nonce_field('dropui_disconnect_store', 'dropui_disconnect_nonce'); ?>
    324                         <?php submit_button(
    325                             __('Disconnect DropUI integration', 'dropui'),
    326                             'secondary',
    327                             'disconnect_store',
    328                             false,
    329                             [
    330                                 'data-dropui-disconnect-confirm' => __('Are you sure you want to disconnect this WordPress site from your DropUI account?', 'dropui'),
    331                             ]
    332                         ); ?>
    333                     </form>
    334                 <?php endif; ?>
    335             </footer>
     404            </details>
    336405        </div>
    337406        <?php
  • dropui/tags/1.0.7/src/Admin/ExchangeCallbackHandler.php

    r3664245 r3840376  
    88class ExchangeCallbackHandler
    99{
     10    public static function enqueueCompletionScript(): void
     11    {
     12        wp_enqueue_script(
     13            'dropui-exchange-callback',
     14            plugins_url('assets/js/exchange-callback.js', dirname(__DIR__, 2) . '/dropui-wordpress-app.php'),
     15            [],
     16            DROPUI_VERSION,
     17            true
     18        );
     19    }
     20
    1021    public function handle(): void
    1122    {
    … …  
    7485        }
    7586
    76         $this->redirectWithStatus('connected_login_failed');
     87        $this->redirectWithStatus($loginResult['notice'] ?? 'connected_login_failed');
    7788    }
    7889
    … …  
    8091    {
    8192        $safeRedirectUrl = esc_url_raw($redirectUrl);
     93        self::enqueueCompletionScript();
    8294
    8395        header('Content-Type: text/html; charset=' . get_option('blog_charset'));
  • dropui/tags/1.0.7/src/Frontend/MasterScriptLoader.php

    r3664245 r3840376  
    3737            ]
    3838        );
     39        if ($storeService->hasCommerceSync()) {
     40            $path = wp_parse_url(get_site_url(), PHP_URL_PATH);
     41            $cookiePath = '/' . trim((string) $path, '/');
     42            $config = [
     43                'storeId' => $storeService->getConnectedStoreId(),
     44                'cart' => rest_url('wc/store/v1/cart'),
     45                'add' => rest_url('wc/store/v1/cart/add-item'),
     46                'cartPage' => wc_get_cart_url(),
     47                'cookiePath' => $cookiePath === '/' ? '/' : $cookiePath . '/',
     48                'consentApiAvailable' => function_exists('wp_has_consent'),
     49                'orderId' => is_order_received_page() ? absint(get_query_var('order-received')) : 0,
     50                'productId' => is_product() ? get_queried_object_id() : 0,
     51            ];
     52            wp_add_inline_script(
     53                self::SCRIPT_HANDLE,
     54                'window.__dropuiWooCommerce = ' . wp_json_encode($config) . ';',
     55                'before'
     56            );
     57        }
    3958    }
    4059}
  • dropui/tags/1.0.7/src/Service/DropuiService.php

    r3687292 r3840376  
    55class DropuiService
    66{
     7    public const WOOCOMMERCE_SCOPE_CONFLICT = 'woocommerce_scope_conflict';
     8    public const WOOCOMMERCE_BRIDGE_UNAVAILABLE = 'woocommerce_bridge_unavailable';
     9
    710    private function getConfig(): array
    811    {
    … …  
    315318        // The backend verifies it with a second signature over the same
    316319        // message extended by a version marker and the platform value.
    317         $platform = (new StoreService())->getPlatform();
     320        $storeService = new StoreService();
     321        $platform = $storeService->getPlatform();
    318322        $platformSignature = hash_hmac(
    319323            'sha256',
    … …  
    331335            'platform_signature' => $platformSignature,
    332336        ];
     337        if ($platform === 'woocommerce') {
     338            $payload['commerce_bridge'] = '1';
     339            $payload['commerce_bridge_signature'] = hash_hmac(
     340                'sha256',
     341                $message . "\n2\n" . $platform . "\ncommerce_bridge:1",
     342                $authSecret
     343            );
     344        }
    333345
    334346        $response = wp_remote_post(
    … …  
    362374                'login_url' => $loginUrl,
    363375                'raw_body' => $body,
     376            ];
     377        }
     378
     379        $code = $data['code'] ?? '';
     380        if ($httpCode === 409 && in_array($code, [self::WOOCOMMERCE_SCOPE_CONFLICT, self::WOOCOMMERCE_BRIDGE_UNAVAILABLE], true)) {
     381            $storeService->disableCommerceSync();
     382            return [
     383                'status' => 'error',
     384                'notice' => $code,
    364385            ];
    365386        }
    … …  
    383404            }
    384405
     406            if ($platform === 'woocommerce') {
     407                if (($data['commerce_bridge_ready'] ?? null) === true) {
     408                    $storeService->enableCommerceSync();
     409                } elseif (array_key_exists('commerce_bridge_ready', $data) || !$storeService->hasCommerceSync()) {
     410                    $storeService->disableCommerceSync();
     411                    return [
     412                        'status' => 'error',
     413                        'notice' => self::WOOCOMMERCE_BRIDGE_UNAVAILABLE,
     414                    ];
     415                }
     416            } else {
     417                $storeService->disableCommerceSync();
     418            }
     419
    385420            return [
    386421                'status' => 'redirect',
  • dropui/tags/1.0.7/src/Service/StoreService.php

    r3687292 r3840376  
    55class StoreService
    66{
     7    // The base WooCommerce integration synchronizes store data only.
     8    public const WOO_MARKETING_CONSENTS_ENABLED = false;
     9
    710    private const AUTH_SECRET_PREFIX = 'dropui_encrypted_v1:';
    811    private const AUTH_SECRET_CIPHER = 'aes-256-cbc';
    … …  
    3841    }
    3942
     43    public function hasCommerceSync(): bool
     44    {
     45        return class_exists('WooCommerce') && get_option('dropui_commerce_sync_enabled') === '1';
     46    }
     47
     48    public function enableCommerceSync(): void
     49    {
     50        if (class_exists('WooCommerce')) {
     51            update_option('dropui_commerce_sync_enabled', '1', false);
     52        }
     53    }
     54
     55    public function disableCommerceSync(): void
     56    {
     57        delete_option('dropui_commerce_sync_enabled');
     58    }
     59
    4060    public function getStoreId(): ?string
    4161    {
    … …  
    112132    public function clearConnection(): void
    113133    {
     134        delete_option('dropui_mailpoet_sync_enabled');
     135        delete_option(WooCommerceSmsConsent::OPTION);
     136        $this->disableCommerceSync();
    114137        delete_option('dropui_auth_secret');
    115138        delete_option('dropui_connected_store_id');
    … …  
    123146
    124147        delete_option('dropui_store_id');
     148
     149        global $wpdb;
     150        $wpdb->query($wpdb->prepare(
     151            "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
     152            $wpdb->esc_like(WooCommerceBridge::REQUEST_NONCE_PREFIX) . '%'
     153        ));
    125154    }
    126155
  • dropui/tags/1.0.7/vendor/autoload.php

    r3670371 r3840376  
    1515        }
    1616    }
    17     throw new RuntimeException($err);
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
    1821}
    1922
    2023require_once __DIR__ . '/composer/autoload_real.php';
    2124
    22 return ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a::getLoader();
     25return ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf::getLoader();
  • dropui/tags/1.0.7/vendor/composer/LICENSE

    r3664245 r3840376  
    1 
    21Copyright (c) Nils Adermann, Jordi Boggiano
    32
    … …  
    1918OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2019THE SOFTWARE.
    21 
  • dropui/tags/1.0.7/vendor/composer/autoload_classmap.php

    r3664245 r3840376  
    1212    'DropUI\\Frontend\\MasterScriptLoader' => $baseDir . '/src/Frontend/MasterScriptLoader.php',
    1313    'DropUI\\Service\\DropuiService' => $baseDir . '/src/Service/DropuiService.php',
     14    'DropUI\\Service\\MailPoetConsent' => $baseDir . '/src/Service/MailPoetConsent.php',
    1415    'DropUI\\Service\\StoreService' => $baseDir . '/src/Service/StoreService.php',
     16    'DropUI\\Service\\WooCommerceBridge' => $baseDir . '/src/Service/WooCommerceBridge.php',
     17    'DropUI\\Service\\WooCommerceSmsConsent' => $baseDir . '/src/Service/WooCommerceSmsConsent.php',
    1518);
  • dropui/tags/1.0.7/vendor/composer/autoload_real.php

    r3670371 r3840376  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a
     5class ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf
    66{
    77    private static $loader;
    … …  
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • dropui/tags/1.0.7/vendor/composer/autoload_static.php

    r3670371 r3840376  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a
     7class ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf
    88{
    99    public static $prefixLengthsPsr4 = array (
    10         'D' =>
     10        'D' => 
    1111        array (
    1212            'DropUI\\' => 7,
    … …  
    1515
    1616    public static $prefixDirsPsr4 = array (
    17         'DropUI\\' =>
     17        'DropUI\\' => 
    1818        array (
    1919            0 => __DIR__ . '/../..' . '/src',
    … …  
    2727        'DropUI\\Frontend\\MasterScriptLoader' => __DIR__ . '/../..' . '/src/Frontend/MasterScriptLoader.php',
    2828        'DropUI\\Service\\DropuiService' => __DIR__ . '/../..' . '/src/Service/DropuiService.php',
     29        'DropUI\\Service\\MailPoetConsent' => __DIR__ . '/../..' . '/src/Service/MailPoetConsent.php',
    2930        'DropUI\\Service\\StoreService' => __DIR__ . '/../..' . '/src/Service/StoreService.php',
     31        'DropUI\\Service\\WooCommerceBridge' => __DIR__ . '/../..' . '/src/Service/WooCommerceBridge.php',
     32        'DropUI\\Service\\WooCommerceSmsConsent' => __DIR__ . '/../..' . '/src/Service/WooCommerceSmsConsent.php',
    3033    );
    3134
    … …  
    3336    {
    3437        return \Closure::bind(function () use ($loader) {
    35             $loader->prefixLengthsPsr4 = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$prefixLengthsPsr4;
    36             $loader->prefixDirsPsr4 = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$prefixDirsPsr4;
    37             $loader->classMap = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$classMap;
     38            $loader->prefixLengthsPsr4 = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$prefixLengthsPsr4;
     39            $loader->prefixDirsPsr4 = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$prefixDirsPsr4;
     40            $loader->classMap = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$classMap;
    3841
    3942        }, null, ClassLoader::class);
  • dropui/trunk/assets/css/admin.css

    r3689562 r3840376  
     1body.toplevel_page_dropui {
     2    --dropui-account-manager-width: 320px;
     3    background: #fff;
     4}
     5
    16.dropui-admin {
    2     max-width: 1080px;
    3     color: #1d2327;
    4     letter-spacing: 0;
    5 }
    6 
    7 .dropui-admin:lang(ko) {
    8     word-break: keep-all;
     7    --dropui-ink: #202124;
     8    --dropui-muted: #62666d;
     9    --dropui-surface: #fff;
     10    --dropui-hover: #f0f1f3;
     11    --dropui-border: #e2e4e8;
     12    --dropui-control-border: #d4d7dc;
     13    --dropui-control-hover: #b5bac3;
     14    --dropui-primary-hover: #383b40;
     15    --dropui-focus: #2463b3;
     16    --dropui-focus-ring: rgb(36 99 179 / 12%);
     17    --dropui-error: #b42332;
     18    --dropui-whatsapp-brand: #25d366;
     19    --dropui-shadow: 0 12px 36px rgb(24 30 40 / 14%);
     20    max-width: 960px;
     21    margin: 0 auto;
     22    padding: 76px 32px 64px;
     23    color: var(--dropui-ink);
     24    font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
     25    overflow-wrap: anywhere;
    926}
    1027
    … …  
    1532}
    1633
     34.dropui-admin:lang(ko) {
     35    word-break: keep-all;
     36}
     37
     38.dropui-admin h1,
     39.dropui-admin h2,
     40.dropui-admin h3,
     41.dropui-admin p {
     42    margin: 0;
     43    padding: 0;
     44    color: inherit;
     45    line-height: inherit;
     46}
     47
     48.dropui-admin h1 {
     49    max-width: 720px;
     50    font-size: 32px;
     51    font-weight: 500;
     52    line-height: 1.25;
     53    letter-spacing: -.025em;
     54    text-wrap: balance;
     55}
     56
     57.dropui-admin h2 {
     58    font-size: 18px;
     59    font-weight: 600;
     60    line-height: 1.4;
     61    letter-spacing: -.015em;
     62}
     63
     64.dropui-admin h3 {
     65    font-size: 14px;
     66    font-weight: 600;
     67}
     68
     69.dropui-admin p + p {
     70    margin-top: 8px;
     71}
     72
     73.dropui-admin .dropui-help {
     74    color: var(--dropui-muted);
     75    font-size: 12px;
     76}
     77
     78.dropui-admin a:not(.dropui-button) {
     79    color: var(--dropui-ink);
     80    font-weight: 500;
     81    text-underline-offset: 3px;
     82    text-decoration-color: var(--dropui-control-border);
     83}
     84
     85.dropui-admin a:not(.dropui-button):hover {
     86    text-decoration-color: currentColor;
     87}
     88
     89.dropui-admin :is(a, button, input, summary):focus-visible {
     90    outline: 2px solid var(--dropui-focus);
     91    outline-offset: 2px;
     92    box-shadow: 0 0 0 2px var(--dropui-focus-ring);
     93}
     94
    1795.dropui-intro {
    18     padding: 16px 0 24px;
    19 }
    20 
    21 .dropui-admin .dropui-brand {
     96    display: grid;
     97    justify-items: center;
     98    gap: 12px;
     99    margin-bottom: 40px;
     100    text-align: center;
     101}
     102
     103.dropui-brand {
     104    display: block;
     105    object-fit: contain;
     106}
     107
     108.dropui-admin .dropui-intro-summary {
     109    max-width: 62ch;
     110    color: var(--dropui-muted);
     111    line-height: 1.65;
     112    text-wrap: pretty;
     113}
     114
     115.dropui-page-flow {
     116    display: grid;
     117    gap: 32px;
     118}
     119
     120.dropui-section {
     121    display: grid;
     122    align-content: start;
     123    min-width: 0;
     124    gap: 16px;
     125}
     126
     127.dropui-sync-help {
     128    max-width: 70ch;
     129}
     130
     131.dropui-woo-summary {
     132    padding: 16px 18px;
     133    border-radius: 8px;
     134    color: #0b2230;
     135    background-color: #e6f4f9;
     136    background-image: linear-gradient(90deg, #c1e7f9, #d0edf9 14%, #e1f3f9 36%, #e6f4f9 65%, #e4f3f9 78%, #dbeef9 90%, #c5e9f8);
     137    box-shadow: inset 0 0 0 1px rgb(68 131 205 / 32%);
     138}
     139
     140.dropui-admin .dropui-woo-summary p {
     141    font-size: 14px;
     142    line-height: 1.5;
     143}
     144
     145.dropui-woo-summary strong {
     146    font-weight: 600;
     147}
     148
     149@media (max-width: 600px) {
     150    .dropui-woo-summary {
     151        padding: 16px;
     152    }
     153}
     154
     155.dropui-columns {
     156    display: grid;
     157    grid-template-columns: repeat(2, minmax(0, 1fr));
     158    gap: 20px 24px;
     159}
     160
     161.dropui-data-fields {
     162    margin: 0;
     163}
     164
     165.dropui-data-fields > div {
     166    display: grid;
     167    align-content: start;
     168    gap: 6px;
     169}
     170
     171.dropui-data-fields dt {
     172    color: var(--dropui-muted);
     173    font-size: 12px;
     174}
     175
     176.dropui-data-fields dd {
     177    margin: 0;
     178    line-height: 1.6;
     179}
     180
     181.dropui-connection-actions {
     182    display: flex;
     183    flex-wrap: wrap;
     184    align-items: center;
     185    gap: 8px;
     186}
     187
     188.dropui-admin:has(.dropui-account-manager) {
     189    padding-bottom: 92px;
     190}
     191
     192.dropui-account-manager {
     193    position: fixed;
     194    right: max(16px, env(safe-area-inset-right));
     195    bottom: max(16px, env(safe-area-inset-bottom));
     196    left: max(16px, env(safe-area-inset-left));
     197    z-index: 110;
     198    max-width: var(--dropui-account-manager-width);
     199    margin-left: auto;
     200    pointer-events: none;
     201}
     202
     203#wpwrap.wp-responsive-open .dropui-account-manager {
     204    display: none;
     205}
     206
     207.dropui-admin .dropui-button.dropui-account-manager__trigger {
     208    display: flex;
     209    width: fit-content;
     210    min-height: 64px;
     211    gap: 12px;
     212    margin-left: auto;
     213    padding: 9px 20px 9px 9px;
     214    border-color: transparent;
     215    border-radius: 999px;
     216    background: var(--dropui-whatsapp-brand);
     217    box-shadow: var(--dropui-shadow);
     218    list-style: none;
     219    pointer-events: auto;
     220}
     221
     222.dropui-admin .dropui-button.dropui-account-manager__trigger:hover {
     223    border-color: transparent;
     224    background: color-mix(in srgb, var(--dropui-whatsapp-brand) 92%, var(--dropui-ink));
     225}
     226
     227.dropui-account-manager__trigger::-webkit-details-marker {
     228    display: none;
     229}
     230
     231.dropui-account-manager img {
     232    flex: none;
     233    border-radius: 50%;
     234    object-fit: cover;
     235}
     236
     237.dropui-account-manager__identity {
     238    display: grid;
     239    gap: 1px;
     240    font-size: 13px;
     241    line-height: 1.25;
     242    text-align: left;
     243}
     244
     245.dropui-account-manager__identity strong {
     246    font-size: 15px;
     247    font-weight: 600;
     248}
     249
     250.dropui-account-manager__card {
     251    position: absolute;
     252    right: 0;
     253    bottom: calc(100% + 12px);
     254    width: 100%;
     255    max-height: calc(100dvh - 104px - env(safe-area-inset-bottom));
     256    overflow-y: auto;
     257    padding: 16px;
     258    border: 1px solid var(--dropui-border);
     259    border-radius: 12px;
     260    background: var(--dropui-surface);
     261    box-shadow: var(--dropui-shadow);
     262    pointer-events: auto;
     263}
     264
     265.dropui-account-manager__header {
    22266    display: flex;
    23267    align-items: center;
    24268    gap: 12px;
    25     margin: 0;
    26     padding: 0;
    27     font-size: 22px;
    28     font-weight: 600;
    29     line-height: 1.4;
    30     overflow-wrap: anywhere;
    31 }
    32 
    33 .dropui-brand > span {
    34     min-width: 0;
    35 }
    36 
    37 .dropui-admin .dropui-intro-summary {
    38     max-width: 80ch;
    39     margin: 14px 0 0;
    40     color: #50575e;
    41     font-size: 14px;
    42     line-height: 1.7;
    43 }
    44 
    45 .dropui-brand img {
    46     flex: 0 0 40px;
    47     border-radius: 8px;
    48 }
    49 
    50 .dropui-admin h2 {
    51     margin: 0 0 12px;
    52     font-size: 20px;
    53     line-height: 1.4;
    54 }
    55 
    56 .dropui-admin h3 {
    57     margin: 0 0 12px;
    58     font-size: 15px;
    59     line-height: 1.5;
    60 }
    61 
    62 .dropui-admin p,
    63 .dropui-admin dd,
    64 .dropui-admin a,
    65 .dropui-admin h2,
    66 .dropui-admin h3 {
    67     overflow-wrap: anywhere;
    68 }
    69 
    70 .dropui-connection {
    71     display: grid;
    72     grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    73     gap: 40px;
    74     padding: 28px 0 32px;
    75     border-block: 1px solid #c3c4c7;
    76 }
    77 
    78 .dropui-admin .dropui-status {
    79     display: flex;
     269}
     270
     271.dropui-admin .dropui-account-manager__header h2 {
     272    font-size: 16px;
     273    letter-spacing: 0;
     274}
     275
     276.dropui-admin .dropui-account-manager__card p {
     277    margin: 12px 0 8px;
     278    color: var(--dropui-muted);
     279    font-size: 13px;
     280    line-height: 1.55;
     281}
     282
     283.dropui-account-manager__links {
     284    display: grid;
     285    justify-items: start;
     286}
     287
     288.dropui-account-manager__links a {
     289    display: inline-flex;
    80290    align-items: center;
    81     gap: 6px;
    82     margin: 0 0 12px;
    83     font-size: 13px;
    84     font-weight: 600;
    85 }
    86 
    87 .dropui-status--connected,
    88 .dropui-free {
    89     color: #12633b;
    90 }
    91 
    92 .dropui-status--incomplete {
    93     color: #8a4b00;
    94 }
    95 
    96 .dropui-summary {
    97     max-width: 56ch;
    98     margin: 0 0 22px;
    99     font-size: 15px;
    100     line-height: 1.6;
    101 }
    102 
    103 .dropui-site {
    104     margin: 0 0 22px;
    105     padding-inline-start: 12px;
    106     border-inline-start: 3px solid #c3c4c7;
    107 }
    108 
    109 .dropui-site dt {
    110     margin-bottom: 4px;
    111     color: #50575e;
    112     font-size: 12px;
    113 }
    114 
    115 .dropui-site dd {
    116     margin: 0;
    117     font-size: 14px;
    118     font-weight: 600;
    119     line-height: 1.6;
    120 }
    121 
    122 .dropui-site .dropui-site-url {
    123     color: #50575e;
    124     font-size: 13px;
    125     font-weight: 400;
    126 }
    127 
    128 .dropui-admin .dropui-connect-button {
     291    gap: 8px;
     292    min-height: 38px;
     293}
     294
     295.dropui-icon {
     296    flex: none;
     297}
     298
     299.dropui-admin .dropui-button {
    129300    display: inline-flex;
    130301    align-items: center;
    131302    justify-content: center;
    132     gap: 10px;
    133     min-height: 44px;
     303    gap: 6px;
    134304    max-width: 100%;
    135     padding: 8px 18px;
    136     font-size: 14px;
    137     line-height: 1.5;
    138     white-space: normal;
    139 }
    140 
    141 .dropui-admin .dashicons {
    142     flex: 0 0 20px;
    143 }
    144 
    145 .dropui-admin .description {
    146     margin-top: 10px;
    147     color: #50575e;
    148     font-style: normal;
    149     line-height: 1.6;
    150 }
    151 
    152 .dropui-account {
    153     padding-inline-start: 32px;
    154     border-inline-start: 1px solid #c3c4c7;
    155 }
    156 
    157 .dropui-account p {
    158     line-height: 1.7;
    159 }
    160 
    161 .dropui-free,
    162 .dropui-checklist li {
     305    min-height: 38px;
     306    padding: 8px 14px;
     307    border: 1px solid var(--dropui-control-border);
     308    border-radius: 8px;
     309    background: var(--dropui-surface);
     310    color: var(--dropui-ink);
     311    font: inherit;
     312    font-size: 13px;
     313    font-weight: 500;
     314    line-height: 1.4;
     315    text-align: center;
     316    text-decoration: none;
     317    cursor: pointer;
     318    transition: background-color 120ms ease, border-color 120ms ease;
     319}
     320
     321.dropui-admin .dropui-button:hover {
     322    border-color: var(--dropui-control-hover);
     323    background: var(--dropui-hover);
     324}
     325
     326.dropui-admin .dropui-button--primary {
     327    border-color: var(--dropui-ink);
     328    background: var(--dropui-ink);
     329    color: var(--dropui-surface);
     330}
     331
     332.dropui-admin .dropui-button--primary:hover {
     333    border-color: var(--dropui-primary-hover);
     334    background: var(--dropui-primary-hover);
     335    color: var(--dropui-surface);
     336}
     337
     338.dropui-admin .dropui-button--disconnect {
     339    color: var(--dropui-error);
     340}
     341
     342.dropui-feedback {
     343    margin-bottom: 16px;
     344    padding: 12px 16px;
     345    border-radius: 8px;
     346}
     347
     348.dropui-feedback--success {
     349    background: #ecf7f1;
     350    color: #176b4d;
     351}
     352
     353.dropui-feedback--warning {
     354    background: #fff8e8;
     355    color: #85530b;
     356}
     357
     358.dropui-feedback--error {
     359    background: #fff0f1;
     360    color: var(--dropui-error);
     361}
     362
     363.dropui-settings form {
     364    display: grid;
     365    align-content: start;
     366    justify-items: start;
     367    gap: 12px;
     368}
     369
     370.dropui-settings .dropui-help {
     371    margin: 0;
     372}
     373
     374.dropui-check {
    163375    display: flex;
    164376    align-items: flex-start;
    165377    gap: 8px;
    166 }
    167 
    168 .dropui-admin .dropui-free {
    169     margin: 12px 0 0;
    170     line-height: 1.6;
    171 }
    172 
    173 .dropui-checklist {
    174     margin: 20px 0;
    175 }
    176 
    177 .dropui-checklist li {
    178     margin-bottom: 16px;
    179     line-height: 1.6;
    180 }
    181 
    182 .dropui-guidance {
    183     display: grid;
    184     grid-template-columns: repeat(2, minmax(0, 1fr));
    185     gap: 32px;
    186     padding: 28px 0;
    187 }
    188 
    189 .dropui-guidance h2 {
    190     font-size: 18px;
    191 }
    192 
    193 .dropui-guidance p {
    194     margin: 0;
    195     color: #50575e;
    196     font-size: 14px;
    197     line-height: 1.7;
    198 }
    199 
    200 .dropui-guidance p + p {
    201     margin-top: 10px;
    202 }
    203 
    204 .dropui-support {
    205     display: flex;
    206     align-items: center;
    207     justify-content: space-between;
    208     gap: 24px;
    209     padding: 24px 0;
    210     border-top: 1px solid #c3c4c7;
    211 }
    212 
    213 .dropui-support h2 {
    214     font-size: 15px;
    215 }
    216 
    217 .dropui-support .button {
    218     max-width: 100%;
    219     white-space: normal;
    220 }
    221 
    222 @media (max-width: 960px) {
    223     .dropui-connection {
    224         gap: 24px;
    225     }
    226 
    227     .dropui-account {
    228         padding-inline-start: 24px;
    229     }
    230 }
    231 
    232 @media (max-width: 600px) {
    233     .dropui-connection,
    234     .dropui-guidance {
     378    cursor: pointer;
     379}
     380
     381.dropui-check input[type="checkbox"] {
     382    display: inline-grid;
     383    flex: none;
     384    place-content: center;
     385    width: 16px;
     386    height: 16px;
     387    margin: 2px 0 0;
     388    border-color: var(--dropui-control-border);
     389    border-radius: 4px;
     390}
     391
     392.dropui-check input[type="checkbox"]:checked {
     393    border-color: var(--dropui-ink);
     394    background: var(--dropui-ink);
     395}
     396
     397.dropui-check input[type="checkbox"]:checked::before {
     398    float: none;
     399    width: 5px;
     400    height: 8px;
     401    margin: -1px 0 0;
     402    border: solid var(--dropui-surface);
     403    border-width: 0 2px 2px 0;
     404    transform: rotate(45deg);
     405    content: "";
     406}
     407
     408@media (forced-colors: active) {
     409    .dropui-check input[type="checkbox"]:checked {
     410        border-color: Highlight;
     411        background: Highlight;
     412        forced-color-adjust: none;
     413    }
     414
     415    .dropui-check input[type="checkbox"]:checked::before {
     416        border-color: HighlightText;
     417    }
     418}
     419
     420@media (min-width: 783px) {
     421    body.toplevel_page_dropui:has(.dropui-account-manager) #wpfooter {
     422        padding-inline-end: calc(var(--dropui-account-manager-width) + 28px);
     423    }
     424}
     425
     426@media (max-width: 782px) {
     427    .dropui-admin {
     428        padding: 72px 16px 40px;
     429    }
     430
     431    .dropui-intro {
     432        margin-bottom: 32px;
     433    }
     434
     435    .dropui-admin h1 {
     436        font-size: 26px;
     437    }
     438
     439    .dropui-admin .dropui-button,
     440    .dropui-account-manager__links a {
     441        min-height: 44px;
     442    }
     443
     444    .dropui-columns {
    235445        grid-template-columns: minmax(0, 1fr);
    236446    }
    237 
    238     .dropui-account {
    239         padding: 24px 0 0;
    240         border-inline-start: 0;
    241         border-top: 1px solid #c3c4c7;
    242     }
    243 
    244     .dropui-support {
    245         align-items: flex-start;
    246         flex-direction: column;
    247     }
    248 }
     447}
  • dropui/trunk/assets/js/admin.js

    r3664245 r3840376  
    2020    }
    2121
     22    const accountManager = adminPage.querySelector('[data-dropui-account-manager]');
     23    if (accountManager) {
     24        const closeOutside = function (event) {
     25            if (accountManager.open && !accountManager.contains(event.target)) {
     26                accountManager.open = false;
     27            }
     28        };
     29        document.addEventListener('pointerdown', closeOutside);
     30        document.addEventListener('focusin', closeOutside);
     31        accountManager.addEventListener('keydown', function (event) {
     32            if (event.key !== 'Escape' || !accountManager.open) {
     33                return;
     34            }
     35            event.preventDefault();
     36            event.stopPropagation();
     37            accountManager.open = false;
     38            accountManager.querySelector('summary').focus({ preventScroll: true });
     39        });
     40    }
     41
    2242    const disconnectButton = adminPage.querySelector(
    2343        '[data-dropui-disconnect-confirm]'
  • dropui/trunk/assets/js/exchange-callback.js

    r3664245 r3840376  
    44
    55if (callbackPage) {
    6     try {
    7         localStorage.setItem(
    8             'dropui_connection_updated',
    9             String(Date.now())
    10         );
    11     } catch (error) {
    12         // Ignore localStorage errors.
    13     }
     6    if (callbackPage.dataset.dropuiRefreshTabs !== '0') {
     7        try {
     8            localStorage.setItem(
     9                'dropui_connection_updated',
     10                String(Date.now())
     11            );
     12        } catch (error) {
     13            // Ignore localStorage errors.
     14        }
    1415
    15     if (window.opener && !window.opener.closed) {
    16         window.opener.location.reload();
     16        if (window.opener && !window.opener.closed) {
     17            window.opener.location.reload();
     18        }
    1719    }
    1820
  • dropui/trunk/config/dropui.php

    r3664245 r3840376  
    11<?php
    22
    3 return [
    4     'base_url' => 'https://app.dropui.com/',
    5 ];
     3return ['base_url' => 'https://app.dropui.com/'];
  • dropui/trunk/dropui-wordpress-app.php

    r3689562 r3840376  
    55Plugin URI: https://dropui.com/integrations/wordpress
    66Description: Connect your WordPress site to DropUI and manage your campaigns from your DropUI account.
    7 Version: 1.0.6
     7Version: 1.0.7
    88Requires at least: 6.3
    99Requires PHP: 7.4
    … …  
    2121
    2222if (!defined('DROPUI_VERSION')) {
    23     define('DROPUI_VERSION', '1.0.6');
     23    define('DROPUI_VERSION', '1.0.7');
    2424}
    2525
    … …  
    2929use DropUI\Admin\ExchangeCallbackHandler;
    3030use DropUI\Frontend\MasterScriptLoader;
     31use DropUI\Service\WooCommerceBridge;
     32use DropUI\Service\WooCommerceSmsConsent;
    3133
    3234(new MasterScriptLoader())->register();
     35
     36add_action('admin_post_nopriv_dropui_commerce_read', [new WooCommerceBridge(), 'handle']);
     37add_action('admin_post_dropui_commerce_read', [new WooCommerceBridge(), 'handle']);
     38add_action('woocommerce_checkout_create_order', [new WooCommerceBridge(), 'captureCartToken']);
     39add_action('woocommerce_store_api_checkout_update_order_meta', [new WooCommerceBridge(), 'captureCartToken']);
     40$dropuiSmsConsent = new WooCommerceSmsConsent();
     41add_action('woocommerce_init', [$dropuiSmsConsent, 'registerBlockField']);
     42add_action('woocommerce_after_order_notes', [$dropuiSmsConsent, 'renderClassicField']);
     43add_action('woocommerce_checkout_create_order', [$dropuiSmsConsent, 'captureClassic']);
     44add_action('woocommerce_store_api_checkout_update_order_from_request', [$dropuiSmsConsent, 'readBlockSubmission'], 10, 2);
     45add_action('woocommerce_store_api_checkout_order_processed', [$dropuiSmsConsent, 'captureBlock']);
     46add_filter('wp_consent_api_registered_' . plugin_basename(__FILE__), '__return_true');
     47add_action('before_woocommerce_init', function () {
     48    if (class_exists('Automattic\\WooCommerce\\Utilities\\FeaturesUtil')) {
     49        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
     50            'custom_order_tables', __FILE__, true
     51        );
     52    }
     53});
     54
     55// WooCommerce registers checkout fields at init priority 0.
     56add_action('init', function () {
     57    load_plugin_textdomain('dropui', false, dirname(plugin_basename(__FILE__)) . '/languages');
     58
     59    if (determine_locale() === 'pl_PL') {
     60        // Keep WordPress.org translations and supplement them with bundled Polish strings.
     61        get_translations_for_domain('dropui');
     62        load_textdomain('dropui', __DIR__ . '/languages/dropui-pl_PL.mo', 'pl_PL');
     63    }
     64}, -1);
    3365
    3466add_action('admin_enqueue_scripts', function ($hook) {
    … …  
    4072        'dropui-admin',
    4173        plugin_dir_url(__FILE__) . 'assets/css/admin.css',
    42         ['dashicons'],
     74        [],
    4375        DROPUI_VERSION
    4476    );
    … …  
    74106// run, so this happens once and never again.
    75107add_action('admin_init', function () {
    76     if (!get_option('dropui_activation_redirect')) {
     108    if ((defined('WP_CLI') && WP_CLI) || wp_doing_ajax() || is_network_admin() ||
     109        !current_user_can('manage_options') || !get_option('dropui_activation_redirect')) {
    77110        return;
    78111    }
    … …  
    86119    }
    87120
    88     if (wp_doing_ajax() || is_network_admin()) {
    89         return;
    90     }
    91 
    92     if (!current_user_can('manage_options')) {
    93         return;
    94     }
    95 
    96121    wp_safe_redirect(admin_url('admin.php?page=dropui'));
    97122    exit;
    … …  
    99124
    100125add_action('admin_post_dropui_exchange_callback', function () {
    101     wp_enqueue_script(
    102         'dropui-exchange-callback',
    103         plugin_dir_url(__FILE__) . 'assets/js/exchange-callback.js',
    104         [],
    105         DROPUI_VERSION,
    106         true
    107     );
    108 
    109126    (new ExchangeCallbackHandler())->handle();
    110127});
  • dropui/trunk/languages/dropui.pot

    r3689562 r3840376  
    174174
    175175#: src/Admin/AdminPage.php
    176 msgid "Start with one campaign"
    177 msgstr ""
    178 
    179 #: src/Admin/AdminPage.php
    180176msgid "After connecting your website, you will create and publish campaigns in the DropUI dashboard."
    181177msgstr ""
    … …  
    285281msgid "Unable to encode DropUI auth secret."
    286282msgstr ""
     283
     284#: src/Admin/AdminPage.php
     285msgid "Open DropUI and start synchronization"
     286msgstr ""
     287
     288#: src/Admin/AdminPage.php
     289msgid "Connecting synchronizes products, orders and customer contact details with DropUI. Existing marketing consents are not imported automatically."
     290msgstr ""
     291
     292#: src/Admin/AdminPage.php
     293msgid "Cart tracking requires an explicit marketing decision from a consent manager compatible with WP Consent API or a configured consent integration."
     294msgstr ""
     295
     296#: src/Admin/AdminPage.php
     297msgid "Synchronize MailPoet newsletter subscriptions"
     298msgstr ""
     299
     300#: src/Admin/AdminPage.php
     301msgid "I confirm that these lists contain permission to send this store’s marketing emails."
     302msgstr ""
     303
     304#: src/Admin/AdminPage.php
     305msgid "Save settings"
     306msgstr ""
     307
     308#: src/Admin/AdminPage.php
     309msgid "Settings saved."
     310msgstr ""
     311
     312#: src/Admin/AdminPage.php
     313msgid "Confirm the marketing permission before enabling synchronization."
     314msgstr ""
     315
     316#: src/Admin/AdminPage.php
     317msgid "Ask for SMS marketing consent at checkout"
     318msgstr ""
     319
     320#: src/Admin/AdminPage.php
     321msgid "SMS marketing in DropUI supports Polish phone numbers."
     322msgstr ""
     323
     324#: src/Admin/AdminPage.php
     325msgid "Update WooCommerce to collect SMS consent in the Checkout block."
     326msgstr ""
     327
     328#: src/Service/WooCommerceSmsConsent.php
     329msgid "I agree to receive marketing text messages from this store at the phone number provided."
     330msgstr ""
     331
     332#: src/Admin/AdminPage.php
     333msgid "Your WooCommerce store is connected"
     334msgstr ""
     335
     336#: src/Admin/AdminPage.php
     337msgid "Your WordPress site is connected"
     338msgstr ""
     339
     340#: src/Admin/AdminPage.php
     341msgid "WooCommerce detected."
     342msgstr ""
     343
     344#: src/Admin/AdminPage.php
     345msgid "Start synchronization to import products, orders and customer contact details."
     346msgstr ""
     347
     348#: src/Admin/AdminPage.php
     349msgid "Marketing consents"
     350msgstr ""
     351
     352#: src/Admin/AdminPage.php
     353msgid "SMS at checkout"
     354msgstr ""
     355
     356#: src/Admin/AdminPage.php
     357msgid "Customers decide whether to subscribe. DropUI supports Polish phone numbers for SMS marketing."
     358msgstr ""
     359
     360#: src/Admin/AdminPage.php
     361msgid "Save SMS settings"
     362msgstr ""
     363
     364#: src/Admin/AdminPage.php
     365msgid "Email from MailPoet"
     366msgstr ""
     367
     368#: src/Admin/AdminPage.php
     369msgid "Save MailPoet settings"
     370msgstr ""
     371
     372#: src/Admin/AdminPage.php
     373msgid "Connect your store"
     374msgstr ""
     375
     376#: src/Admin/AdminPage.php
     377msgid "Your store"
     378msgstr ""
     379
     380#: src/Admin/AdminPage.php
     381msgid "Grow sales in your WooCommerce store"
     382msgstr ""
     383
     384#: src/Admin/AdminPage.php
     385msgid "Collect contacts on your WordPress site"
     386msgstr ""
     387
     388#: src/Admin/AdminPage.php
     389msgid "Connect your store to DropUI to recommend products based on purchase history and encourage repeat orders."
     390msgstr ""
     391
     392#: src/Admin/AdminPage.php
     393msgid "Add a newsletter signup form. You will see new signups in DropUI."
     394msgstr ""
     395
     396#: src/Admin/AdminPage.php
     397msgid "After you connect, DropUI imports products, orders and customer contact details."
     398msgstr ""
     399
     400#: src/Admin/AdminPage.php
     401msgid "Site name"
     402msgstr ""
     403
     404#: src/Admin/AdminPage.php
     405msgid "Site address"
     406msgstr ""
     407
     408#: src/Admin/AdminPage.php
     409msgid "Your account manager"
     410msgstr ""
     411
     412#: src/Admin/AdminPage.php
     413msgid "I can help you connect your store, choose a plan or launch a campaign. Email me."
     414msgstr ""
     415
     416msgid "This domain already has a WooCommerce store connected to DropUI. Use a separate domain or subdomain for this store."
     417msgstr ""
     418
     419msgid "WooCommerce synchronization could not start. Try again or contact your account manager."
     420msgstr ""
  • dropui/trunk/readme.txt

    r3689562 r3840376  
    33Tags: popup, lead generation, abandoned cart, marketing automation, woocommerce
    44Requires at least: 6.3
    5 Tested up to: 7.0
     5Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.6
     7Stable tag: 1.0.7
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7474The plugin requires WordPress 6.3 or newer and PHP 7.4 or newer.
    7575
    76 The plugin has been tested up to WordPress 7.0.
     76The plugin has been tested with WordPress 7.1.5.
    7777
    7878In a WordPress Multisite network, each site connects to DropUI independently and has its own configuration and campaigns.
    … …  
    143143
    144144If the website uses WooCommerce, the processed context may also include product, category, variation, coupon, cart contents, cart value, and checkout stage.
     145
     146When an administrator connects a WooCommerce site or starts synchronization from the plugin, DropUI also reads product data, order details and customer contact details from the store. Disconnecting the plugin stops further synchronization.
     147
     148Commerce tracking requires an explicit marketing decision through WP Consent API or an explicitly configured consent integration. Without it, cart tracking and personalized recommendations based on browsing remain inactive.
    145149
    146150The exact scope of processed information depends on the website configuration, enabled features, and active campaigns.
    … …  
    174178== Changelog ==
    175179
     180= 1.0.7 =
     181
     182* Added synchronization of WooCommerce products, orders and customer contact details.
     183* Simplified the connection screen for WordPress sites and WooCommerce stores.
     184
    176185= 1.0.6 =
    177186
  • dropui/trunk/src/Admin/AdminPage.php

    r3689562 r3840376  
    55use DropUI\Service\DropuiService;
    66use DropUI\Service\StoreService;
     7use DropUI\Service\WooCommerceSmsConsent;
    78
    89class AdminPage
    … …  
    2021
    2122        $isConnected = $storeService->hasCompleteConnection();
     23        $isWooCommerce = $storeService->getPlatform() === 'woocommerce';
     24        $wasCommerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     25        $wasConnected = $isConnected;
    2226
    2327        if (
    … …  
    4751        );
    4852
    49         $submitButtonLabel = __('Connect to DropUI', 'dropui');
     53        $connectButtonLabel = $isWooCommerce ? __('Connect your store', 'dropui') : __('Connect to DropUI', 'dropui');
     54        $submitButtonLabel = $connectButtonLabel;
     55
     56        if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && isset($_POST['dropui_save_woo_sms'])) {
     57            $nonce = isset($_POST['dropui_woo_sms_nonce']) ? sanitize_text_field(wp_unslash($_POST['dropui_woo_sms_nonce'])) : '';
     58            if (!current_user_can('manage_options') || !wp_verify_nonce($nonce, 'dropui_save_woo_sms') ||
     59                !$isConnected || !$storeService->hasCommerceSync()) {
     60                $result = ['status' => 'error', 'message' => __('Form security check failed.', 'dropui')];
     61            } else {
     62                update_option(WooCommerceSmsConsent::OPTION, isset($_POST['dropui_woo_sms_checkout']) ? '1' : '0', false);
     63                $result = ['status' => 'success', 'message' => __('Settings saved.', 'dropui')];
     64            }
     65        }
     66
     67        if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && isset($_POST['dropui_save_mailpoet'])) {
     68            $nonce = isset($_POST['dropui_mailpoet_nonce']) ? sanitize_text_field(wp_unslash($_POST['dropui_mailpoet_nonce'])) : '';
     69            if (!current_user_can('manage_options') || !wp_verify_nonce($nonce, 'dropui_save_mailpoet') ||
     70                !$isConnected || !$storeService->hasCommerceSync() || !class_exists('MailPoet\\API\\API')) {
     71                $result = ['status' => 'error', 'message' => __('Form security check failed.', 'dropui')];
     72            } elseif (isset($_POST['dropui_mailpoet_sync']) && !isset($_POST['dropui_mailpoet_confirm'])) {
     73                $result = ['status' => 'error', 'message' => __('Confirm the marketing permission before enabling synchronization.', 'dropui')];
     74            } else {
     75                $enabled = isset($_POST['dropui_mailpoet_sync']);
     76                update_option('dropui_mailpoet_sync_enabled', $enabled ? '1' : '0', false);
     77                $result = ['status' => 'success', 'message' => __('Settings saved.', 'dropui')];
     78            }
     79        }
    5080
    5181        if ($isConnected) {
    5282            $submitButtonLabel = __('Open DropUI dashboard', 'dropui');
     83            if ($isWooCommerce && !$storeService->hasCommerceSync()) {
     84                $submitButtonLabel = __('Open DropUI and start synchronization', 'dropui');
     85            }
    5386        } elseif ($isConnectionIncomplete) {
    5487            $submitButtonLabel = __('Reconnect to DropUI', 'dropui');
    … …  
    83116                    $isConnected = false;
    84117                    $isConnectionIncomplete = false;
    85                     $submitButtonLabel = __('Connect to DropUI', 'dropui');
     118                    $submitButtonLabel = $connectButtonLabel;
    86119                }
    87120            }
    … …  
    119152
    120153                if (($result['status'] ?? '') === 'redirect' && !empty($result['redirect_url'])) {
    121                     wp_add_inline_script(
    122                         'dropui-admin',
    123                         'window.location.href = ' . wp_json_encode($result['redirect_url']) . ';'
    124                     );
     154                    $commerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     155                    ExchangeCallbackHandler::enqueueCompletionScript();
    125156
    126157                    ?>
    127                     <div class="wrap dropui-admin" data-dropui-admin>
    128                         <h1>DropUI</h1>
    129                         <div class="dropui-connection">
    130                             <h2><?php esc_html_e('Redirecting to DropUI...', 'dropui'); ?></h2>
    131                             <p>
    132                                 <a class="button button-primary" href="<?php echo esc_url($result['redirect_url']); ?>">
    133                                     <?php esc_html_e('Open DropUI', 'dropui'); ?>
    134                                 </a>
    135                             </p>
    136                         </div>
     158                    <div
     159                        class="wrap dropui-admin"
     160                        data-dropui-exchange-callback
     161                        data-dropui-redirect-url="<?php echo esc_url($result['redirect_url']); ?>"
     162                        data-dropui-refresh-tabs="<?php echo esc_attr($wasCommerceSyncEnabled !== $commerceSyncEnabled ? '1' : '0'); ?>"
     163                    >
     164                        <h1><?php esc_html_e('Redirecting to DropUI...', 'dropui'); ?></h1>
     165                        <p>
     166                            <a class="dropui-button dropui-button--primary" href="<?php echo esc_url($result['redirect_url']); ?>">
     167                                <?php esc_html_e('Open DropUI', 'dropui'); ?>
     168                            </a>
     169                        </p>
    137170                    </div>
    138171                    <?php
    … …  
    145178            ? sanitize_text_field(wp_unslash($_GET['dropui_status']))
    146179            : '';
     180        if (!empty($result['notice'])) {
     181            $dropuiStatus = $result['notice'];
     182            $submitButtonLabel = __('Open DropUI and start synchronization', 'dropui');
     183        }
    147184
    148185        $dropuiStatusMessages = [
    149186            'connected' => [
    150                 'class' => 'notice-success',
     187                'tone' => 'success',
    151188                'message' => __('The WordPress site has been connected to DropUI.', 'dropui'),
    152189            ],
    153190            'connected_login_failed' => [
    154                 'class' => 'notice-warning',
     191                'tone' => 'warning',
    155192                'message' => __('The WordPress site has been connected to DropUI, but automatic login failed. Try going to DropUI again.', 'dropui'),
    156193            ],
     194            DropuiService::WOOCOMMERCE_SCOPE_CONFLICT => [
     195                'tone' => 'error',
     196                'message' => __('This domain already has a WooCommerce store connected to DropUI. Use a separate domain or subdomain for this store.', 'dropui'),
     197            ],
     198            DropuiService::WOOCOMMERCE_BRIDGE_UNAVAILABLE => [
     199                'tone' => 'error',
     200                'message' => __('WooCommerce synchronization could not start. Try again or contact your account manager.', 'dropui'),
     201            ],
    157202            'missing_exchange_params' => [
    158                 'class' => 'notice-error',
     203                'tone' => 'error',
    159204                'message' => __('The callback data from DropUI is missing.', 'dropui'),
    160205            ],
    161206            'store_mismatch' => [
    162                 'class' => 'notice-error',
     207                'tone' => 'error',
    163208                'message' => __('The site identifier does not match this WordPress site.', 'dropui'),
    164209            ],
    165210            'exchange_failed' => [
    166                 'class' => 'notice-error',
     211                'tone' => 'error',
    167212                'message' => __('Could not retrieve complete connection data from DropUI.', 'dropui'),
    168213            ],
    … …  
    170215
    171216        $dropuiStatusNotice = $dropuiStatusMessages[$dropuiStatus] ?? null;
    172         $isPolish = substr(determine_locale(), 0, 2) === 'pl';
    173         $pricingUrl = $isPolish ? 'https://dropui.com/pl/cennik' : 'https://dropui.com/en/pricing';
    174         $scenariosUrl = $isPolish ? 'https://dropui.com/pl/scenariusze' : 'https://dropui.com/en/scenarios';
    175217        $formUrl = admin_url('admin.php?page=dropui');
    176         $iconUrl = plugins_url('assets/images/dropui-icon.png', dirname(__DIR__, 2) . '/dropui-wordpress-app.php');
     218        $pluginFile = dirname(__DIR__, 2) . '/dropui-wordpress-app.php';
     219        $logoUrl = plugins_url('assets/images/dropui-logo.svg', $pluginFile);
     220        $panelIconsUrl = plugins_url('assets/images/panel-icons.svg', $pluginFile);
     221        $accountManagerName = 'Kornel Szwaja';
     222        $accountManagerPhotoUrl = plugins_url('assets/images/kornel-szwaja.png', $pluginFile);
     223        $commerceSyncEnabled = $isConnected && $storeService->hasCommerceSync();
     224        $connectionChanged = $wasConnected !== $isConnected || $wasCommerceSyncEnabled !== $commerceSyncEnabled;
     225        if ($connectionChanged) {
     226            ExchangeCallbackHandler::enqueueCompletionScript();
     227        }
    177228
    178229        if ($isConnected) {
    179230            $connectionState = 'connected';
    180             $statusLabel = __('Connected', 'dropui');
    181             $heading = __('Your website is connected', 'dropui');
    182             $summary = __('Open the DropUI dashboard to create and publish campaigns.', 'dropui');
     231            $heading = $isWooCommerce && $commerceSyncEnabled
     232                ? __('Your WooCommerce store is connected', 'dropui')
     233                : __('Your WordPress site is connected', 'dropui');
     234            $summary = '';
    183235        } elseif ($isConnectionIncomplete) {
    184236            $connectionState = 'incomplete';
    185             $statusLabel = __('Connection incomplete', 'dropui');
    186237            $heading = __('Complete your connection', 'dropui');
    187238            $summary = __('Some connection details are missing. Your website is not fully connected to DropUI yet.', 'dropui');
    188239        } else {
    189240            $connectionState = 'disconnected';
    190             $statusLabel = __('Not connected', 'dropui');
    191             $heading = __('Connect your website', 'dropui');
    192             $summary = __('Sign in or create a free DropUI account to connect your website.', 'dropui');
     241            $heading = $isWooCommerce
     242                ? __('Grow sales in your WooCommerce store', 'dropui')
     243                : __('Collect contacts on your WordPress site', 'dropui');
     244            $summary = $isWooCommerce
     245                ? __('Connect your store to DropUI to recommend products based on purchase history and encourage repeat orders.', 'dropui')
     246                : __('Add a newsletter signup form. You will see new signups in DropUI.', 'dropui');
    193247        }
    194248
    … …  
    197251            class="wrap dropui-admin"
    198252            data-dropui-admin
     253            <?php if ($connectionChanged): ?>data-dropui-exchange-callback<?php endif; ?>
    199254            data-connection-state="<?php echo esc_attr($connectionState); ?>"
    200255            data-refresh-opener="<?php echo esc_attr(in_array($dropuiStatus, ['connected', 'connected_login_failed'], true) ? '1' : '0'); ?>"
    201256        >
    202257            <header class="dropui-intro">
    203                 <h1 class="dropui-brand">
    204                     <img src="<?php echo esc_url($iconUrl); ?>" width="40" height="40" alt="">
    205                     <span><?php esc_html_e('DropUI - More Sales from the Traffic You Already Have', 'dropui'); ?></span>
    206                 </h1>
    207                 <p class="dropui-intro-summary"><?php esc_html_e('Capture leads, recover abandoned carts and grow sales. Reach visitors with relevant offers while they browse your site and after they leave.', 'dropui'); ?></p>
     258                <img class="dropui-brand" src="<?php echo esc_url($logoUrl); ?>" width="100" height="30" alt="DropUI">
     259                <h1><?php echo esc_html($heading); ?></h1>
     260                <?php if ($summary !== ''): ?>
     261                    <p class="dropui-intro-summary"><?php echo esc_html($summary); ?></p>
     262                <?php endif; ?>
    208263            </header>
    209264
    210265            <?php if ($dropuiStatusNotice): ?>
    211                 <div class="notice <?php echo esc_attr($dropuiStatusNotice['class']); ?> is-dismissible">
     266                <div class="dropui-feedback dropui-feedback--<?php echo esc_attr($dropuiStatusNotice['tone']); ?>" role="status">
    212267                    <p><?php echo esc_html($dropuiStatusNotice['message']); ?></p>
    213268                </div>
    … …  
    215270
    216271            <?php if ($hasAdminEmailChanged): ?>
    217                 <div class="notice notice-warning">
     272                <div class="dropui-feedback dropui-feedback--warning" role="status">
     273                    <p><?php esc_html_e('The WordPress administrator email address has changed since the site was connected to DropUI.', 'dropui'); ?></p>
    218274                    <p>
    219                         <strong><?php esc_html_e('Warning:', 'dropui'); ?></strong>
    220                         <?php esc_html_e('The WordPress administrator email address has changed since the site was connected to DropUI.', 'dropui'); ?>
     275                        <?php esc_html_e('Email used when connecting:', 'dropui'); ?>
     276                        <strong><?php echo esc_html($connectedAdminEmail); ?></strong>
    221277                    </p>
    222278                    <p>
    223                         <?php esc_html_e('Email used when connecting:', 'dropui'); ?>
    224                         <strong><?php echo esc_html($connectedAdminEmail); ?></strong><br>
    225279                        <?php esc_html_e('Current WordPress email:', 'dropui'); ?>
    226280                        <strong><?php echo esc_html($currentAdminEmail); ?></strong>
    227281                    </p>
    228                     <p>
    229                         <?php esc_html_e('If this change was intentional, disconnect the integration and reconnect the WordPress site.', 'dropui'); ?>
    230                     </p>
     282                    <p><?php esc_html_e('If this change was intentional, disconnect the integration and reconnect the WordPress site.', 'dropui'); ?></p>
    231283                </div>
    232284            <?php endif; ?>
    233285
    234286            <?php if ($result && !empty($result['message'])): ?>
    235                 <div class="notice <?php echo esc_attr(($result['status'] ?? '') === 'error' ? 'notice-error' : 'notice-success'); ?> is-dismissible">
     287                <?php $resultIsError = ($result['status'] ?? '') === 'error'; ?>
     288                <div class="dropui-feedback dropui-feedback--<?php echo esc_attr($resultIsError ? 'error' : 'success'); ?>" role="<?php echo esc_attr($resultIsError ? 'alert' : 'status'); ?>">
    236289                    <p><?php echo esc_html($result['message']); ?></p>
    237290                </div>
    238291            <?php endif; ?>
    239292
    240             <section class="dropui-connection" aria-labelledby="dropui-heading">
    241                 <div class="dropui-connection-main">
    242                     <p class="dropui-status dropui-status--<?php echo esc_attr($connectionState); ?>">
    243                         <span class="dashicons <?php echo esc_attr($isConnected ? 'dashicons-yes-alt' : 'dashicons-admin-links'); ?>" aria-hidden="true"></span>
    244                         <?php echo esc_html($statusLabel); ?>
    245                     </p>
    246                     <h2 id="dropui-heading"><?php echo esc_html($heading); ?></h2>
    247                     <?php if ($summary): ?>
    248                         <p class="dropui-summary"><?php echo esc_html($summary); ?></p>
     293            <div class="dropui-page-flow">
     294                <section class="dropui-section" aria-labelledby="dropui-site-heading">
     295                    <h2 id="dropui-site-heading"><?php echo esc_html($isWooCommerce ? __('Your store', 'dropui') : __('Website', 'dropui')); ?></h2>
     296                    <dl class="dropui-columns dropui-data-fields">
     297                        <div>
     298                            <dt><?php esc_html_e('Site name', 'dropui'); ?></dt>
     299                            <dd><?php echo esc_html(get_bloginfo('name')); ?></dd>
     300                        </div>
     301                        <div>
     302                            <dt><?php esc_html_e('Site address', 'dropui'); ?></dt>
     303                            <dd><?php echo esc_html(home_url('/')); ?></dd>
     304                        </div>
     305                    </dl>
     306
     307                    <?php if ($isWooCommerce && !$commerceSyncEnabled): ?>
     308                        <?php if ($isConnected): ?>
     309                            <p class="dropui-sync-help"><?php esc_html_e('Start synchronization to import products, orders and customer contact details.', 'dropui'); ?></p>
     310                        <?php else: ?>
     311                            <div class="dropui-woo-summary">
     312                                <p>
     313                                    <strong><?php esc_html_e('WooCommerce detected.', 'dropui'); ?></strong>
     314                                    <?php esc_html_e('After you connect, DropUI imports products, orders and customer contact details.', 'dropui'); ?>
     315                                </p>
     316                            </div>
     317                        <?php endif; ?>
    249318                    <?php endif; ?>
    250319
    251                     <dl class="dropui-site">
    252                         <dt><?php esc_html_e('Website', 'dropui'); ?></dt>
    253                         <dd><?php echo esc_html(get_bloginfo('name')); ?></dd>
    254                         <dd class="dropui-site-url"><?php echo esc_html(home_url('/')); ?></dd>
    255                     </dl>
    256 
    257                     <form action="<?php echo esc_url($formUrl); ?>" method="post" target="_blank">
    258                         <?php wp_nonce_field('dropui_connect_store', 'dropui_nonce'); ?>
    259                         <input type="hidden" name="connect_store" value="1">
    260                         <button class="button button-primary dropui-connect-button" type="submit" aria-describedby="<?php echo esc_attr($isConnected ? 'dropui-connection-note' : 'dropui-free-note dropui-connection-note'); ?>">
    261                             <?php echo esc_html($submitButtonLabel); ?>
    262                             <span class="dashicons dashicons-external" aria-hidden="true"></span>
    263                         </button>
    264                         <?php if (!$isConnected): ?>
    265                             <p class="dropui-free" id="dropui-free-note"><span class="dashicons dashicons-yes" aria-hidden="true"></span><?php esc_html_e('No credit card required', 'dropui'); ?></p>
     320                    <div class="dropui-connection-actions">
     321                        <form action="<?php echo esc_url($formUrl); ?>" method="post" target="_blank">
     322                            <?php wp_nonce_field('dropui_connect_store', 'dropui_nonce'); ?>
     323                            <input type="hidden" name="connect_store" value="1">
     324                            <button class="dropui-button dropui-button--primary dropui-connect-button" type="submit" aria-describedby="dropui-connection-note">
     325                                <?php echo esc_html($submitButtonLabel); ?>
     326                            </button>
     327                            <span class="screen-reader-text" id="dropui-connection-note">
     328                                <?php esc_html_e('Opens in a new tab. Your WordPress panel stays open.', 'dropui'); ?>
     329                            </span>
     330                        </form>
     331                        <?php if ($isConnected): ?>
     332                            <form action="<?php echo esc_url($formUrl); ?>" method="post">
     333                                <?php wp_nonce_field('dropui_disconnect_store', 'dropui_disconnect_nonce'); ?>
     334                                <button type="submit" name="disconnect_store" value="1" class="dropui-button dropui-button--disconnect"
     335                                    data-dropui-disconnect-confirm="<?php esc_attr_e('Are you sure you want to disconnect this WordPress site from your DropUI account?', 'dropui'); ?>">
     336                                    <?php esc_html_e('Disconnect DropUI integration', 'dropui'); ?>
     337                                </button>
     338                            </form>
    266339                        <?php endif; ?>
    267                         <p class="description" id="dropui-connection-note">
    268                             <?php esc_html_e('Opens in a new tab. Your WordPress panel stays open.', 'dropui'); ?>
    269                         </p>
    270                     </form>
    271                 </div>
    272 
    273                 <aside class="dropui-account" aria-labelledby="dropui-account-heading">
    274                     <?php if ($isConnected): ?>
    275                         <h3 id="dropui-account-heading"><?php esc_html_e('Campaigns and results', 'dropui'); ?></h3>
    276                         <ul class="dropui-checklist">
    277                             <li><span class="dashicons dashicons-layout" aria-hidden="true"></span><?php esc_html_e('Campaign editor and AI Assistant', 'dropui'); ?></li>
    278                             <li><span class="dashicons dashicons-filter" aria-hidden="true"></span><?php esc_html_e('Audiences and display rules', 'dropui'); ?></li>
    279                             <li><span class="dashicons dashicons-chart-bar" aria-hidden="true"></span><?php esc_html_e('Statistics and A/B tests', 'dropui'); ?></li>
    280                         </ul>
    281                     <?php else: ?>
    282                         <h3 id="dropui-account-heading"><?php esc_html_e('Start with the Free plan', 'dropui'); ?></h3>
    283                         <p class="description"><?php esc_html_e('Free plan limits apply. WhatsApp is billed separately.', 'dropui'); ?></p>
    284                     <?php endif; ?>
    285                     <a href="<?php echo esc_url($pricingUrl); ?>" target="_blank" rel="noopener noreferrer">
    286                         <?php esc_html_e('Plans and limits', 'dropui'); ?>
    287                         <span class="screen-reader-text"><?php esc_html_e('(opens in a new tab)', 'dropui'); ?></span>
    288                     </a>
    289                 </aside>
    290             </section>
    291 
    292             <div class="dropui-guidance">
    293                 <section aria-labelledby="dropui-first-campaign-heading">
    294                     <h2 id="dropui-first-campaign-heading"><?php esc_html_e('Start with one campaign', 'dropui'); ?></h2>
    295                     <?php if (!$isConnected): ?>
    296                         <p><?php esc_html_e('After connecting your website, you will create and publish campaigns in the DropUI dashboard.', 'dropui'); ?></p>
    297                     <?php endif; ?>
    298                     <p>
    299                         <?php
    300                         /* translators: %s: link to the ready-made campaign scenarios. */
    301                         printf(
    302                             esc_html__('Choose a %s, use the AI Assistant or create your own campaign. Based on your description, the Assistant suggests copy, a layout and calls to action.', 'dropui'),
    303                             '<a href="' . esc_url($scenariosUrl) . '" target="_blank" rel="noopener noreferrer">'
    304                             . esc_html__('ready-made scenario', 'dropui')
    305                             . '<span class="screen-reader-text"> ' . esc_html__('(opens in a new tab)', 'dropui') . '</span></a>'
    306                         );
    307                         ?>
    308                     </p>
     340                    </div>
    309341                </section>
    310                 <section aria-labelledby="dropui-onboarding-heading">
    311                     <h2 id="dropui-onboarding-heading"><?php esc_html_e('Help from an onboarding specialist', 'dropui'); ?></h2>
    312                     <p><?php esc_html_e('On the Start plan and above, a specialist helps you set up DropUI, create and launch campaigns, and review results. You also get advice on improvements and next steps.', 'dropui'); ?></p>
     342
     343                <?php if (StoreService::WOO_MARKETING_CONSENTS_ENABLED && $commerceSyncEnabled): ?>
     344                    <section class="dropui-section" aria-labelledby="dropui-consents-heading">
     345                        <h2 id="dropui-consents-heading"><?php esc_html_e('Marketing consents', 'dropui'); ?></h2>
     346                        <div class="dropui-columns dropui-settings">
     347                            <form method="post" aria-labelledby="dropui-sms-heading">
     348                                <h3 id="dropui-sms-heading"><?php esc_html_e('SMS at checkout', 'dropui'); ?></h3>
     349                                <?php wp_nonce_field('dropui_save_woo_sms', 'dropui_woo_sms_nonce'); ?>
     350                                <label class="dropui-check">
     351                                    <input type="checkbox" name="dropui_woo_sms_checkout" value="1" <?php checked(get_option(WooCommerceSmsConsent::OPTION), '1'); ?>>
     352                                    <span><?php esc_html_e('Ask for SMS marketing consent at checkout', 'dropui'); ?></span>
     353                                </label>
     354                                <p class="dropui-help"><?php esc_html_e('Customers decide whether to subscribe. DropUI supports Polish phone numbers for SMS marketing.', 'dropui'); ?></p>
     355                                <?php if (!function_exists('woocommerce_register_additional_checkout_field')): ?>
     356                                    <p class="dropui-help"><?php esc_html_e('Update WooCommerce to collect SMS consent in the Checkout block.', 'dropui'); ?></p>
     357                                <?php endif; ?>
     358                                <button type="submit" name="dropui_save_woo_sms" value="1" class="dropui-button"><?php esc_html_e('Save SMS settings', 'dropui'); ?></button>
     359                            </form>
     360
     361                            <?php if (class_exists('MailPoet\\API\\API')): ?>
     362                                <form method="post" aria-labelledby="dropui-mailpoet-heading">
     363                                    <h3 id="dropui-mailpoet-heading"><?php esc_html_e('Email from MailPoet', 'dropui'); ?></h3>
     364                                    <?php wp_nonce_field('dropui_save_mailpoet', 'dropui_mailpoet_nonce'); ?>
     365                                    <label class="dropui-check">
     366                                        <input type="checkbox" name="dropui_mailpoet_sync" value="1" <?php checked(get_option('dropui_mailpoet_sync_enabled'), '1'); ?>>
     367                                        <span><?php esc_html_e('Synchronize MailPoet newsletter subscriptions', 'dropui'); ?></span>
     368                                    </label>
     369                                    <label class="dropui-check">
     370                                        <input type="checkbox" name="dropui_mailpoet_confirm" value="1">
     371                                        <span><?php esc_html_e('I confirm that these lists contain permission to send this store’s marketing emails.', 'dropui'); ?></span>
     372                                    </label>
     373                                    <button type="submit" name="dropui_save_mailpoet" value="1" class="dropui-button"><?php esc_html_e('Save MailPoet settings', 'dropui'); ?></button>
     374                                </form>
     375                            <?php endif; ?>
     376                        </div>
     377                    </section>
     378                <?php endif; ?>
     379            </div>
     380
     381            <details class="dropui-account-manager" data-dropui-account-manager>
     382                <summary class="dropui-button dropui-account-manager__trigger" aria-controls="dropui-account-manager-card">
     383                    <img src="<?php echo esc_url($accountManagerPhotoUrl); ?>" alt="" width="44" height="44">
     384                    <span class="dropui-account-manager__identity">
     385                        <strong><?php echo esc_html($accountManagerName); ?></strong>
     386                        <span><?php esc_html_e('Your account manager', 'dropui'); ?></span>
     387                    </span>
     388                </summary>
     389                <section class="dropui-account-manager__card" id="dropui-account-manager-card" aria-labelledby="dropui-account-manager-name">
     390                    <header class="dropui-account-manager__header">
     391                        <img src="<?php echo esc_url($accountManagerPhotoUrl); ?>" alt="" width="48" height="48">
     392                        <h2 id="dropui-account-manager-name"><?php echo esc_html($accountManagerName); ?></h2>
     393                    </header>
     394                    <p><?php esc_html_e('I can help you connect your store, choose a plan or launch a campaign. Email me.', 'dropui'); ?></p>
     395                    <div class="dropui-account-manager__links">
     396                        <a href="mailto:kornel@dropui.com">
     397                            <svg class="dropui-icon" width="20" height="20" aria-hidden="true" focusable="false">
     398                                <use href="<?php echo esc_url($panelIconsUrl . '#email'); ?>"></use>
     399                            </svg>
     400                            <span>kornel@dropui.com</span>
     401                        </a>
     402                    </div>
    313403                </section>
    314             </div>
    315 
    316             <footer class="dropui-support">
    317                 <div>
    318                     <h2><?php esc_html_e('Support', 'dropui'); ?></h2>
    319                     <a href="mailto:support@dropui.com">support@dropui.com</a>
    320                 </div>
    321                 <?php if ($isConnected): ?>
    322                     <form action="<?php echo esc_url($formUrl); ?>" method="post">
    323                         <?php wp_nonce_field('dropui_disconnect_store', 'dropui_disconnect_nonce'); ?>
    324                         <?php submit_button(
    325                             __('Disconnect DropUI integration', 'dropui'),
    326                             'secondary',
    327                             'disconnect_store',
    328                             false,
    329                             [
    330                                 'data-dropui-disconnect-confirm' => __('Are you sure you want to disconnect this WordPress site from your DropUI account?', 'dropui'),
    331                             ]
    332                         ); ?>
    333                     </form>
    334                 <?php endif; ?>
    335             </footer>
     404            </details>
    336405        </div>
    337406        <?php
  • dropui/trunk/src/Admin/ExchangeCallbackHandler.php

    r3664245 r3840376  
    88class ExchangeCallbackHandler
    99{
     10    public static function enqueueCompletionScript(): void
     11    {
     12        wp_enqueue_script(
     13            'dropui-exchange-callback',
     14            plugins_url('assets/js/exchange-callback.js', dirname(__DIR__, 2) . '/dropui-wordpress-app.php'),
     15            [],
     16            DROPUI_VERSION,
     17            true
     18        );
     19    }
     20
    1021    public function handle(): void
    1122    {
    … …  
    7485        }
    7586
    76         $this->redirectWithStatus('connected_login_failed');
     87        $this->redirectWithStatus($loginResult['notice'] ?? 'connected_login_failed');
    7788    }
    7889
    … …  
    8091    {
    8192        $safeRedirectUrl = esc_url_raw($redirectUrl);
     93        self::enqueueCompletionScript();
    8294
    8395        header('Content-Type: text/html; charset=' . get_option('blog_charset'));
  • dropui/trunk/src/Frontend/MasterScriptLoader.php

    r3664245 r3840376  
    3737            ]
    3838        );
     39        if ($storeService->hasCommerceSync()) {
     40            $path = wp_parse_url(get_site_url(), PHP_URL_PATH);
     41            $cookiePath = '/' . trim((string) $path, '/');
     42            $config = [
     43                'storeId' => $storeService->getConnectedStoreId(),
     44                'cart' => rest_url('wc/store/v1/cart'),
     45                'add' => rest_url('wc/store/v1/cart/add-item'),
     46                'cartPage' => wc_get_cart_url(),
     47                'cookiePath' => $cookiePath === '/' ? '/' : $cookiePath . '/',
     48                'consentApiAvailable' => function_exists('wp_has_consent'),
     49                'orderId' => is_order_received_page() ? absint(get_query_var('order-received')) : 0,
     50                'productId' => is_product() ? get_queried_object_id() : 0,
     51            ];
     52            wp_add_inline_script(
     53                self::SCRIPT_HANDLE,
     54                'window.__dropuiWooCommerce = ' . wp_json_encode($config) . ';',
     55                'before'
     56            );
     57        }
    3958    }
    4059}
  • dropui/trunk/src/Service/DropuiService.php

    r3687292 r3840376  
    55class DropuiService
    66{
     7    public const WOOCOMMERCE_SCOPE_CONFLICT = 'woocommerce_scope_conflict';
     8    public const WOOCOMMERCE_BRIDGE_UNAVAILABLE = 'woocommerce_bridge_unavailable';
     9
    710    private function getConfig(): array
    811    {
    … …  
    315318        // The backend verifies it with a second signature over the same
    316319        // message extended by a version marker and the platform value.
    317         $platform = (new StoreService())->getPlatform();
     320        $storeService = new StoreService();
     321        $platform = $storeService->getPlatform();
    318322        $platformSignature = hash_hmac(
    319323            'sha256',
    … …  
    331335            'platform_signature' => $platformSignature,
    332336        ];
     337        if ($platform === 'woocommerce') {
     338            $payload['commerce_bridge'] = '1';
     339            $payload['commerce_bridge_signature'] = hash_hmac(
     340                'sha256',
     341                $message . "\n2\n" . $platform . "\ncommerce_bridge:1",
     342                $authSecret
     343            );
     344        }
    333345
    334346        $response = wp_remote_post(
    … …  
    362374                'login_url' => $loginUrl,
    363375                'raw_body' => $body,
     376            ];
     377        }
     378
     379        $code = $data['code'] ?? '';
     380        if ($httpCode === 409 && in_array($code, [self::WOOCOMMERCE_SCOPE_CONFLICT, self::WOOCOMMERCE_BRIDGE_UNAVAILABLE], true)) {
     381            $storeService->disableCommerceSync();
     382            return [
     383                'status' => 'error',
     384                'notice' => $code,
    364385            ];
    365386        }
    … …  
    383404            }
    384405
     406            if ($platform === 'woocommerce') {
     407                if (($data['commerce_bridge_ready'] ?? null) === true) {
     408                    $storeService->enableCommerceSync();
     409                } elseif (array_key_exists('commerce_bridge_ready', $data) || !$storeService->hasCommerceSync()) {
     410                    $storeService->disableCommerceSync();
     411                    return [
     412                        'status' => 'error',
     413                        'notice' => self::WOOCOMMERCE_BRIDGE_UNAVAILABLE,
     414                    ];
     415                }
     416            } else {
     417                $storeService->disableCommerceSync();
     418            }
     419
    385420            return [
    386421                'status' => 'redirect',
  • dropui/trunk/src/Service/StoreService.php

    r3687292 r3840376  
    55class StoreService
    66{
     7    // The base WooCommerce integration synchronizes store data only.
     8    public const WOO_MARKETING_CONSENTS_ENABLED = false;
     9
    710    private const AUTH_SECRET_PREFIX = 'dropui_encrypted_v1:';
    811    private const AUTH_SECRET_CIPHER = 'aes-256-cbc';
    … …  
    3841    }
    3942
     43    public function hasCommerceSync(): bool
     44    {
     45        return class_exists('WooCommerce') && get_option('dropui_commerce_sync_enabled') === '1';
     46    }
     47
     48    public function enableCommerceSync(): void
     49    {
     50        if (class_exists('WooCommerce')) {
     51            update_option('dropui_commerce_sync_enabled', '1', false);
     52        }
     53    }
     54
     55    public function disableCommerceSync(): void
     56    {
     57        delete_option('dropui_commerce_sync_enabled');
     58    }
     59
    4060    public function getStoreId(): ?string
    4161    {
    … …  
    112132    public function clearConnection(): void
    113133    {
     134        delete_option('dropui_mailpoet_sync_enabled');
     135        delete_option(WooCommerceSmsConsent::OPTION);
     136        $this->disableCommerceSync();
    114137        delete_option('dropui_auth_secret');
    115138        delete_option('dropui_connected_store_id');
    … …  
    123146
    124147        delete_option('dropui_store_id');
     148
     149        global $wpdb;
     150        $wpdb->query($wpdb->prepare(
     151            "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
     152            $wpdb->esc_like(WooCommerceBridge::REQUEST_NONCE_PREFIX) . '%'
     153        ));
    125154    }
    126155
  • dropui/trunk/vendor/autoload.php

    r3670371 r3840376  
    1515        }
    1616    }
    17     throw new RuntimeException($err);
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
    1821}
    1922
    2023require_once __DIR__ . '/composer/autoload_real.php';
    2124
    22 return ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a::getLoader();
     25return ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf::getLoader();
  • dropui/trunk/vendor/composer/LICENSE

    r3664245 r3840376  
    1 
    21Copyright (c) Nils Adermann, Jordi Boggiano
    32
    … …  
    1918OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2019THE SOFTWARE.
    21 
  • dropui/trunk/vendor/composer/autoload_classmap.php

    r3664245 r3840376  
    1212    'DropUI\\Frontend\\MasterScriptLoader' => $baseDir . '/src/Frontend/MasterScriptLoader.php',
    1313    'DropUI\\Service\\DropuiService' => $baseDir . '/src/Service/DropuiService.php',
     14    'DropUI\\Service\\MailPoetConsent' => $baseDir . '/src/Service/MailPoetConsent.php',
    1415    'DropUI\\Service\\StoreService' => $baseDir . '/src/Service/StoreService.php',
     16    'DropUI\\Service\\WooCommerceBridge' => $baseDir . '/src/Service/WooCommerceBridge.php',
     17    'DropUI\\Service\\WooCommerceSmsConsent' => $baseDir . '/src/Service/WooCommerceSmsConsent.php',
    1518);
  • dropui/trunk/vendor/composer/autoload_real.php

    r3670371 r3840376  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a
     5class ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf
    66{
    77    private static $loader;
    … …  
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit9cf46fb4a3420468178145ec79ef6d1a', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit7b0e39a6d42788a3e8fd4fca5668bebf', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • dropui/trunk/vendor/composer/autoload_static.php

    r3670371 r3840376  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a
     7class ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf
    88{
    99    public static $prefixLengthsPsr4 = array (
    10         'D' =>
     10        'D' => 
    1111        array (
    1212            'DropUI\\' => 7,
    … …  
    1515
    1616    public static $prefixDirsPsr4 = array (
    17         'DropUI\\' =>
     17        'DropUI\\' => 
    1818        array (
    1919            0 => __DIR__ . '/../..' . '/src',
    … …  
    2727        'DropUI\\Frontend\\MasterScriptLoader' => __DIR__ . '/../..' . '/src/Frontend/MasterScriptLoader.php',
    2828        'DropUI\\Service\\DropuiService' => __DIR__ . '/../..' . '/src/Service/DropuiService.php',
     29        'DropUI\\Service\\MailPoetConsent' => __DIR__ . '/../..' . '/src/Service/MailPoetConsent.php',
    2930        'DropUI\\Service\\StoreService' => __DIR__ . '/../..' . '/src/Service/StoreService.php',
     31        'DropUI\\Service\\WooCommerceBridge' => __DIR__ . '/../..' . '/src/Service/WooCommerceBridge.php',
     32        'DropUI\\Service\\WooCommerceSmsConsent' => __DIR__ . '/../..' . '/src/Service/WooCommerceSmsConsent.php',
    3033    );
    3134
    … …  
    3336    {
    3437        return \Closure::bind(function () use ($loader) {
    35             $loader->prefixLengthsPsr4 = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$prefixLengthsPsr4;
    36             $loader->prefixDirsPsr4 = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$prefixDirsPsr4;
    37             $loader->classMap = ComposerStaticInit9cf46fb4a3420468178145ec79ef6d1a::$classMap;
     38            $loader->prefixLengthsPsr4 = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$prefixLengthsPsr4;
     39            $loader->prefixDirsPsr4 = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$prefixDirsPsr4;
     40            $loader->classMap = ComposerStaticInit7b0e39a6d42788a3e8fd4fca5668bebf::$classMap;
    3841
    3942        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.