Changeset 3199387
- Timestamp:
- 11/29/2024 11:27:25 AM (16 months ago)
- Location:
- timestamps
- Files:
-
- 10 edited
- 1 copied
-
tags/1.10.0 (copied) (copied from timestamps/trunk)
-
tags/1.10.0/includes/classes/Feature/Timestamp/Timestamp.php (modified) (3 diffs)
-
tags/1.10.0/package-lock.json (modified) (2 diffs)
-
tags/1.10.0/package.json (modified) (1 diff)
-
tags/1.10.0/readme.txt (modified) (1 diff)
-
tags/1.10.0/timestamps.php (modified) (3 diffs)
-
trunk/includes/classes/Feature/Timestamp/Timestamp.php (modified) (3 diffs)
-
trunk/package-lock.json (modified) (2 diffs)
-
trunk/package.json (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/timestamps.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
timestamps/tags/1.10.0/includes/classes/Feature/Timestamp/Timestamp.php
r3129719 r3199387 72 72 add_filter( 'is_protected_meta', array( $this, 'is_protected_meta' ), 10, 3 ); 73 73 add_shortcode( 'timestamps', array( $this, 'shortcode' ) ); 74 75 // Oxygen Builder. 76 add_action( 'save_post', array( $this, 'save_post_meta_oxygenbuilder' ), 10, 2 ); 74 77 } 75 78 … … 406 409 407 410 /** 411 * Save post meta data during an Oxygen Builder request. 412 * 413 * @param int $post_id The post ID. 414 * @param WP_Post $post The post object. 415 * @since 1.10.0 416 * @since Oxygen Builder 4.9 417 * @return void 418 * @throws \Exception If an error occurs during the process. 419 */ 420 public function save_post_meta_oxygenbuilder( $post_id, $post ) { 421 422 if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'ct_save_components_tree' ) { 423 return; 424 } 425 426 $nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ) : ''; 427 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; 428 429 // Check nonce. 430 if ( ! isset( $nonce, $post_id ) || ! wp_verify_nonce( $nonce, 'oxygen-nonce-' . $post_id ) ) { 431 // This nonce is not valid. 432 die( 'Security check' ); 433 } 434 435 // Check if user can edit this post. 436 if ( ! oxygen_vsb_current_user_can_access() ) { 437 die( 'Security check' ); 438 } 439 440 $sdcom_timestamp_post = get_post_meta( $post_id, 'sdcom_timestamp_post', true ); 441 442 $_ct_builder_json = get_post_meta( $post_id, '_ct_builder_json', true ); 443 444 if ( ! empty( $sdcom_timestamp_post ) && ! empty( $_ct_builder_json ) ) { 445 try { 446 update_post_meta( $post_id, 'sdcom_timestamp_post', true ); 447 448 $create_certificate = $this->create_certificate_post( $post, $_ct_builder_json ); 449 450 // Handle the case where the method returned false. 451 if ( $create_certificate === false ) { 452 throw new \Exception( 'Create certificate failed.' ); 453 } 454 455 $certificate_id = ! empty( $create_certificate->{'certificate'}->{'id'} ) ? $create_certificate->{'certificate'}->{'id'} : ''; 456 457 // Handle the case where the certificate id is empty. 458 if ( empty( $certificate_id ) ) { 459 throw new \Exception( 'Certificate id is empty.' ); 460 } 461 462 $update_certificate = $this->update_certificate_post( $post, $certificate_id, $_ct_builder_json ); 463 464 // Handle the case where the method returned false. 465 if ( $update_certificate === false ) { 466 throw new \Exception( 'Update certificate failed.' ); 467 } 468 469 // Bail early if the certificate id is empty. 470 if ( empty( $certificate_id ) ) { 471 throw new \Exception( 'Certificate id is empty.' ); 472 } 473 474 // Update the post meta with the new certificate id. 475 update_post_meta( $post_id, 'sdcom_previous_certificate_id', $certificate_id ); 476 } catch ( \Exception $e ) { 477 // Handle the exception 478 error_log( 'An error occurred: ' . $e->getMessage() ); 479 } 480 } else { 481 delete_post_meta( $post_id, 'sdcom_timestamp_post' ); 482 } 483 } 484 485 /** 408 486 * Creates a certificate for a post. 409 487 * 410 488 * @param WP_Post $post The post to create a certificate for. 489 * @param string $post_content The post content. If empty, the post content will be used. 411 490 * @return object|false The data returned by the API on success, or false on failure. 412 491 * @throws \Throwable If an exception occurs during the process. 413 492 * @throws \Exception If the options, post content, or API key is empty. 414 493 */ 415 private function create_certificate_post( $post ) {494 private function create_certificate_post( $post, $post_content = null ) { 416 495 try { 417 496 $post_id = $post->ID; 418 $post_content = $post->post_content;497 $post_content = ! empty( $post_content ) ? $post_content : $post->post_content; 419 498 $sdcom_timestamps = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 420 499 $sdcom_previous_certificate_id = get_post_meta( $post_id, 'sdcom_previous_certificate_id', true ); … … 508 587 * @param WP_Post $post The post to update a certificate for. 509 588 * @param string $certificate_id The id of the certificate to update. 589 * @param string $post_content The post content. If empty, the post content will be used. 510 590 * @return object|false The data returned by the API on success, or false on failure. 511 591 * @throws \Exception If the certificate id, options, post content, or API key is empty. 512 592 * @throws \Throwable If an exception occurs during the process. 513 593 */ 514 private function update_certificate_post( $post, $certificate_id ) {594 private function update_certificate_post( $post, $certificate_id, $post_content = null ) { 515 595 try { 516 $post_content = $post->post_content;596 $post_content = ! empty( $post_content ) ? $post_content : $post->post_content; 517 597 $sdcom_timestamps = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 518 598 -
timestamps/tags/1.10.0/package-lock.json
r3179723 r3199387 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 9.0",3 "version": "1.10.0", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "timestamps-plugin", 9 "version": "1. 9.0",9 "version": "1.10.0", 10 10 "dependencies": { 11 11 "@supabase/supabase-js": "^2.39.3", -
timestamps/tags/1.10.0/package.json
r3179723 r3199387 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 9.0",3 "version": "1.10.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.10.0/readme.txt
r3179723 r3199387 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1. 9.07 Stable tag: 1.10.0 8 8 License: AGPL-3.0-only 9 9 License URI: https://spdx.org/licenses/AGPL-3.0-only.html -
timestamps/tags/1.10.0/timestamps.php
r3179723 r3199387 9 9 * 10 10 * @link https://www.scoredetect.com/ 11 * @since 1. 9.011 * @since 1.10.0 12 12 * @package SDCOM_Timestamps 13 13 * … … 15 15 * Plugin Name: Timestamps 16 16 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust. No blockchain skills needed. 17 * Version: 1. 9.017 * Version: 1.10.0 18 18 * Author: ScoreDetect.com 19 19 * Author URI: https://www.scoredetect.com/ … … 34 34 35 35 // Useful global constants. 36 define( 'SDCOM_TIMESTAMPS_VERSION', '1. 9.0' );36 define( 'SDCOM_TIMESTAMPS_VERSION', '1.10.0' ); 37 37 define( 'SDCOM_TIMESTAMPS_OPTIONS', 'sdcom_timestamps' ); 38 38 define( 'SDCOM_TIMESTAMPS_URL', plugin_dir_url( __FILE__ ) ); -
timestamps/trunk/includes/classes/Feature/Timestamp/Timestamp.php
r3129719 r3199387 72 72 add_filter( 'is_protected_meta', array( $this, 'is_protected_meta' ), 10, 3 ); 73 73 add_shortcode( 'timestamps', array( $this, 'shortcode' ) ); 74 75 // Oxygen Builder. 76 add_action( 'save_post', array( $this, 'save_post_meta_oxygenbuilder' ), 10, 2 ); 74 77 } 75 78 … … 406 409 407 410 /** 411 * Save post meta data during an Oxygen Builder request. 412 * 413 * @param int $post_id The post ID. 414 * @param WP_Post $post The post object. 415 * @since 1.10.0 416 * @since Oxygen Builder 4.9 417 * @return void 418 * @throws \Exception If an error occurs during the process. 419 */ 420 public function save_post_meta_oxygenbuilder( $post_id, $post ) { 421 422 if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'ct_save_components_tree' ) { 423 return; 424 } 425 426 $nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ) : ''; 427 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; 428 429 // Check nonce. 430 if ( ! isset( $nonce, $post_id ) || ! wp_verify_nonce( $nonce, 'oxygen-nonce-' . $post_id ) ) { 431 // This nonce is not valid. 432 die( 'Security check' ); 433 } 434 435 // Check if user can edit this post. 436 if ( ! oxygen_vsb_current_user_can_access() ) { 437 die( 'Security check' ); 438 } 439 440 $sdcom_timestamp_post = get_post_meta( $post_id, 'sdcom_timestamp_post', true ); 441 442 $_ct_builder_json = get_post_meta( $post_id, '_ct_builder_json', true ); 443 444 if ( ! empty( $sdcom_timestamp_post ) && ! empty( $_ct_builder_json ) ) { 445 try { 446 update_post_meta( $post_id, 'sdcom_timestamp_post', true ); 447 448 $create_certificate = $this->create_certificate_post( $post, $_ct_builder_json ); 449 450 // Handle the case where the method returned false. 451 if ( $create_certificate === false ) { 452 throw new \Exception( 'Create certificate failed.' ); 453 } 454 455 $certificate_id = ! empty( $create_certificate->{'certificate'}->{'id'} ) ? $create_certificate->{'certificate'}->{'id'} : ''; 456 457 // Handle the case where the certificate id is empty. 458 if ( empty( $certificate_id ) ) { 459 throw new \Exception( 'Certificate id is empty.' ); 460 } 461 462 $update_certificate = $this->update_certificate_post( $post, $certificate_id, $_ct_builder_json ); 463 464 // Handle the case where the method returned false. 465 if ( $update_certificate === false ) { 466 throw new \Exception( 'Update certificate failed.' ); 467 } 468 469 // Bail early if the certificate id is empty. 470 if ( empty( $certificate_id ) ) { 471 throw new \Exception( 'Certificate id is empty.' ); 472 } 473 474 // Update the post meta with the new certificate id. 475 update_post_meta( $post_id, 'sdcom_previous_certificate_id', $certificate_id ); 476 } catch ( \Exception $e ) { 477 // Handle the exception 478 error_log( 'An error occurred: ' . $e->getMessage() ); 479 } 480 } else { 481 delete_post_meta( $post_id, 'sdcom_timestamp_post' ); 482 } 483 } 484 485 /** 408 486 * Creates a certificate for a post. 409 487 * 410 488 * @param WP_Post $post The post to create a certificate for. 489 * @param string $post_content The post content. If empty, the post content will be used. 411 490 * @return object|false The data returned by the API on success, or false on failure. 412 491 * @throws \Throwable If an exception occurs during the process. 413 492 * @throws \Exception If the options, post content, or API key is empty. 414 493 */ 415 private function create_certificate_post( $post ) {494 private function create_certificate_post( $post, $post_content = null ) { 416 495 try { 417 496 $post_id = $post->ID; 418 $post_content = $post->post_content;497 $post_content = ! empty( $post_content ) ? $post_content : $post->post_content; 419 498 $sdcom_timestamps = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 420 499 $sdcom_previous_certificate_id = get_post_meta( $post_id, 'sdcom_previous_certificate_id', true ); … … 508 587 * @param WP_Post $post The post to update a certificate for. 509 588 * @param string $certificate_id The id of the certificate to update. 589 * @param string $post_content The post content. If empty, the post content will be used. 510 590 * @return object|false The data returned by the API on success, or false on failure. 511 591 * @throws \Exception If the certificate id, options, post content, or API key is empty. 512 592 * @throws \Throwable If an exception occurs during the process. 513 593 */ 514 private function update_certificate_post( $post, $certificate_id ) {594 private function update_certificate_post( $post, $certificate_id, $post_content = null ) { 515 595 try { 516 $post_content = $post->post_content;596 $post_content = ! empty( $post_content ) ? $post_content : $post->post_content; 517 597 $sdcom_timestamps = get_option( SDCOM_TIMESTAMPS_OPTIONS ); 518 598 -
timestamps/trunk/package-lock.json
r3179723 r3199387 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 9.0",3 "version": "1.10.0", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "timestamps-plugin", 9 "version": "1. 9.0",9 "version": "1.10.0", 10 10 "dependencies": { 11 11 "@supabase/supabase-js": "^2.39.3", -
timestamps/trunk/package.json
r3179723 r3199387 1 1 { 2 2 "name": "timestamps-plugin", 3 "version": "1. 9.0",3 "version": "1.10.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
r3179723 r3199387 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1. 9.07 Stable tag: 1.10.0 8 8 License: AGPL-3.0-only 9 9 License URI: https://spdx.org/licenses/AGPL-3.0-only.html -
timestamps/trunk/timestamps.php
r3179723 r3199387 9 9 * 10 10 * @link https://www.scoredetect.com/ 11 * @since 1. 9.011 * @since 1.10.0 12 12 * @package SDCOM_Timestamps 13 13 * … … 15 15 * Plugin Name: Timestamps 16 16 * Description: Timestamp your WordPress content to empower your content authenticity and increase user trust. No blockchain skills needed. 17 * Version: 1. 9.017 * Version: 1.10.0 18 18 * Author: ScoreDetect.com 19 19 * Author URI: https://www.scoredetect.com/ … … 34 34 35 35 // Useful global constants. 36 define( 'SDCOM_TIMESTAMPS_VERSION', '1. 9.0' );36 define( 'SDCOM_TIMESTAMPS_VERSION', '1.10.0' ); 37 37 define( 'SDCOM_TIMESTAMPS_OPTIONS', 'sdcom_timestamps' ); 38 38 define( 'SDCOM_TIMESTAMPS_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.