Changeset 3106064
- Timestamp:
- 06/22/2024 04:44:13 PM (22 months ago)
- Location:
- timestamps
- Files:
-
- 4 added
- 16 edited
- 1 copied
-
tags/1.3.0 (copied) (copied from timestamps/trunk)
-
tags/1.3.0/includes/classes/AdminNotices.php (modified) (4 diffs)
-
tags/1.3.0/includes/classes/Feature/Timestamp/Timestamp.php (modified) (12 diffs)
-
tags/1.3.0/includes/classes/Feature/WooCommerce (added)
-
tags/1.3.0/includes/classes/Feature/WooCommerce/Orders.php (added)
-
tags/1.3.0/includes/classes/Screen/Settings.php (modified) (8 diffs)
-
tags/1.3.0/includes/utils.php (modified) (4 diffs)
-
tags/1.3.0/package-lock.json (modified) (2 diffs)
-
tags/1.3.0/package.json (modified) (1 diff)
-
tags/1.3.0/readme.txt (modified) (2 diffs)
-
tags/1.3.0/timestamps.php (modified) (3 diffs)
-
trunk/includes/classes/AdminNotices.php (modified) (4 diffs)
-
trunk/includes/classes/Feature/Timestamp/Timestamp.php (modified) (12 diffs)
-
trunk/includes/classes/Feature/WooCommerce (added)
-
trunk/includes/classes/Feature/WooCommerce/Orders.php (added)
-
trunk/includes/classes/Screen/Settings.php (modified) (8 diffs)
-
trunk/includes/utils.php (modified) (4 diffs)
-
trunk/package-lock.json (modified) (2 diffs)
-
trunk/package.json (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/timestamps.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
timestamps/tags/1.3.0/includes/classes/AdminNotices.php
r3048002 r3106064 13 13 use SDCOM_Timestamps\Utils; 14 14 use SDCOM_Timestamps\Screen; 15 16 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 17 16 18 if ( ! defined( 'ABSPATH' ) ) { … … 70 72 protected function process_need_setup_notice() { 71 73 72 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 73 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 74 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 74 75 75 76 if ( ! empty( $timestamps_api_key ) ) { … … 77 78 } 78 79 79 $dismiss = Utils\get_option( 'sdcom_timestamps_hide_need_setup_notice', false );80 $dismiss = get_option( 'sdcom_timestamps_hide_need_setup_notice', false ); 80 81 81 82 if ( $dismiss ) { … … 128 129 $value = true; 129 130 130 Utils\update_option( 'timestamps_hide_' . $notice . '_notice', $value );131 update_option( 'timestamps_hide_' . $notice . '_notice', $value ); 131 132 } 132 133 -
timestamps/tags/1.3.0/includes/classes/Feature/Timestamp/Timestamp.php
r3076784 r3106064 12 12 use SDCOM_Timestamps\Utils; 13 13 14 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 14 16 /** 15 17 * Timestamp feature class … … 48 50 49 51 /** 50 * We need to delay setup up since it will fire after protected content and protected 51 * content filters into the setup. 52 * We need to delay setup up until init to ensure all plugins are loaded. 52 53 * 53 54 * @since 1.0.0 … … 160 161 wp_set_script_translations( 'timestamp-post-editor', 'timestamps' ); 161 162 162 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 163 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 163 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 164 164 165 165 wp_localize_script( … … 259 259 update_post_meta( $post_id, 'sdcom_timestamp_post', true ); 260 260 261 $create_certificate = $this->create_certificate ( $post );261 $create_certificate = $this->create_certificate_post( $post ); 262 262 263 263 // Handle the case where the method returned false. … … 273 273 } 274 274 275 $update_certificate = $this->update_certificate ( $post, $certificate_id );275 $update_certificate = $this->update_certificate_post( $post, $certificate_id ); 276 276 277 277 // Handle the case where the method returned false. … … 352 352 } 353 353 354 $create_certificate = $this->create_certificate ( $post );354 $create_certificate = $this->create_certificate_post( $post ); 355 355 356 356 // Handle the case where the method returned false. … … 366 366 } 367 367 368 $update_certificate = $this->update_certificate ( $post, $certificate_id );368 $update_certificate = $this->update_certificate_post( $post, $certificate_id ); 369 369 370 370 // Handle the case where the method returned false. … … 436 436 * @throws \Exception If the options, post content, or API key is empty. 437 437 */ 438 private function create_certificate ( $post ) {438 private function create_certificate_post( $post ) { 439 439 try { 440 440 $post_id = $post->ID; … … 518 518 } 519 519 520 // Return the data. 520 521 return $data; 521 522 … … 534 535 * @throws \Throwable If an exception occurs during the process. 535 536 */ 536 private function update_certificate ( $post, $certificate_id ) {537 private function update_certificate_post( $post, $certificate_id ) { 537 538 try { 538 539 $post_content = $post->post_content; … … 575 576 ); 576 577 577 $body = json_encode(578 $body = wp_json_encode( 578 579 array( 579 580 'certificateId' => $certificate_id, … … 619 620 } 620 621 622 // Return the data. 621 623 return $data; 622 624 -
timestamps/tags/1.3.0/includes/classes/Screen/Settings.php
r3048002 r3106064 13 13 use SDCOM_Timestamps\Utils; 14 14 15 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 16 use function SDCOM_Timestamps\Utils\is_authenticated; 17 use function SDCOM_Timestamps\Utils\is_woocommerce_active; 16 18 17 19 if ( ! defined( 'ABSPATH' ) ) { … … 83 85 */ 84 86 public function register_settings() { 87 88 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 89 85 90 register_setting( 86 91 SDCOM_TIMESTAMPS_OPTIONS, … … 146 151 'sdcom_timestamps_general_settings_section' 147 152 ); 153 154 // WooCommerce Settings. 155 if ( is_woocommerce_active() ) { 156 add_settings_section( 157 'sdcom_timestamps_woocommerce_settings_section', 158 null, 159 [ $this, 'woocommerce_settings_section' ], 160 $this->settings_page 161 ); 162 163 add_settings_field( 164 'sdcom_timestamps_enable_timestamps_woocommerce_orders', 165 __( 'Enable Timestamps on WooCommerce Orders', 'timestamps' ), 166 [ $this, 'enable_timestamps_woocommerce_orders_settings_field_callback' ], 167 $this->settings_page, 168 'sdcom_timestamps_woocommerce_settings_section' 169 ); 170 171 // Check if the option "enable_timestamps_woocommerce_orders" is present and is true. 172 if ( ! empty( $option['enable_timestamps_woocommerce_orders'] ) && $option['enable_timestamps_woocommerce_orders'] === 'true' ) { 173 add_settings_field( 174 'sdcom_timestamps_delete_certificates_old_woocommerce_orders_age', 175 __( 'Delete Old Certificates by WooCommerce Order Age', 'timestamps' ), 176 [ $this, 'delete_certificates_old_woocommerce_orders_age_settings_field_callback' ], 177 $this->settings_page, 178 'sdcom_timestamps_woocommerce_settings_section' 179 ); 180 181 add_settings_field( 182 'sdcom_timestamps_woocommerce_order_statuses_marked_old_certificates', 183 __( 'WooCommerce Order Statuses Marked for Old Certificates', 'timestamps' ), 184 [ $this, 'woocommerce_order_statuses_marked_old_certificates_settings_field_callback' ], 185 $this->settings_page, 186 'sdcom_timestamps_woocommerce_settings_section' 187 ); 188 } 189 } 148 190 } 149 191 } … … 185 227 186 228 /** 229 * Outputs the WooCommerce settings section. 230 * 231 * @since 1.3.0 232 * @return void 233 */ 234 public function woocommerce_settings_section() { 235 echo wp_kses_post( 236 sprintf( 237 '<h2>%s</h2>', 238 __( 'WooCommerce Settings', 'timestamps' ) 239 ) 240 ); 241 } 242 243 /** 187 244 * Outputs the "Display Created By" settings input checkbox field. 188 245 * … … 195 252 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 196 253 197 $display_created_by = ! empty( $option['display_created_by'] ) ? $option['display_created_by'] : false;254 $display_created_by = get_plugin_option( 'display_created_by', false ); 198 255 $username = ! empty( $option['username'] ) && $display_created_by ? $option['username'] : 'anonymous'; 199 256 $date_and_time = current_time( 'l, F j, Y \a\t g:i:s A' ); … … 224 281 wp_kses_post( 225 282 sprintf( 283 /* translators: %s: username */ 226 284 __( 'by %s', 'timestamps' ), 227 285 $username … … 253 311 254 312 /** 313 * Outputs the "Enable Timestamps on WooCommerce Orders" settings input checkbox field. 314 * 315 * If the option value is present, the checkbox will be checked. 316 * If the option value is not present, the checkbox will be unchecked. 317 * 318 * @since 1.3.0 319 * @return void 320 */ 321 public function enable_timestamps_woocommerce_orders_settings_field_callback() { 322 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 323 324 printf( 325 '<label><input type="checkbox" name="' . esc_attr( SDCOM_TIMESTAMPS_OPTIONS ) . '[enable_timestamps_woocommerce_orders]" id="enable_timestamps_woocommerce_orders" value="true" %s> %s</label><p class="description">%s</p>', 326 checked( isset( $option['enable_timestamps_woocommerce_orders'] ), true, false ), 327 wp_kses_post( __( 'Active', 'timestamps' ) ), 328 wp_kses_post( __( 'Adds Timestamps to WooCommerce Orders.', 'timestamps' ) ), 329 ); 330 } 331 332 /** 333 * Outputs the "Delete Old Certificates by WooCommerce Order Age" settings input number field. 334 * 335 * The default value is 365 days. 336 * 337 * @since 1.3.0 338 * @return void 339 */ 340 public function delete_certificates_old_woocommerce_orders_age_settings_field_callback() { 341 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 342 343 // Get the value from the option, or use the default value of 365 days. 344 $value = isset( $option['delete_certificates_old_woocommerce_orders_age'] ) && ! empty( $option['delete_certificates_old_woocommerce_orders_age'] ) ? $option['delete_certificates_old_woocommerce_orders_age'] : 365; 345 346 printf( 347 '<label><input type="number" min="0" name="' . esc_attr( SDCOM_TIMESTAMPS_OPTIONS ) . '[delete_certificates_old_woocommerce_orders_age]" id="delete_certificates_old_woocommerce_orders_age" value="' . esc_attr( $value ) . '"> %s</label><p class="description">%s</p>', 348 wp_kses_post( __( 'Days', 'timestamps' ) ), 349 wp_kses_post( __( 'Automatically delete old certificates after a certain age. Defaults to 365 days.', 'timestamps' ) ), 350 ); 351 } 352 353 /** 354 * Outputs the "WooCommerce Order Statuses Marked for Old Certificates" settings input checkbox field. 355 * 356 * The default value is _all_ WooCommerce order statuses. 357 * 358 * @since 1.3.0 359 * 360 * @return void 361 */ 362 public function woocommerce_order_statuses_marked_old_certificates_settings_field_callback() { 363 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 364 365 // Get the WooCommerce order statuses. 366 $order_statuses = wc_get_order_statuses(); 367 368 // Sort the $order_statuses in alphabetical order. 369 ksort( $order_statuses ); 370 371 // If the option value is not present, set the default value to all WooCommerce order statuses. 372 if ( empty( $option['woocommerce_order_statuses_marked_old_certificates'] ) ) { 373 $option['woocommerce_order_statuses_marked_old_certificates'] = array_keys( $order_statuses ); 374 } 375 376 // Loop through the WooCommerce order statuses as checkbox elements. 377 foreach ( $order_statuses as $key => $value ) { 378 $is_checked = in_array( $key, $option['woocommerce_order_statuses_marked_old_certificates'], true ); 379 printf( 380 '<input type="checkbox" name="%s[woocommerce_order_statuses_marked_old_certificates][]" value="%s" %s>%s<br>', 381 esc_attr( SDCOM_TIMESTAMPS_OPTIONS ), 382 esc_attr( $key ), 383 checked( $is_checked, true, false ), 384 esc_html( $value ) 385 ); 386 } 387 388 printf( 389 '<p class="description">%s</p>', 390 wp_kses_post( __( 'Select the statuses to mark for old certificates.', 'timestamps' ) ), 391 ); 392 } 393 394 /** 255 395 * Render settings page. 256 396 * … … 258 398 */ 259 399 public function render_settings_page() { 260 // get the timestamps options. 261 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 262 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 263 $timestamps_username = isset( $timestamps_options['username'] ) ? $timestamps_options['username'] : ''; 264 $timestamps_avatar_url = isset( $timestamps_options['avatar_url'] ) ? $timestamps_options['avatar_url'] : ''; 400 // Get the timestamps options. 401 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 402 $timestamps_username = get_plugin_option( 'username', '' ); 403 $timestamps_avatar_url = get_plugin_option( 'avatar_url', '' ); 265 404 ?> 266 405 <div class="wrap"> -
timestamps/tags/1.3.0/includes/utils.php
r3073868 r3106064 37 37 38 38 /** 39 * Use the correct update option function depending on the context.40 *41 * @since 1.0.042 * @param string $option Name of the option to update.43 * @param mixed $value Option value.44 * @param mixed $autoload Whether to load the option when WordPress starts up.45 * @return bool46 */47 function update_option( $option, $value, $autoload = null ) {48 return \update_option( $option, $value, $autoload );49 }50 51 /**52 * Use the correct get option function depending on the context.53 *54 * @since 1.0.055 * @param string $option Name of the option to get.56 * @param mixed $default_value Default value.57 * @return mixed58 */59 function get_option( $option, $default_value = false ) {60 return \get_option( $option, $default_value );61 }62 63 /**64 * Use the correct delete option function depending on the context.65 *66 * @since 1.0.067 * @param string $option Name of the option to delete.68 * @return bool69 */70 function delete_option( $option ) {71 return \delete_option( $option );72 }73 74 /**75 39 * Checks if the user is authenticated. 76 40 * … … 81 45 */ 82 46 function is_authenticated() { 83 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 84 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 47 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 85 48 86 49 return ! empty( $timestamps_api_key ); … … 95 58 function is_block_editor_active() { 96 59 97 $classic_editor_replace = \get_option( 'classic-editor-replace' );60 $classic_editor_replace = get_option( 'classic-editor-replace' ); 98 61 99 62 // We assume that the Block Editor is active, whilst the Classic Editor plugin never existed. … … 152 115 return false; 153 116 } 117 118 /** 119 * Checks if the WooCommerce plugin is active. 120 * 121 * @since 1.3.0 122 * @return bool Returns true if the WooCommerce plugin is active, false otherwise. 123 */ 124 function is_woocommerce_active() { 125 return class_exists( 'WooCommerce' ); 126 } 127 128 /** 129 * Gets the WooCommerce volatile order data keys. 130 * 131 * This function returns an array of keys that represent volatile data in a WooCommerce order. 132 * 133 * @since 1.3.0 134 * @return array Filtered volatile order data keys. 135 */ 136 function get_wc_volatile_order_data_keys() { 137 $wc_volatile_order_data_keys = [ 'date_modified', 'meta_data', 'version' ]; 138 139 return apply_filters( 'sdcom_timestamps_wc_volatile_order_data_keys', $wc_volatile_order_data_keys ); 140 } 141 142 /** 143 * Checks if timestamps for WooCommerce orders are active. 144 * 145 * @since 1.3.0 146 * @return bool True if the option is active, false otherwise. 147 */ 148 function is_timestamps_woocommerce_orders_active(): bool { 149 $timestamps_woocommerce_orders_enabled = get_plugin_option( 'enable_timestamps_woocommerce_orders', '' ); 150 151 return ! empty( $timestamps_woocommerce_orders_enabled ); 152 } 153 154 /** 155 * Gets the certificate URL for a WooCommerce order. 156 * 157 * @param \WC_Order $order The WooCommerce order object. 158 * @since 1.3.0 159 * @return string The certificate URL. 160 */ 161 function get_certificate_url_wc_order( $order ): string { 162 $sdcom_previous_certificate_id = $order->get_meta( 'sdcom_previous_certificate_id' ); 163 164 // Bail early if there is no previous certificate id. 165 if ( empty( $sdcom_previous_certificate_id ) ) { 166 return ''; 167 } 168 169 return apply_filters( 'get_certificate_url_wc_order', esc_url( 'https://scoredetect.com/certificate/' . $sdcom_previous_certificate_id ), $order ); 170 } 171 172 /** 173 * Gets the plugin option. 174 * 175 * If the option does not exist, the default value is returned. 176 * 177 * @param string $option_key Name of the option to retrieve. Expected to not be SQL-escaped. 178 * @param mixed $default_value Optional. Default value to return if the option does not exist. 179 * @since 1.3.0 180 * @return mixed Value of the option. A value of any type may be returned, including 181 * scalar (string, boolean, float, integer), null, array, object. 182 * Scalar and null values will be returned as strings as long as they originate 183 * from a database stored option value. If there is no option in the database, 184 * boolean `false` is returned. 185 */ 186 function get_plugin_option( $option_key, $default_value = false ) { 187 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 188 189 if ( empty( $timestamps_options ) ) { 190 return false; 191 } 192 193 if ( isset( $timestamps_options[ $option_key ] ) ) { 194 return $timestamps_options[ $option_key ]; 195 } 196 197 return $default_value; 198 } -
timestamps/tags/1.3.0/package-lock.json
r3073868 r3106064 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 1.0",3 "version": "1.2.1", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "timestamps-plugin", 9 "version": "1. 1.0",9 "version": "1.2.1", 10 10 "dependencies": { 11 11 "@supabase/supabase-js": "^2.39.3", -
timestamps/tags/1.3.0/package.json
r3081650 r3106064 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 2.1",3 "version": "1.3.0", 4 4 "description": "Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.", 5 5 "homepage": "https://www.scoredetect.com/", -
timestamps/tags/1.3.0/readme.txt
r3081650 r3106064 1 === Timestamps ===1 === Timestamps – Blockchain Integration for WordPress === 2 2 Contributors: scoredetect, xmic 3 3 Tags: timestamp, blockchain, content, authenticity, copyright, timestamps, protection, verification, proof, timestamping … … 5 5 Tested up to: 6.5.2 6 6 Requires PHP: 7.4 7 Stable tag: 1. 2.17 Stable tag: 1.3.0 8 8 License: AGPL-3.0-only 9 9 License URI: https://spdx.org/licenses/AGPL-3.0-only.html 10 10 11 Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.11 No blockchain skills needed. Timestamp your WordPress content to empower your content authenticity and increase user trust. 12 12 13 13 == Description == 14 Timestamps allow you to increase content authenticity by displaying a rich timeline of your post updates. The timeline can be independently verified by the public , as a verification factor for your content.14 Timestamps allow you to increase content authenticity by displaying a rich timeline of your post updates. The timeline can be independently verified by the public. 15 15 16 16 Here is a list of features included in the plugin: -
timestamps/tags/1.3.0/timestamps.php
r3081650 r3106064 9 9 * 10 10 * @link https://www.scoredetect.com/ 11 * @since 1. 2.111 * @since 1.3.0 12 12 * @package SDCOM_Timestamps 13 13 * 14 14 * @wordpress-plugin 15 15 * Plugin Name: Timestamps 16 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.17 * Version: 1. 2.116 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust. No blockchain skills needed. 17 * Version: 1.3.0 18 18 * Author: ScoreDetect.com 19 19 * Author URI: https://www.scoredetect.com/ … … 32 32 33 33 // Useful global constants. 34 define( 'SDCOM_TIMESTAMPS_VERSION', '1. 2.1' );34 define( 'SDCOM_TIMESTAMPS_VERSION', '1.3.0' ); 35 35 define( 'SDCOM_TIMESTAMPS_OPTIONS', 'sdcom_timestamps' ); 36 36 define( 'SDCOM_TIMESTAMPS_URL', plugin_dir_url( __FILE__ ) ); … … 100 100 new Feature\Timestamp\Timestamp() 101 101 ); 102 Features::factory()->register_feature( 103 new Feature\WooCommerce\Orders() 104 ); 102 105 } 103 106 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_features' ); -
timestamps/trunk/includes/classes/AdminNotices.php
r3048002 r3106064 13 13 use SDCOM_Timestamps\Utils; 14 14 use SDCOM_Timestamps\Screen; 15 16 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 17 16 18 if ( ! defined( 'ABSPATH' ) ) { … … 70 72 protected function process_need_setup_notice() { 71 73 72 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 73 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 74 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 74 75 75 76 if ( ! empty( $timestamps_api_key ) ) { … … 77 78 } 78 79 79 $dismiss = Utils\get_option( 'sdcom_timestamps_hide_need_setup_notice', false );80 $dismiss = get_option( 'sdcom_timestamps_hide_need_setup_notice', false ); 80 81 81 82 if ( $dismiss ) { … … 128 129 $value = true; 129 130 130 Utils\update_option( 'timestamps_hide_' . $notice . '_notice', $value );131 update_option( 'timestamps_hide_' . $notice . '_notice', $value ); 131 132 } 132 133 -
timestamps/trunk/includes/classes/Feature/Timestamp/Timestamp.php
r3076784 r3106064 12 12 use SDCOM_Timestamps\Utils; 13 13 14 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 14 16 /** 15 17 * Timestamp feature class … … 48 50 49 51 /** 50 * We need to delay setup up since it will fire after protected content and protected 51 * content filters into the setup. 52 * We need to delay setup up until init to ensure all plugins are loaded. 52 53 * 53 54 * @since 1.0.0 … … 160 161 wp_set_script_translations( 'timestamp-post-editor', 'timestamps' ); 161 162 162 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 163 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 163 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 164 164 165 165 wp_localize_script( … … 259 259 update_post_meta( $post_id, 'sdcom_timestamp_post', true ); 260 260 261 $create_certificate = $this->create_certificate ( $post );261 $create_certificate = $this->create_certificate_post( $post ); 262 262 263 263 // Handle the case where the method returned false. … … 273 273 } 274 274 275 $update_certificate = $this->update_certificate ( $post, $certificate_id );275 $update_certificate = $this->update_certificate_post( $post, $certificate_id ); 276 276 277 277 // Handle the case where the method returned false. … … 352 352 } 353 353 354 $create_certificate = $this->create_certificate ( $post );354 $create_certificate = $this->create_certificate_post( $post ); 355 355 356 356 // Handle the case where the method returned false. … … 366 366 } 367 367 368 $update_certificate = $this->update_certificate ( $post, $certificate_id );368 $update_certificate = $this->update_certificate_post( $post, $certificate_id ); 369 369 370 370 // Handle the case where the method returned false. … … 436 436 * @throws \Exception If the options, post content, or API key is empty. 437 437 */ 438 private function create_certificate ( $post ) {438 private function create_certificate_post( $post ) { 439 439 try { 440 440 $post_id = $post->ID; … … 518 518 } 519 519 520 // Return the data. 520 521 return $data; 521 522 … … 534 535 * @throws \Throwable If an exception occurs during the process. 535 536 */ 536 private function update_certificate ( $post, $certificate_id ) {537 private function update_certificate_post( $post, $certificate_id ) { 537 538 try { 538 539 $post_content = $post->post_content; … … 575 576 ); 576 577 577 $body = json_encode(578 $body = wp_json_encode( 578 579 array( 579 580 'certificateId' => $certificate_id, … … 619 620 } 620 621 622 // Return the data. 621 623 return $data; 622 624 -
timestamps/trunk/includes/classes/Screen/Settings.php
r3048002 r3106064 13 13 use SDCOM_Timestamps\Utils; 14 14 15 use function SDCOM_Timestamps\Utils\get_plugin_option; 15 16 use function SDCOM_Timestamps\Utils\is_authenticated; 17 use function SDCOM_Timestamps\Utils\is_woocommerce_active; 16 18 17 19 if ( ! defined( 'ABSPATH' ) ) { … … 83 85 */ 84 86 public function register_settings() { 87 88 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 89 85 90 register_setting( 86 91 SDCOM_TIMESTAMPS_OPTIONS, … … 146 151 'sdcom_timestamps_general_settings_section' 147 152 ); 153 154 // WooCommerce Settings. 155 if ( is_woocommerce_active() ) { 156 add_settings_section( 157 'sdcom_timestamps_woocommerce_settings_section', 158 null, 159 [ $this, 'woocommerce_settings_section' ], 160 $this->settings_page 161 ); 162 163 add_settings_field( 164 'sdcom_timestamps_enable_timestamps_woocommerce_orders', 165 __( 'Enable Timestamps on WooCommerce Orders', 'timestamps' ), 166 [ $this, 'enable_timestamps_woocommerce_orders_settings_field_callback' ], 167 $this->settings_page, 168 'sdcom_timestamps_woocommerce_settings_section' 169 ); 170 171 // Check if the option "enable_timestamps_woocommerce_orders" is present and is true. 172 if ( ! empty( $option['enable_timestamps_woocommerce_orders'] ) && $option['enable_timestamps_woocommerce_orders'] === 'true' ) { 173 add_settings_field( 174 'sdcom_timestamps_delete_certificates_old_woocommerce_orders_age', 175 __( 'Delete Old Certificates by WooCommerce Order Age', 'timestamps' ), 176 [ $this, 'delete_certificates_old_woocommerce_orders_age_settings_field_callback' ], 177 $this->settings_page, 178 'sdcom_timestamps_woocommerce_settings_section' 179 ); 180 181 add_settings_field( 182 'sdcom_timestamps_woocommerce_order_statuses_marked_old_certificates', 183 __( 'WooCommerce Order Statuses Marked for Old Certificates', 'timestamps' ), 184 [ $this, 'woocommerce_order_statuses_marked_old_certificates_settings_field_callback' ], 185 $this->settings_page, 186 'sdcom_timestamps_woocommerce_settings_section' 187 ); 188 } 189 } 148 190 } 149 191 } … … 185 227 186 228 /** 229 * Outputs the WooCommerce settings section. 230 * 231 * @since 1.3.0 232 * @return void 233 */ 234 public function woocommerce_settings_section() { 235 echo wp_kses_post( 236 sprintf( 237 '<h2>%s</h2>', 238 __( 'WooCommerce Settings', 'timestamps' ) 239 ) 240 ); 241 } 242 243 /** 187 244 * Outputs the "Display Created By" settings input checkbox field. 188 245 * … … 195 252 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 196 253 197 $display_created_by = ! empty( $option['display_created_by'] ) ? $option['display_created_by'] : false;254 $display_created_by = get_plugin_option( 'display_created_by', false ); 198 255 $username = ! empty( $option['username'] ) && $display_created_by ? $option['username'] : 'anonymous'; 199 256 $date_and_time = current_time( 'l, F j, Y \a\t g:i:s A' ); … … 224 281 wp_kses_post( 225 282 sprintf( 283 /* translators: %s: username */ 226 284 __( 'by %s', 'timestamps' ), 227 285 $username … … 253 311 254 312 /** 313 * Outputs the "Enable Timestamps on WooCommerce Orders" settings input checkbox field. 314 * 315 * If the option value is present, the checkbox will be checked. 316 * If the option value is not present, the checkbox will be unchecked. 317 * 318 * @since 1.3.0 319 * @return void 320 */ 321 public function enable_timestamps_woocommerce_orders_settings_field_callback() { 322 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 323 324 printf( 325 '<label><input type="checkbox" name="' . esc_attr( SDCOM_TIMESTAMPS_OPTIONS ) . '[enable_timestamps_woocommerce_orders]" id="enable_timestamps_woocommerce_orders" value="true" %s> %s</label><p class="description">%s</p>', 326 checked( isset( $option['enable_timestamps_woocommerce_orders'] ), true, false ), 327 wp_kses_post( __( 'Active', 'timestamps' ) ), 328 wp_kses_post( __( 'Adds Timestamps to WooCommerce Orders.', 'timestamps' ) ), 329 ); 330 } 331 332 /** 333 * Outputs the "Delete Old Certificates by WooCommerce Order Age" settings input number field. 334 * 335 * The default value is 365 days. 336 * 337 * @since 1.3.0 338 * @return void 339 */ 340 public function delete_certificates_old_woocommerce_orders_age_settings_field_callback() { 341 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 342 343 // Get the value from the option, or use the default value of 365 days. 344 $value = isset( $option['delete_certificates_old_woocommerce_orders_age'] ) && ! empty( $option['delete_certificates_old_woocommerce_orders_age'] ) ? $option['delete_certificates_old_woocommerce_orders_age'] : 365; 345 346 printf( 347 '<label><input type="number" min="0" name="' . esc_attr( SDCOM_TIMESTAMPS_OPTIONS ) . '[delete_certificates_old_woocommerce_orders_age]" id="delete_certificates_old_woocommerce_orders_age" value="' . esc_attr( $value ) . '"> %s</label><p class="description">%s</p>', 348 wp_kses_post( __( 'Days', 'timestamps' ) ), 349 wp_kses_post( __( 'Automatically delete old certificates after a certain age. Defaults to 365 days.', 'timestamps' ) ), 350 ); 351 } 352 353 /** 354 * Outputs the "WooCommerce Order Statuses Marked for Old Certificates" settings input checkbox field. 355 * 356 * The default value is _all_ WooCommerce order statuses. 357 * 358 * @since 1.3.0 359 * 360 * @return void 361 */ 362 public function woocommerce_order_statuses_marked_old_certificates_settings_field_callback() { 363 $option = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 364 365 // Get the WooCommerce order statuses. 366 $order_statuses = wc_get_order_statuses(); 367 368 // Sort the $order_statuses in alphabetical order. 369 ksort( $order_statuses ); 370 371 // If the option value is not present, set the default value to all WooCommerce order statuses. 372 if ( empty( $option['woocommerce_order_statuses_marked_old_certificates'] ) ) { 373 $option['woocommerce_order_statuses_marked_old_certificates'] = array_keys( $order_statuses ); 374 } 375 376 // Loop through the WooCommerce order statuses as checkbox elements. 377 foreach ( $order_statuses as $key => $value ) { 378 $is_checked = in_array( $key, $option['woocommerce_order_statuses_marked_old_certificates'], true ); 379 printf( 380 '<input type="checkbox" name="%s[woocommerce_order_statuses_marked_old_certificates][]" value="%s" %s>%s<br>', 381 esc_attr( SDCOM_TIMESTAMPS_OPTIONS ), 382 esc_attr( $key ), 383 checked( $is_checked, true, false ), 384 esc_html( $value ) 385 ); 386 } 387 388 printf( 389 '<p class="description">%s</p>', 390 wp_kses_post( __( 'Select the statuses to mark for old certificates.', 'timestamps' ) ), 391 ); 392 } 393 394 /** 255 395 * Render settings page. 256 396 * … … 258 398 */ 259 399 public function render_settings_page() { 260 // get the timestamps options. 261 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 262 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 263 $timestamps_username = isset( $timestamps_options['username'] ) ? $timestamps_options['username'] : ''; 264 $timestamps_avatar_url = isset( $timestamps_options['avatar_url'] ) ? $timestamps_options['avatar_url'] : ''; 400 // Get the timestamps options. 401 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 402 $timestamps_username = get_plugin_option( 'username', '' ); 403 $timestamps_avatar_url = get_plugin_option( 'avatar_url', '' ); 265 404 ?> 266 405 <div class="wrap"> -
timestamps/trunk/includes/utils.php
r3073868 r3106064 37 37 38 38 /** 39 * Use the correct update option function depending on the context.40 *41 * @since 1.0.042 * @param string $option Name of the option to update.43 * @param mixed $value Option value.44 * @param mixed $autoload Whether to load the option when WordPress starts up.45 * @return bool46 */47 function update_option( $option, $value, $autoload = null ) {48 return \update_option( $option, $value, $autoload );49 }50 51 /**52 * Use the correct get option function depending on the context.53 *54 * @since 1.0.055 * @param string $option Name of the option to get.56 * @param mixed $default_value Default value.57 * @return mixed58 */59 function get_option( $option, $default_value = false ) {60 return \get_option( $option, $default_value );61 }62 63 /**64 * Use the correct delete option function depending on the context.65 *66 * @since 1.0.067 * @param string $option Name of the option to delete.68 * @return bool69 */70 function delete_option( $option ) {71 return \delete_option( $option );72 }73 74 /**75 39 * Checks if the user is authenticated. 76 40 * … … 81 45 */ 82 46 function is_authenticated() { 83 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 84 $timestamps_api_key = isset( $timestamps_options['api_key'] ) ? $timestamps_options['api_key'] : ''; 47 $timestamps_api_key = get_plugin_option( 'api_key', '' ); 85 48 86 49 return ! empty( $timestamps_api_key ); … … 95 58 function is_block_editor_active() { 96 59 97 $classic_editor_replace = \get_option( 'classic-editor-replace' );60 $classic_editor_replace = get_option( 'classic-editor-replace' ); 98 61 99 62 // We assume that the Block Editor is active, whilst the Classic Editor plugin never existed. … … 152 115 return false; 153 116 } 117 118 /** 119 * Checks if the WooCommerce plugin is active. 120 * 121 * @since 1.3.0 122 * @return bool Returns true if the WooCommerce plugin is active, false otherwise. 123 */ 124 function is_woocommerce_active() { 125 return class_exists( 'WooCommerce' ); 126 } 127 128 /** 129 * Gets the WooCommerce volatile order data keys. 130 * 131 * This function returns an array of keys that represent volatile data in a WooCommerce order. 132 * 133 * @since 1.3.0 134 * @return array Filtered volatile order data keys. 135 */ 136 function get_wc_volatile_order_data_keys() { 137 $wc_volatile_order_data_keys = [ 'date_modified', 'meta_data', 'version' ]; 138 139 return apply_filters( 'sdcom_timestamps_wc_volatile_order_data_keys', $wc_volatile_order_data_keys ); 140 } 141 142 /** 143 * Checks if timestamps for WooCommerce orders are active. 144 * 145 * @since 1.3.0 146 * @return bool True if the option is active, false otherwise. 147 */ 148 function is_timestamps_woocommerce_orders_active(): bool { 149 $timestamps_woocommerce_orders_enabled = get_plugin_option( 'enable_timestamps_woocommerce_orders', '' ); 150 151 return ! empty( $timestamps_woocommerce_orders_enabled ); 152 } 153 154 /** 155 * Gets the certificate URL for a WooCommerce order. 156 * 157 * @param \WC_Order $order The WooCommerce order object. 158 * @since 1.3.0 159 * @return string The certificate URL. 160 */ 161 function get_certificate_url_wc_order( $order ): string { 162 $sdcom_previous_certificate_id = $order->get_meta( 'sdcom_previous_certificate_id' ); 163 164 // Bail early if there is no previous certificate id. 165 if ( empty( $sdcom_previous_certificate_id ) ) { 166 return ''; 167 } 168 169 return apply_filters( 'get_certificate_url_wc_order', esc_url( 'https://scoredetect.com/certificate/' . $sdcom_previous_certificate_id ), $order ); 170 } 171 172 /** 173 * Gets the plugin option. 174 * 175 * If the option does not exist, the default value is returned. 176 * 177 * @param string $option_key Name of the option to retrieve. Expected to not be SQL-escaped. 178 * @param mixed $default_value Optional. Default value to return if the option does not exist. 179 * @since 1.3.0 180 * @return mixed Value of the option. A value of any type may be returned, including 181 * scalar (string, boolean, float, integer), null, array, object. 182 * Scalar and null values will be returned as strings as long as they originate 183 * from a database stored option value. If there is no option in the database, 184 * boolean `false` is returned. 185 */ 186 function get_plugin_option( $option_key, $default_value = false ) { 187 $timestamps_options = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 188 189 if ( empty( $timestamps_options ) ) { 190 return false; 191 } 192 193 if ( isset( $timestamps_options[ $option_key ] ) ) { 194 return $timestamps_options[ $option_key ]; 195 } 196 197 return $default_value; 198 } -
timestamps/trunk/package-lock.json
r3073868 r3106064 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 1.0",3 "version": "1.2.1", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "timestamps-plugin", 9 "version": "1. 1.0",9 "version": "1.2.1", 10 10 "dependencies": { 11 11 "@supabase/supabase-js": "^2.39.3", -
timestamps/trunk/package.json
r3081650 r3106064 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 2.1",3 "version": "1.3.0", 4 4 "description": "Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.", 5 5 "homepage": "https://www.scoredetect.com/", -
timestamps/trunk/readme.txt
r3081650 r3106064 1 === Timestamps ===1 === Timestamps – Blockchain Integration for WordPress === 2 2 Contributors: scoredetect, xmic 3 3 Tags: timestamp, blockchain, content, authenticity, copyright, timestamps, protection, verification, proof, timestamping … … 5 5 Tested up to: 6.5.2 6 6 Requires PHP: 7.4 7 Stable tag: 1. 2.17 Stable tag: 1.3.0 8 8 License: AGPL-3.0-only 9 9 License URI: https://spdx.org/licenses/AGPL-3.0-only.html 10 10 11 Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.11 No blockchain skills needed. Timestamp your WordPress content to empower your content authenticity and increase user trust. 12 12 13 13 == Description == 14 Timestamps allow you to increase content authenticity by displaying a rich timeline of your post updates. The timeline can be independently verified by the public , as a verification factor for your content.14 Timestamps allow you to increase content authenticity by displaying a rich timeline of your post updates. The timeline can be independently verified by the public. 15 15 16 16 Here is a list of features included in the plugin: -
timestamps/trunk/timestamps.php
r3081650 r3106064 9 9 * 10 10 * @link https://www.scoredetect.com/ 11 * @since 1. 2.111 * @since 1.3.0 12 12 * @package SDCOM_Timestamps 13 13 * 14 14 * @wordpress-plugin 15 15 * Plugin Name: Timestamps 16 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust with our blockchain timestamping solution.17 * Version: 1. 2.116 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust. No blockchain skills needed. 17 * Version: 1.3.0 18 18 * Author: ScoreDetect.com 19 19 * Author URI: https://www.scoredetect.com/ … … 32 32 33 33 // Useful global constants. 34 define( 'SDCOM_TIMESTAMPS_VERSION', '1. 2.1' );34 define( 'SDCOM_TIMESTAMPS_VERSION', '1.3.0' ); 35 35 define( 'SDCOM_TIMESTAMPS_OPTIONS', 'sdcom_timestamps' ); 36 36 define( 'SDCOM_TIMESTAMPS_URL', plugin_dir_url( __FILE__ ) ); … … 100 100 new Feature\Timestamp\Timestamp() 101 101 ); 102 Features::factory()->register_feature( 103 new Feature\WooCommerce\Orders() 104 ); 102 105 } 103 106 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_features' );
Note: See TracChangeset
for help on using the changeset viewer.