Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
inc
/
File Content:
class-my-yoast-api-request.php
<?php /** * WPSEO plugin file. * * @package WPSEO\Inc */ /** * Handles requests to MyYoast. */ class WPSEO_MyYoast_Api_Request { /** * The Request URL. * * @var string */ protected $url; /** * The request parameters. * * @var array */ protected $args = [ 'method' => 'GET', 'timeout' => 5, 'headers' => [ 'Accept-Encoding' => '*', 'Expect' => '', ], ]; /** * Contains the fetched response. * * @var stdClass */ protected $response; /** * Contains the error message when request went wrong. * * @var string */ protected $error_message = ''; /** * Constructor. * * @codeCoverageIgnore * * @param string $url The request url. * @param array $args The request arguments. */ public function __construct( $url, array $args = [] ) { $this->url = 'https://my.yoast.com/api/' . $url; $this->args = wp_parse_args( $args, $this->args ); } /** * Fires the request. * * @return bool True when request is successful. */ public function fire() { try { $response = $this->do_request( $this->url, $this->args ); $this->response = $this->decode_response( $response ); return true; } catch ( WPSEO_MyYoast_Bad_Request_Exception $bad_request_exception ) { $this->error_message = $bad_request_exception->getMessage(); return false; } } /** * Retrieves the error message. * * @return string The set error message. */ public function get_error_message() { return $this->error_message; } /** * Retrieves the response. * * @return stdClass The response object. */ public function get_response() { return $this->response; } /** * Performs the request using WordPress internals. * * @codeCoverageIgnore * * @param string $url The request URL. * @param array $request_arguments The request arguments. * * @return string The retrieved body. * @throws WPSEO_MyYoast_Bad_Request_Exception When request is invalid. */ protected function do_request( $url, $request_arguments ) { $request_arguments = $this->enrich_request_arguments( $request_arguments ); $response = wp_remote_request( $url, $request_arguments ); if ( is_wp_error( $response ) ) { throw new WPSEO_MyYoast_Bad_Request_Exception( $response->get_error_message() ); } $response_code = wp_remote_retrieve_response_code( $response ); $response_message = wp_remote_retrieve_response_message( $response ); // Do nothing, response code is okay. if ( $response_code === 200 || strpos( $response_code, '200' ) !== false ) { return wp_remote_retrieve_body( $response ); } throw new WPSEO_MyYoast_Bad_Request_Exception( esc_html( $response_message ), (int) $response_code ); } /** * Decodes the JSON encoded response. * * @param string $response The response to decode. * * @return stdClass The json decoded response. * @throws WPSEO_MyYoast_Invalid_JSON_Exception When decoded string is not a JSON object. */ protected function decode_response( $response ) { $response = json_decode( $response ); if ( ! is_object( $response ) ) { throw new WPSEO_MyYoast_Invalid_JSON_Exception( esc_html__( 'No JSON object was returned.', 'wordpress-seo' ) ); } return $response; } /** * Checks if MyYoast tokens are allowed and adds the token to the request body. * * When tokens are disallowed it will add the url to the request body. * * @param array $request_arguments The arguments to enrich. * * @return array The enriched arguments. */ protected function enrich_request_arguments( array $request_arguments ) { $request_arguments = wp_parse_args( $request_arguments, [ 'headers' => [] ] ); $addon_version_headers = $this->get_installed_addon_versions(); foreach ( $addon_version_headers as $addon => $version ) { $request_arguments['headers'][ $addon . '-version' ] = $version; } $request_body = $this->get_request_body(); if ( $request_body !== [] ) { $request_arguments['body'] = $request_body; } return $request_arguments; } /** * Retrieves the request body based on URL or access token support. * * @codeCoverageIgnore * * @return array The request body. */ public function get_request_body() { return [ 'url' => WPSEO_Utils::get_home_url() ]; } /** * Wraps the get current user id function. * * @codeCoverageIgnore * * @return int The user id. */ protected function get_current_user_id() { return get_current_user_id(); } /** * Retrieves the installed addons as http headers. * * @codeCoverageIgnore * * @return array The installed addon versions. */ protected function get_installed_addon_versions() { $addon_manager = new WPSEO_Addon_Manager(); return $addon_manager->get_installed_addons_versions(); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
exceptions
---
0755
options
---
0755
sitemaps
---
0755
.DS_Store
10234 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
MessageInterface.php
6950 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
base.php
2793 bytes
0644
class-addon-manager.php
20295 bytes
0644
class-admin-utils.php
2147 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-my-yoast-api-request.php
4890 bytes
0644
class-plugin-availability.php
8440 bytes
0644
class-post-type.php
2833 bytes
0644
class-rewrite.php
7140 bytes
0644
class-sitemaps-admin-20260703023908.php
3665 bytes
0644
class-sitemaps-admin.php
3665 bytes
0644
class-tracking-server-data.php
1989 bytes
0644
class-upgrade-history.php
2939 bytes
0644
class-upgrade.php
36923 bytes
0644
class-wpseo-admin-bar-menu.php
19858 bytes
0644
class-wpseo-content-images.php
2613 bytes
0644
class-wpseo-custom-fields.php
1485 bytes
0644
class-wpseo-custom-taxonomies.php
1628 bytes
0644
class-wpseo-features.php
788 bytes
0644
class-wpseo-image-utils.php
13988 bytes
0644
class-wpseo-installation.php
1118 bytes
0644
class-wpseo-meta.php
36093 bytes
0644
class-wpseo-primary-term.php
1669 bytes
0644
class-wpseo-rank.php
5845 bytes
0644
class-wpseo-replace-vars.php
45562 bytes
0644
class-wpseo-replacement-variable.php
1375 bytes
0644
class-wpseo-shortlinker.php
3433 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-wpseo-utils.php
39644 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
ctrl.package.php
17073 bytes
0644
date-helper.php
1752 bytes
0644
define.php
4567 bytes
0644
duplicator.php
1781 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260706100554.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
exceptions.php
708 bytes
0644
health-check-curl-version.php
4584 bytes
0644
health-check-default-tagline.php
1961 bytes
0644
health-check-links-table-not-accessible.php
2312 bytes
0644
health-check-page-comments.php
1733 bytes
0644
health-check-postname-permalink.php
1775 bytes
0644
health-check-ryte.php
8457 bytes
0644
health-check.php
4522 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
38 bytes
0644
interface-wpseo-wordpress-ajax-integration.php
294 bytes
0644
interface-wpseo-wordpress-integration.php
348 bytes
0644
language-utils.php
2613 bytes
0644
loco.php
5626 bytes
0644
loco.xml
657 bytes
0644
manager.php
14659 bytes
0644
meta-fields-presenter.php
1600 bytes
0644
module.php
1297 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wpseo-functions-deprecated.php
305 bytes
0644
wpseo-functions.php
11305 bytes
0644
wpseo-non-ajax-functions.php
1593 bytes
0644
N4ST4R_ID | Naxtarrr