���� JFIF    �� �        "" $(4,$&1'-=-157:::#+?D?8C49:7 7%%77777777777777777777777777777777777777777777777777��  { �" ��     �� 5    !1AQa"q�2��BR��#b�������  ��  ��   ? ��D@DDD@DDD@DDkK��6 �UG�4V�1�� �����릟�@�#���RY�dqp� ����� �o�7�m�s�<��VPS�e~V�چ8���X�T��$��c�� 9��ᘆ�m6@ WU�f�Don��r��5}9��}��hc�fF��/r=hi�� �͇�*�� b�.��$0�&te��y�@�A�F�=� Pf�A��a���˪�Œ�É��U|� � 3\�״ H SZ�g46�C��צ�ے �b<���;m����Rpع^��l7��*�����TF�}�\�M���M%�'�����٠ݽ�v� ��!-�����?�N!La��A+[`#���M����'�~oR�?��v^)��=��h����A��X�.���˃����^Ə��ܯsO"B�c>; �e�4��5�k��/CB��.  �J?��;�҈�������������������~�<�VZ�ꭼ2/)Í”jC���ע�V�G�!���!�F������\�� Kj�R�oc�h���:Þ I��1"2�q×°8��Р@ז���_C0�ր��A��lQ��@纼�!7��F�� �]�sZ B�62r�v�z~�K�7�c��5�.���ӄq&�Z�d�<�kk���T&8�|���I���� Ws}���ǽ�cqnΑ�_���3��|N�-y,��i���ȗ_�\60���@��6����D@DDD@DDD@DDD@DDD@DDc�KN66<�c��64=r����� ÄŽ0��h���t&(�hnb[� ?��^��\��â|�,�/h�\��R��5�? �0�!צ܉-����G����٬��Q�zA���1�����V��� �:R���`�$��ik��H����D4�����#dk����� h�}����7���w%�������*o8wG�LycuT�.���ܯ7��I��u^���)��/c�,s�Nq�ۺ�;�ך�YH2���.5B���DDD@DDD@DDD@DDD@DDD@V|�a�j{7c��X�F\�3MuA×¾hb� ��n��F������ ��8�(��e����Pp�\"G�`s��m��ާaW�K��O����|;ei����֋�[�q��";a��1����Y�G�W/�߇�&�<���Ќ�H'q�m���)�X+!���=�m�ۚ丷~6a^X�)���,�>#&6G���Y��{����"" """ """ """ """ ""��at\/�a�8 �yp%�lhl�n����)���i�t��B�������������?��modskinlienminh.com - WSOX ENC ‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT h25jguaT5*!‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT h25jguaT5*!infrastructure/endpoints/consent-endpoint.php000066600000002023151733467250015645 0ustar00get_namespace() . $this->get_route() ); } } user-interface/ai-consent-integration.php000066600000005712151733467250014600 0ustar00 */ public static function get_conditionals(): array { return [ User_Profile_Conditional::class ]; } /** * Constructs the class. * * @param WPSEO_Admin_Asset_Manager $asset_manager The admin asset manager. * @param User_Helper $user_helper The user helper. * @param Short_Link_Helper $short_link_helper The short link helper. */ public function __construct( WPSEO_Admin_Asset_Manager $asset_manager, User_Helper $user_helper, Short_Link_Helper $short_link_helper ) { $this->asset_manager = $asset_manager; $this->user_helper = $user_helper; $this->short_link_helper = $short_link_helper; } /** * Initializes the integration. * * This is the place to register hooks and filters. * * @return void */ public function register_hooks() { // Hide AI feature option in user profile if the user is not allowed to use it. if ( \current_user_can( 'edit_posts' ) ) { \add_action( 'wpseo_user_profile_additions', [ $this, 'render_user_profile' ], 12 ); } \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 ); } /** * Returns the script data for the AI consent button. * * @return array */ public function get_script_data(): array { return [ 'hasConsent' => $this->user_helper->get_meta( $this->user_helper->get_current_user_id(), '_yoast_wpseo_ai_consent', true ), 'pluginUrl' => \plugins_url( '', \WPSEO_FILE ), 'linkParams' => $this->short_link_helper->get_query_params(), ]; } /** * Enqueues the required assets. * * @return void */ public function enqueue_assets() { $this->asset_manager->enqueue_style( 'ai-generator' ); $this->asset_manager->localize_script( 'ai-consent', 'wpseoAiConsent', $this->get_script_data() ); $this->asset_manager->enqueue_script( 'ai-consent' ); } /** * Renders the AI consent button for the user profile. * * @return void */ public function render_user_profile() { echo '', ''; } } user-interface/consent-route.php000066600000010553151733467250013023 0ustar00 The conditionals. */ public static function get_conditionals() { return [ AI_Conditional::class ]; } /** * Class constructor. * * @param Consent_Handler $consent_handler The consent handler. * @param Token_Manager $token_manager The token manager. */ public function __construct( Consent_Handler $consent_handler, Token_Manager $token_manager ) { $this->consent_handler = $consent_handler; $this->token_manager = $token_manager; } /** * Registers routes with WordPress. * * @return void */ public function register_routes() { \register_rest_route( self::ROUTE_NAMESPACE, self::ROUTE_PREFIX, [ 'methods' => 'POST', 'args' => [ 'consent' => [ 'required' => true, 'type' => 'boolean', 'description' => 'Whether the consent to use AI-based services has been given by the user.', ], ], 'callback' => [ $this, 'consent' ], 'permission_callback' => [ $this, 'check_permissions' ], ] ); } /** * Runs the callback to store the consent given by the user to use AI-based services. * * @param WP_REST_Request $request The request object. * * @return WP_REST_Response The response of the callback action. */ public function consent( WP_REST_Request $request ): WP_REST_Response { $user_id = \get_current_user_id(); $consent = \boolval( $request['consent'] ); try { if ( $consent ) { // Store the consent at user level. $this->consent_handler->grant_consent( $user_id ); } else { // Delete the consent at user level. $this->consent_handler->revoke_consent( $user_id ); // Invalidate the token if the user revoked the consent. $this->token_manager->token_invalidate( $user_id ); } } catch ( Bad_Request_Exception | Forbidden_Exception | Internal_Server_Error_Exception | Not_Found_Exception | Payment_Required_Exception | Request_Timeout_Exception | Service_Unavailable_Exception | Too_Many_Requests_Exception | RuntimeException $e ) { return new WP_REST_Response( ( $consent ) ? 'Failed to store consent.' : 'Failed to revoke consent.', 500 ); } return new WP_REST_Response( ( $consent ) ? 'Consent successfully stored.' : 'Consent successfully revoked.' ); } /** * Checks: * - if the user is logged * - if the user can edit posts * * @return bool Whether the user is logged in, can edit posts and the feature is active. */ public function check_permissions(): bool { $user = \wp_get_current_user(); if ( $user === null || $user->ID < 1 ) { return false; } return \user_can( $user, 'edit_posts' ); } } application/consent-handler.php000066600000002135151733467250012666 0ustar00user_helper = $user_helper; } /** * Handles consent revoked by deleting the consent user metadata from the database. * * @param int $user_id The user ID. * * @return void */ public function revoke_consent( int $user_id ) { $this->user_helper->delete_meta( $user_id, '_yoast_wpseo_ai_consent' ); } /** * Handles consent granted by adding the consent user metadata to the database. * * @param int $user_id The user ID. * * @return void */ public function grant_consent( int $user_id ) { $this->user_helper->update_meta( $user_id, '_yoast_wpseo_ai_consent', true ); } } application/consent-handler-interface.php000066600000001153151733467250014623 0ustar00