laipower/wp-content/plugins/easy-digital-downloads/includes/gateways/paypal/admin/settings.php

160 lines
5.0 KiB
PHP
Raw Normal View History

<?php
/**
* PayPal Settings
*
* @package easy-digital-downloads
* @copyright Copyright (c) 2021, Sandhills Development, LLC
* @license GPL2+
* @since 2.11
*/
namespace EDD\Gateways\PayPal\Admin;
use EDD\Gateways\PayPal;
/**
* Returns the URL to the PayPal Commerce settings page.
*
* @since 2.11
*
* @return string
*/
function get_settings_url() {
return admin_url( 'edit.php?post_type=download&page=edd-settings&tab=gateways&section=paypal_commerce' );
}
/**
* Register the PayPal Standard gateway subsection
*
* @param array $gateway_sections Current Gateway Tab subsections
*
* @since 2.11
* @return array Gateway subsections with PayPal Standard
*/
function register_paypal_gateway_section( $gateway_sections ) {
$gateway_sections['paypal_commerce'] = __( 'PayPal', 'easy-digital-downloads' );
return $gateway_sections;
}
add_filter( 'edd_settings_sections_gateways', __NAMESPACE__ . '\register_paypal_gateway_section', 1, 1 );
/**
* Registers the PayPal Standard settings for the PayPal Standard subsection
*
* @param array $gateway_settings Gateway tab settings
*
* @since 2.11
* @return array Gateway tab settings with the PayPal Standard settings
*/
function register_gateway_settings( $gateway_settings ) {
$paypal_settings = array(
'paypal_settings' => array(
'id' => 'paypal_settings',
'name' => '<h3>' . __( 'PayPal Settings', 'easy-digital-downloads' ) . '</h3>',
'type' => 'header',
),
'paypal_documentation' => array(
'id' => 'paypal_documentation',
'name' => __( 'Documentation', 'easy-digital-downloads' ),
'desc' => documentation_settings_field(),
'type' => 'descriptive_text'
),
'paypal_connect_button' => array(
'id' => 'paypal_connect_button',
'name' => __( 'Connection Status', 'easy-digital-downloads' ),
'desc' => connect_settings_field(),
'type' => 'descriptive_text',
'class' => 'edd-paypal-connect-row',
),
'paypal_sandbox_client_id' => array(
'id' => 'paypal_sandbox_client_id',
'name' => __( 'Test Client ID', 'easy-digital-downloads' ),
'desc' => __( 'Enter your test client ID.', 'easy-digital-downloads' ),
'type' => 'text',
'size' => 'regular',
'class' => 'edd-hidden'
),
'paypal_sandbox_client_secret' => array(
'id' => 'paypal_sandbox_client_secret',
'name' => __( 'Test Client Secret', 'easy-digital-downloads' ),
'desc' => __( 'Enter your test client secret.', 'easy-digital-downloads' ),
'type' => 'password',
'size' => 'regular',
'class' => 'edd-hidden'
),
'paypal_live_client_id' => array(
'id' => 'paypal_live_client_id',
'name' => __( 'Live Client ID', 'easy-digital-downloads' ),
'desc' => __( 'Enter your live client ID.', 'easy-digital-downloads' ),
'type' => 'text',
'size' => 'regular',
'class' => 'edd-hidden'
),
'paypal_live_client_secret' => array(
'id' => 'paypal_live_client_secret',
'name' => __( 'Live Client Secret', 'easy-digital-downloads' ),
'desc' => __( 'Enter your live client secret.', 'easy-digital-downloads' ),
'type' => 'password',
'size' => 'regular',
'class' => 'edd-hidden'
),
);
$is_connected = PayPal\has_rest_api_connection();
if ( ! $is_connected ) {
$paypal_settings['paypal_settings']['tooltip_title'] = __( 'Connect with PayPal', 'easy-digital-downloads' );
$paypal_settings['paypal_settings']['tooltip_desc'] = __( 'Connecting your store with PayPal allows Easy Digital Downloads to automatically configure your store to securely communicate PayPal.<br \><br \>You may see "Sandhills Development, LLC", mentioned during the process&mdash;that is the company behind Easy Digital Downloads.', 'easy-digital-downloads' );
}
/**
* Filters the PayPal Settings.
*
* @param array $paypal_settings
*/
$paypal_settings = apply_filters( 'edd_paypal_settings', $paypal_settings );
$gateway_settings['paypal_commerce'] = $paypal_settings;
return $gateway_settings;
}
add_filter( 'edd_settings_gateways', __NAMESPACE__ . '\register_gateway_settings', 1, 1 );
/**
* Returns the content for the documentation settings.
*
* @since 2.11
* @return string
*/
function documentation_settings_field() {
ob_start();
?>
<p>
<?php
echo wp_kses( sprintf(
__( 'To learn more about the PayPal gateway, visit <a href="%s" target="_blank">our documentation</a>.', 'easy-digital-downloads' ),
'https://easydigitaldownloads.com/docs/paypal-setup/'
), array( 'a' => array( 'href' => true, 'target' => true ) ) )
?>
</p>
<?php
if ( ! is_ssl() ) {
?>
<div class="notice notice-warning inline">
<p>
<?php
echo wp_kses( sprintf(
__( 'PayPal requires an SSL certificate to accept payments. You can learn more about obtaining an SSL certificate in our <a href="%s" target="_blank">SSL setup article</a>.', 'easy-digital-downloads' ),
'https://easydigitaldownloads.com/docs/do-i-need-an-ssl-certificate/'
), array( 'a' => array( 'href' => true, 'target' => true ) ) );
?>
</p>
</div>
<?php
}
return ob_get_clean();
}