| @@ -748,74 +748,8 @@ | ||
| 748 | 748 | return get_site_url(); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | - * Register the shared secret with the server during plugin activation. | |
| 753 | - * | |
| 754 | - * @since 1.0.0 | |
| 755 | - * @return array<int|string, mixed> The registration response. | |
| 756 | - */ | |
| 757 | - public static function register_shared_secret_with_laravel() { | |
| 758 | - $shared_secret = self::get_shared_secret(); | |
| 759 | - $site_id = self::get_site_id(); | |
| 760 | - | |
| 761 | - // Register endpoint - this should point to the server. | |
| 762 | - $register_endpoint = ZIPAI_MCP_CREDIT_SERVER_API . 'auth/register-secret'; | |
| 763 | - | |
| 764 | - $registration_data = array( | |
| 765 | - 'site_id' => $site_id, | |
| 766 | - 'secret' => $shared_secret, | |
| 767 | - 'site_name' => get_bloginfo( 'name' ), | |
| 768 | - 'admin_email' => get_option( 'admin_email' ), | |
| 769 | - ); | |
| 770 | - | |
| 771 | - $response = wp_remote_post( | |
| 772 | - $register_endpoint, | |
| 773 | - array( | |
| 774 | - 'headers' => array( | |
| 775 | - 'Content-Type' => 'application/json', | |
| 776 | - ), | |
| 777 | - 'body' => (string) wp_json_encode( $registration_data ), | |
| 778 | - 'timeout' => 30, | |
| 779 | - ) | |
| 780 | - ); | |
| 781 | - | |
| 782 | - if ( is_wp_error( $response ) ) { | |
| 783 | - return array( | |
| 784 | - 'error' => $response->get_error_message(), | |
| 785 | - 'code' => 'registration_failed', | |
| 786 | - ); | |
| 787 | - } | |
| 788 | - | |
| 789 | - $response_body = wp_remote_retrieve_body( $response ); | |
| 790 | - $status_code = wp_remote_retrieve_response_code( $response ); | |
| 791 | - | |
| 792 | - if ( 200 !== $status_code ) { | |
| 793 | - return array( | |
| 794 | - 'error' => __( 'Failed to register with Laravel server.', 'zip-ai' ), | |
| 795 | - 'code' => 'registration_failed', | |
| 796 | - ); | |
| 797 | - } | |
| 798 | - | |
| 799 | - $response_data = json_decode( $response_body, true ); | |
| 800 | - | |
| 801 | - // Store the registration status. | |
| 802 | - self::update_setting( 'hmac_registered', 'true' ); | |
| 803 | - | |
| 804 | - return is_array( $response_data ) ? $response_data : array(); | |
| 805 | - } | |
| 806 | - | |
| 807 | - /** | |
| 808 | - * Check if HMAC is registered with the server. | |
| 809 | - * | |
| 810 | - * @since 1.0.0 | |
| 811 | - * @return bool True if registered, false otherwise. | |
| 812 | - */ | |
| 813 | - public static function is_hmac_registered() { | |
| 814 | - return 'true' === self::get_setting( 'hmac_registered', 'false' ); | |
| 815 | - } | |
| 816 | - | |
| 817 | - /** | |
| 818 | 752 | * Prepare a block array for WordPress serialize_blocks(). |
| 819 | 753 | * |
| 820 | 754 | * LLM-generated blocks only have blockName/attrs/innerBlocks. |
| 821 | 755 | * WordPress serialize_block() requires innerHTML and innerContent |