Plugin Directory

Changeset 3365148


Ignore:
Timestamp:
09/21/2025 06:58:21 AM (6 months ago)
Author:
Goback2
Message:

New ver 1.4.3

Location:
edd-custom-checkout-fields
Files:
10 added
5 edited

Legend:

Unmodified
Added
Removed
  • edd-custom-checkout-fields/trunk/class-fields-generator.php

    r2694443 r3365148  
    55{
    66    private static $instance = null;
     7    /**
     8     * @var array|array[]
     9     */
     10    private $fields;
    711
    812    public static function get_instance($slug = '_slug', $text_domain = 'ecf')
     
    168172            .field_type_paragraph .f_desc,
    169173            .field_type_paragraph .f_show_admin,
    170             .field_type_paragraph .f_id
    171             {
     174            .field_type_paragraph .f_id {
    172175                display: none;
    173176            }
  • edd-custom-checkout-fields/trunk/index.php

    r2763952 r3365148  
    11<?php
    22/*
    3 Plugin Name: EDD custom checkout fields
     3Plugin Name: Custom checkout fields for EDD
    44Description: Add custom fields to edd checkout form
    5 Plugin URI: http://wp-master.ir
    6 Author: Omid Shamlu
    7 Author URI: http://wp-master.ir
    8 Version: 1.4.1
    9 License: GPL2
     5Plugin URI: https://wp-master.ir
     6Author: Omid Shamloo
     7Author URI: https://wp-master.ir
     8Version: 1.4.3
    109Text Domain: ecf
     10Domain Path: /languages
     11Requires PHP: 7.0
     12Requires Plugins: easy-digital-downloads
    1113 */
    1214
     
    1416 * Changes:
    1517 * 1.4.1  : fixed not working in new EDD version
     18 * 1.4.2  : fixed not working when user logged in
     19 * 1.4.3  : Some fixes and change plugin name due trademark alert from plugins@wordpress.org
    1620 */
    1721defined('ABSPATH') or die('No script kiddies please!');
    1822
    19 $defs = array(
    20     'ecf_url' => plugin_dir_url(__FILE__),
    21     'ecf_dir' => plugin_dir_path(__FILE__),
    22 );
    23 foreach ($defs as $def_name => $def_val) {
    24     define($def_name, $def_val);
    25 }
    26 
     23/**
     24 * defines
     25 */
     26define('ecf_url', plugin_dir_url(__FILE__));
     27define('ecf_dir', plugin_dir_path(__FILE__));
     28
     29/**
     30 * activate action
     31 * like redirect to admin settings and ...
     32 */
     33register_activation_hook(__FILE__, ['wpm_edd_custom_fields', 'activation_hook']);
     34/**
     35 * plugins loaded action
     36 */
     37add_action('plugins_loaded', ['wpm_edd_custom_fields', 'plugins_loaded']);
    2738
    2839/**
     
    5465        }
    5566
    56         load_plugin_textdomain('ecf', false, dirname(plugin_basename(__FILE__)) . '/languages');
    57         __('EDD custom checkout fields', 'ecf');
    58         __('Add custom fields to edd checkout form', 'ecf');
     67        /**
     68         * load textdomain
     69         */
     70        $this->load_plugin_textdomain();
     71
    5972        /**
    6073         * admin menu
     
    8295    }
    8396
     97    public static function load_plugin_textdomain()
     98    {
     99        load_plugin_textdomain('ecf', false, dirname(plugin_basename(__FILE__)) . '/languages');
     100        __('EDD custom checkout fields', 'ecf');
     101        __('Custom checkout fields for EDD', 'ecf');
     102        __('Add custom fields to edd checkout form', 'ecf');
     103    }
     104
     105    public static function plugins_loaded()
     106    {
     107
     108        if (get_option('wpm_ecf_redirect_after_activation_option', false)) {
     109            delete_option('wpm_ecf_redirect_after_activation_option');
     110            exit(wp_redirect(admin_url('edit.php?post_type=download&page=edd-custom-fields')));
     111        }
     112
     113    }
     114
     115    public static function activation_hook()
     116    {
     117        add_option('wpm_ecf_redirect_after_activation_option', true);
     118    }
     119
    84120    public function make_fields($fields, $prefix = 'edd-')
    85121    {
     
    92128        }
    93129        $this->fields = $fields;
    94         add_action('edd_purchase_form_user_info_fields', array($this, 'wpm_edd_display_checkout_fields'));
     130        if (!is_user_logged_in()) {
     131            add_action('edd_purchase_form_user_info_fields', array($this, 'wpm_edd_display_checkout_fields'));
     132        } else {
     133            /**
     134             * @since 1.4.2
     135             */
     136
     137            add_action('edd_purchase_form_after_user_info', array($this, 'wpm_edd_display_checkout_fields'));
     138        }
    95139        add_filter('edd_purchase_form_required_fields', array($this, 'wpm_edd_required_checkout_fields'));
    96140        add_action('edd_checkout_error_checks', array($this, 'wpm_edd_validate_checkout_fields'), 10, 2);
     
    106150        add_filter('edd_payments_table_column', array($this, 'edd_payments_table_column'), 10, 3);
    107151
    108     }
    109 
    110     public function wpm_edd_display_checkout_fields()
     152        /**
     153         * @since 1.4.2
     154         * Add custom fields data to purchase session data
     155         */
     156        add_filter('edd_purchase_data_before_gateway', [$this, 'wpm_edd_custom_fields_data_to_purchase_data'], 10, 2);
     157    }
     158
     159    function wpm_edd_custom_fields_data_to_purchase_data($purchase_data, $valid_data)
     160    {
     161        $payment_id = '';
     162        $fields = $this->fields;
     163        foreach ($fields as $field) {
     164            extract($field);
     165            if (strpos($id, 'ecf_') !== false) {
     166                $id = 'edd_' . $this->prefix . $id;
     167            }
     168            $purchase_data[$id] = isset($_POST[$id]) ? sanitize_text_field($_POST[$id]) : '';
     169//            edd_update_payment_meta($payment_id, $id, $payment_meta[$id]);
     170        }
     171
     172//        die(var_export($purchase_data, 1));
     173        return $purchase_data;
     174    }
     175
     176    public function wpm_edd_display_checkout_fields($customer = false)
    111177    {
    112178        $fields = $this->fields;
     
    266332    public function wpm_edd_store_custom_fields($payment_meta)
    267333    {
     334//        die(var_export($payment_meta, 1));
    268335        if (did_action('edd_purchase')) {
    269336            $fields = $this->fields;
    270337            foreach ($fields as $field) {
    271338                extract($field);
    272                 if (strpos($id, 'ecf_') === false) {
    273                     $id = $id;
    274                 } else {
     339                if (strpos($id, 'ecf_') !== false) {
    275340                    $id = 'edd_' . $this->prefix . $id;
    276341                }
    277342                $payment_meta[$id] = isset($_POST[$id]) ? sanitize_text_field($_POST[$id]) : '';
     343//                edd_update_payment_meta($payment_id, $id, $payment_meta[$id]);
    278344            }
    279345        }
     
    351417            <div class="column-container">
    352418                <div class="column">
    353                     <strong>' . $title . ': </strong>
     419                    <strong>' . $title . ': </strong> <br>
    354420                    ' . $_val . '
    355421                </div>
     
    439505}
    440506
    441 add_action('plugins_loaded', 'load_wpm_edd_custom_fields');
     507add_action('init', 'load_wpm_edd_custom_fields');
    442508function load_wpm_edd_custom_fields()
    443509{
     
    447513    unset($_ecf_custom_fields['last_saved']);
    448514    if (is_array($_ecf_custom_fields) && !empty($_ecf_custom_fields)) {
     515
    449516        $_fields = array();
    450517        foreach ($_ecf_custom_fields['type'] as $index => $value) {
     
    519586    }
    520587
     588
    521589}
  • edd-custom-checkout-fields/trunk/languages/ecf-fa_IR.po

    r2694443 r3365148  
    22msgstr ""
    33"Project-Id-Version: custom price payment\n"
    4 "POT-Creation-Date: 2022-03-15 21:09+0330\n"
    5 "PO-Revision-Date: 2022-03-15 21:10+0330\n"
     4"POT-Creation-Date: 2025-09-20 23:59+0330\n"
     5"PO-Revision-Date: 2025-09-20 23:59+0330\n"
    66"Last-Translator: \n"
    77"Language-Team: wp-master.ir\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.3\n"
     12"Plural-Forms: nplurals=1; plural=0;\n"
     13"X-Generator: Poedit 3.4.2\n"
    1314"X-Poedit-Basepath: ..\n"
    14 "Plural-Forms: nplurals=1; plural=0;\n"
    1515"X-Poedit-KeywordsList: __;_e\n"
    1616"X-Poedit-SourceCharset: UTF-8\n"
     
    2626msgstr "متن چند خطی"
    2727
    28 #: class-fields-generator.php:30 class-fields-generator.php:460
     28#: class-fields-generator.php:30 class-fields-generator.php:458
    2929msgid "Checkbox"
    3030msgstr "گزینه انتخابی"
    3131
    32 #: class-fields-generator.php:34 class-fields-generator.php:447
     32#: class-fields-generator.php:34 class-fields-generator.php:445
    3333msgid "Paragraph"
    3434msgstr "پاراگراف"
    3535
    36 #: class-fields-generator.php:42
     36#: class-fields-generator.php:38
    3737msgid "ComboBox"
    3838msgstr "لیست باز شو"
    3939
    40 #: class-fields-generator.php:211
     40#: class-fields-generator.php:210
    4141msgid "+Add Field"
    4242msgstr "+افزودن فیلد"
    4343
    44 #: class-fields-generator.php:216
     44#: class-fields-generator.php:215
    4545msgid "Click to add new field"
    4646msgstr "برای افزودن فیلد جدید کلیک کنید"
    4747
    48 #: class-fields-generator.php:253
     48#: class-fields-generator.php:252
    4949msgid "Save"
    5050msgstr "ذخیره"
    5151
    52 #: class-fields-generator.php:286 class-fields-generator.php:300
     52#: class-fields-generator.php:285 class-fields-generator.php:299
    5353msgid "Are You Sure?"
    5454msgstr "برای حذف مطمئن هستید؟"
    5555
    56 #: class-fields-generator.php:347
     56#: class-fields-generator.php:345
    5757msgid "Untitled"
    5858msgstr "بدون عنوان"
    5959
    60 #: class-fields-generator.php:351
     60#: class-fields-generator.php:349
    6161msgid "Field Type"
    6262msgstr "انتخاب نوع فیلد"
    6363
    64 #: class-fields-generator.php:353
     64#: class-fields-generator.php:351
    6565msgid "Select Field Type"
    6666msgstr "انتخاب نوع فیلد"
    6767
    68 #: class-fields-generator.php:363
     68#: class-fields-generator.php:361
    6969msgid "General"
    7070msgstr "تنظیمات عمومی"
    7171
    72 #: class-fields-generator.php:364
     72#: class-fields-generator.php:362
    7373msgid "Field Name"
    7474msgstr "نام فیلد"
    7575
    76 #: class-fields-generator.php:369
     76#: class-fields-generator.php:367
    7777msgid "Required?"
    78 msgstr "(الزامی)"
     78msgstr "الزامی ؟"
    7979
    80 #: class-fields-generator.php:377
     80#: class-fields-generator.php:375
    8181msgid "Show in edd admin table?"
    8282msgstr "نمایش در جداول ادمین؟"
    8383
    84 #: class-fields-generator.php:385
     84#: class-fields-generator.php:383
    8585msgid "Description"
    8686msgstr "توضیحات"
    8787
    88 #: class-fields-generator.php:389
     88#: class-fields-generator.php:387
    8989msgid "Custom ID"
    9090msgstr "آی دی اختصاصی"
    9191
    92 #: class-fields-generator.php:392
     92#: class-fields-generator.php:390
    9393msgid "to match with any older functions.php codes"
    9494msgstr ""
     
    9696"استفاده کنید آی دی آن را وارد کنید"
    9797
    98 #: class-fields-generator.php:400 class-fields-generator.php:420
     98#: class-fields-generator.php:398 class-fields-generator.php:418
    9999msgid "Textbox"
    100100msgstr "متن تک خطی"
    101101
    102 #: class-fields-generator.php:402 class-fields-generator.php:422
     102#: class-fields-generator.php:400 class-fields-generator.php:420
    103103msgid "Default Value"
    104104msgstr "مقدار پیش فرض"
    105105
    106 #: class-fields-generator.php:409 class-fields-generator.php:428
     106#: class-fields-generator.php:407 class-fields-generator.php:426
    107107msgid "Placeholder"
    108108msgstr "عنوان نگه دارنده"
    109109
    110 #: class-fields-generator.php:435
     110#: class-fields-generator.php:433
    111111msgid "ReadOnly"
    112 msgstr ""
     112msgstr "فقط خواندنی"
    113113
    114 #: class-fields-generator.php:449
     114#: class-fields-generator.php:447
    115115msgid "Content"
    116116msgstr "محتوا"
    117117
    118 #: class-fields-generator.php:469
     118#: class-fields-generator.php:467
    119119msgid "Combobox"
    120120msgstr "لیست باز شو"
    121121
    122 #: index.php:52
     122#: index.php:59
    123123msgid "EDD custom checkout fields"
    124124msgstr "فیلد سفارشی برای فرم خرید EDD"
    125125
    126 #: index.php:53
     126#: index.php:60
     127msgid "Custom checkout fields for EDD"
     128msgstr "فیلد سفارشی برای فرم خرید EDD"
     129
     130#: index.php:61
    127131msgid "Add custom fields to edd checkout form"
    128132msgstr "به فرم پرداخت خرید در EDD فیلدهای دلخواه اضافه کنید."
    129133
    130 #: index.php:64
     134#: index.php:72
    131135msgid "checkout fields"
    132136msgstr "فیلد های پرداخت"
    133137
    134 #: index.php:155
     138#: index.php:193
    135139msgid "select one"
    136140msgstr "فقط خواندنی"
    137141
    138 #: index.php:190
     142#: index.php:228
    139143msgid "Please check out this field"
    140144msgstr "لطفا در پر کردن این فیلد دقت کنید"
    141145
    142 #: index.php:232
     146#: index.php:270
    143147msgid "Please Fill This Field:"
    144148msgstr "لطفا در پر کردن این فیلد دقت کنید:"
    145149
    146 #: index.php:241
     150#: index.php:279
    147151msgid "Please Check This Field Value:"
    148152msgstr "لطفا در پر کردن این فیلد دقت کنید:"
    149153
    150 #: index.php:305
     154#: index.php:342 index.php:345
    151155msgid "Other Information"
    152156msgstr "اطلاعات دیگر"
    153157
    154 #: index.php:461
     158#: index.php:523
    155159msgid "Optional"
    156160msgstr "اختیاری"
  • edd-custom-checkout-fields/trunk/readme.txt

    r2763952 r3365148  
    1 === EDD custom checkout fields ===
     1=== Custom checkout fields for EDD ===
    22Contributors: goback2
    3 Donate link: http://wp-master.ir
     3Donate link: https://wp-master.ir/pay
    44Tags: edd,easy digital downloads,edd custom field,custom checkout,checkout
    55Requires at least: 4.6
    6 Tested up to: 6.0.1
    7 Stable tag: trunk
     6Tested up to: 6.8.2
     7Stable tag: 1.4.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 By **EDD custom checkout fields** , you can add custom fields to the EDD checkout page and get information from users.
     15By **Custom checkout fields for EDD** , you can add custom fields to the EDD checkout page and get information from users.
    1616
    1717Supported fields:
Note: See TracChangeset for help on using the changeset viewer.