Plugin Directory

Changeset 3389314


Ignore:
Timestamp:
11/04/2025 04:19:44 AM (5 months ago)
Author:
evcode
Message:

Update to version 1.3.3 from GitHub

Location:
myd-delivery
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • myd-delivery/tags/1.3.3/README.txt

    r3389122 r3389314  
    55Requires at least: 5.5
    66Tested up to: 6.8
    7 Stable tag: 1.3.2
     7Stable tag: 1.3.3
    88Requires PHP: 7.4
    99License: GPL-3.0+
     
    7676== Changelog ==
    7777
     78= 1.3.3 =
     79* Changed: code support to print function refactoring in pro version.
     80* Changed: code improvements.
     81
    7882= 1.3.2 =
    7983* Changed: code improvements in Mercado Pago integration.
  • myd-delivery/tags/1.3.3/includes/telemetry/class-snapshots.php

    r3389122 r3389314  
    1515    const MAX_SNAPSHOTS = 7;
    1616    const OPTION_KEY = 'myddelivery_telemetry_snapshots';
     17    const ENDPOINT = 'https://api.myddelivery.com/api/telemetry';
     18    const SECRET = '63d704ae5e6f4c0a465790ce666b7c7a8e9c9c4f7eb02ec35246eac96b9c3475';
    1719    /**
    1820     * Capture a snapshot of the current plugin state
     
    9193            'products_count' => $products_count,
    9294            'product_categories_count' => $categories_count,
     95            'orders_count' => 0,
    9396            'whatsapp_redirect_enabled' => $whatsapp_redirect_enabled,
    9497        ];
     
    112115
    113116        \update_option( self::OPTION_KEY, $snapshots, false );
     117
     118        if ( ! \wp_next_scheduled('myddelivery_send_snapshot_once') ) {
     119            \wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'myddelivery_send_snapshot_once' );
     120        }
    114121    }
    115122
     
    126133    public static function set_collect_snapshots() {
    127134        \add_action( 'myddelivery_collect_snapshot', [ self::class, 'store_snapshot' ] );
     135        \add_action( 'myddelivery_send_snapshot_once', [ self::class, 'send' ] );
    128136
    129137        if ( ! \wp_next_scheduled( 'myddelivery_collect_snapshot' ) ) {
     
    131139        }
    132140    }
     141
     142    /**
     143     * Send stored snapshots to telemetry endpoint
     144     */
     145    public static function send() {
     146        $snapshots = self::get_snapshots();
     147        if ( empty( $snapshots ) ) {
     148            return new \WP_Error( 'myd_telemetry', 'No provided snapshots.' );
     149        }
     150
     151        $body = \wp_json_encode(
     152            $snapshots,
     153            JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
     154        );
     155        if ( false === $body ) {
     156            return new \WP_Error( 'myd_telemetry', 'Failed to JSON-encode the payload.' );
     157        }
     158
     159        $signature = 'sha256=' . hash_hmac( 'sha256', $body, self::SECRET );
     160
     161        $args = [
     162            'headers'     => [
     163                'Content-Type'    => 'application/json; charset=utf-8',
     164                'X-MYD-Signature' => $signature,
     165                'User-Agent'      => 'MyD-Telemetry/1.0; ' . \home_url(),
     166            ],
     167            'body'        => $body,
     168            'timeout'     => 12,
     169            'blocking'    => \wp_doing_cron(),
     170            'sslverify'   => true,
     171        ];
     172
     173        $response = \wp_remote_post( self::ENDPOINT, $args );
     174
     175        if ( is_wp_error( $response ) ) {
     176            return $response;
     177        }
     178
     179        $code = \wp_remote_retrieve_response_code( $response );
     180
     181        if ( in_array( (int) $code, [ 200, 409 ], true ) ) {
     182            \update_option( self::OPTION_KEY, [], false );
     183            return true;
     184        }
     185
     186        $body_resp = \wp_remote_retrieve_body( $response );
     187        return new \WP_Error(
     188            'myd_telemetry',
     189            sprintf( 'HTTP %d: %s', (int) $code, $body_resp ?? 'no body' )
     190        );
     191    }
    133192}
  • myd-delivery/tags/1.3.3/myd-delivery.php

    r3389122 r3389314  
    66 * Author: EduardoVillao.me
    77 * Author URI: https://eduardovillao.me/
    8  * Version: 1.3.2
     8 * Version: 1.3.3
    99 * Requires PHP: 7.4
    1010 * Requires at least: 5.5
     
    2626define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) );
    2727define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) );
    28 define( 'MYDDELIVERY_VERSION', '1.3.2' );
     28define( 'MYDDELIVERY_VERSION', '1.3.3' );
    2929define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' );
    3030define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' );
  • myd-delivery/trunk/README.txt

    r3389122 r3389314  
    55Requires at least: 5.5
    66Tested up to: 6.8
    7 Stable tag: 1.3.2
     7Stable tag: 1.3.3
    88Requires PHP: 7.4
    99License: GPL-3.0+
     
    7676== Changelog ==
    7777
     78= 1.3.3 =
     79* Changed: code support to print function refactoring in pro version.
     80* Changed: code improvements.
     81
    7882= 1.3.2 =
    7983* Changed: code improvements in Mercado Pago integration.
  • myd-delivery/trunk/includes/telemetry/class-snapshots.php

    r3389122 r3389314  
    1515    const MAX_SNAPSHOTS = 7;
    1616    const OPTION_KEY = 'myddelivery_telemetry_snapshots';
     17    const ENDPOINT = 'https://api.myddelivery.com/api/telemetry';
     18    const SECRET = '63d704ae5e6f4c0a465790ce666b7c7a8e9c9c4f7eb02ec35246eac96b9c3475';
    1719    /**
    1820     * Capture a snapshot of the current plugin state
     
    9193            'products_count' => $products_count,
    9294            'product_categories_count' => $categories_count,
     95            'orders_count' => 0,
    9396            'whatsapp_redirect_enabled' => $whatsapp_redirect_enabled,
    9497        ];
     
    112115
    113116        \update_option( self::OPTION_KEY, $snapshots, false );
     117
     118        if ( ! \wp_next_scheduled('myddelivery_send_snapshot_once') ) {
     119            \wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'myddelivery_send_snapshot_once' );
     120        }
    114121    }
    115122
     
    126133    public static function set_collect_snapshots() {
    127134        \add_action( 'myddelivery_collect_snapshot', [ self::class, 'store_snapshot' ] );
     135        \add_action( 'myddelivery_send_snapshot_once', [ self::class, 'send' ] );
    128136
    129137        if ( ! \wp_next_scheduled( 'myddelivery_collect_snapshot' ) ) {
     
    131139        }
    132140    }
     141
     142    /**
     143     * Send stored snapshots to telemetry endpoint
     144     */
     145    public static function send() {
     146        $snapshots = self::get_snapshots();
     147        if ( empty( $snapshots ) ) {
     148            return new \WP_Error( 'myd_telemetry', 'No provided snapshots.' );
     149        }
     150
     151        $body = \wp_json_encode(
     152            $snapshots,
     153            JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
     154        );
     155        if ( false === $body ) {
     156            return new \WP_Error( 'myd_telemetry', 'Failed to JSON-encode the payload.' );
     157        }
     158
     159        $signature = 'sha256=' . hash_hmac( 'sha256', $body, self::SECRET );
     160
     161        $args = [
     162            'headers'     => [
     163                'Content-Type'    => 'application/json; charset=utf-8',
     164                'X-MYD-Signature' => $signature,
     165                'User-Agent'      => 'MyD-Telemetry/1.0; ' . \home_url(),
     166            ],
     167            'body'        => $body,
     168            'timeout'     => 12,
     169            'blocking'    => \wp_doing_cron(),
     170            'sslverify'   => true,
     171        ];
     172
     173        $response = \wp_remote_post( self::ENDPOINT, $args );
     174
     175        if ( is_wp_error( $response ) ) {
     176            return $response;
     177        }
     178
     179        $code = \wp_remote_retrieve_response_code( $response );
     180
     181        if ( in_array( (int) $code, [ 200, 409 ], true ) ) {
     182            \update_option( self::OPTION_KEY, [], false );
     183            return true;
     184        }
     185
     186        $body_resp = \wp_remote_retrieve_body( $response );
     187        return new \WP_Error(
     188            'myd_telemetry',
     189            sprintf( 'HTTP %d: %s', (int) $code, $body_resp ?? 'no body' )
     190        );
     191    }
    133192}
  • myd-delivery/trunk/myd-delivery.php

    r3389122 r3389314  
    66 * Author: EduardoVillao.me
    77 * Author URI: https://eduardovillao.me/
    8  * Version: 1.3.2
     8 * Version: 1.3.3
    99 * Requires PHP: 7.4
    1010 * Requires at least: 5.5
     
    2626define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) );
    2727define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) );
    28 define( 'MYDDELIVERY_VERSION', '1.3.2' );
     28define( 'MYDDELIVERY_VERSION', '1.3.3' );
    2929define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' );
    3030define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' );
Note: See TracChangeset for help on using the changeset viewer.