File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Save.php.tar
uyarreklam.com.tr/httpdocs/wp-content/plugins/optinmonster/OMAPI/EasyDigitalDownloads/Save.php 0000644 00000007327 15154261004 0031511 0 ustar 00 var/www/vhosts <?php
/**
* EasyDigitalDownloads Save class.
*
* @since 2.8.0
*
* @package OMAPI
* @author Gabriel Oliveira
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* EasyDigitalDownloads Save class.
*
* @since 2.8.0
*/
class OMAPI_EasyDigitalDownloads_Save {
/**
* Holds the class object.
*
* @since 2.8.0
*
* @var OMAPI_EasyDigitalDownloads_Save
*/
public static $instance;
/**
* Holds the base class object.
*
* @since 2.8.0
*
* @var OMAPI
*/
public $base;
/**
* The OMAPI_EasyDigitalDownloads instance.
*
* @since 2.8.0
*
* @var OMAPI_EasyDigitalDownloads
*/
public $edd;
/**
* Constructor
*
* @since 2.8.0
*
* @param OMAPI_EasyDigitalDownloads $edd
*/
public function __construct( OMAPI_EasyDigitalDownloads $edd ) {
$this->edd = $edd;
$this->base = OMAPI::get_instance();
self::$instance = $this;
}
/**
* Handles auto-connecting the EDD plugin with our app. First, get public key. If not present, then generate it, and then connect.
*
* @since 2.8.0
*
* @return WP_Error|array Array with public_key, private_key and token, or WP_Error if something happened.
*/
public function autogenerate() {
if ( ! $this->edd->can_manage_shop() ) {
return new WP_Error(
'omapi-error-user-permission',
esc_html__( 'You don\'t have the required permissions to retrieve or generate API Keys for EDD.', 'optin-monster-api' )
);
}
$user_id = get_current_user_id();
// We first try retrieving the public keys for the current user
$public_key = EDD()->api->get_user_public_key( $user_id );
// If it doesn't have, then let's generate it
if ( empty( $public_key ) ) {
EDD()->api->generate_api_key( $user_id );
// If we can't retrieve for the second time, then that's an error
$public_key = EDD()->api->get_user_public_key( $user_id );
if ( empty( $public_key ) ) {
return new WP_Error(
'omapi-error-generate-edd-keys',
esc_html__( 'An error happened while generating the keys for EDD user. Try again.', 'optin-monster-api' )
);
}
}
$token = EDD()->api->get_token( $user_id );
return $this->connect( $public_key, $token, $user_id );
}
/**
* Handles connecting the EDD plugin with our app.
*
* @since 2.8.0
*
* @param string $public_key The user public key
* @param string $token The user token
* @param string $user_id The user ID
*
* @return WP_Error|array Array with public_key, private_key and token, or WP_Error if something happened.
*/
public function connect( $public_key, $token, $user_id = 0 ) {
$url = esc_url_raw( site_url() );
$payload = array(
'public_key' => $public_key,
'token' => $token,
'url' => $url,
);
$response = $this->edd->connect( $payload );
if ( is_wp_error( $response ) ) {
return $response;
}
// Set up the connected EDD options.
// We only need to save the truncated public_key, so we can output to the user.
$option = $this->base->get_option();
$option['edd'] = array(
'key' => $public_key,
'token' => $token,
'shop' => $response->id,
'user' => $user_id,
);
// Save the option.
$this->base->save->update_option( $option );
return true;
}
/**
* Handles disconnecting EDD when the disconnect button is clicked.
*
* @since 2.8.0
*
* @return WP_Error|bool True if successful, or WP_Error if something happened.
*/
public function disconnect() {
$response = $this->edd->disconnect();
// Output an error or register a successful disconnection.
if ( is_wp_error( $response ) ) {
return $response;
}
$option = $this->base->get_option();
unset( $option['edd'] );
// Save the option.
$this->base->save->update_option( $option );
return true;
}
}
var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/optinmonster/OMAPI/WPForms/Save.php 0000644 00000004215 15154310024 0027041 0 ustar 00 <?php
/**
* WPForms Save class.
*
* @since 2.9.0
*
* @package OMAPI
* @author Eduardo Nakatsuka
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WPForms Save class.
*
* @since 2.9.0
*/
class OMAPI_WPForms_Save {
/**
* Holds save error.
*
* @since 2.9.0
*
* @var mixed
*/
public $error = null;
/**
* Holds the base class object.
*
* @since 2.9.0
*
* @var OMAPI
*/
public $base;
/**
* Primary class constructor.
*
* @since 2.9.0
*/
public function __construct() {
$this->base = OMAPI::get_instance();
}
/**
* Helper method to handle connecting WPForms to OptinMonster.
*
* @since 2.9.0
*
* @return void
*/
public function connect() {
$this->update_connection();
}
/**
* Helper method to handle disconnecting WPForms to OptinMonster.
*
* @since 2.9.0
*
* @return void
*/
public function disconnect() {
$this->update_connection( false );
}
/**
* Handles connecting or disconnecting WPForms to OptinMonster.
*
* @since 2.9.0
*
* @param bool $connect True to connect, false to disconnect.
*
* @return void
*/
public function update_connection( $connect = true ) {
$creds = $this->base->get_api_credentials();
if ( empty( $creds['apikey'] ) && empty( $creds['user'] ) && empty( $creds['key'] ) ) {
return;
}
// Make a connection request.
$action = $connect ? 'connect' : 'disconnect';
$api = new OMAPI_Api( 'wpforms/' . $action, $creds, 'POST', 'v2' );
$response = $api->request( OMAPI_Api::get_url_args() );
if ( is_wp_error( $response ) ) {
$message = $connect
/* translators: %s - Error message found while connecting to OptinMonster. */
? esc_html__( 'WPForms could not be connected to OptinMonster. The OptinMonster API returned with the following response: %s', 'optin-monster-api' )
/* translators: %s - Error message found while disconnecting to OptinMonster. */
: esc_html__( 'WPForms could not be disconnected from OptinMonster. The OptinMonster API returned with the following response: %s', 'optin-monster-api' );
$this->error = sprintf( $message, $response->get_error_message() );
}
}
}
var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/optinmonster/OMAPI/WooCommerce/Save.php0000644 00000012200 15154763304 0027731 0 ustar 00 <?php
/**
* WooCommerce Save class.
*
* @since 2.8.0
*
* @package OMAPI
* @author Gabriel Oliveira and Eduardo Nakatsuka
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WooCommerce Save class.
*
* @since 2.8.0
*/
class OMAPI_WooCommerce_Save {
/**
* Holds the class object.
*
* @since 2.8.0
*
* @var OMAPI_WooCommerce_Save
*/
public static $instance;
/**
* Holds save error.
*
* @since 2.8.0
*
* @var mixed
*/
public $error = null;
/**
* Holds the base class object.
*
* @since 2.8.0
*
* @var OMAPI
*/
public $base;
/**
* The OMAPI_WooCommerce instance.
*
* @since 2.13.0
*
* @var OMAPI_WooCommerce
*/
public $woo;
/**
* Primary class constructor.
*
* @since 2.8.0
*
* @param OMAPI_WooCommerce $woo
*/
public function __construct( OMAPI_WooCommerce $woo ) {
$this->woo = $woo;
$this->base = OMAPI::get_instance();
self::$instance = $this;
}
/**
* Handles auto-generating WooCommerce API keys for use with OM.
*
* @since 1.7.0
* @since 2.8.0 Migrated from OMAPI_Save woocommerce_autogenerate
*
* @return array
*/
public function autogenerate() {
$cookies = array();
foreach ( $_COOKIE as $name => $val ) {
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
$cookies[] = "$name=" . rawurlencode( is_array( $val ) ? serialize( $val ) : $val );
}
$cookies = implode( '; ', $cookies );
$request_args = array(
'sslverify' => apply_filters( 'https_local_ssl_verify', true ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'body' => array(
'action' => 'woocommerce_update_api_key',
'description' => esc_html__( 'OptinMonster API Read-Access (Auto-Generated)', 'optin-monster-api' ),
'permissions' => 'read',
'user' => get_current_user_id(),
'security' => wp_create_nonce( 'update-api-key' ),
),
'timeout' => 60,
'headers' => array(
'cookie' => $cookies,
),
);
$response = wp_remote_post( admin_url( 'admin-ajax.php' ), $request_args );
if ( is_wp_error( $response ) ) {
return $response;
}
$code = wp_remote_retrieve_response_code( $response );
$body = json_decode( wp_remote_retrieve_body( $response ) );
if (
200 === intval( $code )
&& ! empty( $body->success )
&& ! empty( $body->data->consumer_key )
&& ! empty( $body->data->consumer_secret )
) {
return (array) $body->data;
}
return array();
}
/**
* Handles connecting WooCommerce when the connect button is clicked.
*
* @since 1.7.0
* @since 2.8.0 Migrated from OMAPI_Save woocommerce_connect
*
* @param array $data The data passed in via POST request.
*
* @return void
*/
public function connect( $data ) {
$keys = $this->woo->validate_keys( $data );
if ( isset( $keys['error'] ) ) {
$this->error = $keys['error'];
} else {
// Get the version of the REST API we should use. The
// `v3` route wasn't added until WooCommerce 3.5.0.
$api_version = $this->woo->version_compare( '3.5.0' )
? 'v3'
: 'v2';
// Get current site url.
$url = esc_url_raw( site_url() );
// Make a connection request.
$response = $this->woo->connect(
array(
'consumerKey' => $keys['consumer_key'],
'consumerSecret' => $keys['consumer_secret'],
'apiVersion' => $api_version,
'shop' => $url,
'name' => esc_html( get_bloginfo( 'name' ) ),
)
);
// Output an error or register a successful connection.
if ( is_wp_error( $response ) ) {
$this->error = isset( $response->message )
? $response->message
: esc_html__( 'WooCommerce could not be connected to OptinMonster. The OptinMonster API returned with the following response: ', 'optin-monster-api' ) . $response->get_error_message();
} else {
// Get the shop hostname.
$site = wp_parse_url( $url );
$host = isset( $site['host'] ) ? $site['host'] : '';
// Set up the connected WooCommerce options.
$option = $this->base->get_option();
$option['woocommerce'] = array(
'api_version' => $api_version,
'key_id' => $keys['key_id'],
'shop' => $host,
);
// Save the option.
$this->base->save->update_option( $option, $data );
}
}
}
/**
* Handles disconnecting WooCommerce when the disconnect button is clicked.
*
* @since 1.7.0
* @since 2.8.0 Migrated from OMAPI_Save woocommerce_disconnect
*
* @param array $data The data passed in via POST request.
*
* @return void
*/
public function disconnect( $data ) {
$response = $this->woo->disconnect();
// Output an error or register a successful disconnection.
if ( is_wp_error( $response ) ) {
$this->error = isset( $response->message )
? $response->message
: esc_html__( 'WooCommerce could not be disconnected from OptinMonster. The OptinMonster API returned with the following response: ', 'optin-monster-api' ) . $response->get_error_message();
} else {
$option = $this->base->get_option();
unset( $option['woocommerce'] );
// Save the option.
$this->base->save->update_option( $option, $data );
}
}
}