installed plugin Easy Digital Downloads version 3.1.0.3

This commit is contained in:
2022-11-27 15:03:07 +00:00
committed by Gitium
parent 555673545b
commit c5dce2cec6
1200 changed files with 238970 additions and 0 deletions

View File

@ -0,0 +1,66 @@
<?php
/**
* General admin functions for blocks.
*
* @package edd-blocks
* @copyright 2022 Easy Digital Downloads
* @license GPL2+
* @since 2.0
*/
namespace EDD\Blocks\Admin\Functions;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
add_filter( 'display_post_states', __NAMESPACE__ . '\display_post_states', 15, 2 );
/**
* Updates the post states array to show states specific to EDD.
*
* @since 2.0
* @param array $post_states An array of post display states.
* @param WP_Post $post Post object.
* @return array
*/
function display_post_states( $post_states, $post ) {
if ( intval( edd_get_option( 'login_page' ) ) === $post->ID ) {
$post_states['edd_login_page'] = __( 'Login Page', 'easy-digital-downloads' );
}
if ( intval( edd_get_option( 'purchase_history_page' ) ) === $post->ID ) {
$post_states['edd_purchase_history_page'] = __( 'Order History Page', 'easy-digital-downloads' );
}
if ( intval( edd_get_option( 'success_page' ) ) === $post->ID ) {
$post_states['edd_success_page'] = __( 'Receipt Page', 'easy-digital-downloads' );
}
if ( intval( edd_get_option( 'confirmation_page' ) ) === $post->ID ) {
$post_states['edd_confirmation_page'] = __( 'Confirmation Page', 'easy-digital-downloads' );
}
return $post_states;
}
add_filter( 'widget_types_to_hide_from_legacy_widget_block', __NAMESPACE__ . '\remove_legacy_widgets' );
/**
* Removes legacy widgets if they're not being used on the site and have block equivalents.
*
* @since 2.0
* @param array $widget_types
* @return array
*/
function remove_legacy_widgets( $widget_types ) {
$legacy_widgets = array(
'edd_cart_widget',
'edd_categories_tags_widget',
);
foreach ( $legacy_widgets as $widget ) {
if ( ! is_active_widget( false, false, $widget ) ) {
$widget_types[] = $widget;
}
}
return $widget_types;
}

View File

@ -0,0 +1,32 @@
<?php
/**
* General admin functions for blocks.
*
* @package edd-blocks
* @copyright 2022 Easy Digital Downloads
* @license GPL2+
* @since 2.0
*/
namespace EDD\Blocks\Admin\Notices;
defined( 'ABSPATH' ) || exit;
add_action( 'admin_notices', __NAMESPACE__ . '\existing_blocks_plugin' );
/**
* Shows a notice if the original EDD Blocks plugin is active.
*
* @since 2.0
* @return void
*/
function existing_blocks_plugin() {
if ( ! class_exists( 'EDD_Blocks' ) ) {
return;
}
?>
<div id="edd-blocks-core-notice" class="notice notice-warning">
<p><strong><?php esc_html_e( 'EDD Blocks are now a part of Easy Digital Downloads', 'easy-digital-downloads' ); ?></strong></p>
<p><?php esc_html_e( 'If you are using the original Downloads block, you will need to update it to use either the new EDD Products or EDD Downloads Terms block. All other blocks functionality is automatically updated. Once you\'ve replaced your blocks, you can deactivate the EDD Blocks plugin.', 'easy-digital-downloads' ); ?></p>
</div>
<?php
}

View File

