Plugin Directory

Changeset 3408882


Ignore:
Timestamp:
12/03/2025 06:41:11 AM (3 months ago)
Author:
convertkit
Message:

Update to version 2.0.2 from GitHub

Location:
convertkit-for-woocommerce
Files:
2 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • convertkit-for-woocommerce/tags/2.0.2/includes/class-ckwc-integration.php

    r3322555 r3408882  
    9191        add_action( 'convertkit_api_refresh_token', array( $this, 'update_credentials' ), 10, 2 );
    9292
     93        // Delete credentials if the API class uses a invalid access token.
     94        // This prevents the Plugin making repetitive API requests that will 401.
     95        add_action( 'convertkit_api_access_token_invalid', array( $this, 'maybe_delete_credentials' ), 10, 2 );
     96
    9397        // Load Admin screens, save settings.
    9498        if ( is_admin() ) {
     
    129133        }
    130134
     135        // Remove any existing persistent notice.
     136        WP_CKWC()->get_class( 'admin_notices' )->delete( 'authorization_failed' );
     137
    131138        // Update settings.
    132139        $this->update_option( 'access_token', $result['access_token'] );
     
    143150
    144151    /**
    145      * Deletes the OAuth Access Token, Refresh Token and Expiry from the Plugin's settings, if the user
    146      * clicked the Disconnect button.
    147      *
    148      * @since   1.8.0
    149      */
    150     public function maybe_disconnect() {
    151 
    152         // Bail if we're not on the integration screen for this action.
    153         if ( ! $this->get_integration_screen_name() ) {
    154             return;
    155         }
    156 
    157         // Bail if nonce verification fails.
    158         if ( ! isset( $_REQUEST['nonce'] ) ) {
    159             return;
    160         }
    161         if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ckwc-oauth-disconnect' ) ) {
    162             return;
    163         }
    164 
    165         // Delete resources.
    166         $this->resources_delete();
    167 
    168         // Remove Access Token from settings.
     152     * Deletes the stored access token, refresh token and its expiry from the Plugin settings,
     153     * and clears any existing scheduled WordPress Cron event to refresh the token on expiry,
     154     * when either:
     155     * - The access token is invalid
     156     * - The access token expired, and refreshing failed
     157     *
     158     * @since   2.0.2
     159     *
     160     * @param   WP_Error $result      Error result.
     161     * @param   string   $client_id   OAuth Client ID used for the Access and Refresh Tokens.
     162     */
     163    public function maybe_delete_credentials( $result, $client_id ) {
     164
     165        // Don't save these credentials if they're not for this Client ID.
     166        // They're for another Kit Plugin that uses OAuth.
     167        if ( $client_id !== CKWC_OAUTH_CLIENT_ID ) {
     168            return;
     169        }
     170
     171        // Persist an error notice in the WordPress Administration until the user fixes the problem.
     172        WP_CKWC()->get_class( 'admin_notices' )->add( 'authorization_failed' );
     173
     174        // Delete the credentials from the Plugin settings.
     175        $this->delete_credentials();
     176
     177    }
     178
     179    /**
     180     * Deletes any existing access token, refresh token and its expiry from the Plugin settings,
     181     * and clears any existing scheduled WordPress Cron event to refresh the token on expiry.
     182     *
     183     * @since   2.0.2
     184     */
     185    public function delete_credentials() {
     186
    169187        $this->update_option( 'access_token', '' );
    170188        $this->update_option( 'refresh_token', '' );
    171189        $this->update_option( 'token_expires', '' );
     190
     191        // Clear any existing scheduled WordPress Cron event.
     192        wp_clear_scheduled_hook( 'ckwc_refresh_token' );
     193
     194    }
     195
     196    /**
     197     * Deletes the OAuth Access Token, Refresh Token and Expiry from the Plugin's settings, if the user
     198     * clicked the Disconnect button.
     199     *
     200     * @since   1.8.0
     201     */
     202    public function maybe_disconnect() {
     203
     204        // Bail if we're not on the integration screen for this action.
     205        if ( ! $this->get_integration_screen_name() ) {
     206            return;
     207        }
     208
     209        // Bail if nonce verification fails.
     210        if ( ! isset( $_REQUEST['nonce'] ) ) {
     211            return;
     212        }
     213        if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ckwc-oauth-disconnect' ) ) {
     214            return;
     215        }
     216
     217        // Delete resources.
     218        $this->resources_delete();
     219
     220        // Remove tokens from settings.
     221        $this->delete_credentials();
    172222
    173223        // Redirect to General screen, which will now show the Plugin's settings, because the Plugin
  • convertkit-for-woocommerce/tags/2.0.2/includes/class-wp-ckwc.php

    r3261448 r3408882  
    184184            return;
    185185        }
    186         if ( ! WP_CLI ) {
     186        if ( ! WP_CLI ) { // @phpstan-ignore-line
    187187            return;
    188188        }
     
    249249    private function initialize_global() {
    250250
     251        $this->classes['admin_notices']    = new CKWC_Admin_Notices();
    251252        $this->classes['checkout']         = new CKWC_Checkout();
    252253        $this->classes['order']            = new CKWC_Order();
  • convertkit-for-woocommerce/tags/2.0.2/languages/woocommerce-convertkit.pot

    r3369639 r3408882  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Kit (formerly ConvertKit) for WooCommerce 2.0.1\n"
     5"Project-Id-Version: Kit (formerly ConvertKit) for WooCommerce 2.0.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/convertkit-woocommerce\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2025-09-29T02:55:29+00:00\n"
     12"POT-Creation-Date: 2025-12-03T01:33:06+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
     
    7474msgstr ""
    7575
     76#: includes/class-ckwc-admin-notices.php:64
     77msgid "Kit for WooCommerce: Authorization failed. Please"
     78msgstr ""
     79
     80#: includes/class-ckwc-admin-notices.php:68
     81msgid "connect your Kit account."
     82msgstr ""
     83
    7684#: includes/class-ckwc-api.php:67
    7785msgid "form_subscribe(): the form_id parameter is empty."
     
    226234msgstr ""
    227235
    228 #: includes/class-ckwc-integration.php:313
     236#: includes/class-ckwc-integration.php:363
    229237msgid "The uploaded configuration file isn't valid."
    230238msgstr ""
    231239
    232 #: includes/class-ckwc-integration.php:322
     240#: includes/class-ckwc-integration.php:372
    233241msgid "The uploaded configuration file contains no settings."
    234242msgstr ""
    235243
    236 #: includes/class-ckwc-integration.php:339
     244#: includes/class-ckwc-integration.php:389
    237245msgid "Configuration imported successfully."
    238246msgstr ""
    239247
    240 #: includes/class-ckwc-integration.php:454
     248#: includes/class-ckwc-integration.php:504
    241249msgid "Account Name"
    242250msgstr ""
    243251
    244 #: includes/class-ckwc-integration.php:456
     252#: includes/class-ckwc-integration.php:506
    245253msgid "Disconnect"
    246254msgstr ""
    247255
    248 #: includes/class-ckwc-integration.php:473
     256#: includes/class-ckwc-integration.php:523
    249257msgid "Enable/Disable"
    250258msgstr ""
    251259
    252 #: includes/class-ckwc-integration.php:475
     260#: includes/class-ckwc-integration.php:525
    253261msgid "Enable Kit integration"
    254262msgstr ""
    255263
    256 #: includes/class-ckwc-integration.php:481
     264#: includes/class-ckwc-integration.php:531
    257265msgid "Subscribe Event"
    258266msgstr ""
    259267
    260 #: includes/class-ckwc-integration.php:487
     268#: includes/class-ckwc-integration.php:537
    261269msgid "When should customers be subscribed?"
    262270msgstr ""
    263271
    264 #: includes/class-ckwc-integration.php:491
     272#: includes/class-ckwc-integration.php:541
    265273msgid "Pending payment:"
    266274msgstr ""
    267275
    268 #: includes/class-ckwc-integration.php:492
     276#: includes/class-ckwc-integration.php:542
    269277msgid "WooCommerce order created, payment not received."
    270278msgstr ""
    271279
    272 #: includes/class-ckwc-integration.php:497
    273 #: includes/class-ckwc-integration.php:709
     280#: includes/class-ckwc-integration.php:547
     281#: includes/class-ckwc-integration.php:759
    274282msgid "Processing:"
    275283msgstr ""
    276284
    277 #: includes/class-ckwc-integration.php:498
    278 #: includes/class-ckwc-integration.php:710
     285#: includes/class-ckwc-integration.php:548
     286#: includes/class-ckwc-integration.php:760
    279287msgid "WooCommerce order created, payment received, order awaiting fulfilment."
    280288msgstr ""
    281289
    282 #: includes/class-ckwc-integration.php:503
    283 #: includes/class-ckwc-integration.php:715
     290#: includes/class-ckwc-integration.php:553
     291#: includes/class-ckwc-integration.php:765
    284292msgid "Completed:"
    285293msgstr ""
    286294
    287 #: includes/class-ckwc-integration.php:504
    288 #: includes/class-ckwc-integration.php:716
     295#: includes/class-ckwc-integration.php:554
     296#: includes/class-ckwc-integration.php:766
    289297msgid "WooCommerce order created, payment received, order fulfiled."
    290298msgstr ""
    291299
    292 #: includes/class-ckwc-integration.php:510
     300#: includes/class-ckwc-integration.php:560
    293301msgid "Order Pending payment"
    294302msgstr ""
    295303
    296 #: includes/class-ckwc-integration.php:511
    297 #: includes/class-ckwc-integration.php:722
     304#: includes/class-ckwc-integration.php:561
     305#: includes/class-ckwc-integration.php:772
    298306msgid "Order Processing"
    299307msgstr ""
    300308
    301 #: includes/class-ckwc-integration.php:512
    302 #: includes/class-ckwc-integration.php:723
     309#: includes/class-ckwc-integration.php:562
     310#: includes/class-ckwc-integration.php:773
    303311msgid "Order Completed"
    304312msgstr ""
    305313
    306 #: includes/class-ckwc-integration.php:519
     314#: includes/class-ckwc-integration.php:569
    307315msgid "Subscription"
    308316msgstr ""
    309317
    310 #: includes/class-ckwc-integration.php:522
     318#: includes/class-ckwc-integration.php:572
    311319msgid "The Kit form, tag or sequence to subscribe customers to."
    312320msgstr ""
    313321
    314 #: includes/class-ckwc-integration.php:528
     322#: includes/class-ckwc-integration.php:578
    315323msgid "Name Format"
    316324msgstr ""
    317325
    318 #: includes/class-ckwc-integration.php:531
     326#: includes/class-ckwc-integration.php:581
    319327msgid "How should the customer name be sent to Kit?"
    320328msgstr ""
    321329
    322 #: includes/class-ckwc-integration.php:534
     330#: includes/class-ckwc-integration.php:584
    323331msgid "Billing First Name"
    324332msgstr ""
    325333
    326 #: includes/class-ckwc-integration.php:535
     334#: includes/class-ckwc-integration.php:585
    327335msgid "Billing Last Name"
    328336msgstr ""
    329337
    330 #: includes/class-ckwc-integration.php:536
     338#: includes/class-ckwc-integration.php:586
    331339msgid "Billing First Name + Billing Last Name"
    332340msgstr ""
    333341
    334 #: includes/class-ckwc-integration.php:545
     342#: includes/class-ckwc-integration.php:595
    335343msgid "Send Last Name"
    336344msgstr ""
    337345
    338 #: includes/class-ckwc-integration.php:548
     346#: includes/class-ckwc-integration.php:598
    339347msgid "The Kit custom field to store the order's last name."
    340348msgstr ""
    341349
    342 #: includes/class-ckwc-integration.php:554
     350#: includes/class-ckwc-integration.php:604
    343351msgid "Send Phone Number"
    344352msgstr ""
    345353
    346 #: includes/class-ckwc-integration.php:557
     354#: includes/class-ckwc-integration.php:607
    347355msgid "The Kit custom field to store the order's phone number."
    348356msgstr ""
    349357
    350 #: includes/class-ckwc-integration.php:563
     358#: includes/class-ckwc-integration.php:613
    351359msgid "Send Billing Address"
    352360msgstr ""
    353361
    354 #: includes/class-ckwc-integration.php:566
     362#: includes/class-ckwc-integration.php:616
    355363msgid "The Kit custom field to store the order's billing address."
    356364msgstr ""
    357365
    358 #: includes/class-ckwc-integration.php:572
     366#: includes/class-ckwc-integration.php:622
    359367msgid "Send Shipping Address"
    360368msgstr ""
    361369
    362 #: includes/class-ckwc-integration.php:575
     370#: includes/class-ckwc-integration.php:625
    363371msgid "The Kit custom field to store the order's shipping address."
    364372msgstr ""
    365373
    366 #: includes/class-ckwc-integration.php:581
     374#: includes/class-ckwc-integration.php:631
    367375msgid "Address Format"
    368376msgstr ""
    369377
    370 #: includes/class-ckwc-integration.php:592
     378#: includes/class-ckwc-integration.php:642
    371379msgid "The format of the billing and shipping addresses to store in Kit."
    372380msgstr ""
    373381
    374 #: includes/class-ckwc-integration.php:595
     382#: includes/class-ckwc-integration.php:645
    375383msgid "Name"
    376384msgstr ""
    377385
    378 #: includes/class-ckwc-integration.php:596
     386#: includes/class-ckwc-integration.php:646
    379387msgid "Company Name"
    380388msgstr ""
    381389
    382 #: includes/class-ckwc-integration.php:597
     390#: includes/class-ckwc-integration.php:647
    383391msgid "Address 1"
    384392msgstr ""
    385393
    386 #: includes/class-ckwc-integration.php:598
     394#: includes/class-ckwc-integration.php:648
    387395msgid "Address 2"
    388396msgstr ""
    389397
    390 #: includes/class-ckwc-integration.php:599
     398#: includes/class-ckwc-integration.php:649
    391399msgid "City"
    392400msgstr ""
    393401
    394 #: includes/class-ckwc-integration.php:600
     402#: includes/class-ckwc-integration.php:650
    395403msgid "State"
    396404msgstr ""
    397405
    398 #: includes/class-ckwc-integration.php:601
     406#: includes/class-ckwc-integration.php:651
    399407msgid "Postcode"
    400408msgstr ""
    401409
    402 #: includes/class-ckwc-integration.php:602
     410#: includes/class-ckwc-integration.php:652
    403411msgid "Country"
    404412msgstr ""
    405413
    406 #: includes/class-ckwc-integration.php:609
     414#: includes/class-ckwc-integration.php:659
    407415msgid "Send Payment Method"
    408416msgstr ""
    409417
    410 #: includes/class-ckwc-integration.php:612
     418#: includes/class-ckwc-integration.php:662
    411419msgid "The Kit custom field to store the order's payment method."
    412420msgstr ""
    413421
    414 #: includes/class-ckwc-integration.php:618
     422#: includes/class-ckwc-integration.php:668
    415423msgid "Send Customer Note"
    416424msgstr ""
    417425
    418 #: includes/class-ckwc-integration.php:621
     426#: includes/class-ckwc-integration.php:671
    419427msgid "The Kit custom field to store the order's customer note."
    420428msgstr ""
    421429
    422 #: includes/class-ckwc-integration.php:629
     430#: includes/class-ckwc-integration.php:679
    423431msgid "Opt-In Checkbox"
    424432msgstr ""
    425433
    426 #: includes/class-ckwc-integration.php:630
     434#: includes/class-ckwc-integration.php:680
    427435msgid "Display an opt-in checkbox on checkout"
    428436msgstr ""
    429437
    430 #: includes/class-ckwc-integration.php:633
     438#: includes/class-ckwc-integration.php:683
    431439msgid ""
    432440"If enabled, customers will <strong>only</strong> be subscribed to the chosen forms, tags and sequences if they check the opt-in checkbox at checkout.<br />\n"
     
    434442msgstr ""
    435443
    436 #: includes/class-ckwc-integration.php:644
     444#: includes/class-ckwc-integration.php:694
    437445msgid "Opt-In Checkbox: Label"
    438446msgstr ""
    439447
    440 #: includes/class-ckwc-integration.php:646
     448#: includes/class-ckwc-integration.php:696
    441449msgid "I want to subscribe to the newsletter"
    442450msgstr ""
    443451
    444 #: includes/class-ckwc-integration.php:647
     452#: includes/class-ckwc-integration.php:697
    445453msgid "Customize the label next to the opt-in checkbox."
    446454msgstr ""
    447455
    448 #: includes/class-ckwc-integration.php:654
     456#: includes/class-ckwc-integration.php:704
    449457msgid "Opt-In Checkbox: Default Status"
    450458msgstr ""
    451459
    452 #: includes/class-ckwc-integration.php:657
     460#: includes/class-ckwc-integration.php:707
    453461msgid "The default state of the opt-in checkbox."
    454462msgstr ""
    455463
    456 #: includes/class-ckwc-integration.php:660
     464#: includes/class-ckwc-integration.php:710
    457465msgid "Checked"
    458466msgstr ""
    459467
    460 #: includes/class-ckwc-integration.php:661
     468#: includes/class-ckwc-integration.php:711
    461469msgid "Unchecked"
    462470msgstr ""
    463471
    464 #: includes/class-ckwc-integration.php:668
     472#: includes/class-ckwc-integration.php:718
    465473msgid "Opt-In Checkbox: Display Location"
    466474msgstr ""
    467475
    468 #: includes/class-ckwc-integration.php:671
     476#: includes/class-ckwc-integration.php:721
    469477msgid "Where to display the opt-in checkbox on the checkout page (under \"Billing details\" or \"Additional information\")."
    470478msgstr ""
    471479
    472 #: includes/class-ckwc-integration.php:674
     480#: includes/class-ckwc-integration.php:724
    473481msgid "Billing"
    474482msgstr ""
    475483
    476 #: includes/class-ckwc-integration.php:675
     484#: includes/class-ckwc-integration.php:725
    477485msgid "Order"
    478486msgstr ""
    479487
    480 #: includes/class-ckwc-integration.php:684
     488#: includes/class-ckwc-integration.php:734
    481489msgid "Purchase Data"
    482490msgstr ""
    483491
    484 #: includes/class-ckwc-integration.php:685
     492#: includes/class-ckwc-integration.php:735
    485493msgid "Send purchase data to Kit."
    486494msgstr ""
    487495
    488 #: includes/class-ckwc-integration.php:688
     496#: includes/class-ckwc-integration.php:738
    489497msgid ""
    490498"If enabled, the customer's order data will be sent to Kit. Their email address will always be subscribed to Kit, <strong>regardless of the Customer's opt in status.</strong><br />\n"
     
    492500msgstr ""
    493501
    494 #: includes/class-ckwc-integration.php:699
     502#: includes/class-ckwc-integration.php:749
    495503msgid "Purchase Data Event"
    496504msgstr ""
    497505
    498 #: includes/class-ckwc-integration.php:705
     506#: includes/class-ckwc-integration.php:755
    499507msgid "When should purchase data be sent?"
    500508msgstr ""
    501509
    502 #: includes/class-ckwc-integration.php:730
     510#: includes/class-ckwc-integration.php:780
    503511msgid "Sync Past Orders"
    504512msgstr ""
    505513
    506 #: includes/class-ckwc-integration.php:731
     514#: includes/class-ckwc-integration.php:781
    507515msgid "Send old purchase data to Kit i.e. Orders that were created in WooCommerce prior to this Plugin being installed."
    508516msgstr ""
    509517
    510 #: includes/class-ckwc-integration.php:747
     518#: includes/class-ckwc-integration.php:797
    511519msgid "Debug"
    512520msgstr ""
    513521
    514 #: includes/class-ckwc-integration.php:749
     522#: includes/class-ckwc-integration.php:799
    515523msgid "Write data to a log file"
    516524msgstr ""
    517525
    518 #: includes/class-ckwc-integration.php:754
     526#: includes/class-ckwc-integration.php:804
    519527msgid "View log file"
    520528msgstr ""
    521529
    522 #: includes/class-ckwc-integration.php:824
     530#: includes/class-ckwc-integration.php:874
    523531msgid "Do you want to send past WooCommerce Orders to Kit?"
    524532msgstr ""
    525533
    526534#. translators: Number of WooCommerce Orders
    527 #: includes/class-ckwc-integration.php:1004
     535#: includes/class-ckwc-integration.php:1054
    528536#, php-format
    529537msgid "%s not been sent to Kit based on the Purchase Data Event setting above. This is either because sending purchase data is/was disabled, and/or orders were created prior to installing this integration.<br />Use the sync button to send data for these orders to Kit."
     
    531539
    532540#. translators: number of Orders not sent to ConvertKit
    533 #: includes/class-ckwc-integration.php:1007
     541#: includes/class-ckwc-integration.php:1057
    534542#, php-format
    535543msgid "%s WooCommerce order has"
     
    625633
    626634#. translators: %1$s: PHP class name
    627 #: includes/class-wp-ckwc.php:297
     635#: includes/class-wp-ckwc.php:298
    628636#, php-format
    629637msgid "Kit for WooCommerce Error: Could not load Plugin class <strong>%1$s</strong>"
    630638msgstr ""
    631639
    632 #: includes/class-wp-ckwc.php:307
     640#: includes/class-wp-ckwc.php:308
    633641msgid "Kit for WooCommerce Error"
    634642msgstr ""
  • convertkit-for-woocommerce/tags/2.0.2/readme.txt

    r3369639 r3408882  
    44Tags: email, marketing, embed form, convertkit, capture
    55Requires at least: 5.0
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.1
    8 Stable tag: 2.0.1
     8Stable tag: 2.0.2
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    4646
    4747== Changelog ==
     48
     49### 2.0.2 2025-12-03
     50* Fix: Settings: Automatically delete invalid Access Tokens
     51* Updated: Use WordPress Libraries 2.1.2
    4852
    4953### 2.0.1 2025-09-29
  • convertkit-for-woocommerce/tags/2.0.2/vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-v4.php

    r3369639 r3408882  
    378378        if ( is_wp_error( $result ) ) {
    379379            $this->log( 'API: Error: ' . $result->get_error_message() );
     380
     381            /**
     382             * Perform any actions when obtaining an access token fails.
     383             *
     384             * @since   2.1.1
     385             *
     386             * @param   WP_Error  $result     Error from API.
     387             * @param   string    $client_id  OAuth Client ID.
     388             */
     389            do_action( 'convertkit_api_get_access_token_error', $result, $this->client_id );
     390
    380391            return $result;
    381392        }
     
    415426        if ( is_wp_error( $result ) ) {
    416427            $this->log( 'API: Error: ' . $result->get_error_message() );
     428
     429            /**
     430             * Perform any actions when refreshing an expired access token fails.
     431             *
     432             * @since   2.1.1
     433             *
     434             * @param   WP_Error  $result     Error from API.
     435             * @param   string    $client_id  OAuth Client ID.
     436             */
     437            do_action( 'convertkit_api_refresh_token_error', $result, $this->client_id );
     438
    417439            return $result;
    418440        }
     
    14331455        // Return the API error message as a WP_Error if the HTTP response code is a 4xx code.
    14341456        if ( $http_response_code >= 400 ) {
     1457
    14351458            // Define the error message.
    14361459            $error = $this->get_error_message_string( $response );
     
    14391462
    14401463            switch ( $http_response_code ) {
    1441                 // If the HTTP response code is 401, and the error matches 'The access token expired', refresh the access token now
    1442                 // and re-attempt the request.
    14431464                case 401:
    1444                     if ( $error !== 'The access token expired' ) {
    1445                         break;
     1465                    switch ( $error ) {
     1466                        case 'The access token expired':
     1467                            // Attempt to refresh the access token.
     1468                            $result = $this->refresh_token();
     1469
     1470                            // If an error occured, bail.
     1471                            if ( is_wp_error( $result ) ) {
     1472                                return $result;
     1473                            }
     1474
     1475                            // Attempt the request again, now we have a new access token.
     1476                            return $this->request( $endpoint, $method, $params, false );
     1477
     1478                        case 'The access token is invalid':
     1479                            $error = new WP_Error(
     1480                                'convertkit_api_error',
     1481                                $error,
     1482                                $http_response_code
     1483                            );
     1484
     1485                            /**
     1486                             * Perform any actions when an invalid access token was used.
     1487                             *
     1488                             * @since   2.1.1
     1489                             *
     1490                             * @param   WP_Error  $error      WP_Error object.
     1491                             * @param   string    $client_id  OAuth Client ID.
     1492                             */
     1493                            do_action( 'convertkit_api_access_token_invalid', $error, $this->client_id );
     1494
     1495                            // Return error.
     1496                            return $error;
     1497
     1498                        default:
     1499                            return new WP_Error(
     1500                                'convertkit_api_error',
     1501                                $error,
     1502                                $http_response_code
     1503                            );
    14461504                    }
    14471505
    1448                     // Don't automatically refresh the expired access token if we're not on a production environment.
    1449                     // This prevents the same ConvertKit account used on both a staging and production site from
    1450                     // reaching a race condition where the staging site refreshes the token first, resulting in
    1451                     // the production site unable to later refresh its same expired access token.
    1452                     if ( ! $this->is_production_site() ) {
    1453                         break;
    1454                     }
    1455 
    1456                     // Refresh the access token.
    1457                     $result = $this->refresh_token();
    1458 
    1459                     // If an error occured, bail.
    1460                     if ( is_wp_error( $result ) ) {
    1461                         return $result;
    1462                     }
    1463 
    1464                     // Attempt the request again, now we have a new access token.
    1465                     return $this->request( $endpoint, $method, $params, false );
    1466 
    1467                 // If a rate limit was hit, maybe try again.
    14681506                case 429:
    14691507                    // If retry on rate limit hit is disabled, return a WP_Error.
     
    14891527
    14901528        return $response;
    1491 
    1492     }
    1493 
    1494     /**
    1495      * Helper method to determine the WordPress environment type, checking
    1496      * if the wp_get_environment_type() function exists in WordPress (versions
    1497      * older than WordPress 5.5 won't have this function).
    1498      *
    1499      * @since   2.0.2
    1500      *
    1501      * @return  bool
    1502      */
    1503     private function is_production_site() {
    1504 
    1505         // If the WordPress wp_get_environment_type() function isn't available,
    1506         // assume this is a production site.
    1507         if ( ! function_exists( 'wp_get_environment_type' ) ) {
    1508             return true;
    1509         }
    1510 
    1511         return ( wp_get_environment_type() === 'production' );
    15121529
    15131530    }
  • convertkit-for-woocommerce/tags/2.0.2/vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-resource-v4.php

    r3112082 r3408882  
    117117        // would never expire.
    118118        if ( ! $this->last_queried ) {
    119             $this->refresh();
    120             return;
     119            return $this->refresh();
    121120        }
    122121
    123122        // If the resources have expired, refresh them now.
    124123        if ( time() > ( $this->last_queried + $this->cache_duration ) ) {
    125             $this->refresh();
    126             return;
     124            return $this->refresh();
    127125        }
    128126
     
    345343     * @since   1.0.0
    346344     *
    347      * @return  bool|WP_Error|array
     345     * @return  WP_Error|array
    348346     */
    349347    public function refresh() {
     
    351349        // Bail if no API class was defined.
    352350        if ( ! $this->api ) {
    353             return false;
     351            return new WP_Error( 'convertkit_resource_refresh_error', 'Connect the Plugin to your Kit account to refresh resources.' );
    354352        }
    355353
  • convertkit-for-woocommerce/tags/2.0.2/woocommerce-convertkit.php

    r3369639 r3408882  
    1010 * Plugin URI:  https://www.kit.com
    1111 * Description: Integrates WooCommerce with Kit, allowing customers to be automatically sent to your Kit account.
    12  * Version:     2.0.1
     12 * Version:     2.0.2
    1313 * Author:      Kit
    1414 * Author URI:  https://www.kit.com
     
    3131define( 'CKWC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    3232define( 'CKWC_PLUGIN_PATH', __DIR__ );
    33 define( 'CKWC_PLUGIN_VERSION', '2.0.1' );
     33define( 'CKWC_PLUGIN_VERSION', '2.0.2' );
    3434define( 'CKWC_OAUTH_CLIENT_ID', 'L0kyADsB3WP5zO5MvUpXQU64gIntQg9BBAIme17r_7A' );
    3535define( 'CKWC_OAUTH_CLIENT_REDIRECT_URI', 'https://app.kit.com/wordpress/redirect' );
     
    5353require_once CKWC_PLUGIN_PATH . '/includes/functions.php';
    5454require_once CKWC_PLUGIN_PATH . '/includes/class-wp-ckwc.php';
     55require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-admin-notices.php';
    5556require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-api.php';
    5657require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-checkout.php';
  • convertkit-for-woocommerce/trunk/includes/class-ckwc-integration.php

    r3322555 r3408882  
    9191        add_action( 'convertkit_api_refresh_token', array( $this, 'update_credentials' ), 10, 2 );
    9292
     93        // Delete credentials if the API class uses a invalid access token.
     94        // This prevents the Plugin making repetitive API requests that will 401.
     95        add_action( 'convertkit_api_access_token_invalid', array( $this, 'maybe_delete_credentials' ), 10, 2 );
     96
    9397        // Load Admin screens, save settings.
    9498        if ( is_admin() ) {
     
    129133        }
    130134
     135        // Remove any existing persistent notice.
     136        WP_CKWC()->get_class( 'admin_notices' )->delete( 'authorization_failed' );
     137
    131138        // Update settings.
    132139        $this->update_option( 'access_token', $result['access_token'] );
     
    143150
    144151    /**
    145      * Deletes the OAuth Access Token, Refresh Token and Expiry from the Plugin's settings, if the user
    146      * clicked the Disconnect button.
    147      *
    148      * @since   1.8.0
    149      */
    150     public function maybe_disconnect() {
    151 
    152         // Bail if we're not on the integration screen for this action.
    153         if ( ! $this->get_integration_screen_name() ) {
    154             return;
    155         }
    156 
    157         // Bail if nonce verification fails.
    158         if ( ! isset( $_REQUEST['nonce'] ) ) {
    159             return;
    160         }
    161         if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ckwc-oauth-disconnect' ) ) {
    162             return;
    163         }
    164 
    165         // Delete resources.
    166         $this->resources_delete();
    167 
    168         // Remove Access Token from settings.
     152     * Deletes the stored access token, refresh token and its expiry from the Plugin settings,
     153     * and clears any existing scheduled WordPress Cron event to refresh the token on expiry,
     154     * when either:
     155     * - The access token is invalid
     156     * - The access token expired, and refreshing failed
     157     *
     158     * @since   2.0.2
     159     *
     160     * @param   WP_Error $result      Error result.
     161     * @param   string   $client_id   OAuth Client ID used for the Access and Refresh Tokens.
     162     */
     163    public function maybe_delete_credentials( $result, $client_id ) {
     164
     165        // Don't save these credentials if they're not for this Client ID.
     166        // They're for another Kit Plugin that uses OAuth.
     167        if ( $client_id !== CKWC_OAUTH_CLIENT_ID ) {
     168            return;
     169        }
     170
     171        // Persist an error notice in the WordPress Administration until the user fixes the problem.
     172        WP_CKWC()->get_class( 'admin_notices' )->add( 'authorization_failed' );
     173
     174        // Delete the credentials from the Plugin settings.
     175        $this->delete_credentials();
     176
     177    }
     178
     179    /**
     180     * Deletes any existing access token, refresh token and its expiry from the Plugin settings,
     181     * and clears any existing scheduled WordPress Cron event to refresh the token on expiry.
     182     *
     183     * @since   2.0.2
     184     */
     185    public function delete_credentials() {
     186
    169187        $this->update_option( 'access_token', '' );
    170188        $this->update_option( 'refresh_token', '' );
    171189        $this->update_option( 'token_expires', '' );
     190
     191        // Clear any existing scheduled WordPress Cron event.
     192        wp_clear_scheduled_hook( 'ckwc_refresh_token' );
     193
     194    }
     195
     196    /**
     197     * Deletes the OAuth Access Token, Refresh Token and Expiry from the Plugin's settings, if the user
     198     * clicked the Disconnect button.
     199     *
     200     * @since   1.8.0
     201     */
     202    public function maybe_disconnect() {
     203
     204        // Bail if we're not on the integration screen for this action.
     205        if ( ! $this->get_integration_screen_name() ) {
     206            return;
     207        }
     208
     209        // Bail if nonce verification fails.
     210        if ( ! isset( $_REQUEST['nonce'] ) ) {
     211            return;
     212        }
     213        if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ckwc-oauth-disconnect' ) ) {
     214            return;
     215        }
     216
     217        // Delete resources.
     218        $this->resources_delete();
     219
     220        // Remove tokens from settings.
     221        $this->delete_credentials();
    172222
    173223        // Redirect to General screen, which will now show the Plugin's settings, because the Plugin
  • convertkit-for-woocommerce/trunk/includes/class-wp-ckwc.php

    r3261448 r3408882  
    184184            return;
    185185        }
    186         if ( ! WP_CLI ) {
     186        if ( ! WP_CLI ) { // @phpstan-ignore-line
    187187            return;
    188188        }
     
    249249    private function initialize_global() {
    250250
     251        $this->classes['admin_notices']    = new CKWC_Admin_Notices();
    251252        $this->classes['checkout']         = new CKWC_Checkout();
    252253        $this->classes['order']            = new CKWC_Order();
  • convertkit-for-woocommerce/trunk/languages/woocommerce-convertkit.pot

    r3369639 r3408882  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Kit (formerly ConvertKit) for WooCommerce 2.0.1\n"
     5"Project-Id-Version: Kit (formerly ConvertKit) for WooCommerce 2.0.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/convertkit-woocommerce\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2025-09-29T02:55:29+00:00\n"
     12"POT-Creation-Date: 2025-12-03T01:33:06+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
     
    7474msgstr ""
    7575
     76#: includes/class-ckwc-admin-notices.php:64
     77msgid "Kit for WooCommerce: Authorization failed. Please"
     78msgstr ""
     79
     80#: includes/class-ckwc-admin-notices.php:68
     81msgid "connect your Kit account."
     82msgstr ""
     83
    7684#: includes/class-ckwc-api.php:67
    7785msgid "form_subscribe(): the form_id parameter is empty."
     
    226234msgstr ""
    227235
    228 #: includes/class-ckwc-integration.php:313
     236#: includes/class-ckwc-integration.php:363
    229237msgid "The uploaded configuration file isn't valid."
    230238msgstr ""
    231239
    232 #: includes/class-ckwc-integration.php:322
     240#: includes/class-ckwc-integration.php:372
    233241msgid "The uploaded configuration file contains no settings."
    234242msgstr ""
    235243
    236 #: includes/class-ckwc-integration.php:339
     244#: includes/class-ckwc-integration.php:389
    237245msgid "Configuration imported successfully."
    238246msgstr ""
    239247
    240 #: includes/class-ckwc-integration.php:454
     248#: includes/class-ckwc-integration.php:504
    241249msgid "Account Name"
    242250msgstr ""
    243251
    244 #: includes/class-ckwc-integration.php:456
     252#: includes/class-ckwc-integration.php:506
    245253msgid "Disconnect"
    246254msgstr ""
    247255
    248 #: includes/class-ckwc-integration.php:473
     256#: includes/class-ckwc-integration.php:523
    249257msgid "Enable/Disable"
    250258msgstr ""
    251259
    252 #: includes/class-ckwc-integration.php:475
     260#: includes/class-ckwc-integration.php:525
    253261msgid "Enable Kit integration"
    254262msgstr ""
    255263
    256 #: includes/class-ckwc-integration.php:481
     264#: includes/class-ckwc-integration.php:531
    257265msgid "Subscribe Event"
    258266msgstr ""
    259267
    260 #: includes/class-ckwc-integration.php:487
     268#: includes/class-ckwc-integration.php:537
    261269msgid "When should customers be subscribed?"
    262270msgstr ""
    263271
    264 #: includes/class-ckwc-integration.php:491
     272#: includes/class-ckwc-integration.php:541
    265273msgid "Pending payment:"
    266274msgstr ""
    267275
    268 #: includes/class-ckwc-integration.php:492
     276#: includes/class-ckwc-integration.php:542
    269277msgid "WooCommerce order created, payment not received."
    270278msgstr ""
    271279
    272 #: includes/class-ckwc-integration.php:497
    273 #: includes/class-ckwc-integration.php:709
     280#: includes/class-ckwc-integration.php:547
     281#: includes/class-ckwc-integration.php:759
    274282msgid "Processing:"
    275283msgstr ""
    276284
    277 #: includes/class-ckwc-integration.php:498
    278 #: includes/class-ckwc-integration.php:710
     285#: includes/class-ckwc-integration.php:548
     286#: includes/class-ckwc-integration.php:760
    279287msgid "WooCommerce order created, payment received, order awaiting fulfilment."
    280288msgstr ""
    281289
    282 #: includes/class-ckwc-integration.php:503
    283 #: includes/class-ckwc-integration.php:715
     290#: includes/class-ckwc-integration.php:553
     291#: includes/class-ckwc-integration.php:765
    284292msgid "Completed:"
    285293msgstr ""
    286294
    287 #: includes/class-ckwc-integration.php:504
    288 #: includes/class-ckwc-integration.php:716
     295#: includes/class-ckwc-integration.php:554
     296#: includes/class-ckwc-integration.php:766
    289297msgid "WooCommerce order created, payment received, order fulfiled."
    290298msgstr ""
    291299
    292 #: includes/class-ckwc-integration.php:510
     300#: includes/class-ckwc-integration.php:560
    293301msgid "Order Pending payment"
    294302msgstr ""
    295303
    296 #: includes/class-ckwc-integration.php:511
    297 #: includes/class-ckwc-integration.php:722
     304#: includes/class-ckwc-integration.php:561
     305#: includes/class-ckwc-integration.php:772
    298306msgid "Order Processing"
    299307msgstr ""
    300308
    301 #: includes/class-ckwc-integration.php:512
    302 #: includes/class-ckwc-integration.php:723
     309#: includes/class-ckwc-integration.php:562
     310#: includes/class-ckwc-integration.php:773
    303311msgid "Order Completed"
    304312msgstr ""
    305313
    306 #: includes/class-ckwc-integration.php:519
     314#: includes/class-ckwc-integration.php:569
    307315msgid "Subscription"
    308316msgstr ""
    309317
    310 #: includes/class-ckwc-integration.php:522
     318#: includes/class-ckwc-integration.php:572
    311319msgid "The Kit form, tag or sequence to subscribe customers to."
    312320msgstr ""
    313321
    314 #: includes/class-ckwc-integration.php:528
     322#: includes/class-ckwc-integration.php:578
    315323msgid "Name Format"
    316324msgstr ""
    317325
    318 #: includes/class-ckwc-integration.php:531
     326#: includes/class-ckwc-integration.php:581
    319327msgid "How should the customer name be sent to Kit?"
    320328msgstr ""
    321329
    322 #: includes/class-ckwc-integration.php:534
     330#: includes/class-ckwc-integration.php:584
    323331msgid "Billing First Name"
    324332msgstr ""
    325333
    326 #: includes/class-ckwc-integration.php:535
     334#: includes/class-ckwc-integration.php:585
    327335msgid "Billing Last Name"
    328336msgstr ""
    329337
    330 #: includes/class-ckwc-integration.php:536
     338#: includes/class-ckwc-integration.php:586
    331339msgid "Billing First Name + Billing Last Name"
    332340msgstr ""
    333341
    334 #: includes/class-ckwc-integration.php:545
     342#: includes/class-ckwc-integration.php:595
    335343msgid "Send Last Name"
    336344msgstr ""
    337345
    338 #: includes/class-ckwc-integration.php:548
     346#: includes/class-ckwc-integration.php:598
    339347msgid "The Kit custom field to store the order's last name."
    340348msgstr ""
    341349
    342 #: includes/class-ckwc-integration.php:554
     350#: includes/class-ckwc-integration.php:604
    343351msgid "Send Phone Number"
    344352msgstr ""
    345353
    346 #: includes/class-ckwc-integration.php:557
     354#: includes/class-ckwc-integration.php:607
    347355msgid "The Kit custom field to store the order's phone number."
    348356msgstr ""
    349357
    350 #: includes/class-ckwc-integration.php:563
     358#: includes/class-ckwc-integration.php:613
    351359msgid "Send Billing Address"
    352360msgstr ""
    353361
    354 #: includes/class-ckwc-integration.php:566
     362#: includes/class-ckwc-integration.php:616
    355363msgid "The Kit custom field to store the order's billing address."
    356364msgstr ""
    357365
    358 #: includes/class-ckwc-integration.php:572
     366#: includes/class-ckwc-integration.php:622
    359367msgid "Send Shipping Address"
    360368msgstr ""
    361369
    362 #: includes/class-ckwc-integration.php:575
     370#: includes/class-ckwc-integration.php:625
    363371msgid "The Kit custom field to store the order's shipping address."
    364372msgstr ""
    365373
    366 #: includes/class-ckwc-integration.php:581
     374#: includes/class-ckwc-integration.php:631
    367375msgid "Address Format"
    368376msgstr ""
    369377
    370 #: includes/class-ckwc-integration.php:592
     378#: includes/class-ckwc-integration.php:642
    371379msgid "The format of the billing and shipping addresses to store in Kit."
    372380msgstr ""
    373381
    374 #: includes/class-ckwc-integration.php:595
     382#: includes/class-ckwc-integration.php:645
    375383msgid "Name"
    376384msgstr ""
    377385
    378 #: includes/class-ckwc-integration.php:596
     386#: includes/class-ckwc-integration.php:646
    379387msgid "Company Name"
    380388msgstr ""
    381389
    382 #: includes/class-ckwc-integration.php:597
     390#: includes/class-ckwc-integration.php:647
    383391msgid "Address 1"
    384392msgstr ""
    385393
    386 #: includes/class-ckwc-integration.php:598
     394#: includes/class-ckwc-integration.php:648
    387395msgid "Address 2"
    388396msgstr ""
    389397
    390 #: includes/class-ckwc-integration.php:599
     398#: includes/class-ckwc-integration.php:649
    391399msgid "City"
    392400msgstr ""
    393401
    394 #: includes/class-ckwc-integration.php:600
     402#: includes/class-ckwc-integration.php:650
    395403msgid "State"
    396404msgstr ""
    397405
    398 #: includes/class-ckwc-integration.php:601
     406#: includes/class-ckwc-integration.php:651
    399407msgid "Postcode"
    400408msgstr ""
    401409
    402 #: includes/class-ckwc-integration.php:602
     410#: includes/class-ckwc-integration.php:652
    403411msgid "Country"
    404412msgstr ""
    405413
    406 #: includes/class-ckwc-integration.php:609
     414#: includes/class-ckwc-integration.php:659
    407415msgid "Send Payment Method"
    408416msgstr ""
    409417
    410 #: includes/class-ckwc-integration.php:612
     418#: includes/class-ckwc-integration.php:662
    411419msgid "The Kit custom field to store the order's payment method."
    412420msgstr ""
    413421
    414 #: includes/class-ckwc-integration.php:618
     422#: includes/class-ckwc-integration.php:668
    415423msgid "Send Customer Note"
    416424msgstr ""
    417425
    418 #: includes/class-ckwc-integration.php:621
     426#: includes/class-ckwc-integration.php:671
    419427msgid "The Kit custom field to store the order's customer note."
    420428msgstr ""
    421429
    422 #: includes/class-ckwc-integration.php:629
     430#: includes/class-ckwc-integration.php:679
    423431msgid "Opt-In Checkbox"
    424432msgstr ""
    425433
    426 #: includes/class-ckwc-integration.php:630
     434#: includes/class-ckwc-integration.php:680
    427435msgid "Display an opt-in checkbox on checkout"
    428436msgstr ""
    429437
    430 #: includes/class-ckwc-integration.php:633
     438#: includes/class-ckwc-integration.php:683
    431439msgid ""
    432440"If enabled, customers will <strong>only</strong> be subscribed to the chosen forms, tags and sequences if they check the opt-in checkbox at checkout.<br />\n"
     
    434442msgstr ""
    435443
    436 #: includes/class-ckwc-integration.php:644
     444#: includes/class-ckwc-integration.php:694
    437445msgid "Opt-In Checkbox: Label"
    438446msgstr ""
    439447
    440 #: includes/class-ckwc-integration.php:646
     448#: includes/class-ckwc-integration.php:696
    441449msgid "I want to subscribe to the newsletter"
    442450msgstr ""
    443451
    444 #: includes/class-ckwc-integration.php:647
     452#: includes/class-ckwc-integration.php:697
    445453msgid "Customize the label next to the opt-in checkbox."
    446454msgstr ""
    447455
    448 #: includes/class-ckwc-integration.php:654
     456#: includes/class-ckwc-integration.php:704
    449457msgid "Opt-In Checkbox: Default Status"
    450458msgstr ""
    451459
    452 #: includes/class-ckwc-integration.php:657
     460#: includes/class-ckwc-integration.php:707
    453461msgid "The default state of the opt-in checkbox."
    454462msgstr ""
    455463
    456 #: includes/class-ckwc-integration.php:660
     464#: includes/class-ckwc-integration.php:710
    457465msgid "Checked"
    458466msgstr ""
    459467
    460 #: includes/class-ckwc-integration.php:661
     468#: includes/class-ckwc-integration.php:711
    461469msgid "Unchecked"
    462470msgstr ""
    463471
    464 #: includes/class-ckwc-integration.php:668
     472#: includes/class-ckwc-integration.php:718
    465473msgid "Opt-In Checkbox: Display Location"
    466474msgstr ""
    467475
    468 #: includes/class-ckwc-integration.php:671
     476#: includes/class-ckwc-integration.php:721
    469477msgid "Where to display the opt-in checkbox on the checkout page (under \"Billing details\" or \"Additional information\")."
    470478msgstr ""
    471479
    472 #: includes/class-ckwc-integration.php:674
     480#: includes/class-ckwc-integration.php:724
    473481msgid "Billing"
    474482msgstr ""
    475483
    476 #: includes/class-ckwc-integration.php:675
     484#: includes/class-ckwc-integration.php:725
    477485msgid "Order"
    478486msgstr ""
    479487
    480 #: includes/class-ckwc-integration.php:684
     488#: includes/class-ckwc-integration.php:734
    481489msgid "Purchase Data"
    482490msgstr ""
    483491
    484 #: includes/class-ckwc-integration.php:685
     492#: includes/class-ckwc-integration.php:735
    485493msgid "Send purchase data to Kit."
    486494msgstr ""
    487495
    488 #: includes/class-ckwc-integration.php:688
     496#: includes/class-ckwc-integration.php:738
    489497msgid ""
    490498"If enabled, the customer's order data will be sent to Kit. Their email address will always be subscribed to Kit, <strong>regardless of the Customer's opt in status.</strong><br />\n"
     
    492500msgstr ""
    493501
    494 #: includes/class-ckwc-integration.php:699
     502#: includes/class-ckwc-integration.php:749
    495503msgid "Purchase Data Event"
    496504msgstr ""
    497505
    498 #: includes/class-ckwc-integration.php:705
     506#: includes/class-ckwc-integration.php:755
    499507msgid "When should purchase data be sent?"
    500508msgstr ""
    501509
    502 #: includes/class-ckwc-integration.php:730
     510#: includes/class-ckwc-integration.php:780
    503511msgid "Sync Past Orders"
    504512msgstr ""
    505513
    506 #: includes/class-ckwc-integration.php:731
     514#: includes/class-ckwc-integration.php:781
    507515msgid "Send old purchase data to Kit i.e. Orders that were created in WooCommerce prior to this Plugin being installed."
    508516msgstr ""
    509517
    510 #: includes/class-ckwc-integration.php:747
     518#: includes/class-ckwc-integration.php:797
    511519msgid "Debug"
    512520msgstr ""
    513521
    514 #: includes/class-ckwc-integration.php:749
     522#: includes/class-ckwc-integration.php:799
    515523msgid "Write data to a log file"
    516524msgstr ""
    517525
    518 #: includes/class-ckwc-integration.php:754
     526#: includes/class-ckwc-integration.php:804
    519527msgid "View log file"
    520528msgstr ""
    521529
    522 #: includes/class-ckwc-integration.php:824
     530#: includes/class-ckwc-integration.php:874
    523531msgid "Do you want to send past WooCommerce Orders to Kit?"
    524532msgstr ""
    525533
    526534#. translators: Number of WooCommerce Orders
    527 #: includes/class-ckwc-integration.php:1004
     535#: includes/class-ckwc-integration.php:1054
    528536#, php-format
    529537msgid "%s not been sent to Kit based on the Purchase Data Event setting above. This is either because sending purchase data is/was disabled, and/or orders were created prior to installing this integration.<br />Use the sync button to send data for these orders to Kit."
     
    531539
    532540#. translators: number of Orders not sent to ConvertKit
    533 #: includes/class-ckwc-integration.php:1007
     541#: includes/class-ckwc-integration.php:1057
    534542#, php-format
    535543msgid "%s WooCommerce order has"
     
    625633
    626634#. translators: %1$s: PHP class name
    627 #: includes/class-wp-ckwc.php:297
     635#: includes/class-wp-ckwc.php:298
    628636#, php-format
    629637msgid "Kit for WooCommerce Error: Could not load Plugin class <strong>%1$s</strong>"
    630638msgstr ""
    631639
    632 #: includes/class-wp-ckwc.php:307
     640#: includes/class-wp-ckwc.php:308
    633641msgid "Kit for WooCommerce Error"
    634642msgstr ""
  • convertkit-for-woocommerce/trunk/readme.txt

    r3369639 r3408882  
    44Tags: email, marketing, embed form, convertkit, capture
    55Requires at least: 5.0
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.1
    8 Stable tag: 2.0.1
     8Stable tag: 2.0.2
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    4646
    4747== Changelog ==
     48
     49### 2.0.2 2025-12-03
     50* Fix: Settings: Automatically delete invalid Access Tokens
     51* Updated: Use WordPress Libraries 2.1.2
    4852
    4953### 2.0.1 2025-09-29
  • convertkit-for-woocommerce/trunk/vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-v4.php

    r3369639 r3408882  
    378378        if ( is_wp_error( $result ) ) {
    379379            $this->log( 'API: Error: ' . $result->get_error_message() );
     380
     381            /**
     382             * Perform any actions when obtaining an access token fails.
     383             *
     384             * @since   2.1.1
     385             *
     386             * @param   WP_Error  $result     Error from API.
     387             * @param   string    $client_id  OAuth Client ID.
     388             */
     389            do_action( 'convertkit_api_get_access_token_error', $result, $this->client_id );
     390
    380391            return $result;
    381392        }
     
    415426        if ( is_wp_error( $result ) ) {
    416427            $this->log( 'API: Error: ' . $result->get_error_message() );
     428
     429            /**
     430             * Perform any actions when refreshing an expired access token fails.
     431             *
     432             * @since   2.1.1
     433             *
     434             * @param   WP_Error  $result     Error from API.
     435             * @param   string    $client_id  OAuth Client ID.
     436             */
     437            do_action( 'convertkit_api_refresh_token_error', $result, $this->client_id );
     438
    417439            return $result;
    418440        }
     
    14331455        // Return the API error message as a WP_Error if the HTTP response code is a 4xx code.
    14341456        if ( $http_response_code >= 400 ) {
     1457
    14351458            // Define the error message.
    14361459            $error = $this->get_error_message_string( $response );
     
    14391462
    14401463            switch ( $http_response_code ) {
    1441                 // If the HTTP response code is 401, and the error matches 'The access token expired', refresh the access token now
    1442                 // and re-attempt the request.
    14431464                case 401:
    1444                     if ( $error !== 'The access token expired' ) {
    1445                         break;
     1465                    switch ( $error ) {
     1466                        case 'The access token expired':
     1467                            // Attempt to refresh the access token.
     1468                            $result = $this->refresh_token();
     1469
     1470                            // If an error occured, bail.
     1471                            if ( is_wp_error( $result ) ) {
     1472                                return $result;
     1473                            }
     1474
     1475                            // Attempt the request again, now we have a new access token.
     1476                            return $this->request( $endpoint, $method, $params, false );
     1477
     1478                        case 'The access token is invalid':
     1479                            $error = new WP_Error(
     1480                                'convertkit_api_error',
     1481                                $error,
     1482                                $http_response_code
     1483                            );
     1484
     1485                            /**
     1486                             * Perform any actions when an invalid access token was used.
     1487                             *
     1488                             * @since   2.1.1
     1489                             *
     1490                             * @param   WP_Error  $error      WP_Error object.
     1491                             * @param   string    $client_id  OAuth Client ID.
     1492                             */
     1493                            do_action( 'convertkit_api_access_token_invalid', $error, $this->client_id );
     1494
     1495                            // Return error.
     1496                            return $error;
     1497
     1498                        default:
     1499                            return new WP_Error(
     1500                                'convertkit_api_error',
     1501                                $error,
     1502                                $http_response_code
     1503                            );
    14461504                    }
    14471505
    1448                     // Don't automatically refresh the expired access token if we're not on a production environment.
    1449                     // This prevents the same ConvertKit account used on both a staging and production site from
    1450                     // reaching a race condition where the staging site refreshes the token first, resulting in
    1451                     // the production site unable to later refresh its same expired access token.
    1452                     if ( ! $this->is_production_site() ) {
    1453                         break;
    1454                     }
    1455 
    1456                     // Refresh the access token.
    1457                     $result = $this->refresh_token();
    1458 
    1459                     // If an error occured, bail.
    1460                     if ( is_wp_error( $result ) ) {
    1461                         return $result;
    1462                     }
    1463 
    1464                     // Attempt the request again, now we have a new access token.
    1465                     return $this->request( $endpoint, $method, $params, false );
    1466 
    1467                 // If a rate limit was hit, maybe try again.
    14681506                case 429:
    14691507                    // If retry on rate limit hit is disabled, return a WP_Error.
     
    14891527
    14901528        return $response;
    1491 
    1492     }
    1493 
    1494     /**
    1495      * Helper method to determine the WordPress environment type, checking
    1496      * if the wp_get_environment_type() function exists in WordPress (versions
    1497      * older than WordPress 5.5 won't have this function).
    1498      *
    1499      * @since   2.0.2
    1500      *
    1501      * @return  bool
    1502      */
    1503     private function is_production_site() {
    1504 
    1505         // If the WordPress wp_get_environment_type() function isn't available,
    1506         // assume this is a production site.
    1507         if ( ! function_exists( 'wp_get_environment_type' ) ) {
    1508             return true;
    1509         }
    1510 
    1511         return ( wp_get_environment_type() === 'production' );
    15121529
    15131530    }
  • convertkit-for-woocommerce/trunk/vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-resource-v4.php

    r3112082 r3408882  
    117117        // would never expire.
    118118        if ( ! $this->last_queried ) {
    119             $this->refresh();
    120             return;
     119            return $this->refresh();
    121120        }
    122121
    123122        // If the resources have expired, refresh them now.
    124123        if ( time() > ( $this->last_queried + $this->cache_duration ) ) {
    125             $this->refresh();
    126             return;
     124            return $this->refresh();
    127125        }
    128126
     
    345343     * @since   1.0.0
    346344     *
    347      * @return  bool|WP_Error|array
     345     * @return  WP_Error|array
    348346     */
    349347    public function refresh() {
     
    351349        // Bail if no API class was defined.
    352350        if ( ! $this->api ) {
    353             return false;
     351            return new WP_Error( 'convertkit_resource_refresh_error', 'Connect the Plugin to your Kit account to refresh resources.' );
    354352        }
    355353
  • convertkit-for-woocommerce/trunk/woocommerce-convertkit.php

    r3369639 r3408882  
    1010 * Plugin URI:  https://www.kit.com
    1111 * Description: Integrates WooCommerce with Kit, allowing customers to be automatically sent to your Kit account.
    12  * Version:     2.0.1
     12 * Version:     2.0.2
    1313 * Author:      Kit
    1414 * Author URI:  https://www.kit.com
     
    3131define( 'CKWC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    3232define( 'CKWC_PLUGIN_PATH', __DIR__ );
    33 define( 'CKWC_PLUGIN_VERSION', '2.0.1' );
     33define( 'CKWC_PLUGIN_VERSION', '2.0.2' );
    3434define( 'CKWC_OAUTH_CLIENT_ID', 'L0kyADsB3WP5zO5MvUpXQU64gIntQg9BBAIme17r_7A' );
    3535define( 'CKWC_OAUTH_CLIENT_REDIRECT_URI', 'https://app.kit.com/wordpress/redirect' );
     
    5353require_once CKWC_PLUGIN_PATH . '/includes/functions.php';
    5454require_once CKWC_PLUGIN_PATH . '/includes/class-wp-ckwc.php';
     55require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-admin-notices.php';
    5556require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-api.php';
    5657require_once CKWC_PLUGIN_PATH . '/includes/class-ckwc-checkout.php';
Note: See TracChangeset for help on using the changeset viewer.