s_authorized_blog_request() ? 'blog' : 'user', 'test_connections' => $request->get_param( 'test_connections' ), ); $connections = Connections::wpcom_get_connections( $args ); } else { $connections = $this->proxy_request_to_wpcom_as_user( $request ); } if ( is_wp_error( $connections ) ) { return $connections; } $items = array(); foreach ( $connections as $item ) { $data = $this->prepare_item_for_response( $item, $request ); $items[] = $this->prepare_response_for_collection( $data ); } $response = rest_ensure_response( $items ); $response->header( 'X-WP-Total', (string) count( $items ) ); $response->header( 'X-WP-TotalPages', '1' ); return $response; } /** * Checks if a given request has access to create a connection. * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */ public function create_item_permissions_check( $request ) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $permissions = parent::publicize_permissions_check(); if ( is_wp_error( $permissions ) ) { return $permissions; } return current_user_can( 'publish_posts' ); } /** * Creates a new connection. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function create_item( $request ) { if ( Publicize_Utils::is_wpcom() ) { $input = array( 'keyring_connection_ID' => $request->get_param( 'keyring_connection_ID' ), 'shared' => $request->get_param( 'shared' ), ); $external_user_id = $request->get_param( 'external_user_ID' ); if ( ! empty( $external_user_id ) ) { $input['external_user_ID'] = $external_user_id; } $result = Connections::wpcom_create_connection( $input ); if ( is_wp_error( $result ) ) { return $result; } $connection = Connections::get_by_id( $result ); $response = $this->prepare_item_for_response( $connection, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); return $response; } $response = $this->proxy_request_to_wpcom_as_user( $request, '', array( 'timeout' => 120 ) ); if ( is_wp_error( $response ) ) { return new WP_Error( 'jp_connection_update_failed', __( 'Something went wrong while creating a connection.', 'jetpack-publicize-pkg' ), $response->get_error_message() ); } $response = rest_ensure_response( $response ); $response->set_status( 201 ); return $response; } /** * Checks if a given request has access to update a connection. * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */ public function update_item_permissions_check( $request ) { $permissions = parent::publicize_permissions_check(); if ( is_wp_error( $permissions ) ) { return $permissions; } // If the user cannot manage the connection, they can't update it either. if ( ! $this->manage_connection_permission_check( $request ) ) { return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to update this connection.', 'jetpack-publicize-pkg' ), array( 'status' => rest_authorization_required_code() ) ); } // If the connection is being marked/unmarked as shared. if ( $request->has_param( 'shared' ) ) { // Only editors and above can mark a connection as shared. return current_user_can( 'edit_others_posts' ); } return current_user_can( 'publish_posts' ); } /** * Update a connection. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function update_item( $request ) { $connection_id = $request->get_param( 'connection_id' ); if ( Publicize_Utils::is_wpcom() ) { $input = array( 'shared' => $request->get_param( 'shared' ), ); $result = Connections::wpcom_update_connection( $connection_id, $input ); if ( is_wp_error( $result ) ) { return $result; } $connection = Connections::get_by_id( $connection_id ); $response = $this->prepare_item_for_response( $connection, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); return $response; } $response = $this->proxy_request_to_wpcom_as_user( $request, $connection_id, array( 'timeout' => 120 ) ); if ( is_wp_error( $response ) ) { return new WP_Error( 'jp_connection_updation_failed', __( 'Something went wrong while updating the connection.', 'jetpack-publicize-pkg' ), $response->get_error_message() ); } $response = rest_ensure_response( $response ); $response->set_status( 201 ); return $response; } /** * Checks if a given request has access to delete a connection. * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */ public function delete_item_permissions_check( $request ) { $permissions = parent::publicize_permissions_check(); if ( is_wp_error( $permissions ) ) { return $permissions; } return $this->manage_connection_permission_check( $request ); } /** * Delete a connection. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function delete_item( $request ) { $connection_id = $request->get_param( 'connection_id' ); if ( Publicize_Utils::is_wpcom() ) { $result = Connections::wpcom_delete_connection( $connection_id ); if ( is_wp_error( $result ) ) { return $result; } $response = rest_ensure_response( $result ); $response->set_status( 201 ); return $response; } $response = $this->proxy_request_to_wpcom_as_user( $request, $connection_id, array( 'timeout' => 120 ) ); if ( is_wp_error( $response ) ) { return new WP_Error( 'jp_connection_deletion_failed', __( 'Something went wrong while deleting the connection.', 'jetpack-publicize-pkg' ), $response->get_error_message() ); } $response = rest_ensure_response( $response ); $response->set_status( 201 ); return $response; } }
Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Publicize\REST_API\Connections_Controller' not found in /var/www/html/dportilho.com.br/web/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-setup.php:50 Stack trace: #0 /var/www/html/dportilho.com.br/web/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Publicize\Publicize_Setup::pre_initialization('') #1 /var/www/html/dportilho.com.br/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #2 /var/www/html/dportilho.com.br/web/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /var/www/html/dportilho.com.br/web/wp-settings.php(559): do_action('plugins_loaded') #4 /var/www/html/dportilho.com.br/web/wp-config.php(126): require_once('/var/www/html/d...') #5 /var/www/html/dportilho.com.br/web/wp-load.php(50): require_once('/var/www/html/d...') #6 /var/www/html/dportilho.com.br/web/wp-blog-header.php(13): require_once('/var/www/html/d...') #7 /var/www/html/dportilho.com.br/web/index.php(17): require in /var/www/html/dportilho.com.br/web/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-setup.php on line 50