Plugin Directory


Ignore:
Location:
buddyforms/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • buddyforms/trunk/BuddyForms.php

    r3031945 r3046092  
    11<?php
    22
    33if ( !defined( 'ABSPATH' ) ) {
    44    exit;
    55}
    66/**
    77 * Plugin Name: BuddyForms
    88 * Plugin URI:  https://themekraft.com/buddyforms/
    99 * Description: Contact Forms, Post Forms for User Generated Content and Registration Forms easily build in minutes. Ideal for User Submitted Posts. Extendable with Addons!
    10  * Version: 2.8.7
     10 * Version: 2.8.8
    1111 * Author: ThemeKraft
    1212 * Author URI: https://themekraft.com/buddyforms/
    1313 * Licence: GPLv3
    1414 * Network: false
    1515 * Text Domain: buddyforms
    1616 * Domain Path: /languages
    1717 * Svn: buddyforms
    1818 *
    1919 *
    2020 * ****************************************************************************
    2121 *
    2222 * This script is free software; you can redistribute it and/or modify
    2323 * it under the terms of the GNU General Public License as published by
    2424 * the Free Software Foundation; either version 2 of the License, or
    2525 * (at your option) any later version.
    2626 *
    2727 * This program is distributed in the hope that it will be useful,
    2828 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2929 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
    3030 * GNU General Public License for more details.
    3131 *
    3232 * You should have received a copy of the GNU General Public License
    3333 * along with this program; if not, write to the Free Software
    3434 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA    02111-1307    USA
    3535 *
    3636 * ***************************************************************************
    3737 */
    3838
    3939if ( !class_exists( 'BuddyForms' ) ) {
    4040    /**
    4141     * Class BuddyForms
    4242     */
    4343    class BuddyForms
    4444    {
    4545        /**
    4646         * @var string
    4747         */
    48         public  $version = '2.8.7' ;
     48        public  $version = '2.8.8' ;
    4949        /**
    5050         * @var array Frontend Global JS parameters
    5151         */
    5252        private static  $global_js_parameters ;
    5353        /**
    5454         * Initiate the class
    5555         *
    5656         * @package buddyforms
    5757         * @since 0.1-beta
    5858         */
    5959        public function __construct()
    6060        {
    6161            global  $wp_session ;
    6262            register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) );
    6363            $this->load_constants();
    6464            add_action(
    6565                'init',
    6666                array( $this, 'init_hook' ),
    6767                1,
    6868                1
    6969            );
    7070            require_once BUDDYFORMS_INCLUDES_PATH . '/form/form-assets.php';
    7171            new BuddyFormsAssets();
    7272            add_action(
    7373                'init',
    7474                array( $this, 'includes' ),
    7575                4,
    7676                1
    7777            );
    7878            add_action( 'init', array( $this, 'update_db_check' ), 10 );
    7979            add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
    8080            register_deactivation_hook( __FILE__, array( $this, 'plugin_deactivation' ) );
    8181        }
    8282       
    8383        /**
    8484         * Defines constants needed throughout the plugin.
    8585         *
    8686         * These constants can be overridden in bp-custom.php or wp-config.php.
    8787         *
    8888         * @package buddyforms
    8989         * @since 0.1-beta
    9090         */
    9191        public function load_constants()
    9292        {
    9393            /**
    9494             * Define the plugin version
    9595             */
    9696            define( 'BUDDYFORMS_VERSION', $this->version );
    9797            if ( !defined( 'BUDDYFORMS_PLUGIN_URL' ) ) {
    9898                /**
    9999                 * Define the plugin url
    100100                 */
    101101                define( 'BUDDYFORMS_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
    102102            }
    103103            if ( !defined( 'BUDDYFORMS_INSTALL_PATH' ) ) {
    104104                /**
    105105                 * Define the install path
    106106                 */
    107107                define( 'BUDDYFORMS_INSTALL_PATH', dirname( __FILE__ ) . '/' );
    108108            }
    109109            if ( !defined( 'BUDDYFORMS_INCLUDES_PATH' ) ) {
    110110                /**
    111111                 * Define the include path
    112112                 */
    113113                define( 'BUDDYFORMS_INCLUDES_PATH', BUDDYFORMS_INSTALL_PATH . 'includes/' );
    114114            }
    115115            if ( !defined( 'BUDDYFORMS_TEMPLATE_PATH' ) ) {
    116116                /**
    117117                 * Define the template path
    118118                 */
    119119                define( 'BUDDYFORMS_TEMPLATE_PATH', BUDDYFORMS_INSTALL_PATH . 'templates/' );
    120120            }
    121121            if ( !defined( 'BUDDYFORMS_ADMIN_VIEW' ) ) {
    122122                /**
    123123                 * Define the template path
    124124                 */
    125125                define( 'BUDDYFORMS_ADMIN_VIEW', BUDDYFORMS_INCLUDES_PATH . 'admin/view/' );
    126126            }
    127127            if ( !defined( 'BUDDYFORMS_ASSETS' ) ) {
    128128                /**
    129129                 * Define the template path
    130130                 */
    131131                define( 'BUDDYFORMS_ASSETS', plugins_url( 'assets/', __FILE__ ) );
    132132            }
    133133        }
    134134       
    135135        /**
    136136         * Defines buddyforms_init action
    137137         *
    138138         * This action fires on WP's init action and provides a way for the rest of WP,
    139139         * as well as other dependent plugins, to hook into the loading process in an
    140140         * orderly fashion.
    141141         *
    142142         * @package buddyforms
    143143         * @since 0.1-beta
    144144         */
    145145        public function init_hook()
    146146        {
    147147            $this->set_globals();
    148148            do_action( 'buddyforms_init' );
    149149           
    150150            if ( function_exists( 'buddyforms_core_fs' ) ) {
    151151                $bf_fr = buddyforms_core_fs();
    152152                if ( !empty($bf_fr) ) {
    153153                    $bf_fr->add_filter( 'plugin_icon', array( $this, 'buddyforms_freemius_icon' ) );
    154154                }
    155155            }
    156156       
    157157        }
    158158       
    159159        public function buddyforms_freemius_icon()
    160160        {
    161161            return BUDDYFORMS_INSTALL_PATH . 'assets/images/buddyforms.jpg';
    162162        }
    163163       
    164164        /**
    165165         * Enable the localization of the fields adding the strings to js and hold the global localization
    166166         *
    167167         * @return array
    168168         */
    169169        public static function localize_fields()
    170170        {
    171171            return apply_filters( 'buddyforms_field_localization', array(
    172172                'error_strings' => array(
    173173                'error_string_start'    => __( 'The following', 'buddyforms' ),
    174174                'error_string_singular' => __( 'error was', 'buddyforms' ),
    175175                'error_string_plural'   => __( 'errors were', 'buddyforms' ),
    176176                'error_string_end'      => __( 'found: ', 'buddyforms' ),
    177177            ),
    178178                'bf_trans'      => array(
    179179                array(
    180180                'msgid'  => 'The following',
    181181                'msgstr' => __( 'The following', 'buddyforms' ),
    182182            ),
    183183                array(
    184184                'msgid'  => 'error was',
    185185                'msgstr' => __( 'error was', 'buddyforms' ),
    186186            ),
    187187                array(
    188188                'msgid'  => 'errors were',
    189189                'msgstr' => __( 'errors were', 'buddyforms' ),
    190190            ),
    191191                array(
    192192                'msgid'  => 'found: ',
    193193                'msgstr' => __( 'found: ', 'buddyforms' ),
    194194            ),
    195195                array(
    196196                'msgid'  => 'Delete Permanently',
    197197                'msgstr' => __( 'Delete Permanently', 'buddyforms' ),
    198198            ),
    199199                array(
    200200                'msgid'  => 'Use a few words, avoid common phrases',
    201201                'msgstr' => __( 'Use a few words, avoid common phrases', 'buddyforms' ),
    202202            ),
    203203                array(
    204204                'msgid'  => 'No need for symbols, digits, or uppercase letters',
    205205                'msgstr' => __( 'No need for symbols, digits, or uppercase letters', 'buddyforms' ),
    206206            ),
    207207                array(
    208208                'msgid'  => 'Add another word or two. Uncommon words are better.',
    209209                'msgstr' => __( 'Add another word or two. Uncommon words are better.', 'buddyforms' ),
    210210            ),
    211211                array(
    212212                'msgid'  => 'Straight rows of keys are easy to guess',
    213213                'msgstr' => __( 'Short keyboard patterns are easy to guess', 'buddyforms' ),
    214214            ),
    215215                array(
    216216                'msgid'  => 'Short keyboard patterns are easy to guess',
    217217                'msgstr' => __( 'Short keyboard patterns are easy to guess', 'buddyforms' ),
    218218            ),
    219219                array(
    220220                'msgid'  => 'Use a longer keyboard pattern with more turns',
    221221                'msgstr' => __( 'Use a longer keyboard pattern with more turns', 'buddyforms' ),
    222222            ),
    223223                array(
    224224                'msgid'  => 'Repeats like "aaa" are easy to guess',
    225225                'msgstr' => __( 'Repeats like "aaa" are easy to guess', 'buddyforms' ),
    226226            ),
    227227                array(
    228228                'msgid'  => 'Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
    229229                'msgstr' => __( 'Repeats like "abcabcabc" are only slightly harder to guess than "abc"', 'buddyforms' ),
    230230            ),
    231231                array(
    232232                'msgid'  => 'Avoid repeated words and characters',
    233233                'msgstr' => __( 'Avoid repeated words and characters', 'buddyforms' ),
    234234            ),
    235235                array(
    236236                'msgid'  => 'Sequences like abc or 6543 are easy to guess',
    237237                'msgstr' => __( 'Sequences like abc or 6543 are easy to guess', 'buddyforms' ),
    238238            ),
    239239                array(
    240240                'msgid'  => 'Recent years are easy to guess',
    241241                'msgstr' => __( 'Recent years are easy to guess', 'buddyforms' ),
    242242            ),
    243243                array(
    244244                'msgid'  => 'Avoid recent years',
    245245                'msgstr' => __( 'Avoid recent years', 'buddyforms' ),
    246246            ),
    247247                array(
    248248                'msgid'  => 'Avoid years that are associated with you',
    249249                'msgstr' => __( 'Avoid years that are associated with you', 'buddyforms' ),
    250250            ),
    251251                array(
    252252                'msgid'  => 'Dates are often easy to guess',
    253253                'msgstr' => __( 'Dates are often easy to guess', 'buddyforms' ),
    254254            ),
    255255                array(
    256256                'msgid'  => 'Avoid dates and years that are associated with you',
    257257                'msgstr' => __( 'Avoid dates and years that are associated with you', 'buddyforms' ),
    258258            ),
    259259                array(
    260260                'msgid'  => 'This is a top-10 common password',
    261261                'msgstr' => __( 'This is a top-10 common password', 'buddyforms' ),
    262262            ),
    263263                array(
    264264                'msgid'  => 'This is a top-100 common password',
    265265                'msgstr' => __( 'This is a top-100 common password', 'buddyforms' ),
    266266            ),
    267267                array(
    268268                'msgid'  => 'This is a very common password',
    269269                'msgstr' => __( 'This is a very common password', 'buddyforms' ),
    270270            ),
    271271                array(
    272272                'msgid'  => 'This is similar to a commonly used password',
    273273                'msgstr' => __( 'This is similar to a commonly used password', 'buddyforms' ),
    274274            ),
    275275                array(
    276276                'msgid'  => 'A word by itself is easy to guess',
    277277                'msgstr' => __( 'A word by itself is easy to guess', 'buddyforms' ),
    278278            ),
    279279                array(
    280280                'msgid'  => 'Names and surnames by themselves are easy to guess',
    281281                'msgstr' => __( 'Names and surnames by themselves are easy to guess', 'buddyforms' ),
    282282            ),
    283283                array(
    284284                'msgid'  => 'Common names and surnames are easy to guess',
    285285                'msgstr' => __( 'Common names and surnames are easy to guess', 'buddyforms' ),
    286286            ),
    287287                array(
    288288                'msgid'  => 'Capitalization doesn\'t help very much',
    289289                'msgstr' => __( 'Capitalization doesn\'t help very much', 'buddyforms' ),
    290290            ),
    291291                array(
    292292                'msgid'  => 'All-uppercase is almost as easy to guess as all-lowercase',
    293293                'msgstr' => __( 'All-uppercase is almost as easy to guess as all-lowercase', 'buddyforms' ),
    294294            ),
    295295                array(
    296296                'msgid'  => 'Reversed words aren\'t much harder to guess',
    297297                'msgstr' => __( 'Reversed words aren\'t much harder to guess', 'buddyforms' ),
    298298            ),
    299299                array(
    300300                'msgid'  => 'Predictable substitutions like \'@\' instead of \'a\' don\'t help very much',
    301301                'msgstr' => __( 'Predictable substitutions like \'@\' instead of \'a\' don\'t help very much', 'buddyforms' ),
    302302            ),
    303303                array(
    304304                'msgid'  => 'Avoid sequences',
    305305                'msgstr' => __( 'Avoid sequences', 'buddyforms' ),
    306306            ),
    307307                array(
    308308                'msgid'  => 'Warning: ',
    309309                'msgstr' => __( 'Warning: ', 'buddyforms' ),
    310310            ),
    311311                array(
    312312                'msgid'  => 'Suggestions: ',
    313313                'msgstr' => __( 'Suggestions: ', 'buddyforms' ),
    314314            )
    315315            ),
    316316            ) );
    317317        }
    318318       
    319319        /**
    320320         * Hold the global variables to put in the frontend
    321321         *
    322322         * @param $array
    323323         *
    324324         * @return array
    325325         */
    326326        public static function buddyforms_js_global_set_parameters( $array )
    327327        {
    328328           
    329329            if ( !empty(self::$global_js_parameters) ) {
    330330                self::$global_js_parameters = array_merge( $array, self::$global_js_parameters );
    331331            } else {
    332332                self::$global_js_parameters = $array;
    333333            }
    334334           
    335335            return self::$global_js_parameters;
    336336        }
    337337       
    338338        /**
    339339         * Get the global variables to put in the frontend
    340340         *
    341341         * @param string $form_slug
    342342         *
    343343         * @return array
    344344         */
    345345        public static function buddyforms_js_global_get_parameters( $form_slug = '' )
    346346        {
    347347            return apply_filters( 'buddyforms_js_parameters', self::$global_js_parameters, $form_slug );
    348348        }
    349349       
    350350        /**
    351351         * Setup all globals
    352352         *
    353353         * @package buddyforms
    354354         * @since 0.1-beta
    355355         */
    356356        static function set_globals()
    357357        {
    358358            global  $buddyforms ;
    359359            /*
    360360             * Get BuddyForms options
    361361             *
    362362             * @filter: buddyforms_set_globals
    363363             *
    364364             */
    365365            $buddyforms = apply_filters( 'buddyforms_set_globals', get_option( 'buddyforms_forms' ) );
    366366            return $buddyforms;
    367367        }
    368368       
    369369        /**
    370370         * Include files needed by BuddyForms
    371371         *
    372372         * @package buddyforms
    373373         * @since 0.1-beta
    374374         */
    375375        public function includes()
    376376        {
    377377            require_once BUDDYFORMS_INSTALL_PATH . '/vendor-scope/buddyforms/vendor/autoload.php';
    378378            require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Encoding.php';
    379379           
    380380            if ( !function_exists( 'PFBC_Load' ) ) {
    381381                require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Form.php';
    382382                require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/FieldControl.php';
    383383                new FieldControl();
    384384                $global_error = ErrorHandler::get_instance();
    385385            }
    386386           
    387387            require_once BUDDYFORMS_INCLUDES_PATH . '/admin/class-bf-admin-notices.php';
    388388            new BfAdminNotices();
    389389            require_once BUDDYFORMS_INCLUDES_PATH . '/admin/register-post-types.php';
    390390            require_once BUDDYFORMS_INCLUDES_PATH . '/admin/admin-analytics.php';
    391391            // Compatibility
    392392            require_once BUDDYFORMS_INCLUDES_PATH . 'compatibility.php';
    393393            require_once BUDDYFORMS_INCLUDES_PATH . 'functions.php';
    394394            require_once BUDDYFORMS_INCLUDES_PATH . 'gdpr.php';
    395395            require_once BUDDYFORMS_INCLUDES_PATH . 'change-password.php';
    396396            require_once BUDDYFORMS_INCLUDES_PATH . 'multisite.php';
    397397            require_once BUDDYFORMS_INCLUDES_PATH . 'the-content.php';
    398398            require_once BUDDYFORMS_INCLUDES_PATH . 'rewrite-roles.php';
    399399            require_once BUDDYFORMS_INCLUDES_PATH . 'shortcodes.php';
    400400            require_once BUDDYFORMS_INCLUDES_PATH . 'wp-mail.php';
    401401            require_once BUDDYFORMS_INCLUDES_PATH . 'wp-insert-user.php';
    402402            require_once BUDDYFORMS_INCLUDES_PATH . 'revisions.php';
    403403            // Gutenberg
    404404            require_once BUDDYFORMS_INCLUDES_PATH . 'gutenberg/gutenberg.php';
    405405            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form.php';
    406406            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-preview.php';
    407407            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-render.php';
    408408            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-ajax.php';
    409409            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-elements.php';
    410410            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-control.php';
    411411            require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-validation.php';
    412412            require_once BUDDYFORMS_INCLUDES_PATH . '/admin/user-meta.php';
    413413           
    414414            if ( is_admin() ) {
    415415                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/form-builder-elements.php';
    416416                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/form-templates.php';
    417417                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/admin-ajax.php';
    418418                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/welcome-screen.php';
    419419                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/pricing-screen.php';
    420420                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/submissions.php';
    421421                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/settings.php';
    422422                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/password-strengh-settings.php';
    423423                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/functions.php';
    424424                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/deregister.php';
    425425                // GDPR
    426426                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/personal-data-exporter.php';
    427427                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/personal-data-eraser.php';
    428428                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/mce-editor-button.php';
    429429                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-mail-notification.php';
    430430                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-permissions.php';
    431431                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-layout.php';
    432432                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-registration.php';
    433433                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-shortcodes.php';
    434434                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-select-form.php';
    435435                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-elements.php';
    436436                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-setup.php';
    437437                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-header.php';
    438438                require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-footer.php';
    439439            }
    440440       
    441441        }
    442442       
    443443        /**
    444444         * Load the textdomain for the plugin
    445445         *
    446446         * @package buddyforms
    447447         * @since 0.1-beta
    448448         */
    449449        public function load_plugin_textdomain()
    450450        {
    451451            load_plugin_textdomain( 'buddyforms', false, basename( dirname( __FILE__ ) ) . '/languages' );
    452452        }
    453453       
    454454        /**
    455455         * Update form 1.x version
    456456         *
    457457         * @package buddyforms
    458458         * @since 2.0
    459459         */
    460460        function update_db_check()
    461461        {
    462462            if ( !is_admin() ) {
    463463                return;
    464464            }
    465465            $buddyforms_old = get_option( 'buddyforms_options' );
    466466            if ( !$buddyforms_old ) {
    467467                return;
    468468            }
    469469            update_option( 'buddyforms_options_old', $buddyforms_old );
    470470            foreach ( $buddyforms_old['buddyforms'] as $key => $form ) {
    471471                $bf_forms_args = array(
    472472                    'post_title'  => $form['name'],
    473473                    'post_type'   => 'buddyforms',
    474474                    'post_status' => 'publish',
    475475                );
    476476                // Insert the new form
    477477                $post_id = wp_insert_post( $bf_forms_args, true );
    478478                $form['id'] = $post_id;
    479479                update_post_meta( $post_id, '_buddyforms_options', $form );
    480480                // Update the option _buddyforms_forms used to reduce queries
    481481                $buddyforms_forms = get_option( 'buddyforms_forms' );
    482482                $buddyforms_forms[$form['slug']] = $form;
    483483                update_option( 'buddyforms_forms', $buddyforms_forms );
    484484            }
    485485            update_option( 'buddyforms_version', BUDDYFORMS_VERSION );
    486486            delete_option( 'buddyforms_options' );
    487487            buddyforms_attached_page_rewrite_rules( true );
    488488        }
    489489       
    490490        /**
    491491         * Plugin activation
    492492         *
    493493         * @since  2.0
    494494         */
    495495        function plugin_activation()
    496496        {
    497497            $title = apply_filters( 'buddyforms_preview_page_title', __( 'BuddyForms Preview Page', 'buddyforms' ) );
    498498            $preview_page = get_page_by_title( $title );
    499499           
    500500            if ( !$preview_page ) {
    501501                // Create preview page object
    502502                $preview_post = array(
    503503                    'post_title'   => $title,
    504504                    'post_content' => __( 'This is a preview of how this form will appear on your website', 'buddyforms' ),
    505505                    'post_status'  => 'draft',
    506506                    'post_type'    => 'page',
    507507                    'post_name'    => sanitize_title( 'BuddyForms Preview Page' ),
    508508                );
    509509                // Insert the page into the database
    510510                $page_id = wp_insert_post( $preview_post );
    511511            } else {
    512512                $page_id = $preview_page->ID;
    513513            }
    514514           
    515515            update_option( 'buddyforms_preview_page', $page_id );
    516516            $title = apply_filters( 'buddyforms_submissions_page_title', __( 'BuddyForms Submissions Page', 'buddyforms' ) );
    517517            $submissions_page = get_page_by_title( $title );
    518518           
    519519            if ( !$submissions_page ) {
    520520                // Create submissions page object
    521521                $preview_post = array(
    522522                    'post_title'   => $title,
    523523                    'post_content' => __( 'This is the default page use like endpoint to the page submissions', 'buddyforms' ),
    524524                    'post_status'  => 'publish',
    525525                    'post_type'    => 'page',
    526526                    'post_name'    => sanitize_title( 'BuddyForms Submissions Page' ),
    527527                );
    528528                // Insert the page into the database
    529529                $page_id = wp_insert_post( $preview_post );
    530530            } else {
    531531                $page_id = $submissions_page->ID;
    532532            }
    533533           
    534534            update_option( 'buddyforms_submissions_page', $page_id );
    535535            update_option( 'buddyforms_first_path_after_install', 'edit.php?post_type=buddyforms&page=buddyforms_welcome_screen' );
    536536            set_transient( '_buddyforms_welcome_screen_activation_redirect', true, 30 );
    537537            $registration_gdpr_template = __( "By signing up on our site you agree to our terms and conditions [link]. We'll create a new user account for you based on your submissions. All data you submit will be stored on our servers.After your registration we'll instantly send you an email with an activation link to verify your mail address. ", 'buddyforms' );
    538538            $post_gdpr_template = __( 'By submitting this form you grant us the rights <br>• to store your submitted contents in our database <br>• to generate a post on our site based on your data <br>• to make this post publicly accessible ', 'buddyforms' );
    539539            $contact_gdpr_template = __( 'By submitting these data you agree that we store all the data from the form our server. We may answer you via mail.', 'buddyforms' );
    540540            $buddyforms_gdpr = array();
    541541            $buddyforms_gdpr['templates']['registration'] = $registration_gdpr_template;
    542542            $buddyforms_gdpr['templates']['post'] = $post_gdpr_template;
    543543            $buddyforms_gdpr['templates']['contact'] = $contact_gdpr_template;
    544544            $buddyforms_gdpr['templates']['other'] = '';
    545545            update_option( 'buddyforms_gdpr', $buddyforms_gdpr );
    546546        }
    547547       
    548548        /**
    549549         * Plugin deactivation
    550550         *
    551551         * @since  2.0
    552552         */
    553553        function plugin_deactivation()
    554554        {
    555555            $buddyforms_page = get_option( 'buddyforms_preview_page', true );
    556556            wp_delete_post( $buddyforms_page, true );
    557557            delete_option( 'buddyforms_preview_page' );
    558558            $buddyforms_page = get_option( 'buddyforms_submissions_page', true );
    559559            wp_delete_post( $buddyforms_page, true );
    560560            delete_option( 'buddyforms_submissions_page' );
    561561        }
    562562       
    563563        public static function error_log( $message )
    564564        {
    565565            if ( !empty($message) ) {
    566566                error_log( 'buddyforms -- ' . $message );
    567567            }
    568568        }
    569569   
    570570    }
    571571    /**
    572572     * Create a helper function for easy SDK access.
    573573     *
    574574     * @return Freemius
    575575     */
    576576    function buddyforms_core_fs()
    577577    {
    578578        global  $buddyforms_core_fs ;
    579579        try {
    580580            $first_path = get_option( 'buddyforms_first_path_after_install' );
    581581           
    582582            if ( !isset( $buddyforms_core_fs ) ) {
    583583                // Include Freemius SDK.
    584584                require_once dirname( __FILE__ ) . '/includes/resources/freemius/start.php';
    585585                $buddyforms_core_fs = fs_dynamic_init( array(
    586586                    'id'                             => '391',
    587587                    'slug'                           => 'buddyforms',
    588588                    'type'                           => 'plugin',
    589589                    'public_key'                     => 'pk_dea3d8c1c831caf06cfea10c7114c',
    590590                    'is_premium'                     => false,
    591591                    'has_addons'                     => true,
    592592                    'has_paid_plans'                 => true,
    593593                    'trial'                          => array(
    594594                    'days'               => 7,
    595595                    'is_require_payment' => true,
    596596                ),
    597597                    'has_affiliation'                => 'selected',
    598598                    'menu'                           => array(
    599599                    'slug'        => 'edit.php?post_type=buddyforms',
    600600                    'first-path'  => $first_path,
    601601                    'support'     => false,
    602602                    'contact'     => true,
    603603                    'addons'      => true,
    604604                    'affiliation' => false,
    605605                ),
    606606                    'bundle_license_auto_activation' => true,
    607607                    'is_live'                        => true,
    608608                ) );
    609609            }
    610610           
    611611            // Signal that parent SDK was initiated.
    612612            do_action( 'buddyforms_core_fs_loaded' );
    613613        } catch ( Freemius_Exception $e ) {
    614614        }
    615615        return $buddyforms_core_fs;
    616616    }
    617617   
    618618    function buddyforms_php_version_admin_notice()
    619619    {
    620620        ?>
    621621        <div class="notice notice-error is-dismissible">
    622622            <p><?php
    623623        esc_html_e( 'PHP Version Update Required!', 'buddyforms' );
    624624        ?></p>
    625625            <p><?php
    626626        esc_html_e( 'You are using PHP Version ' . PHP_VERSION, 'buddyforms' );
    627627        ?></p>
    628628            <p><?php
    629629        esc_html_e( 'Please make sure you have at least php version 5.3 installed.', 'buddyforms' );
    630630        ?></p>
    631631        </div>
    632632        <?php
    633633    }
    634634   
    635635    function activate_buddyform_at_plugin_loader()
    636636    {
    637637        // BuddyForms requires php version 5.3 or higher.
    638638       
    639639        if ( PHP_VERSION < 5.3 ) {
    640640            add_action( 'admin_notices', 'buddyforms_php_version_admin_notice' );
    641641        } else {
    642642            // Init BuddyForms.
    643643            $GLOBALS['buddyforms_new'] = new BuddyForms();
    644644            // Init Freemius.
    645645            buddyforms_core_fs();
    646646            // GDPR Admin Notice
    647647            buddyforms_core_fs()->add_filter( 'handle_gdpr_admin_notice', '__return_true' );
    648648        }
    649649   
    650650    }
    651651   
    652652    activate_buddyform_at_plugin_loader();
    653653}
  • buddyforms/trunk/assets/admin/js/admin.js

    r3031945 r3046092  
    11(function ($) {
    22    $.getStylesheet = function (href) {
    33        var $d = $.Deferred();
    44        var $link = $('<link/>', {
    55            rel: 'stylesheet',
    66            type: 'text/css',
    77            href: href
    88        }).appendTo('head');
    99        $d.resolve($link);
    1010        return $d.promise();
    1111    };
    1212})(jQuery);
    1313
    1414function createNewPageOpenModal(e) {
    1515    var dialog = jQuery('<div></div>').dialog({
    1616        modal: true,
    1717        title: "Info",
    1818        open: function () {
    1919            var markup = 'Name your Page' +
    2020                '<input id="bf_create_page_name" type="text" value="">';
    2121            jQuery(this).html(markup);
    2222        },
    2323        buttons: {
    2424            'Add': function () {
    2525                var page_name = jQuery('#bf_create_page_name').val();
    2626                dialog.html('<span class="spinner is-active"></span>');
    2727                if (buddyformsGlobal) {
    2828                    jQuery.ajax({
    2929                        type: 'POST',
    3030                        dataType: "json",
    3131                        url: buddyformsGlobal.admin_url,
    3232                        data: {
    3333                            "action": "buddyforms_new_page",
    34                             "page_name": page_name
     34                            "page_name": page_name,
     35                            "nonce": buddyformsGlobal.ajaxnonce // Add the nonce parameter
    3536                        },
    3637                        success: function (data) {
    3738                            if (data['error']) {
    3839                                console.log(data['error']);
    3940                            } else {
    4041                                jQuery('#attached_page').append(jQuery('<option>', {
    4142                                    value: data['id'],
    4243                                    text: data['name']
    4344                                }));
    4445                                jQuery('#attached_page').val(data['id']);
    4546                            }
    4647                            dialog.dialog("close");
    4748                        },
    4849                        error: function () {
    4950                            dialog.dialog("close");
    5051                        }
    5152                    });
    5253                }
    5354            }
    5455        }
    5556    });
    5657    e.preventDefault();
    5758    return false;
    5859}
    5960
    6061//
    6162// Helper function to get the post id from url
    6263//
    6364var bf_getUrlParameter = function bf_getUrlParameter(sParam) {
    6465    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
    6566        sURLVariables = sPageURL.split('&'),
    6667        sParameterName,
    6768        i;
    6869
    6970    for (i = 0; i < sURLVariables.length; i++) {
    7071        sParameterName = sURLVariables[i].split('=');
    7172
    7273        if (sParameterName[0] === sParam) {
    7374            return sParameterName[1] === undefined ? true : sParameterName[1];
    7475        }
    7576    }
    7677};
    7778
    7879//
    7980// Generate a custom string to append to the field slug in case of duplicate
    8081//
    8182function buddyformsMakeFieldId() {
    8283    var text = "";
    8384    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    8485
    8586    for (var i = 0; i < 5; i++)
    8687        text += possible.charAt(Math.floor(Math.random() * possible.length));
    8788
    8889    return text;
    8990}
    9091
    9192//
    9293// Autofill empty slug's fields
    9394// or append hashes to duplicate ones
    9495//
    9596function buddyformAutoFillEmptyOrDuplicateSlugs() {
    9697    var findFieldsSlugs = jQuery("#post input[name^='buddyforms_options[form_fields]'][name$='[slug]'][type!='hidden']");
    9798    findFieldsSlugs.each(function () {
    9899        var fieldSlugs = jQuery(this);
    99100        if (!fieldSlugs.val()) {
    100101            console.log('empty field slug');
    101102            var field_id = fieldSlugs.attr('data');
    102103            var fieldContainer = jQuery('li#field_' + field_id);
    103104            if (fieldContainer && fieldContainer.length > 0) {
    104105                var fieldNameValue = fieldContainer.find('tr.use_as_slug input[name="buddyforms_options[form_fields][' + field_id + '][name]"]').val();
    105106                if (fieldNameValue) {
    106107                    var slugFromName = slug(fieldNameValue, {lower: false});
    107108                    fieldContainer.find('tr.slug' + field_id + ' input[name="buddyforms_options[form_fields][' + field_id + '][slug]"]').val(slugFromName);
    108109                }
    109110            }
    110111        }
    111112        findFieldsSlugs.each(function () {
    112113            if (jQuery(this).val() === fieldSlugs.val() && fieldSlugs.attr('name') !== jQuery(this).attr('name')) {
    113114                fieldSlugs.val(fieldSlugs.val() + '_' + buddyformsMakeFieldId());
    114115                return false;
    115116            }
    116117        });
    117118    });
    118119}
    119120
    120121//
    121122// Validate an email using regex
    122123//
    123124function buddyformsIsEmailOrShortcode(email) {
    124125    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})|\[(.*?)(\s.*?)?\]$/;
    125126    return regex.test(email);
    126127}
    127128
    128129//
    129130// Validate multiples email address separated by coma
    130131//
    131132function buddyformsValidateMultiEmail(string) {
    132133    var result = true;
    133134    if (string) {
    134135        var isMulti = /[;,]+/.test(string);
    135136        if (isMulti) {
    136137            var values = string.split(/[;,]+/);
    137138            jQuery.each(values, function (index, email) {
    138139                result = buddyformsIsEmailOrShortcode(email.trim());
    139140                if (!result) {
    140141                    return result;
    141142                }
    142143            });
    143144        } else {
    144145            result = buddyformsIsEmailOrShortcode(string);
    145146            if (!result) {
    146147                return result;
    147148            }
    148149        }
    149150    } else {
    150151        result = false;
    151152    }
    152153
    153154    return result;
    154155}
    155156
    156157//
    157158// Validate notification email element
    158159//
    159160function buddyforms_validate_notifications_email(element) {
    160161    if (element) {
    161162        var value = jQuery(element).val();
    162163        if (value) {
    163164            var isValid = buddyformsValidateMultiEmail(jQuery(element).val());
    164165            if (!isValid) {
    165166                jQuery(element)[0].setCustomValidity('Invalid Email(s)');
    166167                jQuery(element).addClass('bf-error');
    167168            } else {
    168169                jQuery(element)[0].setCustomValidity('');
    169170                jQuery(element).removeClass('bf-error');
    170171            }
    171172            return isValid;
    172173        } else {
    173174            jQuery(element)[0].setCustomValidity('');
    174175            jQuery(element).removeClass('bf-error');
    175176        }
    176177    }
    177178    return true;
    178179}
    179180
    180181//
    181182// Update form builder form elements list number 1,2,3,...
    182183//
    183184function bf_update_list_item_number() {
    184185    jQuery(".buddyforms_forms_builder ul").each(function () {
    185186        jQuery(this).children("li").each(function (t) {
    186187            jQuery(this).find("td.field_order .circle").first().html(t + 1)
    187188        })
    188189    })
    189190}
    190191
    191192//
    192193// Helper Function to use dialog instead of alert
    193194//
    194195function bf_alert(alert_message) {
    195196    jQuery('<div></div>').dialog({
    196197        modal: true,
    197198        title: "Info",
    198199        open: function () {
    199200            jQuery(this).html(alert_message);
    200201        },
    201202        buttons: {
    202203            Ok: function () {
    203204                jQuery(this).dialog("close");
    204205            }
    205206        }
    206207    });
    207208}
    208209
    209210// Update ths list number 1,2,3,... for the mail trigger
    210211function bf_update_list_item_number_mail() {
    211212    jQuery("#mailcontainer .bf_trigger_list_item").each(function (t) {
    212213        jQuery(this).find("td.field_order .circle").first().html(t + 1)
    213214    })
    214215}
    215216
    216217function buddyforms_load_select2(element) {
    217218    jQuery.when(jQuery.getStylesheet(buddyformsGlobal.assets.select2_css), jQuery.getScript(buddyformsGlobal.assets.select2_js))
    218219        .then(function () {
    219220            if (jQuery.fn.select2) {
    220221                element.select2({
    221222                    placeholder: "Select an option"
    222223                });
    223224            } else {
    224225                console.log('BF-Error loading select2 assets, please contact support.');
    225226            }
    226227        }, function () {
    227228            console.log('BF-Error loading select2 assets, please contact support.');
    228229        });
    229230}
    230231
    231232function setStatusDateFormat(arg){
    232233    if(arg.checked){
    233234        jQuery('.status-date-format').show();
    234235        jQuery('.status-time-format').show();
    235236    }else{
    236237        jQuery('.status-date-format').hide();
    237238        jQuery('.status-time-format').hide();
    238239    }
    239240
    240241}
    241242
    242243//
    243244// Helper Function to lode form element templates depend on the form type
    244245//
    245246function load_formbuilder_template(template, completeCallBack) {
    246247    var postTitle = jQuery('input#title');
    247248    if (buddyformsGlobal) {
    248249        jQuery.ajax({
    249250            type: 'POST',
    250251            dataType: "json",
    251252            url: buddyformsGlobal.admin_url,
    252253            data: {
    253254                "action": "buddyforms_form_template",
    254255                "template": template,
    255256                "title": postTitle.val()
    256257            },
    257258            success: function (data) {
    258259                jQuery.each(data, function (i, val) {
    259260                    switch (i) {
    260261                        case 'formbuilder':
    261262                            var form_builder = jQuery('.buddyforms_forms_builder');
    262263                            form_builder.replaceWith(val);
    263264                            bf_update_list_item_number();
    264265                            jQuery(document.body).trigger({type: "buddyform:load_fields"});
    265266                            break;
    266267                        case 'mail_notification':
    267268                            jQuery('.buddyforms_accordion_notification').html(val);
    268269                            jQuery('#no-trigger-mailcontainer').hide();
    269270
    270271                            tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + val['trigger_id']);
    271272                            tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + val['trigger_id']);
    272273
    273274                            bf_update_list_item_number_mail();
    274275
    275276                            break;
    276277                        case 'form_setup':
    277278                            jQuery.each(val, function (i2, form_setup) {
    278279                                if (form_setup instanceof Object) {
    279280                                    jQuery.each(form_setup, function (form_setup_key, form_setup_option) {
    280281                                        var element;
    281282                                        if (form_setup_option instanceof Object) {
    282283                                            jQuery.each(form_setup_option, function (form_setup_key2, form_setup_option2) {
    283284                                                element = jQuery('[name="buddyforms_options[' + i2 + '][' + form_setup_key + '][' + form_setup_key2 + ']"]');
    284285                                                buddyform_apply_template_to_element(element, form_setup_option2);
    285286                                            });
    286287                                        } else {
    287288                                            element = jQuery('[name="buddyforms_options[' + i2 + '][' + form_setup_key + ']"]');
    288289                                            buddyform_apply_template_to_element(element, form_setup_option);
    289290                                        }
    290291                                    });
    291292                                }
    292293
    293294                                if (form_setup instanceof Array) {
    294295                                    buddyform_apply_template_to_element(jQuery('[name="buddyforms_options[' + i2 + '][]"]'), form_setup);
    295296                                } else {
    296297                                    buddyform_apply_template_to_element(jQuery('[name="buddyforms_options[' + i2 + ']"]'), form_setup);
    297298                                }
    298299                                // Add Select2 Support
    299300                                var adminSelect2 = jQuery(".bf-select2");
    300301                                if (adminSelect2.length > 0) {
    301302                                    buddyforms_load_select2(adminSelect2);
    302303                                }
    303304                                // Check the form type and only display the relevant form setup tabs
    304305                                from_setup_form_type(jQuery('#bf-form-type-select').val());
    305306                            });
    306307                            break;
    307308                        default:
    308309                            bf_alert(val);
    309310                    }
    310311                });
    311312                tb_remove();
    312313                if (!postTitle.val()) {
    313314                    postTitle.val(buddyformsMakeFieldId());
    314315                    jQuery('input#title').focus();
    315316                    jQuery('#title-prompt-text').addClass('screen-reader-text');
    316317                }
    317318                jQuery('[name="buddyforms_options[slug]"]').val('');
    318319            },
    319320            error: function () {
    320321                jQuery('<div></div>').dialog({
    321322                    modal: true,
    322323                    title: "Info",
    323324                    open: function () {
    324325                        var markup = 'Something went wrong ;-(sorry)';
    325326                        jQuery(this).html(markup);
    326327                    },
    327328                    buttons: {
    328329                        Ok: function () {
    329330                            jQuery(this).dialog("close");
    330331                        }
    331332                    }
    332333                });
    333334            },
    334335            complete: function (jqXHR, textStatus) {
    335336                if (typeof completeCallBack === 'function') {
    336337                    completeCallBack(jqXHR, textStatus);
    337338                }
    338339            }
    339340        });
    340341    }
    341342
    342343    return false;
    343344}
    344345
    345346/**
    346347 *
    347348 * @param element
    348349 * @param value
    349350 */
    350351function buddyform_apply_template_to_element(element, value) {
    351352    if (element.length === 1) {
    352353        element.val(value).trigger('change');
    353354    } else {
    354355        jQuery.each(element, function () {
    355356            var current = jQuery(this);
    356357            var current_val = current.val();
    357358            current.prop("checked", (current_val === value));
    358359        });
    359360    }
    360361}
    361362
    362363//
    363364// Process the form errors and scroll to it
    364365//
    365366function buddyforms_process_errors(errors) {
    366367    var form_with_no_errors = true;
    367368    if (errors.length > 0) {
    368369        jQuery.each(errors, function (index, current_error) {
    369370            if (!current_error.isValid) {
    370371                form_with_no_errors = false;
    371372                var type = current_error.type || 'accordion';
    372373                switch (type) {
    373374                    case 'title':
    374375                    case 'content':
    375376                    case 'textarea':
    376377                    case 'text':
    377378                    case 'post_excerpt':
    378379                    case 'number':
    379380                    case 'subject':
    380381                    case 'message': {
    381382                        jQuery("a[href='#validation-" + type + "-" + current_error.field_id + "']").trigger("click");
    382383                        var sortableBuddyformsElements = jQuery("#sortable_buddyforms_elements");
    383384                        sortableBuddyformsElements.accordion({
    384385                            active: false
    385386                        });
    386387                        //Find the parent, the element id and expand it
    387388                        jQuery(current_error.element).closest(".accordion-body.ui-accordion-content.collapse").addClass("ui-accordion-content-active").css("height", "auto");
    388389                        var li_id = jQuery(current_error.element).closest('li.bf_list_item');
    389390                        var li_position = jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(li_id));
    390391                        sortableBuddyformsElements.accordion({
    391392                            active: li_position
    392393                        });
    393394                        jQuery('#buddyforms_form_setup').removeClass('closed');
    394395                        jQuery('#buddyforms_form_elements').removeClass('closed');
    395396                        break;
    396397                    }
    397398                    case 'accordion': {
    398399                        var general_tab_id = jQuery(current_error.element).closest('div').parent().attr("id");
    399400                        jQuery("a[href='#" + general_tab_id + "']").trigger("click");
    400401
    401402                        //close all
    402403                        var sortableBuddyformsElements = jQuery("#sortable_buddyforms_elements");
    403404                        sortableBuddyformsElements.accordion({
    404405                            active: false
    405406                        });
    406407                        //Find the parent, the element id and expand it
    407408                        jQuery(current_error.element).closest(".accordion-body.ui-accordion-content.collapse").addClass("ui-accordion-content-active").css("height", "auto");
    408409                        var li_id = jQuery(current_error.element).closest('li.bf_list_item');
    409410                        var li_position = jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(li_id));
    410411                        sortableBuddyformsElements.accordion({
    411412                            active: li_position
    412413                        });
    413414                        jQuery('#buddyforms_form_setup').removeClass('closed');
    414415                        jQuery('#buddyforms_form_elements').removeClass('closed');
    415416                        break;
    416417                    }
    417418                    case 'settings': {
    418419                        if (!jQuery(current_error.element).is(':visible')) {
    419420                            var currentId = jQuery(current_error.element).closest('div.tab-pane.ui-widget-content.ui-corner-bottom').attr('id');
    420421                            jQuery('.buddyform-nav-tabs li[aria-controls="' + currentId + '"]>a').trigger("click");
    421422                        }
    422423                        break;
    423424                    }
    424425                }
    425426                var element_name = jQuery(current_error.element).attr('name');
    426427                jQuery("html, body").animate({scrollTop: jQuery('[name="' + element_name + '"]').offset().top - 250}, 1000);
    427428                return false;
    428429            }
    429430        });
    430431    }
    431432
    432433    return form_with_no_errors;
    433434}
    434435
    435436var bfErrors = [];
    436437
    437438function bfValidateRule(fieldId, option, elem, field_type) {
    438439    var element_min = jQuery("[field_id=" + fieldId + "_validation_minlength]")[0];
    439440    var element_max = jQuery("[field_id=" + fieldId + "_validation_maxlength]")[0];
    440441    if (element_max && element_min) {
    441442
    442443        var element_min_value = parseInt(element_min.value);
    443444        var element_max_value = parseInt(element_max.value);
    444445        var element_min_parent = jQuery(element_min).parent();
    445446        var element_max_parent = jQuery(element_max).parent();
    446447        //Celan previous messages
    447448        jQuery(element_min_parent).find("label#" + fieldId + "_validation_error_message").remove();
    448449        jQuery(element_max_parent).find("label#" + fieldId + "_validation_error_message").remove();
    449450
    450451        //If both min and max value are equals zero then skip validation
    451452        if (element_min_value === 0 && element_max_value === 0) {
    452453            bfErrors = bfErrors.filter(function (obj) {
    453454                return obj.field_id !== fieldId;
    454455            });
    455456        } else {
    456457
    457458            if (option === "min") {
    458459                if (element_min_value < 0) {
    459460                    bfErrors.push({isValid: false, element: element_min, type: field_type, field_id: fieldId});
    460461                    jQuery(element_min_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Value must be greater or equals zero.</label>");
    461462                } else {
    462463                    if (element_min_value >= element_max_value) {
    463464                        //If the min length validation fails, add the error to the array
    464465                        bfErrors.push({isValid: false, element: element_min, type: field_type, field_id: fieldId});
    465466                        //Add the label with the validation error message
    466467                        jQuery(element_min_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Min value must be lesser than Max.</label>");
    467468                    } else {
    468469                        //If the Validation for Min Length was succesful the remove the error from the array
    469470                        bfErrors = bfErrors.filter(function (obj) {
    470471                            return obj.field_id !== fieldId;
    471472                        });
    472473                    }
    473474                }
    474475
    475476            } else if (option === "max") {
    476477
    477478                if (element_max_value < 0) {
    478479                    bfErrors.push({isValid: false, element: element_max, type: field_type, field_id: fieldId});
    479480                    jQuery(element_max_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Value must be greater or equals zero.</label>");
    480481                } else {
    481482
    482483                    if (element_max_value <= element_min_value) {
    483484                        //If the max length validation fails, add the error to the array
    484485                        bfErrors.push({isValid: false, element: element_max, type: field_type, field_id: fieldId});
    485486                        //Add the label with the validation error message
    486487                        jQuery(element_max_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Max value must be greater than Min.</label>");
    487488                    } else {
    488489                        //If the Validation for Min Length was succesful the remove the error from the array
    489490                        bfErrors = bfErrors.filter(function (obj) {
    490491                            return obj.field_id !== fieldId;
    491492                        });
    492493                    }
    493494                }
    494495            }
    495496        }
    496497    }
    497498}
    498499
    499500/**
    500501 * Copy element to clipboard
    501502 *
    502503 * @since 2.4.5
    503504 */
    504505function buddyformsCopyStringToClipboard(string) {
    505506    var el = document.createElement('textarea');
    506507    el.value = string;
    507508    el.setAttribute('readonly', '');
    508509    el.style.position = 'absolute';
    509510    el.style.left = '-9999px';
    510511    document.body.appendChild(el);
    511512    var selected =
    512513        document.getSelection().rangeCount > 0
    513514            ? document.getSelection().getRangeAt(0)
    514515            : false;
    515516    el.select();
    516517    document.execCommand('copy');
    517518    document.body.removeChild(el);
    518519    if (selected) {
    519520        document.getSelection().removeAllRanges();
    520521        document.getSelection().addRange(selected);
    521522    }
    522523}
    523524
    524525/**
    525526 * Find the localize string
    526527 */
    527528function bf_trans(str) {
    528529
    529530    if (typeof str === 'string'
    530531        && typeof buddyformsGlobal !== 'undefined'
    531532        && typeof buddyformsGlobal.localize !== 'undefined'
    532533        && typeof buddyformsGlobal.localize.bf_trans !== 'undefined'
    533534    ) {
    534535        const localize_str = Object.values(buddyformsGlobal.localize.bf_trans).find(function(elm) {
    535536            return elm.msgid === str
    536537        });
    537538
    538539        return (typeof localize_str !== 'undefined') ? localize_str.msgstr : str;
    539540    }
    540541
    541542    return str;
    542543}
    543544
    544545//
    545546// Lets do some stuff after the document is loaded
    546547//
    547548jQuery(document).ready(function (jQuery) {
    548549
    549550    if (buddyformsGlobal) {
    550551        //Fix to show the form editor and hide all unrelated meta-boxes it suppose to only apply in certain pages
    551552        var currentScreen = buddyformsGlobal.current_screen || false;
    552553        var isAdmin = buddyformsGlobal.is_admin || false;
    553554        if (currentScreen && isAdmin) {
    554555            if (
    555556                currentScreen.id === 'edit-buddyforms' || currentScreen.id === 'buddyforms' ||
    556557                currentScreen.id === 'buddyforms_page_buddyforms_submissions' || currentScreen.id === 'buddyforms_page_buddyforms_settings' ||
    557558                currentScreen.id === 'buddyforms_page_bf_add_ons'
    558559            ) {
    559560                var post = jQuery('#post');
    560561                jQuery('#wpbody-content').html('<div class="wrap"></div>');
    561562                jQuery('#wpbody-content .wrap').html(post);
    562563
    563564                jQuery(window).scrollTop(0);
    564565
    565566                // Remove all post box metaboxes except the buddyforms meta boxes
    566567                jQuery('div .postbox').not('.buddyforms-metabox, #submitdiv').remove();
    567568
    568569                // Show the submit metabox
    569570                jQuery('#submitdiv').show();
    570571                post.removeClass('hidden');
    571572            }
    572573        }
    573574    }
    574575
    575576
    576577    // Add Select2 Support
    577578    var adminSelect2 = jQuery(".bf-select2");
    578579    if (adminSelect2.length > 0) {
    579580        buddyforms_load_select2(adminSelect2);
    580581    }
    581582
    582583    // Prevent form submission if enter key is pressed on text fields
    583584    jQuery(document).on('keyup keypress', 'form input[type="text"]', function (e) {
    584585        if (e.which === 13) {
    585586            e.preventDefault();
    586587            return false;
    587588        }
    588589    });
    589590
    590591    /**
    591592     * Click on the button to preview a form type from the demo site
    592593     * @since 2.4.0
    593594     */
    594595    jQuery(document.body).on('click', '.bf-preview', function () {
    595596        var key = jQuery(this).attr('data-key');
    596597        var src = jQuery(this).attr('data-src');
    597598        var iFrame = jQuery('#iframe-' + key);
    598599        if (iFrame.length > 0) {
    599600            iFrame.attr('src', src);
    600601        }
    601602    });
    602603
    603604    /**
    604605     * Add Sortable to radiobutton, checkbox, dropdown and gdpr
    605606     *
    606607     * @since 2.4.1
    607608     */
    608609    var sortableTable = jQuery('table.wp-list-table.element_field_table_sortable');
    609610    if (sortableTable && sortableTable.length > 0) {
    610611        sortableTable.sortable({
    611612            items: "tr.field_item"
    612613        });
    613614    }
    614615
    615616    // Mail Notifications from email display only if selected
    616617    jQuery(document.body).on('change', '.bf_mail_from_name_multi_checkbox input', function () {
    617618
    618619        var val = jQuery(this).val();
    619620
    620621        if (val === 'custom') {
    621622            jQuery(this).closest('.wp-list-table').find('.mail_from_name_custom').removeClass('hidden');
    622623        } else {
    623624            jQuery(this).closest('.wp-list-table').find('.mail_from_name_custom').addClass('hidden');
    624625        }
    625626
    626627    });
    627628
    628629    // Mail Notifications from email display only if selected
    629630    jQuery(document.body).on('change', '.bf_mail_from_multi_checkbox input', function () {
    630631
    631632        var val = jQuery(this).val();
    632633
    633634        if (val === 'custom') {
    634635            jQuery(this).closest('.wp-list-table').find('.mail_from_custom').removeClass('hidden');
    635636        } else {
    636637            jQuery(this).closest('.wp-list-table').find('.mail_from_custom').addClass('hidden');
    637638        }
    638639
    639640    });
    640641
    641642    // Mail Notifications sent to display only if selected
    642643    jQuery(document.body).on('change', '.bf_sent_mail_to_multi_checkbox input', function () {
    643644
    644645        var val = jQuery(this).val();
    645646
    646647        if (jQuery(this).is(':checked')) {
    647648            jQuery(this).closest('.wp-list-table').find('.mail_to_' + val + '_address').removeClass('hidden').prop('required', true);
    648649        } else {
    649650            jQuery(this).closest('.wp-list-table').find('.mail_to_' + val + '_address').addClass('hidden').prop('required', false);
    650651        }
    651652
    652653    });
    653654
    654655    // Validate the form before publish
    655656    jQuery('#publish').on('click', function () {
    656657
    657658        var post_title = jQuery('[name="post_title"]');
    658659
    659660
    660661        if (post_title.val() === '') {
    661662            post_title.removeClass('bf-ok');
    662663            post_title.addClass('bf-error');
    663664            bfErrors.push({isValid: false, element: post_title, type: 'title'});
    664665        } else {
    665666            post_title.removeClass('bf-error');
    666667            post_title.addClass('bf-ok');
    667668        }
    668669
    669670
    670671        //Validate emails notifications
    671672        var mail_to_cc_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_cc_address]"]');
    672673        jQuery.each(mail_to_cc_addresses, function (index, mail_to_cc_address) {
    673674            var result = buddyforms_validate_notifications_email(mail_to_cc_address);
    674675            bfErrors.push({isValid: result, element: mail_to_cc_address, type: 'settings'});
    675676        });
    676677
    677678        var mail_to_bcc_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_bcc_address]"]');
    678679        jQuery.each(mail_to_bcc_addresses, function (index, mail_to_bcc_address) {
    679680            var result = buddyforms_validate_notifications_email(mail_to_bcc_address);
    680681            bfErrors.push({isValid: result, element: mail_to_bcc_address, type: 'settings'});
    681682        });
    682683
    683684        var mail_to_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_address]"]');
    684685        jQuery.each(mail_to_addresses, function (index, mail_to_address) {
    685686            var result = buddyforms_validate_notifications_email(mail_to_address);
    686687            bfErrors.push({isValid: result, element: mail_to_address, type: 'settings'});
    687688        });
    688689
    689690        var mail_from = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_from_custom]"]');
    690691        if (mail_from.length > 0) {
    691692            var result = buddyforms_validate_notifications_email(mail_from);
    692693            bfErrors.push({isValid: result, element: mail_from, type: 'settings'});
    693694        }
    694695
    695696        //Fill and avoid duplicates of field slugs
    696697        buddyformAutoFillEmptyOrDuplicateSlugs();
    697698
    698699        // traverse all the required elements looking for an empty one
    699700        jQuery("#post input[required]").each(function () {
    700701            // if the value is empty, that means that is invalid
    701702            var isValid = (jQuery(this).val() != "");
    702703
    703704            if (isValid) {
    704705                jQuery(this).removeClass("bf-error");
    705706                var element_name = jQuery(this).eq(0).attr('name');
    706707                bfErrors = bfErrors.filter(function (obj) {
    707708                    return obj.field_name !== element_name;
    708709                });
    709710
    710711
    711712            } else {
    712713                var element_name = jQuery(this).eq(0).attr('name');
    713714                bfErrors.push({isValid: isValid, element: jQuery(this)[0], type: 'accordion', field_name: element_name});
    714715                jQuery(this).addClass("bf-error");
    715716                return false;
    716717            }
    717718        });
    718719        var validation_result = buddyforms_process_errors(bfErrors);
    719720
    720721        return validation_result;
    721722
    722723    });
    723724
    724725    /**
    725726     *
    726727     * @since 2.5.26
    727728     */
    728729    jQuery(document).on('click', 'button#btn-compile-custom', function (event) {
    729730        event.preventDefault();
    730731        jQuery('#buddyforms_template_header_container').show('slow').css('display', 'flex');
    731732        jQuery('#formbuilder-action-templates').show('slow');
    732733        jQuery('#buddyforms_template_list_container').hide('fast');
    733734    });
    734735
    735736    /**
    736737     *
    737738     * @since 2.5.26
    738739     */
    739740    jQuery(document).on('click', '#formbuilder-show-templates', function () {
    740741        jQuery('#buddyforms_template_header_container').hide('fast');
    741742        jQuery('#buddyforms_template_list_container').show('slow');
    742743        jQuery('#formbuilder-show-templates').hide();
    743744    });
    744745
    745746    //
    746747    // Remove form element form the form builder
    747748    //
    748749    jQuery(document).on('click', '.bf_delete_field', function () {
    749750
    750751        var del_id = jQuery(this).attr('id');
    751752        var delete_str = bf_trans('Delete Permanently');
    752753
    753754        if (confirm(delete_str))
    754755            jQuery("#field_" + del_id).remove();
    755756
    756757        return false;
    757758    });
    758759
    759760    //
    760761    // Delete mail notification trigger
    761762    //
    762763    jQuery(document).on('click', '.bf_delete_trigger', function () {
    763764        var del_id = jQuery(this).attr('id');
    764765        var delete_str = bf_trans('Delete Permanently');
    765766
    766767        if (confirm(delete_str)) {
    767768            jQuery("#trigger" + del_id).remove();
    768769            jQuery(".trigger" + del_id).remove();
    769770        }
    770771        return false;
    771772    });
    772773
    773774    //
    774775    // Add new options to select, checkbox form element. The js will ad one more line for value and label
    775776    //
    776777    jQuery(document).on('click', '.bf_add_gdpr', function () {
    777778
    778779        if (buddyformsGlobal) {
    779780            var action = jQuery(this);
    780781            var gdpr_type = jQuery(this).attr('data-gdpr-type');
    781782
    782783            var numItems = jQuery('#table_row_' + gdpr_type + '_select_options table.element_field_table_sortable tbody tr').size();
    783784
    784785            var type = jQuery('#gdpr_option_type').val();
    785786
    786787            var message = '';
    787788            if (buddyformsGlobal.admin_text[type]) {
    788789                message = buddyformsGlobal.admin_text[type]
    789790            }
    790791
    791792            var error_message = '';
    792793            if (buddyformsGlobal.admin_text['error_message']) {
    793794                error_message = buddyformsGlobal.admin_text['error_message']
    794795            }
    795796
    796797            numItems = numItems + 1;
    797798            jQuery('#table_row_' + gdpr_type + '_select_options table.element_field_table_sortable tbody').append(
    798799                '<tr class="field_item field_item_' + gdpr_type + '_' + numItems + '">' +
    799800                '<td><div class="dashicons dashicons-image-flip-vertical"></div></td>' +
    800801                '<td>' +
    801802                '<p><b>Agreement Text</b></p>' +
    802803                '<textarea rows="3" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][label]" cols="50">' + message + '</textarea>' +
    803804                '<p><b>Error Message</b></p>' +
    804805                '<textarea rows="3" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][error_message]" cols="50">' + error_message + '</textarea>' +
    805806                '</td>' +
    806807                '<td class="manage-column column-author">' +
    807808                '<div class="checkbox">' +
    808809                '   <label class="">' +
    809810                '       <input type="checkbox" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][checked][]" value="checked"><span>Checked</span>' +
    810811                '   </label>' +
    811812                '</div>' +
    812813                '<div class="checkbox">' +
    813814                '   <label class="">' +
    814815                '       <input type="checkbox" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][required][]" value="required"><span>Required</span>' +
    815816                '   </label>' +
    816817                '</div>' +
    817818                '</td>' +
    818819                '<td class="manage-column column-author">' +
    819820                '<a href="#" id="' + gdpr_type + '_' + numItems + '" class="bf_delete_input">Delete</a>' +
    820821                '</td>' +
    821822                '</tr>');
    822823            return false;
    823824        }
    824825    });
    825826
    826827    /**
    827828     * Reset option for multiple choice fields radio and checkboxes for backend
    828829     *
    829830     * @since 2.4.1
    830831     */
    831832    jQuery(document.body).on('click', '.button.bf_reset_multi_input', function (event) {
    832833        event.preventDefault();
    833834        var groupName = jQuery(this).attr('data-group-name');
    834835        var fieldId = jQuery(this).attr('data-field-id');
    835836        jQuery('input[name="buddyforms_options[form_fields][' + fieldId + '][default]"][value="' + groupName + '"]').attr('checked', false);
    836837        return false;
    837838    });
    838839
    839840    /**
    840841     * Add new options to gdpr, checkbox form element. The js will add one more line for value and label
    841842     *
    842843     * @since 2.4.1
    843844     */
    844845    jQuery(document).on('click', '.bf_add_input', function () {
    845846        var action = jQuery(this);
    846847        var args = action.attr('href').split("/");
    847848        var numItems = jQuery('#table_row_' + args[0] + '_select_options table.element_field_table_sortable tbody tr').size();
    848849
    849850        numItems = numItems + 1;
    850851        jQuery('#table_row_' + args[0] + '_select_options table.element_field_table_sortable tbody').append(
    851852            '<tr class="field_item field_item_' + args[0] + '_' + numItems + '">' +
    852853            '<td><div class="dashicons dashicons-image-flip-vertical"></div></td>' +
    853854            '<td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields][' + args[0] + '][options][' + numItems + '][label]"></td>' +
    854855            '<td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields][' + args[0] + '][options][' + numItems + '][value]"></td>' +
    855856            '<td class="manage-column column-default"><p>Save the Form</p></td>' +
    856857            '<td class="manage-column column-default"><a href="#" id="' + args[0] + '_' + numItems + '" class="bf_delete_input">Delete</a></td>' +
    857858            '</tr>');
    858859        return false;
    859860    });
    860861
    861862    //
    862863    // Remove an option from a select or checkbox
    863864    //
    864865    jQuery(document).on('click', '.bf_delete_input', function () {
    865866        var del_id = jQuery(this).attr('id');
    866867        var delete_str = bf_trans('Delete Permanently');
    867868
    868869        if (confirm(delete_str))
    869870            jQuery(".field_item_" + del_id).remove();
    870871        return false;
    871872    });
    872873
    873874    bf_update_list_item_number();
    874875
    875876    jQuery(document).on('mousedown', '.bf_list_item', function () {
    876877        itemList = jQuery(this).closest('.sortable').sortable({
    877878            update: function (event, ui) {
    878879                bf_update_list_item_number();
    879880            }
    880881        });
    881882    });
    882883
    883884    bf_update_list_item_number_mail();
    884885
    885886     //
    886887    // Trigger the email test notification
    887888    //
    888889    jQuery(document).on('click', '.bf_test_trigger:not(disabled)', function(e) {
    889890        e.preventDefault();
    890891        e.stopPropagation();
    891892        var test_id = jQuery(this).attr('id');
    892893        var actionLink = jQuery(this);
    893894        actionLink.attr('disabled', true);
    894895        actionLink.text('Sending...');
    895896        jQuery.ajax({
    896897            type: 'POST',
    897898            dataType: 'json',
    898899            // contentType: 'application/x-www-form-urlencoded; utf-8',
    899900            url: buddyformsGlobal.admin_url,
    900901            data: {
    901902                'action': 'buddyforms_test_email',
    902903                'notification_id': test_id,
    903904                'form_slug': actionLink.attr('data-form-slug'),
    904905                'nonce': buddyformsGlobal.ajaxnonce,
    905906            },
    906907            success: function(data) {
    907908                alert(data);
    908909            },
    909910            error: function(request) {
    910911                alert(request.responseText);
    911912            },
    912913            complete: function(){
    913914                actionLink.removeAttr('disabled');
    914915                actionLink.text('Test');
    915916            }
    916917        });
    917918
    918919        return false;
    919920    });
    920921
    921922    //
    922923    // Add notification inside the wizard
    923924    //
    924925    jQuery(document).on('click', '#mail_notification_add_new', function () {
    925926        if (buddyformsGlobal) {
    926927            jQuery.ajax({
    927928                type: 'POST',
    928929                dataType: "json",
    929930                url: buddyformsGlobal.admin_url,
    930931                data: {
    931932                    "action": "buddyforms_new_mail_notification",
    932933                    'form_slug': jQuery(this).attr('data-form-slug'),
    933934                    'nonce': buddyformsGlobal.ajaxnonce,
    934935                },
    935936                success: function (data) {
    936937                    //console.log(data);
    937938
    938939                    jQuery('#no-trigger-mailcontainer').hide();
    939940                    jQuery('#mailcontainer').append(data['html']);
    940941
    941942                    tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + data['trigger_id']);
    942943                    tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + data['trigger_id']);
    943944
    944945                    bf_update_list_item_number_mail();
    945946
    946947                    jQuery(document.body).trigger({type: "buddyform:load_notifications"});
    947948                }
    948949            });
    949950        }
    950951        return false;
    951952    });
    952953
    953954    //
    954955    // Add new mail notification
    955956    //
    956957    jQuery(document).on('click', '#post_status_mail_notification_add_new', function () {
    957958        var error = false;
    958959        var trigger = jQuery('.post_status_mail_notification_trigger select').val();
    959960
    960961        if (!trigger) {
    961962            return false;
    962963        }
    963964
    964965        if (trigger === 'none') {
    965966            bf_alert('You have to select a trigger first.');
    966967            return false;
    967968        }
    968969
    969970        // traverse all the required elements looking for an empty one
    970971        jQuery("#post-status-mail-container li.bf_trigger_list_item").each(function () {
    971972            if (jQuery(this).attr('id') == 'trigger' + trigger) {
    972973                bf_alert('Trigger already exists');
    973974                error = true;
    974975            }
    975976        });
    976977
    977978        if (error == true)
    978979            return false;
    979980        if (buddyformsGlobal) {
    980981            jQuery.ajax({
    981982                type: 'POST',
    982983                url: buddyformsGlobal.admin_url,
    983984                dataType: "json",
    984985                data: {
    985986                    "action": "buddyforms_new_post_status_mail_notification",
    986987                    'form_slug': jQuery(this).attr('data-form-slug'),
    987988                    'nonce': buddyformsGlobal.ajaxnonce,
    988989                    "trigger": trigger
    989990                },
    990991                success: function (data) {
    991992                    if (data == 0) {
    992993                        bf_alert('trigger already exists');
    993994                        return false;
    994995                    }
    995996                    jQuery('#no-trigger-post-status-mail-container').hide();
    996997                    jQuery('#post-status-mail-container').append(data['html']);
    997998
    998999                    tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + data['trigger_id']);
    9991000                    tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + data['trigger_id']);
    10001001
    10011002                    bf_update_list_item_number_mail();
    10021003
    10031004                    jQuery(document.body).trigger({type: "buddyform:load_notifications"});
    10041005                }
    10051006            });
    10061007        }
    10071008        return false;
    10081009    });
    10091010
    10101011    //
    10111012    // Permissions Section - select all roles and caps
    10121013    //
    10131014    jQuery(document).on('click', '.bf_check_all', function (e) {
    10141015
    10151016        if (buddyformsGlobal) {
    10161017
    10171018                jQuery('.bf_permissions :checkbox').not("[disabled]").prop('checked', true);
    10181019                jQuery(this).removeClass();
    10191020                jQuery(this).addClass("bf_uncheck_all");
    10201021                jQuery(this).text(buddyformsGlobal.admin_text.uncheck);
    10211022        }
    10221023        e.preventDefault();
    10231024    });
    10241025    jQuery(document).on('click', '.bf_uncheck_all', function (e) {
    10251026
    10261027        if (buddyformsGlobal) {
    10271028
    10281029                jQuery('.bf_permissions :checkbox').not("[disabled]").prop('checked', false);
    10291030                jQuery(this).removeClass();
    10301031                jQuery(this).addClass("bf_check_all");
    10311032                jQuery(this).text(buddyformsGlobal.admin_text.check);
    10321033
    10331034        }
    10341035        e.preventDefault();
    10351036    });
    10361037
    10371038    jQuery(document).on('click', '.bf_check', function (e) {
    10381039        if (buddyformsGlobal) {
    10391040            if (jQuery(".bf_permissions input[type='checkbox']").prop("checked")) {
    10401041                jQuery(this).text(buddyformsGlobal.admin_text.check);
    10411042            } else {
    10421043                jQuery(this).text(buddyformsGlobal.admin_text.uncheck);
    10431044            }
    10441045        }
    10451046        e.preventDefault();
    10461047    });
    10471048
    10481049
    10491050    jQuery('.bf_check').trigger('click');
    10501051    //
    10511052    // #bf-create-page-modal
    10521053
    10531054
    10541055    //
    10551056    // At last let as remove elements added by other plugins we could not remove with the default functions.
    10561057    //
    10571058
    10581059    // Remove all Visual Composer elements form BuddyForms View
    10591060    // Only apply this action on BuddyForms Views
    10601061    if ( window.location.search.indexOf( 'post_type=buddyforms' ) !== -1 ) {
    10611062        jQuery('*[class^="vc_"]').remove();
    10621063    }
    10631064
    10641065    //
    10651066    // Layout Meta-box related functions
    10661067    //
    10671068    if (buddyformsGlobal && buddyformsGlobal.post_type === 'buddyforms') {
    10681069        jQuery(document).on('click', '#bf_load_layout_options', function () {
    10691070            jQuery('.layout-spinner').addClass('is-active').show();
    10701071            var form_slug = jQuery('#bf_form_layout_select').val();
    10711072            jQuery.ajax({
    10721073                type: 'POST',
    10731074                dataType: 'json',
    10741075                url: buddyformsGlobal.admin_url,
    10751076                data: {
    10761077                    'action': 'buddyforms_load_form_layout',
    10771078                    'form_slug': form_slug
    10781079                },
    10791080                success: function (data) {
    10801081                    update_layout_options_screen(data);
    10811082                }
    10821083            });
    10831084            return false;
    10841085        });
    10851086
    10861087        jQuery(document).on('click', '#bf_reset_layout_options', function (event) {
    10871088            jQuery('.layout-spinner-reset').addClass('is-active').show();
    10881089            jQuery.ajax({
    10891090                type: 'POST',
    10901091                dataType: 'json',
    10911092                url: buddyformsGlobal.admin_url,
    10921093                data: {
    10931094                    'action': 'buddyforms_load_form_layout',
    10941095                    'form_slug': 'reset'
    10951096                },
    10961097                success: function (data) {
    10971098                    update_layout_options_screen(data);
    10981099                }
    10991100            });
    11001101            return false;
    11011102        });
    11021103
    11031104        function update_layout_options_screen(data) {
    11041105            jQuery('.layout-spinner').removeClass('is-active').hide();
    11051106            var layout_container = jQuery('#buddyforms_form_designer');
    11061107            if (layout_container.length > 0) {
    11071108                jQuery.each(data, function (key, val) {
    11081109                    var item = jQuery(layout_container).find('input[name^="buddyforms_options[layout]"][name*="' + key + '"]');
    11091110                    var itemColor = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][name$="[color]"]');
    11101111                    var itemStyle = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][name$="[style]"][value="' + val.style + '"]');
    11111112                    var type;
    11121113                    if (item || itemColor || itemStyle) {
    11131114                        type = item.attr('type');
    11141115                        if ((typeof type === 'undefined' || !type) && itemColor.length > 0) {
    11151116                            type = itemColor.attr('type');
    11161117                        }
    11171118                    }
    11181119
    11191120                    if ('custom_css' === key) {
    11201121                        jQuery('#' + key).text(val);
    11211122                    }
    11221123
    11231124                    if (item.length > 0 && type) {
    11241125                        switch (type) {
    11251126                            case 'text':
    11261127                            case 'number':
    11271128                                item.val(val || '');
    11281129                                break;
    11291130                            case 'radio':
    11301131                                jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][value="' + val + '"]').prop('checked', true).trigger('change');
    11311132                                break;
    11321133                            case 'checkbox':
    11331134                                var currentItem = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"]');
    11341135                                currentItem.prop('checked', (val && currentItem.val() === val)).trigger('change');
    11351136                                break;
    11361137                        }
    11371138                    }
    11381139
    11391140                    if (itemColor.length > 0) {
    11401141                        itemColor.val(val && val.color || '').trigger('change');
    11411142                    }
    11421143
    11431144                    if (itemStyle.length > 0) {
    11441145                        itemStyle.prop('checked', val && val.style).trigger('change');
    11451146                    }
    11461147                });
    11471148            }
    11481149        }
    11491150    }
    11501151
    11511152    jQuery(document).on('change', 'select.captcha-version', function (e) {
    11521153        var selectedVersion = jQuery(this).val();
    11531154        if(selectedVersion === 'v3') {
    11541155            jQuery('tr[id$="_captcha_v3_action"]').show();
    11551156            jQuery('tr[id$="_captcha_v3_score"]').show();
    11561157            jQuery('.bf_hide_captcha_v2_options').show();
    11571158        } else {
    11581159            jQuery('tr[id$="_captcha_v3_action"]').hide();
    11591160            jQuery('tr[id$="_captcha_v3_score"]').hide();
    11601161            jQuery('.bf_hide_captcha_v2_options').hide();
    11611162        }
    11621163    });
    11631164
    11641165    jQuery(document).on('click', '.bf-ready-to-copy', function (e) {
    11651166        e.preventDefault();
    11661167        e.stopPropagation();
    11671168        var currentElement = jQuery(this);
    11681169        if (currentElement.is('input')) {
    11691170            buddyformsCopyStringToClipboard(currentElement.val());
    11701171        } else {
    11711172            var parentHeader = jQuery(this).closest('.accordion-heading-options');
    11721173            var accordionBody = parentHeader.parent().find('.accordion-body');
    11731174            accordionBody.removeClass('ui-accordion-content-active').hide();
    11741175            buddyformsCopyStringToClipboard(currentElement.text());
    11751176            accordionBody.addClass('ui-accordion-content-active');
    11761177        }
    11771178        return false;
    11781179    });
    11791180
    11801181
    11811182
    11821183});
  • buddyforms/trunk/assets/admin/js/admin.min.js

    r3031945 r3046092  
    1 (function(e){e.getStylesheet=function(t){var r=e.Deferred(),o=e('<link/>',{rel:'stylesheet',type:'text/css',href:t}).appendTo('head');r.resolve(o);return r.promise()}})(jQuery);function createNewPageOpenModal(e){var t=jQuery('<div></div>').dialog({modal:!0,title:'Info',open:function(){var e='Name your Page<input id="bf_create_page_name" type="text" value="">';jQuery(this).html(e)},buttons:{'Add':function(){var e=jQuery('#bf_create_page_name').val();t.html('<span class="spinner is-active"></span>');if(buddyformsGlobal){jQuery.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_new_page','page_name':e},success:function(e){if(e['error']){console.log(e['error'])}
    2 else{jQuery('#attached_page').append(jQuery('<option>',{value:e['id'],text:e['name']}));jQuery('#attached_page').val(e['id'])};t.dialog('close')},error:function(){t.dialog('close')}})}}}});e.preventDefault();return!1};var bf_getUrlParameter=function(e){var a=decodeURIComponent(window.location.search.substring(1)),o=a.split('&'),t,r;for(r=0;r<o.length;r++){t=o[r].split('=');if(t[0]===e){return t[1]===undefined?!0:t[1]}}};function buddyformsMakeFieldId(){var t='',r='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';for(var e=0;e<5;e++)t+=r.charAt(Math.floor(Math.random()*r.length));return t};function buddyformAutoFillEmptyOrDuplicateSlugs(){var e=jQuery('#post input[name^=\'buddyforms_options[form_fields]\'][name$=\'[slug]\'][type!=\'hidden\']');e.each(function(){var t=jQuery(this);if(!t.val()){console.log('empty field slug');var r=t.attr('data'),o=jQuery('li#field_'+r);if(o&&o.length>0){var a=o.find('tr.use_as_slug input[name="buddyforms_options[form_fields]['+r+'][name]"]').val();if(a){var i=slug(a,{lower:!1});o.find('tr.slug'+r+' input[name="buddyforms_options[form_fields]['+r+'][slug]"]').val(i)}}};e.each(function(){if(jQuery(this).val()===t.val()&&t.attr('name')!==jQuery(this).attr('name')){t.val(t.val()+'_'+buddyformsMakeFieldId());return!1}})})};function buddyformsIsEmailOrShortcode(e){var t=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})|\[(.*?)(\s.*?)?\]$/;return t.test(e)};function buddyformsValidateMultiEmail(e){var t=!0;if(e){var o=/[;,]+/.test(e);if(o){var r=e.split(/[;,]+/);jQuery.each(r,function(e,r){t=buddyformsIsEmailOrShortcode(r.trim());if(!t){return t}})}
     1(function(e){e.getStylesheet=function(t){var o=e.Deferred(),r=e('<link/>',{rel:'stylesheet',type:'text/css',href:t}).appendTo('head');o.resolve(r);return o.promise()}})(jQuery);function createNewPageOpenModal(e){var t=jQuery('<div></div>').dialog({modal:!0,title:'Info',open:function(){var e='Name your Page<input id="bf_create_page_name" type="text" value="">';jQuery(this).html(e)},buttons:{'Add':function(){var e=jQuery('#bf_create_page_name').val();t.html('<span class="spinner is-active"></span>');if(buddyformsGlobal){jQuery.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_new_page','page_name':e,'nonce':buddyformsGlobal.ajaxnonce},success:function(e){if(e['error']){console.log(e['error'])}
     2else{jQuery('#attached_page').append(jQuery('<option>',{value:e['id'],text:e['name']}));jQuery('#attached_page').val(e['id'])};t.dialog('close')},error:function(){t.dialog('close')}})}}}});e.preventDefault();return!1};var bf_getUrlParameter=function(e){var a=decodeURIComponent(window.location.search.substring(1)),r=a.split('&'),t,o;for(o=0;o<r.length;o++){t=r[o].split('=');if(t[0]===e){return t[1]===undefined?!0:t[1]}}};function buddyformsMakeFieldId(){var t='',o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';for(var e=0;e<5;e++)t+=o.charAt(Math.floor(Math.random()*o.length));return t};function buddyformAutoFillEmptyOrDuplicateSlugs(){var e=jQuery('#post input[name^=\'buddyforms_options[form_fields]\'][name$=\'[slug]\'][type!=\'hidden\']');e.each(function(){var t=jQuery(this);if(!t.val()){console.log('empty field slug');var o=t.attr('data'),r=jQuery('li#field_'+o);if(r&&r.length>0){var a=r.find('tr.use_as_slug input[name="buddyforms_options[form_fields]['+o+'][name]"]').val();if(a){var i=slug(a,{lower:!1});r.find('tr.slug'+o+' input[name="buddyforms_options[form_fields]['+o+'][slug]"]').val(i)}}};e.each(function(){if(jQuery(this).val()===t.val()&&t.attr('name')!==jQuery(this).attr('name')){t.val(t.val()+'_'+buddyformsMakeFieldId());return!1}})})};function buddyformsIsEmailOrShortcode(e){var t=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})|\[(.*?)(\s.*?)?\]$/;return t.test(e)};function buddyformsValidateMultiEmail(e){var t=!0;if(e){var r=/[;,]+/.test(e);if(r){var o=e.split(/[;,]+/);jQuery.each(o,function(e,o){t=buddyformsIsEmailOrShortcode(o.trim());if(!t){return t}})}
    33else{t=buddyformsIsEmailOrShortcode(e);if(!t){return t}}}
    4 else{t=!1};return t};function buddyforms_validate_notifications_email(e){if(e){var r=jQuery(e).val();if(r){var t=buddyformsValidateMultiEmail(jQuery(e).val());if(!t){jQuery(e)[0].setCustomValidity('Invalid Email(s)');jQuery(e).addClass('bf-error')}
     4else{t=!1};return t};function buddyforms_validate_notifications_email(e){if(e){var o=jQuery(e).val();if(o){var t=buddyformsValidateMultiEmail(jQuery(e).val());if(!t){jQuery(e)[0].setCustomValidity('Invalid Email(s)');jQuery(e).addClass('bf-error')}
    55else{jQuery(e)[0].setCustomValidity('');jQuery(e).removeClass('bf-error')};return t}
    66else{jQuery(e)[0].setCustomValidity('');jQuery(e).removeClass('bf-error')}};return!0};function bf_update_list_item_number(){jQuery('.buddyforms_forms_builder ul').each(function(){jQuery(this).children('li').each(function(e){jQuery(this).find('td.field_order .circle').first().html(e+1)})})};function bf_alert(e){jQuery('<div></div>').dialog({modal:!0,title:'Info',open:function(){jQuery(this).html(e)},buttons:{Ok:function(){jQuery(this).dialog('close')}}})};function bf_update_list_item_number_mail(){jQuery('#mailcontainer .bf_trigger_list_item').each(function(e){jQuery(this).find('td.field_order .circle').first().html(e+1)})};function buddyforms_load_select2(e){jQuery.when(jQuery.getStylesheet(buddyformsGlobal.assets.select2_css),jQuery.getScript(buddyformsGlobal.assets.select2_js)).then(function(){if(jQuery.fn.select2){e.select2({placeholder:'Select an option'})}
    77else{console.log('BF-Error loading select2 assets, please contact support.')}},function(){console.log('BF-Error loading select2 assets, please contact support.')})};function setStatusDateFormat(e){if(e.checked){jQuery('.status-date-format').show();jQuery('.status-time-format').show()}
    8 else{jQuery('.status-date-format').hide();jQuery('.status-time-format').hide()}};function load_formbuilder_template(e,t){var r=jQuery('input#title');if(buddyformsGlobal){jQuery.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_form_template','template':e,'title':r.val()},success:function(e){jQuery.each(e,function(e,t){switch(e){case'formbuilder':var r=jQuery('.buddyforms_forms_builder');r.replaceWith(t);bf_update_list_item_number();jQuery(document.body).trigger({type:'buddyform:load_fields'});break;case'mail_notification':jQuery('.buddyforms_accordion_notification').html(t);jQuery('#no-trigger-mailcontainer').hide();tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();break;case'form_setup':jQuery.each(t,function(e,t){if(t instanceof Object){jQuery.each(t,function(t,r){var o;if(r instanceof Object){jQuery.each(r,function(r,a){o=jQuery('[name="buddyforms_options['+e+']['+t+']['+r+']"]');buddyform_apply_template_to_element(o,a)})}
    9 else{o=jQuery('[name="buddyforms_options['+e+']['+t+']"]');buddyform_apply_template_to_element(o,r)}})};if(t instanceof Array){buddyform_apply_template_to_element(jQuery('[name="buddyforms_options['+e+'][]"]'),t)}
    10 else{buddyform_apply_template_to_element(jQuery('[name="buddyforms_options['+e+']"]'),t)};var r=jQuery('.bf-select2');if(r.length>0){buddyforms_load_select2(r)};from_setup_form_type(jQuery('#bf-form-type-select').val())});break;default:bf_alert(t)}});tb_remove();if(!r.val()){r.val(buddyformsMakeFieldId());jQuery('input#title').focus();jQuery('#title-prompt-text').addClass('screen-reader-text')};jQuery('[name="buddyforms_options[slug]"]').val('')},error:function(){jQuery('<div></div>').dialog({modal:!0,title:'Info',open:function(){var e='Something went wrong ;-(sorry)';jQuery(this).html(e)},buttons:{Ok:function(){jQuery(this).dialog('close')}}})},complete:function(e,r){if(typeof t==='function'){t(e,r)}}})};return!1};function buddyform_apply_template_to_element(e,t){if(e.length===1){e.val(t).trigger('change')}
    11 else{jQuery.each(e,function(){var e=jQuery(this),r=e.val();e.prop('checked',(r===t))})}};function buddyforms_process_errors(e){var t=!0;if(e.length>0){jQuery.each(e,function(e,r){if(!r.isValid){t=!1;var s=r.type||'accordion';switch(s){case'title':case'content':case'textarea':case'text':case'post_excerpt':case'number':case'subject':case'message':{jQuery('a[href=\'#validation-'+s+'-'+r.field_id+'\']').trigger('click');var o=jQuery('#sortable_buddyforms_elements');o.accordion({active:!1});jQuery(r.element).closest('.accordion-body.ui-accordion-content.collapse').addClass('ui-accordion-content-active').css('height','auto');var a=jQuery(r.element).closest('li.bf_list_item'),i=jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(a));o.accordion({active:i});jQuery('#buddyforms_form_setup').removeClass('closed');jQuery('#buddyforms_form_elements').removeClass('closed');break};case'accordion':{var d=jQuery(r.element).closest('div').parent().attr('id');jQuery('a[href=\'#'+d+'\']').trigger('click');var o=jQuery('#sortable_buddyforms_elements');o.accordion({active:!1});jQuery(r.element).closest('.accordion-body.ui-accordion-content.collapse').addClass('ui-accordion-content-active').css('height','auto');var a=jQuery(r.element).closest('li.bf_list_item'),i=jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(a));o.accordion({active:i});jQuery('#buddyforms_form_setup').removeClass('closed');jQuery('#buddyforms_form_elements').removeClass('closed');break};case'settings':{if(!jQuery(r.element).is(':visible')){var l=jQuery(r.element).closest('div.tab-pane.ui-widget-content.ui-corner-bottom').attr('id');jQuery('.buddyform-nav-tabs li[aria-controls="'+l+'"]>a').trigger('click')};break}};var n=jQuery(r.element).attr('name');jQuery('html, body').animate({scrollTop:jQuery('[name="'+n+'"]').offset().top-250},1000);return!1}})};return t};var bfErrors=[];function bfValidateRule(e,t,d,a){var r=jQuery('[field_id='+e+'_validation_minlength]')[0],o=jQuery('[field_id='+e+'_validation_maxlength]')[0];if(o&&r){var i=parseInt(r.value),s=parseInt(o.value),n=jQuery(r).parent(),l=jQuery(o).parent();jQuery(n).find('label#'+e+'_validation_error_message').remove();jQuery(l).find('label#'+e+'_validation_error_message').remove();if(i===0&&s===0){bfErrors=bfErrors.filter(function(t){return t.field_id!==e})}
    12 else{if(t==='min'){if(i<0){bfErrors.push({isValid:!1,element:r,type:a,field_id:e});jQuery(n).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Value must be greater or equals zero.</label>')}
    13 else{if(i>=s){bfErrors.push({isValid:!1,element:r,type:a,field_id:e});jQuery(n).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Min value must be lesser than Max.</label>')}
     8else{jQuery('.status-date-format').hide();jQuery('.status-time-format').hide()}};function load_formbuilder_template(e,t){var o=jQuery('input#title');if(buddyformsGlobal){jQuery.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_form_template','template':e,'title':o.val()},success:function(e){jQuery.each(e,function(e,t){switch(e){case'formbuilder':var o=jQuery('.buddyforms_forms_builder');o.replaceWith(t);bf_update_list_item_number();jQuery(document.body).trigger({type:'buddyform:load_fields'});break;case'mail_notification':jQuery('.buddyforms_accordion_notification').html(t);jQuery('#no-trigger-mailcontainer').hide();tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();break;case'form_setup':jQuery.each(t,function(e,t){if(t instanceof Object){jQuery.each(t,function(t,o){var r;if(o instanceof Object){jQuery.each(o,function(o,a){r=jQuery('[name="buddyforms_options['+e+']['+t+']['+o+']"]');buddyform_apply_template_to_element(r,a)})}
     9else{r=jQuery('[name="buddyforms_options['+e+']['+t+']"]');buddyform_apply_template_to_element(r,o)}})};if(t instanceof Array){buddyform_apply_template_to_element(jQuery('[name="buddyforms_options['+e+'][]"]'),t)}
     10else{buddyform_apply_template_to_element(jQuery('[name="buddyforms_options['+e+']"]'),t)};var o=jQuery('.bf-select2');if(o.length>0){buddyforms_load_select2(o)};from_setup_form_type(jQuery('#bf-form-type-select').val())});break;default:bf_alert(t)}});tb_remove();if(!o.val()){o.val(buddyformsMakeFieldId());jQuery('input#title').focus();jQuery('#title-prompt-text').addClass('screen-reader-text')};jQuery('[name="buddyforms_options[slug]"]').val('')},error:function(){jQuery('<div></div>').dialog({modal:!0,title:'Info',open:function(){var e='Something went wrong ;-(sorry)';jQuery(this).html(e)},buttons:{Ok:function(){jQuery(this).dialog('close')}}})},complete:function(e,o){if(typeof t==='function'){t(e,o)}}})};return!1};function buddyform_apply_template_to_element(e,t){if(e.length===1){e.val(t).trigger('change')}
     11else{jQuery.each(e,function(){var e=jQuery(this),o=e.val();e.prop('checked',(o===t))})}};function buddyforms_process_errors(e){var t=!0;if(e.length>0){jQuery.each(e,function(e,o){if(!o.isValid){t=!1;var s=o.type||'accordion';switch(s){case'title':case'content':case'textarea':case'text':case'post_excerpt':case'number':case'subject':case'message':{jQuery('a[href=\'#validation-'+s+'-'+o.field_id+'\']').trigger('click');var r=jQuery('#sortable_buddyforms_elements');r.accordion({active:!1});jQuery(o.element).closest('.accordion-body.ui-accordion-content.collapse').addClass('ui-accordion-content-active').css('height','auto');var a=jQuery(o.element).closest('li.bf_list_item'),i=jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(a));r.accordion({active:i});jQuery('#buddyforms_form_setup').removeClass('closed');jQuery('#buddyforms_form_elements').removeClass('closed');break};case'accordion':{var d=jQuery(o.element).closest('div').parent().attr('id');jQuery('a[href=\'#'+d+'\']').trigger('click');var r=jQuery('#sortable_buddyforms_elements');r.accordion({active:!1});jQuery(o.element).closest('.accordion-body.ui-accordion-content.collapse').addClass('ui-accordion-content-active').css('height','auto');var a=jQuery(o.element).closest('li.bf_list_item'),i=jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(a));r.accordion({active:i});jQuery('#buddyforms_form_setup').removeClass('closed');jQuery('#buddyforms_form_elements').removeClass('closed');break};case'settings':{if(!jQuery(o.element).is(':visible')){var l=jQuery(o.element).closest('div.tab-pane.ui-widget-content.ui-corner-bottom').attr('id');jQuery('.buddyform-nav-tabs li[aria-controls="'+l+'"]>a').trigger('click')};break}};var n=jQuery(o.element).attr('name');jQuery('html, body').animate({scrollTop:jQuery('[name="'+n+'"]').offset().top-250},1000);return!1}})};return t};var bfErrors=[];function bfValidateRule(e,t,d,a){var o=jQuery('[field_id='+e+'_validation_minlength]')[0],r=jQuery('[field_id='+e+'_validation_maxlength]')[0];if(r&&o){var i=parseInt(o.value),s=parseInt(r.value),n=jQuery(o).parent(),l=jQuery(r).parent();jQuery(n).find('label#'+e+'_validation_error_message').remove();jQuery(l).find('label#'+e+'_validation_error_message').remove();if(i===0&&s===0){bfErrors=bfErrors.filter(function(t){return t.field_id!==e})}
     12else{if(t==='min'){if(i<0){bfErrors.push({isValid:!1,element:o,type:a,field_id:e});jQuery(n).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Value must be greater or equals zero.</label>')}
     13else{if(i>=s){bfErrors.push({isValid:!1,element:o,type:a,field_id:e});jQuery(n).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Min value must be lesser than Max.</label>')}
    1414else{bfErrors=bfErrors.filter(function(t){return t.field_id!==e})}}}
    15 else if(t==='max'){if(s<0){bfErrors.push({isValid:!1,element:o,type:a,field_id:e});jQuery(l).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Value must be greater or equals zero.</label>')}
    16 else{if(s<=i){bfErrors.push({isValid:!1,element:o,type:a,field_id:e});jQuery(l).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Max value must be greater than Min.</label>')}
    17 else{bfErrors=bfErrors.filter(function(t){return t.field_id!==e})}}}}}};function buddyformsCopyStringToClipboard(e){var t=document.createElement('textarea');t.value=e;t.setAttribute('readonly','');t.style.position='absolute';t.style.left='-9999px';document.body.appendChild(t);var r=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):!1;t.select();document.execCommand('copy');document.body.removeChild(t);if(r){document.getSelection().removeAllRanges();document.getSelection().addRange(r)}};function bf_trans(e){if(typeof e==='string'&&typeof buddyformsGlobal!=='undefined'&&typeof buddyformsGlobal.localize!=='undefined'&&typeof buddyformsGlobal.localize.bf_trans!=='undefined'){const localize_str=Object.values(buddyformsGlobal.localize.bf_trans).find(function(t){return t.msgid===e});return(typeof localize_str!=='undefined')?localize_str.msgstr:e};return e};jQuery(document).ready(function(e){if(buddyformsGlobal){var t=buddyformsGlobal.current_screen||!1,s=buddyformsGlobal.is_admin||!1;if(t&&s){if(t.id==='edit-buddyforms'||t.id==='buddyforms'||t.id==='buddyforms_page_buddyforms_submissions'||t.id==='buddyforms_page_buddyforms_settings'||t.id==='buddyforms_page_bf_add_ons'){var a=e('#post');e('#wpbody-content').html('<div class="wrap"></div>');e('#wpbody-content .wrap').html(a);e(window).scrollTop(0);e('div .postbox').not('.buddyforms-metabox, #submitdiv').remove();e('#submitdiv').show();a.removeClass('hidden')}}};var o=e('.bf-select2');if(o.length>0){buddyforms_load_select2(o)};e(document).on('keyup keypress','form input[type="text"]',function(e){if(e.which===13){e.preventDefault();return!1}});e(document.body).on('click','.bf-preview',function(){var r=e(this).attr('data-key'),o=e(this).attr('data-src'),t=e('#iframe-'+r);if(t.length>0){t.attr('src',o)}});var r=e('table.wp-list-table.element_field_table_sortable');if(r&&r.length>0){r.sortable({items:'tr.field_item'})};e(document.body).on('change','.bf_mail_from_name_multi_checkbox input',function(){var t=e(this).val();if(t==='custom'){e(this).closest('.wp-list-table').find('.mail_from_name_custom').removeClass('hidden')}
     15else if(t==='max'){if(s<0){bfErrors.push({isValid:!1,element:r,type:a,field_id:e});jQuery(l).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Value must be greater or equals zero.</label>')}
     16else{if(s<=i){bfErrors.push({isValid:!1,element:r,type:a,field_id:e});jQuery(l).append('<label id=\''+e+'_validation_error_message\' class=\'error\'>Max value must be greater than Min.</label>')}
     17else{bfErrors=bfErrors.filter(function(t){return t.field_id!==e})}}}}}};function buddyformsCopyStringToClipboard(e){var t=document.createElement('textarea');t.value=e;t.setAttribute('readonly','');t.style.position='absolute';t.style.left='-9999px';document.body.appendChild(t);var o=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):!1;t.select();document.execCommand('copy');document.body.removeChild(t);if(o){document.getSelection().removeAllRanges();document.getSelection().addRange(o)}};function bf_trans(e){if(typeof e==='string'&&typeof buddyformsGlobal!=='undefined'&&typeof buddyformsGlobal.localize!=='undefined'&&typeof buddyformsGlobal.localize.bf_trans!=='undefined'){const localize_str=Object.values(buddyformsGlobal.localize.bf_trans).find(function(t){return t.msgid===e});return(typeof localize_str!=='undefined')?localize_str.msgstr:e};return e};jQuery(document).ready(function(e){if(buddyformsGlobal){var t=buddyformsGlobal.current_screen||!1,s=buddyformsGlobal.is_admin||!1;if(t&&s){if(t.id==='edit-buddyforms'||t.id==='buddyforms'||t.id==='buddyforms_page_buddyforms_submissions'||t.id==='buddyforms_page_buddyforms_settings'||t.id==='buddyforms_page_bf_add_ons'){var a=e('#post');e('#wpbody-content').html('<div class="wrap"></div>');e('#wpbody-content .wrap').html(a);e(window).scrollTop(0);e('div .postbox').not('.buddyforms-metabox, #submitdiv').remove();e('#submitdiv').show();a.removeClass('hidden')}}};var r=e('.bf-select2');if(r.length>0){buddyforms_load_select2(r)};e(document).on('keyup keypress','form input[type="text"]',function(e){if(e.which===13){e.preventDefault();return!1}});e(document.body).on('click','.bf-preview',function(){var o=e(this).attr('data-key'),r=e(this).attr('data-src'),t=e('#iframe-'+o);if(t.length>0){t.attr('src',r)}});var o=e('table.wp-list-table.element_field_table_sortable');if(o&&o.length>0){o.sortable({items:'tr.field_item'})};e(document.body).on('change','.bf_mail_from_name_multi_checkbox input',function(){var t=e(this).val();if(t==='custom'){e(this).closest('.wp-list-table').find('.mail_from_name_custom').removeClass('hidden')}
    1818else{e(this).closest('.wp-list-table').find('.mail_from_name_custom').addClass('hidden')}});e(document.body).on('change','.bf_mail_from_multi_checkbox input',function(){var t=e(this).val();if(t==='custom'){e(this).closest('.wp-list-table').find('.mail_from_custom').removeClass('hidden')}
    1919else{e(this).closest('.wp-list-table').find('.mail_from_custom').addClass('hidden')}});e(document.body).on('change','.bf_sent_mail_to_multi_checkbox input',function(){var t=e(this).val();if(e(this).is(':checked')){e(this).closest('.wp-list-table').find('.mail_to_'+t+'_address').removeClass('hidden').prop('required',!0)}
    2020else{e(this).closest('.wp-list-table').find('.mail_to_'+t+'_address').addClass('hidden').prop('required',!1)}});e('#publish').on('click',function(){var t=e('[name="post_title"]');if(t.val()===''){t.removeClass('bf-ok');t.addClass('bf-error');bfErrors.push({isValid:!1,element:t,type:'title'})}
    21 else{t.removeClass('bf-error');t.addClass('bf-ok')};var n=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_cc_address]"]');e.each(n,function(e,t){var r=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:r,element:t,type:'settings'})});var s=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_bcc_address]"]');e.each(s,function(e,t){var r=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:r,element:t,type:'settings'})});var i=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_address]"]');e.each(i,function(e,t){var r=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:r,element:t,type:'settings'})});var r=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_from_custom]"]');if(r.length>0){var a=buddyforms_validate_notifications_email(r);bfErrors.push({isValid:a,element:r,type:'settings'})};buddyformAutoFillEmptyOrDuplicateSlugs();e('#post input[required]').each(function(){var r=(e(this).val()!='');if(r){e(this).removeClass('bf-error');var t=e(this).eq(0).attr('name');bfErrors=bfErrors.filter(function(e){return e.field_name!==t})}
    22 else{var t=e(this).eq(0).attr('name');bfErrors.push({isValid:r,element:e(this)[0],type:'accordion',field_name:t});e(this).addClass('bf-error');return!1}});var o=buddyforms_process_errors(bfErrors);return o});e(document).on('click','button#btn-compile-custom',function(t){t.preventDefault();e('#buddyforms_template_header_container').show('slow').css('display','flex');e('#formbuilder-action-templates').show('slow');e('#buddyforms_template_list_container').hide('fast')});e(document).on('click','#formbuilder-show-templates',function(){e('#buddyforms_template_header_container').hide('fast');e('#buddyforms_template_list_container').show('slow');e('#formbuilder-show-templates').hide()});e(document).on('click','.bf_delete_field',function(){var t=e(this).attr('id'),r=bf_trans('Delete Permanently');if(confirm(r))e('#field_'+t).remove();return!1});e(document).on('click','.bf_delete_trigger',function(){var t=e(this).attr('id'),r=bf_trans('Delete Permanently');if(confirm(r)){e('#trigger'+t).remove();e('.trigger'+t).remove()};return!1});e(document).on('click','.bf_add_gdpr',function(){if(buddyformsGlobal){var s=e(this),t=e(this).attr('data-gdpr-type'),r=e('#table_row_'+t+'_select_options table.element_field_table_sortable tbody tr').size(),a=e('#gdpr_option_type').val(),i='';if(buddyformsGlobal.admin_text[a]){i=buddyformsGlobal.admin_text[a]};var o='';if(buddyformsGlobal.admin_text['error_message']){o=buddyformsGlobal.admin_text['error_message']};r=r+1;e('#table_row_'+t+'_select_options table.element_field_table_sortable tbody').append('<tr class="field_item field_item_'+t+'_'+r+'"><td><div class="dashicons dashicons-image-flip-vertical"></div></td><td><p><b>Agreement Text</b></p><textarea rows="3" name="buddyforms_options[form_fields]['+t+'][options]['+r+'][label]" cols="50">'+i+'</textarea><p><b>Error Message</b></p><textarea rows="3" name="buddyforms_options[form_fields]['+t+'][options]['+r+'][error_message]" cols="50">'+o+'</textarea></td><td class="manage-column column-author"><div class="checkbox">   <label class="">       <input type="checkbox" name="buddyforms_options[form_fields]['+t+'][options]['+r+'][checked][]" value="checked"><span>Checked</span>   </label></div><div class="checkbox">   <label class="">       <input type="checkbox" name="buddyforms_options[form_fields]['+t+'][options]['+r+'][required][]" value="required"><span>Required</span>   </label></div></td><td class="manage-column column-author"><a href="#" id="'+t+'_'+r+'" class="bf_delete_input">Delete</a></td></tr>');return!1}});e(document.body).on('click','.button.bf_reset_multi_input',function(t){t.preventDefault();var r=e(this).attr('data-group-name'),o=e(this).attr('data-field-id');e('input[name="buddyforms_options[form_fields]['+o+'][default]"][value="'+r+'"]').attr('checked',!1);return!1});e(document).on('click','.bf_add_input',function(){var o=e(this),t=o.attr('href').split('/'),r=e('#table_row_'+t[0]+'_select_options table.element_field_table_sortable tbody tr').size();r=r+1;e('#table_row_'+t[0]+'_select_options table.element_field_table_sortable tbody').append('<tr class="field_item field_item_'+t[0]+'_'+r+'"><td><div class="dashicons dashicons-image-flip-vertical"></div></td><td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields]['+t[0]+'][options]['+r+'][label]"></td><td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields]['+t[0]+'][options]['+r+'][value]"></td><td class="manage-column column-default"><p>Save the Form</p></td><td class="manage-column column-default"><a href="#" id="'+t[0]+'_'+r+'" class="bf_delete_input">Delete</a></td></tr>');return!1});e(document).on('click','.bf_delete_input',function(){var t=e(this).attr('id'),r=bf_trans('Delete Permanently');if(confirm(r))e('.field_item_'+t).remove();return!1});bf_update_list_item_number();e(document).on('mousedown','.bf_list_item',function(){itemList=e(this).closest('.sortable').sortable({update:function(e,t){bf_update_list_item_number()}})});bf_update_list_item_number_mail();e(document).on('click','.bf_test_trigger:not(disabled)',function(t){t.preventDefault();t.stopPropagation();var o=e(this).attr('id'),r=e(this);r.attr('disabled',!0);r.text('Sending...');e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_test_email','notification_id':o,'form_slug':r.attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,},success:function(e){alert(e)},error:function(e){alert(e.responseText)},complete:function(){r.removeAttr('disabled');r.text('Test')}});return!1});e(document).on('click','#mail_notification_add_new',function(){if(buddyformsGlobal){e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_new_mail_notification','form_slug':e(this).attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,},success:function(t){e('#no-trigger-mailcontainer').hide();e('#mailcontainer').append(t['html']);tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();e(document.body).trigger({type:'buddyform:load_notifications'})}})};return!1});e(document).on('click','#post_status_mail_notification_add_new',function(){var r=!1,t=e('.post_status_mail_notification_trigger select').val();if(!t){return!1};if(t==='none'){bf_alert('You have to select a trigger first.');return!1};e('#post-status-mail-container li.bf_trigger_list_item').each(function(){if(e(this).attr('id')=='trigger'+t){bf_alert('Trigger already exists');r=!0}});if(r==!0)return!1;if(buddyformsGlobal){e.ajax({type:'POST',url:buddyformsGlobal.admin_url,dataType:'json',data:{'action':'buddyforms_new_post_status_mail_notification','form_slug':e(this).attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,'trigger':t},success:function(t){if(t==0){bf_alert('trigger already exists');return!1};e('#no-trigger-post-status-mail-container').hide();e('#post-status-mail-container').append(t['html']);tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();e(document.body).trigger({type:'buddyform:load_notifications'})}})};return!1});e(document).on('click','.bf_check_all',function(t){if(buddyformsGlobal){e('.bf_permissions :checkbox').not('[disabled]').prop('checked',!0);e(this).removeClass();e(this).addClass('bf_uncheck_all');e(this).text(buddyformsGlobal.admin_text.uncheck)};t.preventDefault()});e(document).on('click','.bf_uncheck_all',function(t){if(buddyformsGlobal){e('.bf_permissions :checkbox').not('[disabled]').prop('checked',!1);e(this).removeClass();e(this).addClass('bf_check_all');e(this).text(buddyformsGlobal.admin_text.check)};t.preventDefault()});e(document).on('click','.bf_check',function(t){if(buddyformsGlobal){if(e('.bf_permissions input[type=\'checkbox\']').prop('checked')){e(this).text(buddyformsGlobal.admin_text.check)}
    23 else{e(this).text(buddyformsGlobal.admin_text.uncheck)}};t.preventDefault()});e('.bf_check').trigger('click');if(window.location.search.indexOf('post_type=buddyforms')!==-1){e('*[class^="vc_"]').remove()};if(buddyformsGlobal&&buddyformsGlobal.post_type==='buddyforms'){e(document).on('click','#bf_load_layout_options',function(){e('.layout-spinner').addClass('is-active').show();var t=e('#bf_form_layout_select').val();e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_load_form_layout','form_slug':t},success:function(e){i(e)}});return!1});e(document).on('click','#bf_reset_layout_options',function(t){e('.layout-spinner-reset').addClass('is-active').show();e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_load_form_layout','form_slug':'reset'},success:function(e){i(e)}});return!1});function i(t){e('.layout-spinner').removeClass('is-active').hide();var r=e('#buddyforms_form_designer');if(r.length>0){e.each(t,function(t,o){var s=e(r).find('input[name^="buddyforms_options[layout]"][name*="'+t+'"]'),i=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][name$="[color]"]'),n=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][name$="[style]"][value="'+o.style+'"]'),a;if(s||i||n){a=s.attr('type');if((typeof a==='undefined'||!a)&&i.length>0){a=i.attr('type')}};if('custom_css'===t){e('#'+t).text(o)};if(s.length>0&&a){switch(a){case'text':case'number':s.val(o||'');break;case'radio':e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][value="'+o+'"]').prop('checked',!0).trigger('change');break;case'checkbox':var l=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"]');l.prop('checked',(o&&l.val()===o)).trigger('change');break}};if(i.length>0){i.val(o&&o.color||'').trigger('change')};if(n.length>0){n.prop('checked',o&&o.style).trigger('change')}})}}};e(document).on('change','select.captcha-version',function(t){var r=e(this).val();if(r==='v3'){e('tr[id$="_captcha_v3_action"]').show();e('tr[id$="_captcha_v3_score"]').show();e('.bf_hide_captcha_v2_options').show()}
    24 else{e('tr[id$="_captcha_v3_action"]').hide();e('tr[id$="_captcha_v3_score"]').hide();e('.bf_hide_captcha_v2_options').hide()}});e(document).on('click','.bf-ready-to-copy',function(t){t.preventDefault();t.stopPropagation();var r=e(this);if(r.is('input')){buddyformsCopyStringToClipboard(r.val())}
    25 else{var a=e(this).closest('.accordion-heading-options'),o=a.parent().find('.accordion-body');o.removeClass('ui-accordion-content-active').hide();buddyformsCopyStringToClipboard(r.text());o.addClass('ui-accordion-content-active')};return!1})});
     21else{t.removeClass('bf-error');t.addClass('bf-ok')};var n=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_cc_address]"]');e.each(n,function(e,t){var o=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:o,element:t,type:'settings'})});var s=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_bcc_address]"]');e.each(s,function(e,t){var o=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:o,element:t,type:'settings'})});var i=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_address]"]');e.each(i,function(e,t){var o=buddyforms_validate_notifications_email(t);bfErrors.push({isValid:o,element:t,type:'settings'})});var o=e('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_from_custom]"]');if(o.length>0){var a=buddyforms_validate_notifications_email(o);bfErrors.push({isValid:a,element:o,type:'settings'})};buddyformAutoFillEmptyOrDuplicateSlugs();e('#post input[required]').each(function(){var o=(e(this).val()!='');if(o){e(this).removeClass('bf-error');var t=e(this).eq(0).attr('name');bfErrors=bfErrors.filter(function(e){return e.field_name!==t})}
     22else{var t=e(this).eq(0).attr('name');bfErrors.push({isValid:o,element:e(this)[0],type:'accordion',field_name:t});e(this).addClass('bf-error');return!1}});var r=buddyforms_process_errors(bfErrors);return r});e(document).on('click','button#btn-compile-custom',function(t){t.preventDefault();e('#buddyforms_template_header_container').show('slow').css('display','flex');e('#formbuilder-action-templates').show('slow');e('#buddyforms_template_list_container').hide('fast')});e(document).on('click','#formbuilder-show-templates',function(){e('#buddyforms_template_header_container').hide('fast');e('#buddyforms_template_list_container').show('slow');e('#formbuilder-show-templates').hide()});e(document).on('click','.bf_delete_field',function(){var t=e(this).attr('id'),o=bf_trans('Delete Permanently');if(confirm(o))e('#field_'+t).remove();return!1});e(document).on('click','.bf_delete_trigger',function(){var t=e(this).attr('id'),o=bf_trans('Delete Permanently');if(confirm(o)){e('#trigger'+t).remove();e('.trigger'+t).remove()};return!1});e(document).on('click','.bf_add_gdpr',function(){if(buddyformsGlobal){var s=e(this),t=e(this).attr('data-gdpr-type'),o=e('#table_row_'+t+'_select_options table.element_field_table_sortable tbody tr').size(),a=e('#gdpr_option_type').val(),i='';if(buddyformsGlobal.admin_text[a]){i=buddyformsGlobal.admin_text[a]};var r='';if(buddyformsGlobal.admin_text['error_message']){r=buddyformsGlobal.admin_text['error_message']};o=o+1;e('#table_row_'+t+'_select_options table.element_field_table_sortable tbody').append('<tr class="field_item field_item_'+t+'_'+o+'"><td><div class="dashicons dashicons-image-flip-vertical"></div></td><td><p><b>Agreement Text</b></p><textarea rows="3" name="buddyforms_options[form_fields]['+t+'][options]['+o+'][label]" cols="50">'+i+'</textarea><p><b>Error Message</b></p><textarea rows="3" name="buddyforms_options[form_fields]['+t+'][options]['+o+'][error_message]" cols="50">'+r+'</textarea></td><td class="manage-column column-author"><div class="checkbox">   <label class="">       <input type="checkbox" name="buddyforms_options[form_fields]['+t+'][options]['+o+'][checked][]" value="checked"><span>Checked</span>   </label></div><div class="checkbox">   <label class="">       <input type="checkbox" name="buddyforms_options[form_fields]['+t+'][options]['+o+'][required][]" value="required"><span>Required</span>   </label></div></td><td class="manage-column column-author"><a href="#" id="'+t+'_'+o+'" class="bf_delete_input">Delete</a></td></tr>');return!1}});e(document.body).on('click','.button.bf_reset_multi_input',function(t){t.preventDefault();var o=e(this).attr('data-group-name'),r=e(this).attr('data-field-id');e('input[name="buddyforms_options[form_fields]['+r+'][default]"][value="'+o+'"]').attr('checked',!1);return!1});e(document).on('click','.bf_add_input',function(){var r=e(this),t=r.attr('href').split('/'),o=e('#table_row_'+t[0]+'_select_options table.element_field_table_sortable tbody tr').size();o=o+1;e('#table_row_'+t[0]+'_select_options table.element_field_table_sortable tbody').append('<tr class="field_item field_item_'+t[0]+'_'+o+'"><td><div class="dashicons dashicons-image-flip-vertical"></div></td><td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields]['+t[0]+'][options]['+o+'][label]"></td><td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields]['+t[0]+'][options]['+o+'][value]"></td><td class="manage-column column-default"><p>Save the Form</p></td><td class="manage-column column-default"><a href="#" id="'+t[0]+'_'+o+'" class="bf_delete_input">Delete</a></td></tr>');return!1});e(document).on('click','.bf_delete_input',function(){var t=e(this).attr('id'),o=bf_trans('Delete Permanently');if(confirm(o))e('.field_item_'+t).remove();return!1});bf_update_list_item_number();e(document).on('mousedown','.bf_list_item',function(){itemList=e(this).closest('.sortable').sortable({update:function(e,t){bf_update_list_item_number()}})});bf_update_list_item_number_mail();e(document).on('click','.bf_test_trigger:not(disabled)',function(t){t.preventDefault();t.stopPropagation();var r=e(this).attr('id'),o=e(this);o.attr('disabled',!0);o.text('Sending...');e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_test_email','notification_id':r,'form_slug':o.attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,},success:function(e){alert(e)},error:function(e){alert(e.responseText)},complete:function(){o.removeAttr('disabled');o.text('Test')}});return!1});e(document).on('click','#mail_notification_add_new',function(){if(buddyformsGlobal){e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_new_mail_notification','form_slug':e(this).attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,},success:function(t){e('#no-trigger-mailcontainer').hide();e('#mailcontainer').append(t['html']);tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();e(document.body).trigger({type:'buddyform:load_notifications'})}})};return!1});e(document).on('click','#post_status_mail_notification_add_new',function(){var o=!1,t=e('.post_status_mail_notification_trigger select').val();if(!t){return!1};if(t==='none'){bf_alert('You have to select a trigger first.');return!1};e('#post-status-mail-container li.bf_trigger_list_item').each(function(){if(e(this).attr('id')=='trigger'+t){bf_alert('Trigger already exists');o=!0}});if(o==!0)return!1;if(buddyformsGlobal){e.ajax({type:'POST',url:buddyformsGlobal.admin_url,dataType:'json',data:{'action':'buddyforms_new_post_status_mail_notification','form_slug':e(this).attr('data-form-slug'),'nonce':buddyformsGlobal.ajaxnonce,'trigger':t},success:function(t){if(t==0){bf_alert('trigger already exists');return!1};e('#no-trigger-post-status-mail-container').hide();e('#post-status-mail-container').append(t['html']);tinymce.execCommand('mceRemoveEditor',!1,'bf_mail_body'+t['trigger_id']);tinymce.execCommand('mceAddEditor',!1,'bf_mail_body'+t['trigger_id']);bf_update_list_item_number_mail();e(document.body).trigger({type:'buddyform:load_notifications'})}})};return!1});e(document).on('click','.bf_check_all',function(t){if(buddyformsGlobal){e('.bf_permissions :checkbox').not('[disabled]').prop('checked',!0);e(this).removeClass();e(this).addClass('bf_uncheck_all');e(this).text(buddyformsGlobal.admin_text.uncheck)};t.preventDefault()});e(document).on('click','.bf_uncheck_all',function(t){if(buddyformsGlobal){e('.bf_permissions :checkbox').not('[disabled]').prop('checked',!1);e(this).removeClass();e(this).addClass('bf_check_all');e(this).text(buddyformsGlobal.admin_text.check)};t.preventDefault()});e(document).on('click','.bf_check',function(t){if(buddyformsGlobal){if(e('.bf_permissions input[type=\'checkbox\']').prop('checked')){e(this).text(buddyformsGlobal.admin_text.check)}
     23else{e(this).text(buddyformsGlobal.admin_text.uncheck)}};t.preventDefault()});e('.bf_check').trigger('click');if(window.location.search.indexOf('post_type=buddyforms')!==-1){e('*[class^="vc_"]').remove()};if(buddyformsGlobal&&buddyformsGlobal.post_type==='buddyforms'){e(document).on('click','#bf_load_layout_options',function(){e('.layout-spinner').addClass('is-active').show();var t=e('#bf_form_layout_select').val();e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_load_form_layout','form_slug':t},success:function(e){i(e)}});return!1});e(document).on('click','#bf_reset_layout_options',function(t){e('.layout-spinner-reset').addClass('is-active').show();e.ajax({type:'POST',dataType:'json',url:buddyformsGlobal.admin_url,data:{'action':'buddyforms_load_form_layout','form_slug':'reset'},success:function(e){i(e)}});return!1});function i(t){e('.layout-spinner').removeClass('is-active').hide();var o=e('#buddyforms_form_designer');if(o.length>0){e.each(t,function(t,r){var s=e(o).find('input[name^="buddyforms_options[layout]"][name*="'+t+'"]'),i=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][name$="[color]"]'),n=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][name$="[style]"][value="'+r.style+'"]'),a;if(s||i||n){a=s.attr('type');if((typeof a==='undefined'||!a)&&i.length>0){a=i.attr('type')}};if('custom_css'===t){e('#'+t).text(r)};if(s.length>0&&a){switch(a){case'text':case'number':s.val(r||'');break;case'radio':e('input[name^="buddyforms_options[layout]"][name*="'+t+'"][value="'+r+'"]').prop('checked',!0).trigger('change');break;case'checkbox':var l=e('input[name^="buddyforms_options[layout]"][name*="'+t+'"]');l.prop('checked',(r&&l.val()===r)).trigger('change');break}};if(i.length>0){i.val(r&&r.color||'').trigger('change')};if(n.length>0){n.prop('checked',r&&r.style).trigger('change')}})}}};e(document).on('change','select.captcha-version',function(t){var o=e(this).val();if(o==='v3'){e('tr[id$="_captcha_v3_action"]').show();e('tr[id$="_captcha_v3_score"]').show();e('.bf_hide_captcha_v2_options').show()}
     24else{e('tr[id$="_captcha_v3_action"]').hide();e('tr[id$="_captcha_v3_score"]').hide();e('.bf_hide_captcha_v2_options').hide()}});e(document).on('click','.bf-ready-to-copy',function(t){t.preventDefault();t.stopPropagation();var o=e(this);if(o.is('input')){buddyformsCopyStringToClipboard(o.val())}
     25else{var a=e(this).closest('.accordion-heading-options'),r=a.parent().find('.accordion-body');r.removeClass('ui-accordion-content-active').hide();buddyformsCopyStringToClipboard(o.text());r.addClass('ui-accordion-content-active')};return!1})});
  • buddyforms/trunk/assets/resources/dropzone/initializer.js

    r3031945 r3046092  
    11function uploadHandler() {
    22    var submitButtons, submitButton,
    33        existingHtmlInsideSubmitButton = '';
    44
    55    function getFirstSubmitButton(submitButtons) {
    66        submitButton = jQuery.map(submitButtons, function (element) {
    77            return (jQuery(element).attr('type') === 'submit' && jQuery(element).hasClass('bf-submit')) ? jQuery(element) : null;
    88        })[0];
    99        existingHtmlInsideSubmitButton = submitButton.html();
    1010    }
    1111
    1212    function buildDropZoneFieldsOptions() {
    1313        jQuery(".upload_field").each(function () {
    1414            var current = jQuery(this);
    1515            var clickeable = (current.attr('page') !== 'buddyforms_submissions');
    1616            var maxFileSize = current.attr('file_limit');
    1717            var acceptedFiles = current.attr('accepted_files');
    1818            var multipleFiles = current.attr('multiple_files');
    1919            var entry = current.data('entry');
    2020            var form_slug = current.attr('form-slug');
    2121            jQuery('#buddyforms_form_' + form_slug).show();
    2222
    2323            initSingleDropZone(current, current.attr('id'), maxFileSize, acceptedFiles, multipleFiles, clickeable, entry)
    2424        })
    2525    }
    2626
    2727    function initSingleDropZone(current, id, maxSize, acceptedFiles, multipleFiles, clickeable, uploadFields) {
    2828        //Hidden field
    2929        var hidden_field = jQuery(current).find('input[type="text"][style*="hidden"]');
    3030        //Container field
    3131        var dropzoneStringId = '#' + id;
    3232        //Set default values
    3333        if (buddyformsGlobal) {
    3434            var options = {
    3535                url: buddyformsGlobal.admin_url,
    3636                maxFilesize: maxSize,
    3737                parallelUploads: 1,
    3838                acceptedFiles: acceptedFiles,
    3939                maxFiles: multipleFiles,
    4040                clickable: clickeable,
    4141                addRemoveLinks: clickeable,
    4242                init: function () {
    4343                    this.on('queuecomplete', function () {
    4444                        current.removeClass('error');
    4545                    });
    4646                    this.on('addedfile', function () {
    4747                        DropZoneAddedFile(dropzoneStringId);
    4848                    });
    4949                    this.on('success', function (file, response) {
    5050                        DropZoneSuccess(file, response, hidden_field);
    5151                    });
    5252                    this.on('error', DropZoneError);
    5353                    this.on('sending', DropZoneSending);
    5454                    this.on('sendingmultiple', DropZoneSending);
    5555                    this.on('complete', DropZoneComplete);
    5656                    this.on('completemultiple', DropZoneComplete);
    5757                    this.on('removedfile', function (file) {
    5858                        DropZoneRemovedFile(file, hidden_field);
    5959                    });
    6060
    6161                    if (uploadFields) {
    6262                        for (var key in uploadFields) {
    6363                            if (key) {
    6464                                var mockFile = {
    6565                                    name: uploadFields[key]['name'],
    6666                                    size: uploadFields[key]['size'],
    6767                                    url: uploadFields[key]['url'],
    6868                                    attachment_id: uploadFields[key]['attachment_id'],
    6969                                };
    7070                                this.emit('addedfile', mockFile);
    7171                                this.emit('thumbnail', mockFile, mockFile.url);
    7272                                this.emit('complete', mockFile);
    7373                                this.files.push(mockFile);
    7474                            }
    7575                        }
    7676                    }
    7777                },
    7878                //Language options
    7979                dictMaxFilesExceeded: buddyformsGlobal.localize.upload.dictMaxFilesExceeded || "You can not upload any more files.",
    8080                dictRemoveFile: buddyformsGlobal.localize.upload.dictRemoveFile || "Remove file",
    8181                dictCancelUploadConfirmation: buddyformsGlobal.localize.upload.dictCancelUploadConfirmation || "Are you sure you want to cancel this upload?",
    8282                dictCancelUpload: buddyformsGlobal.localize.upload.dictCancelUpload || "Cancel upload",
    8383                dictResponseError: buddyformsGlobal.localize.upload.dictResponseError || "Server responded with {{statusCode}} code.",
    8484                dictInvalidFileType: buddyformsGlobal.localize.upload.dictInvalidFileType || "You can't upload files of this type.",
    8585                dictFileTooBig: buddyformsGlobal.localize.upload.dictFileTooBig || "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
    8686                dictFallbackMessage: buddyformsGlobal.localize.upload.dictFallbackMessage || "Your browser does not support drag'n'drop file uploads.",
    8787                dictDefaultMessage: buddyformsGlobal.localize.upload.dictDefaultMessage || "Drop files here to upload",
    8888            };
    8989            jQuery(current).dropzone(options);
    9090        }
    9191    }
    9292
    9393    function DropZoneComplete() {
    9494        enabledSubmitButtons();
    9595    }
    9696
    9797    function DropZoneAddedFile(dropzoneContainer) {
    9898        jQuery(dropzoneContainer).find("label[class*='error']").text("");
    9999        jQuery(dropzoneContainer).find('.dz-progress').hide()
    100100    }
    101101
    102102    function DropZoneSending(file, xhr, formData) {
    103103        disableSubmitButtons(true);
     104        var form_slug = jQuery('#form_slug').val();
    104105        formData.append('action', 'handle_dropped_media');
    105106        formData.append('nonce', buddyformsGlobal.ajaxnonce);
     107        formData.append('form_slug', form_slug );
    106108    }
    107109
    108110    function DropZoneSuccess(file, response, currentField) {
    109111        file.previewElement.classList.add("dz-success");
    110112        file['attachment_id'] = response; // push the id for future reference
    111113        var ids = jQuery(currentField).val() + ',' + response;
    112114        var idsFormat = "";
    113115        if (ids[0] === ',') {
    114116            idsFormat = ids.substring(1, ids.length);
    115117        } else {
    116118            idsFormat = ids;
    117119        }
    118120        jQuery(currentField).attr('value', idsFormat);
    119121    }
    120122
    121123    function DropZoneError(file, response) {
    122124        file.previewElement.classList.add("dz-error");
    123125        jQuery(file.previewElement).find('div.dz-error-message>span').text(response);
    124126        enabledSubmitButtons();
    125127    }
    126128
    127129    function DropZoneRemovedFile(file, currentField) {
    128130        var attachment_id = file.attachment_id;
    129131        var ids = jQuery(currentField).val();
    130132        var remainigIds = ids.replace(attachment_id, "");
    131133        if (remainigIds[0] === ',') {
    132134            remainigIds = remainigIds.substring(1, ids.length);
    133135        }
    134136        var lastChar = remainigIds[remainigIds.length - 1];
    135137        if (lastChar === ',') {
    136138            remainigIds = remainigIds.slice(0, -1);
    137139        }
    138140        jQuery(currentField).attr('value', remainigIds);
    139141        handleDeletedMedia(attachment_id);
    140142    }
    141143
    142144    function handleDeletedMedia(attachmentId) {
    143145        disableSubmitButtons(false);
    144146        jQuery.post(buddyformsGlobal.admin_url, {
    145147            action: 'handle_deleted_media',
    146148            media_id: attachmentId,
    147149            nonce: buddyformsGlobal.ajaxnonce
    148150        }, function (data) {
    149151            console.log(data);
    150152        }).always(function () {
    151153            enabledSubmitButtons();
    152154        });
    153155    }
    154156
    155157    function disableSubmitButtons(showButtonText) {
    156158        if (buddyformsGlobal) {
    157159            if (submitButtons.length > 0) {
    158160                showButtonText = !!(showButtonText);
    159161                submitButtons.attr("disabled", "disabled");
    160162                if (showButtonText) {
    161163                    submitButton.html(buddyformsGlobal.localize.upload.submitButton || 'Upload in progress'); // todo need il18n
    162164                }
    163165            }
    164166        }
    165167    }
    166168
    167169    function checkToEnableSubmit() {
    168170        var result = true;
    169171        jQuery(".upload_field").each(function () {
    170172            var currentDropZone = jQuery(this)[0].dropzone;
    171173            if (currentDropZone && currentDropZone.files.length > 0) {
    172174                var allFilesSuccessDiff = currentDropZone.files.filter(function (file) {
    173175                    return file.status === Dropzone.UPLOADING;
    174176                });
    175177                result = allFilesSuccessDiff.length === 0;
    176178            }
    177179        });
    178180
    179181        return result;
    180182    }
    181183
    182184    function enabledSubmitButtons() {
    183185        if (submitButtons.length > 0 && checkToEnableSubmit()) {
    184186            submitButtons.removeAttr("disabled");
    185187            submitButton.html(existingHtmlInsideSubmitButton);
    186188        }
    187189    }
    188190
    189191    return {
    190192        init: function () {
    191193            var uploadFields = jQuery(".upload_field");
    192194            submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=submit]");
    193195            if (submitButtons.length > 0) {
    194196                getFirstSubmitButton(submitButtons);
    195197            }
    196198            if (uploadFields.length > 0) {
    197199                buildDropZoneFieldsOptions();
    198200            }
    199201        }
    200202    }
    201203}
    202204
    203205function validateAndUploadImage(field) {
    204206
    205207    var current = jQuery(field);
    206208    var id = current.attr("field-id");
    207209    var accepted_files = current.attr("accepted_files");
    208210    jQuery("#" + id + "_label").text("");
    209211    jQuery("#" + id + "_image").attr('src', "");
    210212    jQuery("#field_" + id).val("");
    211213    var url = jQuery("#" + id + "_upload_from_url").val();
    212214
    213215    if (checkURL(url)) {
    214216
    215217        jQuery("#" + id + "_upload_button").text("Uploading..");
    216218        jQuery("#" + id + "_upload_button").attr('disabled', true);
    217219        var submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]");
    218220        submitButtons.attr('disabled', true);
    219221
    220222        jQuery.ajax({
    221223            url: buddyformsGlobal.admin_url,
    222224            type: 'post',
    223225            data: {
    224226                action: 'upload_image_from_url',
    225227                url: encodeURIComponent(url),
    226228                accepted_files: accepted_files,
    227229                id: id
    228230            },
    229231            success: function (response) {
    230232                var result = JSON.parse(response);
    231233                if(result.status ==="OK"){
    232234                    jQuery("#" + id + "_image").attr('src', result.response);
    233235                    jQuery("#" + id + "_image").attr('width', 300);
    234236                    jQuery("#" + id + "_image").attr('height', 300);
    235237                    jQuery("#field_" + id).val(result.attachment_id);
    236238
    237239                    jQuery("#" + id + "_upload_button").text("Upload");
    238240                    jQuery("#" + id + "_upload_button").attr('disabled', false);
    239241                    submitButtons.attr('disabled', false);
    240242                }else{
    241243                    if(result.status ==="FAILED"){
    242244                        jQuery("#" + id + "_label").text(result.response);
    243245                        jQuery("#" + id + "_upload_button").text("Upload");
    244246                        jQuery("#" + id + "_upload_button").attr('disabled', false);
    245247                        submitButtons.attr('disabled', false);
    246248                    }
    247249                }
    248250            },
    249251            error: function (error) {
    250252                var result = JSON.parse(error);
    251253            }
    252254
    253255        });
    254256
    255257    } else {
    256258        jQuery("#" + id + "_label").text("Wrong Url Format");
    257259    }
    258260}
    259261
    260262function checkURL(url) {
    261263    return (url.match(/\.(jpeg|jpg|gif|png)$/) != null);
    262264}
    263265
    264266var uploadImplementation = uploadHandler();
    265267jQuery(document).ready(function () {
    266268    uploadImplementation.init();
    267269});
    268270if(Dropzone) {
    269271    Dropzone.autoDiscover = false;
    270272}
  • buddyforms/trunk/assets/resources/dropzone/initializer.min.js

    r3031945 r3046092  
    1 ;function uploadHandler(){var e,t,i="";function d(e){t=jQuery.map(e,function(e){return(jQuery(e).attr("type")==="submit"&&jQuery(e).hasClass("bf-submit"))?jQuery(e):null})[0];i=t.html()};function n(){jQuery(".upload_field").each(function(){var e=jQuery(this),t=(e.attr("page")!=="buddyforms_submissions"),a=e.attr("file_limit"),i=e.attr("accepted_files"),l=e.attr("multiple_files"),o=e.data("entry"),r=e.attr("form-slug");jQuery("#buddyforms_form_"+r).show();u(e,e.attr("id"),a,i,l,t,o)})};function u(e,t,i,n,u,r,a){var d=jQuery(e).find("input[type=\"text\"][style*=\"hidden\"]"),b="#"+t;if(buddyformsGlobal){var m={url:buddyformsGlobal.admin_url,maxFilesize:i,parallelUploads:1,acceptedFiles:n,maxFiles:u,clickable:r,addRemoveLinks:r,init:function(){this.on("queuecomplete",function(){e.removeClass("error")});this.on("addedfile",function(){s(b)});this.on("success",function(e,t){c(e,t,d)});this.on("error",f);this.on("sending",o);this.on("sendingmultiple",o);this.on("complete",l);this.on("completemultiple",l);this.on("removedfile",function(e){p(e,d)});if(a){for(var i in a){if(i){var t={name:a[i]["name"],size:a[i]["size"],url:a[i]["url"],attachment_id:a[i]["attachment_id"],};this.emit("addedfile",t);this.emit("thumbnail",t,t.url);this.emit("complete",t);this.files.push(t)}}}},dictMaxFilesExceeded:buddyformsGlobal.localize.upload.dictMaxFilesExceeded||"You can not upload any more files.",dictRemoveFile:buddyformsGlobal.localize.upload.dictRemoveFile||"Remove file",dictCancelUploadConfirmation:buddyformsGlobal.localize.upload.dictCancelUploadConfirmation||"Are you sure you want to cancel this upload?",dictCancelUpload:buddyformsGlobal.localize.upload.dictCancelUpload||"Cancel upload",dictResponseError:buddyformsGlobal.localize.upload.dictResponseError||"Server responded with {{statusCode}} code.",dictInvalidFileType:buddyformsGlobal.localize.upload.dictInvalidFileType||"You can't upload files of this type.",dictFileTooBig:buddyformsGlobal.localize.upload.dictFileTooBig||"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictFallbackMessage:buddyformsGlobal.localize.upload.dictFallbackMessage||"Your browser does not support drag'n'drop file uploads.",dictDefaultMessage:buddyformsGlobal.localize.upload.dictDefaultMessage||"Drop files here to upload",};jQuery(e).dropzone(m)}};function l(){a()};function s(e){jQuery(e).find("label[class*='error']").text("");jQuery(e).find(".dz-progress").hide()};function o(e,t,a){r(!0);a.append("action","handle_dropped_media");a.append("nonce",buddyformsGlobal.ajaxnonce)};function c(e,t,a){e.previewElement.classList.add("dz-success");e["attachment_id"]=t;var i=jQuery(a).val()+","+t,l="";if(i[0]===","){l=i.substring(1,i.length)}
     1;function uploadHandler(){var e,t,i="";function d(e){t=jQuery.map(e,function(e){return(jQuery(e).attr("type")==="submit"&&jQuery(e).hasClass("bf-submit"))?jQuery(e):null})[0];i=t.html()};function n(){jQuery(".upload_field").each(function(){var e=jQuery(this),t=(e.attr("page")!=="buddyforms_submissions"),a=e.attr("file_limit"),i=e.attr("accepted_files"),l=e.attr("multiple_files"),o=e.data("entry"),r=e.attr("form-slug");jQuery("#buddyforms_form_"+r).show();u(e,e.attr("id"),a,i,l,t,o)})};function u(e,t,i,n,u,r,a){var d=jQuery(e).find("input[type=\"text\"][style*=\"hidden\"]"),b="#"+t;if(buddyformsGlobal){var m={url:buddyformsGlobal.admin_url,maxFilesize:i,parallelUploads:1,acceptedFiles:n,maxFiles:u,clickable:r,addRemoveLinks:r,init:function(){this.on("queuecomplete",function(){e.removeClass("error")});this.on("addedfile",function(){s(b)});this.on("success",function(e,t){c(e,t,d)});this.on("error",f);this.on("sending",o);this.on("sendingmultiple",o);this.on("complete",l);this.on("completemultiple",l);this.on("removedfile",function(e){p(e,d)});if(a){for(var i in a){if(i){var t={name:a[i]["name"],size:a[i]["size"],url:a[i]["url"],attachment_id:a[i]["attachment_id"],};this.emit("addedfile",t);this.emit("thumbnail",t,t.url);this.emit("complete",t);this.files.push(t)}}}},dictMaxFilesExceeded:buddyformsGlobal.localize.upload.dictMaxFilesExceeded||"You can not upload any more files.",dictRemoveFile:buddyformsGlobal.localize.upload.dictRemoveFile||"Remove file",dictCancelUploadConfirmation:buddyformsGlobal.localize.upload.dictCancelUploadConfirmation||"Are you sure you want to cancel this upload?",dictCancelUpload:buddyformsGlobal.localize.upload.dictCancelUpload||"Cancel upload",dictResponseError:buddyformsGlobal.localize.upload.dictResponseError||"Server responded with {{statusCode}} code.",dictInvalidFileType:buddyformsGlobal.localize.upload.dictInvalidFileType||"You can't upload files of this type.",dictFileTooBig:buddyformsGlobal.localize.upload.dictFileTooBig||"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictFallbackMessage:buddyformsGlobal.localize.upload.dictFallbackMessage||"Your browser does not support drag'n'drop file uploads.",dictDefaultMessage:buddyformsGlobal.localize.upload.dictDefaultMessage||"Drop files here to upload",};jQuery(e).dropzone(m)}};function l(){a()};function s(e){jQuery(e).find("label[class*='error']").text("");jQuery(e).find(".dz-progress").hide()};function o(e,t,a){r(!0);var i=jQuery("#form_slug").val();a.append("action","handle_dropped_media");a.append("nonce",buddyformsGlobal.ajaxnonce);a.append("form_slug",i)};function c(e,t,a){e.previewElement.classList.add("dz-success");e["attachment_id"]=t;var i=jQuery(a).val()+","+t,l="";if(i[0]===","){l=i.substring(1,i.length)}
    22else{l=i};jQuery(a).attr("value",l)};function f(e,t){e.previewElement.classList.add("dz-error");jQuery(e.previewElement).find("div.dz-error-message>span").text(t);a()};function p(e,a){var i=e.attachment_id,l=jQuery(a).val(),t=l.replace(i,"");if(t[0]===","){t=t.substring(1,l.length)};var o=t[t.length-1];if(o===","){t=t.slice(0,-1)};jQuery(a).attr("value",t);m(i)};function m(e){r(!1);jQuery.post(buddyformsGlobal.admin_url,{action:"handle_deleted_media",media_id:e,nonce:buddyformsGlobal.ajaxnonce},function(e){console.log(e)}).always(function(){a()})};function r(a){if(buddyformsGlobal){if(e.length>0){a=!!(a);e.attr("disabled","disabled");if(a){t.html(buddyformsGlobal.localize.upload.submitButton||"Upload in progress")}}}};function b(){var e=!0;jQuery(".upload_field").each(function(){var t=jQuery(this)[0].dropzone;if(t&&t.files.length>0){var a=t.files.filter(function(e){return e.status===Dropzone.UPLOADING});e=a.length===0}});return e};function a(){if(e.length>0&&b()){e.removeAttr("disabled");t.html(i)}};return{init:function(){var t=jQuery(".upload_field");e=jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=submit]");if(e.length>0){d(e)};if(t.length>0){n()}}}};function validateAndUploadImage(e){var l=jQuery(e),t=l.attr("field-id"),o=l.attr("accepted_files");jQuery("#"+t+"_label").text("");jQuery("#"+t+"_image").attr("src","");jQuery("#field_"+t).val("");var i=jQuery("#"+t+"_upload_from_url").val();if(checkURL(i)){jQuery("#"+t+"_upload_button").text("Uploading..");jQuery("#"+t+"_upload_button").attr("disabled",!0);var a=jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]");a.attr("disabled",!0);jQuery.ajax({url:buddyformsGlobal.admin_url,type:"post",data:{action:"upload_image_from_url",url:encodeURIComponent(i),accepted_files:o,id:t},success:function(e){var i=JSON.parse(e);if(i.status==="OK"){jQuery("#"+t+"_image").attr("src",i.response);jQuery("#"+t+"_image").attr("width",300);jQuery("#"+t+"_image").attr("height",300);jQuery("#field_"+t).val(i.attachment_id);jQuery("#"+t+"_upload_button").text("Upload");jQuery("#"+t+"_upload_button").attr("disabled",!1);a.attr("disabled",!1)}
    33else{if(i.status==="FAILED"){jQuery("#"+t+"_label").text(i.response);jQuery("#"+t+"_upload_button").text("Upload");jQuery("#"+t+"_upload_button").attr("disabled",!1);a.attr("disabled",!1)}}},error:function(e){var t=JSON.parse(e)}})}
    44else{jQuery("#"+t+"_label").text("Wrong Url Format")}};function checkURL(e){return(e.match(/\.(jpeg|jpg|gif|png)$/)!=null)};var uploadImplementation=uploadHandler();jQuery(document).ready(function(){uploadImplementation.init()});if(Dropzone){Dropzone.autoDiscover=!1};
  • buddyforms/trunk/assets/resources/featured-image/featured-image-initializer.js

    r3031945 r3046092  
    11jQuery(document).ready(function() {
    22    var submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]");
    33    var submitButton;
    44    if (submitButtons.length > 0) {
    55        submitButton = jQuery.map(submitButtons, function (element) {
    66            return (jQuery(element).attr('type') === 'submit' && jQuery(element).hasClass('bf-submit')) ? jQuery(element) : null;
    77        })[0];
    88        var existingHtmlInsideSubmitButton = submitButton.html();
    99    }
    1010
    1111    jQuery(".featured-image-uploader").each(function(index, value) {
    1212        var current = jQuery(this),
    1313            id = current.attr('id'),
    1414            max_file_size = current.attr('max_file_size'),
    1515            page = current.attr('page'),
    1616            uploadFields = current.data('entry');
    1717
    1818        var clickeable = page !== 'buddyforms_submissions';
    1919        var currentField = jQuery('#field_' + id);
    2020
    2121        if(buddyformsGlobal) {
    2222
    2323            // Fallback:
    2424            // Check if the form was already inizialize
    2525            // by a third party plugin or theme.
    2626            const dropzoneControl = current[0].dropzone;
    2727            if (dropzoneControl) {
    2828                dropzoneControl.destroy();
    2929            }
    3030
    3131            var myDropzone = new Dropzone("div#" + id, {
    3232                url: buddyformsGlobal.admin_url,
    3333                maxFilesize: max_file_size,
    3434                acceptedFiles: 'image/*',
    3535                maxFiles: 1,
    3636                clickable: clickeable,
    3737                addRemoveLinks: clickeable,
    3838                init: function () {
    3939                    this.on('complete', function () {
    4040                        if (submitButtons.length > 0) {
    4141                            submitButtons.removeAttr("disabled");
    4242                            submitButton.html(existingHtmlInsideSubmitButton);
    4343                        }
    4444                    });
    4545                    this.on('addedfile', function () {
    4646                        jQuery("#field_" + id + "-error").text("");
    4747                        if (this.files.length > 1) {
    4848                            this.removeFile(this.files[0]);
    4949                        }
    5050                        if (submitButtons.length > 0) {
    5151                            submitButtons.attr("disabled", "disabled");
    5252                            submitButton.html(buddyformsGlobal.localize.upload.submitButton || 'Upload in progress');
    5353                        }
    5454                    });
    5555
    5656                    this.on('sending', function (file, xhr, formData) {
     57                        var form_slug = jQuery('#form_slug').val();
    5758                        formData.append('action', 'handle_dropped_media');
    5859                        formData.append('nonce', buddyformsGlobal.ajaxnonce);
     60                        formData.append('form_slug', form_slug );
    5961                    });
    6062
    6163                    this.on('success', function (file, response) {
    6264                        current.removeClass('error');
    6365                        file.previewElement.classList.add("dz-success");
    6466                        file['attachment_id'] = response; // push the id for future reference
    6567                        var ids = currentField.val() + ',' + response;
    6668                        var idsFormat = "";
    6769                        if (ids[0] === ',') {
    6870                            idsFormat = ids.substring(1, ids.length);
    6971                        } else {
    7072                            idsFormat = ids;
    7173                        }
    7274                        currentField.val(idsFormat);
    7375                    });
    7476
    7577                    this.on('error', function (file, response) {
    7678                        file.previewElement.classList.add("dz-error");
    7779                        jQuery(file.previewElement).find('div.dz-error-message>span').text(response);
    7880                        if (submitButtons.length > 0) {
    7981                            submitButtons.removeAttr("disabled");
    8082                            submitButton.html(existingHtmlInsideSubmitButton);
    8183                        }
    8284                    });
    8385                    this.on('removedfile', function (file) {
    8486                        var attachment_id = file.attachment_id;
    8587                        var ids = currentField.val();
    8688                        var remainigIds = ids.replace(attachment_id, "");
    8789                        if (remainigIds[0] === ',') {
    8890                            remainigIds = remainigIds.substring(1, ids.length);
    8991                        }
    9092                        var lastChar = remainigIds[remainigIds.length - 1];
    9193                        if (lastChar === ',') {
    9294                            remainigIds = remainigIds.slice(0, -1);
    9395                        }
    9496                        currentField.val(remainigIds);
    9597                        submitButtons.attr("disabled", "disabled");
    9698                        jQuery.post(buddyformsGlobal.admin_url, {
    9799                            action: 'handle_deleted_media',
    98100                            media_id: attachment_id,
    99101                            nonce: buddyformsGlobal.ajaxnonce
    100102                        }, function (data) {
    101103                            console.log(data);
    102104                        }).always(function () {
    103105                            if (submitButtons.length > 0) {
    104106                                submitButtons.removeAttr("disabled");
    105107                                submitButton.html(existingHtmlInsideSubmitButton);
    106108                            }
    107109                        });
    108110                    });
    109111
    110112                    if (uploadFields) {
    111113                        for (var key in uploadFields) {
    112114                            if (key) {
    113115                                var mockFile = {
    114116                                    name: uploadFields[key]['name'],
    115117                                    size: uploadFields[key]['size'],
    116118                                    url: uploadFields[key]['url'],
    117119                                    attachment_id: uploadFields[key]['attachment_id']
    118120                                };
    119121                                this.emit('addedfile', mockFile);
    120122                                this.emit('thumbnail', mockFile, mockFile.url);
    121123                                this.emit('complete', mockFile);
    122124                                this.files.push(mockFile);
    123125                            }
    124126                        }
    125127                    }
    126128                },
    127129                //Language options
    128130                dictMaxFilesExceeded: buddyformsGlobal.localize.upload.dictMaxFilesExceeded || "You can not upload any more files.",
    129131                dictRemoveFile: buddyformsGlobal.localize.upload.dictRemoveFile || "Remove file",
    130132                dictCancelUploadConfirmation: buddyformsGlobal.localize.upload.dictCancelUploadConfirmation || "Are you sure you want to cancel this upload?",
    131133                dictCancelUpload: buddyformsGlobal.localize.upload.dictCancelUpload || "Cancel upload",
    132134                dictResponseError: buddyformsGlobal.localize.upload.dictResponseError || "Server responded with {{statusCode}} code.",
    133135                dictInvalidFileType: buddyformsGlobal.localize.upload.dictInvalidFileType || "You can't upload files of this type.",
    134136                dictFileTooBig: buddyformsGlobal.localize.upload.dictFileTooBig || "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
    135137                dictFallbackMessage: buddyformsGlobal.localize.upload.dictFallbackMessage || "Your browser does not support drag'n'drop file uploads.",
    136138                dictDefaultMessage: buddyformsGlobal.localize.upload.dictDefaultMessage || "Drop files here to upload",
    137139            });
    138140        }
    139141
    140142    });
    141143});
    142144
    143145if(Dropzone) {
    144146    Dropzone.autoDiscover = false;
    145147}
  • buddyforms/trunk/assets/resources/featured-image/featured-image-initializer.min.js

    r3031945 r3046092  
    1 ;jQuery(document).ready(function(){var e=jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]"),o;if(e.length>0){o=jQuery.map(e,function(e){return(jQuery(e).attr("type")==="submit"&&jQuery(e).hasClass("bf-submit"))?jQuery(e):null})[0];var i=o.html()};jQuery(".featured-image-uploader").each(function(l,r){var a=jQuery(this),s=a.attr("id"),u=a.attr("max_file_size"),c=a.attr("page"),t=a.data("entry"),n=c!=="buddyforms_submissions",d=jQuery("#field_"+s);if(buddyformsGlobal){const dropzoneControl=a[0].dropzone;if(dropzoneControl){dropzoneControl.destroy()};var f=new Dropzone("div#"+s,{url:buddyformsGlobal.admin_url,maxFilesize:u,acceptedFiles:"image/*",maxFiles:1,clickable:n,addRemoveLinks:n,init:function(){this.on("complete",function(){if(e.length>0){e.removeAttr("disabled");o.html(i)}});this.on("addedfile",function(){jQuery("#field_"+s+"-error").text("");if(this.files.length>1){this.removeFile(this.files[0])};if(e.length>0){e.attr("disabled","disabled");o.html(buddyformsGlobal.localize.upload.submitButton||"Upload in progress")}});this.on("sending",function(e,o,i){i.append("action","handle_dropped_media");i.append("nonce",buddyformsGlobal.ajaxnonce)});this.on("success",function(e,o){a.removeClass("error");e.previewElement.classList.add("dz-success");e["attachment_id"]=o;var i=d.val()+","+o,l="";if(i[0]===","){l=i.substring(1,i.length)}
     1;jQuery(document).ready(function(){var e=jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]"),o;if(e.length>0){o=jQuery.map(e,function(e){return(jQuery(e).attr("type")==="submit"&&jQuery(e).hasClass("bf-submit"))?jQuery(e):null})[0];var i=o.html()};jQuery(".featured-image-uploader").each(function(l,r){var a=jQuery(this),s=a.attr("id"),u=a.attr("max_file_size"),c=a.attr("page"),t=a.data("entry"),n=c!=="buddyforms_submissions",d=jQuery("#field_"+s);if(buddyformsGlobal){const dropzoneControl=a[0].dropzone;if(dropzoneControl){dropzoneControl.destroy()};var f=new Dropzone("div#"+s,{url:buddyformsGlobal.admin_url,maxFilesize:u,acceptedFiles:"image/*",maxFiles:1,clickable:n,addRemoveLinks:n,init:function(){this.on("complete",function(){if(e.length>0){e.removeAttr("disabled");o.html(i)}});this.on("addedfile",function(){jQuery("#field_"+s+"-error").text("");if(this.files.length>1){this.removeFile(this.files[0])};if(e.length>0){e.attr("disabled","disabled");o.html(buddyformsGlobal.localize.upload.submitButton||"Upload in progress")}});this.on("sending",function(e,o,i){var l=jQuery("#form_slug").val();i.append("action","handle_dropped_media");i.append("nonce",buddyformsGlobal.ajaxnonce);i.append("form_slug",l)});this.on("success",function(e,o){a.removeClass("error");e.previewElement.classList.add("dz-success");e["attachment_id"]=o;var i=d.val()+","+o,l="";if(i[0]===","){l=i.substring(1,i.length)}
    22else{l=i};d.val(l)});this.on("error",function(l,a){l.previewElement.classList.add("dz-error");jQuery(l.previewElement).find("div.dz-error-message>span").text(a);if(e.length>0){e.removeAttr("disabled");o.html(i)}});this.on("removedfile",function(a){var t=a.attachment_id,r=d.val(),l=r.replace(t,"");if(l[0]===","){l=l.substring(1,r.length)};var s=l[l.length-1];if(s===","){l=l.slice(0,-1)};d.val(l);e.attr("disabled","disabled");jQuery.post(buddyformsGlobal.admin_url,{action:"handle_deleted_media",media_id:t,nonce:buddyformsGlobal.ajaxnonce},function(e){console.log(e)}).always(function(){if(e.length>0){e.removeAttr("disabled");o.html(i)}})});if(t){for(var r in t){if(r){var l={name:t[r]["name"],size:t[r]["size"],url:t[r]["url"],attachment_id:t[r]["attachment_id"]};this.emit("addedfile",l);this.emit("thumbnail",l,l.url);this.emit("complete",l);this.files.push(l)}}}},dictMaxFilesExceeded:buddyformsGlobal.localize.upload.dictMaxFilesExceeded||"You can not upload any more files.",dictRemoveFile:buddyformsGlobal.localize.upload.dictRemoveFile||"Remove file",dictCancelUploadConfirmation:buddyformsGlobal.localize.upload.dictCancelUploadConfirmation||"Are you sure you want to cancel this upload?",dictCancelUpload:buddyformsGlobal.localize.upload.dictCancelUpload||"Cancel upload",dictResponseError:buddyformsGlobal.localize.upload.dictResponseError||"Server responded with {{statusCode}} code.",dictInvalidFileType:buddyformsGlobal.localize.upload.dictInvalidFileType||"You can't upload files of this type.",dictFileTooBig:buddyformsGlobal.localize.upload.dictFileTooBig||"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictFallbackMessage:buddyformsGlobal.localize.upload.dictFallbackMessage||"Your browser does not support drag'n'drop file uploads.",dictDefaultMessage:buddyformsGlobal.localize.upload.dictDefaultMessage||"Drop files here to upload",})}})});if(Dropzone){Dropzone.autoDiscover=!1};
  • buddyforms/trunk/includes/admin/admin-ajax.php

    r3031945 r3046092  
    11<?php
    22
    33if ( ! defined( 'ABSPATH' ) ) { exit; }
    44
    55
    66use tk\GuzzleHttp\Client;
    77use tk\GuzzleHttp\Psr7\Request;
    88
    99add_action( 'wp_ajax_buddyforms_post_types_taxonomies', 'buddyforms_post_types_taxonomies' );
    1010function buddyforms_post_types_taxonomies() {
    1111
    1212    if ( ! isset( $_POST['post_type'] ) ) {
    1313        echo 'false';
    1414        die();
    1515    }
    1616
    1717    $post_type             = buddyforms_sanitize( '', wp_unslash( $_POST['post_type'] ) );
    1818    $buddyforms_taxonomies = buddyforms_taxonomies( $post_type );
    1919
    2020    $tmp = '';
    2121    foreach ( $buddyforms_taxonomies as $name => $label ) {
    2222        $tmp .= '<option value="' . $name . '">' . $label . '</option>';
    2323    }
    2424
    2525    echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() );
    2626    die();
    2727
    2828}
    2929
    3030add_action( 'wp_ajax_buddyforms_close_submission_default_page_notification', 'buddyforms_close_submission_default_page_notification' );
    3131/**
    3232 * @return bool
    3333 */
    3434function buddyforms_close_submission_default_page_notification() {
    3535    if ( ! ( is_array( $_POST ) && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    3636        die();
    3737    }
    3838    if ( ! isset( $_POST['action'] ) || wp_verify_nonce( $_POST['nonce'], 'fac_drop' ) === false || $_POST['action'] !== 'buddyforms_close_submission_default_page_notification' ) {
    3939        die();
    4040    }
    4141    update_option( 'close_submission_default_page_notification', 1 );
    4242    die();
    4343}
    4444
    4545add_action( 'wp_ajax_buddyforms_update_taxonomy_default', 'buddyforms_update_taxonomy_default' );
    4646function buddyforms_update_taxonomy_default() {
    4747
    4848    if ( ! isset( $_POST['taxonomy'] ) || $_POST['taxonomy'] == 'none' ) {
    4949        $tmp = '<option value="none">' . __( 'First you need to select a Taxonomy to select the Taxonomy defaults', 'buddyforms' ) . '</option>';
    5050        echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() );
    5151        die();
    5252    }
    5353
    5454    $taxonomy = buddyforms_sanitize( '', wp_unslash( $_POST['taxonomy'] ) );
    5555
    5656    $args = array(
    5757        'orderby'    => 'name',
    5858        'order'      => 'ASC',
    5959        'hide_empty' => false,
    6060        'fields'     => 'id=>name',
    6161    );
    6262
    6363    $terms = get_terms( $taxonomy, $args );
    6464
    6565    $tmp = '<option value="none">none</option>';
    6666    foreach ( $terms as $key => $term_name ) {
    6767        $tmp .= '<option value="' . $key . '">' . $term_name . '</option>';
    6868    }
    6969
    7070    echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() );
    7171
    7272    die();
    7373
    7474}
    7575
    7676add_action( 'wp_ajax_buddyforms_new_page', 'buddyforms_new_page' );
    7777/**
    7878 * Create the holder page to be use as endpoint
    7979 */
    8080function buddyforms_new_page() {
    8181
    82     if ( ! is_admin() ) {
     82    check_ajax_referer( 'fac_drop', 'nonce' );
     83   
     84    if ( ! current_user_can( 'manage_options' ) ) {
    8385        return;
    8486    }
    8587
    8688    // Check if a title is entered
    8789    if ( empty( $_POST['page_name'] ) ) {
    8890        $json['error'] = __( 'Please enter a name', 'buddyforms' );
    8991        echo json_encode( $json );
    9092        die();
    9193    }
    9294
    9395    // Create post object
    9496    $new_page = array(
    9597        'post_title'   => wp_strip_all_tags( wp_unslash( $_POST['page_name'] ) ),
    9698        'post_content' => '',
    9799        'post_status'  => 'publish',
    98100        'post_type'    => 'page',
    99101    );
    100102
    101103    // Insert the post into the database
    102104    $new_page = wp_insert_post( $new_page );
    103105
    104106    // Check if page creation worked successfully
    105107    if ( is_wp_error( $new_page ) ) {
    106108        $json['error'] = $new_page;
    107109    } else {
    108110        $json['id']   = $new_page;
    109111        $json['name'] = wp_strip_all_tags( wp_unslash( $_POST['page_name'] ) );
    110112    }
    111113
    112114    echo json_encode( $json );
    113115    die();
    114116
    115117}
    116118
    117119add_action( 'wp_ajax_buddyforms_url_builder', 'buddyforms_url_builder' );
    118120function buddyforms_url_builder() {
    119121    global $post;
    120122    $page_id   = filter_var( wp_unslash( $_POST['attached_page'] ), FILTER_VALIDATE_INT );
    121123    $form_slug = filter_var( wp_unslash( $_POST['form_slug'] ), FILTER_SANITIZE_STRING );
    122124    $post      = get_post( $page_id );
    123125
    124126    if ( isset( $post->post_name ) ) {
    125127        $json['permalink'] = get_permalink( $page_id );
    126128        $json['form_slug'] = $form_slug;
    127129        echo json_encode( $json );
    128130        die();
    129131    }
    130132    echo json_encode( 'none' );
    131133    die();
    132134}
    133135
    134136function buddyforms_custom_form_template_tracking() {
    135137    if ( ! ( is_array( $_POST ) && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    136138        die();
    137139    }
    138140    if ( ! isset( $_POST['action'] ) || ! isset( $_POST['nonce'] ) ) {
    139141        die();
    140142    }
    141143    if ( ! wp_verify_nonce( $_POST['nonce'], 'fac_drop' ) ) {
    142144        die();
    143145    }
    144146    buddyforms_track(
    145147        'selected-form-template',
    146148        array(
    147149            'template' => 'custom',
    148150            'type'     => 'custom',
    149151        )
    150152    );
    151153}
    152154
    153155add_action( 'wp_ajax_buddyforms_custom_form_template', 'buddyforms_custom_form_template_tracking' );
  • buddyforms/trunk/includes/admin/form-builder/meta-boxes/metabox-form-setup.php

    r3031945 r3046092  
    11<?php
    22
    33if ( !defined( 'ABSPATH' ) ) {
    44    exit;
    55}
    66function buddyforms_metabox_form_setup()
    77{
    88    global  $post ;
    99    if ( $post->post_type != 'buddyforms' ) {
    1010        return;
    1111    }
    1212    // Get the BuddyForms Options
    1313    $buddyform = get_post_meta( get_the_ID(), '_buddyforms_options', true );
    1414    // Get all allowed post types
    1515    $post_types = buddyforms_get_post_types();
    1616    // Get all allowed pages
    1717    $all_pages = buddyforms_get_all_pages( 'id' );
    1818    // Get all values or set the default
    1919    $slug = $post->post_name;
    2020    $singular_name = ( isset( $buddyform['singular_name'] ) ? stripslashes( $buddyform['singular_name'] ) : '' );
    2121    $after_submit = ( isset( $buddyform['after_submit'] ) ? $buddyform['after_submit'] : 'display_message' );
    2222    $after_submission_page = ( isset( $buddyform['after_submission_page'] ) ? $buddyform['after_submission_page'] : 'false' );
    2323    $after_submission_url = ( isset( $buddyform['after_submission_url'] ) ? $buddyform['after_submission_url'] : '' );
    2424    $post_type = ( isset( $buddyform['post_type'] ) ? $buddyform['post_type'] : 'false' );
    2525    $form_type = ( isset( $buddyform['form_type'] ) ? $buddyform['form_type'] : 'contact' );
    2626    $message_text_default = ( $post_type == 'false' ? 'Form Submitted Successfully' : __( 'The [form_singular_name] [post_title] has been successfully Submitted!<br>1. [post_link]<br>2. [edit_link]', 'buddyforms' ) );
    2727    $after_submit_message_text = ( isset( $buddyform['after_submit_message_text'] ) ? $buddyform['after_submit_message_text'] : $message_text_default );
    2828    $after_update_submit_message_text = ( isset( $buddyform['after_update_submit_message_text'] ) ? $buddyform['after_update_submit_message_text'] : buddyforms_default_message_on_update() );
    2929    $empty_submit_list_message_text = ( isset( $buddyform['empty_submit_list_message_text'] ) ? $buddyform['empty_submit_list_message_text'] : buddyforms_default_message_on_empty_submission_list() );
    3030    $attached_page = ( isset( $buddyform['attached_page'] ) ? $buddyform['attached_page'] : 'false' );
    3131    $attached_page_div_id = ( isset( $buddyform['attached_page_div_id'] ) ? stripslashes( $buddyform['attached_page_div_id'] ) : '' );
    3232    $status = ( isset( $buddyform['status'] ) ? $buddyform['status'] : 'false' );
    3333    $comment_status = ( isset( $buddyform['comment_status'] ) ? $buddyform['comment_status'] : 'false' );
    3434    $revision = ( isset( $buddyform['revision'] ) ? $buddyform['revision'] : 'false' );
    3535    $admin_bar = ( isset( $buddyform['admin_bar'] ) ? $buddyform['admin_bar'] : 'false' );
    3636    $edit_link = ( isset( $buddyform['edit_link'] ) ? $buddyform['edit_link'] : 'all' );
    3737    $bf_ajax = ( isset( $buddyform['bf_ajax'] ) ? $buddyform['bf_ajax'] : false );
    3838    $user_data = ( isset( $buddyform['user_data'] ) ? $buddyform['user_data'] : array(
    3939        'ipaddress',
    4040        'referer',
    4141        'browser',
    4242        'version',
    4343        'platform',
    4444        'reports',
    4545        'userAgent',
    4646        'enable_all'
    4747    ) );
    4848    $list_posts_option = ( isset( $buddyform['list_posts_option'] ) ? $buddyform['list_posts_option'] : 'list_all_form' );
    4949    $list_posts_style = ( isset( $buddyform['list_posts_style'] ) ? $buddyform['list_posts_style'] : 'list' );
    5050    $local_storage = ( isset( $buddyform['local_storage'] ) ? $buddyform['local_storage'] : '' );
    5151    $js_validation = ( isset( $buddyform['js_validation'] ) ? $buddyform['js_validation'] : '' );
    5252    // Create The Form Array
    5353    $form_setup = array();
    5454    //
    5555    // Submission
    5656    //
    5757    $element = new Element_Textbox( '<b>' . __( 'Form Slug', 'buddyforms' ) . '</b>', 'buddyforms_options[slug]', array(
    5858        'value'     => $slug,
    5959        'shortDesc' => __( 'The Form Slug is used in shortcodes and other places, please take care changing this option.', 'buddyforms' ),
    6060    ) );
    6161    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    6262        $element->setAttribute( 'disabled', 'disabled' );
    6363    }
    6464    $form_setup['Form Submission'][] = $element;
    6565    $element = new Element_Select(
    6666        '<b>' . __( 'After Submission', 'buddyforms' ) . '</b>',
    6767        'buddyforms_options[after_submit]',
    6868        array(
    6969        'display_message'    => __( 'Display Message', 'buddyforms' ),
    7070        'display_form'       => __( 'Display the Form and Message' ),
    7171        'display_page'       => __( 'Display Page Contents', 'buddyforms' ),
    7272        'display_post'       => __( 'Display the Post' ),
    7373        'display_posts_list' => __( 'Display the User\'s Post List' ),
    7474        'redirect'           => __( 'Redirect to url', 'buddyforms' ),
    7575    ),
    7676        array(
    7777        'value' => $after_submit,
    7878        'class' => 'bf-after-submission-action',
    7979        'id'    => 'bf-after-submission-action',
    8080    )
    8181    );
    8282    $element->setAttribute( 'data-hidden', 'display_page display_form display_message redirect' );
    8383    $form_setup['Form Submission'][] = $element;
    8484    // After Submission Page
    8585    $element = new Element_Select(
    8686        '<b>' . __( 'After Submission Page', 'buddyforms' ) . '</b>',
    8787        'buddyforms_options[after_submission_page]',
    8888        $all_pages,
    8989        array(
    9090        'value'     => $after_submission_page,
    9191        'shortDesc' => __( 'Select the Page from where the content gets displayed. Will redirected to the page if ajax is disabled, otherwise display the content.', 'buddyforms' ),
    9292        'class'     => 'display_page',
    9393    )
    9494    );
    9595    $form_setup['Form Submission'][] = $element;
    9696    $form_setup['Form Submission'][] = new Element_Url( '<b>' . __( 'Redirect URL', 'buddyforms' ), 'buddyforms_options[after_submission_url]', array(
    9797        'value'     => $after_submission_url,
    9898        'shortDesc' => __( 'Enter a valid URL', 'buddyforms' ),
    9999        'class'     => 'redirect',
    100100    ) );
    101101    $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'After Create Submission Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[after_submit_message_text]', array(
    102102        'rows'  => 3,
    103103        'style' => 'width:100%',
    104104        'class' => 'display_message display_form',
    105105        'value' => $after_submit_message_text,
    106106        'id'    => 'after_submit_message_text',
    107107    ) );
    108108    $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'After Update Submission Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[after_update_submit_message_text]', array(
    109109        'rows'  => 3,
    110110        'style' => 'width:100%',
    111111        'class' => 'display_message display_form',
    112112        'value' => $after_update_submit_message_text,
    113113        'id'    => 'after_update_submit_message_text',
    114114    ) );
    115115    $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'Empty Submission List Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[empty_submit_list_message_text]', array(
    116116        'rows'      => 3,
    117117        'style'     => 'width:100%',
    118118        'value'     => $empty_submit_list_message_text,
    119119        'id'        => 'empty_submit_list_message_text',
    120120        'shortDesc' => __( 'This message is used when you have setup the option <b>Enable your site members to view their submissions</b>', 'buddyforms' ),
    121121    ) );
    122122    $element = new Element_Checkbox(
    123123        '<b>' . __( 'AJAX', 'buddyforms' ) . '</b>',
    124124        'buddyforms_options[bf_ajax]',
    125125        array(
    126126        'bf_ajax' => __( 'Disable ajax form submission', 'buddyforms' ),
    127127    ),
    128128        array(
    129129        'shortDesc' => '',
    130130        'value'     => $bf_ajax,
    131131    )
    132132    );
    133133    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    134134        $element->setAttribute( 'disabled', 'disabled' );
    135135    }
    136136    $form_setup['Form Submission'][] = $element;
    137137    $element = new Element_Checkbox(
    138138        '<b>' . __( 'Local Storage', 'buddyforms' ) . '</b>',
    139139        'buddyforms_options[local_storage]',
    140140        array(
    141141        'disable' => __( 'Disable Local Storage', 'buddyforms' ),
    142142    ),
    143143        array(
    144144        'shortDesc' => __( 'The form elements content is stored in the browser so it not gets lost if the tab gets closed by accident', 'buddyforms' ),
    145145        'value'     => $local_storage,
    146146    )
    147147    );
    148148    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    149149        $element->setAttribute( 'disabled', 'disabled' );
    150150    }
    151151    $form_setup['Form Submission'][] = $element;
    152152    $element = new Element_Checkbox(
    153153        '<b>' . __( 'Javascript Validations', 'buddyforms' ) . '</b>',
    154154        'buddyforms_options[js_validation]',
    155155        array(
    156156        'disabled' => __( 'Disable JavaScript Validation', 'buddyforms' ),
    157157    ),
    158158        array(
    159159        'shortDesc' => __( 'By default the Javascript validations are enabled. Check to disable it.', 'buddyforms' ),
    160160        'value'     => $js_validation,
    161161    )
    162162    );
    163163    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    164164        $element->setAttribute( 'disabled', 'disabled' );
    165165    }
    166166    $form_setup['Form Submission'][] = $element;
    167167    $public_submit_login = ( isset( $buddyform['public_submit_login'] ) ? $buddyform['public_submit_login'] : 'above' );
    168168    $element = new Element_Select(
    169169        '<b>' . __( 'Enable Login on the form', 'buddyforms' ) . '</b>',
    170170        'buddyforms_options[public_submit_login]',
    171171        array(
    172172        'none'  => __( 'None', 'buddyforms' ),
    173173        'above' => __( 'Above the Form', 'buddyforms' ),
    174174        'under' => __( 'Under the Form', 'buddyforms' ),
    175175    ),
    176176        array(
    177177        'value'     => $public_submit_login,
    178178        'shortDesc' => __( 'Give your existing customers the choice to login. Just place a login form above or under the form. The Login Form is only visible for logged of user.', 'buddyforms' ),
    179179        'class'     => 'public-submit-option',
    180180    )
    181181    );
    182182    $form_setup['Form Submission'][] = $element;
    183183    $element = new Element_Checkbox(
    184184        '<b>' . __( 'User Data', 'buddyforms' ) . '</b>',
    185185        'buddyforms_options[user_data]',
    186186        array(
    187187        'ipaddress'  => __( 'Disable IP Address', 'buddyforms' ),
    188188        'referer'    => __( 'Disable Referer', 'buddyforms' ),
    189189        'browser'    => __( 'Disable Browser', 'buddyforms' ),
    190190        'version'    => __( 'Disable Browser Version', 'buddyforms' ),
    191191        'platform'   => __( 'Disable Platform', 'buddyforms' ),
    192192        'reports'    => __( 'Disable Reports', 'buddyforms' ),
    193193        'userAgent'  => __( 'Disable User Agent', 'buddyforms' ),
    194194        'enable_all' => '',
    195195    ),
    196196        array(
    197197        'shortDesc' => __( 'By default all above user data will not be stored. In some country\'s for example in the EU you are not allowed to save the ip. Please make sure you not against the low in your country and adjust if needed', 'buddyforms' ),
    198198        'value'     => $user_data,
    199199    )
    200200    );
    201201    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    202202        $element->setAttribute( 'disabled', 'disabled' );
    203203    }
    204204    $form_setup['Form Submission'][] = $element;
    205205    $shortDesc_post_type = sprintf(
    206206        '<b>%s</b> <br><br><a target="_blank" href="#">%s</a>',
    207207        __( 'Use any POST TYPE with the PRO Version!', 'buddyforms' ),
    208208        __( 'Select a post type if you want to create posts from form submissions. ', 'buddyforms' ),
    209209        __( 'Read the Documentation', 'buddyforms' )
    210210    );
    211211    //
    212212    // Create Content
    213213    //
    214214    $element = new Element_Select(
    215215        '<b>' . __( 'Post Type', 'buddyforms' ) . '</b>',
    216216        'buddyforms_options[post_type]',
    217217        $post_types,
    218218        array(
    219219        'value'     => $post_type,
    220220        'shortDesc' => $shortDesc_post_type,
    221221        'id'        => 'form_post_type',
    222222    )
    223223    );
    224224    $form_setup['Create Content'][] = $element;
    225225    $element = new Element_Select(
    226226        '<b>' . __( 'Status', 'buddyforms' ) . '</b>',
    227227        'buddyforms_options[status]',
    228228        array( 'publish', 'pending', 'draft' ),
    229229        array(
    230230        'value' => $status,
    231231        'class' => 'bf_hide_if_post_type_none',
    232232    )
    233233    );
    234234    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    235235        $element->setAttribute( 'disabled', 'disabled' );
    236236    }
    237237    $form_setup['Create Content'][] = $element;
    238238    $element = new Element_Select(
    239239        '<b>' . __( 'Comment Status', 'buddyforms' ) . '</b>',
    240240        'buddyforms_options[comment_status]',
    241241        array( 'open', 'closed' ),
    242242        array(
    243243        'value' => $comment_status,
    244244        'class' => 'bf_hide_if_post_type_none',
    245245    )
    246246    );
    247247    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    248248        $element->setAttribute( 'disabled', 'disabled' );
    249249    }
    250250    $form_setup['Create Content'][] = $element;
    251251    $element = new Element_Checkbox(
    252252        '<b>' . __( 'Revision', 'buddyforms' ) . '</b>',
    253253        'buddyforms_options[revision]',
    254254        array(
    255255        'Revision' => __( 'Enable frontend revision control', 'buddyforms' ),
    256256    ),
    257257        array(
    258258        'value' => $revision,
    259259        'class' => 'bf_hide_if_post_type_none',
    260260    )
    261261    );
    262262    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    263263        $element->setAttribute( 'disabled', 'disabled' );
    264264    }
    265265    $form_setup['Create Content'][] = $element;
    266266    $element = new Element_Textbox( '<b>' . __( 'Singular Name', 'buddyforms' ), 'buddyforms_options[singular_name]', array(
    267267        'value'     => $singular_name,
    268268        'shortDesc' => __( 'The Single Name is used by other plugins and Navigation ( Display Books, Add Book )', 'buddyforms' ),
    269269        'class'     => 'bf_hide_if_post_type_none',
    270270    ) );
    271271    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    272272        $element->setAttribute( 'disabled', 'disabled' );
    273273    }
    274274    $form_setup['Create Content'][] = $element;
    275275    //
    276276    // Edit Submissions
    277277    //
    278278    // Make sure to use the default submissions management page if non exist!
    279279   
    280280    if ( !$attached_page || $attached_page == 'none' || $attached_page == 'false' ) {
    281281        $buddyforms_submissions_page = get_option( 'buddyforms_submissions_page' );
    282282        if ( $buddyforms_submissions_page ) {
    283283            $attached_page = $buddyforms_submissions_page;
    284284        }
    285285    }
    286286   
    287287    $siteurl = get_bloginfo( 'wpurl' );
    288288    $attached_page_url = get_permalink( $attached_page );
    289289   
    290290    if ( !empty($attached_page_url) ) {
    291291        $siteurl_page_html = "<a style='color:#7ad03a;' id='siteurl_page' class='' href='" . $attached_page_url . "' target='_blank' >" . $attached_page_url . '</a>';
    292292        $siteurl_create_html = "<a style='color:#7ad03a;' id='siteurl_create' class='' href='" . $attached_page_url . 'create/' . $slug . "' target='_blank' >" . $attached_page_url . 'create/' . $slug . '</a>';
    293293        $siteurl_edit_html = "<a style='color:#7ad03a;' id='siteurl_edit' class='' href='" . $attached_page_url . 'view/' . $slug . "' target='_blank' >" . $attached_page_url . 'view/' . $slug . '</a>';
    294294    } else {
    295295        $siteurl_page_html = $siteurl . '/' . $attached_page;
    296296        $siteurl_create_html = $siteurl . '/' . $attached_page . '/create/' . $slug;
    297297        $siteurl_edit_html = $siteurl . '/' . $attached_page . '/view/' . $slug;
    298298    }
    299299   
    300300    $admin_email = get_option( 'admin_email' );
    301301    // Attached Page
    302302    $form_setup['Edit Submissions'][] = new Element_HTML( sprintf( '<h4>%s</h4>', __( 'Enable your site members to view their submissions', 'buddyforms' ) ) . sprintf( '<p>%s</p>', __( 'Select a page or create a new on if you like to turn on submission management for your logged in users.', 'buddyforms' ) ) . '<div class="bf_hide_if_post_type_none">' . sprintf( '<p class="description">%s<br> %s', __( 'Important!', 'buddyforms' ), __( 'The original page content does not get changed. You are free to use any kind of content on the page itself. View a form or list the users submissions with Shortcodes. For the submissions management new endpoints get create for you. You can combine forms under the same page. Its a powerful option.', 'buddyforms' ) ) . sprintf( '<a target="_blank" href="http://docs.buddyforms.com/article/139-select-page-in-the-formbuilder">%s</a></p>', __( 'Read the Documentation', 'buddyforms' ) ) . sprintf( '<h6>%s<br><small class="siteurl_create_html">' . $siteurl_create_html . '</small></h6>', __( 'Form URL', 'buddyforms' ) ) . sprintf( '<br><h6>%s<br><small class="siteurl_edit_html">' . $siteurl_edit_html . '</small></h6>', __( 'User Submissions URL', 'buddyforms' ) ) . '</div>' );
    303303    $form_setup['Edit Submissions'][] = new Element_Select(
    304304        '<b>' . __( 'Enable site members to manage their submissions', 'buddyforms' ) . '</b>',
    305305        'buddyforms_options[attached_page]',
    306306        $all_pages,
    307307        array(
    308308        'value'     => $attached_page,
    309309        'shortDesc' => sprintf( '<b><a href="javascript:void(0);" onclick="createNewPageOpenModal()" id="bf_create_page_modal">%s </a></b> %s', __( 'Create a new Page', 'buddyforms' ), __( 'The page is used to create the endpoints for the create - list and edit submissions views. ', 'buddyforms' ) ),
    310310        'id'        => 'attached_page',
    311311        'data-slug' => $slug,
    312312    )
    313313    );
    314314    $element = new Element_Textbox( '<b>' . __( "Dynamic Content by ID or Class", 'buddyforms' ) . '</b>', "buddyforms_options[attached_page_div_id]", array(
    315315        'value'     => $attached_page_div_id,
    316316        'class'     => 'bf_hide_if_attached_page_none',
    317317        'shortDesc' => __( 'Create an individual layout and define the BuddyForms output with an ID or by class. The best practice is to use an ID starting with a # like:"#UniqueID" but it also works with a class name starting with a . Like: ".UniqueClass". Please make sure only to use the class name once so that it acts like an ID.', 'buddyforms' ),
    318318    ) );
    319319    $form_setup['Edit Submissions'][] = $element;
    320320    $element = new Element_Checkbox(
    321321        '<b>' . __( 'Admin Bar', 'buddyforms' ) . '</b>',
    322322        'buddyforms_options[admin_bar]',
    323323        array(
    324324        'Admin Bar' => __( 'Add to Admin Bar', 'buddyforms' ),
    325325    ),
    326326        array(
    327327        'value' => $admin_bar,
    328328        'class' => 'bf_hide_if_attached_page_none',
    329329    )
    330330    );
    331331    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    332332        $element->setAttribute( 'disabled', 'disabled' );
    333333    }
    334334    $form_setup['Edit Submissions'][] = $element;
    335335    $element = new Element_Radio(
    336336        '<b>' . __( "Overwrite Frontend 'Edit Post' Link", 'buddyforms' ) . '</b>',
    337337        'buddyforms_options[edit_link]',
    338338        array(
    339339        'none'          => 'None',
    340340        'all'           => __( 'All Edit Links', 'buddyforms' ),
    341341        'my-posts-list' => __( 'Only in My Posts List', 'buddyforms' ),
    342342    ),
    343343        array(
    344344        'view'      => 'vertical',
    345345        'value'     => $edit_link,
    346346        'shortDesc' => __( 'The link to the backend will be changed to use the frontend editing.', 'buddyforms' ),
    347347        'class'     => 'bf_hide_if_attached_page_none',
    348348    )
    349349    );
    350350    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    351351        $element->setAttribute( 'disabled', 'disabled' );
    352352    }
    353353    $form_setup['Edit Submissions'][] = $element;
    354354    $element = new Element_Radio(
    355355        '<b>' . __( 'List Posts Options', 'buddyforms' ) . '</b>',
    356356        'buddyforms_options[list_posts_option]',
    357357        array(
    358358        'list_all_form' => __( 'List all Author Posts created with this Form', 'buddyforms' ),
    359359        'list_all'      => __( 'List all Author Posts of the PostType', 'buddyforms' ),
    360360    ),
    361361        array(
    362362        'value'     => $list_posts_option,
    363363        'shortDesc' => '',
    364364        'class'     => 'bf_hide_if_attached_page_none',
    365365    )
    366366    );
    367367    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    368368        $element->setAttribute( 'disabled', 'disabled' );
    369369    }
    370370    $form_setup['Edit Submissions'][] = $element;
    371371    $element = new Element_Radio(
    372372        '<b>' . __( 'List Style', 'buddyforms' ) . '</b>',
    373373        'buddyforms_options[list_posts_style]',
    374374        apply_filters( 'buddyforms_loop_template_name', array(
    375375        'list'  => 'List',
    376376        'table' => 'Table',
    377377    ) ),
    378378        array(
    379379        'value'     => $list_posts_style,
    380380        'shortDesc' => __( 'Do you want to list post in a ul li list or as table.', 'buddyforms' ),
    381381        'class'     => 'bf_hide_if_attached_page_none',
    382382    )
    383383    );
    384384    if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) {
    385385        $element->setAttribute( 'disabled', 'disabled' );
    386386    }
    387387    $form_setup['Edit Submissions'][] = $element;
    388388    //
    389389    // Display multisite options if network is enabled
    390390    //
    391391   
    392392    if ( buddyforms_is_multisite() ) {
    393393        $sites_select = array();
    394394        $sites = get_sites();
    395395        foreach ( $sites as $site_id => $site ) {
    396396            $blog_details = get_blog_details( $site->blog_id, array( 'blog_id', 'blogname' ) );
    397397            $sites_select[$blog_details->blog_id] = $blog_details->blogname;
    398398        }
    399399        $blog_id = ( isset( $buddyform['blog_id'] ) ? $buddyform['blog_id'] : '' );
    400400        $element = new Element_Select(
    401401            '<b>' . __( 'Select a Blog', 'buddyforms' ) . '</b>',
    402402            'buddyforms_options[blog_id]',
    403403            $sites_select,
    404404            array(
    405405            'value'     => $blog_id,
    406406            'shortDesc' => __( 'You can post with BuddyForms from one Blog to the other. If you use BuddyPress you can have a centralised Profile on the main Blog and let the user submit to the multisite network from a centralised place.', 'buddyforms' ),
    407407            'id'        => 'blog_id',
    408408        )
    409409        );
    410410        $form_setup['Network'][] = $element;
    411411    }
    412412   
    413413    // Check if form elements exist and sort the form elements
    414414    if ( is_array( $form_setup ) ) {
    415415        $form_setup = buddyforms_sort_array_by_Array( $form_setup, array( __( 'Form Submission', 'buddyforms' ), __( 'Create Content', 'buddyforms' ), __( 'Edit Submissions', 'buddyforms' ) ) );
    416416    }
    417417    // Display all Form Elements in a nice Tab UI and List them in a Table
    418418    ?>
    419419    <p>
    420420        <select id="bf-form-type-select" style="margin-left: 0 !important;" name="buddyforms_options[form_type]">
    421421            <optgroup label="Form Type">
    422422                <option <?php
    423423    selected( $form_type, 'contact' );
    424424    ?> value="contact"><?php
    425425    esc_html_e( 'Contact Form', 'buddyforms' );
    426426    ?></option>
    427427                <option <?php
    428428    selected( $form_type, 'registration' );
    429429    ?> value="registration"><?php
    430430    esc_html_e( 'Registration Form', 'buddyforms' );
    431431    ?></option>
    432432                <option <?php
    433433    selected( $form_type, 'post' );
    434434    ?> value="post"><?php
    435435    esc_html_e( 'Post Form', 'buddyforms' );
    436436    ?></option>
    437437            </optgroup>
    438438        </select>
    439439    </p>
    440440    <div class="tabbable buddyform-tabs-left">
    441441        <ul class="nav buddyform-nav-tabs buddyform-nav-pills">
    442442            <?php
    443443    $i = 0;
    444444    foreach ( $form_setup as $tab => $fields ) {
    445445        $tab_slug = sanitize_title( $tab );
    446446        ?>
    447447            <li class="<?php
    448448        echo  ( $i == 0 ? 'active' : '' ) ;
    449449        echo  esc_attr( $tab_slug ) ;
    450450        ?>_nav">
    451451                <a href="#<?php
    452452        echo  esc_attr( $tab_slug ) ;
    453453        ?>" data-toggle="tab"><?php
    454454        echo  esc_attr( $tab ) ;
    455455        ?></a>
    456456                </li>
    457457                <?php
    458458        $i++;
    459459    }
    460460    // Allow other plugins to add new sections
    461461    do_action( 'buddyforms_form_setup_nav_li_last' );
    462462    ?>
    463463
    464464        </ul>
    465465        <div class="tab-content">
    466466            <?php
    467467    $i = 0;
    468468    foreach ( $form_setup as $tab => $fields ) {
    469469        $tab_slug = sanitize_title( $tab );
    470470        ?>
    471471                <div class="tab-pane <?php
    472472        echo  ( $i == 0 ? 'active' : '' ) ;
    473473        ?>"
    474474                     id="<?php
    475475        echo  esc_attr( $tab_slug ) ;
    476476        ?>">
    477477                    <div class="buddyforms_accordion_general">
    478478                        <?php
    479479        // get all the html elements and add them above the settings
    480480        foreach ( $fields as $field_key => $field ) {
    481481            $type = $field->getAttribute( 'type' );
    482482            if ( $type == 'html' ) {
    483483                $field->render();
    484484            }
    485485        }
    486486        ?>
    487487                        <table class="wp-list-table widefat posts fixed">
    488488                            <tbody>
    489489                            <?php
    490490        foreach ( $fields as $field_key => $field ) {
    491491            $type = $field->getAttribute( 'type' );
    492492            $class = $field->getAttribute( 'class' );
    493493            $disabled = $field->getAttribute( 'disabled' );
    494494            $classes = ( empty($class) ? '' : $class . ' ' );
    495495            $classes .= ( empty($disabled) ? '' : 'bf-' . $disabled . ' ' );
    496496            // If the form element is not html create it as table row
    497497           
    498498            if ( $type != 'html' ) {
    499499                ?>
    500500                                    <tr class="<?php
    501501                echo  esc_attr( $classes ) ;
    502502                ?>">
    503503                                        <th scope="row">
    504504                                            <label for="form_title"><?php
    505505                echo  wp_kses( $field->getLabel(), buddyforms_wp_kses_allowed_atts() ) ;
    506506                ?></label>
    507507                                        </th>
    508508                                        <td>
    509509                                            <?php
    510510                echo  wp_kses( $field->render(), buddyforms_wp_kses_allowed_atts() ) ;
    511511                ?>
    512512                                            <p class="description"><?php
    513                 echo  wp_kses( $field->getShortDesc(), buddyforms_wp_kses_allowed_atts() ) ;
     513                echo  $field->getShortDesc() ;
     514                // WPCS: XSS ok.
    514515                ?></p>
    515516                                        </td>
    516517                                    </tr>
    517518                                    <?php
    518519            }
    519520       
    520521        }
    521522        ?>
    522523                            </tbody>
    523524                        </table>
    524525                    </div>
    525526                </div>
    526527                <?php
    527528        $i++;
    528529    }
    529530    // Allow other plugins to hook there content for there nav into the tab content
    530531    do_action( 'buddyforms_form_setup_tab_pane_last' );
    531532    ?>
    532533        </div>  <!-- close .tab-content -->
    533534    </div> <!-- close .tabs -->
    534535    <?php
    535536}
  • buddyforms/trunk/includes/functions.php

    r3031945 r3046092  
    11<?php
    22
    33if ( !defined( 'ABSPATH' ) ) {
    44    exit;
    55}
    66/**
    77 * Add the forms to the admin bar
    88 *
    99 * @package BuddyForms
    1010 * @since 0.3 beta
    1111 */
    1212add_action(
    1313    'wp_before_admin_bar_render',
    1414    'buddyforms_wp_before_admin_bar_render',
    1515    1,
    1616    2
    1717);
    1818function buddyforms_wp_before_admin_bar_render()
    1919{
    2020    global  $wp_admin_bar, $buddyforms ;
    2121    if ( !$buddyforms ) {
    2222        return;
    2323    }
    2424    foreach ( $buddyforms as $key => $buddyform ) {
    2525        if ( !isset( $buddyform['post_type'] ) || $buddyform['post_type'] == 'none' ) {
    2626            continue;
    2727        }
    2828        if ( isset( $buddyform['admin_bar'][0] ) && $buddyform['post_type'] != 'none' && !empty($buddyform['attached_page']) ) {
    2929           
    3030            if ( current_user_can( 'buddyforms_' . $key . '_create' ) ) {
    3131                $permalink = get_permalink( $buddyform['attached_page'] );
    3232                $wp_admin_bar->add_menu( array(
    3333                    'parent' => 'my-account',
    3434                    'id'     => 'my-account-' . $buddyform['slug'],
    3535                    'title'  => $buddyform['name'],
    3636                    'href'   => $permalink,
    3737                ) );
    3838                $wp_admin_bar->add_menu( array(
    3939                    'parent' => 'my-account-' . $buddyform['slug'],
    4040                    'id'     => 'my-account-' . $buddyform['slug'] . '-view',
    4141                    'title'  => __( 'View my ', 'buddyforms' ) . $buddyform['name'],
    4242                    'href'   => $permalink . '/view/' . $buddyform['slug'] . '/',
    4343                ) );
    4444                $wp_admin_bar->add_menu( array(
    4545                    'parent' => 'my-account-' . $buddyform['slug'],
    4646                    'id'     => 'my-account-' . $buddyform['slug'] . '-new',
    4747                    'title'  => __( 'New ', 'buddyforms' ) . $buddyform['singular_name'],
    4848                    'href'   => $permalink . 'create/' . $buddyform['slug'] . '/',
    4949                ) );
    5050            }
    5151       
    5252        }
    5353    }
    5454}
    5555
    5656/**
    5757 * Create the buddyforms post status array.
    5858 * Other Plugins use the filter buddyforms_get_post_status_array to add there post status to the options array
    5959 *
    6060 * @return array
    6161 */
    6262function buddyforms_get_post_status_array()
    6363{
    6464    $status_array = array(
    6565        'publish' => __( 'Publish', 'buddyforms' ),
    6666        'pending' => __( 'Pending Review', 'buddyforms' ),
    6767        'draft'   => __( 'Draft', 'buddyforms' ),
    6868        'future'  => __( 'Schedule', 'buddyforms' ),
    6969        'private' => __( 'Privately Publish', 'buddyforms' ),
    7070        'trash'   => __( 'Trash', 'buddyforms' ),
    7171    );
    7272    return apply_filters( 'buddyforms_get_post_status_array', $status_array );
    7373}
    7474
    7575/**
    7676 * Restricting users to view only media library items they upload.
    7777 *
    7878 * @package BuddyForms
    7979 * @since 0.5 beta
    8080 */
    8181add_action( 'pre_get_posts', 'buddyforms_restrict_media_library' );
    8282/**
    8383 * @param $wp_query_obj
    8484 */
    8585function buddyforms_restrict_media_library( $wp_query_obj )
    8686{
    8787    global  $current_user, $pagenow ;
    8888    if ( is_super_admin( $current_user->ID ) ) {
    8989        return;
    9090    }
    9191    if ( !is_a( $current_user, 'WP_User' ) ) {
    9292        return;
    9393    }
    9494    if ( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' ) {
    9595        return;
    9696    }
    9797    if ( !current_user_can( 'manage_media_library' ) ) {
    9898        $wp_query_obj->set( 'author', $current_user->ID );
    9999    }
    100100    return;
    101101}
    102102
    103103/**
    104104 * Check if a subscriber have the needed rights to upload images and add this capabilities if needed.
    105105 *
    106106 * @package BuddyForms
    107107 * @since 0.5 beta
    108108 */
    109109add_action( 'init', 'buddyforms_allow_subscriber_uploads' );
    110110function buddyforms_allow_subscriber_uploads()
    111111{
    112112   
    113113    if ( current_user_can( 'subscriber' ) && !current_user_can( 'upload_files' ) ) {
    114114        $role = get_role( 'subscriber' );
    115115        if ( !empty($role) ) {
    116116            $role->add_cap( 'upload_files' );
    117117        }
    118118    }
    119119
    120120}
    121121
    122122/**
    123123 * Get the BuddyForms template directory.
    124124 *
    125125 * @return string
    126126 * @since 0.1 beta
    127127 *
    128128 * @uses apply_filters()
    129129 * @package BuddyForms
    130130 */
    131131function buddyforms_get_template_directory()
    132132{
    133133    return apply_filters( 'buddyforms_get_template_directory', constant( 'BUDDYFORMS_TEMPLATE_PATH' ) );
    134134}
    135135
    136136/**
    137137 * Locate a template
    138138 *
    139139 * @param $slug
    140140 *
    141141 * @param $form_slug
    142142 *
    143143 * @package BuddyForms
    144144 * @since 0.1 beta
    145145 *
    146146 * @since 2.3.1
    147147 */
    148148function buddyforms_locate_template( $slug, $form_slug = '' )
    149149{
    150150    global
    151151        $buddyforms,
    152152        $bp,
    153153        $the_lp_query,
    154154        $current_user,
    155155        $post_id
    156156    ;
    157157    // Backward compatibility @sinde 2.3.3.
    158158    if ( empty($form_slug) ) {
    159159        global  $form_slug ;
    160160    }
    161161    // Get the current user so its not needed in the templates
    162162    $current_user = wp_get_current_user();
    163163    // create the plugin template path
    164164    $template_path = BUDDYFORMS_TEMPLATE_PATH . 'buddyforms/' . $slug . '.php';
    165165    /**
    166166     * Extend the template from 3rd party plugins
    167167     *
    168168     * @since 2.5.9
    169169     */
    170170    $template_path = apply_filters(
    171171        'buddyforms_locate_template',
    172172        $template_path,
    173173        $slug,
    174174        $form_slug
    175175    );
    176176    // Check if template exist in the child or parent theme and use this path if available
    177177    if ( $template_file = locate_template( "buddyforms/{$slug}.php", false, false ) ) {
    178178        $template_path = $template_file;
    179179    }
    180180    $empty_post_message = __( 'There were no posts found. Create your first post now! ', 'buddyforms' );
    181181    if ( !empty($form_slug) ) {
    182182       
    183183        if ( !empty($buddyforms[$form_slug]['empty_submit_list_message_text']) ) {
    184184            $empty_post_message = do_shortcode( $buddyforms[$form_slug]['empty_submit_list_message_text'] );
    185185        } else {
    186186            $empty_post_message = do_shortcode( buddyforms_default_message_on_empty_submission_list() );
    187187        }
    188188   
    189189    }
    190190    // Do the include
    191191    include $template_path;
    192192}
    193193
    194194/**
    195195 * Retrieves the post excerpt.
    196196 *
    197197 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    198198 *
    199199 * @return string Post excerpt.
    200200 * @since 2.5.17
    201201 */
    202202function buddyforms_get_the_excerpt( $post = null )
    203203{
    204204    $post = get_post( $post );
    205205    if ( empty($post) ) {
    206206        return '';
    207207    }
    208208    if ( post_password_required( $post ) ) {
    209209        return __( 'There is no excerpt because this is a protected post.' );
    210210    }
    211211    return apply_filters( 'buddyforms_get_the_excerpt', $post->post_excerpt, $post );
    212212}
    213213
    214214function buddyforms_granted_list_posts_style()
    215215{
    216216    return apply_filters( 'buddyforms_granted_list_post_style', array( 'list', 'table' ) );
    217217}
    218218
    219219// Display the WordPress Login Form
    220220function buddyforms_wp_login_form( $hide = false, $form_slug = 'none' )
    221221{
    222222    // Get The Login Form
    223223    $form = buddyforms_get_wp_login_form(
    224224        $form_slug,
    225225        '',
    226226        array(
    227227        'caller'       => 'template',
    228228        'redirect_url' => esc_url_raw( $_SERVER['REQUEST_URI'] ),
    229229    ),
    230230        $hide
    231231    );
    232232    echo  wp_kses( $form, buddyforms_wp_kses_allowed_atts() ) ;
    233233}
    234234
    235235/**
    236236 * Create the BuddyForms Login Form
    237237 *
    238238 * @param string $form_slug
    239239 * @param string $title
    240240 * @param array  $args
    241241 *
    242242 * @param bool   $hide
    243243 *
    244244 * @return string|boolean
    245245 */
    246246function buddyforms_get_wp_login_form(
    247247    $form_slug = 'none',
    248248    $title = '',
    249249    $args = array(),
    250250    $hide = false
    251251)
    252252{
    253253    global  $buddyforms, $wp ;
    254254    if ( is_admin() ) {
    255255        return false;
    256256    }
    257257    $caller = $redirect_url = $label_username = $label_password = $label_remember = $label_log_in = '';
    258258    extract( shortcode_atts( array(
    259259        'caller'         => 'direct',
    260260        'redirect_url'   => home_url(),
    261261        'label_username' => __( 'Username or Email Address', 'buddyforms' ),
    262262        'label_password' => __( 'Password', 'buddyforms' ),
    263263        'label_remember' => __( 'Remember Me', 'buddyforms' ),
    264264        'label_log_in'   => __( 'Log In', 'buddyforms' ),
    265265    ), $args ) );
    266266    if ( empty($title) ) {
    267267        $title = __( 'You need to be logged in to view this page', 'buddyforms' );
    268268    }
    269269    $hide_style = ( $hide ? 'style="display:none"' : '' );
    270270    $wp_login_form = '<div class="bf-show-login-form" ' . $hide_style . '>';
    271271    // include own login basic style
    272272    ob_start();
    273273    require BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Style/LoginStyle.php';
    274274    $style = ob_get_clean();
    275275   
    276276    if ( !empty($style) ) {
    277277        $style = buddyforms_minify_css( $style );
    278278        file_put_contents( dirname( BUDDYFORMS_INCLUDES_PATH ) . '/assets/css/bf-wp-login-form.css', $style );
    279279        $login_form_css_url = BUDDYFORMS_ASSETS . 'css/bf-wp-login-form.css';
    280280        wp_register_style( 'bf-wp-login-form-css', $login_form_css_url );
    281281        wp_enqueue_style( 'bf-wp-login-form-css' );
    282282    }
    283283   
    284284    $wp_login_form .= '<h3>' . $title . '</h3>';
    285285   
    286286    if ( isset( $_GET['bf_login_error_redirect'] ) ) {
    287287        // Remove query strings form URL.
    288288        wp_add_inline_script( 'bf-wp-login-form-css', 'window.history.replaceState(null, null, window.location.pathname);', 'after' );
    289289        $wp_login_form .= '<div class="bf-login-error">';
    290290        foreach ( $_GET as $key => $value ) {
    291291           
    292292            if ( strpos( $key, 'error_msg_' ) !== false ) {
    293293                $error = str_replace( 'Error: ', '<strong>Error: </strong>', $value );
    294294                $wp_login_form .= $error . '<br />';
    295295            }
    296296       
    297297        }
    298298        $wp_login_form .= '</div>';
    299299    }
    300300   
    301301    if ( empty($redirect_url) ) {
    302302        $redirect_url = home_url();
    303303    }
    304304    $login_settings = apply_filters( 'buddyforms_loggin_settings', array(
    305305        'echo'           => false,
    306306        'form_id'        => 'bf_loginform',
    307307        'redirect'       => $redirect_url,
    308308        'id_username'    => 'bf_user_name',
    309309        'id_password'    => 'bf_user_pass',
    310310        'label_username' => $label_username,
    311311        'label_password' => $label_password,
    312312        'label_remember' => $label_remember,
    313313        'label_log_in'   => $label_log_in,
    314314    ) );
    315315    $wp_login_form .= wp_login_form( $login_settings );
    316316    if ( $form_slug !== 'none' ) {
    317317        $wp_login_form = str_replace( '</form>', '<input type="hidden" name="form_slug" value="' . esc_attr( $form_slug ) . '"></form>', $wp_login_form );
    318318    }
    319319    $wp_login_form = str_replace( '</form>', '<input type="hidden" name="caller" value="' . esc_attr( $caller ) . '"></form>', $wp_login_form );
    320320    if ( isset( $wp->request ) ) {
    321321        $wp_login_form = str_replace( '</form>', '<input type="hidden" name="login_error_redirect" value="' . $wp->request . '"></form>', $wp_login_form );
    322322    }
    323323    if ( $form_slug != 'none' ) {
    324324       
    325325        if ( $buddyforms[$form_slug]['public_submit'] == 'registration_form' && $buddyforms[$form_slug]['logged_in_only_reg_form'] != 'none' ) {
    326326            $reg_form_slug = $buddyforms[$form_slug]['logged_in_only_reg_form'];
    327327            set_query_var( 'bf_form_slug', $reg_form_slug );
    328328            $wp_login_form = do_shortcode( '[bf form_slug="' . $reg_form_slug . '"]' );
    329329        }
    330330   
    331331    }
    332332    $wp_login_form .= '</div>';
    333333    $wp_login_form = apply_filters( 'buddyforms_wp_login_form', $wp_login_form );
    334334    return $wp_login_form;
    335335}
    336336
    337337function buddyforms_wp_login_errors_redirect( $errors )
    338338{
    339339    global  $pagenow ;
    340340    if ( empty($_POST['login_error_redirect']) ) {
    341341        return $errors;
    342342    }
    343343    if ( isset( $_GET['action'] ) && $_GET['action'] === 'logout' ) {
    344344        return $errors;
    345345    }
    346346    if ( isset( $_GET['action'] ) && $_GET['action'] === 'switch_to_user' ) {
    347347        return $errors;
    348348    }
    349349    if ( isset( $_GET['action'] ) && $_GET['action'] === 'switch_to_olduser' ) {
    350350        return $errors;
    351351    }
    352352    if ( $pagenow !== 'wp-login.php' || $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
    353353        return $errors;
    354354    }
    355355    $login_page = sanitize_text_field( wp_unslash( $_POST['login_error_redirect'] ) );
    356356    $new_login_page_url = home_url( $login_page ) . '?bf_login_error_redirect=1&';
    357357    $errors = $errors->get_error_messages();
    358358    for ( $i = 0 ;  $i < count( $errors ) ;  $i++ ) {
    359359        $new_login_page_url .= 'error_msg_' . $i . '=' . wp_strip_all_tags( $errors[$i] );
    360360        // Isn't last iteration?
    361361        if ( $i !== count( $errors ) - 1 ) {
    362362            $new_login_page_url .= '&';
    363363        }
    364364    }
    365365    wp_redirect( esc_url_raw( $new_login_page_url ) );
    366366    exit;
    367367}
    368368
    369369add_filter( 'wp_login_errors', 'buddyforms_wp_login_errors_redirect' );
    370370/**
    371371 * since 2.5.13
    372372 * author @gfirem
    373373 *
    374374 * @param $wp_register_url
    375375 *
    376376 * @return string
    377377 */
    378378function buddyforms_register_url( $wp_register_url )
    379379{
    380380    $buddyforms_registration_page = get_option( 'buddyforms_registration_page' );
    381381   
    382382    if ( $buddyforms_registration_page != 'none' ) {
    383383        $new_url = get_permalink( $buddyforms_registration_page );
    384384        if ( !empty($new_url) ) {
    385385            return $new_url;
    386386        }
    387387    }
    388388   
    389389    return $wp_register_url;
    390390}
    391391
    392392add_filter( 'register_url', 'buddyforms_register_url' );
    393393add_filter(
    394394    'login_form_bottom',
    395395    'buddyforms_register_link',
    396396    10,
    397397    2
    398398);
    399399function buddyforms_register_link( $wp_login_form, $args )
    400400{
    401401    if ( $args['form_id'] !== 'bf_loginform' ) {
    402402        return $wp_login_form;
    403403    }
    404404    $buddyforms_registration_page = get_option( 'buddyforms_registration_page' );
    405405   
    406406    if ( $buddyforms_registration_page != 'none' ) {
    407407        $permalink = get_permalink( $buddyforms_registration_page );
    408408    } else {
    409409        $permalink = site_url( '/wp-login.php?action=register&redirect_to=' . get_permalink() );
    410410    }
    411411   
    412412    // new login page
    413413    $wp_login_form .= '<span class="buddyforms-register"><a href="' . $permalink . '">' . __( 'Register', 'buddyforms' ) . '</a></span> &nbsp;';
    414414    return $wp_login_form;
    415415}
    416416
    417417add_action(
    418418    'login_form_bottom',
    419419    'buddyforms_add_lost_password_link',
    420420    10,
    421421    2
    422422);
    423423function buddyforms_add_lost_password_link( $wp_login_form, $args )
    424424{
    425425    if ( $args['form_id'] !== 'bf_loginform' ) {
    426426        return $wp_login_form;
    427427    }
    428428    $lost_password_url = apply_filters( 'buddyforms_lost_password_url', wp_lostpassword_url() );
    429429    $wp_login_form .= '<a href="' . esc_url( $lost_password_url ) . '">' . __( 'Lost Password?', 'buddyforms' ) . '</a> ';
    430430    return $wp_login_form;
    431431}
    432432
    433433// Helper Function to get the Get the REQUEST_URI Vars
    434434/**
    435435 * @param $name
    436436 *
    437437 * @return int
    438438 */
    439439function buddyforms_get_url_var( $name )
    440440{
    441441    $strURL = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
    442442    $arrVals = explode( '/', $strURL );
    443443    $found = 0;
    444444    foreach ( $arrVals as $index => $value ) {
    445445        if ( $value == $name ) {
    446446            $found = $index;
    447447        }
    448448    }
    449449    $place = $found + 1;
    450450    return ( $found == 0 ? 1 : $arrVals[$place] );
    451451}
    452452
    453453/**
    454454 * Queue some JavaScript code to be output in the footer.
    455455 *
    456456 * @param string $code
    457457 */
    458458function buddyforms_enqueue_js( $code )
    459459{
    460460    global  $wc_queued_js ;
    461461    if ( empty($wc_queued_js) ) {
    462462        $wc_queued_js = '';
    463463    }
    464464    $wc_queued_js .= "\n" . $code . "\n";
    465465}
    466466
    467467/**
    468468 * Display edit post link for post.
    469469 *
    470470 * @param string $text Optional. Anchor text.
    471471 * @param string $before Optional. Display before edit link.
    472472 * @param string $after Optional. Display after edit link.
    473473 * @param int    $id Optional. Post ID.
    474474 *
    475475 * @param bool   $echo
    476476 *
    477477 * @return string|void
    478478 * @since 2.3.1
    479479 *
    480480 * @since 1.0.0
    481481 */
    482482function buddyforms_edit_post_link(
    483483    $text = null,
    484484    $before = '',
    485485    $after = '',
    486486    $id = 0,
    487487    $echo = true
    488488)
    489489{
    490490    if ( !($post = get_post( $id )) ) {
    491491        return;
    492492    }
    493493    if ( !($url = buddyforms_get_edit_post_link( $post->ID )) ) {
    494494        return;
    495495    }
    496496    if ( null === $text ) {
    497497        $text = __( 'Edit This' );
    498498    }
    499499    $link = '<a title="' . __( 'Edit', 'buddyforms' ) . '" class="post-edit-link" href="' . $url . '"><span aria-label="' . __( 'Edit', 'buddyforms' ) . '" class="dashicons dashicons-edit"> </span></a>';
    500500    /**
    501501     * Filter the post edit link anchor tag.
    502502     *
    503503     * @param string $link Anchor tag for the edit link.
    504504     * @param int $post_id Post ID.
    505505     * @param string $text Anchor text.
    506506     *
    507507     * @since 2.3.0
    508508     */
    509509    $result = $before . apply_filters(
    510510        'edit_post_link',
    511511        $link,
    512512        $post->ID,
    513513        $text
    514514    ) . $after;
    515515   
    516516    if ( $echo ) {
    517517        echo  wp_kses( $result, buddyforms_wp_kses_allowed_atts() ) ;
    518518    } else {
    519519        return $result;
    520520    }
    521521
    522522}
    523523
    524524/**
    525525 * @param $form_slug
    526526 */
    527527function buddyforms_post_entry_actions( $form_slug )
    528528{
    529529   
    530530    if ( !is_user_logged_in() ) {
    531531        echo  '' ;
    532532        return;
    533533    }
    534534   
    535535   
    536536    if ( empty($form_slug) ) {
    537537        echo  '' ;
    538538        return;
    539539    }
    540540   
    541541    global  $buddyforms, $post ;
    542542   
    543543    if ( !isset( $buddyforms[$form_slug] ) || empty($buddyforms[$form_slug]['attached_page']) ) {
    544544        echo  '' ;
    545545        return;
    546546    }
    547547   
    548548    $attached_page = ( !empty($buddyforms[$form_slug]['attached_page']) ? $buddyforms[$form_slug]['attached_page'] : 'none' );
    549549   
    550550    if ( $attached_page == 'none' ) {
    551551        echo  '' ;
    552552        return;
    553553    }
    554554   
    555555    ?>
    556556    <ul class="edit_links">
    557557        <?php
    558558    $is_author = buddyforms_is_author( $post->ID );
    559559    $user_can_all_submission = current_user_can( 'buddyforms_' . $form_slug . '_all' );
    560560   
    561561    if ( $is_author || $user_can_all_submission && isset( $buddyforms[$form_slug]['attached_page'] ) ) {
    562562        $permalink = '';
    563563       
    564564        if ( !empty($buddyforms[$form_slug]['attached_page']) ) {
    565565            $permalink = get_permalink( $buddyforms[$form_slug]['attached_page'] );
    566566            $permalink = apply_filters( 'buddyforms_the_loop_edit_permalink', $permalink, $buddyforms[$form_slug]['attached_page'] );
    567567        }
    568568       
    569569        if ( empty($permalink) ) {
    570570            return;
    571571        }
    572572        if ( is_multisite() ) {
    573573            if ( apply_filters( 'buddyforms_enable_multisite', false ) ) {
    574574               
    575575                if ( isset( $buddyforms[$form_slug]['blog_id'] ) ) {
    576576                    $current_site = get_current_site();
    577577                    $form_blog_id = $buddyforms[$form_slug]['blog_id'];
    578578                   
    579579                    if ( $current_site->blog_id != $form_blog_id ) {
    580580                        $form_site = get_blog_details( $form_blog_id, array( 'blog_id', 'blogname' ) );
    581581                        $permalink = str_replace( $form_site->path, $current_site->path, $permalink );
    582582                    }
    583583               
    584584                }
    585585           
    586586            }
    587587        }
    588588        ob_start();
    589589        $post_form_slug = get_post_meta( $post->ID, '_bf_form_slug', true );
    590590        if ( $post_form_slug ) {
    591591            $form_slug = $post_form_slug;
    592592        }
    593593        $current_user_can_edit = apply_filters(
    594594            'buddyforms_user_can_edit',
    595595            current_user_can( 'buddyforms_' . $form_slug . '_edit' ),
    596596            $form_slug,
    597597            $post->ID
    598598        );
    599599        $current_user_can_all = apply_filters(
    600600            'buddyforms_user_can_all',
    601601            current_user_can( 'buddyforms_' . $form_slug . '_all' ),
    602602            $form_slug,
    603603            $post->ID
    604604        );
    605605        $current_user_can_delete = apply_filters(
    606606            'buddyforms_user_can_delete',
    607607            current_user_can( 'buddyforms_' . $form_slug . '_delete' ),
    608608            $form_slug,
    609609            $post->ID
    610610        );
    611611        $current_user_can_create = apply_filters(
    612612            'buddyforms_user_can_create',
    613613            current_user_can( 'buddyforms_' . $form_slug . '_create' ),
    614614            $form_slug,
    615615            $post->ID
    616616        );
    617617        $current_user_can_draft = apply_filters(
    618618            'buddyforms_user_can_draft',
    619619            current_user_can( 'buddyforms_' . $form_slug . '_draft' ),
    620620            $form_slug,
    621621            $post->ID
    622622        );
    623623        $current_post_is_draft = $post->post_status == 'draft';
    624624        $current_user_edit_draft = $current_user_can_create && !$current_user_can_edit && $current_post_is_draft && $current_user_can_draft;
    625625        if ( isset( $buddyforms[$form_slug]['form_type'] ) && $buddyforms[$form_slug]['form_type'] != 'contact' ) {
    626626           
    627627            if ( $current_user_can_edit || $current_user_can_all || $current_user_edit_draft ) {
    628628                echo  '<li>' ;
    629629               
    630630                if ( isset( $buddyforms[$form_slug]['edit_link'] ) && $buddyforms[$form_slug]['edit_link'] != 'none' ) {
    631631                    echo  wp_kses( apply_filters(
    632632                        'buddyforms_loop_edit_post_link',
    633633                        '<a title="' . esc_attr__( 'Edit', 'buddyforms' ) . '" id="' . get_the_ID() . '" class="bf_edit_post" href="' . $permalink . 'edit/' . $form_slug . '/' . get_the_ID() . '"><span aria-label="' . esc_attr__( 'Edit', 'buddyforms' ) . '" class="dashicons dashicons-edit"> </span> ' . esc_attr__( 'Edit', 'buddyforms' ) . '</a>',
    634634                        get_the_ID(),
    635635                        $form_slug
    636636                    ), buddyforms_wp_kses_allowed_atts() ) ;
    637637                } else {
    638638                    echo  wp_kses( apply_filters(
    639639                        'buddyforms_loop_edit_post_link',
    640640                        buddyforms_edit_post_link(
    641641                        '<span aria-label="' . esc_attr__( 'Edit', 'buddyforms' ) . '" class="dashicons dashicons-edit"> </span> ' . esc_attr__( 'Edit', 'buddyforms' ),
    642642                        '',
    643643                        '',
    644644                        0,
    645645                        false
    646646                    ),
    647647                        get_the_ID(),
    648648                        $form_slug
    649649                    ), buddyforms_wp_kses_allowed_atts() ) ;
    650650                }
    651651               
    652652                echo  '</li>' ;
    653653            }
    654654       
    655655        }
    656656       
    657657        if ( $current_user_can_delete || $current_user_can_all ) {
    658658            echo  '<li>' ;
    659659            echo  '<a title="' . esc_attr__( 'Delete', 'buddyforms' ) . '"  id="' . get_the_ID() . '" class="bf_delete_post" href="#"><span aria-label="' . esc_attr__( 'Delete', 'buddyforms' ) . '" title="' . esc_attr__( 'Delete', 'buddyforms' ) . '" class="dashicons dashicons-trash"> </span> ' . esc_attr__( 'Delete', 'buddyforms' ) . '</a></li>' ;
    660660            echo  '</li>' ;
    661661        }
    662662       
    663663        // Add custom actions to the entry
    664664        do_action( 'buddyforms_the_loop_actions', get_the_ID() );
    665665        $meta_tmp = ob_get_clean();
    666666        // Display all actions
    667667        echo  wp_kses( apply_filters( 'buddyforms_the_loop_meta_html', $meta_tmp ), buddyforms_wp_kses_allowed_atts() ) ;
    668668    }
    669669   
    670670    do_action( 'buddyforms_the_loop_actions_last', get_the_ID() );
    671671    ?>
    672672    </ul>
    673673    <?php
    674674}
    675675
    676676/**
    677677 * Determinate if the current user is the user of the given post
    678678 *
    679679 * @param $post_id
    680680 *
    681681 * @return bool
    682682 */
    683683function buddyforms_is_author( $post_id )
    684684{
    685685    $is_author = false;
    686686    if ( get_post_field( 'post_author', $post_id ) == get_current_user_id() ) {
    687687        $is_author = true;
    688688    }
    689689    $form_slug = get_post_field( '_bf_form_slug', $post_id );
    690690    $is_author = apply_filters(
    691691        'buddyforms_user_can_edit',
    692692        $is_author,
    693693        $form_slug,
    694694        $post_id
    695695    );
    696696    return $is_author;
    697697}
    698698
    699699/**
    700700 * @param $post_status
    701701 */
    702702function buddyforms_post_status_readable( $post_status )
    703703{
    704704    echo  wp_kses_post( buddyforms_get_post_status_readable( $post_status ) ) ;
    705705}
    706706
    707707/**
    708708 * @param $post_status
    709709 *
    710710 * @return string
    711711 */
    712712function buddyforms_get_post_status_readable( $post_status )
    713713{
    714714    if ( $post_status == 'publish' ) {
    715715        return __( 'Published', 'buddyforms' );
    716716    }
    717717    if ( $post_status == 'draft' ) {
    718718        return __( 'Draft', 'buddyforms' );
    719719    }
    720720    if ( $post_status == 'pending' ) {
    721721        return __( 'Pending Review', 'buddyforms' );
    722722    }
    723723    if ( $post_status == 'future' ) {
    724724        return __( 'Scheduled', 'buddyforms' );
    725725    }
    726726    if ( $post_status == 'awaiting-review' ) {
    727727        return __( 'Awaiting Review', 'buddyforms' );
    728728    }
    729729    if ( $post_status == 'edit-draft' ) {
    730730        return __( 'Edit Draft', 'buddyforms' );
    731731    }
    732732    return apply_filters( 'buddyforms_get_post_status_readable', $post_status );
    733733}
    734734
    735735/**
    736736 * @param $post_status
    737737 * @param $form_slug
    738738 */
    739739function buddyforms_post_status_css_class( $post_status, $form_slug )
    740740{
    741741    echo  wp_kses_post( buddyforms_get_post_status_css_class( $post_status, $form_slug ) ) ;
    742742}
    743743
    744744/**
    745745 * @param $post_status
    746746 * @param $form_slug
    747747 *
    748748 * @return string
    749749 */
    750750function buddyforms_get_post_status_css_class( $post_status, $form_slug )
    751751{
    752752    $post_status_css = $post_status;
    753753    if ( $post_status == 'pending' ) {
    754754        $post_status_css = 'bf-pending';
    755755    }
    756756    return apply_filters( 'buddyforms_post_status_css', $post_status_css, $form_slug );
    757757}
    758758
    759759/**
    760760 * Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation !
    761761 *
    762762 * @param string $hook_name
    763763 * @param string $method_name
    764764 * @param int    $priority
    765765 *
    766766 * @return bool
    767767 */
    768768function buddyforms_remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 )
    769769{
    770770    global  $wp_filter ;
    771771    // Take only filters on right hook name and priority
    772772    if ( !isset( $wp_filter[$hook_name][$priority] ) || !is_array( $wp_filter[$hook_name][$priority] ) ) {
    773773        return false;
    774774    }
    775775    // Loop on filters registered
    776776    foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array ) {
    777777        // Test if filter is an array ! (always for class/method)
    778778        if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
    779779            // Test if object is a class and method is equal to param !
    780780            if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) {
    781781                unset( $wp_filter[$hook_name][$priority][$unique_id] );
    782782            }
    783783        }
    784784    }
    785785    return false;
    786786}
    787787
    788788/**
    789789 * Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :)
    790790 *
    791791 * @param string $hook_name
    792792 * @param string $class_name
    793793 * @param string $method_name
    794794 * @param int    $priority
    795795 *
    796796 * @return bool
    797797 */
    798798function buddyforms_remove_filters_for_anonymous_class(
    799799    $hook_name = '',
    800800    $class_name = '',
    801801    $method_name = '',
    802802    $priority = 0
    803803)
    804804{
    805805    global  $wp_filter ;
    806806    // Take only filters on right hook name and priority
    807807    if ( !isset( $wp_filter[$hook_name][$priority] ) || !is_array( $wp_filter[$hook_name][$priority] ) ) {
    808808        return false;
    809809    }
    810810    // Loop on filters registered
    811811    foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array ) {
    812812        // Test if filter is an array ! (always for class/method)
    813813        if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
    814814            // Test if object is a class, class and method is equal to param !
    815815            if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) == $class_name && $filter_array['function'][1] == $method_name ) {
    816816                unset( $wp_filter[$hook_name][$priority][$unique_id] );
    817817            }
    818818        }
    819819    }
    820820    return false;
    821821}
    822822
    823823/**
    824824 * Get all taxonomies
    825825 *
    826826 * @param $post_type
    827827 *
    828828 * @return
    829829 * @package BuddyForms
    830830 * @since 0.1-beta
    831831 */
    832832function buddyforms_taxonomies( $post_type )
    833833{
    834834    $taxonomies_array = get_object_taxonomies( $post_type, 'objects' );
    835835    $taxonomies['none'] = 'Select a Taxonomy';
    836836    foreach ( $taxonomies_array as $tax_slug => $tax ) {
    837837        $taxonomies[$tax->name] = $tax->label;
    838838    }
    839839    return $taxonomies;
    840840}
    841841
    842842function buddyforms_metabox_go_pro()
    843843{
    844844    buddyforms_go_pro(
    845845        '<span> </span>',
    846846        '',
    847847        array( __( 'Priority Support', 'buddyforms' ), __( 'More Form Elements', 'buddyforms' ), __( 'More Options', 'buddyforms' ) ),
    848848        false
    849849    );
    850850    buddyforms_go_pro(
    851851        '<span> </span>',
    852852        __( 'Full Control', 'buddyforms' ),
    853853        array(
    854854        __( 'Use your form in the backend admin edit screen like ACF', 'buddyforms' ),
    855855        __( 'Control who can create, edit and delete content', 'buddyforms' ),
    856856        __( 'Registration Options', 'buddyforms' ),
    857857        __( 'Disable ajax form submission', 'buddyforms' ),
    858858        __( 'Local Storage', 'buddyforms' ),
    859859        __( 'More Notification Options', 'buddyforms' ),
    860860        __( 'Import - Export Forms', 'buddyforms' )
    861861    ),
    862862        false
    863863    );
    864864    buddyforms_go_pro(
    865865        '<span> </span>',
    866866        __( 'Permissions Management', 'buddyforms' ),
    867867        array( __( 'Manage User Roles', 'buddyforms' ), __( 'Manage Capabilities', 'buddyforms' ), __( 'More Validation Options', 'buddyforms' ) ),
    868868        false
    869869    );
    870870    buddyforms_go_pro(
    871871        '<span> </span>',
    872872        __( 'More Post Options', 'buddyforms' ),
    873873        array(
    874874        __( 'All Post Types', 'buddyforms' ),
    875875        __( 'Posts Revision', 'buddyforms' ),
    876876        __( 'Comment Status', 'buddyforms' ),
    877877        __( 'Enable Login on the form', 'buddyforms' ),
    878878        __( 'Create an account during submission?', 'buddyforms' ),
    879879        __( 'Featured Image Support', 'buddyforms' )
    880880    ),
    881881        false
    882882    );
    883883    buddyforms_go_pro( '<span> </span>', __( 'Know Your User', 'buddyforms' ) . '<p><small>' . __( 'Get deep Insights about your Submitter', 'buddyforms' ) . '</small></p>', array(
    884884        __( 'IP Address', 'buddyforms' ),
    885885        __( 'Referer', 'buddyforms' ),
    886886        __( 'Browser', 'buddyforms' ),
    887887        __( 'Platform', 'buddyforms' ),
    888888        __( 'Reports', 'buddyforms' ),
    889889        __( 'User Agent', 'buddyforms' )
    890890    ) );
    891891}
    892892
    893893/**
    894894 * Get field by slug
    895895 *
    896896 * @param $form_slug
    897897 * @param $field_slug
    898898 *
    899899 * @return bool|array
    900900 * @author Sven edited by gfirem
    901901 */
    902902function buddyforms_get_form_field_by_slug( $form_slug, $field_slug )
    903903{
    904904    $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, 'buddyforms' );
    905905   
    906906    if ( $result_field === false ) {
    907907        global  $buddyforms ;
    908908        if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) {
    909909            foreach ( $buddyforms[$form_slug]['form_fields'] as $field_key => $field ) {
    910910               
    911911                if ( $field['slug'] == $field_slug ) {
    912912                    $result_field = $field;
    913913                    wp_cache_set( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, $result_field, 'buddyforms' );
    914914                    return $result_field;
    915915                }
    916916           
    917917            }
    918918        }
    919919    }
    920920   
    921921    return $result_field;
    922922}
    923923
    924924/**
    925925 * Get field by slug
    926926 *
    927927 * @param $form_slug
    928928 * @param $field_slug
    929929 * @param string     $by
    930930 *
    931931 * @return bool|array
    932932 * @since 2.5.11 Added the $by parameter to specify the comparison parameter
    933933 * @author Sven edited by gfirem
    934934 */
    935935function buddyforms_get_form_field_by( $form_slug, $field_slug, $by = 'slug' )
    936936{
    937937    $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, 'buddyforms' );
    938938   
    939939    if ( $result_field === false ) {
    940940        global  $buddyforms ;
    941941        if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) {
    942942            foreach ( $buddyforms[$form_slug]['form_fields'] as $field_key => $field ) {
    943943               
    944944                if ( $field[$by] == $field_slug ) {
    945945                    $result_field = $field;
    946946                    wp_cache_set( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, $result_field, 'buddyforms' );
    947947                    return $result_field;
    948948                }
    949949           
    950950            }
    951951        }
    952952    }
    953953   
    954954    return $result_field;
    955955}
    956956
    957957/**
    958958 * Get field by ID
    959959 *
    960960 * @param $form_slug
    961961 * @param $field_id
    962962 *
    963963 * @return bool|array
    964964 * @since 2.4.6
    965965 */
    966966function buddyforms_get_form_field_by_id( $form_slug, $field_id )
    967967{
    968968    $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_id . '_in_form_' . $form_slug, 'buddyforms' );
    969969   
    970970    if ( $result_field === false ) {
    971971        global  $buddyforms ;
    972972        if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) {
    973973           
    974974            if ( isset( $buddyforms[$form_slug]['form_fields'] ) && isset( $buddyforms[$form_slug]['form_fields'][$field_id] ) ) {
    975975                $result_field = $buddyforms[$form_slug]['form_fields'][$field_id];
    976976                wp_cache_set( 'buddyforms_get_field_' . $field_id . '_in_form_' . $form_slug, $result_field, 'buddyforms' );
    977977                return $result_field;
    978978            }
    979979       
    980980        }
    981981    }
    982982   
    983983    return $result_field;
    984984}
    985985
    986986/**
    987987 * Return teh array of field belong to the form.
    988988 *
    989989 * @param $form_slug
    990990 *
    991991 * @return bool|array
    992992 */
    993993function buddyforms_get_form_fields( $form_slug )
    994994{
    995995    $result_field = wp_cache_get( 'buddyforms_get_form_fields' . $form_slug, 'buddyforms' );
    996996   
    997997    if ( $result_field === false ) {
    998998        global  $buddyforms ;
    999999        if ( empty($form_slug) ) {
    10001000            return false;
    10011001        }
    10021002       
    10031003        if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) {
    10041004            $result_fields = $buddyforms[$form_slug]['form_fields'];
    10051005            wp_cache_set( 'buddyforms_get_form_fields' . $form_slug, $result_fields, 'buddyforms' );
    10061006            return $result_fields;
    10071007        }
    10081008   
    10091009    }
    10101010   
    10111011    return $result_field;
    10121012}
    10131013
    10141014/**
    10151015 * Check if field type exist in a form
    10161016 *
    10171017 * @param $form_slug
    10181018 * @param $field_type
    10191019 *
    10201020 * @param string     $search_by
    10211021 *
    10221022 * @return bool
    10231023 * @since 2.5.15 added $search_by
    10241024 */
    10251025function buddyforms_exist_field_type_in_form( $form_slug, $field_type, $search_by = 'type' )
    10261026{
    10271027    $fields = buddyforms_get_form_fields( $form_slug );
    10281028    $exist = false;
    10291029    if ( empty($fields) ) {
    10301030        return $exist;
    10311031    }
    10321032    foreach ( $fields as $field ) {
    10331033       
    10341034        if ( $field[$search_by] == $field_type ) {
    10351035            $exist = true;
    10361036            break;
    10371037        }
    10381038   
    10391039    }
    10401040    return $exist;
    10411041}
    10421042
    10431043//
    10441044// Add Placeholder support top the wp editor
    10451045//
    10461046add_filter( 'mce_external_plugins', 'buddyforms_add_mce_placeholder_plugin' );
    10471047function buddyforms_add_mce_placeholder_plugin( $plugins )
    10481048{
    10491049    if ( is_admin() ) {
    10501050        return $plugins;
    10511051    }
    10521052    $plugins['placeholder'] = BUDDYFORMS_PLUGIN_URL . 'assets/resources/wp-tinymce-placeholder/mce.placeholder.js';
    10531053    return $plugins;
    10541054}
    10551055
    10561056/**
    10571057 * Add garlic support to the wp editor for local save the content of the textarea
    10581058 *
    10591059 * @param $initArray
    10601060 *
    10611061 * @return mixed
    10621062 */
    10631063function buddyforms_tinymce_setup_function( $initArray )
    10641064{
    10651065    $initArray['setup'] = 'function(editor) {
    10661066                editor.on("change keyup", function(e){
    10671067                    editor.save();
    10681068                    jQuery(editor.getElement()).trigger(\'change\');
    10691069                });
    10701070            }';
    10711071    return $initArray;
    10721072}
    10731073
    10741074/**
    10751075 * Get a form by slug
    10761076 *
    10771077 * @param $form_slug
    10781078 *
    10791079 * @return bool|array
    10801080 */
    10811081function buddyforms_get_form_by_slug( $form_slug )
    10821082{
    10831083    $value = wp_cache_get( 'buddyforms_form_by_slug_' . $form_slug, 'buddyforms' );
    10841084   
    10851085    if ( $value === false ) {
    10861086        global  $buddyforms ;
    10871087       
    10881088        if ( isset( $buddyforms[$form_slug] ) ) {
    10891089            $value = $buddyforms[$form_slug];
    10901090            wp_cache_set( 'buddyforms_form_by_slug_' . $form_slug, $value, 'buddyforms' );
    10911091        }
    10921092   
    10931093    }
    10941094   
    10951095    return $value;
    10961096}
    10971097
    10981098/**
    10991099 * Get form option
    11001100 *
    11011101 * @param $form_slug
    11021102 * @param string    $option
    11031103 *
    11041104 * @return string|bool
    11051105 * @since 2.5.19
    11061106 */
    11071107function buddyforms_get_form_option( $form_slug, $option )
    11081108{
    11091109    $value = false;
    11101110   
    11111111    if ( !empty($form_slug) && !empty($option) ) {
    11121112        $cache_key = 'buddyforms_form_' . $form_slug . '_option_' . $option;
    11131113        $value = wp_cache_get( $cache_key, 'buddyforms' );
    11141114       
    11151115        if ( $value === false ) {
    11161116            $bf_form = buddyforms_get_form_by_slug( $form_slug );
    11171117           
    11181118            if ( !empty($bf_form) ) {
    11191119                $value = ( isset( $bf_form[$option] ) ? $bf_form[$option] : false );
    11201120                wp_cache_set( $cache_key, $value, 'buddyforms' );
    11211121            }
    11221122       
    11231123        }
    11241124   
    11251125    }
    11261126   
    11271127    return $value;
    11281128}
    11291129
    11301130/**
    11311131 * Will return the form slug from post meta or the default. none if no form is attached
    11321132 *
    11331133 * @param $post_id
    11341134 *
    11351135 * @return mixed
    11361136 * @author Sven edited by gfirem
    11371137 */
    11381138function buddyforms_get_form_slug_by_post_id( $post_id )
    11391139{
    11401140    $value = wp_cache_get( 'buddyform_form_slug_' . $post_id, 'buddyforms' );
    11411141   
    11421142    if ( $value === false ) {
    11431143        $value = get_post_meta( $post_id, '_bf_form_slug', true );
    11441144       
    11451145        if ( empty($value) || isset( $value ) && $value == 'none' ) {
    11461146            $buddyforms_posttypes_default = get_option( 'buddyforms_posttypes_default' );
    11471147            $post_type = get_post_type( $post_id );
    11481148            if ( isset( $buddyforms_posttypes_default[$post_type] ) ) {
    11491149                $value = $buddyforms_posttypes_default[$post_type];
    11501150            }
    11511151        }
    11521152       
    11531153        wp_cache_set( 'buddyform_form_slug_' . $post_id, $value, 'buddyforms' );
    11541154    }
    11551155   
    11561156    return $value;
    11571157}
    11581158
    11591159/**
    11601160 * Get the post types for teh created forms
    11611161 *
    11621162 * @return array
    11631163 */
    11641164function buddyforms_get_post_types_from_forms()
    11651165{
    11661166    global  $buddyforms ;
    11671167    $result = array();
    11681168   
    11691169    if ( !empty($buddyforms) ) {
    11701170        foreach ( $buddyforms as $form ) {
    11711171            $result[] = $form['post_type'];
    11721172        }
    11731173        $result = array_unique( $result );
    11741174    }
    11751175   
    11761176    return $result;
    11771177}
    11781178
    11791179function buddyforms_get_post_types()
    11801180{
    11811181    $post_types = array();
    11821182    // Generate the Post Type Array 'none' == Contact Form
    11831183    $post_types['bf_submissions'] = __( 'none', 'buddyforms' );
    11841184    $post_types['post'] = __( 'Post', 'buddyforms' );
    11851185    $post_types['page'] = __( 'Page', 'buddyforms' );
    11861186    return $post_types;
    11871187}
    11881188
    11891189/**
    11901190 * This function return the dropdown populated with the pages of the site including the childs
    11911191 *
    11921192 * @param $name
    11931193 * @param $selected
    11941194 * @param string   $id
    11951195 * @param string   $default_option_string
    11961196 * @param string   $default_option_value
    11971197 * @param string   $view
    11981198 *
    11991199 * @return string
    12001200 * @author gfirem
    12011201 *
    12021202 * @since 2.5.10
    12031203 */
    12041204function buddyforms_get_all_pages_dropdown(
    12051205    $name,
    12061206    $selected,
    12071207    $id = '',
    12081208    $default_option_string = 'WordPress Default',
    12091209    $default_option_value = 'none',
    12101210    $view = 'form_builder'
    12111211)
    12121212{
    12131213    if ( $default_option_string === 'WordPress Default' ) {
    12141214        $default_option_string = __( 'WordPress Default', 'buddyforms' );
    12151215    }
    12161216    $exclude = array();
    12171217    $page_on_front = get_option( 'page_on_front' );
    12181218    if ( !empty($page_on_front) && $page_on_front !== 'none' && is_numeric( $page_on_front ) && $page_on_front != $selected ) {
    12191219        $exclude[] = intval( $page_on_front );
    12201220    }
    12211221   
    12221222    if ( $view == 'form_builder' ) {
    12231223        $buddyforms_registration_page = get_option( 'buddyforms_registration_page' );
    12241224        if ( !empty($buddyforms_registration_page) && $buddyforms_registration_page !== 'none' && is_numeric( $buddyforms_registration_page ) && $buddyforms_registration_page != $selected ) {
    12251225            $exclude[] = intval( $buddyforms_registration_page );
    12261226        }
    12271227    }
    12281228   
    12291229    $args = array(
    12301230        'depth'             => 0,
    12311231        'post_type'         => 'page',
    12321232        'exclude_tree'      => $exclude,
    12331233        'selected'          => $selected,
    12341234        'name'              => $name,
    12351235        'id'                => ( !empty($id) ? $id : $name ),
    12361236        'show_option_none'  => $default_option_string,
    12371237        'option_none_value' => $default_option_value,
    12381238        'sort_column'       => 'post_title',
    12391239        'echo'              => 0,
    12401240    );
    12411241    return wp_kses( wp_dropdown_pages( $args ), buddyforms_wp_kses_allowed_atts() );
    12421242}
    12431243
    12441244function buddyforms_get_all_pages(
    12451245    $type = 'id',
    12461246    $view = 'form_builder',
    12471247    $exclude_global_submission_endpoint = false,
    12481248    $extra_exclude_ids = array(),
    12491249    $default_string = ''
    12501250)
    12511251{
    12521252    $exclude = array();
    12531253    if ( empty($default_string) ) {
    12541254        $default_string = __( 'Select a Page', 'buddyforms' );
    12551255    }
    12561256    // get the page_on_front and exclude it from the query. This page should not get used for the endpoints
    12571257    $page_on_front = get_option( 'page_on_front' );
    12581258    if ( !empty($page_on_front) ) {
    12591259        $exclude[] = $page_on_front;
    12601260    }
    12611261   
    12621262    if ( $view == 'form_builder' ) {
    12631263        $buddyforms_registration_page = get_option( 'buddyforms_registration_page' );
    12641264        if ( !empty($buddyforms_registration_page) ) {
    12651265            $exclude[] = $buddyforms_registration_page;
    12661266        }
    12671267    }
    12681268   
    12691269   
    12701270    if ( !empty($exclude_global_submission_endpoint) ) {
    12711271        $buddyforms_submissions_page = get_option( 'buddyforms_submissions_page' );
    12721272        if ( !empty($buddyforms_submissions_page) ) {
    12731273            $exclude[] = $buddyforms_submissions_page;
    12741274        }
    12751275    }
    12761276   
    12771277    if ( !empty($extra_exclude_ids) ) {
    12781278        $exclude = array_merge( $extra_exclude_ids, $exclude );
    12791279    }
    12801280    $args = array(
    12811281        'sort_order'  => 'asc',
    12821282        'sort_column' => 'post_title',
    12831283        'parent'      => -1,
    12841284        'post_type'   => 'page',
    12851285        'post_status' => 'publish',
    12861286    );
    12871287    if ( !empty($exclude) ) {
    12881288        $args['exclude'] = $exclude;
    12891289    }
    12901290    $pages = get_pages( $args );
    12911291    $all_pages = array();
    12921292    $all_pages['none'] = $default_string;
    12931293    if ( $type == 'id' ) {
    12941294        // Generate the pages array by id
    12951295        foreach ( $pages as $page ) {
    12961296            $all_pages[$page->ID] = $page->post_title;
    12971297        }
    12981298    }
    12991299    if ( $type == 'name' ) {
    13001300        foreach ( $pages as $page ) {
    13011301            $all_pages[$page->post_name] = $page->post_title;
    13021302        }
    13031303    }
    13041304    return $all_pages;
    13051305}
    13061306
    13071307add_action( 'admin_bar_menu', 'buddyform_admin_bar_shortcut', 60 );
    13081308/**
    13091309 * Add a short-code to the admin toolbar to edit the form in the current screen
    13101310 *
    13111311 * @param WP_Admin_Bar $wp_admin_bar
    13121312 */
    13131313function buddyform_admin_bar_shortcut( $wp_admin_bar )
    13141314{
    13151315    if ( is_admin() && is_user_logged_in() ) {
    13161316        return;
    13171317    }
    13181318    global  $post, $buddyforms ;
    13191319    if ( empty($post->ID) ) {
    13201320        return;
    13211321    }
    13221322    $form_slug = '';
    13231323    global  $wp_query ;
    13241324   
    13251325    if ( !empty($wp_query->query_vars['bf_form_slug']) ) {
    13261326        $form_slug = sanitize_title( $wp_query->query_vars['bf_form_slug'] );
    13271327    } elseif ( !empty($post->post_name) ) {
    13281328        $form_slug = $post->post_name;
    13291329    }
    13301330   
    13311331    if ( empty($form_slug) && is_array( $buddyforms ) && !array_key_exists( $form_slug, $buddyforms ) ) {
    13321332        return;
    13331333    }
    13341334    if ( !current_user_can( 'buddyforms_' . $form_slug . '_create' ) ) {
    13351335        return;
    13361336    }
    13371337    $form = get_page_by_path( $form_slug, 'OBJECT', 'buddyforms' );
    13381338    if ( empty($form) ) {
    13391339        return;
    13401340    }
    13411341    $post_url = sprintf( 'post.php?post=%s&action=edit', $form->ID );
    13421342    $args = array(
    13431343        'id'    => 'buddyforms-admin-edit-form',
    13441344        'title' => __( 'Edit BuddyForm', 'buddyforms' ),
    13451345        'href'  => admin_url( $post_url ),
    13461346        'meta'  => array(
    13471347        'data-post_id' => 33,
    13481348        'class'        => 'admin-bar dashicons-before dashicons-buddyforms',
    13491349    ),
    13501350    );
    13511351    $wp_admin_bar->add_node( $args );
    13521352}
    13531353
    13541354add_action( 'buddyforms_form_hero_last', 'buddyforms_form_footer_terms' );
    13551355function buddyforms_form_footer_terms( $html )
    13561356{
    13571357    $buddyforms_gdpr = get_option( 'buddyforms_gdpr' );
    13581358    $html .= ' <div class="terms"><p>';
    13591359    if ( !empty($buddyforms_gdpr['terms_label']) ) {
    13601360        $html .= '<span id="" class="buddyforms_terms_label">' . $buddyforms_gdpr['terms_label'] . '</span> ';
    13611361    }
    13621362    if ( isset( $buddyforms_gdpr['terms'] ) && $buddyforms_gdpr['terms'] != 'none' ) {
    13631363        $html .= '<a id="" class="" href="' . get_permalink( $buddyforms_gdpr['terms'] ) . '">' . get_the_title( $buddyforms_gdpr['terms'] ) . '</a>';
    13641364    }
    13651365    $html .= '</p></div>';
    13661366    return $html;
    13671367}
    13681368
    13691369/**
    13701370 * This function is an internal implementation to generate the nonce base on specific user.
    13711371 * We create this to generate nonce for user not logged in
    13721372 *
    13731373 * @readmore wp-includes/pluggable.php:2147
    13741374 *
    13751375 * @param int    $action
    13761376 * @param int    $user_id
    13771377 * @param string $token
    13781378 *
    13791379 * @return bool|string
    13801380 * @since 2.5.10 Added the token parameter to emulate loggout user nonce
    13811381 */
    13821382function buddyforms_create_nonce( $action = -1, $user_id = 0, $token = '' )
    13831383{
    13841384   
    13851385    if ( $user_id === 0 ) {
    13861386        $user = wp_get_current_user();
    13871387        $uid = (int) $user->ID;
    13881388        if ( !$uid ) {
    13891389            /** This filter is documented in wp-includes/pluggable.php */
    13901390            $uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
    13911391        }
    13921392        $token = wp_get_session_token();
    13931393    } else {
    13941394        $uid = $user_id;
    13951395    }
    13961396   
    13971397    $i = wp_nonce_tick();
    13981398    return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
    13991399}
    14001400
    14011401function buddyforms_form_display_message( $form_slug, $post_id, $source = 'after_submit_message_text' )
    14021402{
    14031403    global  $buddyforms ;
    14041404    $display_message = buddyforms_default_message_on_create();
    14051405   
    14061406    if ( !empty($buddyforms[$form_slug][$source]) ) {
    14071407        $display_message = $buddyforms[$form_slug][$source];
    14081408    } else {
    14091409        if ( $source !== 'after_submit_message_text' ) {
    14101410            $display_message = buddyforms_default_message_on_update();
    14111411        }
    14121412    }
    14131413   
    14141414    $display_message = apply_filters(
    14151415        'buddyforms_form_display_message',
    14161416        $display_message,
    14171417        $form_slug,
    14181418        $post_id,
    14191419        $source
    14201420    );
    14211421   
    14221422    if ( !empty($buddyforms[$form_slug]['attached_page']) ) {
    14231423        $permalink = get_permalink( $buddyforms[$form_slug]['attached_page'] );
    14241424        $display_message = str_ireplace( '[edit_link]', '<a title="' . __( 'Edit Post', 'buddyforms' ) . '" href="' . $permalink . 'edit/' . $form_slug . '/' . $post_id . '">' . __( 'Continue Editing', 'buddyforms' ) . '</a>', $display_message );
    14251425    }
    14261426   
    14271427    $display_message = str_ireplace( '[form_singular_name]', $buddyforms[$form_slug]['singular_name'], $display_message );
    14281428    $display_message = str_ireplace( '[post_title]', get_the_title( $post_id ), $display_message );
    14291429    $display_message = str_ireplace( '[post_link]', '<a title="' . __( 'Display Post', 'buddyforms' ) . '" href="' . get_permalink( $post_id ) . '">' . __( 'Display Post', 'buddyforms' ) . '</a>', $display_message );
    14301430    return do_shortcode( $display_message );
    14311431}
    14321432
    14331433function buddyforms_user_fields_array()
    14341434{
    14351435    return array(
    14361436        'user_login',
    14371437        'user_email',
    14381438        'user_first',
    14391439        'user_last',
    14401440        'user_pass',
    14411441        'user_website',
    14421442        'display_name',
    14431443        'user_bio',
    14441444        'country',
    14451445        'state'
    14461446    );
    14471447}
    14481448
    14491449function buddyforms_default_message_on_update()
    14501450{
    14511451    return __( 'Form Updated Successfully.', 'buddyforms' );
    14521452}
    14531453
    14541454function buddyforms_default_message_on_empty_submission_list()
    14551455{
    14561456    return __( 'There were no posts found. Create your first post [bf_new_submission_link name="Now"]!', 'buddyforms' );
    14571457}
    14581458
    14591459function buddyforms_default_message_on_create()
    14601460{
    14611461    return __( 'Form Submitted Successfully.', 'buddyforms' );
    14621462}
    14631463
    14641464add_action( 'wp_ajax_nopriv_handle_dropped_media', 'buddyforms_upload_handle_dropped_media' );
    14651465add_action( 'wp_ajax_handle_dropped_media', 'buddyforms_upload_handle_dropped_media' );
    14661466function buddyforms_upload_handle_dropped_media()
    14671467{
    14681468    check_ajax_referer( 'fac_drop', 'nonce' );
    1469     status_header( 200 );
    1470     $newupload = 0;
    1471    
    1472     if ( !empty($_FILES) ) {
    1473         $files = $_FILES;
    1474         foreach ( $files as $file_id => $file ) {
    1475             $newupload = media_handle_upload( $file_id, 0 );
    1476         }
    1477     }
    1478    
    1479    
    1480     if ( is_wp_error( $newupload ) ) {
    1481         status_header( '500' );
    1482         echo  wp_kses_post( $newupload->get_error_message() ) ;
     1469    $form_slug = ( isset( $_POST['form_slug'] ) ? sanitize_text_field( wp_unslash( $_POST['form_slug'] ) ) : '' );
     1470    $current_user = wp_get_current_user();
     1471    $current_user_can_edit = bf_user_can(
     1472        $current_user->ID,
     1473        'buddyforms_' . $form_slug . '_edit',
     1474        array(),
     1475        $form_slug
     1476    );
     1477    $current_user_can_create = bf_user_can(
     1478        $current_user->ID,
     1479        'buddyforms_' . $form_slug . '_create',
     1480        array(),
     1481        $form_slug
     1482    );
     1483    $current_user_can_draft = bf_user_can(
     1484        $current_user->ID,
     1485        'buddyforms_' . $form_slug . '_draft',
     1486        array(),
     1487        $form_slug
     1488    );
     1489   
     1490    if ( $current_user_can_edit || $current_user_can_create || $current_user_can_draft ) {
     1491        status_header( 200 );
     1492        $newupload = 0;
     1493       
     1494        if ( !empty($_FILES) ) {
     1495            $files = $_FILES;
     1496            foreach ( $files as $file_id => $file ) {
     1497                $newupload = media_handle_upload( $file_id, 0 );
     1498            }
     1499        }
     1500       
     1501       
     1502        if ( is_wp_error( $newupload ) ) {
     1503            status_header( '500' );
     1504            echo  wp_kses_post( $newupload->get_error_message() ) ;
     1505        } else {
     1506            status_header( '200' );
     1507            echo  wp_kses_post( $newupload ) ;
     1508        }
     1509       
     1510        die;
    14831511    } else {
    1484         status_header( '200' );
    1485         echo  wp_kses_post( $newupload ) ;
    1486     }
    1487    
    1488     die;
     1512        die;
     1513    }
     1514
    14891515}
    14901516
    14911517add_action( 'wp_ajax_nopriv_handle_deleted_media', 'buddyforms_upload_handle_delete_media' );
    14921518add_action( 'wp_ajax_handle_deleted_media', 'buddyforms_upload_handle_delete_media' );
    14931519function buddyforms_upload_handle_delete_media()
    14941520{
    14951521    check_ajax_referer( 'fac_drop', 'nonce' );
    14961522   
    14971523    if ( isset( $_REQUEST['media_id'] ) ) {
    14981524        $post_id = absint( $_REQUEST['media_id'] );
    1499         $status = wp_delete_attachment( $post_id, true );
     1525        $post = get_post( $post_id );
     1526        $current_user = wp_get_current_user();
     1527       
     1528        if ( $post->post_author == $current_user->ID ) {
     1529            $status = wp_delete_attachment( $post_id, true );
     1530        } else {
     1531            $status = false;
     1532        }
     1533       
    15001534       
    15011535        if ( $status ) {
    15021536            echo  wp_json_encode( array(
    15031537                'status' => 'OK',
    15041538            ) ) ;
    15051539        } else {
    15061540            echo  wp_json_encode( array(
    15071541                'status' => 'FAILED',
    15081542            ) ) ;
    15091543        }
    15101544   
    15111545    }
    15121546   
    15131547    die;
    15141548}
    15151549
    15161550add_action( 'wp_ajax_nopriv_upload_image_from_url', 'buddyforms_upload_image_from_url' );
    15171551add_action( 'wp_ajax_upload_image_from_url', 'buddyforms_upload_image_from_url' );
    15181552function buddyforms_upload_image_from_url()
    15191553{
    15201554    $url = ( isset( $_REQUEST['url'] ) ? wp_kses_post( wp_unslash( $_REQUEST['url'] ) ) : '' );
    15211555    $valid_url = strtolower( $url );
    15221556    if ( strpos( $valid_url, 'phar://' ) !== false || pathinfo( $valid_url, PATHINFO_EXTENSION ) === 'phar' || strpos( $valid_url, 'php://' ) !== false ) {
    15231557        return false;
    15241558    }
    15251559    $file_id = ( isset( $_REQUEST['id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
    15261560    $accepted_files = ( isset( $_REQUEST['accepted_files'] ) ? explode( ',', buddyforms_sanitize( '', wp_unslash( $_REQUEST['accepted_files'] ) ) ) : array( 'jpeg' ) );
    15271561   
    15281562    if ( !empty($url) && !empty($file_id) ) {
    15291563        $upload_dir = wp_upload_dir();
    15301564        $image_url = urldecode( $url );
    15311565        $image_data = file_get_contents( $image_url );
    15321566        // Get image data
    15331567        $image_data_information = getimagesize( $image_url );
    15341568        $image_mime_information = $image_data_information['mime'];
    15351569       
    15361570        if ( !in_array( $image_mime_information, $accepted_files ) ) {
    15371571            echo  wp_json_encode( array(
    15381572                'status'   => 'FAILED',
    15391573                'response' => __( 'File type ' . $image_mime_information . ' is not allowed.', 'budduforms' ),
    15401574            ) ) ;
    15411575            die;
    15421576        }
    15431577       
    15441578       
    15451579        if ( $image_data && $image_data_information ) {
    15461580            $file_name = $file_id . '.png';
    15471581            $full_path = wp_normalize_path( $upload_dir['path'] . DIRECTORY_SEPARATOR . $file_name );
    15481582            $upload_file = wp_upload_bits( $file_name, null, $image_data );
    15491583           
    15501584            if ( !$upload_file['error'] ) {
    15511585                $wp_filetype = wp_check_filetype( $file_name, null );
    15521586                $attachment = array(
    15531587                    'post_mime_type' => $wp_filetype['type'],
    15541588                    'post_title'     => preg_replace( '/\\.[^.]+$/', '', $file_name ),
    15551589                    'post_content'   => '',
    15561590                    'post_status'    => 'inherit',
    15571591                );
    15581592                $attachment_id = wp_insert_attachment( $attachment, $upload_file['file'] );
    15591593                $url = wp_get_attachment_thumb_url( $attachment_id );
    15601594                echo  wp_json_encode( array(
    15611595                    'status'        => 'OK',
    15621596                    'response'      => $url,
    15631597                    'attachment_id' => $attachment_id,
    15641598                ) ) ;
    15651599                die;
    15661600            } else {
    15671601                echo  wp_json_encode( array(
    15681602                    'status'   => 'FAILED',
    15691603                    'response' => 'Error uploading image.',
    15701604                ) ) ;
    15711605                die;
    15721606            }
    15731607       
    15741608        } else {
    15751609            echo  wp_json_encode( array(
    15761610                'status'   => 'FAILED',
    15771611                'response' => 'The Url provided is not an image.',
    15781612            ) ) ;
    15791613            die;
    15801614        }
    15811615   
    15821616    } else {
    15831617        echo  wp_json_encode( array(
    15841618            'status'   => 'FAILED',
    15851619            'response' => 'Wrong Format or Empty Url.',
    15861620        ) ) ;
    15871621        die;
    15881622    }
    15891623
    15901624}
    15911625
    15921626/**
    15931627 * Check if a file was include into the global php queue
    15941628 *
    15951629 * @param $file_name
    15961630 *
    15971631 * @return bool
    15981632 * @since 2.2.8
    15991633 *
    16001634 * @author gfirem
    16011635 */
    16021636function buddyforms_check_loaded_file( $file_name )
    16031637{
    16041638    $includes_files = get_included_files();
    16051639    return in_array( $file_name, $includes_files );
    16061640}
    16071641
    16081642function buddyform_get_role_names()
    16091643{
    16101644    global  $wp_roles ;
    16111645    if ( !isset( $wp_roles ) ) {
    16121646        $wp_roles = new WP_Roles();
    16131647    }
    16141648    return $wp_roles->get_names();
    16151649}
    16161650
    16171651/**
    16181652 * Get a tag inside a shortcode from a given content.
    16191653 *
    16201654 * @param array  $shortcodes
    16211655 * @param array  $targets_tags
    16221656 * @param string $content
    16231657 *
    16241658 * @return string
    16251659 * @since 2.3.1
    16261660 */
    16271661function buddyforms_get_shortcode_tag( $shortcodes, $targets_tags, $content )
    16281662{
    16291663    if ( !is_array( $shortcodes ) || !is_array( $targets_tags ) ) {
    16301664        return '';
    16311665    }
    16321666    foreach ( $shortcodes as $shortcode ) {
    16331667        $regrex = sprintf( '(\\[%s)(.*?)form_slug=\\"(.*?)\\"', $shortcode );
    16341668        preg_match_all( "/{$regrex}/m", $content, $match );
    16351669        if ( !empty($match) && !empty($match[1][0]) && $match[1][0] === '[' . $shortcode && !empty($match[3][0]) ) {
    16361670            return $match[3][0];
    16371671        }
    16381672    }
    16391673    $pattern = get_shortcode_regex();
    16401674    $result = '';
    16411675    preg_replace_callback( "/{$pattern}/m", function ( $tag ) use( $shortcodes, $targets_tags, &$result ) {
    16421676        foreach ( $shortcodes as $shortcode_item ) {
    16431677           
    16441678            if ( $shortcode_item === $tag[2] ) {
    16451679                $attributes = shortcode_parse_atts( $tag[3] );
    16461680                if ( !empty($attributes) ) {
    16471681                    foreach ( $targets_tags as $target_item ) {
    16481682                       
    16491683                        if ( array_key_exists( $target_item, $attributes ) ) {
    16501684                            $result = $attributes[$target_item];
    16511685                            return $tag[0];
    16521686                        }
    16531687                   
    16541688                    }
    16551689                }
    16561690            }
    16571691       
    16581692        }
    16591693        return $tag[0];
    16601694    }, $content );
    16611695    return $result;
    16621696}
    16631697
    16641698/**
    16651699 * Extract the form slug from a html inside the given content reading the inout hidden with the Id `form_slug`
    16661700 *
    16671701 * @param $content
    16681702 *
    16691703 * @return string
    16701704 */
    16711705function buddyforms_get_form_slug_from_html( $content )
    16721706{
    16731707    if ( !empty($content) ) {
    16741708        try {
    16751709            libxml_use_internal_errors( true );
    16761710            $dom = new DOMDocument();
    16771711            $dom->validateOnParse = false;
    16781712            $content = mb_convert_encoding( $content, 'HTML-ENTITIES', 'UTF-8' );
    16791713            $dom->loadHTML( $content );
    16801714            $form_input_node = $dom->getElementById( 'form_slug' );
    16811715            libxml_use_internal_errors( false );
    16821716            if ( !empty($form_input_node) && $form_input_node instanceof DOMElement ) {
    16831717                return $form_input_node->getAttribute( 'value' );
    16841718            }
    16851719        } catch ( Exception $e ) {
    16861720        }
    16871721    }
    16881722    return '';
    16891723}
    16901724
    16911725/**
    16921726 * Extract the form slug from a shortcode inside the given content
    16931727 *
    16941728 * @param $content
    16951729 * @param array   $shortcodes
    16961730 *
    16971731 * @return string
    16981732 */
    16991733function buddyforms_get_form_slug_from_shortcode( $content, $shortcodes = array( 'bf', 'buddyforms_form' ) )
    17001734{
    17011735    $form_slug = buddyforms_get_shortcode_tag( $shortcodes, array( 'form_slug', 'id' ), $content );
    17021736   
    17031737    if ( is_numeric( $form_slug ) ) {
    17041738        $form_post = get_post( $form_slug );
    17051739        $form_slug = $form_post->post_name;
    17061740    }
    17071741   
    17081742    return $form_slug;
    17091743}
    17101744
    17111745/**
    17121746 * Extract the form slug from a shortcode inside the given content, if exist the shortcode or reading the hidden input form_slug from the html
    17131747 *
    17141748 * @param $content
    17151749 * @param array   $shortcodes
    17161750 *
    17171751 * @return string
    17181752 */
    17191753function buddyforms_get_form_slug_from_content( $content, $shortcodes = array(
    17201754    'bf-list-submissions',
    17211755    'buddyforms_form',
    17221756    'buddyforms_list_all',
    17231757    'buddyforms_the_loop',
    17241758    'bf',
    17251759    'buddyforms_reset_password'
    17261760) )
    17271761{
    17281762    // Extract from the a shortcode inside the content
    17291763    $form_slug = buddyforms_get_shortcode_tag( $shortcodes, array( 'form_slug', 'id' ), $content );
    17301764    // Extract form the html inside the content, reading the hidden input form_slug
    17311765   
    17321766    if ( empty($form_slug) ) {
    17331767        // use regex to extract
    17341768        $regex = array();
    17351769        preg_match( '/<input type="hidden" name="form_slug" value="(.*?)" id="form_slug"/m', $content, $regex );
    17361770        if ( !empty($regex) && isset( $regex[1] ) ) {
    17371771           
    17381772            if ( is_array( $regex[1] ) ) {
    17391773                $form_slug = $regex[1][0];
    17401774            } else {
    17411775                $form_slug = $regex[1];
    17421776            }
    17431777       
    17441778        }
    17451779       
    17461780        if ( empty($form_slug) ) {
    17471781            $regex = array();
    17481782            preg_match( '/"bf_form_slug":"(.+?)"(?=.")/m', $content, $regex );
    17491783            // gutenberg block
    17501784            if ( !empty($regex) && isset( $regex[1] ) ) {
    17511785                $form_slug = $regex[1];
    17521786            }
    17531787        }
    17541788       
    17551789       
    17561790        if ( empty($form_slug) ) {
    17571791            $regex = array();
    17581792            preg_match( '/"bf_form_slug":"(.*)"/m', $content, $regex );
    17591793            // gutenberg block
    17601794            if ( !empty($regex) && isset( $regex[1] ) ) {
    17611795                $form_slug = $regex[1];
    17621796            }
    17631797        }
    17641798   
    17651799    }
    17661800   
    17671801   
    17681802    if ( is_numeric( $form_slug ) ) {
    17691803        $form_post = get_post( $form_slug );
    17701804        $form_slug = $form_post->post_name;
    17711805    }
    17721806   
    17731807    return $form_slug;
    17741808}
    17751809
    17761810/**
    17771811 * Detext if is gutenberg
    17781812 *
    17791813 * @return boolean
    17801814 */
    17811815function buddyforms_is_gutenberg_page()
    17821816{
    17831817    if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
    17841818        // The Gutenberg plugin is on.
    17851819        return true;
    17861820    }
    17871821    require_once ABSPATH . 'wp-admin/includes/screen.php';
    17881822    require_once ABSPATH . 'wp-admin/includes/admin.php';
    17891823    $current_screen = get_current_screen();
    17901824    if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
    17911825        // Gutenberg page on 5+.
    17921826        return true;
    17931827    }
    17941828    return false;
    17951829}
    17961830
    17971831/**
    17981832 * This function secure the array of options to use in the buddyformsGlobal
    17991833 *
    18001834 * @param $options
    18011835 * @param $form_slug
    18021836 * @param $bf_post_id
    18031837 *
    18041838 * @return mixed
    18051839 * @since 2.4.0
    18061840 */
    18071841function buddyforms_filter_frontend_js_form_options( $options, $form_slug, $bf_post_id = 0 )
    18081842{
    18091843    /**
    18101844     * Let the user change the user granted options to use in the frontend global variable buddyformsGlobal
    18111845     *
    18121846     * @param array granted keys from the options
    18131847     * @param string The form slug from the global wp_query
    18141848     * @param number The current post id form the wp_query. This can be empty when the form is creating an entry.
    18151849     *
    18161850     * @since 2.4.0
    18171851     */
    18181852    $granted = apply_filters(
    18191853        'buddyforms_frontend_granted_forms_option',
    18201854        array(
    18211855        'status',
    18221856        'form_fields',
    18231857        'draft_action',
    18241858        'js_validation'
    18251859    ),
    18261860        $form_slug,
    18271861        $bf_post_id
    18281862    );
    18291863    foreach ( $granted as $item ) {
    18301864        if ( isset( $options[$item] ) ) {
    18311865            $result[$item] = $options[$item];
    18321866        }
    18331867    }
    18341868    // Filter the field options
    18351869    $remove_field_options = apply_filters(
    18361870        'buddyforms_remove_frontend_forms_fields_option',
    18371871        array( 'captcha_private_key' ),
    18381872        $form_slug,
    18391873        $bf_post_id
    18401874    );
    18411875    if ( !empty($result['form_fields']) ) {
    18421876        foreach ( $remove_field_options as $remove_field ) {
    18431877            foreach ( $result['form_fields'] as $field_id => $field ) {
    18441878                if ( isset( $field[$remove_field] ) ) {
    18451879                    unset( $result['form_fields'][$field_id][$remove_field] );
    18461880                }
    18471881            }
    18481882        }
    18491883    }
    18501884    return $result;
    18511885}
    18521886
    18531887/**
    18541888 * Retrieve the form slug from different sources
    18551889 *
    18561890 * @return string
    18571891 * @since 2.4.0
    18581892 */
    18591893function buddyforms_get_form_slug()
    18601894{
    18611895    $form_slug = '';
    18621896    global  $wp_query, $post ;
    18631897   
    18641898    if ( !empty($wp_query->query_vars['bf_form_slug']) ) {
    18651899        $form_slug = sanitize_title( $wp_query->query_vars['bf_form_slug'] );
    18661900    } elseif ( !empty($_GET['form_slug']) ) {
    18671901        $form_slug = sanitize_title( wp_unslash( $_GET['form_slug'] ) );
    18681902    } elseif ( !empty($wp_query->query_vars['form_slug']) ) {
    18691903        $form_slug = sanitize_title( $wp_query->query_vars['form_slug'] );
    18701904    } elseif ( !empty($post) ) {
    18711905        $post_content = ( !empty($content) ? $content : $post->post_content );
    18721906       
    18731907        if ( !empty($post->post_name) && $post->post_type === 'buddyforms' ) {
    18741908            $form_slug = $post->post_name;
    18751909        } elseif ( !empty($post_content) ) {
    18761910            // Extract the shortcode inside the content
    18771911            $form_slug = buddyforms_get_form_slug_from_content( $post_content );
    18781912            if ( empty($form_slug) ) {
    18791913                $form_slug = buddyforms_get_form_slug_by_post_id( $post->ID );
    18801914            }
    18811915        }
    18821916   
    18831917    } elseif ( function_exists( 'bp_current_component' ) && function_exists( 'bp_current_action' ) && function_exists( 'buddyforms_members_get_form_by_member_type' ) ) {
    18841918        global  $buddyforms_member_tabs ;
    18851919        $bp_action = bp_current_action();
    18861920        $bp_component = bp_current_component();
    18871921       
    18881922        if ( !empty($buddyforms_member_tabs) && 'xprofile' !== $bp_component ) {
    18891923            $form_slug = ( !empty($buddyforms_member_tabs[bp_current_component()][bp_current_action()]) ? $buddyforms_member_tabs[bp_current_component()][bp_current_action()] : '' );
    18901924           
    18911925            if ( $form_slug . '-create' !== $bp_action && $form_slug . '-edit' !== $bp_action && $form_slug . '-revision' !== $bp_action ) {
    18921926                $member_type = bp_get_member_type( get_current_user_id() );
    18931927                $form_slug = buddyforms_members_get_form_by_member_type( $member_type );
    18941928                if ( !$form_slug ) {
    18951929                    $form_slug = buddyforms_members_get_form_by_member_type( 'none' );
    18961930                }
    18971931            }
    18981932       
    18991933        }
    19001934   
    19011935    }
    19021936   
    19031937    return $form_slug;
    19041938}
    19051939
    19061940/**
    19071941 * Check if the draft is enabled for the given form slug
    19081942 *
    19091943 * @param $form_slug
    19101944 * @param string    $permission
    19111945 *
    19121946 * @return bool
    19131947 * @since 2.5.14
    19141948 * @author gfirem
    19151949 */
    19161950function buddyforms_is_permission_enabled( $form_slug, $permission = 'draft' )
    19171951{
    19181952    $result = wp_cache_get( 'buddyforms_user_capability_for_' . $form_slug . '_draft', 'buddyforms' );
    19191953   
    19201954    if ( !empty($form_slug) && $result === false ) {
    19211955        /** @var WP_User $current_user */
    19221956        $current_user = wp_get_current_user();
    19231957       
    19241958        if ( empty($current_user) ) {
    19251959            $result = false;
    19261960        } else {
    19271961            $result = bf_user_can(
    19281962                $current_user->ID,
    19291963                'buddyforms_' . $form_slug . '_' . $permission,
    19301964                array(),
    19311965                $form_slug
    19321966            );
    19331967        }
    19341968       
    19351969        wp_cache_set( 'buddyforms_user_capability_for_' . $form_slug . '_draft', $result, 'buddyforms' );
    19361970    }
    19371971   
    19381972    return $result;
    19391973}
    19401974
    19411975/**
    19421976 * Get the form actions. This function is used to handle the form actions if the form have a form_action element or if not
    19431977 *
    19441978 * @param $form Form
    19451979 * @param $form_slug
    19461980 * @param $post_id
    19471981 * @param $field_options
    19481982 *
    19491983 * @return Form
    19501984 * @since 2.4.0
    19511985 */
    19521986function buddyforms_form_action_buttons(
    19531987    $form,
    19541988    $form_slug,
    19551989    $post_id,
    19561990    $field_options
    19571991)
    19581992{
    19591993    global  $buddyforms ;
    19601994    $exist_field_status = buddyforms_exist_field_type_in_form( $form_slug, 'status' );
    19611995    $is_draft_permission_enabled = buddyforms_is_permission_enabled( $form_slug );
    19621996    $is_form_element_action = !empty($field_options);
    19631997   
    19641998    if ( $is_form_element_action ) {
    19651999        $is_field_publish_enabled = empty($field_options['disabled_publish']);
    19662000        $is_edit_permission_enabled = buddyforms_is_permission_enabled( $form_slug, 'edit' );
    19672001        $is_create_permission_enabled = buddyforms_is_permission_enabled( $form_slug, 'create' );
    19682002        $is_draft_enabled = $is_draft_permission_enabled || $is_create_permission_enabled && !$is_edit_permission_enabled && $is_draft_permission_enabled;
    19692003    } else {
    19702004        $is_draft_enabled = $is_draft_permission_enabled;
    19712005        $is_field_publish_enabled = true;
    19722006    }
    19732007   
    19742008    $bfdesign = ( isset( $buddyforms[$form_slug]['layout'] ) ? $buddyforms[$form_slug]['layout'] : array() );
    19752009    $form_type = ( isset( $buddyforms[$form_slug]['form_type'] ) ? $buddyforms[$form_slug]['form_type'] : '' );
    19762010    $form_status = ( isset( $buddyforms[$form_slug]['status'] ) ? $buddyforms[$form_slug]['status'] : 'publish' );
    19772011    $button_class = ( !empty($bfdesign['button_class']) ? $bfdesign['button_class'] : '' );
    19782012    $include_form_draft_button = apply_filters(
    19792013        'buddyforms_include_form_draft_button',
    19802014        true,
    19812015        $form_slug,
    19822016        $form,
    19832017        $post_id
    19842018    );
    19852019    if ( $is_draft_enabled && $include_form_draft_button ) {
    19862020       
    19872021        if ( !$exist_field_status && $form_type === 'post' && is_user_logged_in() ) {
    19882022            $bf_draft_button_text = ( !empty($bfdesign['draft_text']) ? $bfdesign['draft_text'] : apply_filters( 'buddyforms_draft_button_text', __( 'Save as draft', 'buddyforms' ), $form_slug ) );
    19892023            $bf_draft_button_classes = 'bf-draft ' . $button_class;
    19902024            $bf_draft_button = new Element_Button( $bf_draft_button_text, 'submit', array(
    19912025                'id'             => $form_slug . '-draft',
    19922026                'class'          => $bf_draft_button_classes,
    19932027                'name'           => 'draft',
    19942028                'formnovalidate' => 'formnovalidate',
    19952029                'data-target'    => $form_slug,
    19962030                'data-status'    => 'draft',
    19972031            ) );
    19982032            if ( $bf_draft_button ) {
    19992033                $form->addElement( $bf_draft_button );
    20002034            }
    20012035        }
    20022036   
    20032037    }
    20042038    $include_form_submit_button = apply_filters(
    20052039        'buddyforms_include_form_submit_button',
    20062040        true,
    20072041        $form_slug,
    20082042        $form,
    20092043        $post_id
    20102044    );
    20112045   
    20122046    if ( $is_field_publish_enabled && $include_form_submit_button ) {
    20132047        $bf_publish_button_classes = 'bf-submit ' . $button_class;
    20142048       
    20152049        if ( !empty($form_type) && $form_type === 'post' && !$exist_field_status ) {
    20162050            $bf_button_text = ( !empty($bfdesign['submit_text']) ? $bfdesign['submit_text'] : __( 'Publish', 'buddyforms' ) );
    20172051        } else {
    20182052            $bf_button_text = ( !empty($bfdesign['submit_text']) ? $bfdesign['submit_text'] : __( 'Submit', 'buddyforms' ) );
    20192053        }
    20202054       
    20212055        $bf_submit_button = new Element_Button( $bf_button_text, 'submit', array(
    20222056            'id'          => $form_slug,
    20232057            'class'       => $bf_publish_button_classes,
    20242058            'name'        => 'submitted',
    20252059            'data-target' => $form_slug,
    20262060            'data-status' => $form_status,
    20272061        ) );
    20282062        $form->addElement( $bf_submit_button );
    20292063    }
    20302064   
    20312065    $form = apply_filters(
    20322066        'buddyforms_create_edit_form_button',
    20332067        $form,
    20342068        $form_slug,
    20352069        $post_id
    20362070    );
    20372071    return $form;
    20382072}
    20392073
    20402074if ( !function_exists( 'buddyforms_show_error_messages' ) ) {
    20412075    // displays error messages from form submissions
    20422076    function buddyforms_show_error_messages()
    20432077    {
    20442078        $global_error = ErrorHandler::get_instance();
    20452079        $global_bf_error = $global_error->get_global_error();
    20462080        if ( !empty($global_bf_error) ) {
    20472081           
    20482082            if ( $global_bf_error->has_errors() ) {
    20492083                echo  '<div class="bf-alert error">' ;
    20502084                /**
    20512085                 * @var string|int $code
    20522086                 * @var  BuddyForms_Error|WP_Error $error
    20532087                 */
    20542088                foreach ( $global_error->get_global_error()->errors as $code => $error ) {
    20552089                    $message = $global_error->get_global_error()->get_error_message( $code );
    20562090                    if ( is_array( $message ) ) {
    20572091                        $message = $message[0];
    20582092                    }
    20592093                    echo  '<span class="buddyforms_error" data-error-code="' . esc_attr( $code ) . '"><strong>' . esc_html__( 'Error', 'buddyforms' ) . '</strong>: ' . esc_html( $message ) . '</span><br/>' ;
    20602094                }
    20612095                echo  '</div>' ;
    20622096            }
    20632097       
    20642098        }
    20652099    }
    20662100
    20672101}
    20682102if ( !function_exists( 'buddyforms_reset_password_errors' ) ) {
    20692103    // used for tracking error messages
    20702104    function buddyforms_reset_password_errors()
    20712105    {
    20722106        $global_error = ErrorHandler::get_instance();
    20732107        return $global_error->get_global_error();
    20742108    }
    20752109
    20762110}
    20772111/**
    20782112 * Check whether the specified user has a given capability on a given site.
    20792113 *
    20802114 * @param int       $user_id
    20812115 * @param string    $capability Capability or role name.
    20822116 * @param string    $form_slug
    20832117 * @param array|int $args {
    20842118 *     Array of extra arguments applicable to the capability check.
    20852119 *
    20862120 * @return bool True if the user has the cap for the given parameters.
    20872121 * @since 2.5.0
    20882122 */
    20892123function bf_user_can(
    20902124    $user_id,
    20912125    $capability,
    20922126    $args = array(),
    20932127    $form_slug = ''
    20942128)
    20952129{
    20962130    if ( !empty($form_slug) ) {
    20972131        $switched = buddyforms_switch_to_form_blog( $form_slug );
    20982132    }
    20992133    $user = get_user_by( 'ID', $user_id );
    21002134    if ( !$user || !$user->exists() ) {
    21012135        return false;
    21022136    }
    21032137    $result = $user->has_cap( $capability );
    21042138    if ( !empty($switched) ) {
    21052139        restore_current_blog();
    21062140    }
    21072141    return $result;
    21082142}
    21092143
    21102144/**
    21112145 * Array of fields slug to exclude from the submission columns and email table
    21122146 *
    21132147 * since 2.5.0
    21142148 *
    21152149 * @return mixed|void
    21162150 */
    21172151function buddyforms_get_exclude_field_slugs()
    21182152{
    21192153    return apply_filters( 'buddyforms_submission_exclude_columns', array( 'user_pass', 'captcha', 'html' ) );
    21202154}
    21212155
    21222156/**
    21232157 * Sanitizes a slug for an element, replacing whitespace and a few other characters with dashes.
    21242158 *
    21252159 * @param string $slug The title to be sanitized.
    21262160 * @param string $context Optional. The operation for which the string is sanitized.
    21272161 *
    21282162 * @return string The sanitized title.
    21292163 * @since 2.5.6
    21302164 *
    21312165 * @see sanitize_title_with_dashes
    21322166 */
    21332167function buddyforms_sanitize_slug( $slug, $context = 'save' )
    21342168{
    21352169    $slug = strip_tags( $slug );
    21362170    // Preserve escaped octets.
    21372171    $slug = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $slug );
    21382172    // Remove percent signs that are not part of an octet.
    21392173    $slug = str_replace( '%', '', $slug );
    21402174    // Restore octets.
    21412175    $slug = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $slug );
    21422176    if ( seems_utf8( $slug ) ) {
    21432177        $slug = utf8_uri_encode( $slug, 200 );
    21442178    }
    21452179   
    21462180    if ( 'save' == $context ) {
    21472181        // Convert nbsp, ndash and mdash to hyphens
    21482182        $slug = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $slug );
    21492183        // Convert nbsp, ndash and mdash HTML entities to hyphens
    21502184        $slug = str_replace( array(
    21512185            '&nbsp;',
    21522186            '&#160;',
    21532187            '&ndash;',
    21542188            '&#8211;',
    21552189            '&mdash;',
    21562190            '&#8212;'
    21572191        ), '-', $slug );
    21582192        // Convert forward slash to hyphen
    21592193        $slug = str_replace( '/', '-', $slug );
    21602194        // Strip these characters entirely
    21612195        $slug = str_replace( array(
    21622196            // soft hyphens
    21632197            '%c2%ad',
    21642198            // iexcl and iquest
    21652199            '%c2%a1',
    21662200            '%c2%bf',
    21672201            // angle quotes
    21682202            '%c2%ab',
    21692203            '%c2%bb',
    21702204            '%e2%80%b9',
    21712205            '%e2%80%ba',
    21722206            // curly quotes
    21732207            '%e2%80%98',
    21742208            '%e2%80%99',
    21752209            '%e2%80%9c',
    21762210            '%e2%80%9d',
    21772211            '%e2%80%9a',
    21782212            '%e2%80%9b',
    21792213            '%e2%80%9e',
    21802214            '%e2%80%9f',
    21812215            // copy, reg, deg, hellip and trade
    21822216            '%c2%a9',
    21832217            '%c2%ae',
    21842218            '%c2%b0',
    21852219            '%e2%80%a6',
    21862220            '%e2%84%a2',
    21872221            // acute accents
    21882222            '%c2%b4',
    21892223            '%cb%8a',
    21902224            '%cc%81',
    21912225            '%cd%81',
    21922226            // grave accent, macron, caron
    21932227            '%cc%80',
    21942228            '%cc%84',
    21952229            '%cc%8c',
    21962230        ), '', $slug );
    21972231        // Convert times to x
    21982232        $slug = str_replace( '%c3%97', 'x', $slug );
    21992233    }
    22002234   
    22012235    $slug = preg_replace( '/&.+?;/', '', $slug );
    22022236    // kill entities
    22032237    $slug = str_replace( '.', '-', $slug );
    22042238    $slug = preg_replace( '/[^%a-zA-Z0-9 _-]/', '', $slug );
    22052239    $slug = preg_replace( '/\\s+/', '-', $slug );
    22062240    $slug = preg_replace( '|-+|', '-', $slug );
    22072241    $slug = trim( $slug, '-' );
    22082242    return $slug;
    22092243}
    22102244
    22112245/**
    22122246 * Override the form_slug from the loop to get the correct base on the current post
    22132247 *
    22142248 * @param $form_slug
    22152249 * @param $post_id
    22162250 *
    22172251 * @return string
    22182252 *
    22192253 * @since 2.5.17
    22202254 */
    22212255function buddyforms_contact_author_loop_form_slug( $form_slug, $post_id )
    22222256{
    22232257    if ( !empty($post_id) && function_exists( 'buddyforms_get_form_slug_by_post_id' ) ) {
    22242258        $form_slug = buddyforms_get_form_slug_by_post_id( $post_id );
    22252259    }
    22262260    return $form_slug;
    22272261}
    22282262
    22292263add_filter(
    22302264    'buddyforms_loop_form_slug',
    22312265    'buddyforms_contact_author_loop_form_slug',
    22322266    10,
    22332267    2
    22342268);
    22352269/**
    22362270 * Enqueue buddyforms thickbox wrapper
    22372271 *
    22382272 * @since 2.5.19
    22392273 */
    22402274function buddyforms_add_bf_thickbox()
    22412275{
    22422276    wp_enqueue_script( 'buddyforms-thickbox' );
    22432277    wp_enqueue_style( 'buddyforms-thickbox' );
    22442278}
    22452279
    22462280add_filter(
    22472281    'buddyforms_mail_to_before_send_notification',
    22482282    'buddyforms_process_shortcode_notificate_to_attr',
    22492283    10,
    22502284    2
    22512285);
    22522286function buddyforms_process_shortcode_notificate_to_attr( $mail_to, $notification )
    22532287{
    22542288   
    22552289    if ( isset( $_POST['notificate_to'] ) && !empty($_POST['notificate_to']) ) {
    22562290        $notificate_to = sanitize_text_field( wp_unslash( $_POST['notificate_to'] ) );
    22572291        $notificate_to = trim( preg_replace( '/\\s+/', '', $notificate_to ) );
    22582292        $notificate_to = explode( ',', $notificate_to );
    22592293        foreach ( $notificate_to as $value ) {
    22602294            $_notificate_to = explode( '-', $value );
    22612295            $mail_trigger_id = $_notificate_to[0];
    22622296            $user_email = sanitize_email( $_notificate_to[1] );
    22632297            // Check if mail_trigger_id match with current notification.
    22642298            if ( $notification['mail_trigger_id'] === $mail_trigger_id && is_email( $user_email ) ) {
    22652299                array_push( $mail_to, $user_email );
    22662300            }
    22672301        }
    22682302    }
    22692303   
    22702304    return $mail_to;
    22712305}
    22722306
    22732307function buddyforms_add_safe_css_attributes( $atts )
    22742308{
    22752309    $atts[] = 'display';
    22762310    $atts[] = 'visibility';
    22772311    return $atts;
    22782312}
    22792313
    22802314add_filter( 'safe_style_css', 'buddyforms_add_safe_css_attributes' );
    22812315function buddyforms_wp_kses_allowed_atts()
    22822316{
    22832317    $allowed_tags = array(
    22842318        'div'      => array(
    22852319        'class'           => array(),
    22862320        'id'              => array(),
    22872321        'hidefocus'       => array(),
    22882322        'tabindex'        => array(),
    22892323        'role'            => array(),
    22902324        'style'           => array(),
    22912325        'action'          => array(),
    22922326        'page'            => array(),
    22932327        'aria-labelledby' => array(),
    22942328        'aria-haspopup'   => array(),
    22952329        'aria-pressed'    => array(),
    22962330        'aria-label'      => array(),
    22972331        'aria-level'      => array(),
    22982332        'aria-controls'   => array(),
    22992333        'aria-selected'   => array(),
    23002334        'aria-expanded'   => array(),
    23012335        'data-index'      => array(),
    23022336        'data-entry'      => array(),
    23032337        'data-dz-message' => array(),
    23042338    ),
    23052339        'span'     => array(
    23062340        'class'                  => array(),
    23072341        'id'                     => array(),
    23082342        'dir'                    => array(),
    23092343        'style'                  => array(),
    23102344        'role'                   => array(),
    23112345        'aria-haspopup'          => array(),
    23122346        'aria-hidden'            => array(),
    23132347        'aria-expanded'          => array(),
    23142348        'aria-label'             => array(),
    23152349        'aria-disable'           => array(),
    23162350        'aria-labelledby'        => array(),
    23172351        'tabindex'               => array(),
    23182352        'data'                   => array(),
    23192353        'data-tip'               => array(),
    23202354        'data-dz-size'           => array(),
    23212355        'data-dz-name'           => array(),
    23222356        'data-dz-uploadprogress' => array(),
    23232357        'data-dz-errormessage'   => array(),
    23242358        'data-select2-id'        => array(),
    23252359    ),
    23262360        'strong'   => array(),
    23272361        'p'        => array(
    23282362        'class' => array(),
    23292363        'id'    => array(),
    23302364        'name'  => array(),
    23312365        'title' => array(),
    23322366    ),
    23332367        'style'    => array(),
    23342368        'form'     => array(
    23352369        'class'      => array(),
    23362370        'name'       => array(),
    23372371        'id'         => array(),
    23382372        'action'     => array(),
    23392373        'method'     => array(),
    23402374        'novalidate' => array(),
    23412375        'target'     => array(),
    23422376    ),
    23432377        'fieldset' => array(),
    23442378        'input'    => array(
    23452379        'class'                           => array(),
    23462380        'id'                              => array(),
    23472381        'name'                            => array(),
    23482382        'type'                            => array(),
    23492383        'role'                            => array(),
    23502384        'style'                           => array(),
    23512385        'step'                            => array(),
    23522386        'value'                           => array(),
    23532387        'field-id'                        => array(),
    23542388        'field_id'                        => array(),
    23552389        'required'                        => array(),
    23562390        'checked'                         => array(),
    23572391        'tabindex'                        => array(),
    23582392        'pattern'                         => array(),
    23592393        'placeholder'                     => array(),
    23602394        'autocomplete'                    => array(),
    23612395        'autocorrect'                     => array(),
    23622396        'autocapitalize'                  => array(),
    23632397        'spellcheck'                      => array(),
    23642398        'frontend_reset'                  => array(),
    23652399        'size'                            => array(),
    23662400        'aria'                            => array(),
    23672401        'aria-invalid'                    => array(),
    23682402        'data'                            => array(),
    23692403        'data-form'                       => array(),
    23702404        'data-rule-minlength'             => array(),
    23712405        'data-rule-maxlength'             => array(),
    23722406        'placeholder'                     => array(),
    23732407        'aria-autocomplete'               => array(),
    23742408        'data-rule-upload-required'       => array(),
    23752409        'data-msg-upload-required'        => array(),
    23762410        'data-rule-featured-image-error'  => array(),
    23772411        'upload_error_validation_message' => array(),
    23782412    ),
    23792413        'select'   => array(
    23802414        'class'               => array(),
    23812415        'id'                  => array(),
    23822416        'name'                => array(),
    23832417        'type'                => array(),
    23842418        'hidden'              => array(),
    23852419        'multiple'            => array(),
    23862420        'style'               => array(),
    23872421        'value'               => array(),
    23882422        'tabindex'            => array(),
    23892423        'field-id'            => array(),
    23902424        'field_id'            => array(),
    23912425        'required'            => array(),
    23922426        'aria-hidden'         => array(),
    23932427        'data-form'           => array(),
    23942428        'data-action'         => array(),
    23952429        'data-exclude'        => array(),
    23962430        'data-sortable'       => array(),
    23972431        'data-rule-minlength' => array(),
    23982432        'data-rule-maxlength' => array(),
    23992433        'data-placeholder'    => array(),
    24002434        'placeholder'         => array(),
    24012435        'data-select2-id'     => array(),
    24022436    ),
    24032437        'option'   => array(
    24042438        'class'               => array(),
    24052439        'id'                  => array(),
    24062440        'name'                => array(),
    24072441        'type'                => array(),
    24082442        'style'               => array(),
    24092443        'value'               => array(),
    24102444        'field-id'            => array(),
    24112445        'field_id'            => array(),
    24122446        'data-form'           => array(),
    24132447        'data-country'        => array(),
    24142448        'data-rule-minlength' => array(),
    24152449        'data-rule-maxlength' => array(),
    24162450        'data-unique'         => array(),
    24172451        'placeholder'         => array(),
    24182452        'selected'            => array(),
    24192453    ),
    24202454        'optgroup' => array(
    24212455        'class'    => array(),
    24222456        'id'       => array(),
    24232457        'name'     => array(),
    24242458        'label'    => array(),
    24252459        'style'    => array(),
    24262460        'value'    => array(),
    24272461        'field-id' => array(),
    24282462        'field_id' => array(),
    24292463        'selected' => array(),
    24302464    ),
    24312465        'label'    => array(
    24322466        'for'      => array(),
    24332467        'id'       => array(),
    24342468        'class'    => array(),
    24352469        'style'    => array(),
    24362470        'data'     => array(),
    24372471        'data-tip' => array(),
    24382472    ),
    24392473        'link'     => array(
    24402474        'class' => array(),
    24412475        'id'    => array(),
    24422476        'rel'   => array(),
    24432477        'href'  => array(),
    24442478        'media' => array(),
    24452479    ),
    24462480        'a'        => array(
    24472481        'class'          => array(),
    24482482        'id'             => array(),
    24492483        'style'          => array(),
    24502484        'target'         => array(),
    24512485        'href'           => array(),
    24522486        'name'           => array(),
    24532487        'title'          => array(),
    24542488        'type'           => array(),
    24552489        'tabindex'       => array(),
    24562490        'data'           => array(),
    24572491        'data-toggle'    => array(),
    24582492        'data-type'      => array(),
    24592493        'data-row'       => array(),
    24602494        'data-gdpr-type' => array(),
    24612495        'data-form-slug' => array(),
    24622496        'onclick'        => array(),
    24632497    ),
    24642498        'button'   => array(
    24652499        'class'             => array(),
    24662500        'id'                => array(),
    24672501        'type'              => array(),
    24682502        'name'              => array(),
    24692503        'disabled'          => array(),
    24702504        'data-editor'       => array(),
    24712505        'data-wp-editor-id' => array(),
    24722506        'data-target'       => array(),
    24732507        'data-status'       => array(),
    24742508        'data-template'     => array(),
    24752509        'data-type'         => array(),
    24762510        'onclick'           => array(),
    24772511        'tabindex'          => array(),
    24782512        'role'              => array(),
    24792513        'field-id'          => array(),
    24802514        'field_id'          => array(),
    24812515        'accepted_files'    => array(),
    24822516        'onclick'           => array(),
    24832517    ),
    24842518        'i'        => array(
    24852519        'class' => array(),
    24862520        'id'    => array(),
    24872521        'name'  => array(),
    24882522    ),
    24892523        'abbr'     => array(
    24902524        'class' => array(),
    24912525        'id'    => array(),
    24922526        'name'  => array(),
    24932527        'title' => array(),
    24942528    ),
    24952529        'iframe'   => array(
    24962530        'id'                => array(),
    24972531        'allowtransparency' => array(),
    24982532        'title'             => array(),
    24992533        'style'             => array(),
    25002534        'frameborder'       => array(),
    25012535    ),
    25022536        'textarea' => array(
    25032537        'id'                  => array(),
    25042538        'class'               => array(),
    25052539        'name'                => array(),
    25062540        'style'               => array(),
    25072541        'placeholder'         => array(),
    25082542        'data-form'           => array(),
    25092543        'data-rule-minlength' => array(),
    25102544        'data-rule-maxlength' => array(),
    25112545        'rows'                => array(),
    25122546        'required'            => array(),
    25132547        'autocomplete'        => array(),
    25142548        'cols'                => array(),
    25152549        'aria-hidden'         => array(),
    25162550    ),
    25172551        'img'      => array(
    25182552        'id'                => array(),
    25192553        'src'               => array(),
    25202554        'alt'               => array(),
    25212555        'data-dz-thumbnail' => array(),
    25222556    ),
    25232557        'svg'      => array(
    25242558        'width'   => array(),
    25252559        'height'  => array(),
    25262560        'alt'     => array(),
    25272561        'viewBox' => array(),
    25282562    ),
    25292563        'small'    => array(
    25302564        'class' => array(),
    25312565        'id'    => array(),
    25322566        'style' => array(),
    25332567        'name'  => array(),
    25342568    ),
    25352569        'ul'       => array(
    25362570        'class'           => array(),
    25372571        'id'              => array(),
    25382572        'style'           => array(),
    25392573        'name'            => array(),
    25402574        'role'            => array(),
    25412575        'tabindex'        => array(),
    25422576        'aria-controls'   => array(),
    25432577        'aria-labelledby' => array(),
    25442578        'aria-selected'   => array(),
    25452579        'aria-expanded'   => array(),
    25462580    ),
    25472581        'li'       => array(
    25482582        'class'           => array(),
    25492583        'id'              => array(),
    25502584        'style'           => array(),
    25512585        'name'            => array(),
    25522586        'role'            => array(),
    25532587        'tabindex'        => array(),
    25542588        'aria-controls'   => array(),
    25552589        'aria-labelledby' => array(),
    25562590        'aria-selected'   => array(),
    25572591        'aria-expanded'   => array(),
    25582592        'data-field-id'   => array(),
    25592593    ),
    25602594        'table'    => array(
    25612595        'class' => array(),
    25622596        'id'    => array(),
    25632597        'style' => array(),
    25642598        'name'  => array(),
    25652599    ),
    25662600        'tbody'    => array(
    25672601        'class' => array(),
    25682602        'id'    => array(),
    25692603        'style' => array(),
    25702604        'name'  => array(),
    25712605    ),
    25722606        'tr'       => array(
    25732607        'class' => array(),
    25742608        'id'    => array(),
    25752609        'style' => array(),
    25762610        'name'  => array(),
    25772611    ),
    25782612        'td'       => array(
    25792613        'class'    => array(),
    25802614        'id'       => array(),
    25812615        'style'    => array(),
    25822616        'name'     => array(),
    25832617        'role'     => array(),
    25842618        'tabindex' => array(),
    25852619        'colspan'  => array(),
    25862620    ),
    25872621        'thead'    => array(
    25882622        'class'    => array(),
    25892623        'id'       => array(),
    25902624        'style'    => array(),
    25912625        'name'     => array(),
    25922626        'role'     => array(),
    25932627        'tabindex' => array(),
    25942628    ),
    25952629        'th'       => array(
    25962630        'class'    => array(),
    25972631        'id'       => array(),
    25982632        'style'    => array(),
    25992633        'name'     => array(),
    26002634        'role'     => array(),
    26012635        'tabindex' => array(),
    26022636        'colspan'  => array(),
    26032637    ),
    26042638        'tfoot'    => array(
    26052639        'class'    => array(),
    26062640        'id'       => array(),
    26072641        'style'    => array(),
    26082642        'name'     => array(),
    26092643        'role'     => array(),
    26102644        'tabindex' => array(),
    26112645        'colspan'  => array(),
    26122646    ),
    26132647        'style'    => array(
    26142648        'type' => array(),
    26152649    ),
    26162650        'h1'       => array(
    26172651        'class' => array(),
    26182652        'id'    => array(),
    26192653        'style' => array(),
    26202654        'name'  => array(),
    26212655    ),
    26222656        'h2'       => array(
    26232657        'class' => array(),
    26242658        'id'    => array(),
    26252659        'style' => array(),
    26262660        'name'  => array(),
    26272661    ),
    26282662        'h3'       => array(
    26292663        'class' => array(),
    26302664        'id'    => array(),
    26312665        'style' => array(),
    26322666        'name'  => array(),
    26332667    ),
    26342668        'h4'       => array(
    26352669        'class' => array(),
    26362670        'id'    => array(),
    26372671        'style' => array(),
    26382672        'name'  => array(),
    26392673    ),
    26402674        'h5'       => array(
    26412675        'class' => array(),
    26422676        'id'    => array(),
    26432677        'style' => array(),
    26442678        'name'  => array(),
    26452679    ),
    26462680        'strong'   => array(),
    26472681        'br'       => array(),
    26482682        'b'        => array(
    26492683        'class' => array(),
    26502684        'id'    => array(),
    26512685        'style' => array(),
    26522686        'name'  => array(),
    26532687    ),
    26542688    );
    26552689    return $allowed_tags;
    26562690}
  • buddyforms/trunk/readme.txt

    r3031945 r3046092  
    11=== Post Form - Registration Form - Profile Form for User Profiles - Frontend Content Forms for User Submissions (UGC) ===
    22Contributors: svenl77, konrads, themekraft, buddyforms, shabushabu, christianwach, projectkarol, phuck22, gfirem, jnfdev, freemius
    33Tags: custom form, form builder, registration, user registration, forms
    44Requires at least: 4.0
    55Tested up to: 6.4.3
    6 Stable tag: 2.8.7
     6Stable tag: 2.8.8
    77Requires PHP: 5.3
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    1111BuddyForms is a versatile WordPress plugin that allows the creation of post forms, registration forms, profile forms, content forms, and supports file uploads.
    1212
    1313== Description ==
    1414
    1515Manage your WordPress content effortlessly with BuddyForms, a plugin that simplifies form creation and content management.
    1616
    1717###With BuddyForms, you can:
    1818
    1919####Create Post Forms
    2020BuddyForms makes creating and managing post forms simple. Build and customize your forms to meet your needs.
    2121
    2222####Generate Registration Forms
    2323Design your own registration processes with our registration form feature. It's efficient, customizable, and easy to use.
    2424
    2525####Craft Profile Forms
    2626Create profile forms tailored to your users. BuddyForms offers a robust solution for crafting and managing these forms.
    2727
    2828####Manage Content Forms
    2929Streamline your content creation process with our content forms. Handle blog posts, articles, or any other content type.
    3030
    3131####Facilitate File Uploads
    3232With BuddyForms, attaching files, images, or any other media to your forms is effortless.
    3333
    3434#####BuddyForms is a comprehensive solution for WordPress form creation and management. If you need to build post forms, registration forms, profile forms, or other content forms, BuddyForms is your go-to tool.
    3535
    3636[youtube https://www.youtube.com/watch?v=DoPLWBBlRvA]
    3737
    3838
    3939### Full Gutenberg Support
    4040
    4141#### Embed Forms
    4242Embed any BuddyForms Form as Gutenberg Block. Just select the form you like to embed in the block sidebar.
    4343
    4444#### List Submissions
    4545You can list form submissions form any form and post type. Filter post lists by author or only display posts from the logged in user. Use the options in the Block sidebar.
    4646
    4747#### Embed Navigation
    4848Link to form endpoints or user posts lists for every post form with an attached page to create and edit submissions. You can select the attached page under the "Edit Submissions" tab in the Form Builder.
    4949
    5050#### Login/ Logout Form
    5151Display a login form or a logout button if the user is logged in.
    5252
    5353
    5454### Shortcodes
    5555
    5656#### Display a Form
    5757Use this shortcode if you wanna show a form on frontend.
    5858> [bf form_slug="YOUR-FORM-SLUG"]
    5959
    6060#### Display Submissions
    6161Use this shortcode if you wanna show a list of entries belonging to a Form.
    6262The attribute "list_posts_style" is optional and its possible values are "table" or "list"
    6363> [bf_posts_list form_slug="YOUR-FORM-SLUG" list_posts_style=""]
    6464
    6565#### Link to Form
    6666This shortcode will create a link to the form for creating or editing submissions.
    6767The attribute "label" is optional (the default value is "Add New").
    6868> [bf_link_to_form form_slug="YOUR-FORM-SLUG" label=""]
    6969
    7070#### Link to User Posts
    7171For logged-in users you can use the following shortcode to display their submissions.
    7272The attribute "label" is optional (the default value is "View").
    7373> [bf_link_to_user_posts form_slug="YOUR-FORM-SLUG" label=""]
    7474
    7575#### User Posts List
    7676For logged-in users you can use the following shortcode to display a list of posts.
    7777> [bf_user_posts_list form_slug="YOUR-FORM-SLUG"]
    7878
    7979####Easily submit posts and images directly from the front end of your site.
    8080
    8181#### 1. Contact Forms
    8282* Create Custom Contact Forms for your Brand and Business in Minutes
    8383* Prevent users from submitting false data by setting custom validation rules on your forms
    8484
    8585#### 2. User Registration Forms
    8686* Overwrite and customize the WordPress Registration Form.
    8787* Redirect to a Custom Registration Page
    8888* Redirect your users to a custom location page or form if they click the activation link.
    8989* Combine Registration and Post forms and redirect your user to the Post Form after Registration.
    9090
    9191#### 2. Post Forms - Frontend submission
    9292* Let users save drafts and let them work on their edits before they send them to moderation
    9393* Define the Permission for a user role and grant create edit and delete rights
    9494* Define Moderators to manage submissions from the front end'
    9595
    9696## Deeply Tested Solutions Built with BuddyForms you can Trust and rely on.
    9797
    9898### Guest Posts Submission Management in WordPress
    9999Enable Guest Posts Submission Management with Full Moderation from the Front End for Any WordPress Site and Theme.
    100100[Guest Post Management](https://themekraft.com/wordpress-solutions/guest-posts-submission/)
    101101
    102102### Display Your Website Data Anywhere You Choose
    103103Make all information submitted through a form easily accessible from wherever you like.
    104104[Display Form Submission Data](https://themekraft.com/wordpress-solutions/display-form-data/)
    105105
    106106### Publishing Content in BuddyPress & BuddyBoss Made Easy.
    107107Enable your users to create content and bring your community to life. Easy Front-End Blogging with BuddyPress and BuddyForms!+
    108108[Posting Content in BuddyPress and BuddyBoss](https://themekraft.com/wordpress-solutions/guest-posts-submission/)
    109109
    110110#### More Supported Solutions. [BuddyForms Solutions](https://themekraft.com/solutions/buddyforms/)
    111111
    112112#### Form Builder Features
    113113* Drag and Drop Forms Builder
    114114* Form Designer to Layout your forms with options and custom css
    115115* Form Grid to sort form elements in a grid
    116116* Submission Manager. Find All Forms and there submissions in one place. Post Forms, Registration Forms and Contact Forms
    117117
    118118#### User Submitted Content
    119119* Ideal for guest posts. Let your user submit the content. User-generated content is an easy and effective way to get unique content on your site.
    120120* Frontend-generated content made possible with Endpoints and ShortCodes for easy access
    121121* All the tools you need to manage guest posts, Full frontend Moderation Controles and Frontend Post Management
    122122
    123123#### Supported Frontend Forms
    124124* Post Form
    125125* User Registration
    126126* Contact Form
    127127* Content Form for any Post Type
    128128* User profile form
    129129* Image Upload Form
    130130* Media Upload Form
    131131* File upload of any kind (restrict to specific file types) 
    132132* Mixed Custom Post Type and Registration Form
    133133* Post meta form
    134134* User meta form
    135135* Profile form for WordPress user data
    136136* Author forms for WordPress author data like Bio
    137137* Change password form
    138138* Frontend submission
    139139
    140140### Free Field Types
    141141
    142142#### Contact Fields
    143143* Subject
    144144* Message
    145145* User Fields
    146146* Username
    147147* User email
    148148* User First Name
    149149* User Last Name
    150150* Password
    151151* Website
    152152* About / Bio
    153153* Date
    154154* Captcha
    155155
    156156#### Post Fields
    157157* Title
    158158* Content
    159159* Category
    160160* Tags
    161161* Text, Textarea
    162162* Number
    163163* Dropdown, Select
    164164* Radiobutton
    165165* Checkbox
    166166
    167167#### Pro Field Types
    168168* Taxonomy
    169169* Post Formats
    170170* Comments
    171171* Post Status
    172172* Featured Image
    173173* File
    174174* Hidden
    175175* HTML
    176176* Date
    177177* More Fields available by Add-Ons!
    178178
    179179### Your Data Protection is Our Priority
    180180Buddyform is a Full GDPR compliant WordPress Form Builder.
    181181
    182182#### You get Privacy by Design
    183183With Buddyform, you are the boss of your data and we’ve made it our major priority that you store data on your own server fully WordPress-compliant.
    184184
    185185#### Easy to navigate and User-friendly interface.
    186186* Easily embed forms anywhere on your website with just shortcodes by blocks or code.
    187187* Create registration funnels and ask to create a password after clicking on the activation link.
    188188* Create forms for any kind of user-generated content.
    189189* Easily define what happens after a user submits content (display a submission message, display the page content, redirect to a specific URL)
    190190* Enable/Disable comments related to the submitted content,  Frontend Revision for users
    191191* Overwrite the WordPress default Registration Form and Page
    192192* Set up email notifications to notify admins when content is submitted and also notify users when their content gets published or changes status (published, awaiting review, draft, scheduled, privately published, deleted, editing draft, awaiting moderation).
    193193
    194194### Integrate with other Plugins
    195195* BuddyPress/ BuddyBoss – Enable all publishing features of BuddyForms in BuddyPress
    196196* Ultimate Member – Submit and manage posts from your Ultimate Member Profile
    197197* ACF - Advanced Custom Fields – Integrate Advanced Custom Fields in your forms like native BuddyForms form elements
    198198* Pods
    199199* MailPoed
    200200* WooCommerce – Build your own marketplace with user-submitted products
    201201* WooCommerce Simple Auctions – Create and manage auctions via front end
    202202* HubSpot
    203203* Geo My WP
    204204
    205205#### Search All Extensions. [BuddyForms Exdtensions](https://themekraft.com/wordpress-product/buddyforms/)
    206206
    207207### List of Forms
    208208* Contact Forms – Collect leads and customer support data
    209209* Registration Forms – Sign-up users to your webpage
    210210* Profile Forms – Let your user update their profile information.
    211211* Login Forms – Grant users access to restricted content
    212212* Post Forms for Blog Posts – Follow your editorial schedule and keep your blog up-to-date by collecting content from different authors
    213213
    214214### List of User Examples
    215215* Online Directories – Crowdsource categorized data from your community
    216216* Showcase – Present your recent work or let clients showcase their use cases built with your product or tool
    217217* News Magazines – Create single articles through collaborative writing among a team of editors
    218218* How-to’s – Gather a learning community around you, let users share their knowledge and engage discussions on your site
    219219* Marketplace – Sell and purchase products from different vendors and list all the product features
    220220* Content Forms for any kind of user-generated content, user-submitted posts
    221221
    222222> #### Follow Us
    223223> [Blog](https://themekraft.com/blog/) | [YouTube](https://www.youtube.com/themekraft)
    224224
    225225== Installation ==
    226226
    227227Upload the entire BuddyForms folder to the /wp-content/plugins/ directory or install the plugin through the WordPress plugins screen directly.
    228228Activate the plugin through the 'Plugins' menu in WordPress.
    229229Head to the 'BuddyForms' menu item in your admin sidebar
    230230
    231231== Frequently Asked Questions ==
    232232
    233233= How easy is it to create a post form using BuddyForms? =
    234234Creating a post form using BuddyForms is incredibly simple. Our intuitive user interface allows you to build and customize your post forms to meet your unique requirements.
    235235
    236236= Can I customize the fields in the registration form? =
    237237Absolutely! BuddyForms allows you to fully customize your registration form fields. You can add or remove fields as needed, ensuring a seamless registration process for your users.
    238238
    239239= Is it possible to create multiple profile forms for different user roles? =
    240240Yes, with BuddyForms, you can create profile forms tailored to different user roles. Our plugin provides a robust solution for crafting and managing multiple profile forms with ease.
    241241
    242242= What types of content forms can I create with BuddyForms? =
    243243BuddyForms is versatile and allows you to create a variety of content forms. Whether you need to handle blog posts, articles, product descriptions, or any other content types, BuddyForms has got you covered.
    244244
    245245= Can users attach files to the forms? =
    246246Yes, BuddyForms supports file uploads. Users can easily attach files, images, or any other media to their forms, making BuddyForms a comprehensive solution for your form needs.
    247247
    248248= Can I create a normal Contact Form =
    249249Yes, you can create Simple Contact Forms or Complex Contact Forms with different custom fields
    250250
    251251= Can I Combine Registration Forms and Content Forms =
    252252Yes, you can add login and registration Form Elements to any form and ask your user to log in or Register during form submission.
    253253
    254254== Documentation & Support ==
    255255Documentation: [docs.buddyforms.com](http://docs.buddyforms.com/)
    256256
    257257If you still get stuck somewhere, our support gets you back on the right track. You can find all help buttons in your BuddyForms Settings Panel in your WP Dashboard and the Help Center! Our goal is to help you, that's why if you have any questions or concerns, on our website you can find all the information related to BuddyForms.
    258258
    259259== Screenshots ==
    260260
    2612611. Embed Forms - The easy way to embed forms
    2622622. List Submissions - Display the user Submissions
    2632633. Embed Navigation -  Link to forms and Submissions
    2642644. Login/ Logout Form - Add Loggin Forms and define a custom redirect after login
    265265
    266266== Changelog ==
     267= 2.8.8 - 06 Mar 2024 =
     268* Improved security.
     269* Fixed issue with creation of pages from submissions setup tab.
     270
    267271= 2.8.7 - 06 Feb 2024 =
    268272* Added new hook to filter custom field value.
    269273* Tested up to WordPress 6.4.3
    270274
    271275= 2.8.6 - 18 Jan 2024 =
    272276* Fixed XSS issue.
    273277* Fixed arbitrary file download issue.
    274278* Fixed issue related with filter submissions by author.
    275279* Updated Freemius SDK.
    276280* Tested up to WordPress 6.4.2
    277281
    278282= 2.8.5 - 21 Nov 2023 =
    279283* Fixed issue with some file format.
    280284
    281285= 2.8.4 - 16 Nov 2023 =
    282286* Updated Freemius SDK.
    283287* Tested up to WordPress 6.4.1
    284288
    285289= 2.8.3 - 05 Jul 2023 =
    286290* Fixed XSS vulnerability.
    287291* Fixed issue with an upload field and allowed formats.
    288292* Fixed issue with string max length validation.
    289293* Tested up to WordPress 6.2.2
    290294
    291295= 2.8.2 - 11 May 2023 =
    292296* Fixed vulnerability issue in shortcode.
    293297
    294298= 2.8.1 - 04 May 2023 =
    295299* Added a new hook to filter form html content.
    296300* Updated Freemius SDK.
    297301* Tested up to WordPress 6.2
    298302
    299303= 2.8.0 - 22 Mar 2023 =
    300304* Added a new option to the Form Builder Edit Submission Settings to dynamically define the output from BuddyForms
    301305
    302306= 2.7.9 - 17 Mar 2023 =
    303307* Improved phar file verification (issue found by Jesús Miguel Calderón).
    304308* Fixed issue with new user activation link.
    305309
    306310= 2.7.8 - 11 Jan 2023 =
    307311* Fixed vulnerability with image uploaded from URL.
    308312* Fixed issue with swapped classes in menu items.
    309313
    310314= 2.7.7 - 23 Dec 2022 =
    311315* Removed rating admin notice.
    312316* Removed license activation screen from the free version.
    313317* Fixed issue with non-existent script.
    314318* Added missing form element attributes.
    315319
    316320= 2.7.6 - 16 Dec 2022 =
    317321* Fixed issue with post content field value.
    318322* Fixed issue with text area field value after submission.
    319323* Updated duration of the trial version.
    320324* Improved Go Pro screen.
    321325* Updated Freemius SDK.
    322326
    323327= 2.7.5 - 9 Dec 2022 =
    324328* Correcting the price of BuddyForms plans in Go Pro screen.
    325329* Added 5 site license options in the BuddyForms bundle.
    326330* Correcting misspelt element description in setup meta box.
    327331
    328332= 2.7.4 - 8 Dec 2022 =
    329333* Fixed issue with Custom Login extension.
    330334* Added new pricing screen.
    331335* Updated Freemius SDK.
    332336* Tested up with WordPress 6.1.1
    333337
    334338= 2.7.3 - 18 Nov 2022 =
    335339* Fixed issue with field validation.
    336340* Improved forms security.
    337341* Tested up with WordPress 6.1
    338342
    339343= 2.7.2 - 08 Sep 2022 =
    340344* Improved integration with ACF extension.
    341345* Tested up to WordPress 6.0.2
    342346
    343347= 2.7.1 - 29 Aug 2022 =
    344348* Added automatic activation when using a bundle license.
    345349* Updated bundled link and popup text.
    346350
    347351= 2.7.0 - 19 Jul 2022 =
    348352* Fixed issue with field validation.
    349353
    350354= 2.6.15 - 19 Jul 2022 =
    351355* Fixed issue with global JS.
    352356
    353357= 2.6.14 - 19 Jul 2022 =
    354358* Fixed issue with form render.
    355359
    356360= 2.6.13 - 16 Jul 2022 =
    357361* Fixed issue with the required attribute.
    358362* Fixed issue with email notification table.
    359363
    360364= 2.6.12 - 13 Jul 2022 =
    361365* Fixed issue with reCaptcha validation.
    362366* Fixed issue with email field validation.
    363367* Tested up to WordPress 6.0.1
    364368
    365369= 2.6.11 - 06 Jul 2022 =
    366370* Fixed issue with Post type selection.
    367371* Fixed issue with form field values.
    368372
    369373= 2.6.10 - 26 Jun 2022 =
    370374* Fixed vulnerability issue.
    371375
    372376= 2.6.9 - 22 Jun 2022 =
    373377* Fixed security issue.
    374378
    375379= 2.6.8 - 8 Jun 2022 =
    376380* Fixed vulnerability issue.
    377381
    378382= 2.6.7 - 31 May 2022 =
    379383* Fixed vulnerability issue.
    380384
    381385= 2.6.6 - 26 May 2022 =
    382386* Fixed issue with jQuery call.
    383387* Fixed issue with remote assets call.
    384388
    385389= 2.6.5 - 26 May 2022 =
    386390* Fixed security issues.
    387391* Tested up to WordPress 6.0
    388392
    389393= 2.6.4 - 17 May 2022 =
    390394* Fixed issue with phone field validation.
    391395* Changed format of form error message.
    392396* Updated readme.txt
    393397
    394398= 2.6.3 - 16 Mar 2022 =
    395399* Fixed security issue.
    396400* Improved handling of JS variables.
    397401
    398402= 2.6.2 - 11 Mar 2022 =
    399403* Fixed issue with JS variable conflict.
    400404* Fixed issue with forms permalinks.
    401405
    402406= 2.6.1 - 24 Feb 2022 =
    403407* Changed the position of the descriptive video in the readme.txt
    404408
    405409= 2.6.0 - 23 Feb 2022 =
    406410* Disabled affiliate program notices.
    407411* Fixed issue with taxonomies field type.
    408412* Added new welcome screen.
    409413* Tested up to WordPress 5.9
    410414
    411415= 2.5.32 - 2 Dec 2021 =
    412416* Added new hook for improve forms render in frontend.
    413417* Updated readme.txt
    414418
    415419= 2.5.31 - 10 Jul 2021 =
    416420* Tested up to WordPress 5.8
    417421* Fixed issue with Beta Program, now betas should be showing if the user enable the Beta Program.
    418422* Upated Freemius SDK.
    419423* Added hook to filter permalink on both the_loop and the_table templates.
    420424* Added redirect URL fallback if any URL is provided.
    421425* Added filter (hook) to customize the "Save as draft" button text.
    422426* Fixed issue with "Allow multiple file upload" option on the File field.
    423427* Added new filter (hook) to customize buddyforms login form settings.
    424428* Remove passive feedback.
    425429* Fixed CSS glitch on the Form Builder.
    426430* Added method to dequeue conflictive assets from third-party plugins.
    427431* Added paged attribute on the shortcode buddyforms_the_loop to allow set current page on the pagination.
    428432* Added two new filters (hooks) to the links pagination on post list.
    429433* Fixed compatibility issue on the Uplaod field with mp3, zip, and rar file types.
    430434* Fixed conflict with WPBakery on the Post Edit View at Admin.
    431435* Added getValues method on the Form class to get element's values more easily.
    432436* Improvements on the Price field to allow price without thousands separator.
    433437* Added feature to allow users send notification via shortcode attribute.
    434438* Improvements on the Price field to allow price without prefix.
    435439* Added new hook "buddyforms_create_edit_form_add_element" to add or edit form fields on the Frontend.
    436440* Added JavaScript Hook before and after the garlic init.
    437441
    438442= 2.5.30 - 17 May 2021 =
    439443* Fixed/improvement the UI on Checkbox & Radios inputs on the Front-end view of forms.
    440444* Fixed misleading error message shown on the Category Field in the Form Builder.
    441445* Fixed issue related with placeholder on select2 fields for Safari 13.x (<=).
    442446* Improved function to output HTML for Upload and File fields, this improvement its used by BF Hook Fields.
    443447* Fixed jQuery Validation on select2 fields to avoid trigger other fields validation.
    444448* Fixed compatibilty issue witn WP 5.7 related with Gutenberg Blocks.
    445449* Added Time & Date Format to the schedule option of the post_status field.
    446450* Removed the “Add this field to Metabox” option for  the user fields.
    447451* Fixed to validate mime type when upload image from url is checked.
    448452* Added the notification feature to the registration forms.
    449453* Improvements to show login errors on login forms.
    450454* Remove unused Composer dependencies.
    451455* improvement on the UI for standard form fields at Front-end.
    452456* Fixed conflict with ACF metabox on the Form Builder.
    453457
    454458= 2.5.29 - 19 Feb 2021 =
    455459* Fixed issue related with wrong server-side validation messages.
    456460* Fixed issue related to Content columns on submission list table (Submission Page). Some Content columns with HTML inside were breaking the layout of the table.
    457461* Improvement/fix the Author selector on the Submissions list page.
    458462* Fixed for the Password Reset shortcode. The password validation inside was broken!.
    459463* Fixed conflict between user website and custom fields with a slug set to "website".
    460464* Deprecated buddyforms_avoid_user_fields_in_forms in favor of buddyforms_avoid_user_fields_slugs_in_forms.
    461465* Fixed issue related with overridden post on public submissions.
    462466* Changed version of select2 library to his latest.
    463467* Fixed issue related to Taxonomies fields, on the first submission (on the post creation) their values were not being saved.
    464468* Fixed issue related to the values of Checkbox fields when they're shown on the metabox that's on the admin user edit screen.
    465469* Fixed issue on the fr_FR language file to avoid warnings on BuddyForms admin pages like eg Form Builder.
    466470* Fixed visual issue related with Taxonomies fields on the Admin Form Builder page.
    467471* Changed in notification system to allow global shortcodes as [site_name], [user_login], [published_post_link_html] to be used in fields like Subject, Email and Name.
    468472
    469473= 2.5.28 - 18 Dec 2020 =
    470474* Fixed issue related to PHP code in the HTML of template files.
    471475* Fixed issue related with Featured Image and Dropzone library.
    472476
    473477= 2.5.27 - 17 Dec 2020 =
    474478* Add a default page for submissions after enable the plugin.
    475479* Add labels to the default pages of BuddyForms to improve the user experience.
    476480* Fixed JS issue related to the feature image and upload form element not working properly.
    477481* Added Passive Feedback.
    478482
    479483= 2.5.26 - 7 Dec 2020 =
    480484* Fixed duplicate Singular Name option on the Form Builder.
    481485* Fixed the Race Condition issue on Composer dependencies, now all the namespaces in our Composer dependencies are prefixed.
    482486* Add Portuguese translations with .mo and .po files provided by a customer.
    483487* Fixed the URL validation for required and non required Website field.
    484488* Fixed Website field getting value from WordPress cache and not database.
    485489* Fixed a CCS-issue by adding clearfix class on the form parent container to avoid containers without height.
    486490* Changed the redirection to the Form Wizard after enabling the plugin, now it will redirect to the Form Builder.
    487491* Removed several files and references related to the Form Wizard in the code, as a part of the progressive Form Wizard extinction.
    488492* Added localize strings (translatable strings) to the Suggestions and Warnings displayed on the Password field at the Front-end.
    489493* Updated the fields output.
    490494* Fixed default data for the users fields.
    491495* Removed the add template button from the metabox.
    492496* Fixed issue related to creation permission. Users without creation permission can't create entries.
    493497* Added border and hover style on the Form Builder options.
    494498* Fixed tabs style on the Form Builder.
    495499* Updated the "Add a Form" process, it was improved to show first the template list.
    496500* Removed the stripe for the options on the Form Builder.
    497501* Added border to all tables and tabs outline.
    498502
    499503= 2.5.25 - 18 Nov 2020 =
    500504* Fixed to show custom login links only for buddyforms.
    501505* Fixed a bug in forms using Elementor.
    502506* Improved compatibility issues with the Divi theme.
    503507* Improved Buddyforms Form Builder compatibility with TinyMCE plugins on admin Buddyforms pages.
    504508* Added a new Submission by author filter.
    505509* Fixed the visual issue with time picker (date form field).
    506510* Fixed to Prevent Firefox from maintaining previously selected items to ensure all selected items get showing.
    507511* Fixed the Invalid name attribute in post_excerpt when is a hidden field.
    508512* Fixed the Invalid "for" attribute (label) in post_excerpt when the labels are shown.
    509513* Fixed the GDPR Field Templates not loading when the plugin  is activated.
    510514* Fixed the validation for the global variable before using it to replace the args variable.
    511515* Fixed the Nested ternary expressions (without parentheses) deprecated in PHP 7.4.
    512516* Fixed the Add min attribute to avoid negative values in Taxonomy Limit Selections.
    513517* Fixed the add template text to the GDPR when missing. 5208cb1c    DESKTOP-5SDFPDV\marin <marin250189@gmail.com>   Oct 13, 2020 at 1:04 AM
    514518* Fixed the Description font style.
    515519* Fixed notice in the post view when there are posts created from the admin and the options "List all Author Posts of the Post Type" and "List Style Table" are enabled.
    516520* Fixed to replace deprecated jQuery method "live"  by "on".
    517521* Fixed for the Submitted form override the slug in other forms when submitted on a page with several forms.
    518522* Fixed previous entry is overridden by the next one when submitted entries from several forms by-one-by on the same page.
    519523* Fixed to improve the Disable CSS for description option to disabled all the style-related with description if is enabled.
    520524* Fixed adding spacing on "form-type" meta-box.
    521525* Fixed issues in the query that gets the last auto-draft associate with the author and form.
    522526* Fixed to set full-width button on mobile only
    523527* Added to hidden fields new name option.
    524528* Fixed issue related with multi-form per page use case.
    525529* Added a new filter to catch postmeta before get saved on the form builder page submission.
    526530* Added a user satisfaction wizard to understand more the user and improve the product.
    527531* Updated Freemius library.
    528532
    529533= 2.5.22 - 14 Sept 2020 =
    530534* Fix a code in a wrong position for the BF settings header.
    531535
    532536= 2.5.21 - 30 Jul 2020 =
    533537* Fixed styles issue for the entries table.
    534538* Improved the bf-thickbox library.
    535539* Improve compatibility with PHP 7.4.
    536540* Fixed a typo code in the Bcc and Cc email headers.
    537541* Fixed to add "_bf_registration_user_id" post_meta before the buddyforms_update_post_meta hook.
    538542* Fixed in scroll validation.
    539543* Fixed validation in wp-editor (content) field.
    540544* Fixed Avoid themes hiding .bf_alert messages with less specific CSS rules.
    541545* Fixed Captcha V3 submission when ajax is not activated.
    542546* Fixed the case of empty field on the phone validation process.
    543547* Fixed when in a Custom row the sum of the width of all the fields in the row is greater than 100 the bf-start-row was not added and a js error was happening.
    544548* Improved the way localized strings are used in JS.
    545549* Fixed the tabs css class Incompatibility issue with third party plugins.
    546550* Fixed attributes assignation to hidden elements.
    547551* Added option to disabled select2 option for the dropdown.
    548552* Fixed for the custom classes wasn't showing on the Upload field.
    549553* Fixed description size style.
    550554* Fixed font-size description.
    551555* Fixed password validation issue on page with multiples forms.
    552556* Fixed issue related to required fields validation on the Wizard.
    553557* Fixed to Autofill empty slugs and avoid duplicate ones on the Wizard.
    554558
    555559= 2.5.20 - 9 Jun 2020 =
    556560* Fixed the header actions in the list of forms.
    557561* Fixed boostrap compatibility issue form-control class.
    558562* Fixed the ellipsis function to force to break the strings.
    559563* Improved Upload form element compatibility.
    560564* Fixed the hardcoded blank option on the dropdown and added a new settings to make it optional.
    561565* Improved the form styles.
    562566* Added compatibility with Divi.
    563567* Updating freemius.
    564568* Fixed style in dropdown.
    565569* Fixed the Category when it suppose to be hidden.
    566570* Fixed the conditional logic for the Form Builder to show the extra field group.
    567571* Improved compatibility for PHP 7.4.
    568572
    569573= 2.5.19 - 17 May 2020 =
    570574* Fixed the issue related to the lost of osme core styles when the form builder was loaded.
    571575* Fixed validation message show in the direct input form builder wizzard.
    572576* Fixed the min and max lenght validation message not showing for the message field.
    573577* Fixed the add the valid phone number validation.  Client and Server side validation.
    574578* Fixed the field slug missing for some Form Elements.
    575579* Fixed tje check All option on the permissions tab.
    576580* Fixed the CheckAll option to not check the disabled columns.
    577581* Updated the last version of jquery validation.
    578582* Fixed the override of the required method of jQuery validate to not lose the other methods.
    579583* Added form element output for all user form elements.
    580584* Fixed the Category assign for creating post with user form elements.
    581585* Formatting the code for the Phone Validation.
    582586* Fixed the issue related to the Form Element category not create categories when the entry is created.
    583587* Added form element output for all user form elements.
    584588* Moved the option `Enable Login on the form` to the Form submission tab inside the Form Setup metabox.
    585589* Fixed disable all the grid columns and rows on the permission tab when the free version is installed.
    586590* Fixed the captcha label.
    587591* Fixed the assign user to a post when the user is created during post submission.
    588592* Fixed the empty option for the DropDowns form Elements.
    589593* Improved the password hints.
    590594* Fixed the password strength score.
    591595* Added 2 hooks to avoid send user email activation to letting the use-case of manual activation form the user administration.
    592596* Fixed the multiple form submission trigger.
    593597* Fixed marketing wrong message.
    594598* Fixed the reCaptcha v3.
    595599* Fixed user form element to be included as hidden when they are setup to be hidden for logged in users.
    596600* Added a hook filter to force the html output of the form element metas.
    597601* Improved the styles for Dropdowns.
    598602* Fixed media buttons notice.
    599603* Fixed description position option for tag element.
    600604* Added own implementation of thickbox.
    601605* Fixed the user website field validation when not was correct.
    602606* Added a filter to let 3rd party extension change the form submission message.
    603607* Added a filter to let 3rd party extension change the submission link shortcode url.
    604608* Improved the styles of the dropdown and select2 form elements.
    605609* Added a new user Form Element to handle the user display option. Thanks to a contribution from Marco Massari Calderone marco@marcomc.com
    606610* Improved the email notification to let 3rd party extension to extend the email templates.
    607611* Fixed the form validation for not logged in user.
    608612* Fixed the style issue in the form builder.
    609613
    610614= 2.5.18 - 23 March 2020 =
    611615* Fixed the permission tab style for the wizard.
    612616* Removed deprecated option label button from the featured image field.
    613617* Added composer instructions to the readme for the case somebody use the plugin from the repository.
    614618* Updated the readme tags.
    615619* Improved the function to get all pages excluding the pages from global settings.
    616620* Improved the shortcodes processing from a string and they now are able to process shortcode attributes.
    617621* Moved the field Country and State Form Element to the Extra section.
    618622* Updated the user related fields to include the option to be hide for logged in users.
    619623* Added styles for disabled inputs.
    620624* Added a restriction to the user_login Form Element due to a WordPress restriction updating the username.
    621625* Fixed the password strength option.
    622626
    623627= 2.5.17 - 17 March 2020 =
    624628* Fixed the duplicate labels for the Category, Tag and Taxonomy form element.
    625629* Fixed the template system to show the parent page and not duplicate the content.
    626630* Added a reste option for the marketing popups.
    627631* Added a marketing popup to show an offer to free and trial clients.
    628632* Added the localization files.
    629633* Added compatibility with reCaptcha.
    630634* Fixed the global dashboard to get the correct form-slug from the current entry.
    631635* Fixed the Gutenberg navigation to use the correct labels.
    632636* Improved the Gutenberg block to show submission filter by current user.
    633637* Fixed the default page for manage the submission to keep selected when the user select a template.
    634638* Fixed the Gutenberg block to publish a form.
    635639
    636640= 2.5.16 - 6 March 2020 =
    637641* Fixed the string localization for the Feature Image and Upload Form Element.
    638642* Improved the compatibility with LOCO translate.
    639643* Fixed the encoding for the email notifications to make it compatible with hebrew.
    640644* Fixed the min/max validation JS messages.
    641645* Fixed the After Submission option to show a page content in the correct way.
    642646
    643647= 2.5.15 - 5 March 2020 =
    644648* Fixed the Test email Notification empty body for the Change Status email notifications.
    645649* Fixed the page submission with content.
    646650* Fixed the server validation for the Content Form element.
    647651* Fixed the server validation for the Taxonomy, Category and Tags Form element.
    648652* Fixed the styles for the Dropdown, Taxonomy, Category and Tags Form element.
    649653* Fixed add the mp3/audio file type to the Upload field.
    650654* Added the Affiliation menu option to bring new ambassadors for BuddyForms.
    651655* Fixed the JS error for invalid date when the field was not required and it not have value.
    652656* Fixed the registration form error messages.
    653657* Fixed the missing Date assets for the Schedule Status Form Element.
    654658* Fixed the double label for the Post Excerpt and Textarea Form Elements.
    655659* Improve compatibility with SendGrid email provider.
    656660* Fixed the Link Form Element.
    657661* Fixed the select2 to use the full version.
    658662* Fixed the dropdown and autocomplete Form Element to show correctly in the popups.
    659663* Fixed the template system, it was not detecting well when the site had another language.
    660664* Fixed the error placement for the Content Form Element.
    661665* Code improvement.
    662666* Added a new parameter `$customfield` with the field options to the hook filter `buddyforms_form_element_add_field`.
    663667* Fixed the default value of the email notification option mail to, by default is the admin option.
    664668* Added a new parameter `$form_slug` to the hook action `buddyforms_update_post_meta`.
    665669* Fixed the error placement for the requirement form elements.
    666670* Removed the recently added styles for the dropdown and select2 form Elements.
    667671* Fixed the language loader.
    668672* Updated the Spanish language.
    669673* Fixed styles for files types in the upload form element.
    670674* Fixed a nonce issue.
    671675* Fixed the style of the HTML form element.
    672676* Fixed the issue related to the registration page selected in the Setting.
    673677* Fixed the styles of the input override by BuddyPress.
    674678
    675679= 2.5.14 - 11 Feb 2020 =
    676680* Fixed the mail notification functionality.
    677681* Fixed the login redirection to return to the same form after login over a form.
    678682* Improved the permission table.
    679683* Fixed notice error.
    680684* Improved the post_excerpt to show the ellipsis ... when the content is visualized.
    681685* Fixed the Date Form Element error for invalid format when a time was included in the element.
    682686* Fixed the style of the circle in the list of post in the frontend.
    683687* Fixed the permissions for draft, create and edit.
    684688* Fixed the state of the permission when they get changed.
    685689* Removed the option to enabled the draft, now is direct from the permission.
    686690* Removed the draft option from the Form Action element.
    687691* Improved the Form Action options to show the button by default and the options only disabled them.
    688692* Added a popup modal to the Add-ons page to direct the user to the TK Bundle offer.
    689693* Fixed the option After Form submission, it was not removing the draft button on specific permission use case.
    690694* Fixed the draft permission.
    691695* Fixed the Label on the Range element and to remove the validation tab from the Range Field.
    692696* Improved the compatibility with gutenberg and the Form Element option to show as a metabox when the Post is edited.
    693697
    694698
    695699
    696700= 2.5.13 - 28 Jan 2020 =
    697701* Fixed the dependency error from a BuddyPress function `bp_get_signup_slug`.
    698702* Moved the Form submit JS action to the same form onsubmit where the form is render to give more priority.
    699703* Fixed the required validation for the Post Excerpt Form Element.
    700704* Removed the Error box above the form when the error are process by the server. Now they will appear in each Form Element using the same error placement from JS.
    701705* Fixed the permission change when the form switch from Contact to Post Form type for the free version.
    702706* Fixed the Registration Settings functionality.
    703707* Fixed for the email shortcode insert helper.
    704708* Fixed the textarea validation.
    705709* Fixed the issue related to the taxonomy field not letting create or search for a tag.
    706710
    707711= 2.5.12 - 18 Jan 2020 =
    708712* Fixed the message for the required gdpr form element.
    709713* Added a $form_slug parameter to hook filter where the form elements are added to JS.
    710714* Fixed an issue related with the shortcode to output the form and a hide element echo out of the context.
    711715* Fixed the auto-generate content option for the textarea form element.
    712716* Added a helper class to handled mail utf8 encoding.
    713717* Added a test option to try the Form Notifications.
    714718* Added a hook filter (`buddyforms_test_email`) to change the test email receiver.
    715719* Added a hook to change the Redirect.. string after a form is submit with ajax.
    716720* Fixed the auto generate option for the form elements post excerpt, post title, textarea and post content.
    717721* Fixed the styles for the date form element * Improved the date format validation for the date form element.
    718722* Added invalid format error message option to the Date Form Element.
    719723
    720724= 2.5.11 - 18 Jan 2020 =
    721725* Fixed the validation issue when the form not have any invalid fields.
    722726* Added a hook to extend the form classes.
    723727
    724728= 2.5.10 - 18 Jan 2020 =
    725729* Added the shortcode helper for the submission notification.
    726730* Shortcode helper now is compatible with tinymce.
    727731* Added filters to tweak the email headers, `buddyforms_email_headers_priority`,`buddyforms_email_headers_mime_version`, `buddyforms_email_headers_content_type` and `buddyforms_email_headers_content_transfer_encoding`.
    728732* Added a filter to extend the email body `buddyforms_email_body`.
    729733* Improved the UTF-8 encoding of the email body.
    730734* Fixed the email option to let the user send only email to custom.
    731735* Added error messages for invalid email, min/max value and length. Now is possible to translate this messages from the field options.
    732736* Improved the styles for the dropdown and the select related form elements.
    733737* Fixed the functionality to schedule post. Thanks to @Azila92 to report it.
    734738* Fixed the Contact form is not applying the permission new logic when the form is loaded the first time.
    735739* Added the option to upload images from URL inside the Upload form element.
    736740* Fixed the form templates, now they are loaded from a new website.
    737741* Improved the templates system and connected to a new services.
    738742* Fixed the notice in the chrome console about field with the same id.
    739743* Fixed the duplicate label for the textarea elements.
    740744* Added a JS hook to let 3rd party Addons handle the form submission like BuddyForms ACF.
    741745* Improved the bf login form to include the form slug related.
    742746* Improved the redirect after login to execute by 3rd party extensions when the form is not a registration form.
    743747* Fixed the redirection of the bf login when a form is for logged user only, in this case will be redirect to the same form page.
    744748* Added a function to output a list of pages with his child included.
    745749* Added styles for the login block.
    746750* Fixed the border of the form.
    747751* Improved the nonce function to generate nonce for logged out users.
    748752* Updated form element styles to have a minimum height.
    749753* Fixed the textarea to include the description.
    750754* Started the process to add a helper section at the bottom of the places where the shortcodes of the form elements can be used to be replaced by the values. Like the email notifications.
    751755* Fixed the user related field to be saved form any form and load the related user meta if the user is logged in.
    752756* Added a filter hook (`buddyforms_element_attribute`) to customize the form elements before render it.
    753757* Added a Date format validation.
    754758* Avoided collision of the date element style with other plugins with jquery-ui.
    755759* Added the create date of the license to the inbound marketing process.
    756760* Refactored the class BF_Error to BuddyForms_Error to avoid class collision.
    757761* Fixed issue in the State element not including the correct field value.
    758762* Added form_slug parameter to internal hook to include assets from extensions.
    759763* Code improved to avoid the issue with BF_Error class.
    760764* Start the inbound marketing development process.
    761765* Added a hook to extend form output templates from 3rd party addons.
    762766* Fixed bug related to the shortcode and the way to override the output template.
    763767* Added the ellipsis to the title and content form elements output in the submissions and frontend table, to avoid break the views when the content is too big.
    764768* Fixed the issue of the form element loading the values when the form was in create mode.
    765769
    766770= 2.5.9 - 14 Dec 2019 =
    767771* Fixed the global style to include before the error messages.
    768772* Fixed to show the user defined error message for the GDPR field.
    769773* Fixed the permission for the Entries list action button now the hooks are compatible with the uses in other addons and the core plugin.
    770774* Hooks changes `buddyforms_user_can_edit`, `buddyforms_user_can_all` and `buddyforms_user_can_delete` using the next params, 1st boolean if the user can edit, 2nd the form slug and 3er the post id.
    771775* Updated the function `buddyforms_get_form_slug_by_post_id` to get the correct form_slug base on the global default form base on the post type.
    772776* New shortcode to count how may time a field appear with value in the post-meta table. `[bf_meta_key_count slug="user_first" form-slug="test-contact-form-with-user-at-the-same-time"]`
    773777* Improved compatibility with the last version of BuddyPress.
    774778* Updated the way to show PRO fields to the Free plan users.
    775779* Added the permission tab for the contact form.
    776780* Enabled the Contact form to use the permission `all submission` for specific roles. So the user can check the entries from different users.
    777781* Removed the create account option for the template basic post field.
    778782* Fixed the textarea style for the form designer.
    779783* Improved compatibility with WP 5.3.
    780784* Updated the code to check the user permission.
    781785* Updated the form field element option name by label.
    782786* Fixed the Bio field to include the required signal and the description, also to make the correct validation.
    783787* Improved compatibility with Elementor.
    784788* Added a $wp_query var to get the form slug in 3rd party addons.
    785789* Fixed the permission to let other user roles to edit others users post.
    786790* Fixed the missing CSS file for the gpdr element.
    787791* Added new hook buddyforms_the_loop_after_actions to the table.
    788792* Added a new filter buddyforms_shortcode_the_loop_post_status.
    789793* Fixed an issue in the Gutenberg blocks for the post listings.
    790794* Update Freemius to 2.3.1.
    791795* Removed the dependency of the templates from the demo site.
    792796* Improved the GDPR form element.
    793797* Improved the conversion to UTF8 and the subject UTF8 conversion.
    794798* Improved the string to be ready for localizations.
    795799* Fixed the email sending for the anonymous user. The default notification setup include `From Email` as submitter and this value is only available if the user is logged in, now when is send by a user not logged the notification will use the admin email form the wp config.
    796800* Improved the email notification header to be more compatible with 3rd party systems like SendGrid.
    797801* Added a hook to modify the emails header before pass to wp_mail.
    798802* Improved the textarea element code and validation.
    799803* Added a function inside the date element to check if the date is valid in certain format.
    800804* Fixed the required validation for the File element.
    801805* Correct the align text for the feature image and upload form element.
    802806* Added the red dots to the feature and upload form element, to be shown on error.
    803807* Added the error label for the password form element when is required and the validation is performed in JS.
    804808* Fixed the serve side validations and error signals.
    805809* Improved the way the error was handled by the plugin.
    806810* Fixed Enfold theme compatibility issue.
    807811* Fixed password place holder.
    808812* Added a location.reload(); to the delete js to make sure it also works with custom templates including the delete button.
    809813* Added a featured image as case to the function preparing the form element values.
    810814* Fixed the form submission with no ajax.
    811815* New feature, now the save draft will not trigger the form validation.
    812816* Fixed the form permission to edit the post or create a new one.
    813817* Fixed the permission to check if the user have the capability `edit_others_posts` or `edit_others_pages` to grant the edit other users entry.
    814818
    815819= 2.5.8 - 11 Oct 2019 =
    816820* Added an implementation to avoid acf field from form validation.
    817821* Added a new way to edit the list of Countries and States from the elements options.
    818822* Added a new option into the Country element to load the States for the next State element base on the Country key present in State list. More in the documentation https://docs.buddyforms.com/article/582-country-and-state-elements.
    819823* Added the default name of does fields which not was adding it when they was added to the form.
    820824* Fixed the store/load values for elements like the number field in a registration form.
    821825* Fixed the store/load values for elements from a registration form.
    822826* Fixed the required signal for the textarea element.
    823827* Changing the file element from a link to a button.
    824828* Changing the file element * place to be after the label.
    825829* Changing the default date format to `dd/mm/yy`.
    826830* Fixed the jQuery form validation to override the default required jQuery validate by buddyforms internal implementation where external element will not process and letting 3rd addOns to hook into the process.
    827831* Fixed the form option to stop the Js validation.
    828832* Fixed error position for the checkbox and the radio buttons.
    829833* Fixed the red border for the bio element.
    830834* Fixed the validation for the upload element.
    831835* Added a * to the first empty element of the country and state element when they are required and the label is inline.
    832836* Added the placeholder for the upload element with the corresponding *. Now it have the correct label when the form is showing the placeholder or labels.
    833837* Fixed the error placement for the category, taxonomy and tag element, now the error will appear after the element.
    834838* Fixed the error placement for the elements textarea, post_excerpt and buddyform_form_content.
    835839* Fixed the error placement fo the radio buttons.
    836840* Fixed the red border for password element.
    837841* Improved the password element label and placeholder. Now the label is showed when the form is configured in the other way the password element will show the placeholder inside the input with the * if the element is required.
    838842* Fixed the JS validation for the post_formats element.
    839843* Fixed the placeholder and label for the post_formats element.
    840844* Fixed the label for the feature image element and added a label inside the element to work as placeholder.
    841845* Fixed the Category and Tag element missing placeholder.
    842846* Fixed the captcha form element label and description.
    843847* Added a new option inside the captcha form element to override the language.
    844848* Added a hook to customize the Js parameters to include in the request for the captcha form element. `buddyforms_captcha_js_source_parameter`.
    845849* Improved the honey-pot anti spam.
    846850
    847851= 2.5.7 - 4 Oct 2019 =
    848852* Fixed the issue with the output buffer.
    849853
    850854= 2.5.6 - 3 Oct 2019 =
    851855* Fixed the date element format. Thanks to `Maxime From Hophop Ride`
    852856* Fixed the hidden element.
    853857* Fixed the admin submission list to include the Date and the Hidden element correctly.
    854858* Fixed the Post Excerpt element to be output in the correct place.
    855859* Fixed the issue with the dropdown element where they let the user add text always.
    856860* Added support to use the element properties name with Upper letters, this changes improve compatibility with other extensions. Thanks to Joanna Pantages to bring this topic to us.
    857861
    858862= 2.5.5 - 30 Sept 2019 =
    859863* Added a new filter `buddyforms_current_user_can` to change the permission. The filter has 4 parameter permission, form slug, post, type (edit, delete, all).
    860864* Moved the BuddyForms js global above buddyforms_front_js_css_after_enqueue.
    861865* Add a new filter buddyforms_loop_form_slug to overwrite the form slug on a post basis in the loop.
    862866* Reformat the code of the-loop.php
    863867* Added 2 hooks to let 3rd party addons not include the form action buttons.
    864868* Added a new do action `buddyforms_the_loop_after_actions` to add actions buttons outside the normal action workflow.
    865869* Improved the compatibility with the BF UM addon. This change avoid to override the form slug from the query arguments coming from 3rd party addons.
    866870* Added hooks to change the Country and State list from the code in the professional version.
    867871* Disabled the select2 to include elements if the option is not activated.
    868872* Fixed the format for the date element.
    869873* Fixed the styles to be included in the shortcodes.
    870874* Fixed the category element to include the default value and the correct items.
    871875* Fixed the modal to create the pages from the wizard, the setting page and the form builder.
    872876* Added a new hook buddyforms_after_user_activation to hook after the user activation.
    873877* Added the time field using the jquery ui datepicker.
    874878* Changed the library for the date element to use jquery ui datepicker.
    875879* Improved the way the js data is loaded into the form.
    876880* Added the ability to process shortcodes from the after form submited message.
    877881* Fixed the styles of the message.
    878882* Added some hook into JS to get the field data from 3rd party plugins.
    879883* Added a class `form-control` to all elements.
    880884* Changed the required validation to apply only to elements `.form-control:required`.
    881885* Added a JS action hook for Form submit.
    882886* Added a new tag option for the shortcode used to get the list of entries. This open the posibility to get entries from multiples forms in one place. Example shortcode `[buddyforms_list_all query_option="list_all_published_posts_by_meta_key" meta_value="acf-validation,test-ultimate-member,test-assets" meta_compare="in" form_slug="acf-validation" meta_key="_bf_form_slug"]`
    883887
    884888= 2.5.4 - 19 Aug 2019 =
    885889* Fixed the validation of the backend message for the manage submission page.
    886890* Fixed the issue generated by submit an empty tag or category.
    887891* Fixed the issue to edit/delete post created before without BuddyForms.
    888892
    889893= 2.5.3 - 19 Aug 2019 =
    890894* Fixed the wrong message from the Category field.
    891895* Updated the generated styles.
    892896* Fixed the captcha to be showed in all forms.
    893897* Fixed the styles to be applied correctly to all forms.
    894898* Fixed the default field option for the taxonomy, category and tag field.
    895899* Added the dismissible option to the admin notification to setup the page in the plugin settings for Frontend Submissions Management.
    896900
    897901= 2.5.2 - 19 Aug 2019 =
    898902* Improved the way the styles of the forms are loaded and how the are apply to the form. Now this improve let to edit the css of specific form even if exist multiples forms in the same page.
    899903* Improved the load of the assets.
    900904* Fixed the password validation to take in count if the field is required or not. Useful for Forms to edit the user profile.
    901905* Fixed the GDPR output.
    902906* Fixed the validation of the website and link field to only apply the JS validation when correspond.
    903907* Added a new general settings for the frontend submissions management.
    904908* Added the submissions management page to the form select as pre selected if n o attached page exist.
    905909* Fixed the email validation for the field user_email and email.
    906910* Added a hook system for frontend JS.
    907911* Fixed the suffix for the price field.
    908912* Added required signal for the fields in the builder, to easy identify what fields are required.
    909913* Fixed the email validation message for the email field.
    910914* Fixed the issue originated by the form slug coming from the templates.
    911915* Added 2 function to load the assets using JS.
    912916* Fixed the field dependent on select2 to load correctly in the builder.
    913917* Improve the compatibility with the plugin email-subscribers. https://wordpress.org/support/topic/compatibility-with-email-subscribers
    914918* Fixed the auto-load of the content of the default page to manage submitions.
    915919* Fixed to get back the post_id used when a form is loaded and the auto-draft is created.
    916920* Fixed the scroll after the form is submitted.
    917921* Fixed the creation of the form from the Wizard.
    918922* Fixed the captcha field.
    919923* Fixed the email notification for the user not logged in.
    920924* Fixed the user_email field was changing the email of the current user logged in in all forms.
    921925* Fixed the output of the tags in the admin submission screen.
    922926* Fixed the wizard registration tab.
    923927* Fixed the auto-generate slug for the fields in the form designer.
    924928* Move the Date field to the basic fields.
    925929* Adding the field name for all fields when they are added to the builder.
    926930
    927931= 2.5.1 - 11 July 2019 =
    928932* Fixed the double Label for the content field.
    929933* Updated the way of the form render using echo or simply returning the html.
    930934* Improved the code to be compatible with JupiterX.
    931935
    932936= 2.5.0 - 9 July 2019 =
    933937* Improved required field messages to be more user friendly.
    934938* Fixed the function to register users from multisite.
    935939* Added more argument to extend the fields form 3rd parties.
    936940* Moved the captcha field to the basic field group.
    937941* Added a Price field.
    938942* Removed the label option from the From Action field.
    939943* Fixed the option to change the form slug, because it was not working if the form not have any submitted entry.
    940944* Fixed JS incompatibility with external plugins.
    941945* Code improvement and cleaning.
    942946* Improved the detection of the bf shortcodes from the post content.
    943947* Fixed the fields user_login and user_email because the option `hide to logged in` was hiding this field for logged out users and not make sense for a registration form.
    944948* Added a filter to exclude columns in the submission list from the administration.
    945949* Updated the user meta mapping to load the user website from user metas.
    946950* Improved the default submission title for the registration forms.
    947951* Fixed to show the User meta values when a list of entries shortcode is used.
    948952* Fixed the user_login and user_email field to load the value from the user meta.
    949953* Fixed the show captcha when the submission is in the action view.
    950954* Code fix to the action column of the list of entries of a contact form.
    951955* Added a custom class to the list of submissions.
    952956* Fixed the password reset shortcode.
    953957* Improved the code related to the error handling.
    954958* Added the possibility to override the template/output used to change the password.
    955959* Removing the session from the form submission and the error handling.
    956960* Adding the Content element to handle the server validation for that component.
    957961* Added a filter to change the output used to replace by a shortcode. `apply_filters('buddyforms_field_shortcode_value', $field_result_value, $form_slug, $post_id, $target_slug )`
    958962* Fixed to avoid jQuery validate crash.
    959963* Fixed the undefined index when the dropdown don't have any item created yet.
    960964* Added the option to create a form from scratch or select the existing templates when a form is added trough the option add new.
    961965* Fixed the wizard to not show the new builder background.
    962966* Fixed the issue related to the creation of auto-draft in each visit of the form in the frontend.
    963967* Added a filter to change the array separator. `apply_filters('buddyforms_implode_separator', ', ', $field_type, $field_slug)`
    964968* Fixed the validation to process the array correctly, it affect the taxonomy fields.
    965969* Added the taxonomy field value for the submission column in the administration.
    966970* Fixed the permission issue when the post is created using buddyforms.
    967971* Added a helper function to check the user capability. `bf_user_can`
    968972* Added a nonce error message.
    969973* Added a cursos pointer to the checkbox input.
    970974* Fixed the permission to submit a form for anonymous users.
    971975* Fixed a notice in the email notifications.
    972976* Fixed the edit and delete buttons.
    973977* Fixed the required validation for the content field.
    974978* Fixed the auto-draft error for different post types.
    975979* Added a Js hook to extend the function to get field data.
    976980* Change "Check to enabled" to "Check to enable".
    977981* Updating Freemius to version 2.3.0.
    978982* Added the ability to join the beta tester groups.
    979983* Fixed the way is added the scripts when the form is load from a shortcode.
    980984* Fixed the user email element to be an email input to validate with html5.
    981985
    982986= 2.4.6 - 3 Jun 2019 =
    983987* Fix : Feature Image Field layout.
    984988* Fix: Validation min/max value for number field type.
    985989* Fixed the trash option inside the post status field.
    986990* Added a filter (`buddyforms_before_update_post_meta`). to hook before the form meta is saved in order to customize it.
    987991* Added an option inside the form to enabled or disabled the js validation in the frontend.
    988992* Removing the jQuery validation from php code.
    989993* Added the required validtion inside JS file.
    990994* Removed the validation tab and required option for the comment field.
    991995* Added an event to the required validation to be extended from 3rd extensions for custom fields using JS.
    992996* Fix the required validation to pass the field with no data like password second field.
    993997* Added a global event to enabled or disabled the form submit button, this give the possibility to improve the integration of 3rd party code.
    994998* Fixed the repeated Date field. Fixes #498
    995999* Added the current form into the JS global var to be used in the backend to load or apply the field related code.
    9961000* Change the Date field to jQuery DateTimePicker and added more options to get more control of this field.
    9971001* The new Date field is enabled to use with Time or Date or both at same time and handle custom formats and time steps. Also is possible to customize from external JS using event callback.
    9981002* Improving the validation for the hidden fields like the taxonomies, dates.
    9991003* Fixing the placement of the validation error.
    10001004* Fixing the error validation to work with taxonomy fields.
    10011005* Removing the limit to have more than one Date field in a form.
    10021006* Added the label to the Date field this field is inline.
    10031007* Added a function to get the field by ID.
    10041008* Added a code to get the form slug from the post meta to define to include the assets.
    10051009* Improved the label position for the error validation.
    10061010* Fixed the column row to styles. Added a new class for the first element row `bf-start-row`.
    10071011* Added an option inside the fields Excerpt, Content and Textarea to control the amount of rows.
    10081012* Added the ability to copy the shortcodes from the side bar using a single click inside the form builder.
    10091013* Fixed the option to generate the title and content for a post to not take precedence over the submitted value if the field is not hidden.
    10101014* Added one option inside the form to change the Form slug.
    10111015* Added server side validation for Date fields.
    10121016* Fixed the styles for the Date field when is show in the edit post screen inside a metabox.
    10131017* Improved the form slug option to be process only if it change.
    10141018* Improved the Element Class and Validation Class to accept the field options as a property to handle the field options inside the Field Class.
    10151019* Moved the Date field options inside the Date field Class.
    10161020* Added the server side validation for the PostFormat field.
    10171021* Added PostFormat as a new Field type in the code.
    10181022* Improve the server side validation to extend existing using filters.
    10191023* Fixing the shortcodes to only show the requested form by the provided form slug.
    10201024* Fixing a hook to override the submit button.
    10211025
    10221026= 2.4.5 - 19 May 2019 =
    10231027* Adding a copy to clipboard into the form designer to copy the field slug.
    10241028* Fixing the extra weigh of the plugin zip.
    10251029
    10261030= 2.4.4 - 19 May 2019 =
    10271031* Fixed the editor issue in order to only apply the fix related to the form designer in certain pages.
    10281032* Fixed email notification duplicate values for taxonomies in the table of all fields.
    10291033* Improved the notification code to be more fast and stable. Now the empty shortcodes will be replace by empty string to not send noice shortcode tags into the email to the final users.
    10301034
    10311035= 2.4.3 - 17 May 2019 =
    10321036* Fixed fields with ajax validations allows to enter a lower number in Max Length than the entered in Min Length.
    10331037* Fixed the empty editor with gutenberg.
    10341038* Fixed the issue reported in https://wordpress.org/support/topic/buddy-forms-not-working-with-5-1-1/.
    10351039* Fix to avoid hide all metaboxes when BF is adding his own metabox.
    10361040
    10371041= 2.4.2 - 16 May 2019 =
    10381042* Fixed the assets issue caused by the automation script used to generate and deployed the new version.
    10391043
    10401044= 2.4.1 – 14 May 2019
    10411045* Added the option to define the number of rows for a textarea.
    10421046* Fixed the option `Make this field Hidden` because it was not appearing in the form designer.
    10431047* Fixed: To load the assets on the admin pages and show the upload field on the admin pages.
    10441048* Added the ability to sort the item inside the next field types: checkbox, dropdown, radiobutton and gpdr
    10451049* Fixed the Ajax Validation, broken for the text aria.
    10461050* Fixed the issue related to the post status. Now the post will keep the post status when is created or edited if not exist a status field.
    10471051* Fixed the css for "Required field" messages in the dropdowns, checkboxes, radiobuttons and GDPRs are misplaced.
    10481052* Fixed the email notification to process the field shortcode user_email.
    10491053* Fixed the notification issue. The bug was throw when a field shortcode was used in the notification options and was not process correctly. Now even is possible to use field shortcodes inline with strings.
    10501054* Fixed the validation for min and max length.
    10511055* Fixed the validation for min and max number.
    10521056
    10531057= 2.4.0 – 29 March 2019
    10541058* Change to use SEM Version
    10551059* Fixed default value for upload and feature image field
    10561060* Added a way to not echo the textarea, only return the html
    10571061* Fixed the double update of the existing post
    10581062* Improved the taxonomy, category and tag field to be possible to extend the terms query by 3rd parties using the filter `buddyforms_ajax_load_term_query`
    10591063* Ready to be localized the string `Upload in progress`
    10601064* Added a hook to add field related translations inside the field
    10611065* Added a container to divide the form actions
    10621066* Fixed the error related to the save of fields placed after a taxonomy field
    10631067* Added a validation to avoid error when no exist any form
    10641068* Fixed the visibility of the new ajax option inside the taxonomy field
    10651069* Fixed the button to reset the form styles
    10661070* Added compatibility for `Better Notifications for WordPress`
    10671071* Changed the ajax search name_like to use search option
    10681072* Updated select2 to the latest version
    10691073* Added cache to the select2 search terms field
    10701074* Add draft functionality
    10711075* Add a mechanism to read the form options from the js side
    10721076* Improved the code stability
    10731077* Added a helper function to grab the form slug from different sources
    10741078* Added a btn-alt for the draft button to make a difference with the primary button
    10751079* Added custom class for draft button
    10761080* Added a custom element to handle the form actions (publish/draft) buttons. With this custom field is possible to output the selected button in a different order
    10771081* Updated the draft text
    10781082* DOMDocument error fixed. Now the code detect if dom library is loaded if not it use regex
    10791083* Moved the custom class option under the switch to make sure the option is available for all fields
    10801084* Added the draft options
    10811085* Move the form action field into the basic group
    10821086* Fixed the issue related to load assets in the admin where they don't needed
    10831087* Improved the detection of the block to include the assets trough gutenberg
    10841088* Fixed the navigation in the list of entries for contact form
    10851089* Fixed the form builder grid option not working for images
    10861090* Update the session to use transient to avoid trash in the database
    10871091* Remove the long time expiration for the session, now is 27~30mn
    10881092* Fixed the mail notification when the post status change.
    10891093* Improved the shortcode `form_elements_table` used into the mail notifications
    10901094* Added the git templates for issues and features request into the git repository
    10911095* Added a filter to override the lost password link
    10921096* Fix the notification accordion
    10931097* Fix the ad notification button
    10941098* Fixed the after submission option when is displaying a page content
    10951099* Fixed the regex to detect bf from the post content
    10961100* Fix the shortcode to generate the table with all values from the form. This shortcode is used in the form notification. The fix include the notification when the post change his status.
    10971101* Fixed the notification accordion when the form is created directly
    10981102
    10991103= 2.3.3.2 – 6 March 2019
    11001104* Added a check to avoid start gutenberg block in older wordpress versions
    11011105* Added an option to use ajax for the taxonomy field
    11021106* Code improved
    11031107
    11041108= 2.3.3.1 – 2 March 2019
    11051109* IMPORTANT: the function buddyforms_locate_template used in our templates has changed now need the $form_slug parameter. Please update your templates files.
    11061110* Fixed the checkbox styles in the form permissions
    11071111* Freemus SDK Update
    11081112
    11091113= 2.3.3 – 28 Feb 2019
    11101114* Update the way to include parameters into js
    11111115* Added buddyformsGlobal var
    11121116* Code Refactored
    11131117* Improved the upload field to work in the list of contact entries
    11141118* Fixed the double label for the upload field
    11151119* Fixed the way is added the rules to jQuery validation, now the input need to be active.
    11161120* Fixed: Overlapping title on a new BuddyForm
    11171121* fixed the admin url used in ajax call
    11181122* Update Freemius
    11191123* Update composer type
    11201124
    11211125= 2.3.2 – 26 Feb 2019
    11221126* Fixed the assets to be included with the shortcodes.
    11231127
    11241128= 2.3.1 – 22 Feb 2019
    11251129* Added Gutenberg Support
    11261130* Add new Blocks for Embed Forms, Submissions, Registration and Login Forms.
    11271131* Added the ability to show other user submission if the permission is enabled.
    11281132* Fixed the permission auto check. Now the permissions follow the next rules:
    11291133--> For pro version -if the form is new only select create-edit-delete by default for admin and editor
    11301134--> Free version -all permission checked for all roles except for all submissions Fix/all submission permission
    11311135* Fixed Upload field - image url is getting reset on save
    11321136* Added the user_login to the submission list to get the value form the user meta.
    11331137* Improved the user_login and email field to show in the single submission view.
    11341138* Fixed the label duplication issue in the single submission view
    11351139* Change the button text from Close to Back
    11361140* Fixed the user fields first and last name to store correctly into the user meta.
    11371141* Fixed the issue related to create multiples entries when the registration form was used to update an user.
    11381142* Added the different Column name for table template
    11391143* Changed the post entry title to use the user nicename when the pest entry belong to a registration form.
    11401144* Added a new tag to define the style of the list in the shortcodes.
    11411145* Updated the default value for the post style
    11421146* Fixed the warning inside the Gutenberg shortcode
    11431147* Added an Author column to the submission list in the administration, to easily identify the author of the entry. If the entry belong to an un-authenticated user it will show `Anonymous`
    11441148* Changed the name of the composer library to avoid conflict with composer 2
    11451149* Added the styles to organize the permission chk.
    11461150* Added the validation for the permissions inside the submission view.
    11471151* Added the value as class inside the container of the checkbox to easily style each one.
    11481152* Removed the home page from the activation page list. Now to redirect to WordPress home is necessary to use the HomePage option in the list.
    11491153* Avoid to ask for permission to show the form in the registration forms.
    11501154* Fixed the fields email and user_login to show if the user is not logged in.
    11511155* Improved the code.
    11521156* Localized ready for all strings
    11531157* Fixed the empty localization strings
    11541158* Updating the translation file. Adding the Spanish translation.
    11551159* updated composer.lock
    11561160* Fixed the undefined index name in the submission page
    11571161* Add a new function to detect if is gutenberg
    11581162* Added a filter to disable the validation of the email send to the user on activation or update
    11591163* Improved the assets included in the form.
    11601164* Added a function to extract the form slug reading a shortcode or direct from the html after the shortcode is processed reading the hidden input form_slug.
    11611165* Fixed security issue related to the registration form. It was including the last entry id in the hidden field of a registration form where it suppose to be empty. Now the update user process work seamless.
    11621166* Code cleaning
    11631167
    11641168
    11651169= 2.3 – 21 Jan 2019
    11661170* Removed an left over alert from the dropdown rewrite
    11671171* Fixed user_website valdiation
    11681172* Moving the asterisk to flag required fields to by at the end of the label.
    11691173* Added a Hook to change the signal of the default values, by default asterisk. Filter details `buddyforms_render_required_signal` one parameter.
    11701174* Removed composer update from the post-merge git hook
    11711175* Added a message inside the registration forms type to let the user know the Wordpress user registration is disable, added the same validation and message to avoid to render a registration form.
    11721176* Improved the validation
    11731177* Added the first step to create gutenberg block
    11741178* Fixed E-Mail Adress is empty, if no form field with E-Mail Adress is submitted by logged in users
    11751179* Added a space between the Date #167
    11761180* Changed the labels in the form builder
    11771181* Added a space between the Date #167
    11781182* Created a new helper function to get $_GET parameter
    11791183* Fixed an issue with the form element custom class. The class option was not working on every form element. Should be fixed now.
    11801184* Added a wrapper class to the form element call div. The wrapper class starts with col- and the custom form element class from the form element option custom_class
    11811185* Added a query var to get the form slug from the Form preview
    11821186* Fixed the field id for the form_arg parameter
    11831187* Updated the freemius sdk to version 2.2.3
    11841188* Cleaned and refactored the code.
    11851189
    11861190
    11871191= 2.2.9.2 – 29 November 2018
    11881192* Added validation to the file element.
    11891193* Fixing the validation of the emails notifications.
    11901194* Fixed the function to scroll to error in the form designer.
    11911195* Fixing the form designer validation
    11921196
    11931197= 2.2.9.1 – 28 November 2018
    11941198Spelling correctioon
    11951199Added a extra check to the updated script top avoid a PHP Warning: Invalid argument supplied for foreach. This was reported by a user and happened on some installs if a form with no form elements was used from the backend.
    11961200Reformat code
    11971201
    11981202= 2.2.9 – 23 November 2018
    11991203* Improving the email functionality to receive the user cc and bcc copies of the emails. Refactoring the code.
    12001204* Added a default template for the shortcode
    12011205* Added validation for the cc and bcc fields with multiples emails or one.
    12021206* Fixed the option to show the cc or bcc to interact only with the field in the current notification.
    12031207* fixed to keep the round red color and the scroll to the elements.
    12041208
    12051209= 2.2.8 – 9 November 2018
    12061210* Fixed an issue where the feature image was not attach to the post
    12071211* Removed the maxFiles limit from the upload form element
    12081212* Improved the security and added prepare to queries to avoid sql injection.
    12091213* Improved the field processing, for extra process.
    12101214* Added the action `buddyforms_process_field_submission` to grant 3rd party to add extra process to the field and include this extra process internal fields like Upload and Features.
    12111215* Added the Field Control to start migrating to SOLID principles.
    12121216* Added the action to the action `buddyforms_process_field_submission`.
    12131217* Fixed the condition to ask if the imgae.php was already included.
    12141218* Fixed the email short-code generation.
    12151219* Improving the shortcode replacement
    12161220* Adding CI with codeship, phpcs, php linter and php fixer.
    12171221* Updated php cs and fixer configuration
    12181222* Fixed the validation og the website form element without http protocol
    12191223* Improving the code.
    12201224
    12211225
    12221226= 2.2.7 – 19 October 2018
    12231227* Added missing translations
    12241228* Fixed some admin css issues and make sure its also working for WordPress.com
    12251229* Removed the readme from the zip process.
    12261230* Added a functionality to add a random string as the form name in case the form is created and not provide a title.
    12271231* Fixed the notices and warnings related to the create form process
    12281232* Added the BuddyForms version to the file enqueue
    12291233* Fixed the shortcode to show all users entries work.
    12301234* Fixed the permission tab to avoid override saved values with default values.
    12311235* Disabled the ACF js navigate away pop up
    12321236* Updated the cache group.
    12331237* Added a helper function to get the form by slug and include a cache inside
    12341238* Improving function documentation
    12351239
    12361240= 2.2.6 – 1 October 2018
    12371241* Fixed the option to delete an image when post is deleted inside the upload field.
    12381242* Added new option to upload field to define how many file will be uploaded.
    12391243* Added new option in the upload field to define the validation messages.
    12401244* The upload field now upload one file by one.
    12411245* Fixed the the shortcode bf_user_posts_list.
    12421246* Fixed the validations process, in the case where the jQuery validator not exist.
    12431247* Added new options to the featured-image field, now it work like the upload field.
    12441248* Fixed the invalid image when file is not present.
    12451249* New option for image upload max number of files to ensure the amount of files to upload.
    12461250
    12471251= 2.2.5 – 10 September 2018
    12481252* Added support for WordPress.com. There have been UI issue in the Admin backend.
    12491253* Added validation to avoid form submission when one of the files in the upload has errors
    12501254* Added a validation to avoid enable the submit button when some process is in motion.
    12511255
    12521256* Rewrite the file upload form element
    12531257** New version of the upload field.
    12541258** Added a new validation for required fields.
    12551259** Added a validation for when the field have more file than allowed.
    12561260** Included de description at the bottom of the field, if the description exist.
    12571261** The validations run over jquery validations.
    12581262** Adding a new filter to pass the jquery validation for certain field types. Filter name 'buddyforms_jquery_validator_field_to_pass' with the parameter array('upload').
    12591263** Fixed the link between the media files and the created post.
    12601264** Changed the behavior of the upload field. When a file is droped is automatically validated. The submit of the form is lock until a file is uploading and unlock on finish the queue.
    12611265** Improved the code of the upload field.
    12621266** Changed the color of the error and success svg using a filter to be red and green.
    12631267
    12641268* Added group validation
    12651269* Added a global validation to avoid send the form until the field not upload the files
    12661270* Added a validation with jquery to check if the upload is required and if they have only the allowed files
    12671271* Removed prevent default of the submit button
    12681272* Added a red color to the error cross in the field upload
    12691273* Fixed compatibility to php 7.1 for the function `buddyforms_strip_html_title_for_entries_in_post_screen`
    12701274* Added a new permission to get all user submission in the frontend.
    12711275* Added a script to check for repeated slug and add a random suffix. This is important to avoid crash with components that use the name in the frontend with javascript
    12721276* Added a filter to customize the jquery validations. `buddyforms_jquery_validator_init`, thanks to @pattyok.
    12731277* Added the function to the form to open the field in case of empty required setting.
    12741278* Fixed the list post option setting.
    12751279* Show the empty submission list message option always in the form settings.
    12761280* Removed the permalink notice and Removing permalink verification funciton
    12771281* Fixed the shortcode generator modal. Now it look full width
    12781282* Changed the version of the upload script make it load by the clients.
    12791283* Fixed the upload field to handle more than one field in the same form.
    12801284* Added the option to handle the empty submission list.
    12811285* Added a shortcode to add a link inside the empty submission list message.
    12821286* Added an improve to wait the form submission for multiples file upload from diferents fields
    12831287* Moved upload function to the function file to include in the front.
    12841288* Fixed submission view to include the post title and the post content. The post content with the elipsis form wp
    12851289* Cleaned the upload field.
    12861290* Added a code to check if the uploader have a file to avoid cancel the form submission.
    12871291* Added a script to check for repeated slug and add a random suffix.
    12881292* Added a new permission to get all user submission in the frontend.
    12891293* Cleaned the code.
    12901294
    12911295= 2.2.5 – 31 August 2018
    12921296* Fixed the shortcode generator modal. Now it look full width.
    12931297* Removed the permalink notice and function.
    12941298* Showing the empty submission list message option always in the form settings.
    12951299* Fixed the list post option setting.
    12961300* Added a filter to customize the jquery validations. `buddyforms_jquery_validator_init`, thanks to @pattyok.
    12971301* Added the function to the form to open the field in case of empty required setting.
    12981302* Added a script to check for repeated slug and add a random suffix.
    12991303* Added a new permission to get all user submission in the frontend.
    13001304
    13011305= 2.2.4 – 7 August 2018
    13021306* Fix the screen option for submission page in BuddyForms.
    13031307* Fix: Featured image field is not working in the front-end for edit entries.
    13041308* Fix :Upload field is not working in the front-end for edit entries.
    13051309* Adding a function to check for the correct permalink.
    13061310* Adding a notice to show to the user in case the permalink are not the correct.
    13071311* Adding permalink admin notification.
    13081312* Fixing the js code related to the new upload field, because it was changing the name of the submit buttons in the forms.
    13091313* Removing unused php session.
    13101314* Adding the option to hide the User related fields.
    13111315* Adding status of the post to the submission list
    13121316* Adding better return for the post status. Now it show the full string.
    13131317* Adding helper functions to get all files of one form.
    13141318* Adding a helper function to check if exist a field in the form.
    13151319* Implementing a condition to hide the hidden status input is exist the field status in the form.
    13161320* Adding the code to handle the status if they coming form the form.
    13171321* Fix Status field.
    13181322* Fixing the user role moderation to avoid the user role change for admin and when the option is to keep the current user role.
    13191323* Fixing the user role moderation.
    13201324* Fixing the submit of the form.
    13211325* Added a code to check if the uploader have a file to avoid cancel the form submission.
    13221326* Moving upload function to the function file to include in the front.
    13231327* Fixing submission view to include the post title and the post content. The post content with the elipsis form wp
    13241328* Cleaning the upload field.
    13251329* Added a code to wait the form submission for multiples file upload from different fields.
    13261330* Added the option to handle the empty submission list.
    13271331* Added a shortcode to add a link inside the empty submission list message.
    13281332
    13291333= 2.2.3 – 10. July 2018
    13301334* Fixed the reCaptcha library, adding a native checking from google.
    13311335* Added a link to generate new keys.
    13321336* Fixed the permission tab checkboxes css
    13331337* Implemented a role based authorization security mechanism using a custom attribute filter.
    13341338* Fixed a issue with the drop zone. File upload via form not attached to post
    13351339* Added a screen option for the submission screen.
    13361340* Fixed the login for active or not active users.
    13371341* Added the js script to handle the moderation settings.
    13381342* Added the new moderation and on update user settings.
    13391343* Implementing the moderation function for user update.
    13401344* Updating the options and the text related to the moderation to make more friendly.
    13411345* Fixed the upload field initializer.
    13421346* Added some functions to display the submit message of the forms and the default message.
    13431347* Added the new option to the form setting to add new message on form update.
    13441348* Fixed the user update on form update.
    13451349* Implementing the new update message for form submit
    13461350* Freemius SDK Update
    13471351
    13481352= 2.2.2 – 29. Jun 2018
    13491353* Fixed the resend activation link for user pending of activations
    13501354* Improved the submission view UI
    13511355* Added a new filter buddyform_after_activate_user. To hook just after the user got activated.
    13521356* Removed duplicated argument `$bf_value` from the filter `bf_submission_column_default`.
    13531357* Fixed a notice related to an empty attached_page option
    13541358* Updating the js functions to not use live, thanks to @virtualLast
    13551359* Removing deprecated functions and fixed several smaller issues
    13561360* Prefixed custom_user_profile_fields function to avoid conflicts with other plugins using the same name.
    13571361
    13581362= 2.2.1 – 22. Jun 2018
    13591363* Added a filter at top of the user list to filter the list of user for the buddyforms pending for activation users.
    13601364* Added the activation and resend activation email link into the admin user list.
    13611365* Added a buddyform function to generate nonces, to use in the activation process of users.
    13621366* Saving the activation link into user meta.
    13631367* Added a function to get the current user id from the get parameters when the activation process is running.
    13641368* Applying code style.
    13651369* Mke the review notification grab the correct version number.
    13661370
    13671371= 2.2 – 20. Jun 2018
    13681372* This is a huge update. Please test deeply.
    13691373
    13701374* GDPR Release
    13711375* We belive we have done all possible to make BuddyForms GDPR compliance. GDPR is still a subject to change and we will adjust BuddyForms if we find out that something is not build GDPR compliance.
    13721376* --> Make the architecture of BuddyForms GDPR Complaint
    13731377* --> Add a new Form Element "GDPR Agreement"
    13741378* --> Added GDPR Agreement templates for registration, post and contact forms
    13751379* --> Add new general settings page to create default Agreement templates and form footer terms text and terms page link option.
    13761380* --> Added a new shortcode "GDPR Export and Erase Form" [buddyforms_gpdr]. A form to add GDPR Personal Data Export and Erase request forms to your site
    13771381* --> Added support for the Personal data exporter
    13781382* --> Fixed how the plugin get the user data with a new way to disable it.
    13791383* --> Added argument validation to take in count the wp core key and the field types matching.
    13801384* --> Refactoring how the user meta is saved. Now all is in the same place.
    13811385
    13821386* Featured Image
    13831387* Created a new uploader. Its now possible to upload featured images for unregistered logged off users.
    13841388
    13851389* Added a link "create new entry" if the submission list is empty.
    13861390* Fixed the form slug to get the form messages. Cleaning and refactoring the code.
    13871391* Added a code to show the related tabs in base of the form type select in the templates
    13881392* Added a filter to disable save usermeta data 'buddyforms_not_save_usermeta'.
    13891393* Make sure tinyMCE exist otherwise it is braking the ajax.
    13901394* Fixed the submit with ajax option for the form.
    13911395* Added function to map the existing fields to override the meta use in wp core instead of duplicate it.
    13921396* Calling the new functions in the user-meta.php file, this is a new centralice way to get and write the user data.
    13931397* Changing the loader priority of the user-meta.php file to use the new function in the frontend
    13941398* Avoid send the notification id if the status is the same
    13951399* Including Patty O'Hara suggestion to avoid send the email notification if the old status is equal to the new status. This will avoid to send the notification twice
    13961400* Added the new GDPR Admin Notice
    13971401* Added the new freemius sdk
    13981402* Fixed a issue with the user meta. Some data have not get validated correctly.
    13991403* save a issue with tinymce not updating the textbox during submit
    14001404* Added a check to registration forms if the default values exist on update of a user to avoid notice
    14011405* Added new filter and add a check to deactivate the activation mail with a filter
    14021406* Fixed the remote preview url
    14031407
    14041408= 2.1.7 – 20. May 2018
    14051409* Removed all dependencies to bootstrap. In earlier versions UI parts of the Admin have been build with Bootstrap. This parts have been rebuild to use WordPress native jQuery UI
    14061410* --> Added buddyform prefix for nav-pills, nav-tabs and tabs-left
    14071411* --> Fixed the field related scripts like the tabs and the accordion when new field is added to the form builder.
    14081412* --> Added script to load the field inside the wizard.
    14091413* --> Fixed css to organize the arrow inside the wizard
    14101414* Fixed php language minor issues
    14111415* Change the place of the filter for submission default value
    14121416* Fixed a sessions issue. This fix is related a conflict during recovery of the session when the page is load the first time.
    14131417* Improved the submissions table to show the column data and custom field types
    14141418* -->Added the category and the tag to the list of submission
    14151419* changing the input ids for the wp login form to avoid name coalition with the user_id field
    14161420* add form slug as attribute to the buddyforms_formbuilder_fields_options filter
    14171421* Fixed some issue in the registration form redirect. redirect to url #was broken
    14181422
    14191423= 2.1.6.8 – 29. April 2018
    14201424* Fixed an issue with the upload form element “No image displayed in the admin edit screen”
    14211425* Change submit button text to upload in process during upload
    14221426* Fixed the upload label. slug was used.
    14231427* Added a filter for allow add-ons display the value in the column of the submission list
    14241428* show the thumbnail of the uploaded files in the view and edit submision pages
    14251429* Change the loader of garlic library to first check if the html tag exist in the dom.
    14261430* Added jQuery identifier instead of $ to avoid error
    14271431* Make trials working. Tehre was an issue with the trial activation.
    14281432
    14291433= 2.1.6.7 - 16. April 2018
    14301434* Added a display none important as css to the id bf_honeypot. The bf_honeypot form element does have a style attribute display: none but for some reason some customer reported in the support that the field was visible.
    14311435* Fixed an issue in the shortcode. The author id attribute did not have any effect.
    14321436* Added compatibility for public post lists so they can be used in other extension like BuddyForms Ultimate Member
    14331437
    14341438= 2.1.6.6 - 3. March 2018
    14351439* Added a default error message to the error handling just in case we have a error but no message
    14361440* Check if the user id is_wp_error and get the error message
    14371441* Added description and Label to the upload field drop zone
    14381442
    14391443= 2.1.6.5 - 29. March 2018
    14401444* Changing the submission query to use wpdp
    14411445* Improving the edit form shortcode
    14421446* Fixed an issue with the upload form element. The label and description was not displayed
    14431447* Fixed smaller issues reported by users
    14441448* CSS some css in the login form
    14451449
    14461450= 2.1.6.4 - 26. March 2018
    14471451* Fixed the check for the permission for admin and autor (read-edit-write)
    14481452* Fixed the loader of the plugin to avoid incompatibilities with WP
    14491453* Added new class bf-hidden to enable hide form elements by class
    14501454* Added the honey pot to the form.
    14511455* Fixed and issue in the login form. The Lost Password Link was overwriting the registration link
    14521456* Remove the old plugin header from the password-strengh-settings
    14531457* Make sure Form Layout and Import Forms are always the last tabs
    14541458* Improving the global var of BuddyForms
    14551459* Fixed the item in the list of form inside the submission view to include the last updated form names
    14561460* Fixed the items name in the list of form inside the submission view
    14571461* Fixed the the visibility of the selected form post type
    14581462* Moving the tk icon load script to a separated function to load in backend and frontend
    14591463* Added css to include the icon in the shortcode
    14601464* Create a new admin bar menu item to edit the form if the form is displayed.
    14611465* Update Freemius version to 2.0.1
    14621466
    14631467= 2.1.6.3 - 14. March 2018
    14641468* Make sure the password update script in the wp insert user only run if new password is set during update
    14651469* Make sure the password script works for new registrations with the change password class introduced in the latest update
    14661470
    14671471= 2.1.6.2 - 12. March 2018
    14681472* Updated the re captcha form element to use the version 2. Version 1 is only supported til the 30 of March.
    14691473* Added new options for recaptcha v2 to the form element.
    14701474* Fixed an issue with the user creation. If "Create account during submission" was set without a page selected in the form builder under edit submissions.
    14711475* Fixed an issue with the post author. If the user was created during submission it could happen that no author was set.
    14721476* Rebuild the pfbc password field and make use of the WordPress validation also in registration forms.
    14731477* Fixed an with the password option "hide for logged in users". If the option was set the password field was hidden all the time.
    14741478
    14751479= 2.1.6.1 - 6. March 2018
    14761480* Fixed an issue in the Registration and Activation Process.
    14771481* Refactoring the code.
    14781482* Added the login/registration form to the forms when the option correspond
    14791483
    14801484= 2.1.6 - 5. March 2018 =
    14811485* New upload field to integrate with dropzone
    14821486*  - Added option max file size
    14831487*  - Added option acceptedFiles
    14841488*  - Added the option multuple files
    14851489*  - Added the delete file option
    14861490*  - Added the id of the attachment in the submissions table for the upload field
    14871491*  - Show the id of the submited files as links in the entry list
    14881492*  - Props to Victor and Guillermo for there contributions and making the DropZone a reality ;)
    14891493* Fixed the submission view in the backend.
    14901494* Added a function to strip the html from the post list in the backend
    14911495* Added the interaction when the ajax is in progress to disabled the submit button
    14921496* Several smaller bug fixes
    14931497
    14941498= 2.1.5.2 - 20. February 2018 =
    14951499* Fixed an issue in the loop. The thumbnail was not clickable in all sirtuations
    14961500* Moved the password-strength-meter wp_localize_script to its correct location. It was in the admin settings and never got loaded in the frontend. This issue was a merge conflict.
    14971501* Add localisation for password rest to make the password hint and messages translatable.
    14981502
    14991503= 2.1.5.1 - 9. February 2018 =
    15001504* fixed a merge conflict from Merge pull request #174 from BuddyForms/fix/g-171
    15011505
    15021506= 2.1.5 - 8. February 2018 =
    15031507* Add new shortcode attribute query_option to list posts from all users of the post type for public usage
    15041508* Added new js for special password redirects after registration. If a redirect url is added to the register page url we use this redirect and add it as hidden field to the form
    15051509* Fixed some issues with the redirect after successful login
    15061510* Add a check to the change password form to check if the user should be redirected to a special location There is a new option bf_pw_redirect_url with the redirect url as absolute path
    15071511* Added a new check into the wp insert user function to save the redirect url
    15081512* Created a new function buddyforms_login_redirect to redirect after login from shortcode attribute "redirct_url"
    15091513* Created a new filter buddyforms_login_form_redirect_url to make it possible to overwrite the login redirect in BuddyForms extensions.
    15101514* Added the reset option to the dropdown field using an attribute as flag.
    15111515* Added the reset option to the checkbox, dropdown and select2
    15121516* Implementing the save of post in the backend. This implementation is only for 2 field types.
    15131517* Fixed the extract functions to avoid notices and warnings.
    15141518* Change the submission page to use WP_Query and OOP.
    15151519* Added a hook to update the post meta on edit post in the backend
    15161520* Added a validation to check for specific number when the user set max and min for the same number.
    15171521* More fixes and mobile view improvements, bigger image, fix in date formatting, better buttons, better typo
    15181522* Fully reworked list view CSS
    15191523* New CSS for table view and status items for table view
    15201524* CSS options for each module, done and tested
    15211525* Created extras tab with an option to disable all CSS for this form
    15221526* Created also an option to disable CSS for the tab "other form elements"
    15231527* Work on the login form and password reset
    15241528* Added the display form option back to registration forms so they can be used for profile forms.
    15251529* Change the scroll to top so that we can be sure to see the message
    15261530* Add a new filter "buddyforms_reset_password_redirect" to change the password redirect url
    15271531* Fixed an issue with validation min length. There was a spelling issue in the option name.
    15281532* Add support for the option page to the password strength js
    15291533* Add an redirect option to change password
    15301534* Welcome back the languages folder for the .pot file. People still ask for the file so we move it back
    15311535* Fixed an issue with the registration form content overwrite. The content was returned empty in all cases... ;(
    15321536* Add a change password shortcode to the plugin. This enables new workflow You can auto generate the password during registration and redirect the user to a page with the change password shortcode included.
    15331537* Make hidden and html basic fields so they can be used in all form types
    15341538* Added md5 string to auto generated usernames
    15351539* Fixed a issue with the form and posts list did not get displayed in the endpoints
    15361540* Created two new form elements Country and State
    15371541* Enqueue mce-view to view gallery in front-end post edit props to @Hannah93 for there pull request
    15381542* Remove do_shortcode so galleries work on front-end post edit props to @Hannah93
    15391543* Fixed backend tax empty bug
    15401544* Added some extra check to BuddyForms rewrite roles to avoid load registration forms on BuddyPress Groups pages
    15411545* Added a new do action buddyforms_admin_js_css_enqueue
    15421546* Fixed some css issues
    15431547* Correct some spelling and bad english
    15441548* Fixed an issue with validation min length. There was a spelling issue in the option name.
    15451549* Add support for the option page to the password strength js
    15461550* add a new filter "buddyforms_reset_password_redirect" to change the password redirect url
    15471551* Added the display form option back to registration forms so they can be used for profile forms.
    15481552* Change the scroll to top so that we can be sure to see the message
    15491553
    15501554= 2.1.4 - 23 August 2017 =
    15511555* Fixed an issue with the login form shortcode
    15521556* Comment out buddyforms-jquery-ui-style I not think its needed anymore. Let us keep it for a while and delete it in the next versions
    15531557* Update the plugin description and change the link form buddyforms.com to themekraft.com/buddyforms
    15541558* Changed the editor.css path. it was admin_url but should be includes_url. Do not as me why this worked before...
    15551559* Fixed an issue with the taxonomy form element. ID must be an integer. There was a string in some situations passed to the function after the last update.
    15561560--> Make sure the term gets deleted if the field is unselected.
    15571561--> Make sure the new taxonomy is saved as default 'unauthorised' or nothing instead of a "-1"
    15581562* Remove old pfbc css and js dependencies
    15591563* Reorder and clean up the code
    15601564* Clean up the-loop.php template. Move the pagination out of the table
    15611565* Rename the buddyforms_the_loop_item_last hook to buddyforms_the_loop_item_title_after for the table and buddyforms_the_loop_item_excerpt_after for the list
    15621566* Add form_slug as parameter to the buddyforms_the_loop_li_last and buddyforms_after_loop_item in the the-loop.php template
    15631567* Add form_slug as parameter to the buddyforms_the_table_tr_last and buddyforms_after_loop_item in the the-table.php template
    15641568* Add new hook to the the-loop.php templates buddyforms_the_loop_item_title_after to hook content after the title
    15651569* Add new hook to the the-table.php templates buddyforms_the_thead_tr_inner_last to add new table head labels
    15661570
    15671571= 2.1.3.1 - 23 August 2017 =
    15681572* Fixed a issue in the taxonomy form element In some installs it was not possible to process the form if no option was selected even if the field was not required.
    15691573* Added a Redirecting message to the notice if redirect to page is set with Ajax enabled
    15701574
    15711575= 2.1.3 - 21 August 2017 =
    15721576* Fixed form validation jQuery error. Props to @Hannah93
    15731577* Fixed undefined function is_error. Props to @Hannah93
    15741578* Fixed small error fixes. Props to @Hannah93
    15751579    @Hannah93 huge thanks for your contributions!
    15761580* Fixed a issue in the contact form FROM sender. If set to first name and last name only first name was used.
    15771581* Fixed an issue in the mail notifications. It was not possible to add shortcodes in the From custom sender field.
    15781582* Work on the taxonomy form element, make categories and tags fixed without taxonomy select to simplifier the configuration.
    15791583* Fixed smaler issues in the taxonomy form element and optimise the taxonomy category and tags form elements
    15801584* Added a new option to limit category, tags and taxonomy selection if multiple is enabled
    15811585* Add a notice to the taxonomy form element and hide the options if not on the professional plan
    15821586* Fixed an issue with the comment status The form element always stay as comments open. Even if comments are closed.
    15831587* Set the js and css to global by default. There are to many issues with the function at the moment. Can still set to false with the filer priority higher than 10 or by de register buddyforms_front_js_css_loader_global
    15841588* Fixed admin notice in wp-insert-user.php
    15851589* Make sure mail_submission_trigger_sent is only triggered if a post exist
    15861590* Make sure the wp editor css get loaded
    15871591* Rewrite the logic of generate titlle and content
    15881592* New feature! Log Registrations as Submissions. From now on every Registration and profile changed get logged as submission.
    15891593* Add new metabox to the submissions single view in the backend to display the user id if form type is registration form.
    15901594* Hide Password form any view.
    15911595* Make sure passwords fields does not get saved as post meta with the new logic of registration log as submissions
    15921596* Save the user id in the post if registration form to know the user
    15931597* Add functions to load the admin single view from user meta
    15941598* Reformat Code to stay conform with WordPress Coding Standards
    15951599* Make sure Registration Pages are not displayed in the form builder/ form edit / page select
    15961600* Fixed the layout import in the Form Designer. Colors and custom css was broken and did not get imported.
    15971601* check if generate content and title is activated and generate teh content if the field is not empty.
    15981602
    15991603
    16001604= 2.1.2.3 - 1 August 2017 =
    16011605Freemius update to allow free and pro add ons
    16021606
    16031607= 2.1.2.2 - 27 July 2017 =
    16041608* Fixed an issue in wp-insert-user.php. Function return value in write context. Remove the sanitise checks from if empty()
    16051609
    16061610= 2.1.2.1 - July 14.2017 =
    16071611* Fixed a issue with the AddOns Page There was a conflict "Cannot redeclare _wp_menu_output"
    16081612* Remove the old add-ons.php. We use freemius from now on for the Addons
    16091613
    16101614= 2.1.2 - July 14.2017 =
    16111615* Added two now options to select the registration page and form in the general settings and overwrite the WordPress default registration form.
    16121616* Created two new functions buddyforms_registration_page_redirect and buddyforms_registration_page_content to redirect the WordPress registration to a BuddyForms Registration form
    16131617* Created a new user field Date
    16141618* Improved the error handling to better understand ajax errors. If WordPress post insert or update run into an error the error gets displayed.
    16151619* Fixed an issue with the post_excerpt. The form could not get saved if post_excerpt was empty.
    16161620* Moved the required "*" from beginning to the end of the label
    16171621* Fixed some issue in the registration if form is used to update user meta password and mail form element are not required
    16181622* Fixed several smaller issues reported by users
    16191623* Add a new do action do_action( 'buddyforms_process_submission_end', $args ) to the registration case to make sure we can hook into the registration process
    16201624* Created a new option to hide the password form element for logged in users
    16211625
    16221626= 2.1.1.2 - July 01.2017 =
    16231627* Fixed a merge conflict in the submissions and in the settings views. The submissions and settings was set to hidden from the js.
    16241628* Changed the submissions and settings html so it works with the current js and get displayed.
    16251629* Make sure all submission metabox get displayed
    16261630
    16271631= 2.1.1.1 - Jun 29.2017 =
    16281632* Fixed an issue in the ajax error response. $$this should be $this.
    16291633* Adjust the checkbox and select box elements and make label and value required.
    16301634
    16311635= 2.1.1 - Jun 27.2017 =
    16321636* Added a new form element post_excerpt
    16331637* Check if form template json request is an error code and load local json if needed.
    16341638* Create a new file deregister to manage all script and stiles we need to deregister
    16351639* Switch from $_SESSION to $wp_session
    16361640* Make sure the buddyforms metaboxes can not be hidden
    16371641* Move the Form Broken admin_notice to post_submitbox_start
    16381642* Make sure the css and js is not loaded on freemius pages
    16391643* Added a new option to the featured image form element to define the button label
    16401644* Add the field name to the error message
    16411645* Added class_exists as wrapper to the complete loader file to support freemius free plugin deactivation if pro version gets activated
    16421646* Reformat the code and deletes old and unneeded code
    16431647
    16441648= 2.1.0.2 - Jun 12.2017 =
    16451649* Make sure registration activation does work all over the site and if no option is set the home is used
    16461650* Make sure registration activation code check is fired on all pages
    16471651* Allow to add admin mail as from email in the register account activation message
    16481652* Dependencies for WooCommerce Simple Auction added to the form templates
    16491653* Make sure the buddyforms_activate_user template redirect is before any other redirect can take place
    16501654* Added a new option to select a registration form for for the login form.
    16511655* Created a new function buddyforms_get_all_pages to get all pares as id's array or by name
    16521656* Fixed issues in the Registration and Activation Logic. Done some deeply testing and changing some logic.
    16531657* Auto Login user after click the activation link.
    16541658* Added some jQuery to to show hide permission options according to the public_submit settings
    16551659* Added referrer as after activation redirect
    16561660* Check if session is writable and change session to the WordPress upload dir if not writable.
    16571661* Fixed multiple issues
    16581662
    16591663= 2.1.0.1 - Jun 08.2017 =
    16601664* Added a check is_wp_error for the form builder templates and load defaults if request failed.
    16611665* Added a ask for rating notice
    16621666* Fixed several smaller issues
    16631667* Remove freemius module migration. Its not needed anymore
    16641668* Update the Welcome Screen to the new features
    16651669
    16661670= 2.1 - Jun 07.2017 =
    16671671* This is a major update with lots of changes. Not all commits are listed here. For a detailed list of all changes please see the GitHub Commits https://github.com/BuddyForms/BuddyForms
    16681672
    16691673Main New Features:
    16701674* Form Designer: New Metabox Form Designer to design your forms in detail.
    16711675* Form Grid: Add new Options to the Form Builder to set the grid
    16721676* Form Templates System to create any kind of Form from template
    16731677* Added the functionality to update registration forms from the front to allow existing users to change there user data and meta fields
    16741678
    16751679Summary of changes:
    16761680* Added a new form element Phone, eMail and Range
    16771681* Create a new file metabox-layout.php for the form layout
    16781682* Added new options to adjust the form layout
    16791683* Added a new function buddyforms_can_edit to make anonymous and multi author posts possible
    16801684* Create a new global settings page for the form layout options
    16811685* Added a new option to the form element list in the form builder to define the grid
    16821686* Make the author id filterable
    16831687* Added functionality to load the layout form from other forms or the global settings
    16841688* Create a new function buddyforms_layout_style to determine the style and support bootstrap or other frameworks
    16851689* Added a new filer buddyforms_layout_style to overwrite the form grid classes
    16861690* Added CSS for form grid options
    16871691* Add a Grid builder to the Form ELements.
    16881692* Fixed a issue with session start if the server was restarted without deleting the session
    16891693* Added a new filter buddyforms_loop_template_name to register new loop templates
    16901694* Make sure we have a $post->post_name in the shortcode. It created a conflict with draft posts and edits and run the form twice if a post id exist but no post name.
    16911695* Update freemius to prevent function exist
    16921696* Create a new Element_InlineHTML to have an HTML form element without grid
    16931697* Fixed the schedule time. It was broken because the browser close the divs and render not work.
    16941698* Added a new filter buddyforms_the_lp_query to adjust the query result
    16951699* Clean up the content filter for the rewrite endpoints
    16961700* Add a function to support yoast seo
    16971701* Added new function buddyforms_is_author to make BuddyForms better work with multiple authors
    16981702* Added two new attributes $form_slug, $post_id to the buddyforms_user_can_delete filter
    16991703* Remove is user logged in and buddyforms_can_edit functions from the loop and table templates and move this checks to the buddyforms_post_entry_actions function
    17001704* Fixed a freemium issue where the freebies was displayed on gravity forms edit screen.
    17011705* Category and tags never worked ;( they never got saved… What a stupid issue! We switched the naming from taxonomy to taxonomy, category, tags but forgot to check during save for the new types.
    17021706* Added https support to google recaptcha
    17031707* Added a new shortcode bf_login_form to add a simple login/logout form
    17041708* Added new filters to manipulate the insert and update arguments buddyforms_wp_insert_post_args buddyforms_wp_update_post_args
    17051709* Add a new filter to enable the deactivation of the wp_editor. http://docs.buddyforms.com/article/473-site-origin-page-builder-support?auth=true
    17061710* Create a new helper function buddyforms_get_form_slug_by_post_id to get the form slug from post id Will return the form slug from post meta or the default. none if no form is attached
    17071711* Move the session back to the constructor. Otherwise we get issue if the form is used in shortcodes
    17081712* Created a new function buddyforms_get_post_types to get the allowed posts types of BuddyForms
    17091713* Created a new function buddyforms_notice_if_broken_form to check if the form is broken #94
    17101714* Added the functionality to update registration forms from the front to allow existing users to change there user data and meta fields
    17111715* Added a new function buddyforms_wp_update_user to update existing users
    17121716* Adjust the process form script to support update post data and meta
    17131717* Added wp_editor support to the textarea
    17141718* Load js and css on BuddyForms settings page
    17151719* No footer scripts needed at the moment comment out the action for now.
    17161720* Added buddyforms-metabox class to settings metaboxes
    17171721* Fixed an issue in the global layout options. CSS and JS save was broken after rewrite the meta.
    17181722* Fixed an issue where the mail notification was not send if post status changed
    17191723* Fixed an issues in the mail buddy. line brakes have not been recognised
    17201724* Added new options for mail_from_name and mail_from
    17211725* Added the show hide js for new mail notification options
    17221726* Added a new attribute to $striped to the buddyforms_display_field_group_table to allow the disable of table striped
    17231727* New from options: user_login, user_firs, user_last, userfirst_last, blog_title or custom. Custom can use anf form element via shortcodes
    17241728* Added new file form-templates for the form builder and wizard templates
    17251729* Created a new function to create the templates array buddyforms_form_builder_register_templates
    17261730* Make Form Builder default Label values translatable
    17271731* Fixed Wizard -> Permissions -> Check all not working #60
    17281732* Last test with smaller fixes to check if the layout is working in the templates
    17291733* Fixed an issue in the mail notification settings in the form builder templates
    17301734* Strip the content in the submissions view #75
    17311735* Fixed hidden content mce toolbar #69
    17321736* Move the register post type out of the admin to make it accessible for the rest api
    17331737* Make use of the wp rest api for the form builder templates and load the json from the demo.
    17341738* Add Kleo Theme Support
    17351739* Fixed tons of smaller and bigger issues
    17361740* Clean up the code
    17371741
    17381742= 2.0.15 - 05.04.2017 =
    17391743* Fixed a taxonomy issue with excluded terms. Added a check if an excluded term was added via the backend edit screen. If a excluded term is found we need to make sure to add it to the cat_string. Otherwise the term is lost by every update from the frontend
    17401744* Remove the languages. We use the .org translation from now on
    17411745* added post_id as global to the buddyforms_form_html function.
    17421746* Fixed a taxonomy issue with excluded. Added a check if an excluded term was added via the backend edit screen. If a excluded term is found we need to make sure to add it to the cat_string. Otherwise the term is lost by every update from the frontend
    17431747* Added new filter buddyforms_form_field_name and buddyforms_form_field_description to make the form label and description translatable.
    17441748* Added new filter buddyforms_wp_dropdown_categories_args to allow add new attributes to the arguments array.
    17451749* Added a new hook buddyforms_core_fs_loaded for other plugins to check if freemius sdk is loaded
    17461750* smaller fixes and css improvements
    17471751
    17481752
    17491753= 2.0.14 - 07.02.2017 =
    17501754* Added new Filter buddyforms_the_loop_args to manipulate the loop args
    17511755* Fixed a jQuery issue if the taxonomy select was not set to single it was not able to create a new tag.
    17521756* Added strip_tags for the auto generated title title.
    17531757* Better position error message on radiobuttons
    17541758* Enquire jQuery dialog and switch to jQuery dialog for all dialogs
    17551759* Select2 fields have not been responsive. Set the css width to auto
    17561760* Try to grab the form slug from the post to support form overwrite and also fallback to default
    17571761* Hook the form to the content why was this comment out?
    17581762* Make sure the form slug is accessible in the global
    17591763* Added a extra check in the e-mail to make sure we not fire any notice
    17601764
    17611765= 2.0.13 =
    17621766* Add some checks if is object to avoid notice
    17631767* Changed from p tag to span in the generate title function to avoid line breaks
    17641768* Smaller Changes
    17651769
    17661770= 2.0.12.1 =
    17671771* Add missing function buddyforms_get_form_field_by_slug. Was removed from merge conflict
    17681772
    17691773= 2.0.12 =
    17701774* Add new file user-meta.php to display user meta fields in the admin user views
    17711775* There was an issue during registration. add_user_to_blog only works on multi site.
    17721776* Add missing parameter to the buddyforms_activate_account_mail for the new_user_id
    17731777* Rename_process_post to process_submissions
    17741778* Remove old unneeded functions
    17751779* Add new centralised sanitize function buddyforms_sanitize()
    17761780* Move the number form element to the basic fields
    17771781* Small jQuery fix. Make sure the correct fields get displayed for the field types
    17781782
    17791783= 2.0.11 =
    17801784* Full support for the Visual Composer
    17811785* Add new loading overlay animation
    17821786* We fixed creating mail notification triggers in the form wizard.
    17831787* We fixed the submit button from stopped being working
    17841788* If the redirect is enabled and the form is set to ajax, we make sure that the ‘after submission message’ gets displayed
    17851789* Scroll to the top after submitting a successful form with ajax
    17861790* Add some field type management. This will get improved soon. It’s a starting point
    17871791* Add new options to generate content
    17881792* Create a new function to replace form fields easily by slug and shortcode [field_slug]
    17891793* Add a new option to the title to auto generate it from other form elements
    17901794* Create a new option in the taxonomy form element to select a placeholder text
    17911795* Add an ‘is_admin’ check to the post meta saving function, to avoid deleting meta while saving from the admin editing screen.
    17921796* Get the page_on_front and exclude it from the query. This page should not be used for the endpoints
    17931797* We removed visual composer elements from the BuddyForms editing screen
    17941798* Add an extra check to make sure JavaScript validation is only running if at least one form exist.
    17951799* Set the BuddyForms post type public to false. There is no need to access BuddyForms directly
    17961800* Add the post id to the buddyforms_user_can_edit filter. If we need more attributes it’s time for a arguments array
    17971801
    17981802= 2.0.10 =
    17991803* Add Post Formats support
    18001804* Tested WordPress Version 4.7.1
    18011805* New Pro Feature: Create a new form element for the post formats
    18021806
    18031807= 2.0.9 =
    18041808* Fixed a issue in the mail notification. Array elements like checkboxes and taxonomies got displayed as 'Array'
    18051809* Add a new function to display Checkboxes, eMails, Websites and Taxonomies in mail notifications.
    18061810
    18071811= 2.0.8 =
    18081812* Enable Advanced options for the contact form fields
    18091813* Spelling correction
    18101814* Add some isset checks to prevent nonce in the form select meta box
    18111815* Add new parameter to the buddyforms_user_can_edit filter to enable limit user submissions by user role.
    18121816* Add all error messages in filter to allow the overwrite from other plugins
    18131817
    18141818= 2.0.7 =
    18151819* Check if a mail notification exist to avoid php notice if debugger is enabled
    18161820* Update the freemius SDK.
    18171821
    18181822
    18191823= 2.0.6 =
    18201824* Fixed an issue with categories and tax. The form element was only working as taxonomy form element.
    18211825* Fixed the admin header for WordPress 4.7
    18221826* Update the welcome screen links and screenshots
    18231827
    18241828
    18251829= 2.0.5 =
    18261830* Add a new function remove_admin_scripts to remove styles and scripts added by other plugins and themes
    18271831* Add Kleo Theme Support
    18281832* Fixed an issue with the dependencies management. If pro was activatedit still ask for the free. Fixed now with a new default BUDDYFORMS_PRO_VERSION in the core to check if the pro is active.
    18291833* Make sure any css from other plugins is deregistered if the BuddyForms view is displayed
    18301834* Add suffix "buddyforms to all js handle
    18311835* remove_all_actions( 'admin_head', 10  ) if BuddyForms is viewed
    18321836* To strict remove of all other plugin and theme relevant js and css is the only solution to avoid conflicts if the edit screen is used.
    18331837* Fixed a  missing attribute in the  buddyforms_form_element_multiple function cursing the form element checkbox and select to break.
    18341838
    18351839= 2.0.4 =
    18361840* Fixed an issue in the form import function.
    18371841* Add a new do action buddyforms_admin_js_footer to add custom extension js to the admin footer
    18381842* Add a new filter buddyforms_form_builder_post_type to add new options into the post type select
    18391843* Rebuild buddyforms_locate_template function to fix a issue loosing the variables if used locate_template
    18401844* Rename buddyforms_add_form_element_to_select to buddyforms_add_form_element_select_option
    18411845* Add Text Domain and Domain Path in the header
    18421846* Remove indeed function parameter and variables
    18431847* Add dynamic version to the welcome screen
    18441848* Subject and message have not been unique
    18451849* Clean up the code
    18461850* Code smell fixes
    18471851* Delete unneeded files
    18481852* Update translations
    18491853
    18501854= 2.0.3 =
    18511855* Remove old select2 dependencies
    18521856* Fixed a firefox admin ui css issue with the form type select box
    18531857* Make sure the taxonomy form element only get saved during form processing if a taxonomy is selected in the form element
    18541858* Separate starter and professional plans in the pro version. They have been accidentally the same.
    18551859* New labels for the free starter professional and business plans
    18561860* Rebuild the mail notifications. Its not needed to add any message text. BuddyForms will automatically use the subject and message form elements if they are available.
    18571861* If no message text is available BuddyForms will add all form element valuers as table into the eMail.
    18581862* Add new option to select the submitter as Sent to address
    18591863* Create a new function buddyforms_mail_notification_form_elements_as_table to add a form elements table via tags or if no mail message content exists
    18601864* Documentation for the new features
    18611865* Fixed smaller issues and css fixes reported by users.
    18621866
    18631867= 2.0.2 =
    18641868* smaller submissions loop table css fixes
    18651869* fixed an issue with the update form the 1.5.3 version
    18661870
    18671871= 2.0.1 =
    18681872* Freemius SDK update
    18691873* smaller changes
    18701874
    18711875= 2.0 =
    18721876* First public version
Note: See TracChangeset for help on using the changeset viewer.