id = 'thinkrank/get-social-platforms-settings'; $this->label = __( 'Get ThinkRank Social Platform Settings', 'thinkrank' ); $this->description = __( 'Retrieve ThinkRank social platform verification settings: public platform IDs (Facebook, YouTube, WhatsApp) verbatim and sensitive site-verification codes (Pinterest, Instagram, TikTok) masked for security. Use update-social-platforms-settings to change them.', 'thinkrank' ); } /** * {@inheritDoc} * * @return array */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @return array */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'properties' => self::empty_properties(), ]; } /** * {@inheritDoc} * * @return array */ public function get_output_schema() { return [ 'type' => 'object', 'properties' => [ 'settings' => [ 'type' => 'object', 'description' => __( 'Social platform IDs (verbatim) and verification codes (masked).', 'thinkrank' ), 'properties' => [ 'facebook_app_id' => [ 'type' => 'string' ], 'facebook_admins' => [ 'type' => 'string' ], 'youtube_channel_id' => [ 'type' => 'string' ], 'whatsapp_business_id' => [ 'type' => 'string' ], 'pinterest_site_verification' => [ 'type' => 'string' ], 'instagram_verification' => [ 'type' => 'string' ], 'tiktok_verification' => [ 'type' => 'string' ], ], 'additionalProperties' => false, ], ], ]; } /** * Execute ability. * * @param array $input Ability input payload. * @return array */ public function execute( $input ) { $settings = Settings::instance(); $out = []; foreach ( self::PUBLIC_KEYS as $key ) { $out[ $key ] = (string) $settings->get( $key, '' ); } foreach ( self::SENSITIVE_KEYS as $key ) { $out[ $key ] = $this->mask_verification_code( (string) $settings->get( $key, '' ) ); } return [ 'settings' => $out ]; } /** * Mask a verification code: first four chars + "XXXX", or "XXXX" when short. * * @param string $code Raw verification code. * @return string Masked code, or empty string when unset. */ private function mask_verification_code( string $code ): string { if ( '' === $code ) { return ''; } if ( strlen( $code ) > 8 ) { return substr( $code, 0, 4 ) . 'XXXX'; } return 'XXXX'; } }