@ -0,0 +1,52 @@
<?php
/**
* reCAPTCHA settings.
*
* @package edd-blocks
* @copyright 2022 Easy Digital Downloads
* @license GPL2+
* @since 2.0
*/
namespace EDD\Blocks\Recaptcha\Settings;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
add_filter( 'edd_settings_misc', __NAMESPACE__ . '\register_keys' );
/**
* Register the settings for reCAPTCHA keys.
*
* @since 2.0
* @param array $settings EDD settings array.
* @return array
*/
function register_keys( $settings ) {
$settings['main']['recaptcha'] = array(
'id' => 'recaptcha',
'name' => __( 'reCAPTCHA v3', 'easy-digital-downloads' ),
'desc' => sprintf(
/* translators: 1. opening anchor tag; 2. closing anchor tag */
__( '%1$sRegister with Google%2$s to get reCAPTCHA v3 keys. Setting the keys here will enable reCAPTCHA on your registration block and when a user requests a password reset using the login block.', 'easy-digital-downloads' ),
'<a href="https://www.google.com/recaptcha/admin#list" target="_blank">',
'</a>'
),
'type' => 'descriptive_text',
);
$settings['main']['recaptcha_site_key'] = array(
'id' => 'recaptcha_site_key',
'name' => __( 'reCAPTCHA Site Key', 'easy-digital-downloads' ),
'type' => 'text',
'std' => '',
);
$settings['main']['recaptcha_secret_key'] = array(
'id' => 'recaptcha_secret_key',
'name' => __( 'reCAPTCHA Secret Key', 'easy-digital-downloads' ),
'type' => 'text',
'std' => '',
);
return $settings;
}

View File

@ -0,0 +1,46 @@
<?php
namespace EDD\Blocks\Admin\Scripts;
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\localize' );
/**
* Adds a custom variable to the JS to allow a user in the block editor
* to preview sensitive data.
*
* @since 2.0
* @return void
*/
function localize() {
$user = wp_get_current_user();
wp_localize_script(
'wp-block-editor',
'EDDBlocks',
array(
'current_user' => md5( $user->user_email ),
'all_access' => function_exists( 'edd_all_access' ),
'recurring' => function_exists( 'EDD_Recurring' ),
)
);
}
/**
* Makes sure the payment icons show on the checkout block in the editor.
*
* @since 2.0
*/
add_action( 'admin_print_footer_scripts', '\edd_print_payment_icons_on_checkout' );
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\add_edd_styles_block_editor' );
/**
* If the EDD styles are registered, load them for the block editor.
*
* @since 2.0
* @return void
*/
function add_edd_styles_block_editor() {
if ( wp_style_is( 'edd-styles', 'registered' ) ) {
wp_enqueue_style( 'edd-styles' );
}
}

View File

