$sections ) { // Loop through sections foreach ( $sections as $section => $settings ) { // Check for backwards compatibility $section_tabs = edd_get_settings_tab_sections( $tab ); if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { $section = 'main'; $settings = $sections; } // Current page $page = "edd_settings_{$tab}_{$section}"; // Add the settings section add_settings_section( $page, __return_null(), '__return_false', $page ); foreach ( $settings as $option ) { // For backwards compatibility if ( empty( $option['id'] ) ) { continue; } // Parse args $args = wp_parse_args( $option, array( 'section' => $section, 'id' => null, 'desc' => '', 'name' => '', 'size' => null, 'options' => '', 'std' => '', 'min' => null, 'max' => null, 'step' => null, 'chosen' => null, 'multiple' => null, 'placeholder' => null, 'allow_blank' => true, 'readonly' => false, 'faux' => false, 'tooltip_title' => false, 'tooltip_desc' => false, 'field_class' => '', 'label_for' => false ) ); // Callback fallback $func = 'edd_' . $args['type'] . '_callback'; $callback = ! function_exists( $func ) ? 'edd_missing_callback' : $func; // Link the label to the form field if ( empty( $args['label_for'] ) ) { $args['label_for'] = 'edd_settings[' . $args['id'] . ']'; } // Add the settings field add_settings_field( 'edd_settings[' . $args['id'] . ']', $args['name'], $callback, $page, $page, $args ); } } } // Register our setting in the options table register_setting( 'edd_settings', 'edd_settings', 'edd_settings_sanitize' ); } add_action( 'admin_init', 'edd_register_settings' ); /** * Retrieve the array of plugin settings * * @since 1.8 * @since 3.0 Use a static variable internally to store registered settings * @return array */ function edd_get_registered_settings() { static $edd_settings = null; /** * 'Whitelisted' EDD settings, filters are provided for each settings * section to allow extensions and other plugins to add their own settings */ // Only build settings if not already build if ( null === $edd_settings ) { $options = array( 'none' => __( 'Do Nothing', 'easy-digital-downloads' ), 'anonymize' => __( 'Anonymize', 'easy-digital-downloads' ), 'delete' => __( 'Delete', 'easy-digital-downloads' ) ); $debug_log_url = edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => 'debug_log' ) ); $debug_log_link = '' . __( 'View the Log', 'easy-digital-downloads' ) . ''; $payment_statuses = edd_get_payment_statuses(); $pages = edd_get_pages(); $gateways = edd_get_payment_gateways(); $admin_email = get_bloginfo( 'admin_email' ); $site_name = get_bloginfo( 'name' ); $email_summary_recipient = edd_get_option( 'email_summary_recipient', 'admin' ); $email_summary_trigger_url = wp_nonce_url( edd_get_admin_url( array( 'page' => 'edd-settings', 'tab' => 'emails', 'section' => 'email_summaries', 'edd_action' => 'trigger_email_summary', ) ), 'edd_trigger_email_summary' ); $email_summary_schedule = wp_next_scheduled( EDD_Email_Summary_Cron::CRON_EVENT_NAME ); $email_summary_schedule_text = ' ' . esc_html( __( 'The summary email is not yet scheduled. Save the settings to manually schedule it.', 'easy-digital-downloads' ) ) . ''; if ( $email_summary_schedule ) { $email_summary_schedule_date = \Carbon\Carbon::createFromTimestamp( $email_summary_schedule )->setTimezone( edd_get_timezone_id() ); /* Translators: formatted date */ $email_summary_schedule_text = sprintf( __( 'The next summary email is scheduled to send on %s.', 'easy-digital-downloads' ), $email_summary_schedule_date->format( get_option( 'date_format' ) ) ); } $site_hash = substr( md5( $site_name ), 0, 10 ); $edd_settings = array( // General Settings 'general' => apply_filters( 'edd_settings_general', array( 'main' => array( 'business_settings' => array( 'id' => 'business_settings', 'name' => '
[download_checkout]
shortcode must be on this page.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
),
'success_page' => array(
'id' => 'success_page',
'name' => __( 'Success Page', 'easy-digital-downloads' ),
'desc' => __( 'This is the page buyers are sent to after completing their purchases.[edd_receipt]
shortcode should be on this page.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
),
'failure_page' => array(
'id' => 'failure_page',
'name' => __( 'Failed Transaction Page', 'easy-digital-downloads' ),
'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
),
'purchase_history_page' => array(
'id' => 'purchase_history_page',
'name' => __( 'Purchase History Page', 'easy-digital-downloads' ),
'desc' => __( 'This page shows a complete purchase history for the current user, including download links.[purchase_history]
shortcode should be on this page.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
),
'login_redirect_page' => array(
'id' => 'login_redirect_page',
'name' => __( 'Login Redirect Page', 'easy-digital-downloads' ),
'desc' => sprintf(
__( 'If a customer logs in using the [edd_login]
shortcode, this is the page they will be redirected to.[edd_login redirect="%s"]
.', 'easy-digital-downloads' ),
trailingslashit( home_url() )
),
'type' => 'select',
'options' => $pages,
'chosen' => true,
'placeholder' => __( 'Select a page', 'easy-digital-downloads' ),
)
),
'currency' => array(
'currency_settings' => array(
'id' => 'currency_settings',
'name' => ',
or .
.', 'easy-digital-downloads' ),
'type' => 'text',
'size' => 'small',
'field_class' => 'code',
'std' => ',',
'placeholder' => ','
),
'decimal_separator' => array(
'id' => 'decimal_separator',
'name' => __( 'Decimal Separator', 'easy-digital-downloads' ),
'desc' => __( 'The symbol to separate decimal points. Usually ,
or .
.', 'easy-digital-downloads' ),
'type' => 'text',
'size' => 'small',
'field_class' => 'code',
'std' => '.',
'placeholder' => '.'
),
),
'api' => array(
'api_settings' => array(
'id' => 'api_settings',
'name' => 'manage_shop_settings
are always allowed to generate keys.', 'easy-digital-downloads' ),
'type' => 'checkbox_description',
),
'api_help' => array(
'id' => 'api_help',
'desc' => sprintf(
__( 'Visit the REST API documentation for further information.', 'easy-digital-downloads' ),
edd_link_helper(
'https://easydigitaldownloads.com/categories/docs/api-reference/',
array(
'utm_medium' => 'settings',
'utm_content' => 'api-documentation',
)
)
),
'type' => 'descriptive_text',
),
),
) ),
// Payment Gateways Settings
'gateways' => apply_filters( 'edd_settings_gateways', array(
'main' => array(
'test_mode' => array(
'id' => 'test_mode',
'name' => __( 'Test Mode', 'easy-digital-downloads' ),
'check' => __( 'Enabled', 'easy-digital-downloads' ),
'desc' => __( 'While test mode is enabled, no live transactions are processed.@example.com
), or TLDs (.gov
).', 'easy-digital-downloads' ),
'type' => 'textarea',
'placeholder' => __( '@example.com', 'easy-digital-downloads' )
),
),
'refunds' => array(
'refunds_settings' => array(
'id' => 'refunds_settings',
'name' => '30
days. Set to 0
for infinity. It can be changed at a per-product level.', 'easy-digital-downloads' ),
'std' => 30,
'type' => 'number',
'size' => 'small',
'max' => 3650, // Ten year maximum, because why explicitly support longer
'min' => 0,
'step' => 1,
),
),
'accounting' => array(
'enable_skus' => array(
'id' => 'enable_skus',
'name' => __( 'Enable SKU Entry', 'easy-digital-downloads' ),
'check' => __( 'Check this box to allow entry of product SKUs.', 'easy-digital-downloads' ),
'desc' => __( 'SKUs will be shown on purchase receipt and exported purchase histories.', 'easy-digital-downloads' ),
'type' => 'checkbox_description',
),
'enable_sequential' => array(
'id' => 'enable_sequential',
'name' => __( 'Sequential Order Numbers', 'easy-digital-downloads' ),
'check' => __( 'Check this box to enable sequential order numbers.', 'easy-digital-downloads' ),
'desc' => __( 'Does not impact previous orders. Future orders will be sequential.', 'easy-digital-downloads' ),
'type' => 'checkbox_description',
),
'sequential_start' => array(
'id' => 'sequential_start',
'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ),
'desc' => __( 'The number at which the sequence should begin.', 'easy-digital-downloads' ),
'type' => 'number',
'size' => 'small',
'std' => '1',
),
'sequential_prefix' => array(
'id' => 'sequential_prefix',
'name' => __( 'Sequential Number Prefix', 'easy-digital-downloads' ),
'desc' => __( 'A prefix to prepend to all sequential order numbers.', 'easy-digital-downloads' ),
'type' => 'text',
),
'sequential_postfix' => array(
'id' => 'sequential_postfix',
'name' => __( 'Sequential Number Postfix', 'easy-digital-downloads' ),
'desc' => __( 'A postfix to append to all sequential order numbers.', 'easy-digital-downloads' ),
'type' => 'text',
)
),
) ),
// Emails Settings
'emails' => apply_filters( 'edd_settings_emails', array(
'main' => array(
'email_header' => array(
'id' => 'email_header',
'name' => '' . __( 'Email Configuration', 'easy-digital-downloads' ) . '',
'type' => 'header',
),
'email_template' => array(
'id' => 'email_template',
'name' => __( 'Template', 'easy-digital-downloads' ),
'desc' => __( 'Choose a template. Click "Save Changes" then "Preview Purchase Receipt" to see the new template.', 'easy-digital-downloads' ),
'type' => 'select',
'options' => edd_get_email_templates(),
),
'email_logo' => array(
'id' => 'email_logo',
'name' => __( 'Logo', 'easy-digital-downloads' ),
'desc' => __( 'Upload or choose a logo to be displayed at the top of sales receipt emails. Displayed on HTML emails only.', 'easy-digital-downloads' ),
'type' => 'upload',
),
'from_name' => array(
'id' => 'from_name',
'name' => __( 'From Name', 'easy-digital-downloads' ),
'desc' => __( 'This should be your site or shop name. Defaults to Site Title if empty.', 'easy-digital-downloads' ),
'type' => 'text',
'std' => $site_name,
'placeholder' => $site_name
),
'from_email' => array(
'id' => 'from_email',
'name' => __( 'From Email', 'easy-digital-downloads' ),
'desc' => __( 'This will act as the "from" and "reply-to" addresses.', 'easy-digital-downloads' ),
'type' => 'email',
'std' => $admin_email,
'placeholder' => $admin_email
),
'email_settings' => array(
'id' => 'email_settings',
'name' => '',
'desc' => '',
'type' => 'hook',
),
),
'purchase_receipts' => array(
'purchase_receipt_email_settings' => array(
'id' => 'purchase_receipt_email_settings',
'name' => '',
'desc' => '',
'type' => 'hook',
),
'purchase_subject' => array(
'id' => 'purchase_subject',
'name' => __( 'Purchase Email Subject', 'easy-digital-downloads' ),
'desc' => __( 'Enter the subject line for the purchase receipt email.', 'easy-digital-downloads' ),
'type' => 'text',
'std' => __( 'Purchase Receipt', 'easy-digital-downloads' ),
),
'purchase_heading' => array(
'id' => 'purchase_heading',
'name' => __( 'Purchase Email Heading', 'easy-digital-downloads' ),
'desc' => __( 'Enter the heading for the purchase receipt email.', 'easy-digital-downloads' ),
'type' => 'text',
'std' => __( 'Purchase Receipt', 'easy-digital-downloads' ),
),
'purchase_receipt' => array(
'id' => 'purchase_receipt',
'name' => __( 'Purchase Receipt', 'easy-digital-downloads' ),
'desc' => __( 'Text to email customers after completing a purchase. Personalize with HTML and {tag}
markers.', 'easy-digital-downloads' ) . '{tag}
markers.', 'easy-digital-downloads' ) . 'If you need VAT support, there are options listed on the documentation page.
', 'easy-digital-downloads' ), 'https://easydigitaldownloads.com/docs/tax-settings/' ), 'type' => 'descriptive_text', ), 'prices_include_tax' => array( 'id' => 'prices_include_tax', 'name' => __( 'Prices Include Tax', 'easy-digital-downloads' ), 'desc' => __( 'This option affects how you enter prices.', 'easy-digital-downloads' ), 'type' => 'radio', 'std' => 'no', 'options' => array( 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'easy-digital-downloads' ), 'no' => __( 'No, I will enter prices exclusive of tax', 'easy-digital-downloads' ), ), 'tooltip_title' => __( 'Prices Inclusive of Tax', 'easy-digital-downloads' ), 'tooltip_desc' => __( 'When using prices inclusive of tax, you will be entering your prices as the total amount you want a customer to pay for the download, including tax. Easy Digital Downloads will calculate the proper amount to tax the customer for the defined total price.', 'easy-digital-downloads' ), ), 'display_tax_rate' => array( 'id' => 'display_tax_rate', 'name' => __( 'Show Tax Rate on Prices', 'easy-digital-downloads' ), 'check' => __( 'Show', 'easy-digital-downloads' ), 'desc' => __( 'Some countries require a notice that product prices include tax.', 'easy-digital-downloads' ), 'type' => 'checkbox_description', ), 'checkout_include_tax' => array( 'id' => 'checkout_include_tax', 'name' => __( 'Show in Checkout', 'easy-digital-downloads' ), 'desc' => __( 'Should prices on the checkout page be shown with or without tax?', 'easy-digital-downloads' ), 'type' => 'select', 'std' => 'no', 'options' => array( 'yes' => __( 'Including tax', 'easy-digital-downloads' ), 'no' => __( 'Excluding tax', 'easy-digital-downloads' ), ), 'tooltip_title' => __( 'Taxes Displayed for Products on Checkout', 'easy-digital-downloads' ), 'tooltip_desc' => __( 'This option will determine whether the product price displays with or without tax on checkout.', 'easy-digital-downloads' ), ), ), 'rates' => array( 'tax_rates' => array( 'id' => 'tax_rates', 'name' => '' . __( 'Regional Rates', 'easy-digital-downloads' ) . '', 'desc' => __( 'Configure rates for each region you wish to collect sales tax in.', 'easy-digital-downloads' ), 'type' => 'tax_rates', ), ) ) ), // Extension Settings 'extensions' => apply_filters( 'edd_settings_extensions', array() ), 'licenses' => apply_filters( 'edd_settings_licenses', array() ), // Misc Settings 'misc' => apply_filters( 'edd_settings_misc', array( 'main' => array( 'debug_mode' => array( 'id' => 'debug_mode', 'name' => __( 'Debug Mode', 'easy-digital-downloads' ), 'check' => __( 'Enabled', 'easy-digital-downloads' ), 'desc' => __( 'Check this box to enable Debug Mode.', 'easy-digital-downloads' ) . ' ' . $debug_log_link, 'type' => 'checkbox_description', ), 'disable_styles' => array( 'id' => 'disable_styles', 'name' => __( 'Disable Styles', 'easy-digital-downloads' ), 'check' => __( 'Check this box to disable all included styling.', 'easy-digital-downloads' ), 'desc' => __( 'This includes buttons, checkout fields, product pages, and all other elements', 'easy-digital-downloads' ), 'type' => 'checkbox_description', 'tooltip_title' => __( 'Disabling Styles', 'easy-digital-downloads' ), 'tooltip_desc' => __( "If your theme has a complete custom CSS file for Easy Digital Downloads, you may wish to disable our default styles. This is not recommended unless you're sure your theme has a complete custom CSS.", 'easy-digital-downloads' ), ), 'item_quantities' => array( 'id' => 'item_quantities', 'name' => __( 'Cart Item Quantities', 'easy-digital-downloads' ), 'desc' => sprintf( __( 'Allow quantities to be adjusted when adding %s to the cart, and while viewing the checkout cart.', 'easy-digital-downloads' ), edd_get_label_plural( true ) ), 'type' => 'checkbox', ), 'uninstall_on_delete' => array( 'id' => 'uninstall_on_delete', 'name' => __( 'Remove Data on Uninstall', 'easy-digital-downloads' ), 'desc' => __( 'Check this box if you would like EDD to completely remove all of its data when the plugin is deleted.', 'easy-digital-downloads' ), 'type' => 'checkbox', ), ), 'button_text' => array( 'button_style' => array( 'id' => 'button_style', 'name' => __( 'Default Button Style', 'easy-digital-downloads' ), 'desc' => __( 'Choose the style you want to use for the buttons.', 'easy-digital-downloads' ), 'type' => 'select', 'options' => edd_get_button_styles(), ), 'checkout_color' => array( 'id' => 'checkout_color', 'name' => __( 'Default Button Color', 'easy-digital-downloads' ), 'desc' => __( 'Choose the color you want to use for the buttons.', 'easy-digital-downloads' ), 'type' => 'color_select', 'options' => edd_get_button_colors(), 'std' => 'blue' ), 'checkout_label' => array( 'id' => 'checkout_label', 'name' => __( 'Complete Purchase Text', 'easy-digital-downloads' ), 'desc' => __( 'The button label for completing a purchase.', 'easy-digital-downloads' ), 'type' => 'text', 'std' => __( 'Purchase', 'easy-digital-downloads' ), ), 'free_checkout_label' => array( 'id' => 'free_checkout_label', 'name' => __( 'Complete Free Purchase Text', 'easy-digital-downloads' ), 'desc' => __( 'The button label for completing a free purchase.', 'easy-digital-downloads' ), 'type' => 'text', 'std' => __( 'Free Download', 'easy-digital-downloads' ), ), 'add_to_cart_text' => array( 'id' => 'add_to_cart_text', 'name' => __( 'Add to Cart Text', 'easy-digital-downloads' ), 'desc' => __( 'Text shown on the Add to Cart Buttons.', 'easy-digital-downloads' ), 'type' => 'text', 'std' => __( 'Add to Cart', 'easy-digital-downloads' ), ), 'checkout_button_text' => array( 'id' => 'checkout_button_text', 'name' => __( 'Checkout Button Text', 'easy-digital-downloads' ), 'desc' => __( 'Text shown on the Add to Cart Button when the product is already in the cart.', 'easy-digital-downloads' ), 'type' => 'text', 'std' => _x( 'Checkout', 'text shown on the Add to Cart Button when the product is already in the cart', 'easy-digital-downloads' ), ), 'buy_now_text' => array( 'id' => 'buy_now_text', 'name' => __( 'Buy Now Text', 'easy-digital-downloads' ), 'desc' => __( 'Text shown on the Buy Now Buttons.', 'easy-digital-downloads' ), 'type' => 'text', 'std' => __( 'Buy Now', 'easy-digital-downloads' ), ), ), 'file_downloads' => array( 'require_login_to_download' => array( 'id' => 'require_login_to_download', 'name' => __( 'Require Login', 'easy-digital-downloads' ), 'desc' => __( 'Require a user to login before file download links deliver the file.', 'easy-digital-downloads' ), 'tooltip_title' => __( 'Require Login', 'easy-digital-downloads' ), 'tooltip_desc' => __( 'Download links expire after the link expiration setting, but you can restrict file downloads to only logged in users. Note: This may affect links from purchase receipts and customers if you have guest checkout enabled.', 'easy-digital-downloads' ), 'type' => 'checkbox', ), 'download_method' => array( 'id' => 'download_method', 'name' => __( 'Download Method', 'easy-digital-downloads' ), 'desc' => sprintf( __( 'Select the file download method. Note, not all methods work on all servers.', 'easy-digital-downloads' ), edd_get_label_singular() ), 'type' => 'select', 'tooltip_title' => __( 'Download Method', 'easy-digital-downloads' ), 'tooltip_desc' => __( 'Due to its consistency in multiple platforms and better file protection, \'forced\' is the default method. Because Easy Digital Downloads uses PHP to process the file with the \'forced\' method, larger files can cause problems with delivery, resulting in hitting the \'max execution time\' of the server. If users are getting 404 or 403 errors when trying to access their purchased files when using the \'forced\' method, changing to the \'redirect\' method can help resolve this.', 'easy-digital-downloads' ), 'options' => array( 'direct' => __( 'Forced', 'easy-digital-downloads' ), 'redirect' => __( 'Redirect', 'easy-digital-downloads' ), ), ), 'symlink_file_downloads' => array( 'id' => 'symlink_file_downloads', 'name' => __( 'Symbolically Link Files', 'easy-digital-downloads' ), 'desc' => __( 'Check this if you are delivering really large files or having problems with file downloads completing.', 'easy-digital-downloads' ), 'type' => 'checkbox', ), 'file_download_limit' => array( 'id' => 'file_download_limit', 'name' => __( 'File Download Limit', 'easy-digital-downloads' ), 'desc' => sprintf( __( 'The maximum number of times files can be downloaded for purchases. Can be overwritten for each %s.', 'easy-digital-downloads' ), edd_get_label_singular() ), 'type' => 'number', 'size' => 'small', 'tooltip_title' => __( 'File Download Limits', 'easy-digital-downloads' ), 'tooltip_desc' => sprintf( __( 'Set the global default for the number of times a customer can download items they purchase. Using a value of 0 is unlimited. This can be defined on a %s-specific level as well. Download limits can also be reset for an individual purchase.', 'easy-digital-downloads' ), edd_get_label_singular( true ) ), ), 'download_link_expiration' => array( 'id' => 'download_link_expiration', 'name' => __( 'Download Link Expiration', 'easy-digital-downloads' ), 'desc' => __( 'How long should download links be valid for? Default is 24 hours from the time they are generated. Enter a time in hours.', 'easy-digital-downloads' ), 'tooltip_title' => __( 'Download Link Expiration', 'easy-digital-downloads' ), 'tooltip_desc' => __( 'When a customer receives a link to their downloads via email, in their receipt, or in their purchase history, the link will only be valid for the timeframe (in hours) defined in this setting. Sending a new purchase receipt or visiting the account page will re-generate a valid link for the customer.', 'easy-digital-downloads' ), 'type' => 'number', 'size' => 'small', 'std' => '24', 'min' => '0', ), 'disable_redownload' => array( 'id' => 'disable_redownload', 'name' => __( 'Disable Redownload', 'easy-digital-downloads' ), 'desc' => __( 'Check this if you do not want to allow users to redownload items from their purchase history.', 'easy-digital-downloads' ), 'type' => 'checkbox', ), ), ) ), // Privacy Settings 'privacy' => apply_filters( 'edd_settings_privacy', array( 'main' => array( '' => array( 'id' => 'privacy_settings', 'name' => '' . sprintf( __( 'Need help creating a Privacy Policy? We recommend %sTermageddon%s.', 'easy-digital-downloads' ), '', '' ) . '
', 'type' => 'checkbox', ), ), 'site_terms' => array( '' => array( 'id' => 'terms_settings', 'name' => '' . sprintf( __( 'Need help creating a Terms of Agreement? We recommend using %sTermageddon%s.', 'easy-digital-downloads' ), '', '' ) . '
', 'type' => 'checkbox_description', ), 'agree_label' => array( 'id' => 'agree_label', 'name' => __( 'Agreement Label', 'easy-digital-downloads' ), 'desc' => __( 'Label for the "Agree to Terms" checkbox.', 'easy-digital-downloads' ), 'placeholder' => __( 'I agree to the terms', 'easy-digital-downloads' ), 'type' => 'text', 'size' => 'regular', ), 'agree_text' => array( 'id' => 'agree_text', 'name' => __( 'Agreement Text', 'easy-digital-downloads' ), 'type' => 'rich_editor', ), ), 'export_erase' => array( array( 'id' => 'payment_privacy_status_action_header', 'name' => '' . __( 'This setting is no longer used in this version of Easy Digital Downloads. We have migrated any fallback tax rates for you to verify below. Click "Save Changes" to dismiss this notice.', 'easy-digital-downloads' ) . '
' . wp_kses_post( $args['desc'] ) . '
'; } echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Multicheck Callback * * Renders multiple checkboxes. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_multicheck_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); $class = edd_sanitize_html_class( $args['field_class'] ); $html = ''; if ( ! empty( $args['options'] ) ) { $html .= ''; foreach ( $args['options'] as $key => $option ): if ( isset( $edd_option[ $key ] ) ) { $enabled = $option; } else { $enabled = null; } $html .= '' . $args['desc'] . '
'; } echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Payment method icons callback * * @since 2.1 * * @param array $args Arguments passed by the setting * * @return void */ function edd_payment_icons_callback( $args = array() ) { // Start an output buffer ob_start(); $edd_option = edd_get_option( $args['id'] ); $class = edd_sanitize_html_class( $args['field_class'] ); ?>' . apply_filters( 'edd_after_setting_output', wp_kses_post( $args['desc'] ), $args ) . '
'; echo $html; } /** * Gateways Callback * * Renders gateways fields. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_gateways_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); $html = ''; $html .= ''; if ( ! empty( $args['options'] ) ) { $class = edd_sanitize_html_class( $args['field_class'] ); $html .= '' . esc_html__( 'These gateways will be offered at checkout.', 'easy-digital-downloads' ) . '
' . sprintf( __( 'More Payment Gateways are available.', 'easy-digital-downloads' ), $url ) . '
' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Text Callback * * Renders text fields. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_text_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } elseif ( ! empty( $args['allow_blank'] ) && empty( $edd_option ) ) { $value = ''; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } if ( isset( $args['faux'] ) && true === $args['faux'] ) { $args['readonly'] = true; $value = isset( $args['std'] ) ? $args['std'] : ''; $name = ''; } else { $name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"'; } $class = edd_sanitize_html_class( $args['field_class'] ); $placeholder = ! empty( $args['placeholder'] ) ? ' placeholder="' . esc_attr( $args['placeholder'] ) . '"' : ''; $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : ''; $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Email Callback * * Renders email fields. * * @since 2.8 * * @param array $args Arguments passed by the setting * * @return void */ function edd_email_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } elseif ( ! empty( $args['allow_blank'] ) && empty( $edd_option ) ) { $value = ''; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } if ( isset( $args['faux'] ) && true === $args['faux'] ) { $args['readonly'] = true; $value = isset( $args['std'] ) ? $args['std'] : ''; $name = ''; } else { $name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"'; } $class = edd_sanitize_html_class( $args['field_class'] ); $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : ''; $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Number Callback * * Renders number fields. * * @since 1.9 * * @param array $args Arguments passed by the setting * * @return void */ function edd_number_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( is_numeric( $edd_option ) ) { $value = $edd_option; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } if ( isset( $args['faux'] ) && true === $args['faux'] ) { $args['readonly'] = true; $value = isset( $args['std'] ) ? $args['std'] : ''; $name = ''; } else { $name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"'; } $class = edd_sanitize_html_class( $args['field_class'] ); $max = isset( $args['max'] ) ? $args['max'] : 999999; $min = isset( $args['min'] ) ? $args['min'] : 0; $step = isset( $args['step'] ) ? $args['step'] : 1; $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Textarea Callback * * Renders textarea fields. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_textarea_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { if ( is_array( $edd_option ) ) { $value = implode( "\n", maybe_unserialize( $edd_option ) ); } else { $value = $edd_option; } } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $class = edd_sanitize_html_class( $args['field_class'] ); $placeholder = ! empty( $args['placeholder'] ) ? ' placeholder="' . esc_attr( $args['placeholder'] ) . '"' : ''; $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Password Callback * * Renders password fields. * * @since 1.3 * * @param array $args Arguments passed by the setting * * @return void */ function edd_password_callback( $args ) { $edd_options = edd_get_option( $args['id'] ); if ( $edd_options ) { $value = $edd_options; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $class = edd_sanitize_html_class( $args['field_class'] ); $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Missing Callback * * If a function is missing for settings callbacks alert the user. * * @since 1.3.1 * * @param array $args Arguments passed by the setting * * @return void */ function edd_missing_callback( $args ) { printf( __( 'The callback function used for the %s setting is missing.', 'easy-digital-downloads' ), '' . $args['id'] . '' ); } /** * Select Callback * * Renders select fields. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_select_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } else { // Properly set default fallback if the Select Field allows Multiple values if ( empty( $args['multiple'] ) ) { $value = isset( $args['std'] ) ? $args['std'] : ''; } else { $value = ! empty( $args['std'] ) ? $args['std'] : array(); } } $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; $class = edd_sanitize_html_class( $args['field_class'] ); if ( isset( $args['chosen'] ) ) { $class .= ' edd-select-chosen'; if ( is_rtl() ) { $class .= ' chosen-rtl'; } } // Nonce $nonce = isset( $args['data']['nonce'] ) ? ' data-nonce="' . sanitize_text_field( $args['data']['nonce'] ) . '"' : ''; // If the Select Field allows Multiple values, save as an Array $name_attr = 'edd_settings[' . esc_attr( $args['id'] ) . ']'; $name_attr = ( $args['multiple'] ) ? $name_attr . '[]' : $name_attr; $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Color select Callback * * Renders color select fields. * * @since 1.8 * * @param array $args Arguments passed by the setting * * @return void */ function edd_color_select_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $class = edd_sanitize_html_class( $args['field_class'] ); if ( $args['chosen'] ) { $class .= 'edd-select-chosen'; if ( is_rtl() ) { $class .= ' chosen-rtl'; } } $html = ''; foreach ( $args['options'] as $option => $color ) { $selected = selected( $option, $value, false ); $html .= ''; } $html .= ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Rich Editor Callback * * Renders rich editor fields. * * @since 1.0 * * @param array $args Arguments passed by the setting */ function edd_rich_editor_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } else { if ( ! empty( $args['allow_blank'] ) && empty( $edd_option ) ) { $value = ''; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } } $rows = isset( $args['size'] ) ? $args['size'] : 20; $class = edd_sanitize_html_class( $args['field_class'] ); ob_start(); wp_editor( stripslashes( $value ), 'edd_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'edd_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'editor_class' => $class, ) ); if ( ! empty( $args['desc'] ) ) { echo '' . wp_kses_post( $args['desc'] ) . '
'; } $html = ob_get_clean(); echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Upload Callback * * Renders upload fields. * * @since 1.0 * * @param array $args Arguments passed by the setting * * @return void */ function edd_upload_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $class = edd_sanitize_html_class( $args['field_class'] ); $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ' '; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Color picker Callback * * Renders color picker fields. * * @since 1.6 * * @param array $args Arguments passed by the setting * * @return void */ function edd_color_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); if ( $edd_option ) { $value = $edd_option; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $default = isset( $args['std'] ) ? $args['std'] : ''; $class = edd_sanitize_html_class( $args['field_class'] ); $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Shop States Callback * * Renders states drop down based on the currently selected country * * @since 1.6 * * @param array $args Arguments passed by the setting * * @return void */ function edd_shop_states_callback( $args ) { $edd_option = edd_get_option( $args['id'] ); $states = edd_get_shop_states(); $class = edd_sanitize_html_class( $args['field_class'] ); $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; if ( $args['chosen'] ) { $class .= ' edd-select-chosen'; if ( is_rtl() ) { $class .= ' chosen-rtl'; } } if ( empty( $states ) ) { $class .= ' edd-no-states'; } $html = ''; $html .= '' . wp_kses_post( $args['desc'] ) . '
'; echo apply_filters( 'edd_after_setting_output', $html, $args ); } /** * Outputs the "Default Rate" setting. * * @since 3.0 * * @param array $args Arguments passed to the setting. */ function edd_tax_rate_callback( $args ) { echo ''; echo wp_kses_post( $args['desc'] ); } /** * Recapture Callback * * Renders Recapture Settings * * @since 2.10.2 * @param array $args Arguments passed by the setting * @return void */ function edd_recapture_callback($args) { $client_connected = false; if ( class_exists( 'RecaptureEDD' ) ) { $client_connected = RecaptureEDD::is_ready(); } ob_start(); echo $args['desc']; // Output the appropriate button and label based on connection status if ( $client_connected ) : $connection_complete = get_option( 'recapture_api_key' ); ?>', '' ); ?>
9999 ), OBJECT ); wp_enqueue_script( 'edd-admin-tax-rates' ); wp_enqueue_style( 'edd-admin-tax-rates' ); wp_localize_script( 'edd-admin-tax-rates', 'eddTaxRates', array( 'rates' => $rates, 'nonce' => wp_create_nonce( 'edd-country-field-nonce' ), 'i18n' => array( /* translators: Tax rate country code */ 'duplicateRate' => esc_html__( 'Duplicate tax rates are not allowed. Please deactivate the existing %s tax rate before adding or activating another.', 'easy-digital-downloads' ), 'emptyCountry' => esc_html__( 'Please select a country.', 'easy-digital-downloads' ), 'negativeTax' => esc_html__( 'Please enter a tax rate greater than 0.', 'easy-digital-downloads' ), 'emptyTax' => esc_html__( 'Are you sure you want to add a 0% tax rate?', 'easy-digital-downloads' ), ), ) ); $templates = array( 'meta', 'row', 'row-empty', 'add', 'bulk-actions' ); echo '
' . $args['desc'] . '
'; echo ''; foreach ( $templates as $tmpl ) { ?> ' . esc_html( $args['tooltip_title'] ) . ': ' . esc_html( $args['tooltip_desc'] ) . '">'; $has_p_tag = strstr( $html, '' ); $has_label = strstr( $html, '' ); // Insert tooltip at end of paragraph if ( false !== $has_p_tag ) { $html = str_replace( '', $tooltip . '', $html ); // Insert tooltip at end of label } elseif ( false !== $has_label ) { $html = str_replace( '', '' . $tooltip, $html ); // Append tooltip to end of HTML } else { $html .= $tooltip; } } return $html; } add_filter( 'edd_after_setting_output', 'edd_add_setting_tooltip', 10, 2 ); /** * Filters the edd_get_option call for test_mode. * * This allows us to ensure that calls directly to edd_get_option respect the constant * in addition to the edd_is_test_mode() function call and included filter. * * @since 3.1 * * @param bool $value If test_mode is enabled in the settings. * @param string $key The key of the setting, should be test_mode. * @param bool $default The default setting, which is 'false' for test_mode. */ function edd_filter_test_mode_option( $value, $key, $default ) { if ( edd_is_test_mode_forced() ) { $value = true; } return $value; } add_filter( 'edd_get_option_test_mode', 'edd_filter_test_mode_option', 10, 3 ); /** * Determine if test mode is being forced to true. * * Using the EDD_TEST_MODE and the edd_is_test_mode filter, determine if the value of true * is being forced for test_mode so we can properly alter the setting for it. * * @since 3.1 * * @return bool If test_mode is being forced or not. */ function edd_is_test_mode_forced() { if ( defined( 'EDD_TEST_MODE' ) && true === EDD_TEST_MODE ) { return true; } if ( false !== has_filter( 'edd_is_test_mode', '__return_true' ) ) { return true; } return false; } /** * Checks for an incorrect setting for the privacy policy. * Required in updating from EDD 2.9.2 to 2.9.3. */ add_filter( 'edd_get_option_show_privacy_policy_on_checkout', function( $value ) { if ( ! empty( $value ) ) { return $value; } $fix_show_privacy_policy_setting = edd_get_option( 'show_agree_to_privacy_policy_on_checkout', false ); if ( ! empty( $fix_show_privacy_policy_setting ) ) { edd_update_option( 'show_privacy_policy_on_checkout', $fix_show_privacy_policy_setting ); edd_delete_option( 'show_agree_to_privacy_policy_on_checkout' ); return $fix_show_privacy_policy_setting; } return $value; }, 10, 3 );