File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Api.php.tar
var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/optinmonster/OMAPI/Api.php 0000644 00000034254 15153770721 0025342 0 ustar 00 <?php
/**
* Api class.
*
* @since 1.0.0
*
* @package OMAPI
* @author Thomas Griffin
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Api class.
*
* @since 1.0.0
*/
class OMAPI_Api {
/**
* Holds the last instantiated instance of this class.
*
* @var OMAPI_Api
*/
protected static $instance = null;
/**
* Base API route.
*
* @since 1.0.0
*
* @var string
*/
public $base = OPTINMONSTER_API_URL;
/**
* Current API route.
*
* @since 1.0.0
*
* @var bool|string
*/
public $route = false;
/**
* Full API URL endpoint.
*
* @since 1.0.0
*
* @var bool|string
*/
public $url = false;
/**
* Current API method.
*
* @since 1.0.0
*
* @var bool|string
*/
public $method = false;
/**
* API Username.
*
* @since 1.0.0
*
* @var bool|string
*/
public $user = false;
/**
* API Key.
*
* @since 1.0.0
*
* @var bool|string
*/
public $key = false;
/**
* New API Key.
*
* @since 1.3.4
*
* @var bool|string
*/
public $apikey = false;
/**
* Plugin slug.
*
* @since 1.0.0
*
* @var bool|string
*/
public $plugin = false;
/**
* The Api Version (v1 or v2) for this request.
*
* @since 1.8.0
*
* @var string
*/
public $version = 'v1';
/**
* Additional data to add to request body
*
* @since 1.0.0
*
* @var array
*/
protected $additional_data = array();
/**
* The HTTP response array.
*
* @since 1.6.5
*
* @var null|array
*/
public $response = null;
/**
* The HTTP response code.
*
* @since 1.6.5
*
* @var int
*/
public $response_code = 0;
/**
* The parsed HTTP response body.
*
* @since 1.6.5
*
* @var mixed
*/
public $response_body = null;
/**
* JSON decode error from decoding the response, if found.
*
* @since 2.6.6
*
* @var mixed
*/
public $decode_error = null;
/**
* Builds the API Object
*
* @since 1.8.0
*
* @param string $version The Api Version (v1 or v2).
* @param string $route The Api Endpoint/route.
* @param string $method The Request method.
* @param array $creds Array of API credentials.
*
* @return self
*/
public static function build( $version, $route, $method = 'POST', $creds = array() ) {
if ( empty( $creds ) ) {
$creds = OMAPI::get_instance()->get_api_credentials();
if ( ! empty( $creds ) ) {
// Check if we have the new API and if so only use it.
$creds = ! empty( $creds['apikey'] )
? array( 'apikey' => $creds['apikey'] )
: array(
'user' => ! empty( $creds['user'] ) ? $creds['user'] : '',
'key' => ! empty( $creds['key'] ) ? $creds['key'] : '',
);
}
}
return new self( $route, $creds, $method, $version );
}
/**
* Primary class constructor.
*
* @since 1.0.0
*
* @param string $route The API route to target.
* @param array $creds Array of API credentials.
* @param string $method The API method.
* @param string $version The version number of our API.
*/
public function __construct( $route, $creds, $method = 'POST', $version = 'v1' ) {
// Set class properties.
$this->route = $route;
$this->version = $version;
$this->method = $method;
$this->user = ! empty( $creds['user'] ) ? $creds['user'] : '';
$this->key = ! empty( $creds['key'] ) ? $creds['key'] : '';
$this->apikey = ! empty( $creds['apikey'] ) ? $creds['apikey'] : '';
$this->plugin = OMAPI::get_instance()->plugin_slug;
self::$instance = $this;
}
/**
* Processes the API request.
*
* @since 1.0.0
*
* @param array $args Request args.
*
* @return mixed $value The response to the API call.
*/
public function request( $args = array() ) {
// Build the body of the request.
$body = array(
'omapi-user' => $this->user,
'omapi-key' => $this->key,
);
$body = array_filter( $body );
// If a plugin API request, add the data.
if ( 'info' === $this->route || 'update' === $this->route ) {
$body['omapi-plugin'] = $this->plugin;
}
// Add in additional data if needed.
if ( ! empty( $this->additional_data ) ) {
$body['omapi-data'] = maybe_serialize( $this->additional_data );
}
$body = wp_parse_args( $args, $body );
$url = in_array( $this->method, array( 'GET', 'DELETE' ), true )
? add_query_arg( array_map( 'urlencode', $body ), $this->get_url() )
: $this->get_url();
$url = esc_url_raw( $url );
$plugins = new OMAPI_Plugins();
// Build the headers of the request.
$headers = array(
'Content-Type' => 'application/x-www-form-urlencoded',
'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
'Pragma' => 'no-cache',
'Expires' => 0,
'Origin' => site_url(),
'OMAPI-Referer' => site_url(),
'OMAPI-Sender' => 'WordPress',
'OMAPI-Site' => esc_attr( get_option( 'blogname' ) ),
'OMAPI-Version' => esc_attr( OMAPI::get_instance()->version ),
'OMAPI-Plugins' => $plugins->get_active_plugins_header_value(),
);
if ( $this->apikey ) {
$headers['X-OptinMonster-ApiKey'] = $this->apikey;
}
// If the onboarding key is set, let's use that as the API key.
if ( ! empty( $args['onboardingApiKey'] ) ) {
$headers['X-OptinMonster-ApiKey'] = $args['onboardingApiKey'];
}
// Setup data to be sent to the API.
$data = array(
'headers' => $headers,
'body' => $body,
'timeout' => 3000,
'sslverify' => false,
'method' => $this->method,
);
// Perform the query and retrieve the response.
$this->handle_response( wp_remote_request( $url, $data ) );
// Bail out early if there are any errors.
if ( is_wp_error( $this->response ) ) {
return $this->response;
}
// If we used the legacy api-creds, we'll get back a new api key.
if (
empty( $this->apikey )
&& ! empty( $this->response['headers']['x-optinmonster-apikey'] )
) {
$this->apikey = sanitize_text_field( $this->response['headers']['x-optinmonster-apikey'] );
}
$error = $this->check_response_error();
// Bail out early if there are any errors.
if ( is_wp_error( $error ) ) {
return $error;
}
// Return the json decoded content.
return $this->response_body;
}
/**
* Handle setting up the object properties from the response.
*
* @since 2.6.6
*
* @param object $response The response object from wp_remote_request.
*
* @return void
*/
public function handle_response( $response ) {
$this->response = $response;
// Get the response code and response body.
$this->response_code = wp_remote_retrieve_response_code( $response );
$this->response_body = json_decode( wp_remote_retrieve_body( $response ) );
$this->decode_error = json_last_error();
}
/**
* Check for an error response, and return an applicable WP_Error instance.
*
* @since 2.6.6
*
* @return boolean|WP_Error False if no errors, and WP_Error object if found.
*/
public function check_response_error() {
$code = (int) $this->response_code;
if ( $code < 400 ) {
return false;
}
// If not successful status header, send back error.
$type = ! empty( $this->response_body->type ) ? $this->response_body->type : 'api-error';
$message = ! empty( $this->response_body->message ) ? stripslashes( $this->response_body->message ) : '';
if ( empty( $message ) ) {
$message = ! empty( $this->response_body->status_message ) ? stripslashes( $this->response_body->status_message ) : '';
}
if ( empty( $message ) ) {
$message = ! empty( $this->response_body->error ) ? stripslashes( $this->response_body->error ) : 'unknown';
}
$message = sprintf(
/* translators: %1$s - API response code, %2$s - returned error from API. */
__( 'The API returned a <strong>%1$s</strong> response with this message: <strong>%2$s</strong>', 'optin-monster-api' ),
$this->response_code,
$message
);
return new WP_Error( $type, $message, $this->response_code );
}
/**
* The gets the URL based on our base, endpoint and version
*
* @since 1.8.0
*
* @return string The API url.
*/
public function get_url() {
return $this->base . '/' . $this->version . '/' . $this->route;
}
/**
* Sets a class property.
*
* @since 1.0.0
*
* @param string $key The property to set.
* @param string $val The value to set for the property.
* @return mixed $value The response to the API call.
*/
public function set( $key, $val ) {
$this->{$key} = $val;
}
/**
* Allow additional data to be passed in the request
*
* @since 1.0.0
*
* @param array $data The data to set.
*
* @return void
*/
public function set_additional_data( array $data ) {
$this->additional_data = array_merge( $this->additional_data, $data );
}
/**
* Clear additional data
*
* @since 1.9.0
*
* return void
*/
public function clear_additional_data() {
$this->additional_data = null;
return $this;
}
/**
* Get the request credentials for this API object.
*
* @since 2.3.0
*
* @return array Array containing API credentials.
*/
public function get_creds() {
return ! empty( $this->apikey )
? array( 'apikey' => $this->apikey )
: array(
'user' => $this->user,
'key' => $this->key,
);
}
/**
* Returns the last instantiated instance of this class.
*
* @since 1.9.10
*
* @return OMAPI_Api A single instance of this class.
*/
public static function instance() {
return self::$instance;
}
/**
* Fetch from the OM /me route, and cache results if no error..
*
* @since 2.6.6
*
* @param bool $refresh Whether to refresh the cache.
* @param array $creds Existing credentials array.
*
* @return array Requested /me data.
*/
public static function fetch_me_cached( $refresh = false, $creds = array() ) {
$api = self::build( 'v2', 'me?includeOnboarding=true', 'GET', $creds );
$creds = array( $api->user, $api->key, $api->apikey );
$creds = array_filter( $creds );
$creds = array_values( $creds );
$cache_key = 'omapp_me_cached' . md5( implode( ':', $creds ) );
$result = get_transient( $cache_key );
if ( empty( $result ) || $refresh ) {
$result = $api->request();
if ( ! is_wp_error( $result ) ) {
set_transient( $cache_key, $result, DAY_IN_SECONDS );
// Force the option to be updated when we gather new data from the API.
self::return_option_from_fetch( $result, array(), $creds, true );
}
}
return $result;
}
/**
* Fetch from the OM /me route to complete the plugin connection after onboarding.
*
* This differs from `OMAPI_Api::fetch_me_cached` in that there is no results
* caching. Fresh results are pulled every time this method is called.
*
* @since 2.16.6
*
* @param array $creds Existing credentials array.
*
* @return array Requested /me data.
*/
public static function fetch_me_onboarding( $creds = array() ) {
$api = self::build( 'v2', 'me?includeOnboarding=true', 'GET', $creds );
$result = $api->request( array( 'onboardingApiKey' => $creds['onboardingApiKey'] ) );
if ( ! is_wp_error( $result ) ) {
// Force the option to be updated when we gather new data from the API.
self::return_option_from_fetch( $result, array(), $creds, true );
OMAPI_ApiKey::init_connection( $api->apikey );
}
return $result;
}
/**
* Fetch from the OM /me route, and store data to our options.
*
* @since 2.0.0
*
* @param array $option Existing options array.
* @param array $creds Existing credentials array.
*
* @return array Updated options array.
*/
public static function fetch_me( $option = array(), $creds = array() ) {
if ( ! empty( $creds['onboardingApiKey'] ) ) {
$option = array();
$result = self::fetch_me_onboarding( $creds );
} else {
$result = self::fetch_me_cached( true, $creds );
}
if ( is_wp_error( $result ) ) {
return $result;
}
return self::return_option_from_fetch( $result, $option, $creds, empty( $option ) );
}
/**
* Return the option after fetching data from the /me route, potentially
* updating it in the database as well.
*
* @since 2.6.13
*
* @param stdClass $result The /me route result.
* @param array $option Possible option to be passed.
* @param array $creds Possible creds to be passed.
* @param bool $should_update Flag to update the option in the database or not.
*
* @return array Updated options array.
*/
public static function return_option_from_fetch( $result, $option = array(), $creds = array(), $should_update = false ) {
$api = self::instance();
if ( $should_update ) {
$option = OMAPI::get_instance()->get_option();
}
// Make sure to set the new api key, if we have it.
if ( empty( $option['api']['apikey'] ) && ! empty( $api->apikey ) ) {
$option['api'] = array( 'apikey' => $api->apikey );
if ( $api->user && $api->key ) {
// Notify user of credentials replacement.
OMAPI::get_instance()->notifications->add_event(
array(
'type' => 'success',
'title' => 'Your API Access Credentials have been updated',
'content' => 'We have automatically replaced your deprecated user/key OptinMonster connection credentials with a new API key.',
'btns' => array(
'main' => array(
'text' => 'Manage API Keys',
'url' => esc_url_raw( OPTINMONSTER_APP_URL . '/account/api/' ),
),
),
)
);
}
}
if ( isset( $result->id ) ) {
/*
* The user id connecting the plugin. It could be the owner or any sub-account.
* This key should not be used to embed codes or other API usage.
* In those cases, the owner's id (accountUserId) would be the one to use.
*/
$option['userId'] = $result->id;
}
$to_store = array( 'accountId', 'accountUserId', 'currentLevel', 'plan', 'revenueAttribution' );
foreach ( $to_store as $key ) {
if ( isset( $result->{$key} ) ) {
$option[ $key ] = is_object( $result->{$key} ) ? (array) $result->{$key} : $result->{$key};
}
}
if ( $should_update ) {
OMAPI::get_instance()->save->update_option( $option, $creds );
}
return $option;
}
/**
* Get the home/rest/admin url args.
*
* @since 2.13.0
*
* @return array
*/
public static function get_url_args() {
return array(
'homeUrl' => esc_url_raw( home_url() ),
'restUrl' => esc_url_raw( get_rest_url() ),
'adminUrl' => esc_url_raw( get_admin_url() ),
);
}
}
www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Api/Api.php 0000644 00000052160 15154622651 0030024 0 ustar 00 var <?php
namespace AIOSEO\Plugin\Common\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Api class for the admin.
*
* @since 4.0.0
*/
class Api {
/**
* The REST API Namespace
*
* @since 4.0.0
*
* @var string
*/
public $namespace = 'aioseo/v1';
/**
* The routes we use in the rest API.
*
* @since 4.0.0
*
* @var array
*/
protected $routes = [
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
'GET' => [
'options' => [ 'callback' => [ 'Settings', 'getOptions' ], 'access' => 'everyone' ],
'ping' => [ 'callback' => [ 'Ping', 'ping' ], 'access' => 'everyone' ],
'post' => [ 'callback' => [ 'PostsTerms', 'getPostData' ], 'access' => 'everyone' ],
'post/(?P<postId>[\d]+)/first-attached-image' => [ 'callback' => [ 'PostsTerms', 'getFirstAttachedImage' ], 'access' => 'aioseo_page_social_settings' ],
'user/(?P<userId>[\d]+)/image' => [ 'callback' => [ 'User', 'getUserImage' ], 'access' => 'aioseo_page_social_settings' ],
'tags' => [ 'callback' => [ 'Tags', 'getTags' ], 'access' => 'everyone' ],
'search-statistics/url/auth' => [ 'callback' => [ 'SearchStatistics', 'getAuthUrl' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings', 'aioseo_setup_wizard' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'search-statistics/url/reauth' => [ 'callback' => [ 'SearchStatistics', 'getReauthUrl' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ],
'writing-assistant/keyword/(?P<postId>[\d]+)' => [ 'callback' => [ 'WritingAssistant', 'getPostKeyword' ], 'access' => 'aioseo_page_writing_assistant_settings' ],
'writing-assistant/user-info' => [ 'callback' => [ 'WritingAssistant', 'getUserInfo' ], 'access' => 'aioseo_page_writing_assistant_settings' ],
'writing-assistant/user-options' => [ 'callback' => [ 'WritingAssistant', 'getUserOptions' ], 'access' => 'aioseo_page_writing_assistant_settings' ],
'writing-assistant/report-history' => [ 'callback' => [ 'WritingAssistant', 'getReportHistory' ], 'access' => 'aioseo_page_writing_assistant_settings' ],
'seo-analysis/homeresults' => [ 'callback' => [ 'Analyze', 'getHomeResults' ], 'access' => 'aioseo_seo_analysis_settings' ],
'seo-analysis/competitors' => [ 'callback' => [ 'Analyze', 'getCompetitorsResults' ], 'access' => 'aioseo_seo_analysis_settings' ]
],
'POST' => [
'ai/auth' => [ 'callback' => [ 'Ai', 'storeAccessToken' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/meta/title' => [ 'callback' => [ 'Ai', 'generateTitles' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/meta/description' => [ 'callback' => [ 'Ai', 'generateDescriptions' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/faqs' => [ 'callback' => [ 'Ai', 'generateFaqs' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/key-points' => [ 'callback' => [ 'Ai', 'generateKeyPoints' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/social-posts' => [ 'callback' => [ 'Ai', 'generateSocialPosts' ], 'access' => 'aioseo_page_ai_content_settings' ],
'ai/deactivate' => [ 'callback' => [ 'Ai', 'deactivate' ], 'access' => 'aioseo_page_ai_content_settings' ],
'htaccess' => [ 'callback' => [ 'Tools', 'saveHtaccess' ], 'access' => 'aioseo_tools_settings' ],
'post' => [
'callback' => [ 'PostsTerms', 'updatePosts' ],
'access' => [
'aioseo_page_analysis',
'aioseo_page_general_settings',
'aioseo_page_advanced_settings',
'aioseo_page_schema_settings',
'aioseo_page_social_settings'
]
],
'post/(?P<postId>[\d]+)/disable-primary-term-education' => [ 'callback' => [ 'PostsTerms', 'disablePrimaryTermEducation' ], 'access' => 'aioseo_page_general_settings' ],
'post/(?P<postId>[\d]+)/disable-link-format-education' => [ 'callback' => [ 'PostsTerms', 'disableLinkFormatEducation' ], 'access' => 'aioseo_page_general_settings' ],
'post/(?P<postId>[\d]+)/update-internal-link-count' => [ 'callback' => [ 'PostsTerms', 'updateInternalLinkCount' ], 'access' => 'aioseo_page_general_settings' ],
'post/(?P<postId>[\d]+)/process-content' => [ 'callback' => [ 'PostsTerms', 'processContent' ], 'access' => 'aioseo_page_general_settings' ],
'posts-list/load-details-column' => [ 'callback' => [ 'PostsTerms', 'loadPostDetailsColumn' ], 'access' => 'aioseo_page_general_settings' ],
'posts-list/update-details-column' => [ 'callback' => [ 'PostsTerms', 'updatePostDetailsColumn' ], 'access' => 'aioseo_page_general_settings' ],
'terms-list/load-details-column' => [ 'callback' => [ 'PostsTerms', 'loadTermDetailsColumn' ], 'access' => 'aioseo_page_general_settings' ],
'terms-list/update-details-column' => [ 'callback' => [ 'PostsTerms', 'updateTermDetailsColumn' ], 'access' => 'aioseo_page_general_settings' ],
'keyphrases' => [ 'callback' => [ 'PostsTerms', 'updatePostKeyphrases' ], 'access' => 'aioseo_page_analysis' ],
'analyze' => [ 'callback' => [ 'Analyze', 'analyzeSite' ], 'access' => 'aioseo_seo_analysis_settings' ],
'analyze-headline' => [ 'callback' => [ 'Analyze', 'analyzeHeadline' ], 'access' => 'everyone' ],
'analyze-headline/delete' => [ 'callback' => [ 'Analyze', 'deleteHeadline' ], 'access' => 'aioseo_seo_analysis_settings' ],
'analyze/delete-site' => [ 'callback' => [ 'Analyze', 'deleteSite' ], 'access' => 'aioseo_seo_analysis_settings' ],
'clear-log' => [ 'callback' => [ 'Tools', 'clearLog' ], 'access' => 'aioseo_tools_settings' ],
'connect' => [ 'callback' => [ 'Connect', 'saveConnectToken' ], 'access' => [ 'aioseo_general_settings', 'aioseo_setup_wizard' ] ],
'connect-pro' => [ 'callback' => [ 'Connect', 'processConnect' ], 'access' => [ 'aioseo_general_settings', 'aioseo_setup_wizard' ] ],
'connect-url' => [ 'callback' => [ 'Connect', 'getConnectUrl' ], 'access' => [ 'aioseo_general_settings', 'aioseo_setup_wizard' ] ],
'backup' => [ 'callback' => [ 'Tools', 'createBackup' ], 'access' => 'aioseo_tools_settings' ],
'backup/restore' => [ 'callback' => [ 'Tools', 'restoreBackup' ], 'access' => 'aioseo_tools_settings' ],
'email-debug-info' => [ 'callback' => [ 'Tools', 'emailDebugInfo' ], 'access' => 'aioseo_tools_settings' ],
'migration/fix-blank-formats' => [ 'callback' => [ 'Migration', 'fixBlankFormats' ], 'access' => 'any' ],
'notification/blog-visibility-reminder' => [ 'callback' => [ 'Notifications', 'blogVisibilityReminder' ], 'access' => 'any' ],
'notification/conflicting-plugins-reminder' => [ 'callback' => [ 'Notifications', 'conflictingPluginsReminder' ], 'access' => 'any' ],
'notification/description-format-reminder' => [ 'callback' => [ 'Notifications', 'descriptionFormatReminder' ], 'access' => 'any' ],
'notification/email-reports-enable' => [ 'callback' => [ 'EmailSummary', 'enableEmailReports' ], 'access' => 'any' ],
'notification/install-addons-reminder' => [ 'callback' => [ 'Notifications', 'installAddonsReminder' ], 'access' => 'any' ],
'notification/install-aioseo-image-seo-reminder' => [ 'callback' => [ 'Notifications', 'installImageSeoReminder' ], 'access' => 'any' ],
'notification/install-aioseo-local-business-reminder' => [ 'callback' => [ 'Notifications', 'installLocalBusinessReminder' ], 'access' => 'any' ],
'notification/install-aioseo-news-sitemap-reminder' => [ 'callback' => [ 'Notifications', 'installNewsSitemapReminder' ], 'access' => 'any' ],
'notification/install-aioseo-video-sitemap-reminder' => [ 'callback' => [ 'Notifications', 'installVideoSitemapReminder' ], 'access' => 'any' ],
'notification/install-mi-reminder' => [ 'callback' => [ 'Notifications', 'installMiReminder' ], 'access' => 'any' ],
'notification/install-om-reminder' => [ 'callback' => [ 'Notifications', 'installOmReminder' ], 'access' => 'any' ],
'notification/v3-migration-custom-field-reminder' => [ 'callback' => [ 'Notifications', 'migrationCustomFieldReminder' ], 'access' => 'any' ],
'notification/v3-migration-schema-number-reminder' => [ 'callback' => [ 'Notifications', 'migrationSchemaNumberReminder' ], 'access' => 'any' ],
'notifications/dismiss' => [ 'callback' => [ 'Notifications', 'dismissNotifications' ], 'access' => 'any' ],
'objects' => [ 'callback' => [ 'PostsTerms', 'searchForObjects' ], 'access' => [ 'aioseo_search_appearance_settings', 'aioseo_sitemap_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'options' => [ 'callback' => [ 'Settings', 'saveChanges' ], 'access' => 'any' ],
'plugins/deactivate' => [ 'callback' => [ 'Plugins', 'deactivatePlugins' ], 'access' => 'aioseo_feature_manager_settings' ],
'plugins/install' => [ 'callback' => [ 'Plugins', 'installPlugins' ], 'access' => [ 'install_plugins', 'aioseo_feature_manager_settings' ] ],
'plugins/upgrade' => [ 'callback' => [ 'Plugins', 'upgradePlugins' ], 'access' => [ 'update_plugins', 'aioseo_feature_manager_settings' ] ],
'reset-settings' => [ 'callback' => [ 'Settings', 'resetSettings' ], 'access' => 'aioseo_tools_settings' ],
'search-statistics/sitemap/delete' => [ 'callback' => [ 'SearchStatistics', 'deleteSitemap' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'search-statistics/sitemap/ignore' => [ 'callback' => [ 'SearchStatistics', 'ignoreSitemap' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'settings/export' => [ 'callback' => [ 'Settings', 'exportSettings' ], 'access' => 'aioseo_tools_settings' ],
'settings/export-content' => [ 'callback' => [ 'Settings', 'exportContent' ], 'access' => 'aioseo_tools_settings' ],
'settings/hide-setup-wizard' => [ 'callback' => [ 'Settings', 'hideSetupWizard' ], 'access' => 'any' ],
'settings/hide-upgrade-bar' => [ 'callback' => [ 'Settings', 'hideUpgradeBar' ], 'access' => 'any' ],
'settings/import' => [ 'callback' => [ 'Settings', 'importSettings' ], 'access' => 'aioseo_tools_settings' ],
'settings/import/(?P<siteId>[\d]+)' => [ 'callback' => [ 'Settings', 'importSettings' ], 'access' => 'aioseo_tools_settings' ],
'settings/import-plugins' => [ 'callback' => [ 'Settings', 'importPlugins' ], 'access' => 'aioseo_tools_settings' ],
'settings/toggle-card' => [ 'callback' => [ 'Settings', 'toggleCard' ], 'access' => 'any' ],
'settings/toggle-radio' => [ 'callback' => [ 'Settings', 'toggleRadio' ], 'access' => 'any' ],
'settings/dismiss-alert' => [ 'callback' => [ 'Settings', 'dismissAlert' ], 'access' => 'any' ],
'settings/items-per-page' => [ 'callback' => [ 'Settings', 'changeItemsPerPage' ], 'access' => 'any' ],
'settings/semrush-country' => [ 'callback' => [ 'Settings', 'changeSemrushCountry' ], 'access' => 'any' ],
'settings/do-task' => [ 'callback' => [ 'Settings', 'doTask' ], 'access' => 'aioseo_tools_settings' ],
'sitemap/deactivate-conflicting-plugins' => [ 'callback' => [ 'Sitemaps', 'deactivateConflictingPlugins' ], 'access' => 'any' ],
'sitemap/delete-static-files' => [ 'callback' => [ 'Sitemaps', 'deleteStaticFiles' ], 'access' => 'aioseo_sitemap_settings' ],
'sitemap/validate-html-sitemap-slug' => [ 'callback' => [ 'Sitemaps', 'validateHtmlSitemapSlug' ], 'access' => 'aioseo_sitemap_settings' ],
'tools/delete-robots-txt' => [ 'callback' => [ 'Tools', 'deleteRobotsTxt' ], 'access' => 'aioseo_tools_settings' ],
'tools/import-robots-txt' => [ 'callback' => [ 'Tools', 'importRobotsTxt' ], 'access' => 'aioseo_tools_settings' ],
'wizard' => [ 'callback' => [ 'Wizard', 'saveWizard' ], 'access' => 'aioseo_setup_wizard' ],
'integration/semrush/authenticate' => [
'callback' => [ 'Semrush', 'semrushAuthenticate', 'AIOSEO\\Plugin\\Common\\Api\\Integrations' ],
'access' => 'aioseo_page_analysis'
],
'integration/semrush/refresh' => [
'callback' => [ 'Semrush', 'semrushRefresh', 'AIOSEO\\Plugin\\Common\\Api\\Integrations' ],
'access' => 'aioseo_page_analysis'
],
'integration/semrush/keyphrases' => [
'callback' => [ 'Semrush', 'semrushGetKeyphrases', 'AIOSEO\\Plugin\\Common\\Api\\Integrations' ],
'access' => 'aioseo_page_analysis'
],
'integration/wpcode/snippets' => [
'callback' => [ 'WpCode', 'getSnippets', 'AIOSEO\\Plugin\\Common\\Api\\Integrations' ],
'access' => 'aioseo_tools_settings'
],
'crawl-cleanup' => [
'callback' => [ 'CrawlCleanup', 'fetchLogs', 'AIOSEO\\Plugin\\Common\\QueryArgs' ],
'access' => 'aioseo_search_appearance_settings'
],
'crawl-cleanup/block' => [
'callback' => [ 'CrawlCleanup', 'blockArg', 'AIOSEO\\Plugin\\Common\\QueryArgs' ],
'access' => 'aioseo_search_appearance_settings'
],
'crawl-cleanup/delete-blocked' => [
'callback' => [ 'CrawlCleanup', 'deleteBlocked', 'AIOSEO\\Plugin\\Common\\QueryArgs' ],
'access' => 'aioseo_search_appearance_settings'
],
'crawl-cleanup/delete-unblocked' => [
'callback' => [ 'CrawlCleanup', 'deleteLog', 'AIOSEO\\Plugin\\Common\\QueryArgs' ],
'access' => 'aioseo_search_appearance_settings'
],
'email-summary/send' => [
'callback' => [ 'EmailSummary', 'send' ],
'access' => 'aioseo_page_advanced_settings'
],
'writing-assistant/process' => [
'callback' => [ 'WritingAssistant', 'processKeyword' ],
'access' => 'aioseo_page_writing_assistant_settings'
],
'writing-assistant/content-analysis' => [
'callback' => [ 'WritingAssistant', 'getContentAnalysis' ],
'access' => 'aioseo_page_writing_assistant_settings'
],
'writing-assistant/disconnect' => [
'callback' => [ 'WritingAssistant', 'disconnect' ],
'access' => 'aioseo_page_writing_assistant_settings'
],
'writing-assistant/user-options' => [
'callback' => [ 'WritingAssistant', 'saveUserOptions' ],
'access' => 'aioseo_page_writing_assistant_settings'
],
'writing-assistant/set-report-progress' => [
'callback' => [ 'WritingAssistant', 'setReportProgress' ],
'access' => 'aioseo_page_writing_assistant_settings'
]
],
'DELETE' => [
'backup' => [ 'callback' => [ 'Tools', 'deleteBackup' ], 'access' => 'aioseo_tools_settings' ],
'search-statistics/auth' => [ 'callback' => [ 'SearchStatistics', 'deleteAuth' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ]
]
// phpcs:enable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
];
/**
* Class constructor.
*
* @since 4.0.0
*/
public function __construct() {
add_filter( 'rest_allowed_cors_headers', [ $this, 'allowedHeaders' ] );
add_action( 'rest_api_init', [ $this, 'registerRoutes' ] );
}
/**
* Get all the routes to register.
*
* @since 4.0.0
*
* @return array An array of routes.
*/
protected function getRoutes() {
return $this->routes;
}
/**
* Registers the API routes.
*
* @since 4.0.0
*
* @return void
*/
public function registerRoutes() {
$class = new \ReflectionClass( get_called_class() );
foreach ( $this->getRoutes() as $method => $data ) {
foreach ( $data as $route => $options ) {
register_rest_route(
$this->namespace,
$route,
[
'methods' => $method,
'permission_callback' => empty( $options['permissions'] ) ? [ $this, 'validRequest' ] : [ $this, $options['permissions'] ],
'callback' => is_array( $options['callback'] )
? [
(
! empty( $options['callback'][2] )
? $options['callback'][2] . '\\' . $options['callback'][0]
: (
class_exists( $class->getNamespaceName() . '\\' . $options['callback'][0] )
? $class->getNamespaceName() . '\\' . $options['callback'][0]
: __NAMESPACE__ . '\\' . $options['callback'][0]
)
),
$options['callback'][1]
]
: [ $this, $options['callback'] ]
]
);
}
}
}
/**
* Sets headers that are allowed for our API routes.
*
* @since 4.0.0
*
* @return void
*/
public function allowHeaders() {
// TODO: Remove this entire function after a while. It's only here to ensure compatibility with people that are still using Image SEO 1.0.3 or lower.
header( 'Access-Control-Allow-Headers: X-WP-Nonce' );
}
/**
* Sets headers that are allowed for our API routes.
*
* @since 4.1.1
*
* @param array $allowHeaders The allowed request headers.
* @return array $allowHeaders The allowed request headers.
*/
public function allowedHeaders( $allowHeaders ) {
if ( ! array_search( 'X-WP-Nonce', $allowHeaders, true ) ) {
$allowHeaders[] = 'X-WP-Nonce';
}
return $allowHeaders;
}
/**
* Determine if logged in or has the proper permissions.
*
* @since 4.0.0
*
* @param \WP_REST_Request $request The REST Request.
* @return bool True if validated, false if not.
*/
public function validRequest( $request ) {
return is_user_logged_in() && $this->validateAccess( $request );
}
/**
* Validates access from the routes array.
*
* @since 4.0.0
*
* @param \WP_REST_Request $request The REST Request.
* @return bool True if validated, false if not.
*/
public function validateAccess( $request ) {
$routeData = $this->getRouteData( $request );
if ( empty( $routeData ) || empty( $routeData['access'] ) ) {
return false;
}
// Admins always have access.
if ( aioseo()->access->isAdmin() ) {
return true;
}
switch ( $routeData['access'] ) {
case 'everyone':
// Any user is able to access the route.
return true;
default:
return aioseo()->access->hasCapability( $routeData['access'] );
}
}
/**
* Returns the data for the route that is being accessed.
*
* @since 4.1.6
*
* @param \WP_REST_Request $request The REST Request.
* @return array The route data.
*/
protected function getRouteData( $request ) {
// NOTE: Since WordPress uses case-insensitive patterns to match routes,
// we are forcing everything to lowercase to ensure we have the proper route.
// This prevents users with lower privileges from accessing routes they shouldn't.
$route = aioseo()->helpers->toLowercase( $request->get_route() );
$route = untrailingslashit( str_replace( '/' . $this->namespace . '/', '', $route ) );
$routeData = isset( $this->getRoutes()[ $request->get_method() ][ $route ] ) ? $this->getRoutes()[ $request->get_method() ][ $route ] : [];
// No direct route name, let's try the regexes.
if ( empty( $routeData ) ) {
foreach ( $this->getRoutes()[ $request->get_method() ] as $routeRegex => $routeInfo ) {
$routeRegex = str_replace( '@', '\@', $routeRegex );
if ( preg_match( "@{$routeRegex}@", (string) $route ) ) {
$routeData = $routeInfo;
break;
}
}
}
return $routeData;
}
} www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Lite/Api/Api.php 0000644 00000001351 15155055456 0027471 0 ustar 00 var <?php
namespace AIOSEO\Plugin\Lite\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Api as CommonApi;
/**
* Api class for the admin.
*
* @since 4.0.0
*/
class Api extends CommonApi\Api {
/**
* The routes we use in the rest API.
*
* @since 4.0.0
*
* @var array
*/
protected $liteRoutes = [
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
// phpcs:enable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
];
/**
* Get all the routes to register.
*
* @since 4.0.0
*
* @return array An array of routes.
*/
protected function getRoutes() {
return array_merge_recursive( $this->routes, $this->liteRoutes );
}
} uyarreklam.com.tr/httpdocs/wp-content/plugins/broken-link-checker-seo/app/Traits/Helpers/Api.php 0000644 00000006136 15155077302 0031701 0 ustar 00 var/www/vhosts <?php
namespace AIOSEO\BrokenLinkChecker\Traits\Helpers;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains API specific helper methods.
*
* @since 1.0.0
*/
trait Api {
/**
* Request the remote URL via wp_remote_post and return a json decoded response.
*
* @since 1.0.0
*
* @param array $body The content to retrieve from the remote URL.
* @param array $headers The headers to send to the remote URL.
* @return string|null JSON decoded response on success, false on failure.
*/
public function sendRequest( $url, $body = [], $headers = [] ) {
$body = wp_json_encode( $body );
// Build the headers of the request.
$headers = wp_parse_args(
$headers,
[
'Content-Type' => 'application/json'
]
);
// Setup variable for wp_remote_post.
$requestArgs = [
'headers' => $headers,
'body' => $body,
'timeout' => 20
];
// Perform the query and retrieve the response.
$response = $this->wpRemotePost( $url, $requestArgs );
$responseBody = wp_remote_retrieve_body( $response );
// Bail out early if there are any errors.
if ( ! $responseBody ) {
return null;
}
// Return the json decoded content.
return json_decode( $responseBody );
}
/**
* Sends a request using wp_remote_post.
*
* @since 1.0.0
*
* @param string $url The URL to send the request to.
* @param array $args The args to use in the request.
* @return array|\WP_Error The response as an array or WP_Error on failure.
*/
public function wpRemotePost( $url, $args = [] ) {
return wp_remote_post( $url, array_replace_recursive( $this->getWpApiRequestDefaults(), $args ) );
}
/**
* Sends a request using wp_remote_get.
*
* @since 1.0.0
*
* @param string $url The URL to send the request to.
* @param array $args The args to use in the request.
* @return array|\WP_Error The response as an array or WP_Error on failure.
*/
public function wpRemoteGet( $url, $args = [] ) {
return wp_remote_get( $url, array_replace_recursive( $this->getWpApiRequestDefaults(), $args ) );
}
/**
* Default arguments for wp_remote_get and wp_remote_post.
*
* @since 1.0.0
*
* @return array An array of default arguments for the request.
*/
private function getWpApiRequestDefaults() {
return [
'timeout' => 10,
'headers' => aioseoBrokenLinkChecker()->helpers->getApiHeaders(),
'user-agent' => aioseoBrokenLinkChecker()->helpers->getApiUserAgent()
];
}
/**
* Returns the headers for internal API requests.
*
* @since 1.0.0
*
* @return array An array of headers.
*/
private function getApiHeaders() {
return [
'X-AIOSEO-BLC-License' => aioseoBrokenLinkChecker()->internalOptions->internal->license->licenseKey
];
}
/**
* Returns the User Agent for internal API requests.
*
* @since 1.0.0
*
* @return string The User Agent.
*/
private function getApiUserAgent() {
return 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; AIOSEO/BrokenLinkChecker/' . AIOSEO_BROKEN_LINK_CHECKER_VERSION;
}
} httpdocs/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Assets/Api.php 0000644 00000026272 15155255114 0033572 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php
namespace Automattic\WooCommerce\Blocks\Assets;
use Automattic\WooCommerce\Blocks\Domain\Package;
use Exception;
/**
* The Api class provides an interface to various asset registration helpers.
*
* Contains asset api methods
*
* @since 2.5.0
*/
class Api {
/**
* Stores inline scripts already enqueued.
*
* @var array
*/
private $inline_scripts = [];
/**
* Determines if caching is enabled for script data.
*
* @var boolean
*/
private $disable_cache = false;
/**
* Stores loaded script data for the current request
*
* @var array|null
*/
private $script_data = null;
/**
* Stores the hash for the script data, made up of the site url, plugin version and package path.
*
* @var string
*/
private $script_data_hash;
/**
* Stores the transient key used to cache the script data. This will change if the site is accessed via HTTPS or HTTP.
*
* @var string
*/
private $script_data_transient_key = 'woocommerce_blocks_asset_api_script_data';
/**
* Reference to the Package instance
*
* @var Package
*/
private $package;
/**
* Constructor for class
*
* @param Package $package An instance of Package.
*/
public function __construct( Package $package ) {
$this->package = $package;
$this->disable_cache = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || ! $this->package->feature()->is_production_environment();
// If the site is accessed via HTTPS, change the transient key. This is to prevent the script URLs being cached
// with the first scheme they are accessed on after cache expiry.
if ( is_ssl() ) {
$this->script_data_transient_key .= '_ssl';
}
if ( ! $this->disable_cache ) {
$this->script_data_hash = $this->get_script_data_hash();
}
add_action( 'shutdown', array( $this, 'update_script_data_cache' ), 20 );
}
/**
* Get the file modified time as a cache buster if we're in dev mode.
*
* @param string $file Local path to the file (relative to the plugin
* directory).
* @return string The cache buster value to use for the given file.
*/
protected function get_file_version( $file ) {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $this->package->get_path() . $file ) ) {
return filemtime( $this->package->get_path( trim( $file, '/' ) ) );
}
return $this->package->get_version();
}
/**
* Retrieve the url to an asset for this plugin.
*
* @param string $relative_path An optional relative path appended to the
* returned url.
*
* @return string
*/
protected function get_asset_url( $relative_path = '' ) {
return $this->package->get_url( $relative_path );
}
/**
* Get the path to a block's metadata
*
* @param string $block_name The block to get metadata for.
* @param string $path Optional. The path to the metadata file inside the 'build' folder.
*
* @return string|boolean False if metadata file is not found for the block.
*/
public function get_block_metadata_path( $block_name, $path = '' ) {
$path_to_metadata_from_plugin_root = $this->package->get_path( 'build/' . $path . $block_name . '/block.json' );
if ( ! file_exists( $path_to_metadata_from_plugin_root ) ) {
return false;
}
return $path_to_metadata_from_plugin_root;
}
/**
* Generates a hash containing the site url, plugin version and package path.
*
* Moving the plugin, changing the version, or changing the site url will result in a new hash and the cache will be invalidated.
*
* @return string The generated hash.
*/
private function get_script_data_hash() {
return md5( get_option( 'siteurl', '' ) . $this->package->get_version() . $this->package->get_path() );
}
/**
* Initialize and load cached script data from the transient cache.
*
* @return array
*/
private function get_cached_script_data() {
if ( $this->disable_cache ) {
return [];
}
$transient_value = json_decode( (string) get_transient( $this->script_data_transient_key ), true );
if (
json_last_error() !== JSON_ERROR_NONE ||
empty( $transient_value ) ||
empty( $transient_value['script_data'] ) ||
empty( $transient_value['version'] ) ||
$transient_value['version'] !== $this->package->get_version() ||
empty( $transient_value['hash'] ) ||
$transient_value['hash'] !== $this->script_data_hash
) {
return [];
}
return (array) ( $transient_value['script_data'] ?? [] );
}
/**
* Store all cached script data in the transient cache.
*/
public function update_script_data_cache() {
if ( is_null( $this->script_data ) || $this->disable_cache ) {
return;
}
set_transient(
$this->script_data_transient_key,
wp_json_encode(
array(
'script_data' => $this->script_data,
'version' => $this->package->get_version(),
'hash' => $this->script_data_hash,
)
),
DAY_IN_SECONDS * 30
);
}
/**
* Get src, version and dependencies given a script relative src.
*
* @param string $relative_src Relative src to the script.
* @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array.
*
* @return array src, version and dependencies of the script.
*/
public function get_script_data( $relative_src, $dependencies = [] ) {
if ( ! $relative_src ) {
return array(
'src' => '',
'version' => '1',
'dependencies' => $dependencies,
);
}
if ( is_null( $this->script_data ) ) {
$this->script_data = $this->get_cached_script_data();
}
if ( empty( $this->script_data[ $relative_src ] ) ) {
$asset_path = $this->package->get_path( str_replace( '.js', '.asset.php', $relative_src ) );
// The following require is safe because we are checking if the file exists and it is not a user input.
// nosemgrep audit.php.lang.security.file.inclusion-arg.
$asset = file_exists( $asset_path ) ? require $asset_path : [];
$this->script_data[ $relative_src ] = array(
'src' => $this->get_asset_url( $relative_src ),
'version' => ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src ),
'dependencies' => ! empty( $asset['dependencies'] ) ? $asset['dependencies'] : [],
);
}
// Return asset details as well as the requested dependencies array.
return [
'src' => $this->script_data[ $relative_src ]['src'],
'version' => $this->script_data[ $relative_src ]['version'],
'dependencies' => array_merge( $this->script_data[ $relative_src ]['dependencies'], $dependencies ),
];
}
/**
* Registers a script according to `wp_register_script`, adding the correct prefix, and additionally loading translations.
*
* When creating script assets, the following rules should be followed:
* 1. All asset handles should have a `wc-` prefix.
* 2. If the asset handle is for a Block (in editor context) use the `-block` suffix.
* 3. If the asset handle is for a Block (in frontend context) use the `-block-frontend` suffix.
* 4. If the asset is for any other script being consumed or enqueued by the blocks plugin, use the `wc-blocks-` prefix.
*
* @since 2.5.0
* @throws Exception If the registered script has a dependency on itself.
*
* @param string $handle Unique name of the script.
* @param string $relative_src Relative url for the script to the path from plugin root.
* @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array.
* @param bool $has_i18n Optional. Whether to add a script translation call to this file. Default: true.
*/
public function register_script( $handle, $relative_src, $dependencies = [], $has_i18n = true ) {
$script_data = $this->get_script_data( $relative_src, $dependencies );
if ( in_array( $handle, $script_data['dependencies'], true ) ) {
if ( $this->package->feature()->is_development_environment() ) {
$dependencies = array_diff( $script_data['dependencies'], [ $handle ] );
add_action(
'admin_notices',
function() use ( $handle ) {
echo '<div class="error"><p>';
/* translators: %s file handle name. */
printf( esc_html__( 'Script with handle %s had a dependency on itself which has been removed. This is an indicator that your JS code has a circular dependency that can cause bugs.', 'woocommerce' ), esc_html( $handle ) );
echo '</p></div>';
}
);
} else {
throw new Exception( sprintf( 'Script with handle %s had a dependency on itself. This is an indicator that your JS code has a circular dependency that can cause bugs.', $handle ) );
}
}
/**
* Filters the list of script dependencies.
*
* @since 3.0.0
*
* @param array $dependencies The list of script dependencies.
* @param string $handle The script's handle.
* @return array
*/
$script_dependencies = apply_filters( 'woocommerce_blocks_register_script_dependencies', $script_data['dependencies'], $handle );
wp_register_script( $handle, $script_data['src'], $script_dependencies, $script_data['version'], true );
if ( $has_i18n && function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( $handle, 'woocommerce', $this->package->get_path( 'languages' ) );
}
}
/**
* Registers a style according to `wp_register_style`.
*
* @since 2.5.0
* @since 2.6.0 Change src to be relative source.
*
* @param string $handle Name of the stylesheet. Should be unique.
* @param string $relative_src Relative source of the stylesheet to the plugin path.
* @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array.
* @param string $media Optional. The media for which this stylesheet has been defined. Default 'all'. Accepts media types like
* 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
* @param boolean $rtl Optional. Whether or not to register RTL styles.
*/
public function register_style( $handle, $relative_src, $deps = [], $media = 'all', $rtl = false ) {
$filename = str_replace( plugins_url( '/', __DIR__ ), '', $relative_src );
$src = $this->get_asset_url( $relative_src );
$ver = $this->get_file_version( $filename );
wp_register_style( $handle, $src, $deps, $ver, $media );
if ( $rtl ) {
wp_style_add_data( $handle, 'rtl', 'replace' );
}
}
/**
* Returns the appropriate asset path for current builds.
*
* @param string $filename Filename for asset path (without extension).
* @param string $type File type (.css or .js).
* @return string The generated path.
*/
public function get_block_asset_build_path( $filename, $type = 'js' ) {
return "build/$filename.$type";
}
/**
* Adds an inline script, once.
*
* @param string $handle Script handle.
* @param string $script Script contents.
*/
public function add_inline_script( $handle, $script ) {
if ( ! empty( $this->inline_scripts[ $handle ] ) && in_array( $script, $this->inline_scripts[ $handle ], true ) ) {
return;
}
wp_add_inline_script( $handle, $script );
if ( isset( $this->inline_scripts[ $handle ] ) ) {
$this->inline_scripts[ $handle ][] = $script;
} else {
$this->inline_scripts[ $handle ] = array( $script );
}
}
}
httpdocs/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Payments/Api.php 0000644 00000016232 15155417563 0034133 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php
namespace Automattic\WooCommerce\Blocks\Payments;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Payments\Integrations\BankTransfer;
use Automattic\WooCommerce\Blocks\Payments\Integrations\CashOnDelivery;
use Automattic\WooCommerce\Blocks\Payments\Integrations\Cheque;
use Automattic\WooCommerce\Blocks\Payments\Integrations\PayPal;
/**
* The Api class provides an interface to payment method registration.
*
* @since 2.6.0
*/
class Api {
/**
* Reference to the PaymentMethodRegistry instance.
*
* @var PaymentMethodRegistry
*/
private $payment_method_registry;
/**
* Reference to the AssetDataRegistry instance.
*
* @var AssetDataRegistry
*/
private $asset_registry;
/**
* Constructor
*
* @param PaymentMethodRegistry $payment_method_registry An instance of Payment Method Registry.
* @param AssetDataRegistry $asset_registry Used for registering data to pass along to the request.
*/
public function __construct( PaymentMethodRegistry $payment_method_registry, AssetDataRegistry $asset_registry ) {
$this->payment_method_registry = $payment_method_registry;
$this->asset_registry = $asset_registry;
}
/**
* Initialize class features.
*/
public function init() {
add_action( 'init', array( $this->payment_method_registry, 'initialize' ), 5 );
add_filter( 'woocommerce_blocks_register_script_dependencies', array( $this, 'add_payment_method_script_dependencies' ), 10, 2 );
add_action( 'woocommerce_blocks_checkout_enqueue_data', array( $this, 'add_payment_method_script_data' ) );
add_action( 'woocommerce_blocks_cart_enqueue_data', array( $this, 'add_payment_method_script_data' ) );
add_action( 'woocommerce_blocks_payment_method_type_registration', array( $this, 'register_payment_method_integrations' ) );
add_action( 'wp_print_scripts', array( $this, 'verify_payment_methods_dependencies' ), 1 );
}
/**
* Add payment method script handles as script dependencies.
*
* @param array $dependencies Array of script dependencies.
* @param string $handle Script handle.
* @return array
*/
public function add_payment_method_script_dependencies( $dependencies, $handle ) {
if ( ! in_array( $handle, [ 'wc-checkout-block', 'wc-checkout-block-frontend', 'wc-cart-block', 'wc-cart-block-frontend' ], true ) ) {
return $dependencies;
}
return array_merge( $dependencies, $this->payment_method_registry->get_all_active_payment_method_script_dependencies() );
}
/**
* Returns true if the payment gateway is enabled.
*
* @param object $gateway Payment gateway.
* @return boolean
*/
private function is_payment_gateway_enabled( $gateway ) {
return filter_var( $gateway->enabled, FILTER_VALIDATE_BOOLEAN );
}
/**
* Add payment method data to Asset Registry.
*/
public function add_payment_method_script_data() {
// Enqueue the order of enabled gateways.
if ( ! $this->asset_registry->exists( 'paymentMethodSortOrder' ) ) {
// We use payment_gateways() here to get the sort order of all enabled gateways. Some may be
// programmatically disabled later on, but we still need to know where the enabled ones are in the list.
$payment_gateways = WC()->payment_gateways->payment_gateways();
$enabled_gateways = array_filter( $payment_gateways, array( $this, 'is_payment_gateway_enabled' ) );
$this->asset_registry->add( 'paymentMethodSortOrder', array_keys( $enabled_gateways ) );
}
// Enqueue all registered gateway data (settings/config etc).
$script_data = $this->payment_method_registry->get_all_registered_script_data();
foreach ( $script_data as $asset_data_key => $asset_data_value ) {
if ( ! $this->asset_registry->exists( $asset_data_key ) ) {
$this->asset_registry->add( $asset_data_key, $asset_data_value );
}
}
}
/**
* Register payment method integrations bundled with blocks.
*
* @param PaymentMethodRegistry $payment_method_registry Payment method registry instance.
*/
public function register_payment_method_integrations( PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register(
Package::container()->get( Cheque::class )
);
$payment_method_registry->register(
Package::container()->get( PayPal::class )
);
$payment_method_registry->register(
Package::container()->get( BankTransfer::class )
);
$payment_method_registry->register(
Package::container()->get( CashOnDelivery::class )
);
}
/**
* Verify all dependencies of registered payment methods have been registered.
* If not, remove that payment method script from the list of dependencies
* of Cart and Checkout block scripts so it doesn't break the blocks and show
* an error in the admin.
*/
public function verify_payment_methods_dependencies() {
// Check that the wc-blocks script is registered before continuing. Some extensions may cause this function to run
// before the payment method scripts' dependencies are registered.
if ( ! wp_script_is( 'wc-blocks', 'registered' ) ) {
return;
}
$wp_scripts = wp_scripts();
$payment_method_scripts = $this->payment_method_registry->get_all_active_payment_method_script_dependencies();
foreach ( $payment_method_scripts as $payment_method_script ) {
if (
! array_key_exists( $payment_method_script, $wp_scripts->registered ) ||
! property_exists( $wp_scripts->registered[ $payment_method_script ], 'deps' )
) {
continue;
}
$deps = $wp_scripts->registered[ $payment_method_script ]->deps;
foreach ( $deps as $dep ) {
if ( ! wp_script_is( $dep, 'registered' ) ) {
$error_handle = $dep . '-dependency-error';
$error_message = sprintf(
'Payment gateway with handle \'%1$s\' has been deactivated in Cart and Checkout blocks because its dependency \'%2$s\' is not registered. Read the docs about registering assets for payment methods: https://github.com/woocommerce/woocommerce-blocks/blob/060f63c04f0f34f645200b5d4da9212125c49177/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets',
esc_html( $payment_method_script ),
esc_html( $dep )
);
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log( $error_message );
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter,WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_register_script( $error_handle, '' );
wp_enqueue_script( $error_handle );
wp_add_inline_script(
$error_handle,
sprintf( 'console.error( "%s" );', $error_message )
);
$cart_checkout_scripts = [ 'wc-cart-block', 'wc-cart-block-frontend', 'wc-checkout-block', 'wc-checkout-block-frontend' ];
foreach ( $cart_checkout_scripts as $script_handle ) {
if (
! array_key_exists( $script_handle, $wp_scripts->registered ) ||
! property_exists( $wp_scripts->registered[ $script_handle ], 'deps' )
) {
continue;
}
// Remove payment method script from dependencies.
$wp_scripts->registered[ $script_handle ]->deps = array_diff(
$wp_scripts->registered[ $script_handle ]->deps,
[ $payment_method_script ]
);
}
}
}
}
}
}
uyarreklam.com.tr/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/Helpers/Api.php 0000644 00000004752 15155440233 0032162 0 ustar 00 var/www/vhosts <?php
namespace AIOSEO\Plugin\Common\Traits\Helpers;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains Action Scheduler specific helper methods.
*
* @since 4.2.4
*/
trait Api {
/**
* Request the remote URL via wp_remote_post and return a json decoded response.
*
* @since 4.2.4
*
* @param array $body The content to retrieve from the remote URL.
* @param array $headers The headers to send to the remote URL.
* @return object|null JSON decoded response on success, false on failure.
*/
public function sendRequest( $url, $body = [], $headers = [] ) {
$body = wp_json_encode( $body );
// Build the headers of the request.
$headers = wp_parse_args(
$headers,
[
'Content-Type' => 'application/json'
]
);
// Setup variable for wp_remote_post.
$requestArgs = [
'headers' => $headers,
'body' => $body,
'timeout' => 20
];
// Perform the query and retrieve the response.
$response = $this->wpRemotePost( $url, $requestArgs );
$responseBody = wp_remote_retrieve_body( $response );
// Bail out early if there are any errors.
if ( ! $responseBody ) {
return null;
}
// Return the json decoded content.
return json_decode( $responseBody );
}
/**
* Default arguments for wp_remote_get and wp_remote_post.
*
* @since 4.2.4
*
* @return array An array of default arguments for the request.
*/
private function getWpApiRequestDefaults() {
return [
'timeout' => 10,
'headers' => aioseo()->helpers->getApiHeaders(),
'user-agent' => aioseo()->helpers->getApiUserAgent()
];
}
/**
* Sends a request using wp_remote_post.
*
* @since 4.2.4
*
* @param string $url The URL to send the request to.
* @param array $args The args to use in the request.
* @return array|\WP_Error The response as an array or WP_Error on failure.
*/
public function wpRemotePost( $url, $args = [] ) {
return wp_remote_post( $url, array_replace_recursive( $this->getWpApiRequestDefaults(), $args ) );
}
/**
* Sends a request using wp_remote_get.
*
* @since 4.2.4
*
* @param string $url The URL to send the request to.
* @param array $args The args to use in the request.
* @return array|\WP_Error The response as an array or WP_Error on failure.
*/
public function wpRemoteGet( $url, $args = [] ) {
return wp_remote_get( $url, array_replace_recursive( $this->getWpApiRequestDefaults(), $args ) );
}
} httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/SearchStatistics/Api/Api.php 0000644 00000004550 15155647703 0033312 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php
namespace AIOSEO\Plugin\Common\SearchStatistics\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* API class.
*
* @since 4.3.0
* @version 4.6.2 Moved from Pro to Common.
*/
class Api {
/**
* Holds the instance of the Auth class.
*
* @since 4.3.0
*
* @var Auth
*/
public $auth;
/**
* Holds the instance of the TrustToken class.
*
* @since 4.3.0
*
* @var TrustToken
*/
public $trustToken;
/**
* Holds the instance of the Listener class.
*
* @since 4.3.0
*
* @var Listener
*/
public $listener;
/**
* The base URL for the Search Statistics microservice.
*
* @since 4.3.0
*
* @var string
*/
private $url = 'google.aioseo.com';
/**
* The API version for the Search Statistics microservice.
*
* @since 4.3.0
*
* @var string
*/
private $version = 'v1';
/**
* Class constructor.
*
* @since 4.3.0
*/
public function __construct() {
$this->auth = new Auth();
$this->trustToken = new TrustToken();
$this->listener = new Listener();
}
/**
* Returns the site identifier key according to the WordPress keys.
*
* @since 4.3.0
*
* @return string The site identifier key.
*/
public function getSiteIdentifier() {
$authKey = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
$secureAuthKey = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
$loggedInKey = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : '';
$siteIdentifier = $authKey . $secureAuthKey . $loggedInKey;
$siteIdentifier = preg_replace( '/[^a-zA-Z0-9]/', '', (string) $siteIdentifier );
$siteIdentifier = sanitize_text_field( $siteIdentifier );
$siteIdentifier = trim( $siteIdentifier );
$siteIdentifier = ( strlen( $siteIdentifier ) > 30 ) ? substr( $siteIdentifier, 0, 30 ) : $siteIdentifier;
return $siteIdentifier;
}
/**
* Returns the URL of the remote endpoint.
*
* @since 4.3.0
*
* @return string The URL.
*/
public function getApiUrl() {
if ( defined( 'AIOSEO_SEARCH_STATISTICS_API_URL' ) ) {
return AIOSEO_SEARCH_STATISTICS_API_URL;
}
return $this->url;
}
/**
* Returns the version of the remote endpoint.
*
* @since 4.3.0
*
* @return string The version.
*/
public function getApiVersion() {
if ( defined( 'AIOSEO_SEARCH_STATISTICS_API_VERSION' ) ) {
return AIOSEO_SEARCH_STATISTICS_API_VERSION;
}
return $this->version;
}
}