Changeset 3389314
- Timestamp:
- 11/04/2025 04:19:44 AM (5 months ago)
- Location:
- myd-delivery
- Files:
-
- 6 edited
- 1 copied
-
tags/1.3.3 (copied) (copied from myd-delivery/trunk)
-
tags/1.3.3/README.txt (modified) (2 diffs)
-
tags/1.3.3/includes/telemetry/class-snapshots.php (modified) (5 diffs)
-
tags/1.3.3/myd-delivery.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/telemetry/class-snapshots.php (modified) (5 diffs)
-
trunk/myd-delivery.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
myd-delivery/tags/1.3.3/README.txt
r3389122 r3389314 5 5 Requires at least: 5.5 6 6 Tested up to: 6.8 7 Stable tag: 1.3. 27 Stable tag: 1.3.3 8 8 Requires PHP: 7.4 9 9 License: GPL-3.0+ … … 76 76 == Changelog == 77 77 78 = 1.3.3 = 79 * Changed: code support to print function refactoring in pro version. 80 * Changed: code improvements. 81 78 82 = 1.3.2 = 79 83 * Changed: code improvements in Mercado Pago integration. -
myd-delivery/tags/1.3.3/includes/telemetry/class-snapshots.php
r3389122 r3389314 15 15 const MAX_SNAPSHOTS = 7; 16 16 const OPTION_KEY = 'myddelivery_telemetry_snapshots'; 17 const ENDPOINT = 'https://api.myddelivery.com/api/telemetry'; 18 const SECRET = '63d704ae5e6f4c0a465790ce666b7c7a8e9c9c4f7eb02ec35246eac96b9c3475'; 17 19 /** 18 20 * Capture a snapshot of the current plugin state … … 91 93 'products_count' => $products_count, 92 94 'product_categories_count' => $categories_count, 95 'orders_count' => 0, 93 96 'whatsapp_redirect_enabled' => $whatsapp_redirect_enabled, 94 97 ]; … … 112 115 113 116 \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 } 114 121 } 115 122 … … 126 133 public static function set_collect_snapshots() { 127 134 \add_action( 'myddelivery_collect_snapshot', [ self::class, 'store_snapshot' ] ); 135 \add_action( 'myddelivery_send_snapshot_once', [ self::class, 'send' ] ); 128 136 129 137 if ( ! \wp_next_scheduled( 'myddelivery_collect_snapshot' ) ) { … … 131 139 } 132 140 } 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 } 133 192 } -
myd-delivery/tags/1.3.3/myd-delivery.php
r3389122 r3389314 6 6 * Author: EduardoVillao.me 7 7 * Author URI: https://eduardovillao.me/ 8 * Version: 1.3. 28 * Version: 1.3.3 9 9 * Requires PHP: 7.4 10 10 * Requires at least: 5.5 … … 26 26 define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) ); 27 27 define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) ); 28 define( 'MYDDELIVERY_VERSION', '1.3. 2' );28 define( 'MYDDELIVERY_VERSION', '1.3.3' ); 29 29 define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' ); 30 30 define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' ); -
myd-delivery/trunk/README.txt
r3389122 r3389314 5 5 Requires at least: 5.5 6 6 Tested up to: 6.8 7 Stable tag: 1.3. 27 Stable tag: 1.3.3 8 8 Requires PHP: 7.4 9 9 License: GPL-3.0+ … … 76 76 == Changelog == 77 77 78 = 1.3.3 = 79 * Changed: code support to print function refactoring in pro version. 80 * Changed: code improvements. 81 78 82 = 1.3.2 = 79 83 * Changed: code improvements in Mercado Pago integration. -
myd-delivery/trunk/includes/telemetry/class-snapshots.php
r3389122 r3389314 15 15 const MAX_SNAPSHOTS = 7; 16 16 const OPTION_KEY = 'myddelivery_telemetry_snapshots'; 17 const ENDPOINT = 'https://api.myddelivery.com/api/telemetry'; 18 const SECRET = '63d704ae5e6f4c0a465790ce666b7c7a8e9c9c4f7eb02ec35246eac96b9c3475'; 17 19 /** 18 20 * Capture a snapshot of the current plugin state … … 91 93 'products_count' => $products_count, 92 94 'product_categories_count' => $categories_count, 95 'orders_count' => 0, 93 96 'whatsapp_redirect_enabled' => $whatsapp_redirect_enabled, 94 97 ]; … … 112 115 113 116 \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 } 114 121 } 115 122 … … 126 133 public static function set_collect_snapshots() { 127 134 \add_action( 'myddelivery_collect_snapshot', [ self::class, 'store_snapshot' ] ); 135 \add_action( 'myddelivery_send_snapshot_once', [ self::class, 'send' ] ); 128 136 129 137 if ( ! \wp_next_scheduled( 'myddelivery_collect_snapshot' ) ) { … … 131 139 } 132 140 } 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 } 133 192 } -
myd-delivery/trunk/myd-delivery.php
r3389122 r3389314 6 6 * Author: EduardoVillao.me 7 7 * Author URI: https://eduardovillao.me/ 8 * Version: 1.3. 28 * Version: 1.3.3 9 9 * Requires PHP: 7.4 10 10 * Requires at least: 5.5 … … 26 26 define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) ); 27 27 define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) ); 28 define( 'MYDDELIVERY_VERSION', '1.3. 2' );28 define( 'MYDDELIVERY_VERSION', '1.3.3' ); 29 29 define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' ); 30 30 define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' );
Note: See TracChangeset
for help on using the changeset viewer.