diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b39fa7e..7fb8ed8 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: '1.2.0' # Generate new release - name: Generate new Release diff --git a/CHANGELOG.md b/CHANGELOG.md index 019e5a4..80f8444 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.2.0 - 14/12/2024 +* Compatibility with Form 3.0 + # 1.1.2 - 02/01/2024 * Fix security issues with plugin; * Fix internationalization. diff --git a/README.txt b/README.txt index d2ab13c..410599d 100755 --- a/README.txt +++ b/README.txt @@ -4,8 +4,8 @@ Donate link: https://www.linknacional.com/wordpress/ Tags: fee, donation, givewp, form, recover Requires at least: 5.0 Requires PHP: 7.4 -Tested up to: 6.4 -Stable tag: 1.1.2 +Tested up to: 6.7 +Stable tag: 1.2.0 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -62,9 +62,16 @@ Not in the free version. We have this option and more in our Fee recovery PRO p == Screenshots == -1. Example screenshot +1. Configuration page +2. Legacy template form recovery fee option +3. Multi-step template form recovery fee option +4. Classic template form recovery fee option +5. Donation summary == Changelog == += 1.2.0 = +**14/12/2024** +* Compatibility with 3.0.0 forms. = 1.1.2 = **02/01/2024** diff --git a/admin/class-fee-recovery-for-givewp-admin.php b/admin/class-fee-recovery-for-givewp-admin.php index f80b27d..f979ed1 100755 --- a/admin/class-fee-recovery-for-givewp-admin.php +++ b/admin/class-fee-recovery-for-givewp-admin.php @@ -163,7 +163,7 @@ public function add_settings_into_section($settings) :array { 'default' => 0, ); } - + $settings[] = array( 'name' => __('Rate field description', 'fee-recovery-for-givewp'), 'id' => 'lkn_fee_recovery_setting_field_description', @@ -171,13 +171,28 @@ public function add_settings_into_section($settings) :array { 'type' => 'text', 'default' => __('Cover the payment fee?', 'fee-recovery-for-givewp'), ); - + $settings[] = array( + 'type' => 'title', + 'id' => 'lkn_fee_recovery', + ); + $settings[] = array( + 'name' => __('Visual Form Builder', 'fee-recovery-for-givewp'), + 'id' => 'lkn_fee_recovery_vfb', + 'desc' => __('Enable or disable the option to add the payment fee amount to the donation amount in Form 3.0.', 'fee-recovery-for-givewp'), + 'type' => 'radio', + 'default' => 'disabled', + 'options' => array( + 'enabled' => __('Enabled', 'fee-recovery-for-givewp'), + 'disabled' => __('Disabled', 'fee-recovery-for-givewp'), + ), + ); + $settings[] = array( 'id' => 'lkn_fee_recovery', 'type' => 'sectionend', ); } - + return $settings; } } diff --git a/fee-recovery-for-givewp.php b/fee-recovery-for-givewp.php index 09e25b7..43c9226 100755 --- a/fee-recovery-for-givewp.php +++ b/fee-recovery-for-givewp.php @@ -15,7 +15,7 @@ * Plugin Name: Fee recovery for GiveWP * Plugin URI: https://wordpress.org/plugins/fee-recovery-for-givewp * Description: Add donor option to cover payment expenses - * Version: 1.1.2 + * Version: 1.2.0 * Author: Link Nacional * Author URI: https://www.linknacional.com/wordpress/ * License: GPL-3.0+ @@ -34,8 +34,10 @@ * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'FEE_RECOVERY_FOR_GIVEWP_VERSION', '1.1.2' ); +define( 'FEE_RECOVERY_FOR_GIVEWP_VERSION', '1.2.0' ); define( 'FEE_RECOVERY_FOR_GIVEWP_BASENAME', plugin_basename(__FILE__) ); +define("FEE_RECOVERY_FOR_GIVEWP_URL", plugin_dir_url(__FILE__)); +define("FEE_RECOVERY_FOR_GIVEWP_DIR", plugin_dir_path(__FILE__)); /** * The code that runs during plugin activation. diff --git a/includes/class-fee-recovery-for-givewp.php b/includes/class-fee-recovery-for-givewp.php index 3552f8e..e3c9a13 100755 --- a/includes/class-fee-recovery-for-givewp.php +++ b/includes/class-fee-recovery-for-givewp.php @@ -10,6 +10,12 @@ * @since 1.0.0 */ +use Give\DonationForms\Blocks\DonationFormBlock\Block; +use Give\Donations\Models\Donation; +use Give\Framework\FieldsAPI\DonationForm; +use Give\Framework\Support\ValueObjects\Money; +use Give\Helpers\Hooks; + /** * The core plugin class. * @@ -23,7 +29,8 @@ * * @author Link Nacional */ -final class Fee_Recovery_For_Givewp { +final class Fee_Recovery_For_Givewp +{ /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. @@ -61,8 +68,9 @@ final class Fee_Recovery_For_Givewp { * * @since 1.0.0 */ - public function __construct() { - if ( defined( 'FEE_RECOVERY_FOR_GIVEWP_VERSION' ) ) { + public function __construct() + { + if (defined('FEE_RECOVERY_FOR_GIVEWP_VERSION')) { $this->version = FEE_RECOVERY_FOR_GIVEWP_VERSION; } else { $this->version = '1.0.0'; @@ -80,7 +88,8 @@ public function __construct() { * * @since 1.0.0 */ - public function run(): void { + public function run(): void + { $this->loader->run(); } @@ -92,7 +101,8 @@ public function run(): void { * * @return string the name of the plugin */ - public function get_plugin_name() :string { + public function get_plugin_name(): string + { return $this->plugin_name; } @@ -103,7 +113,8 @@ public function get_plugin_name() :string { * * @return Fee_Recovery_For_Givewp_Loader orchestrates the hooks of the plugin */ - public function get_loader() :Fee_Recovery_For_Givewp_Loader { + public function get_loader(): Fee_Recovery_For_Givewp_Loader + { return $this->loader; } @@ -114,7 +125,8 @@ public function get_loader() :Fee_Recovery_For_Givewp_Loader { * * @return string the version number of the plugin */ - public function get_version() :string { + public function get_version(): string + { return $this->version; } @@ -123,15 +135,15 @@ public function get_version() :string { * * @since 1.0.0 * - * @param array $donation_data - * @param array $valid_data + * @param array $donation_data + * @param array $valid_data * * @return array */ - public function update_amount($donation_data, $valid_data) :array { + public function update_amount($donation_data, $valid_data): array + { $enabledFee = give_get_option('lkn_fee_recovery_setting_field', 'disabled'); $enabledFeeMeta = apply_filters('fee_recovery_update_amount_enabled', $enabledFee, $donation_data['post_data']); - if ( isset($donation_data['post_data']['lkn-fee-recovery']) && 'yes' === $donation_data['post_data']['lkn-fee-recovery'] @@ -139,12 +151,12 @@ public function update_amount($donation_data, $valid_data) :array { && 'global' === $enabledFeeMeta ) { $price = (float) ($donation_data['price']); - $feeValue = (float) (give_get_option('lkn_fee_recovery_setting_field_fixed', 0)); - $feeValuePercent = (float) (give_get_option('lkn_fee_recovery_setting_field_percent', 0)) / 100; + // $feeValue = (float) (give_get_option('lkn_fee_recovery_setting_field_fixed', 0)); + // $feeValuePercent = (float) (give_get_option('lkn_fee_recovery_setting_field_percent', 0)) / 100; - $feeTotal = ($price * $feeValuePercent) + $feeValue; + // $feeTotal = ($price * (1 + $feeValuePercent) + $feeValue) * 100; - $donation_data['price'] = (float) $price + $feeTotal; + // $donation_data['price'] = (float) $feeTotal; } return $donation_data; @@ -165,29 +177,30 @@ public function update_amount($donation_data, $valid_data) :array { * * @since 1.0.0 */ - private function load_dependencies(): void { + private function load_dependencies(): void + { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ - require_once plugin_dir_path( __DIR__ ) . 'includes/class-fee-recovery-for-givewp-loader.php'; + require_once plugin_dir_path(__DIR__) . 'includes/class-fee-recovery-for-givewp-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ - require_once plugin_dir_path( __DIR__ ) . 'includes/class-fee-recovery-for-givewp-i18n.php'; + require_once plugin_dir_path(__DIR__) . 'includes/class-fee-recovery-for-givewp-i18n.php'; /** * The class responsible for defining all actions that occur in the admin area. */ - require_once plugin_dir_path( __DIR__ ) . 'admin/class-fee-recovery-for-givewp-admin.php'; + require_once plugin_dir_path(__DIR__) . 'admin/class-fee-recovery-for-givewp-admin.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ - require_once plugin_dir_path( __DIR__ ) . 'public/class-fee-recovery-for-givewp-public.php'; + require_once plugin_dir_path(__DIR__) . 'public/class-fee-recovery-for-givewp-public.php'; $this->loader = new Fee_Recovery_For_Givewp_Loader(); } @@ -200,10 +213,11 @@ private function load_dependencies(): void { * * @since 1.0.0 */ - private function set_locale(): void { + private function set_locale(): void + { $plugin_i18n = new Fee_Recovery_For_Givewp_i18n(); - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); } /** @@ -212,11 +226,12 @@ private function set_locale(): void { * * @since 1.0.0 */ - private function define_admin_hooks(): void { - $plugin_admin = new Fee_Recovery_For_Givewp_Admin( $this->get_plugin_name(), $this->get_version() ); + private function define_admin_hooks(): void + { + $plugin_admin = new Fee_Recovery_For_Givewp_Admin($this->get_plugin_name(), $this->get_version()); - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); $this->loader->add_filter('plugin_action_links_' . FEE_RECOVERY_FOR_GIVEWP_BASENAME, $this, 'define_row_meta', 10, 2); } @@ -226,12 +241,63 @@ private function define_admin_hooks(): void { * * @since 1.0.0 */ - private function define_public_hooks(): void { - $plugin_public = new Fee_Recovery_For_Givewp_Public( $this->get_plugin_name(), $this->get_version() ); + private function define_public_hooks(): void + { + $plugin_public = new Fee_Recovery_For_Givewp_Public($this->get_plugin_name(), $this->get_version()); + + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); + $this->loader->add_filter('give_donation_data_before_gateway', $this, 'update_amount', 99, 2); + $this->loader->add_action('give_init', $this, 'initialize_new_form'); + + add_action('givewp_donation_form_schema', function (DonationForm $form, $formId): void { + $enabledFee = give_get_option('lkn_fee_recovery_vfb', 'disabled'); + + if ('disabled' !== $enabledFee) { + + $fieldName = 'lkn_fee_recovery_enabled'; + $nonceAction = 'fee_recovery_nonce'; + $nonceValue = wp_create_nonce($nonceAction); + + // Verifica se o campo já existe + $fields = $form->getFields(); + foreach ($fields as $field) { + if ($field->getName() === $fieldName) { + return; // Se o campo já existe, sai da função + } + } + + $description = give_get_option('lkn_fee_recovery_setting_field_description', __('Cover the payment fee?', 'fee-recovery-for-givewp')); + + // Cria o campo checkbox + $field = Give\Framework\FieldsAPI\Checkbox::make($fieldName) + ->label($description) + ->showInReceipt(false); + + $nonce_field = Give\Framework\FieldsAPI\Hidden::make("fee_recovery_enabled_nonce") + ->defaultValue($nonceValue) + ->showInReceipt(false); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); - $this->loader->add_filter( 'give_donation_data_before_gateway', $this, 'update_amount', 99, 2 ); + // Insere o campo após o campo de email + $form->insertAfter('email', $field); + $form->insertAfter('email', $nonce_field); + + // Enfileira o script e localiza variáveis + $feeValue = (float) give_get_option('lkn_fee_recovery_setting_field_fixed', 0); + $feeValuePercent = (float) give_get_option('lkn_fee_recovery_setting_field_percent', 0) / 100; + + if ('disabled' !== $enabledFee) { + wp_enqueue_script('lkn-fee-recovery-new-form', FEE_RECOVERY_FOR_GIVEWP_URL . '/public/js/fee-recovery-for-givewp-new-form.js', array(), $this->version, true); + wp_localize_script('lkn-fee-recovery-new-form', 'varsPhp', array( + 'description' => $description, + 'feeValue' => $feeValue, + 'feeValuePercent' => $feeValuePercent, + 'enabledFee' => $enabledFee, + 'currency' => give_currency_symbol(give_get_currency()) + )); + } + } + }, 10, 2); // Prioridade 10 e 2 argumentos } /** @@ -239,22 +305,46 @@ private function define_public_hooks(): void { * * @since 1.0.0 * - * @param array $plugin_meta - * @param string $plugin_file + * @param array $plugin_meta + * @param string $plugin_file * * @return array */ - public function define_row_meta($plugin_meta, $plugin_file) :array { - if ( ! defined(FEE_RECOVERY_FOR_GIVEWP_BASENAME) && ! is_plugin_active(FEE_RECOVERY_FOR_GIVEWP_BASENAME)) { + public function define_row_meta($plugin_meta, $plugin_file): array + { + if (! defined(FEE_RECOVERY_FOR_GIVEWP_BASENAME) && ! is_plugin_active(FEE_RECOVERY_FOR_GIVEWP_BASENAME)) { return $plugin_meta; } $new_meta_links['setting'] = sprintf( '%2$s', admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general§ion=lkn-fee-recovery'), - __('Settings', 'give') + __('Settings', 'fee-recovery-for-givewp') ); - + return array_merge($plugin_meta, $new_meta_links); } + + // Chamada de Hooks do Formulário 3.0 + public function initialize_new_form(): void + { + Hooks::addFilter('givewp_donation_creating', __CLASS__, 'change_amount', 10, 2); + } + + // Action que faz a mudança do valor da doação + public static function change_amount(Donation $donation): void + { + if (isset($_POST["lkn_fee_recovery_enabled"]) && + "true" == $_POST["lkn_fee_recovery_enabled"] && + isset($_POST['fee_recovery_enabled_nonce']) && + wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['fee_recovery_enabled_nonce'])), 'fee_recovery_nonce') + ) { + $price = (float) ($donation->amount->formatToDecimal()); + $feeValue = (float) (give_get_option('lkn_fee_recovery_setting_field_fixed', 0)); + $feeValuePercent = (float) (give_get_option('lkn_fee_recovery_setting_field_percent', 0)) / 100; + $feeTotal = ($price * (1 + $feeValuePercent) + $feeValue) * 100; + + $donation->amount = new Money($feeTotal, give_get_currency($donation->formId)); + } + } } diff --git a/languages/fee-recovery-for-givewp-pt_BR.mo b/languages/fee-recovery-for-givewp-pt_BR.mo old mode 100755 new mode 100644 index 7a1463a..9ff23c1 Binary files a/languages/fee-recovery-for-givewp-pt_BR.mo and b/languages/fee-recovery-for-givewp-pt_BR.mo differ diff --git a/languages/fee-recovery-for-givewp-pt_BR.po b/languages/fee-recovery-for-givewp-pt_BR.po old mode 100755 new mode 100644 index 49cf8d7..d73160a --- a/languages/fee-recovery-for-givewp-pt_BR.po +++ b/languages/fee-recovery-for-givewp-pt_BR.po @@ -1,57 +1,132 @@ -# Fee recovery for GiveWP -msgid "Fee recovery for GiveWP" -msgstr "Fee recovery for GiveWP" +# Blank WordPress Pot +# Copyright 2014 ... +# This file is distributed under the GNU General Public License v3 or later. +msgid "" +msgstr "" +"Project-Id-Version: fee-recovery-for-givewp\n" +"Report-Msgid-Bugs-To: Translator Name \n" +"POT-Creation-Date: 2024-12-09 13:07-0300\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: Your Team \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;" +"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;" +"_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c," +"_nc:4c,1,2\n" +"X-Poedit-Basepath: ..\n" +"X-Generator: Poedit 3.4.2\n" +"X-Poedit-SearchPath-0: .\n" + +#: admin/class-fee-recovery-for-givewp-admin.php:94 +msgid "Get new features with" +msgstr "Obtenha novos recursos com" +#: admin/class-fee-recovery-for-givewp-admin.php:108 +#: admin/class-fee-recovery-for-givewp-admin.php:134 msgid "Fee recovery" msgstr "Recuperação de taxa" -msgid "Add donor option to cover payment expenses" -msgstr "Adicionar opção de doador para cobrir despesas de pagamento" - -msgid "Enable or disable the option to add the payment fee amount for the donor." -msgstr "Habilita ou desabilita a opção de adicionar o valor da taxa de pagamento para o doador." +#: admin/class-fee-recovery-for-givewp-admin.php:136 +msgid "" +"Enable or disable the option to add the payment fee amount for the donor." +msgstr "" +"Habilitar ou desabilitar a opção de adicionar o valor da taxa de pagamento " +"para o doador." +#: admin/class-fee-recovery-for-givewp-admin.php:140 msgid "Global" msgstr "Global" +#: admin/class-fee-recovery-for-givewp-admin.php:141 msgid "By payment method" msgstr "Por método de pagamento" +#: admin/class-fee-recovery-for-givewp-admin.php:142 +msgid "By form" +msgstr "Por formulário" + +#: admin/class-fee-recovery-for-givewp-admin.php:143 msgid "Disable" msgstr "Desabilitar" +#: admin/class-fee-recovery-for-givewp-admin.php:151 msgid "Fixed fee" -msgstr "Taxa fixa" +msgstr "Taxa Fixa" +#: admin/class-fee-recovery-for-givewp-admin.php:153 msgid "Fixed fee to be added per donation." msgstr "Taxa fixa a ser adicionada por doação." +#: admin/class-fee-recovery-for-givewp-admin.php:159 msgid "Percentage fee" msgstr "Taxa percentual" +#: admin/class-fee-recovery-for-givewp-admin.php:161 msgid "Percentage fee to be added per donation." msgstr "Taxa percentual a ser adicionada por doação." +#: admin/class-fee-recovery-for-givewp-admin.php:168 msgid "Rate field description" msgstr "Descrição do campo de taxa" -msgid "This description appears on the donation form, use \"##\" to add the fee amount." -msgstr "Essa descrição aparece no formulário de doação, use \"##\" para adicionar o valor da taxa." - +#: admin/class-fee-recovery-for-givewp-admin.php:170 +msgid "" +"This description appears on the donation form, use \"##\" to add the fee " +"amount." +msgstr "" +"Esta descrição aparece no formulário de doação, use '##' para adicionar o " +"valor da taxa." + +#: admin/class-fee-recovery-for-givewp-admin.php:172 +#: includes/class-fee-recovery-for-givewp.php:270 +#: public/class-fee-recovery-for-givewp-public.php:132 msgid "Cover the payment fee?" msgstr "Cobrir a taxa de pagamento?" -msgid "By form" -msgstr "Por formulário" +#: admin/class-fee-recovery-for-givewp-admin.php:179 +msgid "Visual Form Builder" +msgstr "Construtor de Formulários Visual" -msgid "Get new features with" -msgstr "Obtenha novos recursos com" +#: admin/class-fee-recovery-for-givewp-admin.php:181 +msgid "" +"Enable or disable the option to add the payment fee amount to the donation " +"amount in Form 3.0." +msgstr "" +"Habilitar ou desabilitar a opção de adicionar o valor da taxa de pagamento " +"ao valor da doação no Formulário 3.0." + +#: admin/class-fee-recovery-for-givewp-admin.php:185 +msgid "Enabled" +msgstr "Habilitado" +#: admin/class-fee-recovery-for-givewp-admin.php:186 +msgid "Disabled" +msgstr "Desabilitado" + +#: includes/class-fee-recovery-for-givewp-activator.php:58 msgid "Activation error:" msgstr "Erro de ativação:" +#: includes/class-fee-recovery-for-givewp-activator.php:59 msgid "You need the plugin" msgstr "Você precisa do plugin" +#: includes/class-fee-recovery-for-givewp-activator.php:61 +msgid "GiveWP" +msgstr "GiveWP" + +#: includes/class-fee-recovery-for-givewp-activator.php:62 msgid "installed and active for Fee recovery for GiveWP to activate" -msgstr "instalado e ativo para o Fee recovery for GiveWP ser ativado" \ No newline at end of file +msgstr "" +"instalado e ativo para que a recuperação de taxa para o GiveWP seja ativada" + +#: includes/class-fee-recovery-for-givewp.php:322 +msgid "Settings" +msgstr "Configurações" diff --git a/languages/fee-recovery-for-givewp.pot b/languages/fee-recovery-for-givewp.pot old mode 100755 new mode 100644 index 66d5fbb..ee2dec6 --- a/languages/fee-recovery-for-givewp.pot +++ b/languages/fee-recovery-for-givewp.pot @@ -1,63 +1,169 @@ -# Fee recovery for GiveWP -msgid "Fee recovery for GiveWP" -msgstr "" - +# Blank WordPress Pot +# Copyright 2014 ... +# This file is distributed under the GNU General Public License v3 or later. +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: fee-" +"recovery-for-givewp\n" +"Report-Msgid-Bugs-To: " +"Translator Name " +"\n" +"POT-Creation-Date: " +"2024-12-09 13:06-0300\n" +"PO-Revision-Date: \n" +"Last-Translator: Your " +"Name \n" +"Language-Team: Your Team " +"\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/" +"plain; charset=UTF-8\n" +"Content-Transfer-" +"Encoding: 8bit\n" +"Plural-Forms: " +"nplurals=2; plural=n != " +"1;\n" +"X-Textdomain-Support: " +"yesX-Generator: Poedit " +"1.6.4\n" +"X-Poedit-SourceCharset: " +"UTF-8\n" +"X-Poedit-KeywordsList: " +"__;_e;esc_html_e;" +"esc_html_x:1,2c;" +"esc_html__;esc_attr_e;" +"esc_attr_x:1,2c;" +"esc_attr__;_ex:1,2c;" +"_nx:4c,1,2;" +"_nx_noop:4c,1,2;_x:1,2c;" +"_n:1,2;_n_noop:1,2;" +"__ngettext:1,2;" +"__ngettext_noop:1,2;_c," +"_nc:4c,1,2\n" +"X-Poedit-Basepath: ..\n" +"X-Generator: Poedit " +"3.4.2\n" +"X-Poedit-" +"SearchPath-0: .\n" + +#: admin/class-fee-recovery-for-givewp-admin.php:94 +msgid "" +"Get new features with" +msgstr "" + +#: admin/class-fee-recovery-for-givewp-admin.php:108 +#: admin/class-fee-recovery-for-givewp-admin.php:134 msgid "Fee recovery" msgstr "" -msgid "Add donor option to cover payment expenses" -msgstr "" - -msgid "Enable or disable the option to add the payment fee amount for the donor." +#: admin/class-fee-recovery-for-givewp-admin.php:136 +msgid "" +"Enable or disable the " +"option to add the " +"payment fee amount for " +"the donor." msgstr "" +#: admin/class-fee-recovery-for-givewp-admin.php:140 msgid "Global" msgstr "" +#: admin/class-fee-recovery-for-givewp-admin.php:141 msgid "By payment method" msgstr "" +#: admin/class-fee-recovery-for-givewp-admin.php:142 +msgid "By form" +msgstr "" + +#: admin/class-fee-recovery-for-givewp-admin.php:143 msgid "Disable" msgstr "" +#: admin/class-fee-recovery-for-givewp-admin.php:151 msgid "Fixed fee" msgstr "" -msgid "Fixed fee to be added per donation." +#: admin/class-fee-recovery-for-givewp-admin.php:153 +msgid "" +"Fixed fee to be added " +"per donation." msgstr "" +#: admin/class-fee-recovery-for-givewp-admin.php:159 msgid "Percentage fee" msgstr "" -msgid "Percentage fee to be added per donation." +#: admin/class-fee-recovery-for-givewp-admin.php:161 +msgid "" +"Percentage fee to be " +"added per donation." msgstr "" -msgid "Rate field description" +#: admin/class-fee-recovery-for-givewp-admin.php:168 +msgid "" +"Rate field description" msgstr "" -msgid "This description appears on the donation form, use \"##\" to add the fee amount." +#: admin/class-fee-recovery-for-givewp-admin.php:170 +msgid "" +"This description appears " +"on the donation form, " +"use \"##\" to add the " +"fee amount." msgstr "" -msgid "Cover the payment fee?" +#: admin/class-fee-recovery-for-givewp-admin.php:172 +#: includes/class-fee-recovery-for-givewp.php:270 +#: public/class-fee-recovery-for-givewp-public.php:132 +msgid "" +"Cover the payment fee?" msgstr "" -msgid "Fixed fee to be added per donation." +#: admin/class-fee-recovery-for-givewp-admin.php:179 +msgid "Visual Form Builder" msgstr "" -msgid "Percentage fee to be added per donation." +#: admin/class-fee-recovery-for-givewp-admin.php:181 +msgid "" +"Enable or disable the " +"option to add the " +"payment fee amount to " +"the donation amount in " +"Form 3.0." msgstr "" -msgid "By form" +#: admin/class-fee-recovery-for-givewp-admin.php:185 +msgid "Enabled" msgstr "" -msgid "Get new features with" +#: admin/class-fee-recovery-for-givewp-admin.php:186 +msgid "Disabled" msgstr "" +#: includes/class-fee-recovery-for-givewp-activator.php:58 msgid "Activation error:" msgstr "" -msgid "You need" +#: includes/class-fee-recovery-for-givewp-activator.php:59 +msgid "You need the plugin" +msgstr "" + +#: includes/class-fee-recovery-for-givewp-activator.php:61 +msgid "GiveWP" msgstr "" -msgid "installed and active for Fee recovery for GiveWP to activate" -msgstr "" \ No newline at end of file +#: includes/class-fee-recovery-for-givewp-activator.php:62 +msgid "" +"installed and active for " +"Fee recovery for GiveWP " +"to activate" +msgstr "" + +#: includes/class-fee-recovery-for-givewp.php:322 +msgid "Settings" +msgstr "" diff --git a/public/css/fee-recovery-for-givewp-public.css b/public/css/fee-recovery-for-givewp-public.css index 074f75e..e11003e 100755 --- a/public/css/fee-recovery-for-givewp-public.css +++ b/public/css/fee-recovery-for-givewp-public.css @@ -1,4 +1,4 @@ -/** +/* * * All of the CSS for your public-facing functionality should be * included in this file. */ @@ -10,15 +10,15 @@ } #lkn-fee-recovery-wrap { - padding: 2% 1% 2% 1%; + padding: 2% 1% 2% 1%; position: relative; - display: block; - line-height: 1em; - box-sizing: border-box; - clear: both; + display: block; + line-height: 1em; + box-sizing: border-box; + clear: both; } -#lkn-fee-recovery-list-wrap { + #lkn-fee-recovery-list-wrap { padding-left: 0px !important; } diff --git a/public/js/fee-recovery-for-givewp-new-form.js b/public/js/fee-recovery-for-givewp-new-form.js new file mode 100755 index 0000000..c69a978 --- /dev/null +++ b/public/js/fee-recovery-for-givewp-new-form.js @@ -0,0 +1,103 @@ +document.addEventListener('DOMContentLoaded', function () { + // Variáveis com valores do PHP + const feeValue = parseFloat(varsPhp.feeValue) + const feeValuePercent = parseFloat(varsPhp.feeValuePercent) + + // Função para atualizar o valor da taxa de recuperação + function atualizarTaxaDeRecuperacao() { + const hiddenInput = document.querySelector('input[name="amount"]') + const feeRecoveryElement = document.querySelector('#fee-recovery .givewp-elements-donationSummary__list__item__value') + + if (hiddenInput && feeRecoveryElement) { + const amountValue = parseFloat(hiddenInput.value) + const feeRecoveryValue = (amountValue * feeValuePercent + feeValue).toFixed(2) + feeRecoveryElement.textContent = `R$ ${feeRecoveryValue}` + } + } + + // Função para atualizar os textos dos elementos de doação + function atualizarTextos(checked) { + const elements = document.querySelectorAll('.givewp-elements-donationSummary__list__item__value') + const hiddenInput = document.querySelector('input[name="amount"]') + + if (elements.length > 0 && hiddenInput) { + const lastElement = elements[elements.length - 1] + const amountValue = parseFloat(hiddenInput.value) + const newAmount = checked + ? (amountValue + (amountValue * feeValuePercent + feeValue)).toFixed(2) + : amountValue.toFixed(2) + + lastElement.textContent = `R$ ${newAmount}` + atualizarTaxaDeRecuperacao() + } + } + + // Função para adicionar um novo item na lista de doações + function adicionarElementoTaxaDeRecuperacao() { + const list = document.querySelector('.givewp-elements-donationSummary__list') + const hiddenInput = document.querySelector('input[name="amount"]') + + if (list && hiddenInput) { + const amountValue = parseFloat(hiddenInput.value) + const novoItem = document.createElement('li') + novoItem.id = 'fee-recovery' + novoItem.className = 'givewp-elements-donationSummary__list__item' + novoItem.innerHTML = ` +
+
Taxa de recuperação
+
R$ ${(amountValue * feeValuePercent + feeValue).toFixed(2)}
+
+ ` + novoItem.style.display = 'none' + + const items = list.querySelectorAll('.givewp-elements-donationSummary__list__item') + list.insertBefore(novoItem, items[1] || null) + } + } + + // Função para inicializar as atualizações e adicionar o elemento de taxa de recuperação + function inicializar() { + adicionarElementoTaxaDeRecuperacao() + } + + // Inicializa ao carregar o DOM + inicializar() + + // Listener para o checkbox de recuperação de taxa + const checkbox = document.querySelector("input[name='lkn_fee_recovery_enabled']") + if (checkbox) { + checkbox.addEventListener('click', () => { + const info = document.querySelector('#fee-recovery') + if (info) { + if (checkbox.checked) { + info.style.display = 'block' + checkbox.value = true + atualizarTextos(true) + } else { + info.style.display = 'none' + checkbox.value = false + atualizarTextos(false) + } + } + }) + + const hiddenInput = document.querySelector('input[name="amount"]') + const amountCustom = document.querySelector("input[name='amount-custom']") + if (hiddenInput && amountCustom) { + amountCustom.addEventListener('change', () => { + const info = document.querySelector('#fee-recovery') + if (info) { + if (checkbox.checked) { + info.style.display = 'block' + checkbox.value = true + atualizarTextos(true) + } else { + info.style.display = 'none' + checkbox.value = false + atualizarTextos(false) + } + } + }) + } + } +}) diff --git a/public/js/fee-recovery-for-givewp-public.js b/public/js/fee-recovery-for-givewp-public.js index 17b5143..00132e7 100755 --- a/public/js/fee-recovery-for-givewp-public.js +++ b/public/js/fee-recovery-for-givewp-public.js @@ -4,7 +4,6 @@ $(window).on('load', () => { const iframe = document.getElementsByName('give-embed-form')[0] - // Check if GiveWP donation form has iframe if (iframe) { const checkboxWrapper = iframe.contentDocument.getElementById('lkn-fee-recovery-checkbox-wrapper')