@ -0,0 +1,171 @@
<?php
/**
* Block settings.
*
* @package edd-blocks
* @copyright 2022 Easy Digital Downloads
* @license GPL2+
* @since 2.0
*/
namespace EDD\Blocks\Admin\Settings;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
add_filter( 'edd_settings_general', __NAMESPACE__ . '\pages' );
/**
* Updates some of the pages settings.
*
* @since 2.0
* @param array $settings
* @return array
*/
function pages( $settings ) {
if ( empty( $settings['pages'] ) ) {
return $settings;
}
$pages = edd_get_pages();
// Login page.
$settings['pages']['login_page'] = array(
'id' => 'login_page',
'name' => __( 'Login Page', 'easy-digital-downloads' ),
'desc' => __( 'This page must include the EDD Login block. Setting this allows the front end form to be used for resetting passwords.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
);
if ( ! empty( $settings['pages']['purchase_page']['desc'] ) ) {
$description = __( 'This is the checkout page where customers will complete their purchases.', 'easy-digital-downloads' );
$description .= '<br />';
$description .= sprintf(
/* translators: 1. opening code tag, do not translate; 2. closing code tag, do not translate. */
__( 'The Checkout block or %1$s[download_checkout]%2$s shortcode must be on this page.', 'easy-digital-downloads' ),
'<code>',
'</code>'
);
$settings['pages']['purchase_page']['desc'] = $description;
}
// Update the login redirect description.
if ( ! empty( $settings['pages']['login_redirect_page']['desc'] ) ) {
$description = sprintf(
/* translators: 1. opening code tag, do not translate; 2. closing code tag, do not translate. */
__( 'If a customer logs in using the EDD Login block or %1$s[edd_login]%2$s shortcode, will be redirected to this page.', 'easy-digital-downloads' ),
'<code>',
'</code>'
);
$description .= '<br />';
$description .= __( 'This can be overridden in the block settings or shortcode parameters.', 'easy-digital-downloads' );
$settings['pages']['login_redirect_page']['desc'] = $description;
}
// Update the purchase history page setting name/description.
if ( ! empty( $settings['pages']['purchase_history_page']['desc'] ) ) {
$description = __( 'This page shows a complete order history for the current user, including download links.', 'easy-digital-downloads' );
$description .= '<br />';
$description .= sprintf(
/* translators: 1. opening code tag, do not translate; 2. closing code tag, do not translate. */
__( 'Either the EDD Order History block or the %1$s[purchase_history]%2$s shortcode must be on this page.', 'easy-digital-downloads' ),
'<code>',
'</code>'
);
$settings['pages']['purchase_history_page']['desc'] = $description;
$settings['pages']['purchase_history_page']['name'] = __( 'Order History Page', 'easy-digital-downloads' );
}
$confirmation_description = __( 'This page must include the EDD Confirmation block.', 'easy-digital-downloads' );
$confirmation_description .= '<br />';
$confirmation_description .= __( 'Use this page separately from your receipt page to ensure proper conversion tracking.', 'easy-digital-downloads' );
$confirmation_page = array(
'confirmation_page' => array(
'id' => 'confirmation_page',
'name' => __( 'Confirmation Page', 'easy-digital-downloads' ),
'desc' => $confirmation_description,
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
),
);
// Insert the confirmation page after checkout and before the receipt.
array_splice( $settings['pages'], 2, 0, $confirmation_page );
if ( ! empty( $settings['pages']['success_page']['desc'] ) ) {
$receipt_description = __( 'This is the page to show a detailed receipt for an order.', 'easy-digital-downloads' );
$receipt_description .= '<br />';
$receipt_description .= sprintf(
/* translators: 1. opening code tag, do not translate; 2. closing code tag, do not translate. */
__( 'Use the EDD Receipt block or the %1$s[edd_receipt]%2$s shortcode to work with the confirmation page.', 'easy-digital-downloads' ),
'<code>',
'</code>'
);
$settings['pages']['success_page']['desc'] = $receipt_description;
$settings['pages']['success_page']['name'] = __( 'Receipt Page', 'easy-digital-downloads' );
}
return $settings;
}
add_filter( 'edd_settings_misc', __NAMESPACE__ . '\button_color' );
/**
* Adds the EDD block button color setting to the miscellaneous section.
*
* @since 2.0
* @param array $settings
* @return array
*/
function button_color( $settings ) {
$color_settings = array(
'button_colors' => array(
'id' => 'blocks_button_colors',
'name' => __( 'Default Button Colors', 'easy-digital-downloads' ),
'type' => 'hook',
),
);
array_splice( $settings['button_text'], 1, 0, $color_settings );
$new_colors = edd_get_option( 'button_colors' );
if ( ! empty( $new_colors['background'] ) ) {
unset( $settings['button_text']['checkout_color'] );
}
return $settings;
}
add_action( 'edd_blocks_button_colors', __NAMESPACE__ . '\button_colors' );
/**
* Renders the settings field for the button colors.
*
* @since 2.0
* @param array $args
* @return void
*/
function button_colors( $args ) {
$colors = edd_get_option( 'button_colors' );
$settings = array(
'background' => __( 'Background', 'easy-digital-downloads' ),
'text' => __( 'Text', 'easy-digital-downloads' ),
);
echo '<div class="edd-settings-colors">';
foreach ( $settings as $setting => $label ) {
$color_value = ! empty( $colors[ $setting ] ) ? $colors[ $setting ] : '';
?>
<div class="edd-settings-color">
<label for="edd_settings[button_colors][<?php echo esc_attr( $setting ); ?>]"><?php echo esc_html( $label ); ?></label>
<input type="text" class="edd-color-picker" id="edd_settings[button_colors][<?php echo esc_attr( $setting ); ?>]" name="edd_settings[button_colors][<?php echo esc_attr( $setting ); ?>]" value="<?php echo esc_attr( $color_value ); ?>" data-default-color="" />
</div>
<?php
}
echo '</div>';
}