*/ protected function input_properties(): array { return array( 'library_id' => array( 'type' => 'integer', 'description' => __( 'Library snippet id, from search-library.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'library_id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'snippet' => array( 'type' => 'object', 'additionalProperties' => true ), 'in_cache' => array( 'type' => 'boolean' ), 'safe_mode' => array( 'type' => 'boolean' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => false ); } /** * @since 0.0.34 * @return bool */ protected function requires_confirmation(): bool { return true; } /** * @since 0.0.34 * @return string */ protected function confirmation_message(): string { return __( 'This installs third-party code from the WPCode library onto this site. It will be installed inactive and will not run until you activate it. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $installed = Library_Repository::install( (int) ( $input['library_id'] ?? 0 ) ); if ( is_wp_error( $installed ) ) { return $installed; } return array( 'snippet' => $installed, 'in_cache' => $installed['in_cache'], 'safe_mode' => WPCode_Guard::safe_mode(), 'message' => __( 'Library snippet installed and left inactive. Review the code, then call activate-snippet.', 'acrossai-abilities-manager' ), ); } }