Changes in buddyforms/trunk [3031945:3046092]
- Location:
- buddyforms/trunk
- Files:
-
- 11 edited
-
BuddyForms.php (modified) (1 diff)
-
assets/admin/js/admin.js (modified) (1 diff)
-
assets/admin/js/admin.min.js (modified) (1 diff)
-
assets/resources/dropzone/initializer.js (modified) (1 diff)
-
assets/resources/dropzone/initializer.min.js (modified) (1 diff)
-
assets/resources/featured-image/featured-image-initializer.js (modified) (1 diff)
-
assets/resources/featured-image/featured-image-initializer.min.js (modified) (1 diff)
-
includes/admin/admin-ajax.php (modified) (1 diff)
-
includes/admin/form-builder/meta-boxes/metabox-form-setup.php (modified) (1 diff)
-
includes/functions.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
buddyforms/trunk/BuddyForms.php
r3031945 r3046092 1 1 <?php 2 2 3 3 if ( !defined( 'ABSPATH' ) ) { 4 4 exit; 5 5 } 6 6 /** 7 7 * Plugin Name: BuddyForms 8 8 * Plugin URI: https://themekraft.com/buddyforms/ 9 9 * 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. 710 * Version: 2.8.8 11 11 * Author: ThemeKraft 12 12 * Author URI: https://themekraft.com/buddyforms/ 13 13 * Licence: GPLv3 14 14 * Network: false 15 15 * Text Domain: buddyforms 16 16 * Domain Path: /languages 17 17 * Svn: buddyforms 18 18 * 19 19 * 20 20 * **************************************************************************** 21 21 * 22 22 * This script is free software; you can redistribute it and/or modify 23 23 * it under the terms of the GNU General Public License as published by 24 24 * the Free Software Foundation; either version 2 of the License, or 25 25 * (at your option) any later version. 26 26 * 27 27 * This program is distributed in the hope that it will be useful, 28 28 * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 30 * GNU General Public License for more details. 31 31 * 32 32 * You should have received a copy of the GNU General Public License 33 33 * along with this program; if not, write to the Free Software 34 34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 35 35 * 36 36 * *************************************************************************** 37 37 */ 38 38 39 39 if ( !class_exists( 'BuddyForms' ) ) { 40 40 /** 41 41 * Class BuddyForms 42 42 */ 43 43 class BuddyForms 44 44 { 45 45 /** 46 46 * @var string 47 47 */ 48 public $version = '2.8. 7' ;48 public $version = '2.8.8' ; 49 49 /** 50 50 * @var array Frontend Global JS parameters 51 51 */ 52 52 private static $global_js_parameters ; 53 53 /** 54 54 * Initiate the class 55 55 * 56 56 * @package buddyforms 57 57 * @since 0.1-beta 58 58 */ 59 59 public function __construct() 60 60 { 61 61 global $wp_session ; 62 62 register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) ); 63 63 $this->load_constants(); 64 64 add_action( 65 65 'init', 66 66 array( $this, 'init_hook' ), 67 67 1, 68 68 1 69 69 ); 70 70 require_once BUDDYFORMS_INCLUDES_PATH . '/form/form-assets.php'; 71 71 new BuddyFormsAssets(); 72 72 add_action( 73 73 'init', 74 74 array( $this, 'includes' ), 75 75 4, 76 76 1 77 77 ); 78 78 add_action( 'init', array( $this, 'update_db_check' ), 10 ); 79 79 add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 80 80 register_deactivation_hook( __FILE__, array( $this, 'plugin_deactivation' ) ); 81 81 } 82 82 83 83 /** 84 84 * Defines constants needed throughout the plugin. 85 85 * 86 86 * These constants can be overridden in bp-custom.php or wp-config.php. 87 87 * 88 88 * @package buddyforms 89 89 * @since 0.1-beta 90 90 */ 91 91 public function load_constants() 92 92 { 93 93 /** 94 94 * Define the plugin version 95 95 */ 96 96 define( 'BUDDYFORMS_VERSION', $this->version ); 97 97 if ( !defined( 'BUDDYFORMS_PLUGIN_URL' ) ) { 98 98 /** 99 99 * Define the plugin url 100 100 */ 101 101 define( 'BUDDYFORMS_PLUGIN_URL', plugins_url( '/', __FILE__ ) ); 102 102 } 103 103 if ( !defined( 'BUDDYFORMS_INSTALL_PATH' ) ) { 104 104 /** 105 105 * Define the install path 106 106 */ 107 107 define( 'BUDDYFORMS_INSTALL_PATH', dirname( __FILE__ ) . '/' ); 108 108 } 109 109 if ( !defined( 'BUDDYFORMS_INCLUDES_PATH' ) ) { 110 110 /** 111 111 * Define the include path 112 112 */ 113 113 define( 'BUDDYFORMS_INCLUDES_PATH', BUDDYFORMS_INSTALL_PATH . 'includes/' ); 114 114 } 115 115 if ( !defined( 'BUDDYFORMS_TEMPLATE_PATH' ) ) { 116 116 /** 117 117 * Define the template path 118 118 */ 119 119 define( 'BUDDYFORMS_TEMPLATE_PATH', BUDDYFORMS_INSTALL_PATH . 'templates/' ); 120 120 } 121 121 if ( !defined( 'BUDDYFORMS_ADMIN_VIEW' ) ) { 122 122 /** 123 123 * Define the template path 124 124 */ 125 125 define( 'BUDDYFORMS_ADMIN_VIEW', BUDDYFORMS_INCLUDES_PATH . 'admin/view/' ); 126 126 } 127 127 if ( !defined( 'BUDDYFORMS_ASSETS' ) ) { 128 128 /** 129 129 * Define the template path 130 130 */ 131 131 define( 'BUDDYFORMS_ASSETS', plugins_url( 'assets/', __FILE__ ) ); 132 132 } 133 133 } 134 134 135 135 /** 136 136 * Defines buddyforms_init action 137 137 * 138 138 * This action fires on WP's init action and provides a way for the rest of WP, 139 139 * as well as other dependent plugins, to hook into the loading process in an 140 140 * orderly fashion. 141 141 * 142 142 * @package buddyforms 143 143 * @since 0.1-beta 144 144 */ 145 145 public function init_hook() 146 146 { 147 147 $this->set_globals(); 148 148 do_action( 'buddyforms_init' ); 149 149 150 150 if ( function_exists( 'buddyforms_core_fs' ) ) { 151 151 $bf_fr = buddyforms_core_fs(); 152 152 if ( !empty($bf_fr) ) { 153 153 $bf_fr->add_filter( 'plugin_icon', array( $this, 'buddyforms_freemius_icon' ) ); 154 154 } 155 155 } 156 156 157 157 } 158 158 159 159 public function buddyforms_freemius_icon() 160 160 { 161 161 return BUDDYFORMS_INSTALL_PATH . 'assets/images/buddyforms.jpg'; 162 162 } 163 163 164 164 /** 165 165 * Enable the localization of the fields adding the strings to js and hold the global localization 166 166 * 167 167 * @return array 168 168 */ 169 169 public static function localize_fields() 170 170 { 171 171 return apply_filters( 'buddyforms_field_localization', array( 172 172 'error_strings' => array( 173 173 'error_string_start' => __( 'The following', 'buddyforms' ), 174 174 'error_string_singular' => __( 'error was', 'buddyforms' ), 175 175 'error_string_plural' => __( 'errors were', 'buddyforms' ), 176 176 'error_string_end' => __( 'found: ', 'buddyforms' ), 177 177 ), 178 178 'bf_trans' => array( 179 179 array( 180 180 'msgid' => 'The following', 181 181 'msgstr' => __( 'The following', 'buddyforms' ), 182 182 ), 183 183 array( 184 184 'msgid' => 'error was', 185 185 'msgstr' => __( 'error was', 'buddyforms' ), 186 186 ), 187 187 array( 188 188 'msgid' => 'errors were', 189 189 'msgstr' => __( 'errors were', 'buddyforms' ), 190 190 ), 191 191 array( 192 192 'msgid' => 'found: ', 193 193 'msgstr' => __( 'found: ', 'buddyforms' ), 194 194 ), 195 195 array( 196 196 'msgid' => 'Delete Permanently', 197 197 'msgstr' => __( 'Delete Permanently', 'buddyforms' ), 198 198 ), 199 199 array( 200 200 'msgid' => 'Use a few words, avoid common phrases', 201 201 'msgstr' => __( 'Use a few words, avoid common phrases', 'buddyforms' ), 202 202 ), 203 203 array( 204 204 'msgid' => 'No need for symbols, digits, or uppercase letters', 205 205 'msgstr' => __( 'No need for symbols, digits, or uppercase letters', 'buddyforms' ), 206 206 ), 207 207 array( 208 208 'msgid' => 'Add another word or two. Uncommon words are better.', 209 209 'msgstr' => __( 'Add another word or two. Uncommon words are better.', 'buddyforms' ), 210 210 ), 211 211 array( 212 212 'msgid' => 'Straight rows of keys are easy to guess', 213 213 'msgstr' => __( 'Short keyboard patterns are easy to guess', 'buddyforms' ), 214 214 ), 215 215 array( 216 216 'msgid' => 'Short keyboard patterns are easy to guess', 217 217 'msgstr' => __( 'Short keyboard patterns are easy to guess', 'buddyforms' ), 218 218 ), 219 219 array( 220 220 'msgid' => 'Use a longer keyboard pattern with more turns', 221 221 'msgstr' => __( 'Use a longer keyboard pattern with more turns', 'buddyforms' ), 222 222 ), 223 223 array( 224 224 'msgid' => 'Repeats like "aaa" are easy to guess', 225 225 'msgstr' => __( 'Repeats like "aaa" are easy to guess', 'buddyforms' ), 226 226 ), 227 227 array( 228 228 'msgid' => 'Repeats like "abcabcabc" are only slightly harder to guess than "abc"', 229 229 'msgstr' => __( 'Repeats like "abcabcabc" are only slightly harder to guess than "abc"', 'buddyforms' ), 230 230 ), 231 231 array( 232 232 'msgid' => 'Avoid repeated words and characters', 233 233 'msgstr' => __( 'Avoid repeated words and characters', 'buddyforms' ), 234 234 ), 235 235 array( 236 236 'msgid' => 'Sequences like abc or 6543 are easy to guess', 237 237 'msgstr' => __( 'Sequences like abc or 6543 are easy to guess', 'buddyforms' ), 238 238 ), 239 239 array( 240 240 'msgid' => 'Recent years are easy to guess', 241 241 'msgstr' => __( 'Recent years are easy to guess', 'buddyforms' ), 242 242 ), 243 243 array( 244 244 'msgid' => 'Avoid recent years', 245 245 'msgstr' => __( 'Avoid recent years', 'buddyforms' ), 246 246 ), 247 247 array( 248 248 'msgid' => 'Avoid years that are associated with you', 249 249 'msgstr' => __( 'Avoid years that are associated with you', 'buddyforms' ), 250 250 ), 251 251 array( 252 252 'msgid' => 'Dates are often easy to guess', 253 253 'msgstr' => __( 'Dates are often easy to guess', 'buddyforms' ), 254 254 ), 255 255 array( 256 256 'msgid' => 'Avoid dates and years that are associated with you', 257 257 'msgstr' => __( 'Avoid dates and years that are associated with you', 'buddyforms' ), 258 258 ), 259 259 array( 260 260 'msgid' => 'This is a top-10 common password', 261 261 'msgstr' => __( 'This is a top-10 common password', 'buddyforms' ), 262 262 ), 263 263 array( 264 264 'msgid' => 'This is a top-100 common password', 265 265 'msgstr' => __( 'This is a top-100 common password', 'buddyforms' ), 266 266 ), 267 267 array( 268 268 'msgid' => 'This is a very common password', 269 269 'msgstr' => __( 'This is a very common password', 'buddyforms' ), 270 270 ), 271 271 array( 272 272 'msgid' => 'This is similar to a commonly used password', 273 273 'msgstr' => __( 'This is similar to a commonly used password', 'buddyforms' ), 274 274 ), 275 275 array( 276 276 'msgid' => 'A word by itself is easy to guess', 277 277 'msgstr' => __( 'A word by itself is easy to guess', 'buddyforms' ), 278 278 ), 279 279 array( 280 280 'msgid' => 'Names and surnames by themselves are easy to guess', 281 281 'msgstr' => __( 'Names and surnames by themselves are easy to guess', 'buddyforms' ), 282 282 ), 283 283 array( 284 284 'msgid' => 'Common names and surnames are easy to guess', 285 285 'msgstr' => __( 'Common names and surnames are easy to guess', 'buddyforms' ), 286 286 ), 287 287 array( 288 288 'msgid' => 'Capitalization doesn\'t help very much', 289 289 'msgstr' => __( 'Capitalization doesn\'t help very much', 'buddyforms' ), 290 290 ), 291 291 array( 292 292 'msgid' => 'All-uppercase is almost as easy to guess as all-lowercase', 293 293 'msgstr' => __( 'All-uppercase is almost as easy to guess as all-lowercase', 'buddyforms' ), 294 294 ), 295 295 array( 296 296 'msgid' => 'Reversed words aren\'t much harder to guess', 297 297 'msgstr' => __( 'Reversed words aren\'t much harder to guess', 'buddyforms' ), 298 298 ), 299 299 array( 300 300 'msgid' => 'Predictable substitutions like \'@\' instead of \'a\' don\'t help very much', 301 301 'msgstr' => __( 'Predictable substitutions like \'@\' instead of \'a\' don\'t help very much', 'buddyforms' ), 302 302 ), 303 303 array( 304 304 'msgid' => 'Avoid sequences', 305 305 'msgstr' => __( 'Avoid sequences', 'buddyforms' ), 306 306 ), 307 307 array( 308 308 'msgid' => 'Warning: ', 309 309 'msgstr' => __( 'Warning: ', 'buddyforms' ), 310 310 ), 311 311 array( 312 312 'msgid' => 'Suggestions: ', 313 313 'msgstr' => __( 'Suggestions: ', 'buddyforms' ), 314 314 ) 315 315 ), 316 316 ) ); 317 317 } 318 318 319 319 /** 320 320 * Hold the global variables to put in the frontend 321 321 * 322 322 * @param $array 323 323 * 324 324 * @return array 325 325 */ 326 326 public static function buddyforms_js_global_set_parameters( $array ) 327 327 { 328 328 329 329 if ( !empty(self::$global_js_parameters) ) { 330 330 self::$global_js_parameters = array_merge( $array, self::$global_js_parameters ); 331 331 } else { 332 332 self::$global_js_parameters = $array; 333 333 } 334 334 335 335 return self::$global_js_parameters; 336 336 } 337 337 338 338 /** 339 339 * Get the global variables to put in the frontend 340 340 * 341 341 * @param string $form_slug 342 342 * 343 343 * @return array 344 344 */ 345 345 public static function buddyforms_js_global_get_parameters( $form_slug = '' ) 346 346 { 347 347 return apply_filters( 'buddyforms_js_parameters', self::$global_js_parameters, $form_slug ); 348 348 } 349 349 350 350 /** 351 351 * Setup all globals 352 352 * 353 353 * @package buddyforms 354 354 * @since 0.1-beta 355 355 */ 356 356 static function set_globals() 357 357 { 358 358 global $buddyforms ; 359 359 /* 360 360 * Get BuddyForms options 361 361 * 362 362 * @filter: buddyforms_set_globals 363 363 * 364 364 */ 365 365 $buddyforms = apply_filters( 'buddyforms_set_globals', get_option( 'buddyforms_forms' ) ); 366 366 return $buddyforms; 367 367 } 368 368 369 369 /** 370 370 * Include files needed by BuddyForms 371 371 * 372 372 * @package buddyforms 373 373 * @since 0.1-beta 374 374 */ 375 375 public function includes() 376 376 { 377 377 require_once BUDDYFORMS_INSTALL_PATH . '/vendor-scope/buddyforms/vendor/autoload.php'; 378 378 require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Encoding.php'; 379 379 380 380 if ( !function_exists( 'PFBC_Load' ) ) { 381 381 require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Form.php'; 382 382 require_once BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/FieldControl.php'; 383 383 new FieldControl(); 384 384 $global_error = ErrorHandler::get_instance(); 385 385 } 386 386 387 387 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/class-bf-admin-notices.php'; 388 388 new BfAdminNotices(); 389 389 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/register-post-types.php'; 390 390 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/admin-analytics.php'; 391 391 // Compatibility 392 392 require_once BUDDYFORMS_INCLUDES_PATH . 'compatibility.php'; 393 393 require_once BUDDYFORMS_INCLUDES_PATH . 'functions.php'; 394 394 require_once BUDDYFORMS_INCLUDES_PATH . 'gdpr.php'; 395 395 require_once BUDDYFORMS_INCLUDES_PATH . 'change-password.php'; 396 396 require_once BUDDYFORMS_INCLUDES_PATH . 'multisite.php'; 397 397 require_once BUDDYFORMS_INCLUDES_PATH . 'the-content.php'; 398 398 require_once BUDDYFORMS_INCLUDES_PATH . 'rewrite-roles.php'; 399 399 require_once BUDDYFORMS_INCLUDES_PATH . 'shortcodes.php'; 400 400 require_once BUDDYFORMS_INCLUDES_PATH . 'wp-mail.php'; 401 401 require_once BUDDYFORMS_INCLUDES_PATH . 'wp-insert-user.php'; 402 402 require_once BUDDYFORMS_INCLUDES_PATH . 'revisions.php'; 403 403 // Gutenberg 404 404 require_once BUDDYFORMS_INCLUDES_PATH . 'gutenberg/gutenberg.php'; 405 405 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form.php'; 406 406 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-preview.php'; 407 407 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-render.php'; 408 408 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-ajax.php'; 409 409 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-elements.php'; 410 410 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-control.php'; 411 411 require_once BUDDYFORMS_INCLUDES_PATH . 'form/form-validation.php'; 412 412 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/user-meta.php'; 413 413 414 414 if ( is_admin() ) { 415 415 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/form-builder-elements.php'; 416 416 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/form-templates.php'; 417 417 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/admin-ajax.php'; 418 418 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/welcome-screen.php'; 419 419 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/pricing-screen.php'; 420 420 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/submissions.php'; 421 421 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/settings.php'; 422 422 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/password-strengh-settings.php'; 423 423 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/functions.php'; 424 424 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/deregister.php'; 425 425 // GDPR 426 426 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/personal-data-exporter.php'; 427 427 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/personal-data-eraser.php'; 428 428 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/mce-editor-button.php'; 429 429 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-mail-notification.php'; 430 430 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-permissions.php'; 431 431 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-layout.php'; 432 432 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-registration.php'; 433 433 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-shortcodes.php'; 434 434 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-select-form.php'; 435 435 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-elements.php'; 436 436 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-setup.php'; 437 437 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-header.php'; 438 438 require_once BUDDYFORMS_INCLUDES_PATH . '/admin/form-builder/meta-boxes/metabox-form-footer.php'; 439 439 } 440 440 441 441 } 442 442 443 443 /** 444 444 * Load the textdomain for the plugin 445 445 * 446 446 * @package buddyforms 447 447 * @since 0.1-beta 448 448 */ 449 449 public function load_plugin_textdomain() 450 450 { 451 451 load_plugin_textdomain( 'buddyforms', false, basename( dirname( __FILE__ ) ) . '/languages' ); 452 452 } 453 453 454 454 /** 455 455 * Update form 1.x version 456 456 * 457 457 * @package buddyforms 458 458 * @since 2.0 459 459 */ 460 460 function update_db_check() 461 461 { 462 462 if ( !is_admin() ) { 463 463 return; 464 464 } 465 465 $buddyforms_old = get_option( 'buddyforms_options' ); 466 466 if ( !$buddyforms_old ) { 467 467 return; 468 468 } 469 469 update_option( 'buddyforms_options_old', $buddyforms_old ); 470 470 foreach ( $buddyforms_old['buddyforms'] as $key => $form ) { 471 471 $bf_forms_args = array( 472 472 'post_title' => $form['name'], 473 473 'post_type' => 'buddyforms', 474 474 'post_status' => 'publish', 475 475 ); 476 476 // Insert the new form 477 477 $post_id = wp_insert_post( $bf_forms_args, true ); 478 478 $form['id'] = $post_id; 479 479 update_post_meta( $post_id, '_buddyforms_options', $form ); 480 480 // Update the option _buddyforms_forms used to reduce queries 481 481 $buddyforms_forms = get_option( 'buddyforms_forms' ); 482 482 $buddyforms_forms[$form['slug']] = $form; 483 483 update_option( 'buddyforms_forms', $buddyforms_forms ); 484 484 } 485 485 update_option( 'buddyforms_version', BUDDYFORMS_VERSION ); 486 486 delete_option( 'buddyforms_options' ); 487 487 buddyforms_attached_page_rewrite_rules( true ); 488 488 } 489 489 490 490 /** 491 491 * Plugin activation 492 492 * 493 493 * @since 2.0 494 494 */ 495 495 function plugin_activation() 496 496 { 497 497 $title = apply_filters( 'buddyforms_preview_page_title', __( 'BuddyForms Preview Page', 'buddyforms' ) ); 498 498 $preview_page = get_page_by_title( $title ); 499 499 500 500 if ( !$preview_page ) { 501 501 // Create preview page object 502 502 $preview_post = array( 503 503 'post_title' => $title, 504 504 'post_content' => __( 'This is a preview of how this form will appear on your website', 'buddyforms' ), 505 505 'post_status' => 'draft', 506 506 'post_type' => 'page', 507 507 'post_name' => sanitize_title( 'BuddyForms Preview Page' ), 508 508 ); 509 509 // Insert the page into the database 510 510 $page_id = wp_insert_post( $preview_post ); 511 511 } else { 512 512 $page_id = $preview_page->ID; 513 513 } 514 514 515 515 update_option( 'buddyforms_preview_page', $page_id ); 516 516 $title = apply_filters( 'buddyforms_submissions_page_title', __( 'BuddyForms Submissions Page', 'buddyforms' ) ); 517 517 $submissions_page = get_page_by_title( $title ); 518 518 519 519 if ( !$submissions_page ) { 520 520 // Create submissions page object 521 521 $preview_post = array( 522 522 'post_title' => $title, 523 523 'post_content' => __( 'This is the default page use like endpoint to the page submissions', 'buddyforms' ), 524 524 'post_status' => 'publish', 525 525 'post_type' => 'page', 526 526 'post_name' => sanitize_title( 'BuddyForms Submissions Page' ), 527 527 ); 528 528 // Insert the page into the database 529 529 $page_id = wp_insert_post( $preview_post ); 530 530 } else { 531 531 $page_id = $submissions_page->ID; 532 532 } 533 533 534 534 update_option( 'buddyforms_submissions_page', $page_id ); 535 535 update_option( 'buddyforms_first_path_after_install', 'edit.php?post_type=buddyforms&page=buddyforms_welcome_screen' ); 536 536 set_transient( '_buddyforms_welcome_screen_activation_redirect', true, 30 ); 537 537 $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' ); 538 538 $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' ); 539 539 $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' ); 540 540 $buddyforms_gdpr = array(); 541 541 $buddyforms_gdpr['templates']['registration'] = $registration_gdpr_template; 542 542 $buddyforms_gdpr['templates']['post'] = $post_gdpr_template; 543 543 $buddyforms_gdpr['templates']['contact'] = $contact_gdpr_template; 544 544 $buddyforms_gdpr['templates']['other'] = ''; 545 545 update_option( 'buddyforms_gdpr', $buddyforms_gdpr ); 546 546 } 547 547 548 548 /** 549 549 * Plugin deactivation 550 550 * 551 551 * @since 2.0 552 552 */ 553 553 function plugin_deactivation() 554 554 { 555 555 $buddyforms_page = get_option( 'buddyforms_preview_page', true ); 556 556 wp_delete_post( $buddyforms_page, true ); 557 557 delete_option( 'buddyforms_preview_page' ); 558 558 $buddyforms_page = get_option( 'buddyforms_submissions_page', true ); 559 559 wp_delete_post( $buddyforms_page, true ); 560 560 delete_option( 'buddyforms_submissions_page' ); 561 561 } 562 562 563 563 public static function error_log( $message ) 564 564 { 565 565 if ( !empty($message) ) { 566 566 error_log( 'buddyforms -- ' . $message ); 567 567 } 568 568 } 569 569 570 570 } 571 571 /** 572 572 * Create a helper function for easy SDK access. 573 573 * 574 574 * @return Freemius 575 575 */ 576 576 function buddyforms_core_fs() 577 577 { 578 578 global $buddyforms_core_fs ; 579 579 try { 580 580 $first_path = get_option( 'buddyforms_first_path_after_install' ); 581 581 582 582 if ( !isset( $buddyforms_core_fs ) ) { 583 583 // Include Freemius SDK. 584 584 require_once dirname( __FILE__ ) . '/includes/resources/freemius/start.php'; 585 585 $buddyforms_core_fs = fs_dynamic_init( array( 586 586 'id' => '391', 587 587 'slug' => 'buddyforms', 588 588 'type' => 'plugin', 589 589 'public_key' => 'pk_dea3d8c1c831caf06cfea10c7114c', 590 590 'is_premium' => false, 591 591 'has_addons' => true, 592 592 'has_paid_plans' => true, 593 593 'trial' => array( 594 594 'days' => 7, 595 595 'is_require_payment' => true, 596 596 ), 597 597 'has_affiliation' => 'selected', 598 598 'menu' => array( 599 599 'slug' => 'edit.php?post_type=buddyforms', 600 600 'first-path' => $first_path, 601 601 'support' => false, 602 602 'contact' => true, 603 603 'addons' => true, 604 604 'affiliation' => false, 605 605 ), 606 606 'bundle_license_auto_activation' => true, 607 607 'is_live' => true, 608 608 ) ); 609 609 } 610 610 611 611 // Signal that parent SDK was initiated. 612 612 do_action( 'buddyforms_core_fs_loaded' ); 613 613 } catch ( Freemius_Exception $e ) { 614 614 } 615 615 return $buddyforms_core_fs; 616 616 } 617 617 618 618 function buddyforms_php_version_admin_notice() 619 619 { 620 620 ?> 621 621 <div class="notice notice-error is-dismissible"> 622 622 <p><?php 623 623 esc_html_e( 'PHP Version Update Required!', 'buddyforms' ); 624 624 ?></p> 625 625 <p><?php 626 626 esc_html_e( 'You are using PHP Version ' . PHP_VERSION, 'buddyforms' ); 627 627 ?></p> 628 628 <p><?php 629 629 esc_html_e( 'Please make sure you have at least php version 5.3 installed.', 'buddyforms' ); 630 630 ?></p> 631 631 </div> 632 632 <?php 633 633 } 634 634 635 635 function activate_buddyform_at_plugin_loader() 636 636 { 637 637 // BuddyForms requires php version 5.3 or higher. 638 638 639 639 if ( PHP_VERSION < 5.3 ) { 640 640 add_action( 'admin_notices', 'buddyforms_php_version_admin_notice' ); 641 641 } else { 642 642 // Init BuddyForms. 643 643 $GLOBALS['buddyforms_new'] = new BuddyForms(); 644 644 // Init Freemius. 645 645 buddyforms_core_fs(); 646 646 // GDPR Admin Notice 647 647 buddyforms_core_fs()->add_filter( 'handle_gdpr_admin_notice', '__return_true' ); 648 648 } 649 649 650 650 } 651 651 652 652 activate_buddyform_at_plugin_loader(); 653 653 } -
buddyforms/trunk/assets/admin/js/admin.js
r3031945 r3046092 1 1 (function ($) { 2 2 $.getStylesheet = function (href) { 3 3 var $d = $.Deferred(); 4 4 var $link = $('<link/>', { 5 5 rel: 'stylesheet', 6 6 type: 'text/css', 7 7 href: href 8 8 }).appendTo('head'); 9 9 $d.resolve($link); 10 10 return $d.promise(); 11 11 }; 12 12 })(jQuery); 13 13 14 14 function createNewPageOpenModal(e) { 15 15 var dialog = jQuery('<div></div>').dialog({ 16 16 modal: true, 17 17 title: "Info", 18 18 open: function () { 19 19 var markup = 'Name your Page' + 20 20 '<input id="bf_create_page_name" type="text" value="">'; 21 21 jQuery(this).html(markup); 22 22 }, 23 23 buttons: { 24 24 'Add': function () { 25 25 var page_name = jQuery('#bf_create_page_name').val(); 26 26 dialog.html('<span class="spinner is-active"></span>'); 27 27 if (buddyformsGlobal) { 28 28 jQuery.ajax({ 29 29 type: 'POST', 30 30 dataType: "json", 31 31 url: buddyformsGlobal.admin_url, 32 32 data: { 33 33 "action": "buddyforms_new_page", 34 "page_name": page_name 34 "page_name": page_name, 35 "nonce": buddyformsGlobal.ajaxnonce // Add the nonce parameter 35 36 }, 36 37 success: function (data) { 37 38 if (data['error']) { 38 39 console.log(data['error']); 39 40 } else { 40 41 jQuery('#attached_page').append(jQuery('<option>', { 41 42 value: data['id'], 42 43 text: data['name'] 43 44 })); 44 45 jQuery('#attached_page').val(data['id']); 45 46 } 46 47 dialog.dialog("close"); 47 48 }, 48 49 error: function () { 49 50 dialog.dialog("close"); 50 51 } 51 52 }); 52 53 } 53 54 } 54 55 } 55 56 }); 56 57 e.preventDefault(); 57 58 return false; 58 59 } 59 60 60 61 // 61 62 // Helper function to get the post id from url 62 63 // 63 64 var bf_getUrlParameter = function bf_getUrlParameter(sParam) { 64 65 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 65 66 sURLVariables = sPageURL.split('&'), 66 67 sParameterName, 67 68 i; 68 69 69 70 for (i = 0; i < sURLVariables.length; i++) { 70 71 sParameterName = sURLVariables[i].split('='); 71 72 72 73 if (sParameterName[0] === sParam) { 73 74 return sParameterName[1] === undefined ? true : sParameterName[1]; 74 75 } 75 76 } 76 77 }; 77 78 78 79 // 79 80 // Generate a custom string to append to the field slug in case of duplicate 80 81 // 81 82 function buddyformsMakeFieldId() { 82 83 var text = ""; 83 84 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 84 85 85 86 for (var i = 0; i < 5; i++) 86 87 text += possible.charAt(Math.floor(Math.random() * possible.length)); 87 88 88 89 return text; 89 90 } 90 91 91 92 // 92 93 // Autofill empty slug's fields 93 94 // or append hashes to duplicate ones 94 95 // 95 96 function buddyformAutoFillEmptyOrDuplicateSlugs() { 96 97 var findFieldsSlugs = jQuery("#post input[name^='buddyforms_options[form_fields]'][name$='[slug]'][type!='hidden']"); 97 98 findFieldsSlugs.each(function () { 98 99 var fieldSlugs = jQuery(this); 99 100 if (!fieldSlugs.val()) { 100 101 console.log('empty field slug'); 101 102 var field_id = fieldSlugs.attr('data'); 102 103 var fieldContainer = jQuery('li#field_' + field_id); 103 104 if (fieldContainer && fieldContainer.length > 0) { 104 105 var fieldNameValue = fieldContainer.find('tr.use_as_slug input[name="buddyforms_options[form_fields][' + field_id + '][name]"]').val(); 105 106 if (fieldNameValue) { 106 107 var slugFromName = slug(fieldNameValue, {lower: false}); 107 108 fieldContainer.find('tr.slug' + field_id + ' input[name="buddyforms_options[form_fields][' + field_id + '][slug]"]').val(slugFromName); 108 109 } 109 110 } 110 111 } 111 112 findFieldsSlugs.each(function () { 112 113 if (jQuery(this).val() === fieldSlugs.val() && fieldSlugs.attr('name') !== jQuery(this).attr('name')) { 113 114 fieldSlugs.val(fieldSlugs.val() + '_' + buddyformsMakeFieldId()); 114 115 return false; 115 116 } 116 117 }); 117 118 }); 118 119 } 119 120 120 121 // 121 122 // Validate an email using regex 122 123 // 123 124 function buddyformsIsEmailOrShortcode(email) { 124 125 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})|\[(.*?)(\s.*?)?\]$/; 125 126 return regex.test(email); 126 127 } 127 128 128 129 // 129 130 // Validate multiples email address separated by coma 130 131 // 131 132 function buddyformsValidateMultiEmail(string) { 132 133 var result = true; 133 134 if (string) { 134 135 var isMulti = /[;,]+/.test(string); 135 136 if (isMulti) { 136 137 var values = string.split(/[;,]+/); 137 138 jQuery.each(values, function (index, email) { 138 139 result = buddyformsIsEmailOrShortcode(email.trim()); 139 140 if (!result) { 140 141 return result; 141 142 } 142 143 }); 143 144 } else { 144 145 result = buddyformsIsEmailOrShortcode(string); 145 146 if (!result) { 146 147 return result; 147 148 } 148 149 } 149 150 } else { 150 151 result = false; 151 152 } 152 153 153 154 return result; 154 155 } 155 156 156 157 // 157 158 // Validate notification email element 158 159 // 159 160 function buddyforms_validate_notifications_email(element) { 160 161 if (element) { 161 162 var value = jQuery(element).val(); 162 163 if (value) { 163 164 var isValid = buddyformsValidateMultiEmail(jQuery(element).val()); 164 165 if (!isValid) { 165 166 jQuery(element)[0].setCustomValidity('Invalid Email(s)'); 166 167 jQuery(element).addClass('bf-error'); 167 168 } else { 168 169 jQuery(element)[0].setCustomValidity(''); 169 170 jQuery(element).removeClass('bf-error'); 170 171 } 171 172 return isValid; 172 173 } else { 173 174 jQuery(element)[0].setCustomValidity(''); 174 175 jQuery(element).removeClass('bf-error'); 175 176 } 176 177 } 177 178 return true; 178 179 } 179 180 180 181 // 181 182 // Update form builder form elements list number 1,2,3,... 182 183 // 183 184 function bf_update_list_item_number() { 184 185 jQuery(".buddyforms_forms_builder ul").each(function () { 185 186 jQuery(this).children("li").each(function (t) { 186 187 jQuery(this).find("td.field_order .circle").first().html(t + 1) 187 188 }) 188 189 }) 189 190 } 190 191 191 192 // 192 193 // Helper Function to use dialog instead of alert 193 194 // 194 195 function bf_alert(alert_message) { 195 196 jQuery('<div></div>').dialog({ 196 197 modal: true, 197 198 title: "Info", 198 199 open: function () { 199 200 jQuery(this).html(alert_message); 200 201 }, 201 202 buttons: { 202 203 Ok: function () { 203 204 jQuery(this).dialog("close"); 204 205 } 205 206 } 206 207 }); 207 208 } 208 209 209 210 // Update ths list number 1,2,3,... for the mail trigger 210 211 function bf_update_list_item_number_mail() { 211 212 jQuery("#mailcontainer .bf_trigger_list_item").each(function (t) { 212 213 jQuery(this).find("td.field_order .circle").first().html(t + 1) 213 214 }) 214 215 } 215 216 216 217 function buddyforms_load_select2(element) { 217 218 jQuery.when(jQuery.getStylesheet(buddyformsGlobal.assets.select2_css), jQuery.getScript(buddyformsGlobal.assets.select2_js)) 218 219 .then(function () { 219 220 if (jQuery.fn.select2) { 220 221 element.select2({ 221 222 placeholder: "Select an option" 222 223 }); 223 224 } else { 224 225 console.log('BF-Error loading select2 assets, please contact support.'); 225 226 } 226 227 }, function () { 227 228 console.log('BF-Error loading select2 assets, please contact support.'); 228 229 }); 229 230 } 230 231 231 232 function setStatusDateFormat(arg){ 232 233 if(arg.checked){ 233 234 jQuery('.status-date-format').show(); 234 235 jQuery('.status-time-format').show(); 235 236 }else{ 236 237 jQuery('.status-date-format').hide(); 237 238 jQuery('.status-time-format').hide(); 238 239 } 239 240 240 241 } 241 242 242 243 // 243 244 // Helper Function to lode form element templates depend on the form type 244 245 // 245 246 function load_formbuilder_template(template, completeCallBack) { 246 247 var postTitle = jQuery('input#title'); 247 248 if (buddyformsGlobal) { 248 249 jQuery.ajax({ 249 250 type: 'POST', 250 251 dataType: "json", 251 252 url: buddyformsGlobal.admin_url, 252 253 data: { 253 254 "action": "buddyforms_form_template", 254 255 "template": template, 255 256 "title": postTitle.val() 256 257 }, 257 258 success: function (data) { 258 259 jQuery.each(data, function (i, val) { 259 260 switch (i) { 260 261 case 'formbuilder': 261 262 var form_builder = jQuery('.buddyforms_forms_builder'); 262 263 form_builder.replaceWith(val); 263 264 bf_update_list_item_number(); 264 265 jQuery(document.body).trigger({type: "buddyform:load_fields"}); 265 266 break; 266 267 case 'mail_notification': 267 268 jQuery('.buddyforms_accordion_notification').html(val); 268 269 jQuery('#no-trigger-mailcontainer').hide(); 269 270 270 271 tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + val['trigger_id']); 271 272 tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + val['trigger_id']); 272 273 273 274 bf_update_list_item_number_mail(); 274 275 275 276 break; 276 277 case 'form_setup': 277 278 jQuery.each(val, function (i2, form_setup) { 278 279 if (form_setup instanceof Object) { 279 280 jQuery.each(form_setup, function (form_setup_key, form_setup_option) { 280 281 var element; 281 282 if (form_setup_option instanceof Object) { 282 283 jQuery.each(form_setup_option, function (form_setup_key2, form_setup_option2) { 283 284 element = jQuery('[name="buddyforms_options[' + i2 + '][' + form_setup_key + '][' + form_setup_key2 + ']"]'); 284 285 buddyform_apply_template_to_element(element, form_setup_option2); 285 286 }); 286 287 } else { 287 288 element = jQuery('[name="buddyforms_options[' + i2 + '][' + form_setup_key + ']"]'); 288 289 buddyform_apply_template_to_element(element, form_setup_option); 289 290 } 290 291 }); 291 292 } 292 293 293 294 if (form_setup instanceof Array) { 294 295 buddyform_apply_template_to_element(jQuery('[name="buddyforms_options[' + i2 + '][]"]'), form_setup); 295 296 } else { 296 297 buddyform_apply_template_to_element(jQuery('[name="buddyforms_options[' + i2 + ']"]'), form_setup); 297 298 } 298 299 // Add Select2 Support 299 300 var adminSelect2 = jQuery(".bf-select2"); 300 301 if (adminSelect2.length > 0) { 301 302 buddyforms_load_select2(adminSelect2); 302 303 } 303 304 // Check the form type and only display the relevant form setup tabs 304 305 from_setup_form_type(jQuery('#bf-form-type-select').val()); 305 306 }); 306 307 break; 307 308 default: 308 309 bf_alert(val); 309 310 } 310 311 }); 311 312 tb_remove(); 312 313 if (!postTitle.val()) { 313 314 postTitle.val(buddyformsMakeFieldId()); 314 315 jQuery('input#title').focus(); 315 316 jQuery('#title-prompt-text').addClass('screen-reader-text'); 316 317 } 317 318 jQuery('[name="buddyforms_options[slug]"]').val(''); 318 319 }, 319 320 error: function () { 320 321 jQuery('<div></div>').dialog({ 321 322 modal: true, 322 323 title: "Info", 323 324 open: function () { 324 325 var markup = 'Something went wrong ;-(sorry)'; 325 326 jQuery(this).html(markup); 326 327 }, 327 328 buttons: { 328 329 Ok: function () { 329 330 jQuery(this).dialog("close"); 330 331 } 331 332 } 332 333 }); 333 334 }, 334 335 complete: function (jqXHR, textStatus) { 335 336 if (typeof completeCallBack === 'function') { 336 337 completeCallBack(jqXHR, textStatus); 337 338 } 338 339 } 339 340 }); 340 341 } 341 342 342 343 return false; 343 344 } 344 345 345 346 /** 346 347 * 347 348 * @param element 348 349 * @param value 349 350 */ 350 351 function buddyform_apply_template_to_element(element, value) { 351 352 if (element.length === 1) { 352 353 element.val(value).trigger('change'); 353 354 } else { 354 355 jQuery.each(element, function () { 355 356 var current = jQuery(this); 356 357 var current_val = current.val(); 357 358 current.prop("checked", (current_val === value)); 358 359 }); 359 360 } 360 361 } 361 362 362 363 // 363 364 // Process the form errors and scroll to it 364 365 // 365 366 function buddyforms_process_errors(errors) { 366 367 var form_with_no_errors = true; 367 368 if (errors.length > 0) { 368 369 jQuery.each(errors, function (index, current_error) { 369 370 if (!current_error.isValid) { 370 371 form_with_no_errors = false; 371 372 var type = current_error.type || 'accordion'; 372 373 switch (type) { 373 374 case 'title': 374 375 case 'content': 375 376 case 'textarea': 376 377 case 'text': 377 378 case 'post_excerpt': 378 379 case 'number': 379 380 case 'subject': 380 381 case 'message': { 381 382 jQuery("a[href='#validation-" + type + "-" + current_error.field_id + "']").trigger("click"); 382 383 var sortableBuddyformsElements = jQuery("#sortable_buddyforms_elements"); 383 384 sortableBuddyformsElements.accordion({ 384 385 active: false 385 386 }); 386 387 //Find the parent, the element id and expand it 387 388 jQuery(current_error.element).closest(".accordion-body.ui-accordion-content.collapse").addClass("ui-accordion-content-active").css("height", "auto"); 388 389 var li_id = jQuery(current_error.element).closest('li.bf_list_item'); 389 390 var li_position = jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(li_id)); 390 391 sortableBuddyformsElements.accordion({ 391 392 active: li_position 392 393 }); 393 394 jQuery('#buddyforms_form_setup').removeClass('closed'); 394 395 jQuery('#buddyforms_form_elements').removeClass('closed'); 395 396 break; 396 397 } 397 398 case 'accordion': { 398 399 var general_tab_id = jQuery(current_error.element).closest('div').parent().attr("id"); 399 400 jQuery("a[href='#" + general_tab_id + "']").trigger("click"); 400 401 401 402 //close all 402 403 var sortableBuddyformsElements = jQuery("#sortable_buddyforms_elements"); 403 404 sortableBuddyformsElements.accordion({ 404 405 active: false 405 406 }); 406 407 //Find the parent, the element id and expand it 407 408 jQuery(current_error.element).closest(".accordion-body.ui-accordion-content.collapse").addClass("ui-accordion-content-active").css("height", "auto"); 408 409 var li_id = jQuery(current_error.element).closest('li.bf_list_item'); 409 410 var li_position = jQuery('#sortable_buddyforms_elements li.bf_list_item').index(jQuery(li_id)); 410 411 sortableBuddyformsElements.accordion({ 411 412 active: li_position 412 413 }); 413 414 jQuery('#buddyforms_form_setup').removeClass('closed'); 414 415 jQuery('#buddyforms_form_elements').removeClass('closed'); 415 416 break; 416 417 } 417 418 case 'settings': { 418 419 if (!jQuery(current_error.element).is(':visible')) { 419 420 var currentId = jQuery(current_error.element).closest('div.tab-pane.ui-widget-content.ui-corner-bottom').attr('id'); 420 421 jQuery('.buddyform-nav-tabs li[aria-controls="' + currentId + '"]>a').trigger("click"); 421 422 } 422 423 break; 423 424 } 424 425 } 425 426 var element_name = jQuery(current_error.element).attr('name'); 426 427 jQuery("html, body").animate({scrollTop: jQuery('[name="' + element_name + '"]').offset().top - 250}, 1000); 427 428 return false; 428 429 } 429 430 }); 430 431 } 431 432 432 433 return form_with_no_errors; 433 434 } 434 435 435 436 var bfErrors = []; 436 437 437 438 function bfValidateRule(fieldId, option, elem, field_type) { 438 439 var element_min = jQuery("[field_id=" + fieldId + "_validation_minlength]")[0]; 439 440 var element_max = jQuery("[field_id=" + fieldId + "_validation_maxlength]")[0]; 440 441 if (element_max && element_min) { 441 442 442 443 var element_min_value = parseInt(element_min.value); 443 444 var element_max_value = parseInt(element_max.value); 444 445 var element_min_parent = jQuery(element_min).parent(); 445 446 var element_max_parent = jQuery(element_max).parent(); 446 447 //Celan previous messages 447 448 jQuery(element_min_parent).find("label#" + fieldId + "_validation_error_message").remove(); 448 449 jQuery(element_max_parent).find("label#" + fieldId + "_validation_error_message").remove(); 449 450 450 451 //If both min and max value are equals zero then skip validation 451 452 if (element_min_value === 0 && element_max_value === 0) { 452 453 bfErrors = bfErrors.filter(function (obj) { 453 454 return obj.field_id !== fieldId; 454 455 }); 455 456 } else { 456 457 457 458 if (option === "min") { 458 459 if (element_min_value < 0) { 459 460 bfErrors.push({isValid: false, element: element_min, type: field_type, field_id: fieldId}); 460 461 jQuery(element_min_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Value must be greater or equals zero.</label>"); 461 462 } else { 462 463 if (element_min_value >= element_max_value) { 463 464 //If the min length validation fails, add the error to the array 464 465 bfErrors.push({isValid: false, element: element_min, type: field_type, field_id: fieldId}); 465 466 //Add the label with the validation error message 466 467 jQuery(element_min_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Min value must be lesser than Max.</label>"); 467 468 } else { 468 469 //If the Validation for Min Length was succesful the remove the error from the array 469 470 bfErrors = bfErrors.filter(function (obj) { 470 471 return obj.field_id !== fieldId; 471 472 }); 472 473 } 473 474 } 474 475 475 476 } else if (option === "max") { 476 477 477 478 if (element_max_value < 0) { 478 479 bfErrors.push({isValid: false, element: element_max, type: field_type, field_id: fieldId}); 479 480 jQuery(element_max_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Value must be greater or equals zero.</label>"); 480 481 } else { 481 482 482 483 if (element_max_value <= element_min_value) { 483 484 //If the max length validation fails, add the error to the array 484 485 bfErrors.push({isValid: false, element: element_max, type: field_type, field_id: fieldId}); 485 486 //Add the label with the validation error message 486 487 jQuery(element_max_parent).append("<label id='" + fieldId + "_validation_error_message' class='error'>Max value must be greater than Min.</label>"); 487 488 } else { 488 489 //If the Validation for Min Length was succesful the remove the error from the array 489 490 bfErrors = bfErrors.filter(function (obj) { 490 491 return obj.field_id !== fieldId; 491 492 }); 492 493 } 493 494 } 494 495 } 495 496 } 496 497 } 497 498 } 498 499 499 500 /** 500 501 * Copy element to clipboard 501 502 * 502 503 * @since 2.4.5 503 504 */ 504 505 function buddyformsCopyStringToClipboard(string) { 505 506 var el = document.createElement('textarea'); 506 507 el.value = string; 507 508 el.setAttribute('readonly', ''); 508 509 el.style.position = 'absolute'; 509 510 el.style.left = '-9999px'; 510 511 document.body.appendChild(el); 511 512 var selected = 512 513 document.getSelection().rangeCount > 0 513 514 ? document.getSelection().getRangeAt(0) 514 515 : false; 515 516 el.select(); 516 517 document.execCommand('copy'); 517 518 document.body.removeChild(el); 518 519 if (selected) { 519 520 document.getSelection().removeAllRanges(); 520 521 document.getSelection().addRange(selected); 521 522 } 522 523 } 523 524 524 525 /** 525 526 * Find the localize string 526 527 */ 527 528 function bf_trans(str) { 528 529 529 530 if (typeof str === 'string' 530 531 && typeof buddyformsGlobal !== 'undefined' 531 532 && typeof buddyformsGlobal.localize !== 'undefined' 532 533 && typeof buddyformsGlobal.localize.bf_trans !== 'undefined' 533 534 ) { 534 535 const localize_str = Object.values(buddyformsGlobal.localize.bf_trans).find(function(elm) { 535 536 return elm.msgid === str 536 537 }); 537 538 538 539 return (typeof localize_str !== 'undefined') ? localize_str.msgstr : str; 539 540 } 540 541 541 542 return str; 542 543 } 543 544 544 545 // 545 546 // Lets do some stuff after the document is loaded 546 547 // 547 548 jQuery(document).ready(function (jQuery) { 548 549 549 550 if (buddyformsGlobal) { 550 551 //Fix to show the form editor and hide all unrelated meta-boxes it suppose to only apply in certain pages 551 552 var currentScreen = buddyformsGlobal.current_screen || false; 552 553 var isAdmin = buddyformsGlobal.is_admin || false; 553 554 if (currentScreen && isAdmin) { 554 555 if ( 555 556 currentScreen.id === 'edit-buddyforms' || currentScreen.id === 'buddyforms' || 556 557 currentScreen.id === 'buddyforms_page_buddyforms_submissions' || currentScreen.id === 'buddyforms_page_buddyforms_settings' || 557 558 currentScreen.id === 'buddyforms_page_bf_add_ons' 558 559 ) { 559 560 var post = jQuery('#post'); 560 561 jQuery('#wpbody-content').html('<div class="wrap"></div>'); 561 562 jQuery('#wpbody-content .wrap').html(post); 562 563 563 564 jQuery(window).scrollTop(0); 564 565 565 566 // Remove all post box metaboxes except the buddyforms meta boxes 566 567 jQuery('div .postbox').not('.buddyforms-metabox, #submitdiv').remove(); 567 568 568 569 // Show the submit metabox 569 570 jQuery('#submitdiv').show(); 570 571 post.removeClass('hidden'); 571 572 } 572 573 } 573 574 } 574 575 575 576 576 577 // Add Select2 Support 577 578 var adminSelect2 = jQuery(".bf-select2"); 578 579 if (adminSelect2.length > 0) { 579 580 buddyforms_load_select2(adminSelect2); 580 581 } 581 582 582 583 // Prevent form submission if enter key is pressed on text fields 583 584 jQuery(document).on('keyup keypress', 'form input[type="text"]', function (e) { 584 585 if (e.which === 13) { 585 586 e.preventDefault(); 586 587 return false; 587 588 } 588 589 }); 589 590 590 591 /** 591 592 * Click on the button to preview a form type from the demo site 592 593 * @since 2.4.0 593 594 */ 594 595 jQuery(document.body).on('click', '.bf-preview', function () { 595 596 var key = jQuery(this).attr('data-key'); 596 597 var src = jQuery(this).attr('data-src'); 597 598 var iFrame = jQuery('#iframe-' + key); 598 599 if (iFrame.length > 0) { 599 600 iFrame.attr('src', src); 600 601 } 601 602 }); 602 603 603 604 /** 604 605 * Add Sortable to radiobutton, checkbox, dropdown and gdpr 605 606 * 606 607 * @since 2.4.1 607 608 */ 608 609 var sortableTable = jQuery('table.wp-list-table.element_field_table_sortable'); 609 610 if (sortableTable && sortableTable.length > 0) { 610 611 sortableTable.sortable({ 611 612 items: "tr.field_item" 612 613 }); 613 614 } 614 615 615 616 // Mail Notifications from email display only if selected 616 617 jQuery(document.body).on('change', '.bf_mail_from_name_multi_checkbox input', function () { 617 618 618 619 var val = jQuery(this).val(); 619 620 620 621 if (val === 'custom') { 621 622 jQuery(this).closest('.wp-list-table').find('.mail_from_name_custom').removeClass('hidden'); 622 623 } else { 623 624 jQuery(this).closest('.wp-list-table').find('.mail_from_name_custom').addClass('hidden'); 624 625 } 625 626 626 627 }); 627 628 628 629 // Mail Notifications from email display only if selected 629 630 jQuery(document.body).on('change', '.bf_mail_from_multi_checkbox input', function () { 630 631 631 632 var val = jQuery(this).val(); 632 633 633 634 if (val === 'custom') { 634 635 jQuery(this).closest('.wp-list-table').find('.mail_from_custom').removeClass('hidden'); 635 636 } else { 636 637 jQuery(this).closest('.wp-list-table').find('.mail_from_custom').addClass('hidden'); 637 638 } 638 639 639 640 }); 640 641 641 642 // Mail Notifications sent to display only if selected 642 643 jQuery(document.body).on('change', '.bf_sent_mail_to_multi_checkbox input', function () { 643 644 644 645 var val = jQuery(this).val(); 645 646 646 647 if (jQuery(this).is(':checked')) { 647 648 jQuery(this).closest('.wp-list-table').find('.mail_to_' + val + '_address').removeClass('hidden').prop('required', true); 648 649 } else { 649 650 jQuery(this).closest('.wp-list-table').find('.mail_to_' + val + '_address').addClass('hidden').prop('required', false); 650 651 } 651 652 652 653 }); 653 654 654 655 // Validate the form before publish 655 656 jQuery('#publish').on('click', function () { 656 657 657 658 var post_title = jQuery('[name="post_title"]'); 658 659 659 660 660 661 if (post_title.val() === '') { 661 662 post_title.removeClass('bf-ok'); 662 663 post_title.addClass('bf-error'); 663 664 bfErrors.push({isValid: false, element: post_title, type: 'title'}); 664 665 } else { 665 666 post_title.removeClass('bf-error'); 666 667 post_title.addClass('bf-ok'); 667 668 } 668 669 669 670 670 671 //Validate emails notifications 671 672 var mail_to_cc_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_cc_address]"]'); 672 673 jQuery.each(mail_to_cc_addresses, function (index, mail_to_cc_address) { 673 674 var result = buddyforms_validate_notifications_email(mail_to_cc_address); 674 675 bfErrors.push({isValid: result, element: mail_to_cc_address, type: 'settings'}); 675 676 }); 676 677 677 678 var mail_to_bcc_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_bcc_address]"]'); 678 679 jQuery.each(mail_to_bcc_addresses, function (index, mail_to_bcc_address) { 679 680 var result = buddyforms_validate_notifications_email(mail_to_bcc_address); 680 681 bfErrors.push({isValid: result, element: mail_to_bcc_address, type: 'settings'}); 681 682 }); 682 683 683 684 var mail_to_addresses = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_to_address]"]'); 684 685 jQuery.each(mail_to_addresses, function (index, mail_to_address) { 685 686 var result = buddyforms_validate_notifications_email(mail_to_address); 686 687 bfErrors.push({isValid: result, element: mail_to_address, type: 'settings'}); 687 688 }); 688 689 689 690 var mail_from = jQuery('input[name^="buddyforms_options[mail_submissions]"][name$="[mail_from_custom]"]'); 690 691 if (mail_from.length > 0) { 691 692 var result = buddyforms_validate_notifications_email(mail_from); 692 693 bfErrors.push({isValid: result, element: mail_from, type: 'settings'}); 693 694 } 694 695 695 696 //Fill and avoid duplicates of field slugs 696 697 buddyformAutoFillEmptyOrDuplicateSlugs(); 697 698 698 699 // traverse all the required elements looking for an empty one 699 700 jQuery("#post input[required]").each(function () { 700 701 // if the value is empty, that means that is invalid 701 702 var isValid = (jQuery(this).val() != ""); 702 703 703 704 if (isValid) { 704 705 jQuery(this).removeClass("bf-error"); 705 706 var element_name = jQuery(this).eq(0).attr('name'); 706 707 bfErrors = bfErrors.filter(function (obj) { 707 708 return obj.field_name !== element_name; 708 709 }); 709 710 710 711 711 712 } else { 712 713 var element_name = jQuery(this).eq(0).attr('name'); 713 714 bfErrors.push({isValid: isValid, element: jQuery(this)[0], type: 'accordion', field_name: element_name}); 714 715 jQuery(this).addClass("bf-error"); 715 716 return false; 716 717 } 717 718 }); 718 719 var validation_result = buddyforms_process_errors(bfErrors); 719 720 720 721 return validation_result; 721 722 722 723 }); 723 724 724 725 /** 725 726 * 726 727 * @since 2.5.26 727 728 */ 728 729 jQuery(document).on('click', 'button#btn-compile-custom', function (event) { 729 730 event.preventDefault(); 730 731 jQuery('#buddyforms_template_header_container').show('slow').css('display', 'flex'); 731 732 jQuery('#formbuilder-action-templates').show('slow'); 732 733 jQuery('#buddyforms_template_list_container').hide('fast'); 733 734 }); 734 735 735 736 /** 736 737 * 737 738 * @since 2.5.26 738 739 */ 739 740 jQuery(document).on('click', '#formbuilder-show-templates', function () { 740 741 jQuery('#buddyforms_template_header_container').hide('fast'); 741 742 jQuery('#buddyforms_template_list_container').show('slow'); 742 743 jQuery('#formbuilder-show-templates').hide(); 743 744 }); 744 745 745 746 // 746 747 // Remove form element form the form builder 747 748 // 748 749 jQuery(document).on('click', '.bf_delete_field', function () { 749 750 750 751 var del_id = jQuery(this).attr('id'); 751 752 var delete_str = bf_trans('Delete Permanently'); 752 753 753 754 if (confirm(delete_str)) 754 755 jQuery("#field_" + del_id).remove(); 755 756 756 757 return false; 757 758 }); 758 759 759 760 // 760 761 // Delete mail notification trigger 761 762 // 762 763 jQuery(document).on('click', '.bf_delete_trigger', function () { 763 764 var del_id = jQuery(this).attr('id'); 764 765 var delete_str = bf_trans('Delete Permanently'); 765 766 766 767 if (confirm(delete_str)) { 767 768 jQuery("#trigger" + del_id).remove(); 768 769 jQuery(".trigger" + del_id).remove(); 769 770 } 770 771 return false; 771 772 }); 772 773 773 774 // 774 775 // Add new options to select, checkbox form element. The js will ad one more line for value and label 775 776 // 776 777 jQuery(document).on('click', '.bf_add_gdpr', function () { 777 778 778 779 if (buddyformsGlobal) { 779 780 var action = jQuery(this); 780 781 var gdpr_type = jQuery(this).attr('data-gdpr-type'); 781 782 782 783 var numItems = jQuery('#table_row_' + gdpr_type + '_select_options table.element_field_table_sortable tbody tr').size(); 783 784 784 785 var type = jQuery('#gdpr_option_type').val(); 785 786 786 787 var message = ''; 787 788 if (buddyformsGlobal.admin_text[type]) { 788 789 message = buddyformsGlobal.admin_text[type] 789 790 } 790 791 791 792 var error_message = ''; 792 793 if (buddyformsGlobal.admin_text['error_message']) { 793 794 error_message = buddyformsGlobal.admin_text['error_message'] 794 795 } 795 796 796 797 numItems = numItems + 1; 797 798 jQuery('#table_row_' + gdpr_type + '_select_options table.element_field_table_sortable tbody').append( 798 799 '<tr class="field_item field_item_' + gdpr_type + '_' + numItems + '">' + 799 800 '<td><div class="dashicons dashicons-image-flip-vertical"></div></td>' + 800 801 '<td>' + 801 802 '<p><b>Agreement Text</b></p>' + 802 803 '<textarea rows="3" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][label]" cols="50">' + message + '</textarea>' + 803 804 '<p><b>Error Message</b></p>' + 804 805 '<textarea rows="3" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][error_message]" cols="50">' + error_message + '</textarea>' + 805 806 '</td>' + 806 807 '<td class="manage-column column-author">' + 807 808 '<div class="checkbox">' + 808 809 ' <label class="">' + 809 810 ' <input type="checkbox" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][checked][]" value="checked"><span>Checked</span>' + 810 811 ' </label>' + 811 812 '</div>' + 812 813 '<div class="checkbox">' + 813 814 ' <label class="">' + 814 815 ' <input type="checkbox" name="buddyforms_options[form_fields][' + gdpr_type + '][options][' + numItems + '][required][]" value="required"><span>Required</span>' + 815 816 ' </label>' + 816 817 '</div>' + 817 818 '</td>' + 818 819 '<td class="manage-column column-author">' + 819 820 '<a href="#" id="' + gdpr_type + '_' + numItems + '" class="bf_delete_input">Delete</a>' + 820 821 '</td>' + 821 822 '</tr>'); 822 823 return false; 823 824 } 824 825 }); 825 826 826 827 /** 827 828 * Reset option for multiple choice fields radio and checkboxes for backend 828 829 * 829 830 * @since 2.4.1 830 831 */ 831 832 jQuery(document.body).on('click', '.button.bf_reset_multi_input', function (event) { 832 833 event.preventDefault(); 833 834 var groupName = jQuery(this).attr('data-group-name'); 834 835 var fieldId = jQuery(this).attr('data-field-id'); 835 836 jQuery('input[name="buddyforms_options[form_fields][' + fieldId + '][default]"][value="' + groupName + '"]').attr('checked', false); 836 837 return false; 837 838 }); 838 839 839 840 /** 840 841 * Add new options to gdpr, checkbox form element. The js will add one more line for value and label 841 842 * 842 843 * @since 2.4.1 843 844 */ 844 845 jQuery(document).on('click', '.bf_add_input', function () { 845 846 var action = jQuery(this); 846 847 var args = action.attr('href').split("/"); 847 848 var numItems = jQuery('#table_row_' + args[0] + '_select_options table.element_field_table_sortable tbody tr').size(); 848 849 849 850 numItems = numItems + 1; 850 851 jQuery('#table_row_' + args[0] + '_select_options table.element_field_table_sortable tbody').append( 851 852 '<tr class="field_item field_item_' + args[0] + '_' + numItems + '">' + 852 853 '<td><div class="dashicons dashicons-image-flip-vertical"></div></td>' + 853 854 '<td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields][' + args[0] + '][options][' + numItems + '][label]"></td>' + 854 855 '<td><input class="field-sortable" required="required" type="text" name="buddyforms_options[form_fields][' + args[0] + '][options][' + numItems + '][value]"></td>' + 855 856 '<td class="manage-column column-default"><p>Save the Form</p></td>' + 856 857 '<td class="manage-column column-default"><a href="#" id="' + args[0] + '_' + numItems + '" class="bf_delete_input">Delete</a></td>' + 857 858 '</tr>'); 858 859 return false; 859 860 }); 860 861 861 862 // 862 863 // Remove an option from a select or checkbox 863 864 // 864 865 jQuery(document).on('click', '.bf_delete_input', function () { 865 866 var del_id = jQuery(this).attr('id'); 866 867 var delete_str = bf_trans('Delete Permanently'); 867 868 868 869 if (confirm(delete_str)) 869 870 jQuery(".field_item_" + del_id).remove(); 870 871 return false; 871 872 }); 872 873 873 874 bf_update_list_item_number(); 874 875 875 876 jQuery(document).on('mousedown', '.bf_list_item', function () { 876 877 itemList = jQuery(this).closest('.sortable').sortable({ 877 878 update: function (event, ui) { 878 879 bf_update_list_item_number(); 879 880 } 880 881 }); 881 882 }); 882 883 883 884 bf_update_list_item_number_mail(); 884 885 885 886 // 886 887 // Trigger the email test notification 887 888 // 888 889 jQuery(document).on('click', '.bf_test_trigger:not(disabled)', function(e) { 889 890 e.preventDefault(); 890 891 e.stopPropagation(); 891 892 var test_id = jQuery(this).attr('id'); 892 893 var actionLink = jQuery(this); 893 894 actionLink.attr('disabled', true); 894 895 actionLink.text('Sending...'); 895 896 jQuery.ajax({ 896 897 type: 'POST', 897 898 dataType: 'json', 898 899 // contentType: 'application/x-www-form-urlencoded; utf-8', 899 900 url: buddyformsGlobal.admin_url, 900 901 data: { 901 902 'action': 'buddyforms_test_email', 902 903 'notification_id': test_id, 903 904 'form_slug': actionLink.attr('data-form-slug'), 904 905 'nonce': buddyformsGlobal.ajaxnonce, 905 906 }, 906 907 success: function(data) { 907 908 alert(data); 908 909 }, 909 910 error: function(request) { 910 911 alert(request.responseText); 911 912 }, 912 913 complete: function(){ 913 914 actionLink.removeAttr('disabled'); 914 915 actionLink.text('Test'); 915 916 } 916 917 }); 917 918 918 919 return false; 919 920 }); 920 921 921 922 // 922 923 // Add notification inside the wizard 923 924 // 924 925 jQuery(document).on('click', '#mail_notification_add_new', function () { 925 926 if (buddyformsGlobal) { 926 927 jQuery.ajax({ 927 928 type: 'POST', 928 929 dataType: "json", 929 930 url: buddyformsGlobal.admin_url, 930 931 data: { 931 932 "action": "buddyforms_new_mail_notification", 932 933 'form_slug': jQuery(this).attr('data-form-slug'), 933 934 'nonce': buddyformsGlobal.ajaxnonce, 934 935 }, 935 936 success: function (data) { 936 937 //console.log(data); 937 938 938 939 jQuery('#no-trigger-mailcontainer').hide(); 939 940 jQuery('#mailcontainer').append(data['html']); 940 941 941 942 tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + data['trigger_id']); 942 943 tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + data['trigger_id']); 943 944 944 945 bf_update_list_item_number_mail(); 945 946 946 947 jQuery(document.body).trigger({type: "buddyform:load_notifications"}); 947 948 } 948 949 }); 949 950 } 950 951 return false; 951 952 }); 952 953 953 954 // 954 955 // Add new mail notification 955 956 // 956 957 jQuery(document).on('click', '#post_status_mail_notification_add_new', function () { 957 958 var error = false; 958 959 var trigger = jQuery('.post_status_mail_notification_trigger select').val(); 959 960 960 961 if (!trigger) { 961 962 return false; 962 963 } 963 964 964 965 if (trigger === 'none') { 965 966 bf_alert('You have to select a trigger first.'); 966 967 return false; 967 968 } 968 969 969 970 // traverse all the required elements looking for an empty one 970 971 jQuery("#post-status-mail-container li.bf_trigger_list_item").each(function () { 971 972 if (jQuery(this).attr('id') == 'trigger' + trigger) { 972 973 bf_alert('Trigger already exists'); 973 974 error = true; 974 975 } 975 976 }); 976 977 977 978 if (error == true) 978 979 return false; 979 980 if (buddyformsGlobal) { 980 981 jQuery.ajax({ 981 982 type: 'POST', 982 983 url: buddyformsGlobal.admin_url, 983 984 dataType: "json", 984 985 data: { 985 986 "action": "buddyforms_new_post_status_mail_notification", 986 987 'form_slug': jQuery(this).attr('data-form-slug'), 987 988 'nonce': buddyformsGlobal.ajaxnonce, 988 989 "trigger": trigger 989 990 }, 990 991 success: function (data) { 991 992 if (data == 0) { 992 993 bf_alert('trigger already exists'); 993 994 return false; 994 995 } 995 996 jQuery('#no-trigger-post-status-mail-container').hide(); 996 997 jQuery('#post-status-mail-container').append(data['html']); 997 998 998 999 tinymce.execCommand('mceRemoveEditor', false, 'bf_mail_body' + data['trigger_id']); 999 1000 tinymce.execCommand('mceAddEditor', false, 'bf_mail_body' + data['trigger_id']); 1000 1001 1001 1002 bf_update_list_item_number_mail(); 1002 1003 1003 1004 jQuery(document.body).trigger({type: "buddyform:load_notifications"}); 1004 1005 } 1005 1006 }); 1006 1007 } 1007 1008 return false; 1008 1009 }); 1009 1010 1010 1011 // 1011 1012 // Permissions Section - select all roles and caps 1012 1013 // 1013 1014 jQuery(document).on('click', '.bf_check_all', function (e) { 1014 1015 1015 1016 if (buddyformsGlobal) { 1016 1017 1017 1018 jQuery('.bf_permissions :checkbox').not("[disabled]").prop('checked', true); 1018 1019 jQuery(this).removeClass(); 1019 1020 jQuery(this).addClass("bf_uncheck_all"); 1020 1021 jQuery(this).text(buddyformsGlobal.admin_text.uncheck); 1021 1022 } 1022 1023 e.preventDefault(); 1023 1024 }); 1024 1025 jQuery(document).on('click', '.bf_uncheck_all', function (e) { 1025 1026 1026 1027 if (buddyformsGlobal) { 1027 1028 1028 1029 jQuery('.bf_permissions :checkbox').not("[disabled]").prop('checked', false); 1029 1030 jQuery(this).removeClass(); 1030 1031 jQuery(this).addClass("bf_check_all"); 1031 1032 jQuery(this).text(buddyformsGlobal.admin_text.check); 1032 1033 1033 1034 } 1034 1035 e.preventDefault(); 1035 1036 }); 1036 1037 1037 1038 jQuery(document).on('click', '.bf_check', function (e) { 1038 1039 if (buddyformsGlobal) { 1039 1040 if (jQuery(".bf_permissions input[type='checkbox']").prop("checked")) { 1040 1041 jQuery(this).text(buddyformsGlobal.admin_text.check); 1041 1042 } else { 1042 1043 jQuery(this).text(buddyformsGlobal.admin_text.uncheck); 1043 1044 } 1044 1045 } 1045 1046 e.preventDefault(); 1046 1047 }); 1047 1048 1048 1049 1049 1050 jQuery('.bf_check').trigger('click'); 1050 1051 // 1051 1052 // #bf-create-page-modal 1052 1053 1053 1054 1054 1055 // 1055 1056 // At last let as remove elements added by other plugins we could not remove with the default functions. 1056 1057 // 1057 1058 1058 1059 // Remove all Visual Composer elements form BuddyForms View 1059 1060 // Only apply this action on BuddyForms Views 1060 1061 if ( window.location.search.indexOf( 'post_type=buddyforms' ) !== -1 ) { 1061 1062 jQuery('*[class^="vc_"]').remove(); 1062 1063 } 1063 1064 1064 1065 // 1065 1066 // Layout Meta-box related functions 1066 1067 // 1067 1068 if (buddyformsGlobal && buddyformsGlobal.post_type === 'buddyforms') { 1068 1069 jQuery(document).on('click', '#bf_load_layout_options', function () { 1069 1070 jQuery('.layout-spinner').addClass('is-active').show(); 1070 1071 var form_slug = jQuery('#bf_form_layout_select').val(); 1071 1072 jQuery.ajax({ 1072 1073 type: 'POST', 1073 1074 dataType: 'json', 1074 1075 url: buddyformsGlobal.admin_url, 1075 1076 data: { 1076 1077 'action': 'buddyforms_load_form_layout', 1077 1078 'form_slug': form_slug 1078 1079 }, 1079 1080 success: function (data) { 1080 1081 update_layout_options_screen(data); 1081 1082 } 1082 1083 }); 1083 1084 return false; 1084 1085 }); 1085 1086 1086 1087 jQuery(document).on('click', '#bf_reset_layout_options', function (event) { 1087 1088 jQuery('.layout-spinner-reset').addClass('is-active').show(); 1088 1089 jQuery.ajax({ 1089 1090 type: 'POST', 1090 1091 dataType: 'json', 1091 1092 url: buddyformsGlobal.admin_url, 1092 1093 data: { 1093 1094 'action': 'buddyforms_load_form_layout', 1094 1095 'form_slug': 'reset' 1095 1096 }, 1096 1097 success: function (data) { 1097 1098 update_layout_options_screen(data); 1098 1099 } 1099 1100 }); 1100 1101 return false; 1101 1102 }); 1102 1103 1103 1104 function update_layout_options_screen(data) { 1104 1105 jQuery('.layout-spinner').removeClass('is-active').hide(); 1105 1106 var layout_container = jQuery('#buddyforms_form_designer'); 1106 1107 if (layout_container.length > 0) { 1107 1108 jQuery.each(data, function (key, val) { 1108 1109 var item = jQuery(layout_container).find('input[name^="buddyforms_options[layout]"][name*="' + key + '"]'); 1109 1110 var itemColor = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][name$="[color]"]'); 1110 1111 var itemStyle = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][name$="[style]"][value="' + val.style + '"]'); 1111 1112 var type; 1112 1113 if (item || itemColor || itemStyle) { 1113 1114 type = item.attr('type'); 1114 1115 if ((typeof type === 'undefined' || !type) && itemColor.length > 0) { 1115 1116 type = itemColor.attr('type'); 1116 1117 } 1117 1118 } 1118 1119 1119 1120 if ('custom_css' === key) { 1120 1121 jQuery('#' + key).text(val); 1121 1122 } 1122 1123 1123 1124 if (item.length > 0 && type) { 1124 1125 switch (type) { 1125 1126 case 'text': 1126 1127 case 'number': 1127 1128 item.val(val || ''); 1128 1129 break; 1129 1130 case 'radio': 1130 1131 jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"][value="' + val + '"]').prop('checked', true).trigger('change'); 1131 1132 break; 1132 1133 case 'checkbox': 1133 1134 var currentItem = jQuery('input[name^="buddyforms_options[layout]"][name*="' + key + '"]'); 1134 1135 currentItem.prop('checked', (val && currentItem.val() === val)).trigger('change'); 1135 1136 break; 1136 1137 } 1137 1138 } 1138 1139 1139 1140 if (itemColor.length > 0) { 1140 1141 itemColor.val(val && val.color || '').trigger('change'); 1141 1142 } 1142 1143 1143 1144 if (itemStyle.length > 0) { 1144 1145 itemStyle.prop('checked', val && val.style).trigger('change'); 1145 1146 } 1146 1147 }); 1147 1148 } 1148 1149 } 1149 1150 } 1150 1151 1151 1152 jQuery(document).on('change', 'select.captcha-version', function (e) { 1152 1153 var selectedVersion = jQuery(this).val(); 1153 1154 if(selectedVersion === 'v3') { 1154 1155 jQuery('tr[id$="_captcha_v3_action"]').show(); 1155 1156 jQuery('tr[id$="_captcha_v3_score"]').show(); 1156 1157 jQuery('.bf_hide_captcha_v2_options').show(); 1157 1158 } else { 1158 1159 jQuery('tr[id$="_captcha_v3_action"]').hide(); 1159 1160 jQuery('tr[id$="_captcha_v3_score"]').hide(); 1160 1161 jQuery('.bf_hide_captcha_v2_options').hide(); 1161 1162 } 1162 1163 }); 1163 1164 1164 1165 jQuery(document).on('click', '.bf-ready-to-copy', function (e) { 1165 1166 e.preventDefault(); 1166 1167 e.stopPropagation(); 1167 1168 var currentElement = jQuery(this); 1168 1169 if (currentElement.is('input')) { 1169 1170 buddyformsCopyStringToClipboard(currentElement.val()); 1170 1171 } else { 1171 1172 var parentHeader = jQuery(this).closest('.accordion-heading-options'); 1172 1173 var accordionBody = parentHeader.parent().find('.accordion-body'); 1173 1174 accordionBody.removeClass('ui-accordion-content-active').hide(); 1174 1175 buddyformsCopyStringToClipboard(currentElement.text()); 1175 1176 accordionBody.addClass('ui-accordion-content-active'); 1176 1177 } 1177 1178 return false; 1178 1179 }); 1179 1180 1180 1181 1181 1182 1182 1183 }); -
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'])} 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)),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}})} 3 3 else{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')}4 else{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')} 5 5 else{jQuery(e)[0].setCustomValidity('');jQuery(e).removeClass('bf-error')};return t} 6 6 else{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'})} 7 7 else{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>')}8 else{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)})} 9 else{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)} 10 else{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')} 11 else{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})} 12 else{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>')} 13 else{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>')} 14 14 else{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')}15 else 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>')} 16 else{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>')} 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 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')} 18 18 else{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')} 19 19 else{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)} 20 20 else{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})});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 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})} 22 else{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)} 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 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()} 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 o=e(this);if(o.is('input')){buddyformsCopyStringToClipboard(o.val())} 25 else{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 1 1 function uploadHandler() { 2 2 var submitButtons, submitButton, 3 3 existingHtmlInsideSubmitButton = ''; 4 4 5 5 function getFirstSubmitButton(submitButtons) { 6 6 submitButton = jQuery.map(submitButtons, function (element) { 7 7 return (jQuery(element).attr('type') === 'submit' && jQuery(element).hasClass('bf-submit')) ? jQuery(element) : null; 8 8 })[0]; 9 9 existingHtmlInsideSubmitButton = submitButton.html(); 10 10 } 11 11 12 12 function buildDropZoneFieldsOptions() { 13 13 jQuery(".upload_field").each(function () { 14 14 var current = jQuery(this); 15 15 var clickeable = (current.attr('page') !== 'buddyforms_submissions'); 16 16 var maxFileSize = current.attr('file_limit'); 17 17 var acceptedFiles = current.attr('accepted_files'); 18 18 var multipleFiles = current.attr('multiple_files'); 19 19 var entry = current.data('entry'); 20 20 var form_slug = current.attr('form-slug'); 21 21 jQuery('#buddyforms_form_' + form_slug).show(); 22 22 23 23 initSingleDropZone(current, current.attr('id'), maxFileSize, acceptedFiles, multipleFiles, clickeable, entry) 24 24 }) 25 25 } 26 26 27 27 function initSingleDropZone(current, id, maxSize, acceptedFiles, multipleFiles, clickeable, uploadFields) { 28 28 //Hidden field 29 29 var hidden_field = jQuery(current).find('input[type="text"][style*="hidden"]'); 30 30 //Container field 31 31 var dropzoneStringId = '#' + id; 32 32 //Set default values 33 33 if (buddyformsGlobal) { 34 34 var options = { 35 35 url: buddyformsGlobal.admin_url, 36 36 maxFilesize: maxSize, 37 37 parallelUploads: 1, 38 38 acceptedFiles: acceptedFiles, 39 39 maxFiles: multipleFiles, 40 40 clickable: clickeable, 41 41 addRemoveLinks: clickeable, 42 42 init: function () { 43 43 this.on('queuecomplete', function () { 44 44 current.removeClass('error'); 45 45 }); 46 46 this.on('addedfile', function () { 47 47 DropZoneAddedFile(dropzoneStringId); 48 48 }); 49 49 this.on('success', function (file, response) { 50 50 DropZoneSuccess(file, response, hidden_field); 51 51 }); 52 52 this.on('error', DropZoneError); 53 53 this.on('sending', DropZoneSending); 54 54 this.on('sendingmultiple', DropZoneSending); 55 55 this.on('complete', DropZoneComplete); 56 56 this.on('completemultiple', DropZoneComplete); 57 57 this.on('removedfile', function (file) { 58 58 DropZoneRemovedFile(file, hidden_field); 59 59 }); 60 60 61 61 if (uploadFields) { 62 62 for (var key in uploadFields) { 63 63 if (key) { 64 64 var mockFile = { 65 65 name: uploadFields[key]['name'], 66 66 size: uploadFields[key]['size'], 67 67 url: uploadFields[key]['url'], 68 68 attachment_id: uploadFields[key]['attachment_id'], 69 69 }; 70 70 this.emit('addedfile', mockFile); 71 71 this.emit('thumbnail', mockFile, mockFile.url); 72 72 this.emit('complete', mockFile); 73 73 this.files.push(mockFile); 74 74 } 75 75 } 76 76 } 77 77 }, 78 78 //Language options 79 79 dictMaxFilesExceeded: buddyformsGlobal.localize.upload.dictMaxFilesExceeded || "You can not upload any more files.", 80 80 dictRemoveFile: buddyformsGlobal.localize.upload.dictRemoveFile || "Remove file", 81 81 dictCancelUploadConfirmation: buddyformsGlobal.localize.upload.dictCancelUploadConfirmation || "Are you sure you want to cancel this upload?", 82 82 dictCancelUpload: buddyformsGlobal.localize.upload.dictCancelUpload || "Cancel upload", 83 83 dictResponseError: buddyformsGlobal.localize.upload.dictResponseError || "Server responded with {{statusCode}} code.", 84 84 dictInvalidFileType: buddyformsGlobal.localize.upload.dictInvalidFileType || "You can't upload files of this type.", 85 85 dictFileTooBig: buddyformsGlobal.localize.upload.dictFileTooBig || "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.", 86 86 dictFallbackMessage: buddyformsGlobal.localize.upload.dictFallbackMessage || "Your browser does not support drag'n'drop file uploads.", 87 87 dictDefaultMessage: buddyformsGlobal.localize.upload.dictDefaultMessage || "Drop files here to upload", 88 88 }; 89 89 jQuery(current).dropzone(options); 90 90 } 91 91 } 92 92 93 93 function DropZoneComplete() { 94 94 enabledSubmitButtons(); 95 95 } 96 96 97 97 function DropZoneAddedFile(dropzoneContainer) { 98 98 jQuery(dropzoneContainer).find("label[class*='error']").text(""); 99 99 jQuery(dropzoneContainer).find('.dz-progress').hide() 100 100 } 101 101 102 102 function DropZoneSending(file, xhr, formData) { 103 103 disableSubmitButtons(true); 104 var form_slug = jQuery('#form_slug').val(); 104 105 formData.append('action', 'handle_dropped_media'); 105 106 formData.append('nonce', buddyformsGlobal.ajaxnonce); 107 formData.append('form_slug', form_slug ); 106 108 } 107 109 108 110 function DropZoneSuccess(file, response, currentField) { 109 111 file.previewElement.classList.add("dz-success"); 110 112 file['attachment_id'] = response; // push the id for future reference 111 113 var ids = jQuery(currentField).val() + ',' + response; 112 114 var idsFormat = ""; 113 115 if (ids[0] === ',') { 114 116 idsFormat = ids.substring(1, ids.length); 115 117 } else { 116 118 idsFormat = ids; 117 119 } 118 120 jQuery(currentField).attr('value', idsFormat); 119 121 } 120 122 121 123 function DropZoneError(file, response) { 122 124 file.previewElement.classList.add("dz-error"); 123 125 jQuery(file.previewElement).find('div.dz-error-message>span').text(response); 124 126 enabledSubmitButtons(); 125 127 } 126 128 127 129 function DropZoneRemovedFile(file, currentField) { 128 130 var attachment_id = file.attachment_id; 129 131 var ids = jQuery(currentField).val(); 130 132 var remainigIds = ids.replace(attachment_id, ""); 131 133 if (remainigIds[0] === ',') { 132 134 remainigIds = remainigIds.substring(1, ids.length); 133 135 } 134 136 var lastChar = remainigIds[remainigIds.length - 1]; 135 137 if (lastChar === ',') { 136 138 remainigIds = remainigIds.slice(0, -1); 137 139 } 138 140 jQuery(currentField).attr('value', remainigIds); 139 141 handleDeletedMedia(attachment_id); 140 142 } 141 143 142 144 function handleDeletedMedia(attachmentId) { 143 145 disableSubmitButtons(false); 144 146 jQuery.post(buddyformsGlobal.admin_url, { 145 147 action: 'handle_deleted_media', 146 148 media_id: attachmentId, 147 149 nonce: buddyformsGlobal.ajaxnonce 148 150 }, function (data) { 149 151 console.log(data); 150 152 }).always(function () { 151 153 enabledSubmitButtons(); 152 154 }); 153 155 } 154 156 155 157 function disableSubmitButtons(showButtonText) { 156 158 if (buddyformsGlobal) { 157 159 if (submitButtons.length > 0) { 158 160 showButtonText = !!(showButtonText); 159 161 submitButtons.attr("disabled", "disabled"); 160 162 if (showButtonText) { 161 163 submitButton.html(buddyformsGlobal.localize.upload.submitButton || 'Upload in progress'); // todo need il18n 162 164 } 163 165 } 164 166 } 165 167 } 166 168 167 169 function checkToEnableSubmit() { 168 170 var result = true; 169 171 jQuery(".upload_field").each(function () { 170 172 var currentDropZone = jQuery(this)[0].dropzone; 171 173 if (currentDropZone && currentDropZone.files.length > 0) { 172 174 var allFilesSuccessDiff = currentDropZone.files.filter(function (file) { 173 175 return file.status === Dropzone.UPLOADING; 174 176 }); 175 177 result = allFilesSuccessDiff.length === 0; 176 178 } 177 179 }); 178 180 179 181 return result; 180 182 } 181 183 182 184 function enabledSubmitButtons() { 183 185 if (submitButtons.length > 0 && checkToEnableSubmit()) { 184 186 submitButtons.removeAttr("disabled"); 185 187 submitButton.html(existingHtmlInsideSubmitButton); 186 188 } 187 189 } 188 190 189 191 return { 190 192 init: function () { 191 193 var uploadFields = jQuery(".upload_field"); 192 194 submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=submit]"); 193 195 if (submitButtons.length > 0) { 194 196 getFirstSubmitButton(submitButtons); 195 197 } 196 198 if (uploadFields.length > 0) { 197 199 buildDropZoneFieldsOptions(); 198 200 } 199 201 } 200 202 } 201 203 } 202 204 203 205 function validateAndUploadImage(field) { 204 206 205 207 var current = jQuery(field); 206 208 var id = current.attr("field-id"); 207 209 var accepted_files = current.attr("accepted_files"); 208 210 jQuery("#" + id + "_label").text(""); 209 211 jQuery("#" + id + "_image").attr('src', ""); 210 212 jQuery("#field_" + id).val(""); 211 213 var url = jQuery("#" + id + "_upload_from_url").val(); 212 214 213 215 if (checkURL(url)) { 214 216 215 217 jQuery("#" + id + "_upload_button").text("Uploading.."); 216 218 jQuery("#" + id + "_upload_button").attr('disabled', true); 217 219 var submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]"); 218 220 submitButtons.attr('disabled', true); 219 221 220 222 jQuery.ajax({ 221 223 url: buddyformsGlobal.admin_url, 222 224 type: 'post', 223 225 data: { 224 226 action: 'upload_image_from_url', 225 227 url: encodeURIComponent(url), 226 228 accepted_files: accepted_files, 227 229 id: id 228 230 }, 229 231 success: function (response) { 230 232 var result = JSON.parse(response); 231 233 if(result.status ==="OK"){ 232 234 jQuery("#" + id + "_image").attr('src', result.response); 233 235 jQuery("#" + id + "_image").attr('width', 300); 234 236 jQuery("#" + id + "_image").attr('height', 300); 235 237 jQuery("#field_" + id).val(result.attachment_id); 236 238 237 239 jQuery("#" + id + "_upload_button").text("Upload"); 238 240 jQuery("#" + id + "_upload_button").attr('disabled', false); 239 241 submitButtons.attr('disabled', false); 240 242 }else{ 241 243 if(result.status ==="FAILED"){ 242 244 jQuery("#" + id + "_label").text(result.response); 243 245 jQuery("#" + id + "_upload_button").text("Upload"); 244 246 jQuery("#" + id + "_upload_button").attr('disabled', false); 245 247 submitButtons.attr('disabled', false); 246 248 } 247 249 } 248 250 }, 249 251 error: function (error) { 250 252 var result = JSON.parse(error); 251 253 } 252 254 253 255 }); 254 256 255 257 } else { 256 258 jQuery("#" + id + "_label").text("Wrong Url Format"); 257 259 } 258 260 } 259 261 260 262 function checkURL(url) { 261 263 return (url.match(/\.(jpeg|jpg|gif|png)$/) != null); 262 264 } 263 265 264 266 var uploadImplementation = uploadHandler(); 265 267 jQuery(document).ready(function () { 266 268 uploadImplementation.init(); 267 269 }); 268 270 if(Dropzone) { 269 271 Dropzone.autoDiscover = false; 270 272 } -
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)} 2 2 else{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)} 3 3 else{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)}})} 4 4 else{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 1 1 jQuery(document).ready(function() { 2 2 var submitButtons = jQuery("div.form-actions button.bf-submit[type=submit], div.form-actions button.bf-draft[type=button]"); 3 3 var submitButton; 4 4 if (submitButtons.length > 0) { 5 5 submitButton = jQuery.map(submitButtons, function (element) { 6 6 return (jQuery(element).attr('type') === 'submit' && jQuery(element).hasClass('bf-submit')) ? jQuery(element) : null; 7 7 })[0]; 8 8 var existingHtmlInsideSubmitButton = submitButton.html(); 9 9 } 10 10 11 11 jQuery(".featured-image-uploader").each(function(index, value) { 12 12 var current = jQuery(this), 13 13 id = current.attr('id'), 14 14 max_file_size = current.attr('max_file_size'), 15 15 page = current.attr('page'), 16 16 uploadFields = current.data('entry'); 17 17 18 18 var clickeable = page !== 'buddyforms_submissions'; 19 19 var currentField = jQuery('#field_' + id); 20 20 21 21 if(buddyformsGlobal) { 22 22 23 23 // Fallback: 24 24 // Check if the form was already inizialize 25 25 // by a third party plugin or theme. 26 26 const dropzoneControl = current[0].dropzone; 27 27 if (dropzoneControl) { 28 28 dropzoneControl.destroy(); 29 29 } 30 30 31 31 var myDropzone = new Dropzone("div#" + id, { 32 32 url: buddyformsGlobal.admin_url, 33 33 maxFilesize: max_file_size, 34 34 acceptedFiles: 'image/*', 35 35 maxFiles: 1, 36 36 clickable: clickeable, 37 37 addRemoveLinks: clickeable, 38 38 init: function () { 39 39 this.on('complete', function () { 40 40 if (submitButtons.length > 0) { 41 41 submitButtons.removeAttr("disabled"); 42 42 submitButton.html(existingHtmlInsideSubmitButton); 43 43 } 44 44 }); 45 45 this.on('addedfile', function () { 46 46 jQuery("#field_" + id + "-error").text(""); 47 47 if (this.files.length > 1) { 48 48 this.removeFile(this.files[0]); 49 49 } 50 50 if (submitButtons.length > 0) { 51 51 submitButtons.attr("disabled", "disabled"); 52 52 submitButton.html(buddyformsGlobal.localize.upload.submitButton || 'Upload in progress'); 53 53 } 54 54 }); 55 55 56 56 this.on('sending', function (file, xhr, formData) { 57 var form_slug = jQuery('#form_slug').val(); 57 58 formData.append('action', 'handle_dropped_media'); 58 59 formData.append('nonce', buddyformsGlobal.ajaxnonce); 60 formData.append('form_slug', form_slug ); 59 61 }); 60 62 61 63 this.on('success', function (file, response) { 62 64 current.removeClass('error'); 63 65 file.previewElement.classList.add("dz-success"); 64 66 file['attachment_id'] = response; // push the id for future reference 65 67 var ids = currentField.val() + ',' + response; 66 68 var idsFormat = ""; 67 69 if (ids[0] === ',') { 68 70 idsFormat = ids.substring(1, ids.length); 69 71 } else { 70 72 idsFormat = ids; 71 73 } 72 74 currentField.val(idsFormat); 73 75 }); 74 76 75 77 this.on('error', function (file, response) { 76 78 file.previewElement.classList.add("dz-error"); 77 79 jQuery(file.previewElement).find('div.dz-error-message>span').text(response); 78 80 if (submitButtons.length > 0) { 79 81 submitButtons.removeAttr("disabled"); 80 82 submitButton.html(existingHtmlInsideSubmitButton); 81 83 } 82 84 }); 83 85 this.on('removedfile', function (file) { 84 86 var attachment_id = file.attachment_id; 85 87 var ids = currentField.val(); 86 88 var remainigIds = ids.replace(attachment_id, ""); 87 89 if (remainigIds[0] === ',') { 88 90 remainigIds = remainigIds.substring(1, ids.length); 89 91 } 90 92 var lastChar = remainigIds[remainigIds.length - 1]; 91 93 if (lastChar === ',') { 92 94 remainigIds = remainigIds.slice(0, -1); 93 95 } 94 96 currentField.val(remainigIds); 95 97 submitButtons.attr("disabled", "disabled"); 96 98 jQuery.post(buddyformsGlobal.admin_url, { 97 99 action: 'handle_deleted_media', 98 100 media_id: attachment_id, 99 101 nonce: buddyformsGlobal.ajaxnonce 100 102 }, function (data) { 101 103 console.log(data); 102 104 }).always(function () { 103 105 if (submitButtons.length > 0) { 104 106 submitButtons.removeAttr("disabled"); 105 107 submitButton.html(existingHtmlInsideSubmitButton); 106 108 } 107 109 }); 108 110 }); 109 111 110 112 if (uploadFields) { 111 113 for (var key in uploadFields) { 112 114 if (key) { 113 115 var mockFile = { 114 116 name: uploadFields[key]['name'], 115 117 size: uploadFields[key]['size'], 116 118 url: uploadFields[key]['url'], 117 119 attachment_id: uploadFields[key]['attachment_id'] 118 120 }; 119 121 this.emit('addedfile', mockFile); 120 122 this.emit('thumbnail', mockFile, mockFile.url); 121 123 this.emit('complete', mockFile); 122 124 this.files.push(mockFile); 123 125 } 124 126 } 125 127 } 126 128 }, 127 129 //Language options 128 130 dictMaxFilesExceeded: buddyformsGlobal.localize.upload.dictMaxFilesExceeded || "You can not upload any more files.", 129 131 dictRemoveFile: buddyformsGlobal.localize.upload.dictRemoveFile || "Remove file", 130 132 dictCancelUploadConfirmation: buddyformsGlobal.localize.upload.dictCancelUploadConfirmation || "Are you sure you want to cancel this upload?", 131 133 dictCancelUpload: buddyformsGlobal.localize.upload.dictCancelUpload || "Cancel upload", 132 134 dictResponseError: buddyformsGlobal.localize.upload.dictResponseError || "Server responded with {{statusCode}} code.", 133 135 dictInvalidFileType: buddyformsGlobal.localize.upload.dictInvalidFileType || "You can't upload files of this type.", 134 136 dictFileTooBig: buddyformsGlobal.localize.upload.dictFileTooBig || "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.", 135 137 dictFallbackMessage: buddyformsGlobal.localize.upload.dictFallbackMessage || "Your browser does not support drag'n'drop file uploads.", 136 138 dictDefaultMessage: buddyformsGlobal.localize.upload.dictDefaultMessage || "Drop files here to upload", 137 139 }); 138 140 } 139 141 140 142 }); 141 143 }); 142 144 143 145 if(Dropzone) { 144 146 Dropzone.autoDiscover = false; 145 147 } -
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)} 2 2 else{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 1 1 <?php 2 2 3 3 if ( ! defined( 'ABSPATH' ) ) { exit; } 4 4 5 5 6 6 use tk\GuzzleHttp\Client; 7 7 use tk\GuzzleHttp\Psr7\Request; 8 8 9 9 add_action( 'wp_ajax_buddyforms_post_types_taxonomies', 'buddyforms_post_types_taxonomies' ); 10 10 function buddyforms_post_types_taxonomies() { 11 11 12 12 if ( ! isset( $_POST['post_type'] ) ) { 13 13 echo 'false'; 14 14 die(); 15 15 } 16 16 17 17 $post_type = buddyforms_sanitize( '', wp_unslash( $_POST['post_type'] ) ); 18 18 $buddyforms_taxonomies = buddyforms_taxonomies( $post_type ); 19 19 20 20 $tmp = ''; 21 21 foreach ( $buddyforms_taxonomies as $name => $label ) { 22 22 $tmp .= '<option value="' . $name . '">' . $label . '</option>'; 23 23 } 24 24 25 25 echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() ); 26 26 die(); 27 27 28 28 } 29 29 30 30 add_action( 'wp_ajax_buddyforms_close_submission_default_page_notification', 'buddyforms_close_submission_default_page_notification' ); 31 31 /** 32 32 * @return bool 33 33 */ 34 34 function buddyforms_close_submission_default_page_notification() { 35 35 if ( ! ( is_array( $_POST ) && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 36 36 die(); 37 37 } 38 38 if ( ! isset( $_POST['action'] ) || wp_verify_nonce( $_POST['nonce'], 'fac_drop' ) === false || $_POST['action'] !== 'buddyforms_close_submission_default_page_notification' ) { 39 39 die(); 40 40 } 41 41 update_option( 'close_submission_default_page_notification', 1 ); 42 42 die(); 43 43 } 44 44 45 45 add_action( 'wp_ajax_buddyforms_update_taxonomy_default', 'buddyforms_update_taxonomy_default' ); 46 46 function buddyforms_update_taxonomy_default() { 47 47 48 48 if ( ! isset( $_POST['taxonomy'] ) || $_POST['taxonomy'] == 'none' ) { 49 49 $tmp = '<option value="none">' . __( 'First you need to select a Taxonomy to select the Taxonomy defaults', 'buddyforms' ) . '</option>'; 50 50 echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() ); 51 51 die(); 52 52 } 53 53 54 54 $taxonomy = buddyforms_sanitize( '', wp_unslash( $_POST['taxonomy'] ) ); 55 55 56 56 $args = array( 57 57 'orderby' => 'name', 58 58 'order' => 'ASC', 59 59 'hide_empty' => false, 60 60 'fields' => 'id=>name', 61 61 ); 62 62 63 63 $terms = get_terms( $taxonomy, $args ); 64 64 65 65 $tmp = '<option value="none">none</option>'; 66 66 foreach ( $terms as $key => $term_name ) { 67 67 $tmp .= '<option value="' . $key . '">' . $term_name . '</option>'; 68 68 } 69 69 70 70 echo wp_kses( $tmp, buddyforms_wp_kses_allowed_atts() ); 71 71 72 72 die(); 73 73 74 74 } 75 75 76 76 add_action( 'wp_ajax_buddyforms_new_page', 'buddyforms_new_page' ); 77 77 /** 78 78 * Create the holder page to be use as endpoint 79 79 */ 80 80 function buddyforms_new_page() { 81 81 82 if ( ! is_admin() ) { 82 check_ajax_referer( 'fac_drop', 'nonce' ); 83 84 if ( ! current_user_can( 'manage_options' ) ) { 83 85 return; 84 86 } 85 87 86 88 // Check if a title is entered 87 89 if ( empty( $_POST['page_name'] ) ) { 88 90 $json['error'] = __( 'Please enter a name', 'buddyforms' ); 89 91 echo json_encode( $json ); 90 92 die(); 91 93 } 92 94 93 95 // Create post object 94 96 $new_page = array( 95 97 'post_title' => wp_strip_all_tags( wp_unslash( $_POST['page_name'] ) ), 96 98 'post_content' => '', 97 99 'post_status' => 'publish', 98 100 'post_type' => 'page', 99 101 ); 100 102 101 103 // Insert the post into the database 102 104 $new_page = wp_insert_post( $new_page ); 103 105 104 106 // Check if page creation worked successfully 105 107 if ( is_wp_error( $new_page ) ) { 106 108 $json['error'] = $new_page; 107 109 } else { 108 110 $json['id'] = $new_page; 109 111 $json['name'] = wp_strip_all_tags( wp_unslash( $_POST['page_name'] ) ); 110 112 } 111 113 112 114 echo json_encode( $json ); 113 115 die(); 114 116 115 117 } 116 118 117 119 add_action( 'wp_ajax_buddyforms_url_builder', 'buddyforms_url_builder' ); 118 120 function buddyforms_url_builder() { 119 121 global $post; 120 122 $page_id = filter_var( wp_unslash( $_POST['attached_page'] ), FILTER_VALIDATE_INT ); 121 123 $form_slug = filter_var( wp_unslash( $_POST['form_slug'] ), FILTER_SANITIZE_STRING ); 122 124 $post = get_post( $page_id ); 123 125 124 126 if ( isset( $post->post_name ) ) { 125 127 $json['permalink'] = get_permalink( $page_id ); 126 128 $json['form_slug'] = $form_slug; 127 129 echo json_encode( $json ); 128 130 die(); 129 131 } 130 132 echo json_encode( 'none' ); 131 133 die(); 132 134 } 133 135 134 136 function buddyforms_custom_form_template_tracking() { 135 137 if ( ! ( is_array( $_POST ) && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 136 138 die(); 137 139 } 138 140 if ( ! isset( $_POST['action'] ) || ! isset( $_POST['nonce'] ) ) { 139 141 die(); 140 142 } 141 143 if ( ! wp_verify_nonce( $_POST['nonce'], 'fac_drop' ) ) { 142 144 die(); 143 145 } 144 146 buddyforms_track( 145 147 'selected-form-template', 146 148 array( 147 149 'template' => 'custom', 148 150 'type' => 'custom', 149 151 ) 150 152 ); 151 153 } 152 154 153 155 add_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 1 1 <?php 2 2 3 3 if ( !defined( 'ABSPATH' ) ) { 4 4 exit; 5 5 } 6 6 function buddyforms_metabox_form_setup() 7 7 { 8 8 global $post ; 9 9 if ( $post->post_type != 'buddyforms' ) { 10 10 return; 11 11 } 12 12 // Get the BuddyForms Options 13 13 $buddyform = get_post_meta( get_the_ID(), '_buddyforms_options', true ); 14 14 // Get all allowed post types 15 15 $post_types = buddyforms_get_post_types(); 16 16 // Get all allowed pages 17 17 $all_pages = buddyforms_get_all_pages( 'id' ); 18 18 // Get all values or set the default 19 19 $slug = $post->post_name; 20 20 $singular_name = ( isset( $buddyform['singular_name'] ) ? stripslashes( $buddyform['singular_name'] ) : '' ); 21 21 $after_submit = ( isset( $buddyform['after_submit'] ) ? $buddyform['after_submit'] : 'display_message' ); 22 22 $after_submission_page = ( isset( $buddyform['after_submission_page'] ) ? $buddyform['after_submission_page'] : 'false' ); 23 23 $after_submission_url = ( isset( $buddyform['after_submission_url'] ) ? $buddyform['after_submission_url'] : '' ); 24 24 $post_type = ( isset( $buddyform['post_type'] ) ? $buddyform['post_type'] : 'false' ); 25 25 $form_type = ( isset( $buddyform['form_type'] ) ? $buddyform['form_type'] : 'contact' ); 26 26 $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' ) ); 27 27 $after_submit_message_text = ( isset( $buddyform['after_submit_message_text'] ) ? $buddyform['after_submit_message_text'] : $message_text_default ); 28 28 $after_update_submit_message_text = ( isset( $buddyform['after_update_submit_message_text'] ) ? $buddyform['after_update_submit_message_text'] : buddyforms_default_message_on_update() ); 29 29 $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() ); 30 30 $attached_page = ( isset( $buddyform['attached_page'] ) ? $buddyform['attached_page'] : 'false' ); 31 31 $attached_page_div_id = ( isset( $buddyform['attached_page_div_id'] ) ? stripslashes( $buddyform['attached_page_div_id'] ) : '' ); 32 32 $status = ( isset( $buddyform['status'] ) ? $buddyform['status'] : 'false' ); 33 33 $comment_status = ( isset( $buddyform['comment_status'] ) ? $buddyform['comment_status'] : 'false' ); 34 34 $revision = ( isset( $buddyform['revision'] ) ? $buddyform['revision'] : 'false' ); 35 35 $admin_bar = ( isset( $buddyform['admin_bar'] ) ? $buddyform['admin_bar'] : 'false' ); 36 36 $edit_link = ( isset( $buddyform['edit_link'] ) ? $buddyform['edit_link'] : 'all' ); 37 37 $bf_ajax = ( isset( $buddyform['bf_ajax'] ) ? $buddyform['bf_ajax'] : false ); 38 38 $user_data = ( isset( $buddyform['user_data'] ) ? $buddyform['user_data'] : array( 39 39 'ipaddress', 40 40 'referer', 41 41 'browser', 42 42 'version', 43 43 'platform', 44 44 'reports', 45 45 'userAgent', 46 46 'enable_all' 47 47 ) ); 48 48 $list_posts_option = ( isset( $buddyform['list_posts_option'] ) ? $buddyform['list_posts_option'] : 'list_all_form' ); 49 49 $list_posts_style = ( isset( $buddyform['list_posts_style'] ) ? $buddyform['list_posts_style'] : 'list' ); 50 50 $local_storage = ( isset( $buddyform['local_storage'] ) ? $buddyform['local_storage'] : '' ); 51 51 $js_validation = ( isset( $buddyform['js_validation'] ) ? $buddyform['js_validation'] : '' ); 52 52 // Create The Form Array 53 53 $form_setup = array(); 54 54 // 55 55 // Submission 56 56 // 57 57 $element = new Element_Textbox( '<b>' . __( 'Form Slug', 'buddyforms' ) . '</b>', 'buddyforms_options[slug]', array( 58 58 'value' => $slug, 59 59 'shortDesc' => __( 'The Form Slug is used in shortcodes and other places, please take care changing this option.', 'buddyforms' ), 60 60 ) ); 61 61 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 62 62 $element->setAttribute( 'disabled', 'disabled' ); 63 63 } 64 64 $form_setup['Form Submission'][] = $element; 65 65 $element = new Element_Select( 66 66 '<b>' . __( 'After Submission', 'buddyforms' ) . '</b>', 67 67 'buddyforms_options[after_submit]', 68 68 array( 69 69 'display_message' => __( 'Display Message', 'buddyforms' ), 70 70 'display_form' => __( 'Display the Form and Message' ), 71 71 'display_page' => __( 'Display Page Contents', 'buddyforms' ), 72 72 'display_post' => __( 'Display the Post' ), 73 73 'display_posts_list' => __( 'Display the User\'s Post List' ), 74 74 'redirect' => __( 'Redirect to url', 'buddyforms' ), 75 75 ), 76 76 array( 77 77 'value' => $after_submit, 78 78 'class' => 'bf-after-submission-action', 79 79 'id' => 'bf-after-submission-action', 80 80 ) 81 81 ); 82 82 $element->setAttribute( 'data-hidden', 'display_page display_form display_message redirect' ); 83 83 $form_setup['Form Submission'][] = $element; 84 84 // After Submission Page 85 85 $element = new Element_Select( 86 86 '<b>' . __( 'After Submission Page', 'buddyforms' ) . '</b>', 87 87 'buddyforms_options[after_submission_page]', 88 88 $all_pages, 89 89 array( 90 90 'value' => $after_submission_page, 91 91 'shortDesc' => __( 'Select the Page from where the content gets displayed. Will redirected to the page if ajax is disabled, otherwise display the content.', 'buddyforms' ), 92 92 'class' => 'display_page', 93 93 ) 94 94 ); 95 95 $form_setup['Form Submission'][] = $element; 96 96 $form_setup['Form Submission'][] = new Element_Url( '<b>' . __( 'Redirect URL', 'buddyforms' ), 'buddyforms_options[after_submission_url]', array( 97 97 'value' => $after_submission_url, 98 98 'shortDesc' => __( 'Enter a valid URL', 'buddyforms' ), 99 99 'class' => 'redirect', 100 100 ) ); 101 101 $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'After Create Submission Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[after_submit_message_text]', array( 102 102 'rows' => 3, 103 103 'style' => 'width:100%', 104 104 'class' => 'display_message display_form', 105 105 'value' => $after_submit_message_text, 106 106 'id' => 'after_submit_message_text', 107 107 ) ); 108 108 $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'After Update Submission Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[after_update_submit_message_text]', array( 109 109 'rows' => 3, 110 110 'style' => 'width:100%', 111 111 'class' => 'display_message display_form', 112 112 'value' => $after_update_submit_message_text, 113 113 'id' => 'after_update_submit_message_text', 114 114 ) ); 115 115 $form_setup['Form Submission'][] = new Element_Textarea( '<b>' . __( 'Empty Submission List Message Text', 'buddyforms' ) . '</b>', 'buddyforms_options[empty_submit_list_message_text]', array( 116 116 'rows' => 3, 117 117 'style' => 'width:100%', 118 118 'value' => $empty_submit_list_message_text, 119 119 'id' => 'empty_submit_list_message_text', 120 120 'shortDesc' => __( 'This message is used when you have setup the option <b>Enable your site members to view their submissions</b>', 'buddyforms' ), 121 121 ) ); 122 122 $element = new Element_Checkbox( 123 123 '<b>' . __( 'AJAX', 'buddyforms' ) . '</b>', 124 124 'buddyforms_options[bf_ajax]', 125 125 array( 126 126 'bf_ajax' => __( 'Disable ajax form submission', 'buddyforms' ), 127 127 ), 128 128 array( 129 129 'shortDesc' => '', 130 130 'value' => $bf_ajax, 131 131 ) 132 132 ); 133 133 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 134 134 $element->setAttribute( 'disabled', 'disabled' ); 135 135 } 136 136 $form_setup['Form Submission'][] = $element; 137 137 $element = new Element_Checkbox( 138 138 '<b>' . __( 'Local Storage', 'buddyforms' ) . '</b>', 139 139 'buddyforms_options[local_storage]', 140 140 array( 141 141 'disable' => __( 'Disable Local Storage', 'buddyforms' ), 142 142 ), 143 143 array( 144 144 'shortDesc' => __( 'The form elements content is stored in the browser so it not gets lost if the tab gets closed by accident', 'buddyforms' ), 145 145 'value' => $local_storage, 146 146 ) 147 147 ); 148 148 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 149 149 $element->setAttribute( 'disabled', 'disabled' ); 150 150 } 151 151 $form_setup['Form Submission'][] = $element; 152 152 $element = new Element_Checkbox( 153 153 '<b>' . __( 'Javascript Validations', 'buddyforms' ) . '</b>', 154 154 'buddyforms_options[js_validation]', 155 155 array( 156 156 'disabled' => __( 'Disable JavaScript Validation', 'buddyforms' ), 157 157 ), 158 158 array( 159 159 'shortDesc' => __( 'By default the Javascript validations are enabled. Check to disable it.', 'buddyforms' ), 160 160 'value' => $js_validation, 161 161 ) 162 162 ); 163 163 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 164 164 $element->setAttribute( 'disabled', 'disabled' ); 165 165 } 166 166 $form_setup['Form Submission'][] = $element; 167 167 $public_submit_login = ( isset( $buddyform['public_submit_login'] ) ? $buddyform['public_submit_login'] : 'above' ); 168 168 $element = new Element_Select( 169 169 '<b>' . __( 'Enable Login on the form', 'buddyforms' ) . '</b>', 170 170 'buddyforms_options[public_submit_login]', 171 171 array( 172 172 'none' => __( 'None', 'buddyforms' ), 173 173 'above' => __( 'Above the Form', 'buddyforms' ), 174 174 'under' => __( 'Under the Form', 'buddyforms' ), 175 175 ), 176 176 array( 177 177 'value' => $public_submit_login, 178 178 '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' ), 179 179 'class' => 'public-submit-option', 180 180 ) 181 181 ); 182 182 $form_setup['Form Submission'][] = $element; 183 183 $element = new Element_Checkbox( 184 184 '<b>' . __( 'User Data', 'buddyforms' ) . '</b>', 185 185 'buddyforms_options[user_data]', 186 186 array( 187 187 'ipaddress' => __( 'Disable IP Address', 'buddyforms' ), 188 188 'referer' => __( 'Disable Referer', 'buddyforms' ), 189 189 'browser' => __( 'Disable Browser', 'buddyforms' ), 190 190 'version' => __( 'Disable Browser Version', 'buddyforms' ), 191 191 'platform' => __( 'Disable Platform', 'buddyforms' ), 192 192 'reports' => __( 'Disable Reports', 'buddyforms' ), 193 193 'userAgent' => __( 'Disable User Agent', 'buddyforms' ), 194 194 'enable_all' => '', 195 195 ), 196 196 array( 197 197 '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' ), 198 198 'value' => $user_data, 199 199 ) 200 200 ); 201 201 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 202 202 $element->setAttribute( 'disabled', 'disabled' ); 203 203 } 204 204 $form_setup['Form Submission'][] = $element; 205 205 $shortDesc_post_type = sprintf( 206 206 '<b>%s</b> <br><br><a target="_blank" href="#">%s</a>', 207 207 __( 'Use any POST TYPE with the PRO Version!', 'buddyforms' ), 208 208 __( 'Select a post type if you want to create posts from form submissions. ', 'buddyforms' ), 209 209 __( 'Read the Documentation', 'buddyforms' ) 210 210 ); 211 211 // 212 212 // Create Content 213 213 // 214 214 $element = new Element_Select( 215 215 '<b>' . __( 'Post Type', 'buddyforms' ) . '</b>', 216 216 'buddyforms_options[post_type]', 217 217 $post_types, 218 218 array( 219 219 'value' => $post_type, 220 220 'shortDesc' => $shortDesc_post_type, 221 221 'id' => 'form_post_type', 222 222 ) 223 223 ); 224 224 $form_setup['Create Content'][] = $element; 225 225 $element = new Element_Select( 226 226 '<b>' . __( 'Status', 'buddyforms' ) . '</b>', 227 227 'buddyforms_options[status]', 228 228 array( 'publish', 'pending', 'draft' ), 229 229 array( 230 230 'value' => $status, 231 231 'class' => 'bf_hide_if_post_type_none', 232 232 ) 233 233 ); 234 234 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 235 235 $element->setAttribute( 'disabled', 'disabled' ); 236 236 } 237 237 $form_setup['Create Content'][] = $element; 238 238 $element = new Element_Select( 239 239 '<b>' . __( 'Comment Status', 'buddyforms' ) . '</b>', 240 240 'buddyforms_options[comment_status]', 241 241 array( 'open', 'closed' ), 242 242 array( 243 243 'value' => $comment_status, 244 244 'class' => 'bf_hide_if_post_type_none', 245 245 ) 246 246 ); 247 247 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 248 248 $element->setAttribute( 'disabled', 'disabled' ); 249 249 } 250 250 $form_setup['Create Content'][] = $element; 251 251 $element = new Element_Checkbox( 252 252 '<b>' . __( 'Revision', 'buddyforms' ) . '</b>', 253 253 'buddyforms_options[revision]', 254 254 array( 255 255 'Revision' => __( 'Enable frontend revision control', 'buddyforms' ), 256 256 ), 257 257 array( 258 258 'value' => $revision, 259 259 'class' => 'bf_hide_if_post_type_none', 260 260 ) 261 261 ); 262 262 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 263 263 $element->setAttribute( 'disabled', 'disabled' ); 264 264 } 265 265 $form_setup['Create Content'][] = $element; 266 266 $element = new Element_Textbox( '<b>' . __( 'Singular Name', 'buddyforms' ), 'buddyforms_options[singular_name]', array( 267 267 'value' => $singular_name, 268 268 'shortDesc' => __( 'The Single Name is used by other plugins and Navigation ( Display Books, Add Book )', 'buddyforms' ), 269 269 'class' => 'bf_hide_if_post_type_none', 270 270 ) ); 271 271 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 272 272 $element->setAttribute( 'disabled', 'disabled' ); 273 273 } 274 274 $form_setup['Create Content'][] = $element; 275 275 // 276 276 // Edit Submissions 277 277 // 278 278 // Make sure to use the default submissions management page if non exist! 279 279 280 280 if ( !$attached_page || $attached_page == 'none' || $attached_page == 'false' ) { 281 281 $buddyforms_submissions_page = get_option( 'buddyforms_submissions_page' ); 282 282 if ( $buddyforms_submissions_page ) { 283 283 $attached_page = $buddyforms_submissions_page; 284 284 } 285 285 } 286 286 287 287 $siteurl = get_bloginfo( 'wpurl' ); 288 288 $attached_page_url = get_permalink( $attached_page ); 289 289 290 290 if ( !empty($attached_page_url) ) { 291 291 $siteurl_page_html = "<a style='color:#7ad03a;' id='siteurl_page' class='' href='" . $attached_page_url . "' target='_blank' >" . $attached_page_url . '</a>'; 292 292 $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>'; 293 293 $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>'; 294 294 } else { 295 295 $siteurl_page_html = $siteurl . '/' . $attached_page; 296 296 $siteurl_create_html = $siteurl . '/' . $attached_page . '/create/' . $slug; 297 297 $siteurl_edit_html = $siteurl . '/' . $attached_page . '/view/' . $slug; 298 298 } 299 299 300 300 $admin_email = get_option( 'admin_email' ); 301 301 // Attached Page 302 302 $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>' ); 303 303 $form_setup['Edit Submissions'][] = new Element_Select( 304 304 '<b>' . __( 'Enable site members to manage their submissions', 'buddyforms' ) . '</b>', 305 305 'buddyforms_options[attached_page]', 306 306 $all_pages, 307 307 array( 308 308 'value' => $attached_page, 309 309 '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' ) ), 310 310 'id' => 'attached_page', 311 311 'data-slug' => $slug, 312 312 ) 313 313 ); 314 314 $element = new Element_Textbox( '<b>' . __( "Dynamic Content by ID or Class", 'buddyforms' ) . '</b>', "buddyforms_options[attached_page_div_id]", array( 315 315 'value' => $attached_page_div_id, 316 316 'class' => 'bf_hide_if_attached_page_none', 317 317 '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' ), 318 318 ) ); 319 319 $form_setup['Edit Submissions'][] = $element; 320 320 $element = new Element_Checkbox( 321 321 '<b>' . __( 'Admin Bar', 'buddyforms' ) . '</b>', 322 322 'buddyforms_options[admin_bar]', 323 323 array( 324 324 'Admin Bar' => __( 'Add to Admin Bar', 'buddyforms' ), 325 325 ), 326 326 array( 327 327 'value' => $admin_bar, 328 328 'class' => 'bf_hide_if_attached_page_none', 329 329 ) 330 330 ); 331 331 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 332 332 $element->setAttribute( 'disabled', 'disabled' ); 333 333 } 334 334 $form_setup['Edit Submissions'][] = $element; 335 335 $element = new Element_Radio( 336 336 '<b>' . __( "Overwrite Frontend 'Edit Post' Link", 'buddyforms' ) . '</b>', 337 337 'buddyforms_options[edit_link]', 338 338 array( 339 339 'none' => 'None', 340 340 'all' => __( 'All Edit Links', 'buddyforms' ), 341 341 'my-posts-list' => __( 'Only in My Posts List', 'buddyforms' ), 342 342 ), 343 343 array( 344 344 'view' => 'vertical', 345 345 'value' => $edit_link, 346 346 'shortDesc' => __( 'The link to the backend will be changed to use the frontend editing.', 'buddyforms' ), 347 347 'class' => 'bf_hide_if_attached_page_none', 348 348 ) 349 349 ); 350 350 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 351 351 $element->setAttribute( 'disabled', 'disabled' ); 352 352 } 353 353 $form_setup['Edit Submissions'][] = $element; 354 354 $element = new Element_Radio( 355 355 '<b>' . __( 'List Posts Options', 'buddyforms' ) . '</b>', 356 356 'buddyforms_options[list_posts_option]', 357 357 array( 358 358 'list_all_form' => __( 'List all Author Posts created with this Form', 'buddyforms' ), 359 359 'list_all' => __( 'List all Author Posts of the PostType', 'buddyforms' ), 360 360 ), 361 361 array( 362 362 'value' => $list_posts_option, 363 363 'shortDesc' => '', 364 364 'class' => 'bf_hide_if_attached_page_none', 365 365 ) 366 366 ); 367 367 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 368 368 $element->setAttribute( 'disabled', 'disabled' ); 369 369 } 370 370 $form_setup['Edit Submissions'][] = $element; 371 371 $element = new Element_Radio( 372 372 '<b>' . __( 'List Style', 'buddyforms' ) . '</b>', 373 373 'buddyforms_options[list_posts_style]', 374 374 apply_filters( 'buddyforms_loop_template_name', array( 375 375 'list' => 'List', 376 376 'table' => 'Table', 377 377 ) ), 378 378 array( 379 379 'value' => $list_posts_style, 380 380 'shortDesc' => __( 'Do you want to list post in a ul li list or as table.', 'buddyforms' ), 381 381 'class' => 'bf_hide_if_attached_page_none', 382 382 ) 383 383 ); 384 384 if ( buddyforms_core_fs()->is_not_paying() && !buddyforms_core_fs()->is_trial() ) { 385 385 $element->setAttribute( 'disabled', 'disabled' ); 386 386 } 387 387 $form_setup['Edit Submissions'][] = $element; 388 388 // 389 389 // Display multisite options if network is enabled 390 390 // 391 391 392 392 if ( buddyforms_is_multisite() ) { 393 393 $sites_select = array(); 394 394 $sites = get_sites(); 395 395 foreach ( $sites as $site_id => $site ) { 396 396 $blog_details = get_blog_details( $site->blog_id, array( 'blog_id', 'blogname' ) ); 397 397 $sites_select[$blog_details->blog_id] = $blog_details->blogname; 398 398 } 399 399 $blog_id = ( isset( $buddyform['blog_id'] ) ? $buddyform['blog_id'] : '' ); 400 400 $element = new Element_Select( 401 401 '<b>' . __( 'Select a Blog', 'buddyforms' ) . '</b>', 402 402 'buddyforms_options[blog_id]', 403 403 $sites_select, 404 404 array( 405 405 'value' => $blog_id, 406 406 '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' ), 407 407 'id' => 'blog_id', 408 408 ) 409 409 ); 410 410 $form_setup['Network'][] = $element; 411 411 } 412 412 413 413 // Check if form elements exist and sort the form elements 414 414 if ( is_array( $form_setup ) ) { 415 415 $form_setup = buddyforms_sort_array_by_Array( $form_setup, array( __( 'Form Submission', 'buddyforms' ), __( 'Create Content', 'buddyforms' ), __( 'Edit Submissions', 'buddyforms' ) ) ); 416 416 } 417 417 // Display all Form Elements in a nice Tab UI and List them in a Table 418 418 ?> 419 419 <p> 420 420 <select id="bf-form-type-select" style="margin-left: 0 !important;" name="buddyforms_options[form_type]"> 421 421 <optgroup label="Form Type"> 422 422 <option <?php 423 423 selected( $form_type, 'contact' ); 424 424 ?> value="contact"><?php 425 425 esc_html_e( 'Contact Form', 'buddyforms' ); 426 426 ?></option> 427 427 <option <?php 428 428 selected( $form_type, 'registration' ); 429 429 ?> value="registration"><?php 430 430 esc_html_e( 'Registration Form', 'buddyforms' ); 431 431 ?></option> 432 432 <option <?php 433 433 selected( $form_type, 'post' ); 434 434 ?> value="post"><?php 435 435 esc_html_e( 'Post Form', 'buddyforms' ); 436 436 ?></option> 437 437 </optgroup> 438 438 </select> 439 439 </p> 440 440 <div class="tabbable buddyform-tabs-left"> 441 441 <ul class="nav buddyform-nav-tabs buddyform-nav-pills"> 442 442 <?php 443 443 $i = 0; 444 444 foreach ( $form_setup as $tab => $fields ) { 445 445 $tab_slug = sanitize_title( $tab ); 446 446 ?> 447 447 <li class="<?php 448 448 echo ( $i == 0 ? 'active' : '' ) ; 449 449 echo esc_attr( $tab_slug ) ; 450 450 ?>_nav"> 451 451 <a href="#<?php 452 452 echo esc_attr( $tab_slug ) ; 453 453 ?>" data-toggle="tab"><?php 454 454 echo esc_attr( $tab ) ; 455 455 ?></a> 456 456 </li> 457 457 <?php 458 458 $i++; 459 459 } 460 460 // Allow other plugins to add new sections 461 461 do_action( 'buddyforms_form_setup_nav_li_last' ); 462 462 ?> 463 463 464 464 </ul> 465 465 <div class="tab-content"> 466 466 <?php 467 467 $i = 0; 468 468 foreach ( $form_setup as $tab => $fields ) { 469 469 $tab_slug = sanitize_title( $tab ); 470 470 ?> 471 471 <div class="tab-pane <?php 472 472 echo ( $i == 0 ? 'active' : '' ) ; 473 473 ?>" 474 474 id="<?php 475 475 echo esc_attr( $tab_slug ) ; 476 476 ?>"> 477 477 <div class="buddyforms_accordion_general"> 478 478 <?php 479 479 // get all the html elements and add them above the settings 480 480 foreach ( $fields as $field_key => $field ) { 481 481 $type = $field->getAttribute( 'type' ); 482 482 if ( $type == 'html' ) { 483 483 $field->render(); 484 484 } 485 485 } 486 486 ?> 487 487 <table class="wp-list-table widefat posts fixed"> 488 488 <tbody> 489 489 <?php 490 490 foreach ( $fields as $field_key => $field ) { 491 491 $type = $field->getAttribute( 'type' ); 492 492 $class = $field->getAttribute( 'class' ); 493 493 $disabled = $field->getAttribute( 'disabled' ); 494 494 $classes = ( empty($class) ? '' : $class . ' ' ); 495 495 $classes .= ( empty($disabled) ? '' : 'bf-' . $disabled . ' ' ); 496 496 // If the form element is not html create it as table row 497 497 498 498 if ( $type != 'html' ) { 499 499 ?> 500 500 <tr class="<?php 501 501 echo esc_attr( $classes ) ; 502 502 ?>"> 503 503 <th scope="row"> 504 504 <label for="form_title"><?php 505 505 echo wp_kses( $field->getLabel(), buddyforms_wp_kses_allowed_atts() ) ; 506 506 ?></label> 507 507 </th> 508 508 <td> 509 509 <?php 510 510 echo wp_kses( $field->render(), buddyforms_wp_kses_allowed_atts() ) ; 511 511 ?> 512 512 <p class="description"><?php 513 echo wp_kses( $field->getShortDesc(), buddyforms_wp_kses_allowed_atts() ) ; 513 echo $field->getShortDesc() ; 514 // WPCS: XSS ok. 514 515 ?></p> 515 516 </td> 516 517 </tr> 517 518 <?php 518 519 } 519 520 520 521 } 521 522 ?> 522 523 </tbody> 523 524 </table> 524 525 </div> 525 526 </div> 526 527 <?php 527 528 $i++; 528 529 } 529 530 // Allow other plugins to hook there content for there nav into the tab content 530 531 do_action( 'buddyforms_form_setup_tab_pane_last' ); 531 532 ?> 532 533 </div> <!-- close .tab-content --> 533 534 </div> <!-- close .tabs --> 534 535 <?php 535 536 } -
buddyforms/trunk/includes/functions.php
r3031945 r3046092 1 1 <?php 2 2 3 3 if ( !defined( 'ABSPATH' ) ) { 4 4 exit; 5 5 } 6 6 /** 7 7 * Add the forms to the admin bar 8 8 * 9 9 * @package BuddyForms 10 10 * @since 0.3 beta 11 11 */ 12 12 add_action( 13 13 'wp_before_admin_bar_render', 14 14 'buddyforms_wp_before_admin_bar_render', 15 15 1, 16 16 2 17 17 ); 18 18 function buddyforms_wp_before_admin_bar_render() 19 19 { 20 20 global $wp_admin_bar, $buddyforms ; 21 21 if ( !$buddyforms ) { 22 22 return; 23 23 } 24 24 foreach ( $buddyforms as $key => $buddyform ) { 25 25 if ( !isset( $buddyform['post_type'] ) || $buddyform['post_type'] == 'none' ) { 26 26 continue; 27 27 } 28 28 if ( isset( $buddyform['admin_bar'][0] ) && $buddyform['post_type'] != 'none' && !empty($buddyform['attached_page']) ) { 29 29 30 30 if ( current_user_can( 'buddyforms_' . $key . '_create' ) ) { 31 31 $permalink = get_permalink( $buddyform['attached_page'] ); 32 32 $wp_admin_bar->add_menu( array( 33 33 'parent' => 'my-account', 34 34 'id' => 'my-account-' . $buddyform['slug'], 35 35 'title' => $buddyform['name'], 36 36 'href' => $permalink, 37 37 ) ); 38 38 $wp_admin_bar->add_menu( array( 39 39 'parent' => 'my-account-' . $buddyform['slug'], 40 40 'id' => 'my-account-' . $buddyform['slug'] . '-view', 41 41 'title' => __( 'View my ', 'buddyforms' ) . $buddyform['name'], 42 42 'href' => $permalink . '/view/' . $buddyform['slug'] . '/', 43 43 ) ); 44 44 $wp_admin_bar->add_menu( array( 45 45 'parent' => 'my-account-' . $buddyform['slug'], 46 46 'id' => 'my-account-' . $buddyform['slug'] . '-new', 47 47 'title' => __( 'New ', 'buddyforms' ) . $buddyform['singular_name'], 48 48 'href' => $permalink . 'create/' . $buddyform['slug'] . '/', 49 49 ) ); 50 50 } 51 51 52 52 } 53 53 } 54 54 } 55 55 56 56 /** 57 57 * Create the buddyforms post status array. 58 58 * Other Plugins use the filter buddyforms_get_post_status_array to add there post status to the options array 59 59 * 60 60 * @return array 61 61 */ 62 62 function buddyforms_get_post_status_array() 63 63 { 64 64 $status_array = array( 65 65 'publish' => __( 'Publish', 'buddyforms' ), 66 66 'pending' => __( 'Pending Review', 'buddyforms' ), 67 67 'draft' => __( 'Draft', 'buddyforms' ), 68 68 'future' => __( 'Schedule', 'buddyforms' ), 69 69 'private' => __( 'Privately Publish', 'buddyforms' ), 70 70 'trash' => __( 'Trash', 'buddyforms' ), 71 71 ); 72 72 return apply_filters( 'buddyforms_get_post_status_array', $status_array ); 73 73 } 74 74 75 75 /** 76 76 * Restricting users to view only media library items they upload. 77 77 * 78 78 * @package BuddyForms 79 79 * @since 0.5 beta 80 80 */ 81 81 add_action( 'pre_get_posts', 'buddyforms_restrict_media_library' ); 82 82 /** 83 83 * @param $wp_query_obj 84 84 */ 85 85 function buddyforms_restrict_media_library( $wp_query_obj ) 86 86 { 87 87 global $current_user, $pagenow ; 88 88 if ( is_super_admin( $current_user->ID ) ) { 89 89 return; 90 90 } 91 91 if ( !is_a( $current_user, 'WP_User' ) ) { 92 92 return; 93 93 } 94 94 if ( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' ) { 95 95 return; 96 96 } 97 97 if ( !current_user_can( 'manage_media_library' ) ) { 98 98 $wp_query_obj->set( 'author', $current_user->ID ); 99 99 } 100 100 return; 101 101 } 102 102 103 103 /** 104 104 * Check if a subscriber have the needed rights to upload images and add this capabilities if needed. 105 105 * 106 106 * @package BuddyForms 107 107 * @since 0.5 beta 108 108 */ 109 109 add_action( 'init', 'buddyforms_allow_subscriber_uploads' ); 110 110 function buddyforms_allow_subscriber_uploads() 111 111 { 112 112 113 113 if ( current_user_can( 'subscriber' ) && !current_user_can( 'upload_files' ) ) { 114 114 $role = get_role( 'subscriber' ); 115 115 if ( !empty($role) ) { 116 116 $role->add_cap( 'upload_files' ); 117 117 } 118 118 } 119 119 120 120 } 121 121 122 122 /** 123 123 * Get the BuddyForms template directory. 124 124 * 125 125 * @return string 126 126 * @since 0.1 beta 127 127 * 128 128 * @uses apply_filters() 129 129 * @package BuddyForms 130 130 */ 131 131 function buddyforms_get_template_directory() 132 132 { 133 133 return apply_filters( 'buddyforms_get_template_directory', constant( 'BUDDYFORMS_TEMPLATE_PATH' ) ); 134 134 } 135 135 136 136 /** 137 137 * Locate a template 138 138 * 139 139 * @param $slug 140 140 * 141 141 * @param $form_slug 142 142 * 143 143 * @package BuddyForms 144 144 * @since 0.1 beta 145 145 * 146 146 * @since 2.3.1 147 147 */ 148 148 function buddyforms_locate_template( $slug, $form_slug = '' ) 149 149 { 150 150 global 151 151 $buddyforms, 152 152 $bp, 153 153 $the_lp_query, 154 154 $current_user, 155 155 $post_id 156 156 ; 157 157 // Backward compatibility @sinde 2.3.3. 158 158 if ( empty($form_slug) ) { 159 159 global $form_slug ; 160 160 } 161 161 // Get the current user so its not needed in the templates 162 162 $current_user = wp_get_current_user(); 163 163 // create the plugin template path 164 164 $template_path = BUDDYFORMS_TEMPLATE_PATH . 'buddyforms/' . $slug . '.php'; 165 165 /** 166 166 * Extend the template from 3rd party plugins 167 167 * 168 168 * @since 2.5.9 169 169 */ 170 170 $template_path = apply_filters( 171 171 'buddyforms_locate_template', 172 172 $template_path, 173 173 $slug, 174 174 $form_slug 175 175 ); 176 176 // Check if template exist in the child or parent theme and use this path if available 177 177 if ( $template_file = locate_template( "buddyforms/{$slug}.php", false, false ) ) { 178 178 $template_path = $template_file; 179 179 } 180 180 $empty_post_message = __( 'There were no posts found. Create your first post now! ', 'buddyforms' ); 181 181 if ( !empty($form_slug) ) { 182 182 183 183 if ( !empty($buddyforms[$form_slug]['empty_submit_list_message_text']) ) { 184 184 $empty_post_message = do_shortcode( $buddyforms[$form_slug]['empty_submit_list_message_text'] ); 185 185 } else { 186 186 $empty_post_message = do_shortcode( buddyforms_default_message_on_empty_submission_list() ); 187 187 } 188 188 189 189 } 190 190 // Do the include 191 191 include $template_path; 192 192 } 193 193 194 194 /** 195 195 * Retrieves the post excerpt. 196 196 * 197 197 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 198 198 * 199 199 * @return string Post excerpt. 200 200 * @since 2.5.17 201 201 */ 202 202 function buddyforms_get_the_excerpt( $post = null ) 203 203 { 204 204 $post = get_post( $post ); 205 205 if ( empty($post) ) { 206 206 return ''; 207 207 } 208 208 if ( post_password_required( $post ) ) { 209 209 return __( 'There is no excerpt because this is a protected post.' ); 210 210 } 211 211 return apply_filters( 'buddyforms_get_the_excerpt', $post->post_excerpt, $post ); 212 212 } 213 213 214 214 function buddyforms_granted_list_posts_style() 215 215 { 216 216 return apply_filters( 'buddyforms_granted_list_post_style', array( 'list', 'table' ) ); 217 217 } 218 218 219 219 // Display the WordPress Login Form 220 220 function buddyforms_wp_login_form( $hide = false, $form_slug = 'none' ) 221 221 { 222 222 // Get The Login Form 223 223 $form = buddyforms_get_wp_login_form( 224 224 $form_slug, 225 225 '', 226 226 array( 227 227 'caller' => 'template', 228 228 'redirect_url' => esc_url_raw( $_SERVER['REQUEST_URI'] ), 229 229 ), 230 230 $hide 231 231 ); 232 232 echo wp_kses( $form, buddyforms_wp_kses_allowed_atts() ) ; 233 233 } 234 234 235 235 /** 236 236 * Create the BuddyForms Login Form 237 237 * 238 238 * @param string $form_slug 239 239 * @param string $title 240 240 * @param array $args 241 241 * 242 242 * @param bool $hide 243 243 * 244 244 * @return string|boolean 245 245 */ 246 246 function buddyforms_get_wp_login_form( 247 247 $form_slug = 'none', 248 248 $title = '', 249 249 $args = array(), 250 250 $hide = false 251 251 ) 252 252 { 253 253 global $buddyforms, $wp ; 254 254 if ( is_admin() ) { 255 255 return false; 256 256 } 257 257 $caller = $redirect_url = $label_username = $label_password = $label_remember = $label_log_in = ''; 258 258 extract( shortcode_atts( array( 259 259 'caller' => 'direct', 260 260 'redirect_url' => home_url(), 261 261 'label_username' => __( 'Username or Email Address', 'buddyforms' ), 262 262 'label_password' => __( 'Password', 'buddyforms' ), 263 263 'label_remember' => __( 'Remember Me', 'buddyforms' ), 264 264 'label_log_in' => __( 'Log In', 'buddyforms' ), 265 265 ), $args ) ); 266 266 if ( empty($title) ) { 267 267 $title = __( 'You need to be logged in to view this page', 'buddyforms' ); 268 268 } 269 269 $hide_style = ( $hide ? 'style="display:none"' : '' ); 270 270 $wp_login_form = '<div class="bf-show-login-form" ' . $hide_style . '>'; 271 271 // include own login basic style 272 272 ob_start(); 273 273 require BUDDYFORMS_INCLUDES_PATH . '/resources/pfbc/Style/LoginStyle.php'; 274 274 $style = ob_get_clean(); 275 275 276 276 if ( !empty($style) ) { 277 277 $style = buddyforms_minify_css( $style ); 278 278 file_put_contents( dirname( BUDDYFORMS_INCLUDES_PATH ) . '/assets/css/bf-wp-login-form.css', $style ); 279 279 $login_form_css_url = BUDDYFORMS_ASSETS . 'css/bf-wp-login-form.css'; 280 280 wp_register_style( 'bf-wp-login-form-css', $login_form_css_url ); 281 281 wp_enqueue_style( 'bf-wp-login-form-css' ); 282 282 } 283 283 284 284 $wp_login_form .= '<h3>' . $title . '</h3>'; 285 285 286 286 if ( isset( $_GET['bf_login_error_redirect'] ) ) { 287 287 // Remove query strings form URL. 288 288 wp_add_inline_script( 'bf-wp-login-form-css', 'window.history.replaceState(null, null, window.location.pathname);', 'after' ); 289 289 $wp_login_form .= '<div class="bf-login-error">'; 290 290 foreach ( $_GET as $key => $value ) { 291 291 292 292 if ( strpos( $key, 'error_msg_' ) !== false ) { 293 293 $error = str_replace( 'Error: ', '<strong>Error: </strong>', $value ); 294 294 $wp_login_form .= $error . '<br />'; 295 295 } 296 296 297 297 } 298 298 $wp_login_form .= '</div>'; 299 299 } 300 300 301 301 if ( empty($redirect_url) ) { 302 302 $redirect_url = home_url(); 303 303 } 304 304 $login_settings = apply_filters( 'buddyforms_loggin_settings', array( 305 305 'echo' => false, 306 306 'form_id' => 'bf_loginform', 307 307 'redirect' => $redirect_url, 308 308 'id_username' => 'bf_user_name', 309 309 'id_password' => 'bf_user_pass', 310 310 'label_username' => $label_username, 311 311 'label_password' => $label_password, 312 312 'label_remember' => $label_remember, 313 313 'label_log_in' => $label_log_in, 314 314 ) ); 315 315 $wp_login_form .= wp_login_form( $login_settings ); 316 316 if ( $form_slug !== 'none' ) { 317 317 $wp_login_form = str_replace( '</form>', '<input type="hidden" name="form_slug" value="' . esc_attr( $form_slug ) . '"></form>', $wp_login_form ); 318 318 } 319 319 $wp_login_form = str_replace( '</form>', '<input type="hidden" name="caller" value="' . esc_attr( $caller ) . '"></form>', $wp_login_form ); 320 320 if ( isset( $wp->request ) ) { 321 321 $wp_login_form = str_replace( '</form>', '<input type="hidden" name="login_error_redirect" value="' . $wp->request . '"></form>', $wp_login_form ); 322 322 } 323 323 if ( $form_slug != 'none' ) { 324 324 325 325 if ( $buddyforms[$form_slug]['public_submit'] == 'registration_form' && $buddyforms[$form_slug]['logged_in_only_reg_form'] != 'none' ) { 326 326 $reg_form_slug = $buddyforms[$form_slug]['logged_in_only_reg_form']; 327 327 set_query_var( 'bf_form_slug', $reg_form_slug ); 328 328 $wp_login_form = do_shortcode( '[bf form_slug="' . $reg_form_slug . '"]' ); 329 329 } 330 330 331 331 } 332 332 $wp_login_form .= '</div>'; 333 333 $wp_login_form = apply_filters( 'buddyforms_wp_login_form', $wp_login_form ); 334 334 return $wp_login_form; 335 335 } 336 336 337 337 function buddyforms_wp_login_errors_redirect( $errors ) 338 338 { 339 339 global $pagenow ; 340 340 if ( empty($_POST['login_error_redirect']) ) { 341 341 return $errors; 342 342 } 343 343 if ( isset( $_GET['action'] ) && $_GET['action'] === 'logout' ) { 344 344 return $errors; 345 345 } 346 346 if ( isset( $_GET['action'] ) && $_GET['action'] === 'switch_to_user' ) { 347 347 return $errors; 348 348 } 349 349 if ( isset( $_GET['action'] ) && $_GET['action'] === 'switch_to_olduser' ) { 350 350 return $errors; 351 351 } 352 352 if ( $pagenow !== 'wp-login.php' || $_SERVER['REQUEST_METHOD'] !== 'POST' ) { 353 353 return $errors; 354 354 } 355 355 $login_page = sanitize_text_field( wp_unslash( $_POST['login_error_redirect'] ) ); 356 356 $new_login_page_url = home_url( $login_page ) . '?bf_login_error_redirect=1&'; 357 357 $errors = $errors->get_error_messages(); 358 358 for ( $i = 0 ; $i < count( $errors ) ; $i++ ) { 359 359 $new_login_page_url .= 'error_msg_' . $i . '=' . wp_strip_all_tags( $errors[$i] ); 360 360 // Isn't last iteration? 361 361 if ( $i !== count( $errors ) - 1 ) { 362 362 $new_login_page_url .= '&'; 363 363 } 364 364 } 365 365 wp_redirect( esc_url_raw( $new_login_page_url ) ); 366 366 exit; 367 367 } 368 368 369 369 add_filter( 'wp_login_errors', 'buddyforms_wp_login_errors_redirect' ); 370 370 /** 371 371 * since 2.5.13 372 372 * author @gfirem 373 373 * 374 374 * @param $wp_register_url 375 375 * 376 376 * @return string 377 377 */ 378 378 function buddyforms_register_url( $wp_register_url ) 379 379 { 380 380 $buddyforms_registration_page = get_option( 'buddyforms_registration_page' ); 381 381 382 382 if ( $buddyforms_registration_page != 'none' ) { 383 383 $new_url = get_permalink( $buddyforms_registration_page ); 384 384 if ( !empty($new_url) ) { 385 385 return $new_url; 386 386 } 387 387 } 388 388 389 389 return $wp_register_url; 390 390 } 391 391 392 392 add_filter( 'register_url', 'buddyforms_register_url' ); 393 393 add_filter( 394 394 'login_form_bottom', 395 395 'buddyforms_register_link', 396 396 10, 397 397 2 398 398 ); 399 399 function buddyforms_register_link( $wp_login_form, $args ) 400 400 { 401 401 if ( $args['form_id'] !== 'bf_loginform' ) { 402 402 return $wp_login_form; 403 403 } 404 404 $buddyforms_registration_page = get_option( 'buddyforms_registration_page' ); 405 405 406 406 if ( $buddyforms_registration_page != 'none' ) { 407 407 $permalink = get_permalink( $buddyforms_registration_page ); 408 408 } else { 409 409 $permalink = site_url( '/wp-login.php?action=register&redirect_to=' . get_permalink() ); 410 410 } 411 411 412 412 // new login page 413 413 $wp_login_form .= '<span class="buddyforms-register"><a href="' . $permalink . '">' . __( 'Register', 'buddyforms' ) . '</a></span> '; 414 414 return $wp_login_form; 415 415 } 416 416 417 417 add_action( 418 418 'login_form_bottom', 419 419 'buddyforms_add_lost_password_link', 420 420 10, 421 421 2 422 422 ); 423 423 function buddyforms_add_lost_password_link( $wp_login_form, $args ) 424 424 { 425 425 if ( $args['form_id'] !== 'bf_loginform' ) { 426 426 return $wp_login_form; 427 427 } 428 428 $lost_password_url = apply_filters( 'buddyforms_lost_password_url', wp_lostpassword_url() ); 429 429 $wp_login_form .= '<a href="' . esc_url( $lost_password_url ) . '">' . __( 'Lost Password?', 'buddyforms' ) . '</a> '; 430 430 return $wp_login_form; 431 431 } 432 432 433 433 // Helper Function to get the Get the REQUEST_URI Vars 434 434 /** 435 435 * @param $name 436 436 * 437 437 * @return int 438 438 */ 439 439 function buddyforms_get_url_var( $name ) 440 440 { 441 441 $strURL = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ); 442 442 $arrVals = explode( '/', $strURL ); 443 443 $found = 0; 444 444 foreach ( $arrVals as $index => $value ) { 445 445 if ( $value == $name ) { 446 446 $found = $index; 447 447 } 448 448 } 449 449 $place = $found + 1; 450 450 return ( $found == 0 ? 1 : $arrVals[$place] ); 451 451 } 452 452 453 453 /** 454 454 * Queue some JavaScript code to be output in the footer. 455 455 * 456 456 * @param string $code 457 457 */ 458 458 function buddyforms_enqueue_js( $code ) 459 459 { 460 460 global $wc_queued_js ; 461 461 if ( empty($wc_queued_js) ) { 462 462 $wc_queued_js = ''; 463 463 } 464 464 $wc_queued_js .= "\n" . $code . "\n"; 465 465 } 466 466 467 467 /** 468 468 * Display edit post link for post. 469 469 * 470 470 * @param string $text Optional. Anchor text. 471 471 * @param string $before Optional. Display before edit link. 472 472 * @param string $after Optional. Display after edit link. 473 473 * @param int $id Optional. Post ID. 474 474 * 475 475 * @param bool $echo 476 476 * 477 477 * @return string|void 478 478 * @since 2.3.1 479 479 * 480 480 * @since 1.0.0 481 481 */ 482 482 function buddyforms_edit_post_link( 483 483 $text = null, 484 484 $before = '', 485 485 $after = '', 486 486 $id = 0, 487 487 $echo = true 488 488 ) 489 489 { 490 490 if ( !($post = get_post( $id )) ) { 491 491 return; 492 492 } 493 493 if ( !($url = buddyforms_get_edit_post_link( $post->ID )) ) { 494 494 return; 495 495 } 496 496 if ( null === $text ) { 497 497 $text = __( 'Edit This' ); 498 498 } 499 499 $link = '<a title="' . __( 'Edit', 'buddyforms' ) . '" class="post-edit-link" href="' . $url . '"><span aria-label="' . __( 'Edit', 'buddyforms' ) . '" class="dashicons dashicons-edit"> </span></a>'; 500 500 /** 501 501 * Filter the post edit link anchor tag. 502 502 * 503 503 * @param string $link Anchor tag for the edit link. 504 504 * @param int $post_id Post ID. 505 505 * @param string $text Anchor text. 506 506 * 507 507 * @since 2.3.0 508 508 */ 509 509 $result = $before . apply_filters( 510 510 'edit_post_link', 511 511 $link, 512 512 $post->ID, 513 513 $text 514 514 ) . $after; 515 515 516 516 if ( $echo ) { 517 517 echo wp_kses( $result, buddyforms_wp_kses_allowed_atts() ) ; 518 518 } else { 519 519 return $result; 520 520 } 521 521 522 522 } 523 523 524 524 /** 525 525 * @param $form_slug 526 526 */ 527 527 function buddyforms_post_entry_actions( $form_slug ) 528 528 { 529 529 530 530 if ( !is_user_logged_in() ) { 531 531 echo '' ; 532 532 return; 533 533 } 534 534 535 535 536 536 if ( empty($form_slug) ) { 537 537 echo '' ; 538 538 return; 539 539 } 540 540 541 541 global $buddyforms, $post ; 542 542 543 543 if ( !isset( $buddyforms[$form_slug] ) || empty($buddyforms[$form_slug]['attached_page']) ) { 544 544 echo '' ; 545 545 return; 546 546 } 547 547 548 548 $attached_page = ( !empty($buddyforms[$form_slug]['attached_page']) ? $buddyforms[$form_slug]['attached_page'] : 'none' ); 549 549 550 550 if ( $attached_page == 'none' ) { 551 551 echo '' ; 552 552 return; 553 553 } 554 554 555 555 ?> 556 556 <ul class="edit_links"> 557 557 <?php 558 558 $is_author = buddyforms_is_author( $post->ID ); 559 559 $user_can_all_submission = current_user_can( 'buddyforms_' . $form_slug . '_all' ); 560 560 561 561 if ( $is_author || $user_can_all_submission && isset( $buddyforms[$form_slug]['attached_page'] ) ) { 562 562 $permalink = ''; 563 563 564 564 if ( !empty($buddyforms[$form_slug]['attached_page']) ) { 565 565 $permalink = get_permalink( $buddyforms[$form_slug]['attached_page'] ); 566 566 $permalink = apply_filters( 'buddyforms_the_loop_edit_permalink', $permalink, $buddyforms[$form_slug]['attached_page'] ); 567 567 } 568 568 569 569 if ( empty($permalink) ) { 570 570 return; 571 571 } 572 572 if ( is_multisite() ) { 573 573 if ( apply_filters( 'buddyforms_enable_multisite', false ) ) { 574 574 575 575 if ( isset( $buddyforms[$form_slug]['blog_id'] ) ) { 576 576 $current_site = get_current_site(); 577 577 $form_blog_id = $buddyforms[$form_slug]['blog_id']; 578 578 579 579 if ( $current_site->blog_id != $form_blog_id ) { 580 580 $form_site = get_blog_details( $form_blog_id, array( 'blog_id', 'blogname' ) ); 581 581 $permalink = str_replace( $form_site->path, $current_site->path, $permalink ); 582 582 } 583 583 584 584 } 585 585 586 586 } 587 587 } 588 588 ob_start(); 589 589 $post_form_slug = get_post_meta( $post->ID, '_bf_form_slug', true ); 590 590 if ( $post_form_slug ) { 591 591 $form_slug = $post_form_slug; 592 592 } 593 593 $current_user_can_edit = apply_filters( 594 594 'buddyforms_user_can_edit', 595 595 current_user_can( 'buddyforms_' . $form_slug . '_edit' ), 596 596 $form_slug, 597 597 $post->ID 598 598 ); 599 599 $current_user_can_all = apply_filters( 600 600 'buddyforms_user_can_all', 601 601 current_user_can( 'buddyforms_' . $form_slug . '_all' ), 602 602 $form_slug, 603 603 $post->ID 604 604 ); 605 605 $current_user_can_delete = apply_filters( 606 606 'buddyforms_user_can_delete', 607 607 current_user_can( 'buddyforms_' . $form_slug . '_delete' ), 608 608 $form_slug, 609 609 $post->ID 610 610 ); 611 611 $current_user_can_create = apply_filters( 612 612 'buddyforms_user_can_create', 613 613 current_user_can( 'buddyforms_' . $form_slug . '_create' ), 614 614 $form_slug, 615 615 $post->ID 616 616 ); 617 617 $current_user_can_draft = apply_filters( 618 618 'buddyforms_user_can_draft', 619 619 current_user_can( 'buddyforms_' . $form_slug . '_draft' ), 620 620 $form_slug, 621 621 $post->ID 622 622 ); 623 623 $current_post_is_draft = $post->post_status == 'draft'; 624 624 $current_user_edit_draft = $current_user_can_create && !$current_user_can_edit && $current_post_is_draft && $current_user_can_draft; 625 625 if ( isset( $buddyforms[$form_slug]['form_type'] ) && $buddyforms[$form_slug]['form_type'] != 'contact' ) { 626 626 627 627 if ( $current_user_can_edit || $current_user_can_all || $current_user_edit_draft ) { 628 628 echo '<li>' ; 629 629 630 630 if ( isset( $buddyforms[$form_slug]['edit_link'] ) && $buddyforms[$form_slug]['edit_link'] != 'none' ) { 631 631 echo wp_kses( apply_filters( 632 632 'buddyforms_loop_edit_post_link', 633 633 '<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>', 634 634 get_the_ID(), 635 635 $form_slug 636 636 ), buddyforms_wp_kses_allowed_atts() ) ; 637 637 } else { 638 638 echo wp_kses( apply_filters( 639 639 'buddyforms_loop_edit_post_link', 640 640 buddyforms_edit_post_link( 641 641 '<span aria-label="' . esc_attr__( 'Edit', 'buddyforms' ) . '" class="dashicons dashicons-edit"> </span> ' . esc_attr__( 'Edit', 'buddyforms' ), 642 642 '', 643 643 '', 644 644 0, 645 645 false 646 646 ), 647 647 get_the_ID(), 648 648 $form_slug 649 649 ), buddyforms_wp_kses_allowed_atts() ) ; 650 650 } 651 651 652 652 echo '</li>' ; 653 653 } 654 654 655 655 } 656 656 657 657 if ( $current_user_can_delete || $current_user_can_all ) { 658 658 echo '<li>' ; 659 659 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>' ; 660 660 echo '</li>' ; 661 661 } 662 662 663 663 // Add custom actions to the entry 664 664 do_action( 'buddyforms_the_loop_actions', get_the_ID() ); 665 665 $meta_tmp = ob_get_clean(); 666 666 // Display all actions 667 667 echo wp_kses( apply_filters( 'buddyforms_the_loop_meta_html', $meta_tmp ), buddyforms_wp_kses_allowed_atts() ) ; 668 668 } 669 669 670 670 do_action( 'buddyforms_the_loop_actions_last', get_the_ID() ); 671 671 ?> 672 672 </ul> 673 673 <?php 674 674 } 675 675 676 676 /** 677 677 * Determinate if the current user is the user of the given post 678 678 * 679 679 * @param $post_id 680 680 * 681 681 * @return bool 682 682 */ 683 683 function buddyforms_is_author( $post_id ) 684 684 { 685 685 $is_author = false; 686 686 if ( get_post_field( 'post_author', $post_id ) == get_current_user_id() ) { 687 687 $is_author = true; 688 688 } 689 689 $form_slug = get_post_field( '_bf_form_slug', $post_id ); 690 690 $is_author = apply_filters( 691 691 'buddyforms_user_can_edit', 692 692 $is_author, 693 693 $form_slug, 694 694 $post_id 695 695 ); 696 696 return $is_author; 697 697 } 698 698 699 699 /** 700 700 * @param $post_status 701 701 */ 702 702 function buddyforms_post_status_readable( $post_status ) 703 703 { 704 704 echo wp_kses_post( buddyforms_get_post_status_readable( $post_status ) ) ; 705 705 } 706 706 707 707 /** 708 708 * @param $post_status 709 709 * 710 710 * @return string 711 711 */ 712 712 function buddyforms_get_post_status_readable( $post_status ) 713 713 { 714 714 if ( $post_status == 'publish' ) { 715 715 return __( 'Published', 'buddyforms' ); 716 716 } 717 717 if ( $post_status == 'draft' ) { 718 718 return __( 'Draft', 'buddyforms' ); 719 719 } 720 720 if ( $post_status == 'pending' ) { 721 721 return __( 'Pending Review', 'buddyforms' ); 722 722 } 723 723 if ( $post_status == 'future' ) { 724 724 return __( 'Scheduled', 'buddyforms' ); 725 725 } 726 726 if ( $post_status == 'awaiting-review' ) { 727 727 return __( 'Awaiting Review', 'buddyforms' ); 728 728 } 729 729 if ( $post_status == 'edit-draft' ) { 730 730 return __( 'Edit Draft', 'buddyforms' ); 731 731 } 732 732 return apply_filters( 'buddyforms_get_post_status_readable', $post_status ); 733 733 } 734 734 735 735 /** 736 736 * @param $post_status 737 737 * @param $form_slug 738 738 */ 739 739 function buddyforms_post_status_css_class( $post_status, $form_slug ) 740 740 { 741 741 echo wp_kses_post( buddyforms_get_post_status_css_class( $post_status, $form_slug ) ) ; 742 742 } 743 743 744 744 /** 745 745 * @param $post_status 746 746 * @param $form_slug 747 747 * 748 748 * @return string 749 749 */ 750 750 function buddyforms_get_post_status_css_class( $post_status, $form_slug ) 751 751 { 752 752 $post_status_css = $post_status; 753 753 if ( $post_status == 'pending' ) { 754 754 $post_status_css = 'bf-pending'; 755 755 } 756 756 return apply_filters( 'buddyforms_post_status_css', $post_status_css, $form_slug ); 757 757 } 758 758 759 759 /** 760 760 * Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation ! 761 761 * 762 762 * @param string $hook_name 763 763 * @param string $method_name 764 764 * @param int $priority 765 765 * 766 766 * @return bool 767 767 */ 768 768 function buddyforms_remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) 769 769 { 770 770 global $wp_filter ; 771 771 // Take only filters on right hook name and priority 772 772 if ( !isset( $wp_filter[$hook_name][$priority] ) || !is_array( $wp_filter[$hook_name][$priority] ) ) { 773 773 return false; 774 774 } 775 775 // Loop on filters registered 776 776 foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array ) { 777 777 // Test if filter is an array ! (always for class/method) 778 778 if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) { 779 779 // Test if object is a class and method is equal to param ! 780 780 if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) { 781 781 unset( $wp_filter[$hook_name][$priority][$unique_id] ); 782 782 } 783 783 } 784 784 } 785 785 return false; 786 786 } 787 787 788 788 /** 789 789 * 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 :) 790 790 * 791 791 * @param string $hook_name 792 792 * @param string $class_name 793 793 * @param string $method_name 794 794 * @param int $priority 795 795 * 796 796 * @return bool 797 797 */ 798 798 function buddyforms_remove_filters_for_anonymous_class( 799 799 $hook_name = '', 800 800 $class_name = '', 801 801 $method_name = '', 802 802 $priority = 0 803 803 ) 804 804 { 805 805 global $wp_filter ; 806 806 // Take only filters on right hook name and priority 807 807 if ( !isset( $wp_filter[$hook_name][$priority] ) || !is_array( $wp_filter[$hook_name][$priority] ) ) { 808 808 return false; 809 809 } 810 810 // Loop on filters registered 811 811 foreach ( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array ) { 812 812 // Test if filter is an array ! (always for class/method) 813 813 if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) { 814 814 // Test if object is a class, class and method is equal to param ! 815 815 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 ) { 816 816 unset( $wp_filter[$hook_name][$priority][$unique_id] ); 817 817 } 818 818 } 819 819 } 820 820 return false; 821 821 } 822 822 823 823 /** 824 824 * Get all taxonomies 825 825 * 826 826 * @param $post_type 827 827 * 828 828 * @return 829 829 * @package BuddyForms 830 830 * @since 0.1-beta 831 831 */ 832 832 function buddyforms_taxonomies( $post_type ) 833 833 { 834 834 $taxonomies_array = get_object_taxonomies( $post_type, 'objects' ); 835 835 $taxonomies['none'] = 'Select a Taxonomy'; 836 836 foreach ( $taxonomies_array as $tax_slug => $tax ) { 837 837 $taxonomies[$tax->name] = $tax->label; 838 838 } 839 839 return $taxonomies; 840 840 } 841 841 842 842 function buddyforms_metabox_go_pro() 843 843 { 844 844 buddyforms_go_pro( 845 845 '<span> </span>', 846 846 '', 847 847 array( __( 'Priority Support', 'buddyforms' ), __( 'More Form Elements', 'buddyforms' ), __( 'More Options', 'buddyforms' ) ), 848 848 false 849 849 ); 850 850 buddyforms_go_pro( 851 851 '<span> </span>', 852 852 __( 'Full Control', 'buddyforms' ), 853 853 array( 854 854 __( 'Use your form in the backend admin edit screen like ACF', 'buddyforms' ), 855 855 __( 'Control who can create, edit and delete content', 'buddyforms' ), 856 856 __( 'Registration Options', 'buddyforms' ), 857 857 __( 'Disable ajax form submission', 'buddyforms' ), 858 858 __( 'Local Storage', 'buddyforms' ), 859 859 __( 'More Notification Options', 'buddyforms' ), 860 860 __( 'Import - Export Forms', 'buddyforms' ) 861 861 ), 862 862 false 863 863 ); 864 864 buddyforms_go_pro( 865 865 '<span> </span>', 866 866 __( 'Permissions Management', 'buddyforms' ), 867 867 array( __( 'Manage User Roles', 'buddyforms' ), __( 'Manage Capabilities', 'buddyforms' ), __( 'More Validation Options', 'buddyforms' ) ), 868 868 false 869 869 ); 870 870 buddyforms_go_pro( 871 871 '<span> </span>', 872 872 __( 'More Post Options', 'buddyforms' ), 873 873 array( 874 874 __( 'All Post Types', 'buddyforms' ), 875 875 __( 'Posts Revision', 'buddyforms' ), 876 876 __( 'Comment Status', 'buddyforms' ), 877 877 __( 'Enable Login on the form', 'buddyforms' ), 878 878 __( 'Create an account during submission?', 'buddyforms' ), 879 879 __( 'Featured Image Support', 'buddyforms' ) 880 880 ), 881 881 false 882 882 ); 883 883 buddyforms_go_pro( '<span> </span>', __( 'Know Your User', 'buddyforms' ) . '<p><small>' . __( 'Get deep Insights about your Submitter', 'buddyforms' ) . '</small></p>', array( 884 884 __( 'IP Address', 'buddyforms' ), 885 885 __( 'Referer', 'buddyforms' ), 886 886 __( 'Browser', 'buddyforms' ), 887 887 __( 'Platform', 'buddyforms' ), 888 888 __( 'Reports', 'buddyforms' ), 889 889 __( 'User Agent', 'buddyforms' ) 890 890 ) ); 891 891 } 892 892 893 893 /** 894 894 * Get field by slug 895 895 * 896 896 * @param $form_slug 897 897 * @param $field_slug 898 898 * 899 899 * @return bool|array 900 900 * @author Sven edited by gfirem 901 901 */ 902 902 function buddyforms_get_form_field_by_slug( $form_slug, $field_slug ) 903 903 { 904 904 $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, 'buddyforms' ); 905 905 906 906 if ( $result_field === false ) { 907 907 global $buddyforms ; 908 908 if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) { 909 909 foreach ( $buddyforms[$form_slug]['form_fields'] as $field_key => $field ) { 910 910 911 911 if ( $field['slug'] == $field_slug ) { 912 912 $result_field = $field; 913 913 wp_cache_set( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, $result_field, 'buddyforms' ); 914 914 return $result_field; 915 915 } 916 916 917 917 } 918 918 } 919 919 } 920 920 921 921 return $result_field; 922 922 } 923 923 924 924 /** 925 925 * Get field by slug 926 926 * 927 927 * @param $form_slug 928 928 * @param $field_slug 929 929 * @param string $by 930 930 * 931 931 * @return bool|array 932 932 * @since 2.5.11 Added the $by parameter to specify the comparison parameter 933 933 * @author Sven edited by gfirem 934 934 */ 935 935 function buddyforms_get_form_field_by( $form_slug, $field_slug, $by = 'slug' ) 936 936 { 937 937 $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, 'buddyforms' ); 938 938 939 939 if ( $result_field === false ) { 940 940 global $buddyforms ; 941 941 if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) { 942 942 foreach ( $buddyforms[$form_slug]['form_fields'] as $field_key => $field ) { 943 943 944 944 if ( $field[$by] == $field_slug ) { 945 945 $result_field = $field; 946 946 wp_cache_set( 'buddyforms_get_field_' . $field_slug . '_in_form_' . $form_slug, $result_field, 'buddyforms' ); 947 947 return $result_field; 948 948 } 949 949 950 950 } 951 951 } 952 952 } 953 953 954 954 return $result_field; 955 955 } 956 956 957 957 /** 958 958 * Get field by ID 959 959 * 960 960 * @param $form_slug 961 961 * @param $field_id 962 962 * 963 963 * @return bool|array 964 964 * @since 2.4.6 965 965 */ 966 966 function buddyforms_get_form_field_by_id( $form_slug, $field_id ) 967 967 { 968 968 $result_field = wp_cache_get( 'buddyforms_get_field_' . $field_id . '_in_form_' . $form_slug, 'buddyforms' ); 969 969 970 970 if ( $result_field === false ) { 971 971 global $buddyforms ; 972 972 if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) { 973 973 974 974 if ( isset( $buddyforms[$form_slug]['form_fields'] ) && isset( $buddyforms[$form_slug]['form_fields'][$field_id] ) ) { 975 975 $result_field = $buddyforms[$form_slug]['form_fields'][$field_id]; 976 976 wp_cache_set( 'buddyforms_get_field_' . $field_id . '_in_form_' . $form_slug, $result_field, 'buddyforms' ); 977 977 return $result_field; 978 978 } 979 979 980 980 } 981 981 } 982 982 983 983 return $result_field; 984 984 } 985 985 986 986 /** 987 987 * Return teh array of field belong to the form. 988 988 * 989 989 * @param $form_slug 990 990 * 991 991 * @return bool|array 992 992 */ 993 993 function buddyforms_get_form_fields( $form_slug ) 994 994 { 995 995 $result_field = wp_cache_get( 'buddyforms_get_form_fields' . $form_slug, 'buddyforms' ); 996 996 997 997 if ( $result_field === false ) { 998 998 global $buddyforms ; 999 999 if ( empty($form_slug) ) { 1000 1000 return false; 1001 1001 } 1002 1002 1003 1003 if ( isset( $buddyforms[$form_slug]['form_fields'] ) ) { 1004 1004 $result_fields = $buddyforms[$form_slug]['form_fields']; 1005 1005 wp_cache_set( 'buddyforms_get_form_fields' . $form_slug, $result_fields, 'buddyforms' ); 1006 1006 return $result_fields; 1007 1007 } 1008 1008 1009 1009 } 1010 1010 1011 1011 return $result_field; 1012 1012 } 1013 1013 1014 1014 /** 1015 1015 * Check if field type exist in a form 1016 1016 * 1017 1017 * @param $form_slug 1018 1018 * @param $field_type 1019 1019 * 1020 1020 * @param string $search_by 1021 1021 * 1022 1022 * @return bool 1023 1023 * @since 2.5.15 added $search_by 1024 1024 */ 1025 1025 function buddyforms_exist_field_type_in_form( $form_slug, $field_type, $search_by = 'type' ) 1026 1026 { 1027 1027 $fields = buddyforms_get_form_fields( $form_slug ); 1028 1028 $exist = false; 1029 1029 if ( empty($fields) ) { 1030 1030 return $exist; 1031 1031 } 1032 1032 foreach ( $fields as $field ) { 1033 1033 1034 1034 if ( $field[$search_by] == $field_type ) { 1035 1035 $exist = true; 1036 1036 break; 1037 1037 } 1038 1038 1039 1039 } 1040 1040 return $exist; 1041 1041 } 1042 1042 1043 1043 // 1044 1044 // Add Placeholder support top the wp editor 1045 1045 // 1046 1046 add_filter( 'mce_external_plugins', 'buddyforms_add_mce_placeholder_plugin' ); 1047 1047 function buddyforms_add_mce_placeholder_plugin( $plugins ) 1048 1048 { 1049 1049 if ( is_admin() ) { 1050 1050 return $plugins; 1051 1051 } 1052 1052 $plugins['placeholder'] = BUDDYFORMS_PLUGIN_URL . 'assets/resources/wp-tinymce-placeholder/mce.placeholder.js'; 1053 1053 return $plugins; 1054 1054 } 1055 1055 1056 1056 /** 1057 1057 * Add garlic support to the wp editor for local save the content of the textarea 1058 1058 * 1059 1059 * @param $initArray 1060 1060 * 1061 1061 * @return mixed 1062 1062 */ 1063 1063 function buddyforms_tinymce_setup_function( $initArray ) 1064 1064 { 1065 1065 $initArray['setup'] = 'function(editor) { 1066 1066 editor.on("change keyup", function(e){ 1067 1067 editor.save(); 1068 1068 jQuery(editor.getElement()).trigger(\'change\'); 1069 1069 }); 1070 1070 }'; 1071 1071 return $initArray; 1072 1072 } 1073 1073 1074 1074 /** 1075 1075 * Get a form by slug 1076 1076 * 1077 1077 * @param $form_slug 1078 1078 * 1079 1079 * @return bool|array 1080 1080 */ 1081 1081 function buddyforms_get_form_by_slug( $form_slug ) 1082 1082 { 1083 1083 $value = wp_cache_get( 'buddyforms_form_by_slug_' . $form_slug, 'buddyforms' ); 1084 1084 1085 1085 if ( $value === false ) { 1086 1086 global $buddyforms ; 1087 1087 1088 1088 if ( isset( $buddyforms[$form_slug] ) ) { 1089 1089 $value = $buddyforms[$form_slug]; 1090 1090 wp_cache_set( 'buddyforms_form_by_slug_' . $form_slug, $value, 'buddyforms' ); 1091 1091 } 1092 1092 1093 1093 } 1094 1094 1095 1095 return $value; 1096 1096 } 1097 1097 1098 1098 /** 1099 1099 * Get form option 1100 1100 * 1101 1101 * @param $form_slug 1102 1102 * @param string $option 1103 1103 * 1104 1104 * @return string|bool 1105 1105 * @since 2.5.19 1106 1106 */ 1107 1107 function buddyforms_get_form_option( $form_slug, $option ) 1108 1108 { 1109 1109 $value = false; 1110 1110 1111 1111 if ( !empty($form_slug) && !empty($option) ) { 1112 1112 $cache_key = 'buddyforms_form_' . $form_slug . '_option_' . $option; 1113 1113 $value = wp_cache_get( $cache_key, 'buddyforms' ); 1114 1114 1115 1115 if ( $value === false ) { 1116 1116 $bf_form = buddyforms_get_form_by_slug( $form_slug ); 1117 1117 1118 1118 if ( !empty($bf_form) ) { 1119 1119 $value = ( isset( $bf_form[$option] ) ? $bf_form[$option] : false ); 1120 1120 wp_cache_set( $cache_key, $value, 'buddyforms' ); 1121 1121 } 1122 1122 1123 1123 } 1124 1124 1125 1125 } 1126 1126 1127 1127 return $value; 1128 1128 } 1129 1129 1130 1130 /** 1131 1131 * Will return the form slug from post meta or the default. none if no form is attached 1132 1132 * 1133 1133 * @param $post_id 1134 1134 * 1135 1135 * @return mixed 1136 1136 * @author Sven edited by gfirem 1137 1137 */ 1138 1138 function buddyforms_get_form_slug_by_post_id( $post_id ) 1139 1139 { 1140 1140 $value = wp_cache_get( 'buddyform_form_slug_' . $post_id, 'buddyforms' ); 1141 1141 1142 1142 if ( $value === false ) { 1143 1143 $value = get_post_meta( $post_id, '_bf_form_slug', true ); 1144 1144 1145 1145 if ( empty($value) || isset( $value ) && $value == 'none' ) { 1146 1146 $buddyforms_posttypes_default = get_option( 'buddyforms_posttypes_default' ); 1147 1147 $post_type = get_post_type( $post_id ); 1148 1148 if ( isset( $buddyforms_posttypes_default[$post_type] ) ) { 1149 1149 $value = $buddyforms_posttypes_default[$post_type]; 1150 1150 } 1151 1151 } 1152 1152 1153 1153 wp_cache_set( 'buddyform_form_slug_' . $post_id, $value, 'buddyforms' ); 1154 1154 } 1155 1155 1156 1156 return $value; 1157 1157 } 1158 1158 1159 1159 /** 1160 1160 * Get the post types for teh created forms 1161 1161 * 1162 1162 * @return array 1163 1163 */ 1164 1164 function buddyforms_get_post_types_from_forms() 1165 1165 { 1166 1166 global $buddyforms ; 1167 1167 $result = array(); 1168 1168 1169 1169 if ( !empty($buddyforms) ) { 1170 1170 foreach ( $buddyforms as $form ) { 1171 1171 $result[] = $form['post_type']; 1172 1172 } 1173 1173 $result = array_unique( $result ); 1174 1174 } 1175 1175 1176 1176 return $result; 1177 1177 } 1178 1178 1179 1179 function buddyforms_get_post_types() 1180 1180 { 1181 1181 $post_types = array(); 1182 1182 // Generate the Post Type Array 'none' == Contact Form 1183 1183 $post_types['bf_submissions'] = __( 'none', 'buddyforms' ); 1184 1184 $post_types['post'] = __( 'Post', 'buddyforms' ); 1185 1185 $post_types['page'] = __( 'Page', 'buddyforms' ); 1186 1186 return $post_types; 1187 1187 } 1188 1188 1189 1189 /** 1190 1190 * This function return the dropdown populated with the pages of the site including the childs 1191 1191 * 1192 1192 * @param $name 1193 1193 * @param $selected 1194 1194 * @param string $id 1195 1195 * @param string $default_option_string 1196 1196 * @param string $default_option_value 1197 1197 * @param string $view 1198 1198 * 1199 1199 * @return string 1200 1200 * @author gfirem 1201 1201 * 1202 1202 * @since 2.5.10 1203 1203 */ 1204 1204 function buddyforms_get_all_pages_dropdown( 1205 1205 $name, 1206 1206 $selected, 1207 1207 $id = '', 1208 1208 $default_option_string = 'WordPress Default', 1209 1209 $default_option_value = 'none', 1210 1210 $view = 'form_builder' 1211 1211 ) 1212 1212 { 1213 1213 if ( $default_option_string === 'WordPress Default' ) { 1214 1214 $default_option_string = __( 'WordPress Default', 'buddyforms' ); 1215 1215 } 1216 1216 $exclude = array(); 1217 1217 $page_on_front = get_option( 'page_on_front' ); 1218 1218 if ( !empty($page_on_front) && $page_on_front !== 'none' && is_numeric( $page_on_front ) && $page_on_front != $selected ) { 1219 1219 $exclude[] = intval( $page_on_front ); 1220 1220 } 1221 1221 1222 1222 if ( $view == 'form_builder' ) { 1223 1223 $buddyforms_registration_page = get_option( 'buddyforms_registration_page' ); 1224 1224 if ( !empty($buddyforms_registration_page) && $buddyforms_registration_page !== 'none' && is_numeric( $buddyforms_registration_page ) && $buddyforms_registration_page != $selected ) { 1225 1225 $exclude[] = intval( $buddyforms_registration_page ); 1226 1226 } 1227 1227 } 1228 1228 1229 1229 $args = array( 1230 1230 'depth' => 0, 1231 1231 'post_type' => 'page', 1232 1232 'exclude_tree' => $exclude, 1233 1233 'selected' => $selected, 1234 1234 'name' => $name, 1235 1235 'id' => ( !empty($id) ? $id : $name ), 1236 1236 'show_option_none' => $default_option_string, 1237 1237 'option_none_value' => $default_option_value, 1238 1238 'sort_column' => 'post_title', 1239 1239 'echo' => 0, 1240 1240 ); 1241 1241 return wp_kses( wp_dropdown_pages( $args ), buddyforms_wp_kses_allowed_atts() ); 1242 1242 } 1243 1243 1244 1244 function buddyforms_get_all_pages( 1245 1245 $type = 'id', 1246 1246 $view = 'form_builder', 1247 1247 $exclude_global_submission_endpoint = false, 1248 1248 $extra_exclude_ids = array(), 1249 1249 $default_string = '' 1250 1250 ) 1251 1251 { 1252 1252 $exclude = array(); 1253 1253 if ( empty($default_string) ) { 1254 1254 $default_string = __( 'Select a Page', 'buddyforms' ); 1255 1255 } 1256 1256 // get the page_on_front and exclude it from the query. This page should not get used for the endpoints 1257 1257 $page_on_front = get_option( 'page_on_front' ); 1258 1258 if ( !empty($page_on_front) ) { 1259 1259 $exclude[] = $page_on_front; 1260 1260 } 1261 1261 1262 1262 if ( $view == 'form_builder' ) { 1263 1263 $buddyforms_registration_page = get_option( 'buddyforms_registration_page' ); 1264 1264 if ( !empty($buddyforms_registration_page) ) { 1265 1265 $exclude[] = $buddyforms_registration_page; 1266 1266 } 1267 1267 } 1268 1268 1269 1269 1270 1270 if ( !empty($exclude_global_submission_endpoint) ) { 1271 1271 $buddyforms_submissions_page = get_option( 'buddyforms_submissions_page' ); 1272 1272 if ( !empty($buddyforms_submissions_page) ) { 1273 1273 $exclude[] = $buddyforms_submissions_page; 1274 1274 } 1275 1275 } 1276 1276 1277 1277 if ( !empty($extra_exclude_ids) ) { 1278 1278 $exclude = array_merge( $extra_exclude_ids, $exclude ); 1279 1279 } 1280 1280 $args = array( 1281 1281 'sort_order' => 'asc', 1282 1282 'sort_column' => 'post_title', 1283 1283 'parent' => -1, 1284 1284 'post_type' => 'page', 1285 1285 'post_status' => 'publish', 1286 1286 ); 1287 1287 if ( !empty($exclude) ) { 1288 1288 $args['exclude'] = $exclude; 1289 1289 } 1290 1290 $pages = get_pages( $args ); 1291 1291 $all_pages = array(); 1292 1292 $all_pages['none'] = $default_string; 1293 1293 if ( $type == 'id' ) { 1294 1294 // Generate the pages array by id 1295 1295 foreach ( $pages as $page ) { 1296 1296 $all_pages[$page->ID] = $page->post_title; 1297 1297 } 1298 1298 } 1299 1299 if ( $type == 'name' ) { 1300 1300 foreach ( $pages as $page ) { 1301 1301 $all_pages[$page->post_name] = $page->post_title; 1302 1302 } 1303 1303 } 1304 1304 return $all_pages; 1305 1305 } 1306 1306 1307 1307 add_action( 'admin_bar_menu', 'buddyform_admin_bar_shortcut', 60 ); 1308 1308 /** 1309 1309 * Add a short-code to the admin toolbar to edit the form in the current screen 1310 1310 * 1311 1311 * @param WP_Admin_Bar $wp_admin_bar 1312 1312 */ 1313 1313 function buddyform_admin_bar_shortcut( $wp_admin_bar ) 1314 1314 { 1315 1315 if ( is_admin() && is_user_logged_in() ) { 1316 1316 return; 1317 1317 } 1318 1318 global $post, $buddyforms ; 1319 1319 if ( empty($post->ID) ) { 1320 1320 return; 1321 1321 } 1322 1322 $form_slug = ''; 1323 1323 global $wp_query ; 1324 1324 1325 1325 if ( !empty($wp_query->query_vars['bf_form_slug']) ) { 1326 1326 $form_slug = sanitize_title( $wp_query->query_vars['bf_form_slug'] ); 1327 1327 } elseif ( !empty($post->post_name) ) { 1328 1328 $form_slug = $post->post_name; 1329 1329 } 1330 1330 1331 1331 if ( empty($form_slug) && is_array( $buddyforms ) && !array_key_exists( $form_slug, $buddyforms ) ) { 1332 1332 return; 1333 1333 } 1334 1334 if ( !current_user_can( 'buddyforms_' . $form_slug . '_create' ) ) { 1335 1335 return; 1336 1336 } 1337 1337 $form = get_page_by_path( $form_slug, 'OBJECT', 'buddyforms' ); 1338 1338 if ( empty($form) ) { 1339 1339 return; 1340 1340 } 1341 1341 $post_url = sprintf( 'post.php?post=%s&action=edit', $form->ID ); 1342 1342 $args = array( 1343 1343 'id' => 'buddyforms-admin-edit-form', 1344 1344 'title' => __( 'Edit BuddyForm', 'buddyforms' ), 1345 1345 'href' => admin_url( $post_url ), 1346 1346 'meta' => array( 1347 1347 'data-post_id' => 33, 1348 1348 'class' => 'admin-bar dashicons-before dashicons-buddyforms', 1349 1349 ), 1350 1350 ); 1351 1351 $wp_admin_bar->add_node( $args ); 1352 1352 } 1353 1353 1354 1354 add_action( 'buddyforms_form_hero_last', 'buddyforms_form_footer_terms' ); 1355 1355 function buddyforms_form_footer_terms( $html ) 1356 1356 { 1357 1357 $buddyforms_gdpr = get_option( 'buddyforms_gdpr' ); 1358 1358 $html .= ' <div class="terms"><p>'; 1359 1359 if ( !empty($buddyforms_gdpr['terms_label']) ) { 1360 1360 $html .= '<span id="" class="buddyforms_terms_label">' . $buddyforms_gdpr['terms_label'] . '</span> '; 1361 1361 } 1362 1362 if ( isset( $buddyforms_gdpr['terms'] ) && $buddyforms_gdpr['terms'] != 'none' ) { 1363 1363 $html .= '<a id="" class="" href="' . get_permalink( $buddyforms_gdpr['terms'] ) . '">' . get_the_title( $buddyforms_gdpr['terms'] ) . '</a>'; 1364 1364 } 1365 1365 $html .= '</p></div>'; 1366 1366 return $html; 1367 1367 } 1368 1368 1369 1369 /** 1370 1370 * This function is an internal implementation to generate the nonce base on specific user. 1371 1371 * We create this to generate nonce for user not logged in 1372 1372 * 1373 1373 * @readmore wp-includes/pluggable.php:2147 1374 1374 * 1375 1375 * @param int $action 1376 1376 * @param int $user_id 1377 1377 * @param string $token 1378 1378 * 1379 1379 * @return bool|string 1380 1380 * @since 2.5.10 Added the token parameter to emulate loggout user nonce 1381 1381 */ 1382 1382 function buddyforms_create_nonce( $action = -1, $user_id = 0, $token = '' ) 1383 1383 { 1384 1384 1385 1385 if ( $user_id === 0 ) { 1386 1386 $user = wp_get_current_user(); 1387 1387 $uid = (int) $user->ID; 1388 1388 if ( !$uid ) { 1389 1389 /** This filter is documented in wp-includes/pluggable.php */ 1390 1390 $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); 1391 1391 } 1392 1392 $token = wp_get_session_token(); 1393 1393 } else { 1394 1394 $uid = $user_id; 1395 1395 } 1396 1396 1397 1397 $i = wp_nonce_tick(); 1398 1398 return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); 1399 1399 } 1400 1400 1401 1401 function buddyforms_form_display_message( $form_slug, $post_id, $source = 'after_submit_message_text' ) 1402 1402 { 1403 1403 global $buddyforms ; 1404 1404 $display_message = buddyforms_default_message_on_create(); 1405 1405 1406 1406 if ( !empty($buddyforms[$form_slug][$source]) ) { 1407 1407 $display_message = $buddyforms[$form_slug][$source]; 1408 1408 } else { 1409 1409 if ( $source !== 'after_submit_message_text' ) { 1410 1410 $display_message = buddyforms_default_message_on_update(); 1411 1411 } 1412 1412 } 1413 1413 1414 1414 $display_message = apply_filters( 1415 1415 'buddyforms_form_display_message', 1416 1416 $display_message, 1417 1417 $form_slug, 1418 1418 $post_id, 1419 1419 $source 1420 1420 ); 1421 1421 1422 1422 if ( !empty($buddyforms[$form_slug]['attached_page']) ) { 1423 1423 $permalink = get_permalink( $buddyforms[$form_slug]['attached_page'] ); 1424 1424 $display_message = str_ireplace( '[edit_link]', '<a title="' . __( 'Edit Post', 'buddyforms' ) . '" href="' . $permalink . 'edit/' . $form_slug . '/' . $post_id . '">' . __( 'Continue Editing', 'buddyforms' ) . '</a>', $display_message ); 1425 1425 } 1426 1426 1427 1427 $display_message = str_ireplace( '[form_singular_name]', $buddyforms[$form_slug]['singular_name'], $display_message ); 1428 1428 $display_message = str_ireplace( '[post_title]', get_the_title( $post_id ), $display_message ); 1429 1429 $display_message = str_ireplace( '[post_link]', '<a title="' . __( 'Display Post', 'buddyforms' ) . '" href="' . get_permalink( $post_id ) . '">' . __( 'Display Post', 'buddyforms' ) . '</a>', $display_message ); 1430 1430 return do_shortcode( $display_message ); 1431 1431 } 1432 1432 1433 1433 function buddyforms_user_fields_array() 1434 1434 { 1435 1435 return array( 1436 1436 'user_login', 1437 1437 'user_email', 1438 1438 'user_first', 1439 1439 'user_last', 1440 1440 'user_pass', 1441 1441 'user_website', 1442 1442 'display_name', 1443 1443 'user_bio', 1444 1444 'country', 1445 1445 'state' 1446 1446 ); 1447 1447 } 1448 1448 1449 1449 function buddyforms_default_message_on_update() 1450 1450 { 1451 1451 return __( 'Form Updated Successfully.', 'buddyforms' ); 1452 1452 } 1453 1453 1454 1454 function buddyforms_default_message_on_empty_submission_list() 1455 1455 { 1456 1456 return __( 'There were no posts found. Create your first post [bf_new_submission_link name="Now"]!', 'buddyforms' ); 1457 1457 } 1458 1458 1459 1459 function buddyforms_default_message_on_create() 1460 1460 { 1461 1461 return __( 'Form Submitted Successfully.', 'buddyforms' ); 1462 1462 } 1463 1463 1464 1464 add_action( 'wp_ajax_nopriv_handle_dropped_media', 'buddyforms_upload_handle_dropped_media' ); 1465 1465 add_action( 'wp_ajax_handle_dropped_media', 'buddyforms_upload_handle_dropped_media' ); 1466 1466 function buddyforms_upload_handle_dropped_media() 1467 1467 { 1468 1468 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; 1483 1511 } else { 1484 status_header( '200' ); 1485 echo wp_kses_post( $newupload ) ; 1486 } 1487 1488 die; 1512 die; 1513 } 1514 1489 1515 } 1490 1516 1491 1517 add_action( 'wp_ajax_nopriv_handle_deleted_media', 'buddyforms_upload_handle_delete_media' ); 1492 1518 add_action( 'wp_ajax_handle_deleted_media', 'buddyforms_upload_handle_delete_media' ); 1493 1519 function buddyforms_upload_handle_delete_media() 1494 1520 { 1495 1521 check_ajax_referer( 'fac_drop', 'nonce' ); 1496 1522 1497 1523 if ( isset( $_REQUEST['media_id'] ) ) { 1498 1524 $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 1500 1534 1501 1535 if ( $status ) { 1502 1536 echo wp_json_encode( array( 1503 1537 'status' => 'OK', 1504 1538 ) ) ; 1505 1539 } else { 1506 1540 echo wp_json_encode( array( 1507 1541 'status' => 'FAILED', 1508 1542 ) ) ; 1509 1543 } 1510 1544 1511 1545 } 1512 1546 1513 1547 die; 1514 1548 } 1515 1549 1516 1550 add_action( 'wp_ajax_nopriv_upload_image_from_url', 'buddyforms_upload_image_from_url' ); 1517 1551 add_action( 'wp_ajax_upload_image_from_url', 'buddyforms_upload_image_from_url' ); 1518 1552 function buddyforms_upload_image_from_url() 1519 1553 { 1520 1554 $url = ( isset( $_REQUEST['url'] ) ? wp_kses_post( wp_unslash( $_REQUEST['url'] ) ) : '' ); 1521 1555 $valid_url = strtolower( $url ); 1522 1556 if ( strpos( $valid_url, 'phar://' ) !== false || pathinfo( $valid_url, PATHINFO_EXTENSION ) === 'phar' || strpos( $valid_url, 'php://' ) !== false ) { 1523 1557 return false; 1524 1558 } 1525 1559 $file_id = ( isset( $_REQUEST['id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' ); 1526 1560 $accepted_files = ( isset( $_REQUEST['accepted_files'] ) ? explode( ',', buddyforms_sanitize( '', wp_unslash( $_REQUEST['accepted_files'] ) ) ) : array( 'jpeg' ) ); 1527 1561 1528 1562 if ( !empty($url) && !empty($file_id) ) { 1529 1563 $upload_dir = wp_upload_dir(); 1530 1564 $image_url = urldecode( $url ); 1531 1565 $image_data = file_get_contents( $image_url ); 1532 1566 // Get image data 1533 1567 $image_data_information = getimagesize( $image_url ); 1534 1568 $image_mime_information = $image_data_information['mime']; 1535 1569 1536 1570 if ( !in_array( $image_mime_information, $accepted_files ) ) { 1537 1571 echo wp_json_encode( array( 1538 1572 'status' => 'FAILED', 1539 1573 'response' => __( 'File type ' . $image_mime_information . ' is not allowed.', 'budduforms' ), 1540 1574 ) ) ; 1541 1575 die; 1542 1576 } 1543 1577 1544 1578 1545 1579 if ( $image_data && $image_data_information ) { 1546 1580 $file_name = $file_id . '.png'; 1547 1581 $full_path = wp_normalize_path( $upload_dir['path'] . DIRECTORY_SEPARATOR . $file_name ); 1548 1582 $upload_file = wp_upload_bits( $file_name, null, $image_data ); 1549 1583 1550 1584 if ( !$upload_file['error'] ) { 1551 1585 $wp_filetype = wp_check_filetype( $file_name, null ); 1552 1586 $attachment = array( 1553 1587 'post_mime_type' => $wp_filetype['type'], 1554 1588 'post_title' => preg_replace( '/\\.[^.]+$/', '', $file_name ), 1555 1589 'post_content' => '', 1556 1590 'post_status' => 'inherit', 1557 1591 ); 1558 1592 $attachment_id = wp_insert_attachment( $attachment, $upload_file['file'] ); 1559 1593 $url = wp_get_attachment_thumb_url( $attachment_id ); 1560 1594 echo wp_json_encode( array( 1561 1595 'status' => 'OK', 1562 1596 'response' => $url, 1563 1597 'attachment_id' => $attachment_id, 1564 1598 ) ) ; 1565 1599 die; 1566 1600 } else { 1567 1601 echo wp_json_encode( array( 1568 1602 'status' => 'FAILED', 1569 1603 'response' => 'Error uploading image.', 1570 1604 ) ) ; 1571 1605 die; 1572 1606 } 1573 1607 1574 1608 } else { 1575 1609 echo wp_json_encode( array( 1576 1610 'status' => 'FAILED', 1577 1611 'response' => 'The Url provided is not an image.', 1578 1612 ) ) ; 1579 1613 die; 1580 1614 } 1581 1615 1582 1616 } else { 1583 1617 echo wp_json_encode( array( 1584 1618 'status' => 'FAILED', 1585 1619 'response' => 'Wrong Format or Empty Url.', 1586 1620 ) ) ; 1587 1621 die; 1588 1622 } 1589 1623 1590 1624 } 1591 1625 1592 1626 /** 1593 1627 * Check if a file was include into the global php queue 1594 1628 * 1595 1629 * @param $file_name 1596 1630 * 1597 1631 * @return bool 1598 1632 * @since 2.2.8 1599 1633 * 1600 1634 * @author gfirem 1601 1635 */ 1602 1636 function buddyforms_check_loaded_file( $file_name ) 1603 1637 { 1604 1638 $includes_files = get_included_files(); 1605 1639 return in_array( $file_name, $includes_files ); 1606 1640 } 1607 1641 1608 1642 function buddyform_get_role_names() 1609 1643 { 1610 1644 global $wp_roles ; 1611 1645 if ( !isset( $wp_roles ) ) { 1612 1646 $wp_roles = new WP_Roles(); 1613 1647 } 1614 1648 return $wp_roles->get_names(); 1615 1649 } 1616 1650 1617 1651 /** 1618 1652 * Get a tag inside a shortcode from a given content. 1619 1653 * 1620 1654 * @param array $shortcodes 1621 1655 * @param array $targets_tags 1622 1656 * @param string $content 1623 1657 * 1624 1658 * @return string 1625 1659 * @since 2.3.1 1626 1660 */ 1627 1661 function buddyforms_get_shortcode_tag( $shortcodes, $targets_tags, $content ) 1628 1662 { 1629 1663 if ( !is_array( $shortcodes ) || !is_array( $targets_tags ) ) { 1630 1664 return ''; 1631 1665 } 1632 1666 foreach ( $shortcodes as $shortcode ) { 1633 1667 $regrex = sprintf( '(\\[%s)(.*?)form_slug=\\"(.*?)\\"', $shortcode ); 1634 1668 preg_match_all( "/{$regrex}/m", $content, $match ); 1635 1669 if ( !empty($match) && !empty($match[1][0]) && $match[1][0] === '[' . $shortcode && !empty($match[3][0]) ) { 1636 1670 return $match[3][0]; 1637 1671 } 1638 1672 } 1639 1673 $pattern = get_shortcode_regex(); 1640 1674 $result = ''; 1641 1675 preg_replace_callback( "/{$pattern}/m", function ( $tag ) use( $shortcodes, $targets_tags, &$result ) { 1642 1676 foreach ( $shortcodes as $shortcode_item ) { 1643 1677 1644 1678 if ( $shortcode_item === $tag[2] ) { 1645 1679 $attributes = shortcode_parse_atts( $tag[3] ); 1646 1680 if ( !empty($attributes) ) { 1647 1681 foreach ( $targets_tags as $target_item ) { 1648 1682 1649 1683 if ( array_key_exists( $target_item, $attributes ) ) { 1650 1684 $result = $attributes[$target_item]; 1651 1685 return $tag[0]; 1652 1686 } 1653 1687 1654 1688 } 1655 1689 } 1656 1690 } 1657 1691 1658 1692 } 1659 1693 return $tag[0]; 1660 1694 }, $content ); 1661 1695 return $result; 1662 1696 } 1663 1697 1664 1698 /** 1665 1699 * Extract the form slug from a html inside the given content reading the inout hidden with the Id `form_slug` 1666 1700 * 1667 1701 * @param $content 1668 1702 * 1669 1703 * @return string 1670 1704 */ 1671 1705 function buddyforms_get_form_slug_from_html( $content ) 1672 1706 { 1673 1707 if ( !empty($content) ) { 1674 1708 try { 1675 1709 libxml_use_internal_errors( true ); 1676 1710 $dom = new DOMDocument(); 1677 1711 $dom->validateOnParse = false; 1678 1712 $content = mb_convert_encoding( $content, 'HTML-ENTITIES', 'UTF-8' ); 1679 1713 $dom->loadHTML( $content ); 1680 1714 $form_input_node = $dom->getElementById( 'form_slug' ); 1681 1715 libxml_use_internal_errors( false ); 1682 1716 if ( !empty($form_input_node) && $form_input_node instanceof DOMElement ) { 1683 1717 return $form_input_node->getAttribute( 'value' ); 1684 1718 } 1685 1719 } catch ( Exception $e ) { 1686 1720 } 1687 1721 } 1688 1722 return ''; 1689 1723 } 1690 1724 1691 1725 /** 1692 1726 * Extract the form slug from a shortcode inside the given content 1693 1727 * 1694 1728 * @param $content 1695 1729 * @param array $shortcodes 1696 1730 * 1697 1731 * @return string 1698 1732 */ 1699 1733 function buddyforms_get_form_slug_from_shortcode( $content, $shortcodes = array( 'bf', 'buddyforms_form' ) ) 1700 1734 { 1701 1735 $form_slug = buddyforms_get_shortcode_tag( $shortcodes, array( 'form_slug', 'id' ), $content ); 1702 1736 1703 1737 if ( is_numeric( $form_slug ) ) { 1704 1738 $form_post = get_post( $form_slug ); 1705 1739 $form_slug = $form_post->post_name; 1706 1740 } 1707 1741 1708 1742 return $form_slug; 1709 1743 } 1710 1744 1711 1745 /** 1712 1746 * 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 1713 1747 * 1714 1748 * @param $content 1715 1749 * @param array $shortcodes 1716 1750 * 1717 1751 * @return string 1718 1752 */ 1719 1753 function buddyforms_get_form_slug_from_content( $content, $shortcodes = array( 1720 1754 'bf-list-submissions', 1721 1755 'buddyforms_form', 1722 1756 'buddyforms_list_all', 1723 1757 'buddyforms_the_loop', 1724 1758 'bf', 1725 1759 'buddyforms_reset_password' 1726 1760 ) ) 1727 1761 { 1728 1762 // Extract from the a shortcode inside the content 1729 1763 $form_slug = buddyforms_get_shortcode_tag( $shortcodes, array( 'form_slug', 'id' ), $content ); 1730 1764 // Extract form the html inside the content, reading the hidden input form_slug 1731 1765 1732 1766 if ( empty($form_slug) ) { 1733 1767 // use regex to extract 1734 1768 $regex = array(); 1735 1769 preg_match( '/<input type="hidden" name="form_slug" value="(.*?)" id="form_slug"/m', $content, $regex ); 1736 1770 if ( !empty($regex) && isset( $regex[1] ) ) { 1737 1771 1738 1772 if ( is_array( $regex[1] ) ) { 1739 1773 $form_slug = $regex[1][0]; 1740 1774 } else { 1741 1775 $form_slug = $regex[1]; 1742 1776 } 1743 1777 1744 1778 } 1745 1779 1746 1780 if ( empty($form_slug) ) { 1747 1781 $regex = array(); 1748 1782 preg_match( '/"bf_form_slug":"(.+?)"(?=.")/m', $content, $regex ); 1749 1783 // gutenberg block 1750 1784 if ( !empty($regex) && isset( $regex[1] ) ) { 1751 1785 $form_slug = $regex[1]; 1752 1786 } 1753 1787 } 1754 1788 1755 1789 1756 1790 if ( empty($form_slug) ) { 1757 1791 $regex = array(); 1758 1792 preg_match( '/"bf_form_slug":"(.*)"/m', $content, $regex ); 1759 1793 // gutenberg block 1760 1794 if ( !empty($regex) && isset( $regex[1] ) ) { 1761 1795 $form_slug = $regex[1]; 1762 1796 } 1763 1797 } 1764 1798 1765 1799 } 1766 1800 1767 1801 1768 1802 if ( is_numeric( $form_slug ) ) { 1769 1803 $form_post = get_post( $form_slug ); 1770 1804 $form_slug = $form_post->post_name; 1771 1805 } 1772 1806 1773 1807 return $form_slug; 1774 1808 } 1775 1809 1776 1810 /** 1777 1811 * Detext if is gutenberg 1778 1812 * 1779 1813 * @return boolean 1780 1814 */ 1781 1815 function buddyforms_is_gutenberg_page() 1782 1816 { 1783 1817 if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { 1784 1818 // The Gutenberg plugin is on. 1785 1819 return true; 1786 1820 } 1787 1821 require_once ABSPATH . 'wp-admin/includes/screen.php'; 1788 1822 require_once ABSPATH . 'wp-admin/includes/admin.php'; 1789 1823 $current_screen = get_current_screen(); 1790 1824 if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { 1791 1825 // Gutenberg page on 5+. 1792 1826 return true; 1793 1827 } 1794 1828 return false; 1795 1829 } 1796 1830 1797 1831 /** 1798 1832 * This function secure the array of options to use in the buddyformsGlobal 1799 1833 * 1800 1834 * @param $options 1801 1835 * @param $form_slug 1802 1836 * @param $bf_post_id 1803 1837 * 1804 1838 * @return mixed 1805 1839 * @since 2.4.0 1806 1840 */ 1807 1841 function buddyforms_filter_frontend_js_form_options( $options, $form_slug, $bf_post_id = 0 ) 1808 1842 { 1809 1843 /** 1810 1844 * Let the user change the user granted options to use in the frontend global variable buddyformsGlobal 1811 1845 * 1812 1846 * @param array granted keys from the options 1813 1847 * @param string The form slug from the global wp_query 1814 1848 * @param number The current post id form the wp_query. This can be empty when the form is creating an entry. 1815 1849 * 1816 1850 * @since 2.4.0 1817 1851 */ 1818 1852 $granted = apply_filters( 1819 1853 'buddyforms_frontend_granted_forms_option', 1820 1854 array( 1821 1855 'status', 1822 1856 'form_fields', 1823 1857 'draft_action', 1824 1858 'js_validation' 1825 1859 ), 1826 1860 $form_slug, 1827 1861 $bf_post_id 1828 1862 ); 1829 1863 foreach ( $granted as $item ) { 1830 1864 if ( isset( $options[$item] ) ) { 1831 1865 $result[$item] = $options[$item]; 1832 1866 } 1833 1867 } 1834 1868 // Filter the field options 1835 1869 $remove_field_options = apply_filters( 1836 1870 'buddyforms_remove_frontend_forms_fields_option', 1837 1871 array( 'captcha_private_key' ), 1838 1872 $form_slug, 1839 1873 $bf_post_id 1840 1874 ); 1841 1875 if ( !empty($result['form_fields']) ) { 1842 1876 foreach ( $remove_field_options as $remove_field ) { 1843 1877 foreach ( $result['form_fields'] as $field_id => $field ) { 1844 1878 if ( isset( $field[$remove_field] ) ) { 1845 1879 unset( $result['form_fields'][$field_id][$remove_field] ); 1846 1880 } 1847 1881 } 1848 1882 } 1849 1883 } 1850 1884 return $result; 1851 1885 } 1852 1886 1853 1887 /** 1854 1888 * Retrieve the form slug from different sources 1855 1889 * 1856 1890 * @return string 1857 1891 * @since 2.4.0 1858 1892 */ 1859 1893 function buddyforms_get_form_slug() 1860 1894 { 1861 1895 $form_slug = ''; 1862 1896 global $wp_query, $post ; 1863 1897 1864 1898 if ( !empty($wp_query->query_vars['bf_form_slug']) ) { 1865 1899 $form_slug = sanitize_title( $wp_query->query_vars['bf_form_slug'] ); 1866 1900 } elseif ( !empty($_GET['form_slug']) ) { 1867 1901 $form_slug = sanitize_title( wp_unslash( $_GET['form_slug'] ) ); 1868 1902 } elseif ( !empty($wp_query->query_vars['form_slug']) ) { 1869 1903 $form_slug = sanitize_title( $wp_query->query_vars['form_slug'] ); 1870 1904 } elseif ( !empty($post) ) { 1871 1905 $post_content = ( !empty($content) ? $content : $post->post_content ); 1872 1906 1873 1907 if ( !empty($post->post_name) && $post->post_type === 'buddyforms' ) { 1874 1908 $form_slug = $post->post_name; 1875 1909 } elseif ( !empty($post_content) ) { 1876 1910 // Extract the shortcode inside the content 1877 1911 $form_slug = buddyforms_get_form_slug_from_content( $post_content ); 1878 1912 if ( empty($form_slug) ) { 1879 1913 $form_slug = buddyforms_get_form_slug_by_post_id( $post->ID ); 1880 1914 } 1881 1915 } 1882 1916 1883 1917 } elseif ( function_exists( 'bp_current_component' ) && function_exists( 'bp_current_action' ) && function_exists( 'buddyforms_members_get_form_by_member_type' ) ) { 1884 1918 global $buddyforms_member_tabs ; 1885 1919 $bp_action = bp_current_action(); 1886 1920 $bp_component = bp_current_component(); 1887 1921 1888 1922 if ( !empty($buddyforms_member_tabs) && 'xprofile' !== $bp_component ) { 1889 1923 $form_slug = ( !empty($buddyforms_member_tabs[bp_current_component()][bp_current_action()]) ? $buddyforms_member_tabs[bp_current_component()][bp_current_action()] : '' ); 1890 1924 1891 1925 if ( $form_slug . '-create' !== $bp_action && $form_slug . '-edit' !== $bp_action && $form_slug . '-revision' !== $bp_action ) { 1892 1926 $member_type = bp_get_member_type( get_current_user_id() ); 1893 1927 $form_slug = buddyforms_members_get_form_by_member_type( $member_type ); 1894 1928 if ( !$form_slug ) { 1895 1929 $form_slug = buddyforms_members_get_form_by_member_type( 'none' ); 1896 1930 } 1897 1931 } 1898 1932 1899 1933 } 1900 1934 1901 1935 } 1902 1936 1903 1937 return $form_slug; 1904 1938 } 1905 1939 1906 1940 /** 1907 1941 * Check if the draft is enabled for the given form slug 1908 1942 * 1909 1943 * @param $form_slug 1910 1944 * @param string $permission 1911 1945 * 1912 1946 * @return bool 1913 1947 * @since 2.5.14 1914 1948 * @author gfirem 1915 1949 */ 1916 1950 function buddyforms_is_permission_enabled( $form_slug, $permission = 'draft' ) 1917 1951 { 1918 1952 $result = wp_cache_get( 'buddyforms_user_capability_for_' . $form_slug . '_draft', 'buddyforms' ); 1919 1953 1920 1954 if ( !empty($form_slug) && $result === false ) { 1921 1955 /** @var WP_User $current_user */ 1922 1956 $current_user = wp_get_current_user(); 1923 1957 1924 1958 if ( empty($current_user) ) { 1925 1959 $result = false; 1926 1960 } else { 1927 1961 $result = bf_user_can( 1928 1962 $current_user->ID, 1929 1963 'buddyforms_' . $form_slug . '_' . $permission, 1930 1964 array(), 1931 1965 $form_slug 1932 1966 ); 1933 1967 } 1934 1968 1935 1969 wp_cache_set( 'buddyforms_user_capability_for_' . $form_slug . '_draft', $result, 'buddyforms' ); 1936 1970 } 1937 1971 1938 1972 return $result; 1939 1973 } 1940 1974 1941 1975 /** 1942 1976 * Get the form actions. This function is used to handle the form actions if the form have a form_action element or if not 1943 1977 * 1944 1978 * @param $form Form 1945 1979 * @param $form_slug 1946 1980 * @param $post_id 1947 1981 * @param $field_options 1948 1982 * 1949 1983 * @return Form 1950 1984 * @since 2.4.0 1951 1985 */ 1952 1986 function buddyforms_form_action_buttons( 1953 1987 $form, 1954 1988 $form_slug, 1955 1989 $post_id, 1956 1990 $field_options 1957 1991 ) 1958 1992 { 1959 1993 global $buddyforms ; 1960 1994 $exist_field_status = buddyforms_exist_field_type_in_form( $form_slug, 'status' ); 1961 1995 $is_draft_permission_enabled = buddyforms_is_permission_enabled( $form_slug ); 1962 1996 $is_form_element_action = !empty($field_options); 1963 1997 1964 1998 if ( $is_form_element_action ) { 1965 1999 $is_field_publish_enabled = empty($field_options['disabled_publish']); 1966 2000 $is_edit_permission_enabled = buddyforms_is_permission_enabled( $form_slug, 'edit' ); 1967 2001 $is_create_permission_enabled = buddyforms_is_permission_enabled( $form_slug, 'create' ); 1968 2002 $is_draft_enabled = $is_draft_permission_enabled || $is_create_permission_enabled && !$is_edit_permission_enabled && $is_draft_permission_enabled; 1969 2003 } else { 1970 2004 $is_draft_enabled = $is_draft_permission_enabled; 1971 2005 $is_field_publish_enabled = true; 1972 2006 } 1973 2007 1974 2008 $bfdesign = ( isset( $buddyforms[$form_slug]['layout'] ) ? $buddyforms[$form_slug]['layout'] : array() ); 1975 2009 $form_type = ( isset( $buddyforms[$form_slug]['form_type'] ) ? $buddyforms[$form_slug]['form_type'] : '' ); 1976 2010 $form_status = ( isset( $buddyforms[$form_slug]['status'] ) ? $buddyforms[$form_slug]['status'] : 'publish' ); 1977 2011 $button_class = ( !empty($bfdesign['button_class']) ? $bfdesign['button_class'] : '' ); 1978 2012 $include_form_draft_button = apply_filters( 1979 2013 'buddyforms_include_form_draft_button', 1980 2014 true, 1981 2015 $form_slug, 1982 2016 $form, 1983 2017 $post_id 1984 2018 ); 1985 2019 if ( $is_draft_enabled && $include_form_draft_button ) { 1986 2020 1987 2021 if ( !$exist_field_status && $form_type === 'post' && is_user_logged_in() ) { 1988 2022 $bf_draft_button_text = ( !empty($bfdesign['draft_text']) ? $bfdesign['draft_text'] : apply_filters( 'buddyforms_draft_button_text', __( 'Save as draft', 'buddyforms' ), $form_slug ) ); 1989 2023 $bf_draft_button_classes = 'bf-draft ' . $button_class; 1990 2024 $bf_draft_button = new Element_Button( $bf_draft_button_text, 'submit', array( 1991 2025 'id' => $form_slug . '-draft', 1992 2026 'class' => $bf_draft_button_classes, 1993 2027 'name' => 'draft', 1994 2028 'formnovalidate' => 'formnovalidate', 1995 2029 'data-target' => $form_slug, 1996 2030 'data-status' => 'draft', 1997 2031 ) ); 1998 2032 if ( $bf_draft_button ) { 1999 2033 $form->addElement( $bf_draft_button ); 2000 2034 } 2001 2035 } 2002 2036 2003 2037 } 2004 2038 $include_form_submit_button = apply_filters( 2005 2039 'buddyforms_include_form_submit_button', 2006 2040 true, 2007 2041 $form_slug, 2008 2042 $form, 2009 2043 $post_id 2010 2044 ); 2011 2045 2012 2046 if ( $is_field_publish_enabled && $include_form_submit_button ) { 2013 2047 $bf_publish_button_classes = 'bf-submit ' . $button_class; 2014 2048 2015 2049 if ( !empty($form_type) && $form_type === 'post' && !$exist_field_status ) { 2016 2050 $bf_button_text = ( !empty($bfdesign['submit_text']) ? $bfdesign['submit_text'] : __( 'Publish', 'buddyforms' ) ); 2017 2051 } else { 2018 2052 $bf_button_text = ( !empty($bfdesign['submit_text']) ? $bfdesign['submit_text'] : __( 'Submit', 'buddyforms' ) ); 2019 2053 } 2020 2054 2021 2055 $bf_submit_button = new Element_Button( $bf_button_text, 'submit', array( 2022 2056 'id' => $form_slug, 2023 2057 'class' => $bf_publish_button_classes, 2024 2058 'name' => 'submitted', 2025 2059 'data-target' => $form_slug, 2026 2060 'data-status' => $form_status, 2027 2061 ) ); 2028 2062 $form->addElement( $bf_submit_button ); 2029 2063 } 2030 2064 2031 2065 $form = apply_filters( 2032 2066 'buddyforms_create_edit_form_button', 2033 2067 $form, 2034 2068 $form_slug, 2035 2069 $post_id 2036 2070 ); 2037 2071 return $form; 2038 2072 } 2039 2073 2040 2074 if ( !function_exists( 'buddyforms_show_error_messages' ) ) { 2041 2075 // displays error messages from form submissions 2042 2076 function buddyforms_show_error_messages() 2043 2077 { 2044 2078 $global_error = ErrorHandler::get_instance(); 2045 2079 $global_bf_error = $global_error->get_global_error(); 2046 2080 if ( !empty($global_bf_error) ) { 2047 2081 2048 2082 if ( $global_bf_error->has_errors() ) { 2049 2083 echo '<div class="bf-alert error">' ; 2050 2084 /** 2051 2085 * @var string|int $code 2052 2086 * @var BuddyForms_Error|WP_Error $error 2053 2087 */ 2054 2088 foreach ( $global_error->get_global_error()->errors as $code => $error ) { 2055 2089 $message = $global_error->get_global_error()->get_error_message( $code ); 2056 2090 if ( is_array( $message ) ) { 2057 2091 $message = $message[0]; 2058 2092 } 2059 2093 echo '<span class="buddyforms_error" data-error-code="' . esc_attr( $code ) . '"><strong>' . esc_html__( 'Error', 'buddyforms' ) . '</strong>: ' . esc_html( $message ) . '</span><br/>' ; 2060 2094 } 2061 2095 echo '</div>' ; 2062 2096 } 2063 2097 2064 2098 } 2065 2099 } 2066 2100 2067 2101 } 2068 2102 if ( !function_exists( 'buddyforms_reset_password_errors' ) ) { 2069 2103 // used for tracking error messages 2070 2104 function buddyforms_reset_password_errors() 2071 2105 { 2072 2106 $global_error = ErrorHandler::get_instance(); 2073 2107 return $global_error->get_global_error(); 2074 2108 } 2075 2109 2076 2110 } 2077 2111 /** 2078 2112 * Check whether the specified user has a given capability on a given site. 2079 2113 * 2080 2114 * @param int $user_id 2081 2115 * @param string $capability Capability or role name. 2082 2116 * @param string $form_slug 2083 2117 * @param array|int $args { 2084 2118 * Array of extra arguments applicable to the capability check. 2085 2119 * 2086 2120 * @return bool True if the user has the cap for the given parameters. 2087 2121 * @since 2.5.0 2088 2122 */ 2089 2123 function bf_user_can( 2090 2124 $user_id, 2091 2125 $capability, 2092 2126 $args = array(), 2093 2127 $form_slug = '' 2094 2128 ) 2095 2129 { 2096 2130 if ( !empty($form_slug) ) { 2097 2131 $switched = buddyforms_switch_to_form_blog( $form_slug ); 2098 2132 } 2099 2133 $user = get_user_by( 'ID', $user_id ); 2100 2134 if ( !$user || !$user->exists() ) { 2101 2135 return false; 2102 2136 } 2103 2137 $result = $user->has_cap( $capability ); 2104 2138 if ( !empty($switched) ) { 2105 2139 restore_current_blog(); 2106 2140 } 2107 2141 return $result; 2108 2142 } 2109 2143 2110 2144 /** 2111 2145 * Array of fields slug to exclude from the submission columns and email table 2112 2146 * 2113 2147 * since 2.5.0 2114 2148 * 2115 2149 * @return mixed|void 2116 2150 */ 2117 2151 function buddyforms_get_exclude_field_slugs() 2118 2152 { 2119 2153 return apply_filters( 'buddyforms_submission_exclude_columns', array( 'user_pass', 'captcha', 'html' ) ); 2120 2154 } 2121 2155 2122 2156 /** 2123 2157 * Sanitizes a slug for an element, replacing whitespace and a few other characters with dashes. 2124 2158 * 2125 2159 * @param string $slug The title to be sanitized. 2126 2160 * @param string $context Optional. The operation for which the string is sanitized. 2127 2161 * 2128 2162 * @return string The sanitized title. 2129 2163 * @since 2.5.6 2130 2164 * 2131 2165 * @see sanitize_title_with_dashes 2132 2166 */ 2133 2167 function buddyforms_sanitize_slug( $slug, $context = 'save' ) 2134 2168 { 2135 2169 $slug = strip_tags( $slug ); 2136 2170 // Preserve escaped octets. 2137 2171 $slug = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $slug ); 2138 2172 // Remove percent signs that are not part of an octet. 2139 2173 $slug = str_replace( '%', '', $slug ); 2140 2174 // Restore octets. 2141 2175 $slug = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $slug ); 2142 2176 if ( seems_utf8( $slug ) ) { 2143 2177 $slug = utf8_uri_encode( $slug, 200 ); 2144 2178 } 2145 2179 2146 2180 if ( 'save' == $context ) { 2147 2181 // Convert nbsp, ndash and mdash to hyphens 2148 2182 $slug = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $slug ); 2149 2183 // Convert nbsp, ndash and mdash HTML entities to hyphens 2150 2184 $slug = str_replace( array( 2151 2185 ' ', 2152 2186 ' ', 2153 2187 '–', 2154 2188 '–', 2155 2189 '—', 2156 2190 '—' 2157 2191 ), '-', $slug ); 2158 2192 // Convert forward slash to hyphen 2159 2193 $slug = str_replace( '/', '-', $slug ); 2160 2194 // Strip these characters entirely 2161 2195 $slug = str_replace( array( 2162 2196 // soft hyphens 2163 2197 '%c2%ad', 2164 2198 // iexcl and iquest 2165 2199 '%c2%a1', 2166 2200 '%c2%bf', 2167 2201 // angle quotes 2168 2202 '%c2%ab', 2169 2203 '%c2%bb', 2170 2204 '%e2%80%b9', 2171 2205 '%e2%80%ba', 2172 2206 // curly quotes 2173 2207 '%e2%80%98', 2174 2208 '%e2%80%99', 2175 2209 '%e2%80%9c', 2176 2210 '%e2%80%9d', 2177 2211 '%e2%80%9a', 2178 2212 '%e2%80%9b', 2179 2213 '%e2%80%9e', 2180 2214 '%e2%80%9f', 2181 2215 // copy, reg, deg, hellip and trade 2182 2216 '%c2%a9', 2183 2217 '%c2%ae', 2184 2218 '%c2%b0', 2185 2219 '%e2%80%a6', 2186 2220 '%e2%84%a2', 2187 2221 // acute accents 2188 2222 '%c2%b4', 2189 2223 '%cb%8a', 2190 2224 '%cc%81', 2191 2225 '%cd%81', 2192 2226 // grave accent, macron, caron 2193 2227 '%cc%80', 2194 2228 '%cc%84', 2195 2229 '%cc%8c', 2196 2230 ), '', $slug ); 2197 2231 // Convert times to x 2198 2232 $slug = str_replace( '%c3%97', 'x', $slug ); 2199 2233 } 2200 2234 2201 2235 $slug = preg_replace( '/&.+?;/', '', $slug ); 2202 2236 // kill entities 2203 2237 $slug = str_replace( '.', '-', $slug ); 2204 2238 $slug = preg_replace( '/[^%a-zA-Z0-9 _-]/', '', $slug ); 2205 2239 $slug = preg_replace( '/\\s+/', '-', $slug ); 2206 2240 $slug = preg_replace( '|-+|', '-', $slug ); 2207 2241 $slug = trim( $slug, '-' ); 2208 2242 return $slug; 2209 2243 } 2210 2244 2211 2245 /** 2212 2246 * Override the form_slug from the loop to get the correct base on the current post 2213 2247 * 2214 2248 * @param $form_slug 2215 2249 * @param $post_id 2216 2250 * 2217 2251 * @return string 2218 2252 * 2219 2253 * @since 2.5.17 2220 2254 */ 2221 2255 function buddyforms_contact_author_loop_form_slug( $form_slug, $post_id ) 2222 2256 { 2223 2257 if ( !empty($post_id) && function_exists( 'buddyforms_get_form_slug_by_post_id' ) ) { 2224 2258 $form_slug = buddyforms_get_form_slug_by_post_id( $post_id ); 2225 2259 } 2226 2260 return $form_slug; 2227 2261 } 2228 2262 2229 2263 add_filter( 2230 2264 'buddyforms_loop_form_slug', 2231 2265 'buddyforms_contact_author_loop_form_slug', 2232 2266 10, 2233 2267 2 2234 2268 ); 2235 2269 /** 2236 2270 * Enqueue buddyforms thickbox wrapper 2237 2271 * 2238 2272 * @since 2.5.19 2239 2273 */ 2240 2274 function buddyforms_add_bf_thickbox() 2241 2275 { 2242 2276 wp_enqueue_script( 'buddyforms-thickbox' ); 2243 2277 wp_enqueue_style( 'buddyforms-thickbox' ); 2244 2278 } 2245 2279 2246 2280 add_filter( 2247 2281 'buddyforms_mail_to_before_send_notification', 2248 2282 'buddyforms_process_shortcode_notificate_to_attr', 2249 2283 10, 2250 2284 2 2251 2285 ); 2252 2286 function buddyforms_process_shortcode_notificate_to_attr( $mail_to, $notification ) 2253 2287 { 2254 2288 2255 2289 if ( isset( $_POST['notificate_to'] ) && !empty($_POST['notificate_to']) ) { 2256 2290 $notificate_to = sanitize_text_field( wp_unslash( $_POST['notificate_to'] ) ); 2257 2291 $notificate_to = trim( preg_replace( '/\\s+/', '', $notificate_to ) ); 2258 2292 $notificate_to = explode( ',', $notificate_to ); 2259 2293 foreach ( $notificate_to as $value ) { 2260 2294 $_notificate_to = explode( '-', $value ); 2261 2295 $mail_trigger_id = $_notificate_to[0]; 2262 2296 $user_email = sanitize_email( $_notificate_to[1] ); 2263 2297 // Check if mail_trigger_id match with current notification. 2264 2298 if ( $notification['mail_trigger_id'] === $mail_trigger_id && is_email( $user_email ) ) { 2265 2299 array_push( $mail_to, $user_email ); 2266 2300 } 2267 2301 } 2268 2302 } 2269 2303 2270 2304 return $mail_to; 2271 2305 } 2272 2306 2273 2307 function buddyforms_add_safe_css_attributes( $atts ) 2274 2308 { 2275 2309 $atts[] = 'display'; 2276 2310 $atts[] = 'visibility'; 2277 2311 return $atts; 2278 2312 } 2279 2313 2280 2314 add_filter( 'safe_style_css', 'buddyforms_add_safe_css_attributes' ); 2281 2315 function buddyforms_wp_kses_allowed_atts() 2282 2316 { 2283 2317 $allowed_tags = array( 2284 2318 'div' => array( 2285 2319 'class' => array(), 2286 2320 'id' => array(), 2287 2321 'hidefocus' => array(), 2288 2322 'tabindex' => array(), 2289 2323 'role' => array(), 2290 2324 'style' => array(), 2291 2325 'action' => array(), 2292 2326 'page' => array(), 2293 2327 'aria-labelledby' => array(), 2294 2328 'aria-haspopup' => array(), 2295 2329 'aria-pressed' => array(), 2296 2330 'aria-label' => array(), 2297 2331 'aria-level' => array(), 2298 2332 'aria-controls' => array(), 2299 2333 'aria-selected' => array(), 2300 2334 'aria-expanded' => array(), 2301 2335 'data-index' => array(), 2302 2336 'data-entry' => array(), 2303 2337 'data-dz-message' => array(), 2304 2338 ), 2305 2339 'span' => array( 2306 2340 'class' => array(), 2307 2341 'id' => array(), 2308 2342 'dir' => array(), 2309 2343 'style' => array(), 2310 2344 'role' => array(), 2311 2345 'aria-haspopup' => array(), 2312 2346 'aria-hidden' => array(), 2313 2347 'aria-expanded' => array(), 2314 2348 'aria-label' => array(), 2315 2349 'aria-disable' => array(), 2316 2350 'aria-labelledby' => array(), 2317 2351 'tabindex' => array(), 2318 2352 'data' => array(), 2319 2353 'data-tip' => array(), 2320 2354 'data-dz-size' => array(), 2321 2355 'data-dz-name' => array(), 2322 2356 'data-dz-uploadprogress' => array(), 2323 2357 'data-dz-errormessage' => array(), 2324 2358 'data-select2-id' => array(), 2325 2359 ), 2326 2360 'strong' => array(), 2327 2361 'p' => array( 2328 2362 'class' => array(), 2329 2363 'id' => array(), 2330 2364 'name' => array(), 2331 2365 'title' => array(), 2332 2366 ), 2333 2367 'style' => array(), 2334 2368 'form' => array( 2335 2369 'class' => array(), 2336 2370 'name' => array(), 2337 2371 'id' => array(), 2338 2372 'action' => array(), 2339 2373 'method' => array(), 2340 2374 'novalidate' => array(), 2341 2375 'target' => array(), 2342 2376 ), 2343 2377 'fieldset' => array(), 2344 2378 'input' => array( 2345 2379 'class' => array(), 2346 2380 'id' => array(), 2347 2381 'name' => array(), 2348 2382 'type' => array(), 2349 2383 'role' => array(), 2350 2384 'style' => array(), 2351 2385 'step' => array(), 2352 2386 'value' => array(), 2353 2387 'field-id' => array(), 2354 2388 'field_id' => array(), 2355 2389 'required' => array(), 2356 2390 'checked' => array(), 2357 2391 'tabindex' => array(), 2358 2392 'pattern' => array(), 2359 2393 'placeholder' => array(), 2360 2394 'autocomplete' => array(), 2361 2395 'autocorrect' => array(), 2362 2396 'autocapitalize' => array(), 2363 2397 'spellcheck' => array(), 2364 2398 'frontend_reset' => array(), 2365 2399 'size' => array(), 2366 2400 'aria' => array(), 2367 2401 'aria-invalid' => array(), 2368 2402 'data' => array(), 2369 2403 'data-form' => array(), 2370 2404 'data-rule-minlength' => array(), 2371 2405 'data-rule-maxlength' => array(), 2372 2406 'placeholder' => array(), 2373 2407 'aria-autocomplete' => array(), 2374 2408 'data-rule-upload-required' => array(), 2375 2409 'data-msg-upload-required' => array(), 2376 2410 'data-rule-featured-image-error' => array(), 2377 2411 'upload_error_validation_message' => array(), 2378 2412 ), 2379 2413 'select' => array( 2380 2414 'class' => array(), 2381 2415 'id' => array(), 2382 2416 'name' => array(), 2383 2417 'type' => array(), 2384 2418 'hidden' => array(), 2385 2419 'multiple' => array(), 2386 2420 'style' => array(), 2387 2421 'value' => array(), 2388 2422 'tabindex' => array(), 2389 2423 'field-id' => array(), 2390 2424 'field_id' => array(), 2391 2425 'required' => array(), 2392 2426 'aria-hidden' => array(), 2393 2427 'data-form' => array(), 2394 2428 'data-action' => array(), 2395 2429 'data-exclude' => array(), 2396 2430 'data-sortable' => array(), 2397 2431 'data-rule-minlength' => array(), 2398 2432 'data-rule-maxlength' => array(), 2399 2433 'data-placeholder' => array(), 2400 2434 'placeholder' => array(), 2401 2435 'data-select2-id' => array(), 2402 2436 ), 2403 2437 'option' => array( 2404 2438 'class' => array(), 2405 2439 'id' => array(), 2406 2440 'name' => array(), 2407 2441 'type' => array(), 2408 2442 'style' => array(), 2409 2443 'value' => array(), 2410 2444 'field-id' => array(), 2411 2445 'field_id' => array(), 2412 2446 'data-form' => array(), 2413 2447 'data-country' => array(), 2414 2448 'data-rule-minlength' => array(), 2415 2449 'data-rule-maxlength' => array(), 2416 2450 'data-unique' => array(), 2417 2451 'placeholder' => array(), 2418 2452 'selected' => array(), 2419 2453 ), 2420 2454 'optgroup' => array( 2421 2455 'class' => array(), 2422 2456 'id' => array(), 2423 2457 'name' => array(), 2424 2458 'label' => array(), 2425 2459 'style' => array(), 2426 2460 'value' => array(), 2427 2461 'field-id' => array(), 2428 2462 'field_id' => array(), 2429 2463 'selected' => array(), 2430 2464 ), 2431 2465 'label' => array( 2432 2466 'for' => array(), 2433 2467 'id' => array(), 2434 2468 'class' => array(), 2435 2469 'style' => array(), 2436 2470 'data' => array(), 2437 2471 'data-tip' => array(), 2438 2472 ), 2439 2473 'link' => array( 2440 2474 'class' => array(), 2441 2475 'id' => array(), 2442 2476 'rel' => array(), 2443 2477 'href' => array(), 2444 2478 'media' => array(), 2445 2479 ), 2446 2480 'a' => array( 2447 2481 'class' => array(), 2448 2482 'id' => array(), 2449 2483 'style' => array(), 2450 2484 'target' => array(), 2451 2485 'href' => array(), 2452 2486 'name' => array(), 2453 2487 'title' => array(), 2454 2488 'type' => array(), 2455 2489 'tabindex' => array(), 2456 2490 'data' => array(), 2457 2491 'data-toggle' => array(), 2458 2492 'data-type' => array(), 2459 2493 'data-row' => array(), 2460 2494 'data-gdpr-type' => array(), 2461 2495 'data-form-slug' => array(), 2462 2496 'onclick' => array(), 2463 2497 ), 2464 2498 'button' => array( 2465 2499 'class' => array(), 2466 2500 'id' => array(), 2467 2501 'type' => array(), 2468 2502 'name' => array(), 2469 2503 'disabled' => array(), 2470 2504 'data-editor' => array(), 2471 2505 'data-wp-editor-id' => array(), 2472 2506 'data-target' => array(), 2473 2507 'data-status' => array(), 2474 2508 'data-template' => array(), 2475 2509 'data-type' => array(), 2476 2510 'onclick' => array(), 2477 2511 'tabindex' => array(), 2478 2512 'role' => array(), 2479 2513 'field-id' => array(), 2480 2514 'field_id' => array(), 2481 2515 'accepted_files' => array(), 2482 2516 'onclick' => array(), 2483 2517 ), 2484 2518 'i' => array( 2485 2519 'class' => array(), 2486 2520 'id' => array(), 2487 2521 'name' => array(), 2488 2522 ), 2489 2523 'abbr' => array( 2490 2524 'class' => array(), 2491 2525 'id' => array(), 2492 2526 'name' => array(), 2493 2527 'title' => array(), 2494 2528 ), 2495 2529 'iframe' => array( 2496 2530 'id' => array(), 2497 2531 'allowtransparency' => array(), 2498 2532 'title' => array(), 2499 2533 'style' => array(), 2500 2534 'frameborder' => array(), 2501 2535 ), 2502 2536 'textarea' => array( 2503 2537 'id' => array(), 2504 2538 'class' => array(), 2505 2539 'name' => array(), 2506 2540 'style' => array(), 2507 2541 'placeholder' => array(), 2508 2542 'data-form' => array(), 2509 2543 'data-rule-minlength' => array(), 2510 2544 'data-rule-maxlength' => array(), 2511 2545 'rows' => array(), 2512 2546 'required' => array(), 2513 2547 'autocomplete' => array(), 2514 2548 'cols' => array(), 2515 2549 'aria-hidden' => array(), 2516 2550 ), 2517 2551 'img' => array( 2518 2552 'id' => array(), 2519 2553 'src' => array(), 2520 2554 'alt' => array(), 2521 2555 'data-dz-thumbnail' => array(), 2522 2556 ), 2523 2557 'svg' => array( 2524 2558 'width' => array(), 2525 2559 'height' => array(), 2526 2560 'alt' => array(), 2527 2561 'viewBox' => array(), 2528 2562 ), 2529 2563 'small' => array( 2530 2564 'class' => array(), 2531 2565 'id' => array(), 2532 2566 'style' => array(), 2533 2567 'name' => array(), 2534 2568 ), 2535 2569 'ul' => array( 2536 2570 'class' => array(), 2537 2571 'id' => array(), 2538 2572 'style' => array(), 2539 2573 'name' => array(), 2540 2574 'role' => array(), 2541 2575 'tabindex' => array(), 2542 2576 'aria-controls' => array(), 2543 2577 'aria-labelledby' => array(), 2544 2578 'aria-selected' => array(), 2545 2579 'aria-expanded' => array(), 2546 2580 ), 2547 2581 'li' => array( 2548 2582 'class' => array(), 2549 2583 'id' => array(), 2550 2584 'style' => array(), 2551 2585 'name' => array(), 2552 2586 'role' => array(), 2553 2587 'tabindex' => array(), 2554 2588 'aria-controls' => array(), 2555 2589 'aria-labelledby' => array(), 2556 2590 'aria-selected' => array(), 2557 2591 'aria-expanded' => array(), 2558 2592 'data-field-id' => array(), 2559 2593 ), 2560 2594 'table' => array( 2561 2595 'class' => array(), 2562 2596 'id' => array(), 2563 2597 'style' => array(), 2564 2598 'name' => array(), 2565 2599 ), 2566 2600 'tbody' => array( 2567 2601 'class' => array(), 2568 2602 'id' => array(), 2569 2603 'style' => array(), 2570 2604 'name' => array(), 2571 2605 ), 2572 2606 'tr' => array( 2573 2607 'class' => array(), 2574 2608 'id' => array(), 2575 2609 'style' => array(), 2576 2610 'name' => array(), 2577 2611 ), 2578 2612 'td' => array( 2579 2613 'class' => array(), 2580 2614 'id' => array(), 2581 2615 'style' => array(), 2582 2616 'name' => array(), 2583 2617 'role' => array(), 2584 2618 'tabindex' => array(), 2585 2619 'colspan' => array(), 2586 2620 ), 2587 2621 'thead' => array( 2588 2622 'class' => array(), 2589 2623 'id' => array(), 2590 2624 'style' => array(), 2591 2625 'name' => array(), 2592 2626 'role' => array(), 2593 2627 'tabindex' => array(), 2594 2628 ), 2595 2629 'th' => array( 2596 2630 'class' => array(), 2597 2631 'id' => array(), 2598 2632 'style' => array(), 2599 2633 'name' => array(), 2600 2634 'role' => array(), 2601 2635 'tabindex' => array(), 2602 2636 'colspan' => array(), 2603 2637 ), 2604 2638 'tfoot' => array( 2605 2639 'class' => array(), 2606 2640 'id' => array(), 2607 2641 'style' => array(), 2608 2642 'name' => array(), 2609 2643 'role' => array(), 2610 2644 'tabindex' => array(), 2611 2645 'colspan' => array(), 2612 2646 ), 2613 2647 'style' => array( 2614 2648 'type' => array(), 2615 2649 ), 2616 2650 'h1' => array( 2617 2651 'class' => array(), 2618 2652 'id' => array(), 2619 2653 'style' => array(), 2620 2654 'name' => array(), 2621 2655 ), 2622 2656 'h2' => array( 2623 2657 'class' => array(), 2624 2658 'id' => array(), 2625 2659 'style' => array(), 2626 2660 'name' => array(), 2627 2661 ), 2628 2662 'h3' => array( 2629 2663 'class' => array(), 2630 2664 'id' => array(), 2631 2665 'style' => array(), 2632 2666 'name' => array(), 2633 2667 ), 2634 2668 'h4' => array( 2635 2669 'class' => array(), 2636 2670 'id' => array(), 2637 2671 'style' => array(), 2638 2672 'name' => array(), 2639 2673 ), 2640 2674 'h5' => array( 2641 2675 'class' => array(), 2642 2676 'id' => array(), 2643 2677 'style' => array(), 2644 2678 'name' => array(), 2645 2679 ), 2646 2680 'strong' => array(), 2647 2681 'br' => array(), 2648 2682 'b' => array( 2649 2683 'class' => array(), 2650 2684 'id' => array(), 2651 2685 'style' => array(), 2652 2686 'name' => array(), 2653 2687 ), 2654 2688 ); 2655 2689 return $allowed_tags; 2656 2690 } -
buddyforms/trunk/readme.txt
r3031945 r3046092 1 1 === Post Form - Registration Form - Profile Form for User Profiles - Frontend Content Forms for User Submissions (UGC) === 2 2 Contributors: svenl77, konrads, themekraft, buddyforms, shabushabu, christianwach, projectkarol, phuck22, gfirem, jnfdev, freemius 3 3 Tags: custom form, form builder, registration, user registration, forms 4 4 Requires at least: 4.0 5 5 Tested up to: 6.4.3 6 Stable tag: 2.8. 76 Stable tag: 2.8.8 7 7 Requires PHP: 5.3 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 11 BuddyForms is a versatile WordPress plugin that allows the creation of post forms, registration forms, profile forms, content forms, and supports file uploads. 12 12 13 13 == Description == 14 14 15 15 Manage your WordPress content effortlessly with BuddyForms, a plugin that simplifies form creation and content management. 16 16 17 17 ###With BuddyForms, you can: 18 18 19 19 ####Create Post Forms 20 20 BuddyForms makes creating and managing post forms simple. Build and customize your forms to meet your needs. 21 21 22 22 ####Generate Registration Forms 23 23 Design your own registration processes with our registration form feature. It's efficient, customizable, and easy to use. 24 24 25 25 ####Craft Profile Forms 26 26 Create profile forms tailored to your users. BuddyForms offers a robust solution for crafting and managing these forms. 27 27 28 28 ####Manage Content Forms 29 29 Streamline your content creation process with our content forms. Handle blog posts, articles, or any other content type. 30 30 31 31 ####Facilitate File Uploads 32 32 With BuddyForms, attaching files, images, or any other media to your forms is effortless. 33 33 34 34 #####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. 35 35 36 36 [youtube https://www.youtube.com/watch?v=DoPLWBBlRvA] 37 37 38 38 39 39 ### Full Gutenberg Support 40 40 41 41 #### Embed Forms 42 42 Embed any BuddyForms Form as Gutenberg Block. Just select the form you like to embed in the block sidebar. 43 43 44 44 #### List Submissions 45 45 You 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. 46 46 47 47 #### Embed Navigation 48 48 Link 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. 49 49 50 50 #### Login/ Logout Form 51 51 Display a login form or a logout button if the user is logged in. 52 52 53 53 54 54 ### Shortcodes 55 55 56 56 #### Display a Form 57 57 Use this shortcode if you wanna show a form on frontend. 58 58 > [bf form_slug="YOUR-FORM-SLUG"] 59 59 60 60 #### Display Submissions 61 61 Use this shortcode if you wanna show a list of entries belonging to a Form. 62 62 The attribute "list_posts_style" is optional and its possible values are "table" or "list" 63 63 > [bf_posts_list form_slug="YOUR-FORM-SLUG" list_posts_style=""] 64 64 65 65 #### Link to Form 66 66 This shortcode will create a link to the form for creating or editing submissions. 67 67 The attribute "label" is optional (the default value is "Add New"). 68 68 > [bf_link_to_form form_slug="YOUR-FORM-SLUG" label=""] 69 69 70 70 #### Link to User Posts 71 71 For logged-in users you can use the following shortcode to display their submissions. 72 72 The attribute "label" is optional (the default value is "View"). 73 73 > [bf_link_to_user_posts form_slug="YOUR-FORM-SLUG" label=""] 74 74 75 75 #### User Posts List 76 76 For logged-in users you can use the following shortcode to display a list of posts. 77 77 > [bf_user_posts_list form_slug="YOUR-FORM-SLUG"] 78 78 79 79 ####Easily submit posts and images directly from the front end of your site. 80 80 81 81 #### 1. Contact Forms 82 82 * Create Custom Contact Forms for your Brand and Business in Minutes 83 83 * Prevent users from submitting false data by setting custom validation rules on your forms 84 84 85 85 #### 2. User Registration Forms 86 86 * Overwrite and customize the WordPress Registration Form. 87 87 * Redirect to a Custom Registration Page 88 88 * Redirect your users to a custom location page or form if they click the activation link. 89 89 * Combine Registration and Post forms and redirect your user to the Post Form after Registration. 90 90 91 91 #### 2. Post Forms - Frontend submission 92 92 * Let users save drafts and let them work on their edits before they send them to moderation 93 93 * Define the Permission for a user role and grant create edit and delete rights 94 94 * Define Moderators to manage submissions from the front end' 95 95 96 96 ## Deeply Tested Solutions Built with BuddyForms you can Trust and rely on. 97 97 98 98 ### Guest Posts Submission Management in WordPress 99 99 Enable Guest Posts Submission Management with Full Moderation from the Front End for Any WordPress Site and Theme. 100 100 [Guest Post Management](https://themekraft.com/wordpress-solutions/guest-posts-submission/) 101 101 102 102 ### Display Your Website Data Anywhere You Choose 103 103 Make all information submitted through a form easily accessible from wherever you like. 104 104 [Display Form Submission Data](https://themekraft.com/wordpress-solutions/display-form-data/) 105 105 106 106 ### Publishing Content in BuddyPress & BuddyBoss Made Easy. 107 107 Enable your users to create content and bring your community to life. Easy Front-End Blogging with BuddyPress and BuddyForms!+ 108 108 [Posting Content in BuddyPress and BuddyBoss](https://themekraft.com/wordpress-solutions/guest-posts-submission/) 109 109 110 110 #### More Supported Solutions. [BuddyForms Solutions](https://themekraft.com/solutions/buddyforms/) 111 111 112 112 #### Form Builder Features 113 113 * Drag and Drop Forms Builder 114 114 * Form Designer to Layout your forms with options and custom css 115 115 * Form Grid to sort form elements in a grid 116 116 * Submission Manager. Find All Forms and there submissions in one place. Post Forms, Registration Forms and Contact Forms 117 117 118 118 #### User Submitted Content 119 119 * 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. 120 120 * Frontend-generated content made possible with Endpoints and ShortCodes for easy access 121 121 * All the tools you need to manage guest posts, Full frontend Moderation Controles and Frontend Post Management 122 122 123 123 #### Supported Frontend Forms 124 124 * Post Form 125 125 * User Registration 126 126 * Contact Form 127 127 * Content Form for any Post Type 128 128 * User profile form 129 129 * Image Upload Form 130 130 * Media Upload Form 131 131 * File upload of any kind (restrict to specific file types) 132 132 * Mixed Custom Post Type and Registration Form 133 133 * Post meta form 134 134 * User meta form 135 135 * Profile form for WordPress user data 136 136 * Author forms for WordPress author data like Bio 137 137 * Change password form 138 138 * Frontend submission 139 139 140 140 ### Free Field Types 141 141 142 142 #### Contact Fields 143 143 * Subject 144 144 * Message 145 145 * User Fields 146 146 * Username 147 147 * User email 148 148 * User First Name 149 149 * User Last Name 150 150 * Password 151 151 * Website 152 152 * About / Bio 153 153 * Date 154 154 * Captcha 155 155 156 156 #### Post Fields 157 157 * Title 158 158 * Content 159 159 * Category 160 160 * Tags 161 161 * Text, Textarea 162 162 * Number 163 163 * Dropdown, Select 164 164 * Radiobutton 165 165 * Checkbox 166 166 167 167 #### Pro Field Types 168 168 * Taxonomy 169 169 * Post Formats 170 170 * Comments 171 171 * Post Status 172 172 * Featured Image 173 173 * File 174 174 * Hidden 175 175 * HTML 176 176 * Date 177 177 * More Fields available by Add-Ons! 178 178 179 179 ### Your Data Protection is Our Priority 180 180 Buddyform is a Full GDPR compliant WordPress Form Builder. 181 181 182 182 #### You get Privacy by Design 183 183 With 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. 184 184 185 185 #### Easy to navigate and User-friendly interface. 186 186 * Easily embed forms anywhere on your website with just shortcodes by blocks or code. 187 187 * Create registration funnels and ask to create a password after clicking on the activation link. 188 188 * Create forms for any kind of user-generated content. 189 189 * Easily define what happens after a user submits content (display a submission message, display the page content, redirect to a specific URL) 190 190 * Enable/Disable comments related to the submitted content, Frontend Revision for users 191 191 * Overwrite the WordPress default Registration Form and Page 192 192 * 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). 193 193 194 194 ### Integrate with other Plugins 195 195 * BuddyPress/ BuddyBoss – Enable all publishing features of BuddyForms in BuddyPress 196 196 * Ultimate Member – Submit and manage posts from your Ultimate Member Profile 197 197 * ACF - Advanced Custom Fields – Integrate Advanced Custom Fields in your forms like native BuddyForms form elements 198 198 * Pods 199 199 * MailPoed 200 200 * WooCommerce – Build your own marketplace with user-submitted products 201 201 * WooCommerce Simple Auctions – Create and manage auctions via front end 202 202 * HubSpot 203 203 * Geo My WP 204 204 205 205 #### Search All Extensions. [BuddyForms Exdtensions](https://themekraft.com/wordpress-product/buddyforms/) 206 206 207 207 ### List of Forms 208 208 * Contact Forms – Collect leads and customer support data 209 209 * Registration Forms – Sign-up users to your webpage 210 210 * Profile Forms – Let your user update their profile information. 211 211 * Login Forms – Grant users access to restricted content 212 212 * Post Forms for Blog Posts – Follow your editorial schedule and keep your blog up-to-date by collecting content from different authors 213 213 214 214 ### List of User Examples 215 215 * Online Directories – Crowdsource categorized data from your community 216 216 * Showcase – Present your recent work or let clients showcase their use cases built with your product or tool 217 217 * News Magazines – Create single articles through collaborative writing among a team of editors 218 218 * How-to’s – Gather a learning community around you, let users share their knowledge and engage discussions on your site 219 219 * Marketplace – Sell and purchase products from different vendors and list all the product features 220 220 * Content Forms for any kind of user-generated content, user-submitted posts 221 221 222 222 > #### Follow Us 223 223 > [Blog](https://themekraft.com/blog/) | [YouTube](https://www.youtube.com/themekraft) 224 224 225 225 == Installation == 226 226 227 227 Upload the entire BuddyForms folder to the /wp-content/plugins/ directory or install the plugin through the WordPress plugins screen directly. 228 228 Activate the plugin through the 'Plugins' menu in WordPress. 229 229 Head to the 'BuddyForms' menu item in your admin sidebar 230 230 231 231 == Frequently Asked Questions == 232 232 233 233 = How easy is it to create a post form using BuddyForms? = 234 234 Creating 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. 235 235 236 236 = Can I customize the fields in the registration form? = 237 237 Absolutely! 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. 238 238 239 239 = Is it possible to create multiple profile forms for different user roles? = 240 240 Yes, 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. 241 241 242 242 = What types of content forms can I create with BuddyForms? = 243 243 BuddyForms 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. 244 244 245 245 = Can users attach files to the forms? = 246 246 Yes, 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. 247 247 248 248 = Can I create a normal Contact Form = 249 249 Yes, you can create Simple Contact Forms or Complex Contact Forms with different custom fields 250 250 251 251 = Can I Combine Registration Forms and Content Forms = 252 252 Yes, you can add login and registration Form Elements to any form and ask your user to log in or Register during form submission. 253 253 254 254 == Documentation & Support == 255 255 Documentation: [docs.buddyforms.com](http://docs.buddyforms.com/) 256 256 257 257 If 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. 258 258 259 259 == Screenshots == 260 260 261 261 1. Embed Forms - The easy way to embed forms 262 262 2. List Submissions - Display the user Submissions 263 263 3. Embed Navigation - Link to forms and Submissions 264 264 4. Login/ Logout Form - Add Loggin Forms and define a custom redirect after login 265 265 266 266 == Changelog == 267 = 2.8.8 - 06 Mar 2024 = 268 * Improved security. 269 * Fixed issue with creation of pages from submissions setup tab. 270 267 271 = 2.8.7 - 06 Feb 2024 = 268 272 * Added new hook to filter custom field value. 269 273 * Tested up to WordPress 6.4.3 270 274 271 275 = 2.8.6 - 18 Jan 2024 = 272 276 * Fixed XSS issue. 273 277 * Fixed arbitrary file download issue. 274 278 * Fixed issue related with filter submissions by author. 275 279 * Updated Freemius SDK. 276 280 * Tested up to WordPress 6.4.2 277 281 278 282 = 2.8.5 - 21 Nov 2023 = 279 283 * Fixed issue with some file format. 280 284 281 285 = 2.8.4 - 16 Nov 2023 = 282 286 * Updated Freemius SDK. 283 287 * Tested up to WordPress 6.4.1 284 288 285 289 = 2.8.3 - 05 Jul 2023 = 286 290 * Fixed XSS vulnerability. 287 291 * Fixed issue with an upload field and allowed formats. 288 292 * Fixed issue with string max length validation. 289 293 * Tested up to WordPress 6.2.2 290 294 291 295 = 2.8.2 - 11 May 2023 = 292 296 * Fixed vulnerability issue in shortcode. 293 297 294 298 = 2.8.1 - 04 May 2023 = 295 299 * Added a new hook to filter form html content. 296 300 * Updated Freemius SDK. 297 301 * Tested up to WordPress 6.2 298 302 299 303 = 2.8.0 - 22 Mar 2023 = 300 304 * Added a new option to the Form Builder Edit Submission Settings to dynamically define the output from BuddyForms 301 305 302 306 = 2.7.9 - 17 Mar 2023 = 303 307 * Improved phar file verification (issue found by Jesús Miguel Calderón). 304 308 * Fixed issue with new user activation link. 305 309 306 310 = 2.7.8 - 11 Jan 2023 = 307 311 * Fixed vulnerability with image uploaded from URL. 308 312 * Fixed issue with swapped classes in menu items. 309 313 310 314 = 2.7.7 - 23 Dec 2022 = 311 315 * Removed rating admin notice. 312 316 * Removed license activation screen from the free version. 313 317 * Fixed issue with non-existent script. 314 318 * Added missing form element attributes. 315 319 316 320 = 2.7.6 - 16 Dec 2022 = 317 321 * Fixed issue with post content field value. 318 322 * Fixed issue with text area field value after submission. 319 323 * Updated duration of the trial version. 320 324 * Improved Go Pro screen. 321 325 * Updated Freemius SDK. 322 326 323 327 = 2.7.5 - 9 Dec 2022 = 324 328 * Correcting the price of BuddyForms plans in Go Pro screen. 325 329 * Added 5 site license options in the BuddyForms bundle. 326 330 * Correcting misspelt element description in setup meta box. 327 331 328 332 = 2.7.4 - 8 Dec 2022 = 329 333 * Fixed issue with Custom Login extension. 330 334 * Added new pricing screen. 331 335 * Updated Freemius SDK. 332 336 * Tested up with WordPress 6.1.1 333 337 334 338 = 2.7.3 - 18 Nov 2022 = 335 339 * Fixed issue with field validation. 336 340 * Improved forms security. 337 341 * Tested up with WordPress 6.1 338 342 339 343 = 2.7.2 - 08 Sep 2022 = 340 344 * Improved integration with ACF extension. 341 345 * Tested up to WordPress 6.0.2 342 346 343 347 = 2.7.1 - 29 Aug 2022 = 344 348 * Added automatic activation when using a bundle license. 345 349 * Updated bundled link and popup text. 346 350 347 351 = 2.7.0 - 19 Jul 2022 = 348 352 * Fixed issue with field validation. 349 353 350 354 = 2.6.15 - 19 Jul 2022 = 351 355 * Fixed issue with global JS. 352 356 353 357 = 2.6.14 - 19 Jul 2022 = 354 358 * Fixed issue with form render. 355 359 356 360 = 2.6.13 - 16 Jul 2022 = 357 361 * Fixed issue with the required attribute. 358 362 * Fixed issue with email notification table. 359 363 360 364 = 2.6.12 - 13 Jul 2022 = 361 365 * Fixed issue with reCaptcha validation. 362 366 * Fixed issue with email field validation. 363 367 * Tested up to WordPress 6.0.1 364 368 365 369 = 2.6.11 - 06 Jul 2022 = 366 370 * Fixed issue with Post type selection. 367 371 * Fixed issue with form field values. 368 372 369 373 = 2.6.10 - 26 Jun 2022 = 370 374 * Fixed vulnerability issue. 371 375 372 376 = 2.6.9 - 22 Jun 2022 = 373 377 * Fixed security issue. 374 378 375 379 = 2.6.8 - 8 Jun 2022 = 376 380 * Fixed vulnerability issue. 377 381 378 382 = 2.6.7 - 31 May 2022 = 379 383 * Fixed vulnerability issue. 380 384 381 385 = 2.6.6 - 26 May 2022 = 382 386 * Fixed issue with jQuery call. 383 387 * Fixed issue with remote assets call. 384 388 385 389 = 2.6.5 - 26 May 2022 = 386 390 * Fixed security issues. 387 391 * Tested up to WordPress 6.0 388 392 389 393 = 2.6.4 - 17 May 2022 = 390 394 * Fixed issue with phone field validation. 391 395 * Changed format of form error message. 392 396 * Updated readme.txt 393 397 394 398 = 2.6.3 - 16 Mar 2022 = 395 399 * Fixed security issue. 396 400 * Improved handling of JS variables. 397 401 398 402 = 2.6.2 - 11 Mar 2022 = 399 403 * Fixed issue with JS variable conflict. 400 404 * Fixed issue with forms permalinks. 401 405 402 406 = 2.6.1 - 24 Feb 2022 = 403 407 * Changed the position of the descriptive video in the readme.txt 404 408 405 409 = 2.6.0 - 23 Feb 2022 = 406 410 * Disabled affiliate program notices. 407 411 * Fixed issue with taxonomies field type. 408 412 * Added new welcome screen. 409 413 * Tested up to WordPress 5.9 410 414 411 415 = 2.5.32 - 2 Dec 2021 = 412 416 * Added new hook for improve forms render in frontend. 413 417 * Updated readme.txt 414 418 415 419 = 2.5.31 - 10 Jul 2021 = 416 420 * Tested up to WordPress 5.8 417 421 * Fixed issue with Beta Program, now betas should be showing if the user enable the Beta Program. 418 422 * Upated Freemius SDK. 419 423 * Added hook to filter permalink on both the_loop and the_table templates. 420 424 * Added redirect URL fallback if any URL is provided. 421 425 * Added filter (hook) to customize the "Save as draft" button text. 422 426 * Fixed issue with "Allow multiple file upload" option on the File field. 423 427 * Added new filter (hook) to customize buddyforms login form settings. 424 428 * Remove passive feedback. 425 429 * Fixed CSS glitch on the Form Builder. 426 430 * Added method to dequeue conflictive assets from third-party plugins. 427 431 * Added paged attribute on the shortcode buddyforms_the_loop to allow set current page on the pagination. 428 432 * Added two new filters (hooks) to the links pagination on post list. 429 433 * Fixed compatibility issue on the Uplaod field with mp3, zip, and rar file types. 430 434 * Fixed conflict with WPBakery on the Post Edit View at Admin. 431 435 * Added getValues method on the Form class to get element's values more easily. 432 436 * Improvements on the Price field to allow price without thousands separator. 433 437 * Added feature to allow users send notification via shortcode attribute. 434 438 * Improvements on the Price field to allow price without prefix. 435 439 * Added new hook "buddyforms_create_edit_form_add_element" to add or edit form fields on the Frontend. 436 440 * Added JavaScript Hook before and after the garlic init. 437 441 438 442 = 2.5.30 - 17 May 2021 = 439 443 * Fixed/improvement the UI on Checkbox & Radios inputs on the Front-end view of forms. 440 444 * Fixed misleading error message shown on the Category Field in the Form Builder. 441 445 * Fixed issue related with placeholder on select2 fields for Safari 13.x (<=). 442 446 * Improved function to output HTML for Upload and File fields, this improvement its used by BF Hook Fields. 443 447 * Fixed jQuery Validation on select2 fields to avoid trigger other fields validation. 444 448 * Fixed compatibilty issue witn WP 5.7 related with Gutenberg Blocks. 445 449 * Added Time & Date Format to the schedule option of the post_status field. 446 450 * Removed the “Add this field to Metabox” option for the user fields. 447 451 * Fixed to validate mime type when upload image from url is checked. 448 452 * Added the notification feature to the registration forms. 449 453 * Improvements to show login errors on login forms. 450 454 * Remove unused Composer dependencies. 451 455 * improvement on the UI for standard form fields at Front-end. 452 456 * Fixed conflict with ACF metabox on the Form Builder. 453 457 454 458 = 2.5.29 - 19 Feb 2021 = 455 459 * Fixed issue related with wrong server-side validation messages. 456 460 * 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. 457 461 * Improvement/fix the Author selector on the Submissions list page. 458 462 * Fixed for the Password Reset shortcode. The password validation inside was broken!. 459 463 * Fixed conflict between user website and custom fields with a slug set to "website". 460 464 * Deprecated buddyforms_avoid_user_fields_in_forms in favor of buddyforms_avoid_user_fields_slugs_in_forms. 461 465 * Fixed issue related with overridden post on public submissions. 462 466 * Changed version of select2 library to his latest. 463 467 * Fixed issue related to Taxonomies fields, on the first submission (on the post creation) their values were not being saved. 464 468 * Fixed issue related to the values of Checkbox fields when they're shown on the metabox that's on the admin user edit screen. 465 469 * Fixed issue on the fr_FR language file to avoid warnings on BuddyForms admin pages like eg Form Builder. 466 470 * Fixed visual issue related with Taxonomies fields on the Admin Form Builder page. 467 471 * 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. 468 472 469 473 = 2.5.28 - 18 Dec 2020 = 470 474 * Fixed issue related to PHP code in the HTML of template files. 471 475 * Fixed issue related with Featured Image and Dropzone library. 472 476 473 477 = 2.5.27 - 17 Dec 2020 = 474 478 * Add a default page for submissions after enable the plugin. 475 479 * Add labels to the default pages of BuddyForms to improve the user experience. 476 480 * Fixed JS issue related to the feature image and upload form element not working properly. 477 481 * Added Passive Feedback. 478 482 479 483 = 2.5.26 - 7 Dec 2020 = 480 484 * Fixed duplicate Singular Name option on the Form Builder. 481 485 * Fixed the Race Condition issue on Composer dependencies, now all the namespaces in our Composer dependencies are prefixed. 482 486 * Add Portuguese translations with .mo and .po files provided by a customer. 483 487 * Fixed the URL validation for required and non required Website field. 484 488 * Fixed Website field getting value from WordPress cache and not database. 485 489 * Fixed a CCS-issue by adding clearfix class on the form parent container to avoid containers without height. 486 490 * Changed the redirection to the Form Wizard after enabling the plugin, now it will redirect to the Form Builder. 487 491 * Removed several files and references related to the Form Wizard in the code, as a part of the progressive Form Wizard extinction. 488 492 * Added localize strings (translatable strings) to the Suggestions and Warnings displayed on the Password field at the Front-end. 489 493 * Updated the fields output. 490 494 * Fixed default data for the users fields. 491 495 * Removed the add template button from the metabox. 492 496 * Fixed issue related to creation permission. Users without creation permission can't create entries. 493 497 * Added border and hover style on the Form Builder options. 494 498 * Fixed tabs style on the Form Builder. 495 499 * Updated the "Add a Form" process, it was improved to show first the template list. 496 500 * Removed the stripe for the options on the Form Builder. 497 501 * Added border to all tables and tabs outline. 498 502 499 503 = 2.5.25 - 18 Nov 2020 = 500 504 * Fixed to show custom login links only for buddyforms. 501 505 * Fixed a bug in forms using Elementor. 502 506 * Improved compatibility issues with the Divi theme. 503 507 * Improved Buddyforms Form Builder compatibility with TinyMCE plugins on admin Buddyforms pages. 504 508 * Added a new Submission by author filter. 505 509 * Fixed the visual issue with time picker (date form field). 506 510 * Fixed to Prevent Firefox from maintaining previously selected items to ensure all selected items get showing. 507 511 * Fixed the Invalid name attribute in post_excerpt when is a hidden field. 508 512 * Fixed the Invalid "for" attribute (label) in post_excerpt when the labels are shown. 509 513 * Fixed the GDPR Field Templates not loading when the plugin is activated. 510 514 * Fixed the validation for the global variable before using it to replace the args variable. 511 515 * Fixed the Nested ternary expressions (without parentheses) deprecated in PHP 7.4. 512 516 * Fixed the Add min attribute to avoid negative values in Taxonomy Limit Selections. 513 517 * Fixed the add template text to the GDPR when missing. 5208cb1c DESKTOP-5SDFPDV\marin <marin250189@gmail.com> Oct 13, 2020 at 1:04 AM 514 518 * Fixed the Description font style. 515 519 * 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. 516 520 * Fixed to replace deprecated jQuery method "live" by "on". 517 521 * Fixed for the Submitted form override the slug in other forms when submitted on a page with several forms. 518 522 * Fixed previous entry is overridden by the next one when submitted entries from several forms by-one-by on the same page. 519 523 * Fixed to improve the Disable CSS for description option to disabled all the style-related with description if is enabled. 520 524 * Fixed adding spacing on "form-type" meta-box. 521 525 * Fixed issues in the query that gets the last auto-draft associate with the author and form. 522 526 * Fixed to set full-width button on mobile only 523 527 * Added to hidden fields new name option. 524 528 * Fixed issue related with multi-form per page use case. 525 529 * Added a new filter to catch postmeta before get saved on the form builder page submission. 526 530 * Added a user satisfaction wizard to understand more the user and improve the product. 527 531 * Updated Freemius library. 528 532 529 533 = 2.5.22 - 14 Sept 2020 = 530 534 * Fix a code in a wrong position for the BF settings header. 531 535 532 536 = 2.5.21 - 30 Jul 2020 = 533 537 * Fixed styles issue for the entries table. 534 538 * Improved the bf-thickbox library. 535 539 * Improve compatibility with PHP 7.4. 536 540 * Fixed a typo code in the Bcc and Cc email headers. 537 541 * Fixed to add "_bf_registration_user_id" post_meta before the buddyforms_update_post_meta hook. 538 542 * Fixed in scroll validation. 539 543 * Fixed validation in wp-editor (content) field. 540 544 * Fixed Avoid themes hiding .bf_alert messages with less specific CSS rules. 541 545 * Fixed Captcha V3 submission when ajax is not activated. 542 546 * Fixed the case of empty field on the phone validation process. 543 547 * 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. 544 548 * Improved the way localized strings are used in JS. 545 549 * Fixed the tabs css class Incompatibility issue with third party plugins. 546 550 * Fixed attributes assignation to hidden elements. 547 551 * Added option to disabled select2 option for the dropdown. 548 552 * Fixed for the custom classes wasn't showing on the Upload field. 549 553 * Fixed description size style. 550 554 * Fixed font-size description. 551 555 * Fixed password validation issue on page with multiples forms. 552 556 * Fixed issue related to required fields validation on the Wizard. 553 557 * Fixed to Autofill empty slugs and avoid duplicate ones on the Wizard. 554 558 555 559 = 2.5.20 - 9 Jun 2020 = 556 560 * Fixed the header actions in the list of forms. 557 561 * Fixed boostrap compatibility issue form-control class. 558 562 * Fixed the ellipsis function to force to break the strings. 559 563 * Improved Upload form element compatibility. 560 564 * Fixed the hardcoded blank option on the dropdown and added a new settings to make it optional. 561 565 * Improved the form styles. 562 566 * Added compatibility with Divi. 563 567 * Updating freemius. 564 568 * Fixed style in dropdown. 565 569 * Fixed the Category when it suppose to be hidden. 566 570 * Fixed the conditional logic for the Form Builder to show the extra field group. 567 571 * Improved compatibility for PHP 7.4. 568 572 569 573 = 2.5.19 - 17 May 2020 = 570 574 * Fixed the issue related to the lost of osme core styles when the form builder was loaded. 571 575 * Fixed validation message show in the direct input form builder wizzard. 572 576 * Fixed the min and max lenght validation message not showing for the message field. 573 577 * Fixed the add the valid phone number validation. Client and Server side validation. 574 578 * Fixed the field slug missing for some Form Elements. 575 579 * Fixed tje check All option on the permissions tab. 576 580 * Fixed the CheckAll option to not check the disabled columns. 577 581 * Updated the last version of jquery validation. 578 582 * Fixed the override of the required method of jQuery validate to not lose the other methods. 579 583 * Added form element output for all user form elements. 580 584 * Fixed the Category assign for creating post with user form elements. 581 585 * Formatting the code for the Phone Validation. 582 586 * Fixed the issue related to the Form Element category not create categories when the entry is created. 583 587 * Added form element output for all user form elements. 584 588 * Moved the option `Enable Login on the form` to the Form submission tab inside the Form Setup metabox. 585 589 * Fixed disable all the grid columns and rows on the permission tab when the free version is installed. 586 590 * Fixed the captcha label. 587 591 * Fixed the assign user to a post when the user is created during post submission. 588 592 * Fixed the empty option for the DropDowns form Elements. 589 593 * Improved the password hints. 590 594 * Fixed the password strength score. 591 595 * Added 2 hooks to avoid send user email activation to letting the use-case of manual activation form the user administration. 592 596 * Fixed the multiple form submission trigger. 593 597 * Fixed marketing wrong message. 594 598 * Fixed the reCaptcha v3. 595 599 * Fixed user form element to be included as hidden when they are setup to be hidden for logged in users. 596 600 * Added a hook filter to force the html output of the form element metas. 597 601 * Improved the styles for Dropdowns. 598 602 * Fixed media buttons notice. 599 603 * Fixed description position option for tag element. 600 604 * Added own implementation of thickbox. 601 605 * Fixed the user website field validation when not was correct. 602 606 * Added a filter to let 3rd party extension change the form submission message. 603 607 * Added a filter to let 3rd party extension change the submission link shortcode url. 604 608 * Improved the styles of the dropdown and select2 form elements. 605 609 * Added a new user Form Element to handle the user display option. Thanks to a contribution from Marco Massari Calderone marco@marcomc.com 606 610 * Improved the email notification to let 3rd party extension to extend the email templates. 607 611 * Fixed the form validation for not logged in user. 608 612 * Fixed the style issue in the form builder. 609 613 610 614 = 2.5.18 - 23 March 2020 = 611 615 * Fixed the permission tab style for the wizard. 612 616 * Removed deprecated option label button from the featured image field. 613 617 * Added composer instructions to the readme for the case somebody use the plugin from the repository. 614 618 * Updated the readme tags. 615 619 * Improved the function to get all pages excluding the pages from global settings. 616 620 * Improved the shortcodes processing from a string and they now are able to process shortcode attributes. 617 621 * Moved the field Country and State Form Element to the Extra section. 618 622 * Updated the user related fields to include the option to be hide for logged in users. 619 623 * Added styles for disabled inputs. 620 624 * Added a restriction to the user_login Form Element due to a WordPress restriction updating the username. 621 625 * Fixed the password strength option. 622 626 623 627 = 2.5.17 - 17 March 2020 = 624 628 * Fixed the duplicate labels for the Category, Tag and Taxonomy form element. 625 629 * Fixed the template system to show the parent page and not duplicate the content. 626 630 * Added a reste option for the marketing popups. 627 631 * Added a marketing popup to show an offer to free and trial clients. 628 632 * Added the localization files. 629 633 * Added compatibility with reCaptcha. 630 634 * Fixed the global dashboard to get the correct form-slug from the current entry. 631 635 * Fixed the Gutenberg navigation to use the correct labels. 632 636 * Improved the Gutenberg block to show submission filter by current user. 633 637 * Fixed the default page for manage the submission to keep selected when the user select a template. 634 638 * Fixed the Gutenberg block to publish a form. 635 639 636 640 = 2.5.16 - 6 March 2020 = 637 641 * Fixed the string localization for the Feature Image and Upload Form Element. 638 642 * Improved the compatibility with LOCO translate. 639 643 * Fixed the encoding for the email notifications to make it compatible with hebrew. 640 644 * Fixed the min/max validation JS messages. 641 645 * Fixed the After Submission option to show a page content in the correct way. 642 646 643 647 = 2.5.15 - 5 March 2020 = 644 648 * Fixed the Test email Notification empty body for the Change Status email notifications. 645 649 * Fixed the page submission with content. 646 650 * Fixed the server validation for the Content Form element. 647 651 * Fixed the server validation for the Taxonomy, Category and Tags Form element. 648 652 * Fixed the styles for the Dropdown, Taxonomy, Category and Tags Form element. 649 653 * Fixed add the mp3/audio file type to the Upload field. 650 654 * Added the Affiliation menu option to bring new ambassadors for BuddyForms. 651 655 * Fixed the JS error for invalid date when the field was not required and it not have value. 652 656 * Fixed the registration form error messages. 653 657 * Fixed the missing Date assets for the Schedule Status Form Element. 654 658 * Fixed the double label for the Post Excerpt and Textarea Form Elements. 655 659 * Improve compatibility with SendGrid email provider. 656 660 * Fixed the Link Form Element. 657 661 * Fixed the select2 to use the full version. 658 662 * Fixed the dropdown and autocomplete Form Element to show correctly in the popups. 659 663 * Fixed the template system, it was not detecting well when the site had another language. 660 664 * Fixed the error placement for the Content Form Element. 661 665 * Code improvement. 662 666 * Added a new parameter `$customfield` with the field options to the hook filter `buddyforms_form_element_add_field`. 663 667 * Fixed the default value of the email notification option mail to, by default is the admin option. 664 668 * Added a new parameter `$form_slug` to the hook action `buddyforms_update_post_meta`. 665 669 * Fixed the error placement for the requirement form elements. 666 670 * Removed the recently added styles for the dropdown and select2 form Elements. 667 671 * Fixed the language loader. 668 672 * Updated the Spanish language. 669 673 * Fixed styles for files types in the upload form element. 670 674 * Fixed a nonce issue. 671 675 * Fixed the style of the HTML form element. 672 676 * Fixed the issue related to the registration page selected in the Setting. 673 677 * Fixed the styles of the input override by BuddyPress. 674 678 675 679 = 2.5.14 - 11 Feb 2020 = 676 680 * Fixed the mail notification functionality. 677 681 * Fixed the login redirection to return to the same form after login over a form. 678 682 * Improved the permission table. 679 683 * Fixed notice error. 680 684 * Improved the post_excerpt to show the ellipsis ... when the content is visualized. 681 685 * Fixed the Date Form Element error for invalid format when a time was included in the element. 682 686 * Fixed the style of the circle in the list of post in the frontend. 683 687 * Fixed the permissions for draft, create and edit. 684 688 * Fixed the state of the permission when they get changed. 685 689 * Removed the option to enabled the draft, now is direct from the permission. 686 690 * Removed the draft option from the Form Action element. 687 691 * Improved the Form Action options to show the button by default and the options only disabled them. 688 692 * Added a popup modal to the Add-ons page to direct the user to the TK Bundle offer. 689 693 * Fixed the option After Form submission, it was not removing the draft button on specific permission use case. 690 694 * Fixed the draft permission. 691 695 * Fixed the Label on the Range element and to remove the validation tab from the Range Field. 692 696 * Improved the compatibility with gutenberg and the Form Element option to show as a metabox when the Post is edited. 693 697 694 698 695 699 696 700 = 2.5.13 - 28 Jan 2020 = 697 701 * Fixed the dependency error from a BuddyPress function `bp_get_signup_slug`. 698 702 * Moved the Form submit JS action to the same form onsubmit where the form is render to give more priority. 699 703 * Fixed the required validation for the Post Excerpt Form Element. 700 704 * 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. 701 705 * Fixed the permission change when the form switch from Contact to Post Form type for the free version. 702 706 * Fixed the Registration Settings functionality. 703 707 * Fixed for the email shortcode insert helper. 704 708 * Fixed the textarea validation. 705 709 * Fixed the issue related to the taxonomy field not letting create or search for a tag. 706 710 707 711 = 2.5.12 - 18 Jan 2020 = 708 712 * Fixed the message for the required gdpr form element. 709 713 * Added a $form_slug parameter to hook filter where the form elements are added to JS. 710 714 * Fixed an issue related with the shortcode to output the form and a hide element echo out of the context. 711 715 * Fixed the auto-generate content option for the textarea form element. 712 716 * Added a helper class to handled mail utf8 encoding. 713 717 * Added a test option to try the Form Notifications. 714 718 * Added a hook filter (`buddyforms_test_email`) to change the test email receiver. 715 719 * Added a hook to change the Redirect.. string after a form is submit with ajax. 716 720 * Fixed the auto generate option for the form elements post excerpt, post title, textarea and post content. 717 721 * Fixed the styles for the date form element * Improved the date format validation for the date form element. 718 722 * Added invalid format error message option to the Date Form Element. 719 723 720 724 = 2.5.11 - 18 Jan 2020 = 721 725 * Fixed the validation issue when the form not have any invalid fields. 722 726 * Added a hook to extend the form classes. 723 727 724 728 = 2.5.10 - 18 Jan 2020 = 725 729 * Added the shortcode helper for the submission notification. 726 730 * Shortcode helper now is compatible with tinymce. 727 731 * 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`. 728 732 * Added a filter to extend the email body `buddyforms_email_body`. 729 733 * Improved the UTF-8 encoding of the email body. 730 734 * Fixed the email option to let the user send only email to custom. 731 735 * Added error messages for invalid email, min/max value and length. Now is possible to translate this messages from the field options. 732 736 * Improved the styles for the dropdown and the select related form elements. 733 737 * Fixed the functionality to schedule post. Thanks to @Azila92 to report it. 734 738 * Fixed the Contact form is not applying the permission new logic when the form is loaded the first time. 735 739 * Added the option to upload images from URL inside the Upload form element. 736 740 * Fixed the form templates, now they are loaded from a new website. 737 741 * Improved the templates system and connected to a new services. 738 742 * Fixed the notice in the chrome console about field with the same id. 739 743 * Fixed the duplicate label for the textarea elements. 740 744 * Added a JS hook to let 3rd party Addons handle the form submission like BuddyForms ACF. 741 745 * Improved the bf login form to include the form slug related. 742 746 * Improved the redirect after login to execute by 3rd party extensions when the form is not a registration form. 743 747 * 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. 744 748 * Added a function to output a list of pages with his child included. 745 749 * Added styles for the login block. 746 750 * Fixed the border of the form. 747 751 * Improved the nonce function to generate nonce for logged out users. 748 752 * Updated form element styles to have a minimum height. 749 753 * Fixed the textarea to include the description. 750 754 * 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. 751 755 * Fixed the user related field to be saved form any form and load the related user meta if the user is logged in. 752 756 * Added a filter hook (`buddyforms_element_attribute`) to customize the form elements before render it. 753 757 * Added a Date format validation. 754 758 * Avoided collision of the date element style with other plugins with jquery-ui. 755 759 * Added the create date of the license to the inbound marketing process. 756 760 * Refactored the class BF_Error to BuddyForms_Error to avoid class collision. 757 761 * Fixed issue in the State element not including the correct field value. 758 762 * Added form_slug parameter to internal hook to include assets from extensions. 759 763 * Code improved to avoid the issue with BF_Error class. 760 764 * Start the inbound marketing development process. 761 765 * Added a hook to extend form output templates from 3rd party addons. 762 766 * Fixed bug related to the shortcode and the way to override the output template. 763 767 * 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. 764 768 * Fixed the issue of the form element loading the values when the form was in create mode. 765 769 766 770 = 2.5.9 - 14 Dec 2019 = 767 771 * Fixed the global style to include before the error messages. 768 772 * Fixed to show the user defined error message for the GDPR field. 769 773 * Fixed the permission for the Entries list action button now the hooks are compatible with the uses in other addons and the core plugin. 770 774 * 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. 771 775 * 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. 772 776 * 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"]` 773 777 * Improved compatibility with the last version of BuddyPress. 774 778 * Updated the way to show PRO fields to the Free plan users. 775 779 * Added the permission tab for the contact form. 776 780 * Enabled the Contact form to use the permission `all submission` for specific roles. So the user can check the entries from different users. 777 781 * Removed the create account option for the template basic post field. 778 782 * Fixed the textarea style for the form designer. 779 783 * Improved compatibility with WP 5.3. 780 784 * Updated the code to check the user permission. 781 785 * Updated the form field element option name by label. 782 786 * Fixed the Bio field to include the required signal and the description, also to make the correct validation. 783 787 * Improved compatibility with Elementor. 784 788 * Added a $wp_query var to get the form slug in 3rd party addons. 785 789 * Fixed the permission to let other user roles to edit others users post. 786 790 * Fixed the missing CSS file for the gpdr element. 787 791 * Added new hook buddyforms_the_loop_after_actions to the table. 788 792 * Added a new filter buddyforms_shortcode_the_loop_post_status. 789 793 * Fixed an issue in the Gutenberg blocks for the post listings. 790 794 * Update Freemius to 2.3.1. 791 795 * Removed the dependency of the templates from the demo site. 792 796 * Improved the GDPR form element. 793 797 * Improved the conversion to UTF8 and the subject UTF8 conversion. 794 798 * Improved the string to be ready for localizations. 795 799 * 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. 796 800 * Improved the email notification header to be more compatible with 3rd party systems like SendGrid. 797 801 * Added a hook to modify the emails header before pass to wp_mail. 798 802 * Improved the textarea element code and validation. 799 803 * Added a function inside the date element to check if the date is valid in certain format. 800 804 * Fixed the required validation for the File element. 801 805 * Correct the align text for the feature image and upload form element. 802 806 * Added the red dots to the feature and upload form element, to be shown on error. 803 807 * Added the error label for the password form element when is required and the validation is performed in JS. 804 808 * Fixed the serve side validations and error signals. 805 809 * Improved the way the error was handled by the plugin. 806 810 * Fixed Enfold theme compatibility issue. 807 811 * Fixed password place holder. 808 812 * Added a location.reload(); to the delete js to make sure it also works with custom templates including the delete button. 809 813 * Added a featured image as case to the function preparing the form element values. 810 814 * Fixed the form submission with no ajax. 811 815 * New feature, now the save draft will not trigger the form validation. 812 816 * Fixed the form permission to edit the post or create a new one. 813 817 * 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. 814 818 815 819 = 2.5.8 - 11 Oct 2019 = 816 820 * Added an implementation to avoid acf field from form validation. 817 821 * Added a new way to edit the list of Countries and States from the elements options. 818 822 * 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. 819 823 * Added the default name of does fields which not was adding it when they was added to the form. 820 824 * Fixed the store/load values for elements like the number field in a registration form. 821 825 * Fixed the store/load values for elements from a registration form. 822 826 * Fixed the required signal for the textarea element. 823 827 * Changing the file element from a link to a button. 824 828 * Changing the file element * place to be after the label. 825 829 * Changing the default date format to `dd/mm/yy`. 826 830 * 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. 827 831 * Fixed the form option to stop the Js validation. 828 832 * Fixed error position for the checkbox and the radio buttons. 829 833 * Fixed the red border for the bio element. 830 834 * Fixed the validation for the upload element. 831 835 * Added a * to the first empty element of the country and state element when they are required and the label is inline. 832 836 * 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. 833 837 * Fixed the error placement for the category, taxonomy and tag element, now the error will appear after the element. 834 838 * Fixed the error placement for the elements textarea, post_excerpt and buddyform_form_content. 835 839 * Fixed the error placement fo the radio buttons. 836 840 * Fixed the red border for password element. 837 841 * 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. 838 842 * Fixed the JS validation for the post_formats element. 839 843 * Fixed the placeholder and label for the post_formats element. 840 844 * Fixed the label for the feature image element and added a label inside the element to work as placeholder. 841 845 * Fixed the Category and Tag element missing placeholder. 842 846 * Fixed the captcha form element label and description. 843 847 * Added a new option inside the captcha form element to override the language. 844 848 * Added a hook to customize the Js parameters to include in the request for the captcha form element. `buddyforms_captcha_js_source_parameter`. 845 849 * Improved the honey-pot anti spam. 846 850 847 851 = 2.5.7 - 4 Oct 2019 = 848 852 * Fixed the issue with the output buffer. 849 853 850 854 = 2.5.6 - 3 Oct 2019 = 851 855 * Fixed the date element format. Thanks to `Maxime From Hophop Ride` 852 856 * Fixed the hidden element. 853 857 * Fixed the admin submission list to include the Date and the Hidden element correctly. 854 858 * Fixed the Post Excerpt element to be output in the correct place. 855 859 * Fixed the issue with the dropdown element where they let the user add text always. 856 860 * 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. 857 861 858 862 = 2.5.5 - 30 Sept 2019 = 859 863 * 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). 860 864 * Moved the BuddyForms js global above buddyforms_front_js_css_after_enqueue. 861 865 * Add a new filter buddyforms_loop_form_slug to overwrite the form slug on a post basis in the loop. 862 866 * Reformat the code of the-loop.php 863 867 * Added 2 hooks to let 3rd party addons not include the form action buttons. 864 868 * Added a new do action `buddyforms_the_loop_after_actions` to add actions buttons outside the normal action workflow. 865 869 * 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. 866 870 * Added hooks to change the Country and State list from the code in the professional version. 867 871 * Disabled the select2 to include elements if the option is not activated. 868 872 * Fixed the format for the date element. 869 873 * Fixed the styles to be included in the shortcodes. 870 874 * Fixed the category element to include the default value and the correct items. 871 875 * Fixed the modal to create the pages from the wizard, the setting page and the form builder. 872 876 * Added a new hook buddyforms_after_user_activation to hook after the user activation. 873 877 * Added the time field using the jquery ui datepicker. 874 878 * Changed the library for the date element to use jquery ui datepicker. 875 879 * Improved the way the js data is loaded into the form. 876 880 * Added the ability to process shortcodes from the after form submited message. 877 881 * Fixed the styles of the message. 878 882 * Added some hook into JS to get the field data from 3rd party plugins. 879 883 * Added a class `form-control` to all elements. 880 884 * Changed the required validation to apply only to elements `.form-control:required`. 881 885 * Added a JS action hook for Form submit. 882 886 * 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"]` 883 887 884 888 = 2.5.4 - 19 Aug 2019 = 885 889 * Fixed the validation of the backend message for the manage submission page. 886 890 * Fixed the issue generated by submit an empty tag or category. 887 891 * Fixed the issue to edit/delete post created before without BuddyForms. 888 892 889 893 = 2.5.3 - 19 Aug 2019 = 890 894 * Fixed the wrong message from the Category field. 891 895 * Updated the generated styles. 892 896 * Fixed the captcha to be showed in all forms. 893 897 * Fixed the styles to be applied correctly to all forms. 894 898 * Fixed the default field option for the taxonomy, category and tag field. 895 899 * Added the dismissible option to the admin notification to setup the page in the plugin settings for Frontend Submissions Management. 896 900 897 901 = 2.5.2 - 19 Aug 2019 = 898 902 * 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. 899 903 * Improved the load of the assets. 900 904 * Fixed the password validation to take in count if the field is required or not. Useful for Forms to edit the user profile. 901 905 * Fixed the GDPR output. 902 906 * Fixed the validation of the website and link field to only apply the JS validation when correspond. 903 907 * Added a new general settings for the frontend submissions management. 904 908 * Added the submissions management page to the form select as pre selected if n o attached page exist. 905 909 * Fixed the email validation for the field user_email and email. 906 910 * Added a hook system for frontend JS. 907 911 * Fixed the suffix for the price field. 908 912 * Added required signal for the fields in the builder, to easy identify what fields are required. 909 913 * Fixed the email validation message for the email field. 910 914 * Fixed the issue originated by the form slug coming from the templates. 911 915 * Added 2 function to load the assets using JS. 912 916 * Fixed the field dependent on select2 to load correctly in the builder. 913 917 * Improve the compatibility with the plugin email-subscribers. https://wordpress.org/support/topic/compatibility-with-email-subscribers 914 918 * Fixed the auto-load of the content of the default page to manage submitions. 915 919 * Fixed to get back the post_id used when a form is loaded and the auto-draft is created. 916 920 * Fixed the scroll after the form is submitted. 917 921 * Fixed the creation of the form from the Wizard. 918 922 * Fixed the captcha field. 919 923 * Fixed the email notification for the user not logged in. 920 924 * Fixed the user_email field was changing the email of the current user logged in in all forms. 921 925 * Fixed the output of the tags in the admin submission screen. 922 926 * Fixed the wizard registration tab. 923 927 * Fixed the auto-generate slug for the fields in the form designer. 924 928 * Move the Date field to the basic fields. 925 929 * Adding the field name for all fields when they are added to the builder. 926 930 927 931 = 2.5.1 - 11 July 2019 = 928 932 * Fixed the double Label for the content field. 929 933 * Updated the way of the form render using echo or simply returning the html. 930 934 * Improved the code to be compatible with JupiterX. 931 935 932 936 = 2.5.0 - 9 July 2019 = 933 937 * Improved required field messages to be more user friendly. 934 938 * Fixed the function to register users from multisite. 935 939 * Added more argument to extend the fields form 3rd parties. 936 940 * Moved the captcha field to the basic field group. 937 941 * Added a Price field. 938 942 * Removed the label option from the From Action field. 939 943 * Fixed the option to change the form slug, because it was not working if the form not have any submitted entry. 940 944 * Fixed JS incompatibility with external plugins. 941 945 * Code improvement and cleaning. 942 946 * Improved the detection of the bf shortcodes from the post content. 943 947 * 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. 944 948 * Added a filter to exclude columns in the submission list from the administration. 945 949 * Updated the user meta mapping to load the user website from user metas. 946 950 * Improved the default submission title for the registration forms. 947 951 * Fixed to show the User meta values when a list of entries shortcode is used. 948 952 * Fixed the user_login and user_email field to load the value from the user meta. 949 953 * Fixed the show captcha when the submission is in the action view. 950 954 * Code fix to the action column of the list of entries of a contact form. 951 955 * Added a custom class to the list of submissions. 952 956 * Fixed the password reset shortcode. 953 957 * Improved the code related to the error handling. 954 958 * Added the possibility to override the template/output used to change the password. 955 959 * Removing the session from the form submission and the error handling. 956 960 * Adding the Content element to handle the server validation for that component. 957 961 * 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 )` 958 962 * Fixed to avoid jQuery validate crash. 959 963 * Fixed the undefined index when the dropdown don't have any item created yet. 960 964 * Added the option to create a form from scratch or select the existing templates when a form is added trough the option add new. 961 965 * Fixed the wizard to not show the new builder background. 962 966 * Fixed the issue related to the creation of auto-draft in each visit of the form in the frontend. 963 967 * Added a filter to change the array separator. `apply_filters('buddyforms_implode_separator', ', ', $field_type, $field_slug)` 964 968 * Fixed the validation to process the array correctly, it affect the taxonomy fields. 965 969 * Added the taxonomy field value for the submission column in the administration. 966 970 * Fixed the permission issue when the post is created using buddyforms. 967 971 * Added a helper function to check the user capability. `bf_user_can` 968 972 * Added a nonce error message. 969 973 * Added a cursos pointer to the checkbox input. 970 974 * Fixed the permission to submit a form for anonymous users. 971 975 * Fixed a notice in the email notifications. 972 976 * Fixed the edit and delete buttons. 973 977 * Fixed the required validation for the content field. 974 978 * Fixed the auto-draft error for different post types. 975 979 * Added a Js hook to extend the function to get field data. 976 980 * Change "Check to enabled" to "Check to enable". 977 981 * Updating Freemius to version 2.3.0. 978 982 * Added the ability to join the beta tester groups. 979 983 * Fixed the way is added the scripts when the form is load from a shortcode. 980 984 * Fixed the user email element to be an email input to validate with html5. 981 985 982 986 = 2.4.6 - 3 Jun 2019 = 983 987 * Fix : Feature Image Field layout. 984 988 * Fix: Validation min/max value for number field type. 985 989 * Fixed the trash option inside the post status field. 986 990 * Added a filter (`buddyforms_before_update_post_meta`). to hook before the form meta is saved in order to customize it. 987 991 * Added an option inside the form to enabled or disabled the js validation in the frontend. 988 992 * Removing the jQuery validation from php code. 989 993 * Added the required validtion inside JS file. 990 994 * Removed the validation tab and required option for the comment field. 991 995 * Added an event to the required validation to be extended from 3rd extensions for custom fields using JS. 992 996 * Fix the required validation to pass the field with no data like password second field. 993 997 * Added a global event to enabled or disabled the form submit button, this give the possibility to improve the integration of 3rd party code. 994 998 * Fixed the repeated Date field. Fixes #498 995 999 * Added the current form into the JS global var to be used in the backend to load or apply the field related code. 996 1000 * Change the Date field to jQuery DateTimePicker and added more options to get more control of this field. 997 1001 * 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. 998 1002 * Improving the validation for the hidden fields like the taxonomies, dates. 999 1003 * Fixing the placement of the validation error. 1000 1004 * Fixing the error validation to work with taxonomy fields. 1001 1005 * Removing the limit to have more than one Date field in a form. 1002 1006 * Added the label to the Date field this field is inline. 1003 1007 * Added a function to get the field by ID. 1004 1008 * Added a code to get the form slug from the post meta to define to include the assets. 1005 1009 * Improved the label position for the error validation. 1006 1010 * Fixed the column row to styles. Added a new class for the first element row `bf-start-row`. 1007 1011 * Added an option inside the fields Excerpt, Content and Textarea to control the amount of rows. 1008 1012 * Added the ability to copy the shortcodes from the side bar using a single click inside the form builder. 1009 1013 * 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. 1010 1014 * Added one option inside the form to change the Form slug. 1011 1015 * Added server side validation for Date fields. 1012 1016 * Fixed the styles for the Date field when is show in the edit post screen inside a metabox. 1013 1017 * Improved the form slug option to be process only if it change. 1014 1018 * Improved the Element Class and Validation Class to accept the field options as a property to handle the field options inside the Field Class. 1015 1019 * Moved the Date field options inside the Date field Class. 1016 1020 * Added the server side validation for the PostFormat field. 1017 1021 * Added PostFormat as a new Field type in the code. 1018 1022 * Improve the server side validation to extend existing using filters. 1019 1023 * Fixing the shortcodes to only show the requested form by the provided form slug. 1020 1024 * Fixing a hook to override the submit button. 1021 1025 1022 1026 = 2.4.5 - 19 May 2019 = 1023 1027 * Adding a copy to clipboard into the form designer to copy the field slug. 1024 1028 * Fixing the extra weigh of the plugin zip. 1025 1029 1026 1030 = 2.4.4 - 19 May 2019 = 1027 1031 * Fixed the editor issue in order to only apply the fix related to the form designer in certain pages. 1028 1032 * Fixed email notification duplicate values for taxonomies in the table of all fields. 1029 1033 * 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. 1030 1034 1031 1035 = 2.4.3 - 17 May 2019 = 1032 1036 * Fixed fields with ajax validations allows to enter a lower number in Max Length than the entered in Min Length. 1033 1037 * Fixed the empty editor with gutenberg. 1034 1038 * Fixed the issue reported in https://wordpress.org/support/topic/buddy-forms-not-working-with-5-1-1/. 1035 1039 * Fix to avoid hide all metaboxes when BF is adding his own metabox. 1036 1040 1037 1041 = 2.4.2 - 16 May 2019 = 1038 1042 * Fixed the assets issue caused by the automation script used to generate and deployed the new version. 1039 1043 1040 1044 = 2.4.1 – 14 May 2019 1041 1045 * Added the option to define the number of rows for a textarea. 1042 1046 * Fixed the option `Make this field Hidden` because it was not appearing in the form designer. 1043 1047 * Fixed: To load the assets on the admin pages and show the upload field on the admin pages. 1044 1048 * Added the ability to sort the item inside the next field types: checkbox, dropdown, radiobutton and gpdr 1045 1049 * Fixed the Ajax Validation, broken for the text aria. 1046 1050 * 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. 1047 1051 * Fixed the css for "Required field" messages in the dropdowns, checkboxes, radiobuttons and GDPRs are misplaced. 1048 1052 * Fixed the email notification to process the field shortcode user_email. 1049 1053 * 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. 1050 1054 * Fixed the validation for min and max length. 1051 1055 * Fixed the validation for min and max number. 1052 1056 1053 1057 = 2.4.0 – 29 March 2019 1054 1058 * Change to use SEM Version 1055 1059 * Fixed default value for upload and feature image field 1056 1060 * Added a way to not echo the textarea, only return the html 1057 1061 * Fixed the double update of the existing post 1058 1062 * 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` 1059 1063 * Ready to be localized the string `Upload in progress` 1060 1064 * Added a hook to add field related translations inside the field 1061 1065 * Added a container to divide the form actions 1062 1066 * Fixed the error related to the save of fields placed after a taxonomy field 1063 1067 * Added a validation to avoid error when no exist any form 1064 1068 * Fixed the visibility of the new ajax option inside the taxonomy field 1065 1069 * Fixed the button to reset the form styles 1066 1070 * Added compatibility for `Better Notifications for WordPress` 1067 1071 * Changed the ajax search name_like to use search option 1068 1072 * Updated select2 to the latest version 1069 1073 * Added cache to the select2 search terms field 1070 1074 * Add draft functionality 1071 1075 * Add a mechanism to read the form options from the js side 1072 1076 * Improved the code stability 1073 1077 * Added a helper function to grab the form slug from different sources 1074 1078 * Added a btn-alt for the draft button to make a difference with the primary button 1075 1079 * Added custom class for draft button 1076 1080 * 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 1077 1081 * Updated the draft text 1078 1082 * DOMDocument error fixed. Now the code detect if dom library is loaded if not it use regex 1079 1083 * Moved the custom class option under the switch to make sure the option is available for all fields 1080 1084 * Added the draft options 1081 1085 * Move the form action field into the basic group 1082 1086 * Fixed the issue related to load assets in the admin where they don't needed 1083 1087 * Improved the detection of the block to include the assets trough gutenberg 1084 1088 * Fixed the navigation in the list of entries for contact form 1085 1089 * Fixed the form builder grid option not working for images 1086 1090 * Update the session to use transient to avoid trash in the database 1087 1091 * Remove the long time expiration for the session, now is 27~30mn 1088 1092 * Fixed the mail notification when the post status change. 1089 1093 * Improved the shortcode `form_elements_table` used into the mail notifications 1090 1094 * Added the git templates for issues and features request into the git repository 1091 1095 * Added a filter to override the lost password link 1092 1096 * Fix the notification accordion 1093 1097 * Fix the ad notification button 1094 1098 * Fixed the after submission option when is displaying a page content 1095 1099 * Fixed the regex to detect bf from the post content 1096 1100 * 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. 1097 1101 * Fixed the notification accordion when the form is created directly 1098 1102 1099 1103 = 2.3.3.2 – 6 March 2019 1100 1104 * Added a check to avoid start gutenberg block in older wordpress versions 1101 1105 * Added an option to use ajax for the taxonomy field 1102 1106 * Code improved 1103 1107 1104 1108 = 2.3.3.1 – 2 March 2019 1105 1109 * IMPORTANT: the function buddyforms_locate_template used in our templates has changed now need the $form_slug parameter. Please update your templates files. 1106 1110 * Fixed the checkbox styles in the form permissions 1107 1111 * Freemus SDK Update 1108 1112 1109 1113 = 2.3.3 – 28 Feb 2019 1110 1114 * Update the way to include parameters into js 1111 1115 * Added buddyformsGlobal var 1112 1116 * Code Refactored 1113 1117 * Improved the upload field to work in the list of contact entries 1114 1118 * Fixed the double label for the upload field 1115 1119 * Fixed the way is added the rules to jQuery validation, now the input need to be active. 1116 1120 * Fixed: Overlapping title on a new BuddyForm 1117 1121 * fixed the admin url used in ajax call 1118 1122 * Update Freemius 1119 1123 * Update composer type 1120 1124 1121 1125 = 2.3.2 – 26 Feb 2019 1122 1126 * Fixed the assets to be included with the shortcodes. 1123 1127 1124 1128 = 2.3.1 – 22 Feb 2019 1125 1129 * Added Gutenberg Support 1126 1130 * Add new Blocks for Embed Forms, Submissions, Registration and Login Forms. 1127 1131 * Added the ability to show other user submission if the permission is enabled. 1128 1132 * Fixed the permission auto check. Now the permissions follow the next rules: 1129 1133 --> For pro version -if the form is new only select create-edit-delete by default for admin and editor 1130 1134 --> Free version -all permission checked for all roles except for all submissions Fix/all submission permission 1131 1135 * Fixed Upload field - image url is getting reset on save 1132 1136 * Added the user_login to the submission list to get the value form the user meta. 1133 1137 * Improved the user_login and email field to show in the single submission view. 1134 1138 * Fixed the label duplication issue in the single submission view 1135 1139 * Change the button text from Close to Back 1136 1140 * Fixed the user fields first and last name to store correctly into the user meta. 1137 1141 * Fixed the issue related to create multiples entries when the registration form was used to update an user. 1138 1142 * Added the different Column name for table template 1139 1143 * Changed the post entry title to use the user nicename when the pest entry belong to a registration form. 1140 1144 * Added a new tag to define the style of the list in the shortcodes. 1141 1145 * Updated the default value for the post style 1142 1146 * Fixed the warning inside the Gutenberg shortcode 1143 1147 * 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` 1144 1148 * Changed the name of the composer library to avoid conflict with composer 2 1145 1149 * Added the styles to organize the permission chk. 1146 1150 * Added the validation for the permissions inside the submission view. 1147 1151 * Added the value as class inside the container of the checkbox to easily style each one. 1148 1152 * 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. 1149 1153 * Avoid to ask for permission to show the form in the registration forms. 1150 1154 * Fixed the fields email and user_login to show if the user is not logged in. 1151 1155 * Improved the code. 1152 1156 * Localized ready for all strings 1153 1157 * Fixed the empty localization strings 1154 1158 * Updating the translation file. Adding the Spanish translation. 1155 1159 * updated composer.lock 1156 1160 * Fixed the undefined index name in the submission page 1157 1161 * Add a new function to detect if is gutenberg 1158 1162 * Added a filter to disable the validation of the email send to the user on activation or update 1159 1163 * Improved the assets included in the form. 1160 1164 * 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. 1161 1165 * 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. 1162 1166 * Code cleaning 1163 1167 1164 1168 1165 1169 = 2.3 – 21 Jan 2019 1166 1170 * Removed an left over alert from the dropdown rewrite 1167 1171 * Fixed user_website valdiation 1168 1172 * Moving the asterisk to flag required fields to by at the end of the label. 1169 1173 * Added a Hook to change the signal of the default values, by default asterisk. Filter details `buddyforms_render_required_signal` one parameter. 1170 1174 * Removed composer update from the post-merge git hook 1171 1175 * 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. 1172 1176 * Improved the validation 1173 1177 * Added the first step to create gutenberg block 1174 1178 * Fixed E-Mail Adress is empty, if no form field with E-Mail Adress is submitted by logged in users 1175 1179 * Added a space between the Date #167 1176 1180 * Changed the labels in the form builder 1177 1181 * Added a space between the Date #167 1178 1182 * Created a new helper function to get $_GET parameter 1179 1183 * Fixed an issue with the form element custom class. The class option was not working on every form element. Should be fixed now. 1180 1184 * 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 1181 1185 * Added a query var to get the form slug from the Form preview 1182 1186 * Fixed the field id for the form_arg parameter 1183 1187 * Updated the freemius sdk to version 2.2.3 1184 1188 * Cleaned and refactored the code. 1185 1189 1186 1190 1187 1191 = 2.2.9.2 – 29 November 2018 1188 1192 * Added validation to the file element. 1189 1193 * Fixing the validation of the emails notifications. 1190 1194 * Fixed the function to scroll to error in the form designer. 1191 1195 * Fixing the form designer validation 1192 1196 1193 1197 = 2.2.9.1 – 28 November 2018 1194 1198 Spelling correctioon 1195 1199 Added 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. 1196 1200 Reformat code 1197 1201 1198 1202 = 2.2.9 – 23 November 2018 1199 1203 * Improving the email functionality to receive the user cc and bcc copies of the emails. Refactoring the code. 1200 1204 * Added a default template for the shortcode 1201 1205 * Added validation for the cc and bcc fields with multiples emails or one. 1202 1206 * Fixed the option to show the cc or bcc to interact only with the field in the current notification. 1203 1207 * fixed to keep the round red color and the scroll to the elements. 1204 1208 1205 1209 = 2.2.8 – 9 November 2018 1206 1210 * Fixed an issue where the feature image was not attach to the post 1207 1211 * Removed the maxFiles limit from the upload form element 1208 1212 * Improved the security and added prepare to queries to avoid sql injection. 1209 1213 * Improved the field processing, for extra process. 1210 1214 * 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. 1211 1215 * Added the Field Control to start migrating to SOLID principles. 1212 1216 * Added the action to the action `buddyforms_process_field_submission`. 1213 1217 * Fixed the condition to ask if the imgae.php was already included. 1214 1218 * Fixed the email short-code generation. 1215 1219 * Improving the shortcode replacement 1216 1220 * Adding CI with codeship, phpcs, php linter and php fixer. 1217 1221 * Updated php cs and fixer configuration 1218 1222 * Fixed the validation og the website form element without http protocol 1219 1223 * Improving the code. 1220 1224 1221 1225 1222 1226 = 2.2.7 – 19 October 2018 1223 1227 * Added missing translations 1224 1228 * Fixed some admin css issues and make sure its also working for WordPress.com 1225 1229 * Removed the readme from the zip process. 1226 1230 * Added a functionality to add a random string as the form name in case the form is created and not provide a title. 1227 1231 * Fixed the notices and warnings related to the create form process 1228 1232 * Added the BuddyForms version to the file enqueue 1229 1233 * Fixed the shortcode to show all users entries work. 1230 1234 * Fixed the permission tab to avoid override saved values with default values. 1231 1235 * Disabled the ACF js navigate away pop up 1232 1236 * Updated the cache group. 1233 1237 * Added a helper function to get the form by slug and include a cache inside 1234 1238 * Improving function documentation 1235 1239 1236 1240 = 2.2.6 – 1 October 2018 1237 1241 * Fixed the option to delete an image when post is deleted inside the upload field. 1238 1242 * Added new option to upload field to define how many file will be uploaded. 1239 1243 * Added new option in the upload field to define the validation messages. 1240 1244 * The upload field now upload one file by one. 1241 1245 * Fixed the the shortcode bf_user_posts_list. 1242 1246 * Fixed the validations process, in the case where the jQuery validator not exist. 1243 1247 * Added new options to the featured-image field, now it work like the upload field. 1244 1248 * Fixed the invalid image when file is not present. 1245 1249 * New option for image upload max number of files to ensure the amount of files to upload. 1246 1250 1247 1251 = 2.2.5 – 10 September 2018 1248 1252 * Added support for WordPress.com. There have been UI issue in the Admin backend. 1249 1253 * Added validation to avoid form submission when one of the files in the upload has errors 1250 1254 * Added a validation to avoid enable the submit button when some process is in motion. 1251 1255 1252 1256 * Rewrite the file upload form element 1253 1257 ** New version of the upload field. 1254 1258 ** Added a new validation for required fields. 1255 1259 ** Added a validation for when the field have more file than allowed. 1256 1260 ** Included de description at the bottom of the field, if the description exist. 1257 1261 ** The validations run over jquery validations. 1258 1262 ** 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'). 1259 1263 ** Fixed the link between the media files and the created post. 1260 1264 ** 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. 1261 1265 ** Improved the code of the upload field. 1262 1266 ** Changed the color of the error and success svg using a filter to be red and green. 1263 1267 1264 1268 * Added group validation 1265 1269 * Added a global validation to avoid send the form until the field not upload the files 1266 1270 * Added a validation with jquery to check if the upload is required and if they have only the allowed files 1267 1271 * Removed prevent default of the submit button 1268 1272 * Added a red color to the error cross in the field upload 1269 1273 * Fixed compatibility to php 7.1 for the function `buddyforms_strip_html_title_for_entries_in_post_screen` 1270 1274 * Added a new permission to get all user submission in the frontend. 1271 1275 * 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 1272 1276 * Added a filter to customize the jquery validations. `buddyforms_jquery_validator_init`, thanks to @pattyok. 1273 1277 * Added the function to the form to open the field in case of empty required setting. 1274 1278 * Fixed the list post option setting. 1275 1279 * Show the empty submission list message option always in the form settings. 1276 1280 * Removed the permalink notice and Removing permalink verification funciton 1277 1281 * Fixed the shortcode generator modal. Now it look full width 1278 1282 * Changed the version of the upload script make it load by the clients. 1279 1283 * Fixed the upload field to handle more than one field in the same form. 1280 1284 * Added the option to handle the empty submission list. 1281 1285 * Added a shortcode to add a link inside the empty submission list message. 1282 1286 * Added an improve to wait the form submission for multiples file upload from diferents fields 1283 1287 * Moved upload function to the function file to include in the front. 1284 1288 * Fixed submission view to include the post title and the post content. The post content with the elipsis form wp 1285 1289 * Cleaned the upload field. 1286 1290 * Added a code to check if the uploader have a file to avoid cancel the form submission. 1287 1291 * Added a script to check for repeated slug and add a random suffix. 1288 1292 * Added a new permission to get all user submission in the frontend. 1289 1293 * Cleaned the code. 1290 1294 1291 1295 = 2.2.5 – 31 August 2018 1292 1296 * Fixed the shortcode generator modal. Now it look full width. 1293 1297 * Removed the permalink notice and function. 1294 1298 * Showing the empty submission list message option always in the form settings. 1295 1299 * Fixed the list post option setting. 1296 1300 * Added a filter to customize the jquery validations. `buddyforms_jquery_validator_init`, thanks to @pattyok. 1297 1301 * Added the function to the form to open the field in case of empty required setting. 1298 1302 * Added a script to check for repeated slug and add a random suffix. 1299 1303 * Added a new permission to get all user submission in the frontend. 1300 1304 1301 1305 = 2.2.4 – 7 August 2018 1302 1306 * Fix the screen option for submission page in BuddyForms. 1303 1307 * Fix: Featured image field is not working in the front-end for edit entries. 1304 1308 * Fix :Upload field is not working in the front-end for edit entries. 1305 1309 * Adding a function to check for the correct permalink. 1306 1310 * Adding a notice to show to the user in case the permalink are not the correct. 1307 1311 * Adding permalink admin notification. 1308 1312 * Fixing the js code related to the new upload field, because it was changing the name of the submit buttons in the forms. 1309 1313 * Removing unused php session. 1310 1314 * Adding the option to hide the User related fields. 1311 1315 * Adding status of the post to the submission list 1312 1316 * Adding better return for the post status. Now it show the full string. 1313 1317 * Adding helper functions to get all files of one form. 1314 1318 * Adding a helper function to check if exist a field in the form. 1315 1319 * Implementing a condition to hide the hidden status input is exist the field status in the form. 1316 1320 * Adding the code to handle the status if they coming form the form. 1317 1321 * Fix Status field. 1318 1322 * Fixing the user role moderation to avoid the user role change for admin and when the option is to keep the current user role. 1319 1323 * Fixing the user role moderation. 1320 1324 * Fixing the submit of the form. 1321 1325 * Added a code to check if the uploader have a file to avoid cancel the form submission. 1322 1326 * Moving upload function to the function file to include in the front. 1323 1327 * Fixing submission view to include the post title and the post content. The post content with the elipsis form wp 1324 1328 * Cleaning the upload field. 1325 1329 * Added a code to wait the form submission for multiples file upload from different fields. 1326 1330 * Added the option to handle the empty submission list. 1327 1331 * Added a shortcode to add a link inside the empty submission list message. 1328 1332 1329 1333 = 2.2.3 – 10. July 2018 1330 1334 * Fixed the reCaptcha library, adding a native checking from google. 1331 1335 * Added a link to generate new keys. 1332 1336 * Fixed the permission tab checkboxes css 1333 1337 * Implemented a role based authorization security mechanism using a custom attribute filter. 1334 1338 * Fixed a issue with the drop zone. File upload via form not attached to post 1335 1339 * Added a screen option for the submission screen. 1336 1340 * Fixed the login for active or not active users. 1337 1341 * Added the js script to handle the moderation settings. 1338 1342 * Added the new moderation and on update user settings. 1339 1343 * Implementing the moderation function for user update. 1340 1344 * Updating the options and the text related to the moderation to make more friendly. 1341 1345 * Fixed the upload field initializer. 1342 1346 * Added some functions to display the submit message of the forms and the default message. 1343 1347 * Added the new option to the form setting to add new message on form update. 1344 1348 * Fixed the user update on form update. 1345 1349 * Implementing the new update message for form submit 1346 1350 * Freemius SDK Update 1347 1351 1348 1352 = 2.2.2 – 29. Jun 2018 1349 1353 * Fixed the resend activation link for user pending of activations 1350 1354 * Improved the submission view UI 1351 1355 * Added a new filter buddyform_after_activate_user. To hook just after the user got activated. 1352 1356 * Removed duplicated argument `$bf_value` from the filter `bf_submission_column_default`. 1353 1357 * Fixed a notice related to an empty attached_page option 1354 1358 * Updating the js functions to not use live, thanks to @virtualLast 1355 1359 * Removing deprecated functions and fixed several smaller issues 1356 1360 * Prefixed custom_user_profile_fields function to avoid conflicts with other plugins using the same name. 1357 1361 1358 1362 = 2.2.1 – 22. Jun 2018 1359 1363 * Added a filter at top of the user list to filter the list of user for the buddyforms pending for activation users. 1360 1364 * Added the activation and resend activation email link into the admin user list. 1361 1365 * Added a buddyform function to generate nonces, to use in the activation process of users. 1362 1366 * Saving the activation link into user meta. 1363 1367 * Added a function to get the current user id from the get parameters when the activation process is running. 1364 1368 * Applying code style. 1365 1369 * Mke the review notification grab the correct version number. 1366 1370 1367 1371 = 2.2 – 20. Jun 2018 1368 1372 * This is a huge update. Please test deeply. 1369 1373 1370 1374 * GDPR Release 1371 1375 * 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. 1372 1376 * --> Make the architecture of BuddyForms GDPR Complaint 1373 1377 * --> Add a new Form Element "GDPR Agreement" 1374 1378 * --> Added GDPR Agreement templates for registration, post and contact forms 1375 1379 * --> Add new general settings page to create default Agreement templates and form footer terms text and terms page link option. 1376 1380 * --> 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 1377 1381 * --> Added support for the Personal data exporter 1378 1382 * --> Fixed how the plugin get the user data with a new way to disable it. 1379 1383 * --> Added argument validation to take in count the wp core key and the field types matching. 1380 1384 * --> Refactoring how the user meta is saved. Now all is in the same place. 1381 1385 1382 1386 * Featured Image 1383 1387 * Created a new uploader. Its now possible to upload featured images for unregistered logged off users. 1384 1388 1385 1389 * Added a link "create new entry" if the submission list is empty. 1386 1390 * Fixed the form slug to get the form messages. Cleaning and refactoring the code. 1387 1391 * Added a code to show the related tabs in base of the form type select in the templates 1388 1392 * Added a filter to disable save usermeta data 'buddyforms_not_save_usermeta'. 1389 1393 * Make sure tinyMCE exist otherwise it is braking the ajax. 1390 1394 * Fixed the submit with ajax option for the form. 1391 1395 * Added function to map the existing fields to override the meta use in wp core instead of duplicate it. 1392 1396 * Calling the new functions in the user-meta.php file, this is a new centralice way to get and write the user data. 1393 1397 * Changing the loader priority of the user-meta.php file to use the new function in the frontend 1394 1398 * Avoid send the notification id if the status is the same 1395 1399 * 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 1396 1400 * Added the new GDPR Admin Notice 1397 1401 * Added the new freemius sdk 1398 1402 * Fixed a issue with the user meta. Some data have not get validated correctly. 1399 1403 * save a issue with tinymce not updating the textbox during submit 1400 1404 * Added a check to registration forms if the default values exist on update of a user to avoid notice 1401 1405 * Added new filter and add a check to deactivate the activation mail with a filter 1402 1406 * Fixed the remote preview url 1403 1407 1404 1408 = 2.1.7 – 20. May 2018 1405 1409 * 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 1406 1410 * --> Added buddyform prefix for nav-pills, nav-tabs and tabs-left 1407 1411 * --> Fixed the field related scripts like the tabs and the accordion when new field is added to the form builder. 1408 1412 * --> Added script to load the field inside the wizard. 1409 1413 * --> Fixed css to organize the arrow inside the wizard 1410 1414 * Fixed php language minor issues 1411 1415 * Change the place of the filter for submission default value 1412 1416 * Fixed a sessions issue. This fix is related a conflict during recovery of the session when the page is load the first time. 1413 1417 * Improved the submissions table to show the column data and custom field types 1414 1418 * -->Added the category and the tag to the list of submission 1415 1419 * changing the input ids for the wp login form to avoid name coalition with the user_id field 1416 1420 * add form slug as attribute to the buddyforms_formbuilder_fields_options filter 1417 1421 * Fixed some issue in the registration form redirect. redirect to url #was broken 1418 1422 1419 1423 = 2.1.6.8 – 29. April 2018 1420 1424 * Fixed an issue with the upload form element “No image displayed in the admin edit screen” 1421 1425 * Change submit button text to upload in process during upload 1422 1426 * Fixed the upload label. slug was used. 1423 1427 * Added a filter for allow add-ons display the value in the column of the submission list 1424 1428 * show the thumbnail of the uploaded files in the view and edit submision pages 1425 1429 * Change the loader of garlic library to first check if the html tag exist in the dom. 1426 1430 * Added jQuery identifier instead of $ to avoid error 1427 1431 * Make trials working. Tehre was an issue with the trial activation. 1428 1432 1429 1433 = 2.1.6.7 - 16. April 2018 1430 1434 * 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. 1431 1435 * Fixed an issue in the shortcode. The author id attribute did not have any effect. 1432 1436 * Added compatibility for public post lists so they can be used in other extension like BuddyForms Ultimate Member 1433 1437 1434 1438 = 2.1.6.6 - 3. March 2018 1435 1439 * Added a default error message to the error handling just in case we have a error but no message 1436 1440 * Check if the user id is_wp_error and get the error message 1437 1441 * Added description and Label to the upload field drop zone 1438 1442 1439 1443 = 2.1.6.5 - 29. March 2018 1440 1444 * Changing the submission query to use wpdp 1441 1445 * Improving the edit form shortcode 1442 1446 * Fixed an issue with the upload form element. The label and description was not displayed 1443 1447 * Fixed smaller issues reported by users 1444 1448 * CSS some css in the login form 1445 1449 1446 1450 = 2.1.6.4 - 26. March 2018 1447 1451 * Fixed the check for the permission for admin and autor (read-edit-write) 1448 1452 * Fixed the loader of the plugin to avoid incompatibilities with WP 1449 1453 * Added new class bf-hidden to enable hide form elements by class 1450 1454 * Added the honey pot to the form. 1451 1455 * Fixed and issue in the login form. The Lost Password Link was overwriting the registration link 1452 1456 * Remove the old plugin header from the password-strengh-settings 1453 1457 * Make sure Form Layout and Import Forms are always the last tabs 1454 1458 * Improving the global var of BuddyForms 1455 1459 * Fixed the item in the list of form inside the submission view to include the last updated form names 1456 1460 * Fixed the items name in the list of form inside the submission view 1457 1461 * Fixed the the visibility of the selected form post type 1458 1462 * Moving the tk icon load script to a separated function to load in backend and frontend 1459 1463 * Added css to include the icon in the shortcode 1460 1464 * Create a new admin bar menu item to edit the form if the form is displayed. 1461 1465 * Update Freemius version to 2.0.1 1462 1466 1463 1467 = 2.1.6.3 - 14. March 2018 1464 1468 * Make sure the password update script in the wp insert user only run if new password is set during update 1465 1469 * Make sure the password script works for new registrations with the change password class introduced in the latest update 1466 1470 1467 1471 = 2.1.6.2 - 12. March 2018 1468 1472 * Updated the re captcha form element to use the version 2. Version 1 is only supported til the 30 of March. 1469 1473 * Added new options for recaptcha v2 to the form element. 1470 1474 * 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. 1471 1475 * Fixed an issue with the post author. If the user was created during submission it could happen that no author was set. 1472 1476 * Rebuild the pfbc password field and make use of the WordPress validation also in registration forms. 1473 1477 * Fixed an with the password option "hide for logged in users". If the option was set the password field was hidden all the time. 1474 1478 1475 1479 = 2.1.6.1 - 6. March 2018 1476 1480 * Fixed an issue in the Registration and Activation Process. 1477 1481 * Refactoring the code. 1478 1482 * Added the login/registration form to the forms when the option correspond 1479 1483 1480 1484 = 2.1.6 - 5. March 2018 = 1481 1485 * New upload field to integrate with dropzone 1482 1486 * - Added option max file size 1483 1487 * - Added option acceptedFiles 1484 1488 * - Added the option multuple files 1485 1489 * - Added the delete file option 1486 1490 * - Added the id of the attachment in the submissions table for the upload field 1487 1491 * - Show the id of the submited files as links in the entry list 1488 1492 * - Props to Victor and Guillermo for there contributions and making the DropZone a reality ;) 1489 1493 * Fixed the submission view in the backend. 1490 1494 * Added a function to strip the html from the post list in the backend 1491 1495 * Added the interaction when the ajax is in progress to disabled the submit button 1492 1496 * Several smaller bug fixes 1493 1497 1494 1498 = 2.1.5.2 - 20. February 2018 = 1495 1499 * Fixed an issue in the loop. The thumbnail was not clickable in all sirtuations 1496 1500 * 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. 1497 1501 * Add localisation for password rest to make the password hint and messages translatable. 1498 1502 1499 1503 = 2.1.5.1 - 9. February 2018 = 1500 1504 * fixed a merge conflict from Merge pull request #174 from BuddyForms/fix/g-171 1501 1505 1502 1506 = 2.1.5 - 8. February 2018 = 1503 1507 * Add new shortcode attribute query_option to list posts from all users of the post type for public usage 1504 1508 * 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 1505 1509 * Fixed some issues with the redirect after successful login 1506 1510 * 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 1507 1511 * Added a new check into the wp insert user function to save the redirect url 1508 1512 * Created a new function buddyforms_login_redirect to redirect after login from shortcode attribute "redirct_url" 1509 1513 * Created a new filter buddyforms_login_form_redirect_url to make it possible to overwrite the login redirect in BuddyForms extensions. 1510 1514 * Added the reset option to the dropdown field using an attribute as flag. 1511 1515 * Added the reset option to the checkbox, dropdown and select2 1512 1516 * Implementing the save of post in the backend. This implementation is only for 2 field types. 1513 1517 * Fixed the extract functions to avoid notices and warnings. 1514 1518 * Change the submission page to use WP_Query and OOP. 1515 1519 * Added a hook to update the post meta on edit post in the backend 1516 1520 * Added a validation to check for specific number when the user set max and min for the same number. 1517 1521 * More fixes and mobile view improvements, bigger image, fix in date formatting, better buttons, better typo 1518 1522 * Fully reworked list view CSS 1519 1523 * New CSS for table view and status items for table view 1520 1524 * CSS options for each module, done and tested 1521 1525 * Created extras tab with an option to disable all CSS for this form 1522 1526 * Created also an option to disable CSS for the tab "other form elements" 1523 1527 * Work on the login form and password reset 1524 1528 * Added the display form option back to registration forms so they can be used for profile forms. 1525 1529 * Change the scroll to top so that we can be sure to see the message 1526 1530 * Add a new filter "buddyforms_reset_password_redirect" to change the password redirect url 1527 1531 * Fixed an issue with validation min length. There was a spelling issue in the option name. 1528 1532 * Add support for the option page to the password strength js 1529 1533 * Add an redirect option to change password 1530 1534 * Welcome back the languages folder for the .pot file. People still ask for the file so we move it back 1531 1535 * Fixed an issue with the registration form content overwrite. The content was returned empty in all cases... ;( 1532 1536 * 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. 1533 1537 * Make hidden and html basic fields so they can be used in all form types 1534 1538 * Added md5 string to auto generated usernames 1535 1539 * Fixed a issue with the form and posts list did not get displayed in the endpoints 1536 1540 * Created two new form elements Country and State 1537 1541 * Enqueue mce-view to view gallery in front-end post edit props to @Hannah93 for there pull request 1538 1542 * Remove do_shortcode so galleries work on front-end post edit props to @Hannah93 1539 1543 * Fixed backend tax empty bug 1540 1544 * Added some extra check to BuddyForms rewrite roles to avoid load registration forms on BuddyPress Groups pages 1541 1545 * Added a new do action buddyforms_admin_js_css_enqueue 1542 1546 * Fixed some css issues 1543 1547 * Correct some spelling and bad english 1544 1548 * Fixed an issue with validation min length. There was a spelling issue in the option name. 1545 1549 * Add support for the option page to the password strength js 1546 1550 * add a new filter "buddyforms_reset_password_redirect" to change the password redirect url 1547 1551 * Added the display form option back to registration forms so they can be used for profile forms. 1548 1552 * Change the scroll to top so that we can be sure to see the message 1549 1553 1550 1554 = 2.1.4 - 23 August 2017 = 1551 1555 * Fixed an issue with the login form shortcode 1552 1556 * 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 1553 1557 * Update the plugin description and change the link form buddyforms.com to themekraft.com/buddyforms 1554 1558 * Changed the editor.css path. it was admin_url but should be includes_url. Do not as me why this worked before... 1555 1559 * 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. 1556 1560 --> Make sure the term gets deleted if the field is unselected. 1557 1561 --> Make sure the new taxonomy is saved as default 'unauthorised' or nothing instead of a "-1" 1558 1562 * Remove old pfbc css and js dependencies 1559 1563 * Reorder and clean up the code 1560 1564 * Clean up the-loop.php template. Move the pagination out of the table 1561 1565 * 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 1562 1566 * Add form_slug as parameter to the buddyforms_the_loop_li_last and buddyforms_after_loop_item in the the-loop.php template 1563 1567 * Add form_slug as parameter to the buddyforms_the_table_tr_last and buddyforms_after_loop_item in the the-table.php template 1564 1568 * Add new hook to the the-loop.php templates buddyforms_the_loop_item_title_after to hook content after the title 1565 1569 * Add new hook to the the-table.php templates buddyforms_the_thead_tr_inner_last to add new table head labels 1566 1570 1567 1571 = 2.1.3.1 - 23 August 2017 = 1568 1572 * 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. 1569 1573 * Added a Redirecting message to the notice if redirect to page is set with Ajax enabled 1570 1574 1571 1575 = 2.1.3 - 21 August 2017 = 1572 1576 * Fixed form validation jQuery error. Props to @Hannah93 1573 1577 * Fixed undefined function is_error. Props to @Hannah93 1574 1578 * Fixed small error fixes. Props to @Hannah93 1575 1579 @Hannah93 huge thanks for your contributions! 1576 1580 * Fixed a issue in the contact form FROM sender. If set to first name and last name only first name was used. 1577 1581 * Fixed an issue in the mail notifications. It was not possible to add shortcodes in the From custom sender field. 1578 1582 * Work on the taxonomy form element, make categories and tags fixed without taxonomy select to simplifier the configuration. 1579 1583 * Fixed smaler issues in the taxonomy form element and optimise the taxonomy category and tags form elements 1580 1584 * Added a new option to limit category, tags and taxonomy selection if multiple is enabled 1581 1585 * Add a notice to the taxonomy form element and hide the options if not on the professional plan 1582 1586 * Fixed an issue with the comment status The form element always stay as comments open. Even if comments are closed. 1583 1587 * 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 1584 1588 * Fixed admin notice in wp-insert-user.php 1585 1589 * Make sure mail_submission_trigger_sent is only triggered if a post exist 1586 1590 * Make sure the wp editor css get loaded 1587 1591 * Rewrite the logic of generate titlle and content 1588 1592 * New feature! Log Registrations as Submissions. From now on every Registration and profile changed get logged as submission. 1589 1593 * Add new metabox to the submissions single view in the backend to display the user id if form type is registration form. 1590 1594 * Hide Password form any view. 1591 1595 * Make sure passwords fields does not get saved as post meta with the new logic of registration log as submissions 1592 1596 * Save the user id in the post if registration form to know the user 1593 1597 * Add functions to load the admin single view from user meta 1594 1598 * Reformat Code to stay conform with WordPress Coding Standards 1595 1599 * Make sure Registration Pages are not displayed in the form builder/ form edit / page select 1596 1600 * Fixed the layout import in the Form Designer. Colors and custom css was broken and did not get imported. 1597 1601 * check if generate content and title is activated and generate teh content if the field is not empty. 1598 1602 1599 1603 1600 1604 = 2.1.2.3 - 1 August 2017 = 1601 1605 Freemius update to allow free and pro add ons 1602 1606 1603 1607 = 2.1.2.2 - 27 July 2017 = 1604 1608 * Fixed an issue in wp-insert-user.php. Function return value in write context. Remove the sanitise checks from if empty() 1605 1609 1606 1610 = 2.1.2.1 - July 14.2017 = 1607 1611 * Fixed a issue with the AddOns Page There was a conflict "Cannot redeclare _wp_menu_output" 1608 1612 * Remove the old add-ons.php. We use freemius from now on for the Addons 1609 1613 1610 1614 = 2.1.2 - July 14.2017 = 1611 1615 * Added two now options to select the registration page and form in the general settings and overwrite the WordPress default registration form. 1612 1616 * Created two new functions buddyforms_registration_page_redirect and buddyforms_registration_page_content to redirect the WordPress registration to a BuddyForms Registration form 1613 1617 * Created a new user field Date 1614 1618 * Improved the error handling to better understand ajax errors. If WordPress post insert or update run into an error the error gets displayed. 1615 1619 * Fixed an issue with the post_excerpt. The form could not get saved if post_excerpt was empty. 1616 1620 * Moved the required "*" from beginning to the end of the label 1617 1621 * Fixed some issue in the registration if form is used to update user meta password and mail form element are not required 1618 1622 * Fixed several smaller issues reported by users 1619 1623 * 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 1620 1624 * Created a new option to hide the password form element for logged in users 1621 1625 1622 1626 = 2.1.1.2 - July 01.2017 = 1623 1627 * Fixed a merge conflict in the submissions and in the settings views. The submissions and settings was set to hidden from the js. 1624 1628 * Changed the submissions and settings html so it works with the current js and get displayed. 1625 1629 * Make sure all submission metabox get displayed 1626 1630 1627 1631 = 2.1.1.1 - Jun 29.2017 = 1628 1632 * Fixed an issue in the ajax error response. $$this should be $this. 1629 1633 * Adjust the checkbox and select box elements and make label and value required. 1630 1634 1631 1635 = 2.1.1 - Jun 27.2017 = 1632 1636 * Added a new form element post_excerpt 1633 1637 * Check if form template json request is an error code and load local json if needed. 1634 1638 * Create a new file deregister to manage all script and stiles we need to deregister 1635 1639 * Switch from $_SESSION to $wp_session 1636 1640 * Make sure the buddyforms metaboxes can not be hidden 1637 1641 * Move the Form Broken admin_notice to post_submitbox_start 1638 1642 * Make sure the css and js is not loaded on freemius pages 1639 1643 * Added a new option to the featured image form element to define the button label 1640 1644 * Add the field name to the error message 1641 1645 * Added class_exists as wrapper to the complete loader file to support freemius free plugin deactivation if pro version gets activated 1642 1646 * Reformat the code and deletes old and unneeded code 1643 1647 1644 1648 = 2.1.0.2 - Jun 12.2017 = 1645 1649 * Make sure registration activation does work all over the site and if no option is set the home is used 1646 1650 * Make sure registration activation code check is fired on all pages 1647 1651 * Allow to add admin mail as from email in the register account activation message 1648 1652 * Dependencies for WooCommerce Simple Auction added to the form templates 1649 1653 * Make sure the buddyforms_activate_user template redirect is before any other redirect can take place 1650 1654 * Added a new option to select a registration form for for the login form. 1651 1655 * Created a new function buddyforms_get_all_pages to get all pares as id's array or by name 1652 1656 * Fixed issues in the Registration and Activation Logic. Done some deeply testing and changing some logic. 1653 1657 * Auto Login user after click the activation link. 1654 1658 * Added some jQuery to to show hide permission options according to the public_submit settings 1655 1659 * Added referrer as after activation redirect 1656 1660 * Check if session is writable and change session to the WordPress upload dir if not writable. 1657 1661 * Fixed multiple issues 1658 1662 1659 1663 = 2.1.0.1 - Jun 08.2017 = 1660 1664 * Added a check is_wp_error for the form builder templates and load defaults if request failed. 1661 1665 * Added a ask for rating notice 1662 1666 * Fixed several smaller issues 1663 1667 * Remove freemius module migration. Its not needed anymore 1664 1668 * Update the Welcome Screen to the new features 1665 1669 1666 1670 = 2.1 - Jun 07.2017 = 1667 1671 * 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 1668 1672 1669 1673 Main New Features: 1670 1674 * Form Designer: New Metabox Form Designer to design your forms in detail. 1671 1675 * Form Grid: Add new Options to the Form Builder to set the grid 1672 1676 * Form Templates System to create any kind of Form from template 1673 1677 * Added the functionality to update registration forms from the front to allow existing users to change there user data and meta fields 1674 1678 1675 1679 Summary of changes: 1676 1680 * Added a new form element Phone, eMail and Range 1677 1681 * Create a new file metabox-layout.php for the form layout 1678 1682 * Added new options to adjust the form layout 1679 1683 * Added a new function buddyforms_can_edit to make anonymous and multi author posts possible 1680 1684 * Create a new global settings page for the form layout options 1681 1685 * Added a new option to the form element list in the form builder to define the grid 1682 1686 * Make the author id filterable 1683 1687 * Added functionality to load the layout form from other forms or the global settings 1684 1688 * Create a new function buddyforms_layout_style to determine the style and support bootstrap or other frameworks 1685 1689 * Added a new filer buddyforms_layout_style to overwrite the form grid classes 1686 1690 * Added CSS for form grid options 1687 1691 * Add a Grid builder to the Form ELements. 1688 1692 * Fixed a issue with session start if the server was restarted without deleting the session 1689 1693 * Added a new filter buddyforms_loop_template_name to register new loop templates 1690 1694 * 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. 1691 1695 * Update freemius to prevent function exist 1692 1696 * Create a new Element_InlineHTML to have an HTML form element without grid 1693 1697 * Fixed the schedule time. It was broken because the browser close the divs and render not work. 1694 1698 * Added a new filter buddyforms_the_lp_query to adjust the query result 1695 1699 * Clean up the content filter for the rewrite endpoints 1696 1700 * Add a function to support yoast seo 1697 1701 * Added new function buddyforms_is_author to make BuddyForms better work with multiple authors 1698 1702 * Added two new attributes $form_slug, $post_id to the buddyforms_user_can_delete filter 1699 1703 * 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 1700 1704 * Fixed a freemium issue where the freebies was displayed on gravity forms edit screen. 1701 1705 * 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. 1702 1706 * Added https support to google recaptcha 1703 1707 * Added a new shortcode bf_login_form to add a simple login/logout form 1704 1708 * Added new filters to manipulate the insert and update arguments buddyforms_wp_insert_post_args buddyforms_wp_update_post_args 1705 1709 * 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 1706 1710 * 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 1707 1711 * Move the session back to the constructor. Otherwise we get issue if the form is used in shortcodes 1708 1712 * Created a new function buddyforms_get_post_types to get the allowed posts types of BuddyForms 1709 1713 * Created a new function buddyforms_notice_if_broken_form to check if the form is broken #94 1710 1714 * Added the functionality to update registration forms from the front to allow existing users to change there user data and meta fields 1711 1715 * Added a new function buddyforms_wp_update_user to update existing users 1712 1716 * Adjust the process form script to support update post data and meta 1713 1717 * Added wp_editor support to the textarea 1714 1718 * Load js and css on BuddyForms settings page 1715 1719 * No footer scripts needed at the moment comment out the action for now. 1716 1720 * Added buddyforms-metabox class to settings metaboxes 1717 1721 * Fixed an issue in the global layout options. CSS and JS save was broken after rewrite the meta. 1718 1722 * Fixed an issue where the mail notification was not send if post status changed 1719 1723 * Fixed an issues in the mail buddy. line brakes have not been recognised 1720 1724 * Added new options for mail_from_name and mail_from 1721 1725 * Added the show hide js for new mail notification options 1722 1726 * Added a new attribute to $striped to the buddyforms_display_field_group_table to allow the disable of table striped 1723 1727 * New from options: user_login, user_firs, user_last, userfirst_last, blog_title or custom. Custom can use anf form element via shortcodes 1724 1728 * Added new file form-templates for the form builder and wizard templates 1725 1729 * Created a new function to create the templates array buddyforms_form_builder_register_templates 1726 1730 * Make Form Builder default Label values translatable 1727 1731 * Fixed Wizard -> Permissions -> Check all not working #60 1728 1732 * Last test with smaller fixes to check if the layout is working in the templates 1729 1733 * Fixed an issue in the mail notification settings in the form builder templates 1730 1734 * Strip the content in the submissions view #75 1731 1735 * Fixed hidden content mce toolbar #69 1732 1736 * Move the register post type out of the admin to make it accessible for the rest api 1733 1737 * Make use of the wp rest api for the form builder templates and load the json from the demo. 1734 1738 * Add Kleo Theme Support 1735 1739 * Fixed tons of smaller and bigger issues 1736 1740 * Clean up the code 1737 1741 1738 1742 = 2.0.15 - 05.04.2017 = 1739 1743 * 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 1740 1744 * Remove the languages. We use the .org translation from now on 1741 1745 * added post_id as global to the buddyforms_form_html function. 1742 1746 * 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 1743 1747 * Added new filter buddyforms_form_field_name and buddyforms_form_field_description to make the form label and description translatable. 1744 1748 * Added new filter buddyforms_wp_dropdown_categories_args to allow add new attributes to the arguments array. 1745 1749 * Added a new hook buddyforms_core_fs_loaded for other plugins to check if freemius sdk is loaded 1746 1750 * smaller fixes and css improvements 1747 1751 1748 1752 1749 1753 = 2.0.14 - 07.02.2017 = 1750 1754 * Added new Filter buddyforms_the_loop_args to manipulate the loop args 1751 1755 * Fixed a jQuery issue if the taxonomy select was not set to single it was not able to create a new tag. 1752 1756 * Added strip_tags for the auto generated title title. 1753 1757 * Better position error message on radiobuttons 1754 1758 * Enquire jQuery dialog and switch to jQuery dialog for all dialogs 1755 1759 * Select2 fields have not been responsive. Set the css width to auto 1756 1760 * Try to grab the form slug from the post to support form overwrite and also fallback to default 1757 1761 * Hook the form to the content why was this comment out? 1758 1762 * Make sure the form slug is accessible in the global 1759 1763 * Added a extra check in the e-mail to make sure we not fire any notice 1760 1764 1761 1765 = 2.0.13 = 1762 1766 * Add some checks if is object to avoid notice 1763 1767 * Changed from p tag to span in the generate title function to avoid line breaks 1764 1768 * Smaller Changes 1765 1769 1766 1770 = 2.0.12.1 = 1767 1771 * Add missing function buddyforms_get_form_field_by_slug. Was removed from merge conflict 1768 1772 1769 1773 = 2.0.12 = 1770 1774 * Add new file user-meta.php to display user meta fields in the admin user views 1771 1775 * There was an issue during registration. add_user_to_blog only works on multi site. 1772 1776 * Add missing parameter to the buddyforms_activate_account_mail for the new_user_id 1773 1777 * Rename_process_post to process_submissions 1774 1778 * Remove old unneeded functions 1775 1779 * Add new centralised sanitize function buddyforms_sanitize() 1776 1780 * Move the number form element to the basic fields 1777 1781 * Small jQuery fix. Make sure the correct fields get displayed for the field types 1778 1782 1779 1783 = 2.0.11 = 1780 1784 * Full support for the Visual Composer 1781 1785 * Add new loading overlay animation 1782 1786 * We fixed creating mail notification triggers in the form wizard. 1783 1787 * We fixed the submit button from stopped being working 1784 1788 * If the redirect is enabled and the form is set to ajax, we make sure that the ‘after submission message’ gets displayed 1785 1789 * Scroll to the top after submitting a successful form with ajax 1786 1790 * Add some field type management. This will get improved soon. It’s a starting point 1787 1791 * Add new options to generate content 1788 1792 * Create a new function to replace form fields easily by slug and shortcode [field_slug] 1789 1793 * Add a new option to the title to auto generate it from other form elements 1790 1794 * Create a new option in the taxonomy form element to select a placeholder text 1791 1795 * Add an ‘is_admin’ check to the post meta saving function, to avoid deleting meta while saving from the admin editing screen. 1792 1796 * Get the page_on_front and exclude it from the query. This page should not be used for the endpoints 1793 1797 * We removed visual composer elements from the BuddyForms editing screen 1794 1798 * Add an extra check to make sure JavaScript validation is only running if at least one form exist. 1795 1799 * Set the BuddyForms post type public to false. There is no need to access BuddyForms directly 1796 1800 * Add the post id to the buddyforms_user_can_edit filter. If we need more attributes it’s time for a arguments array 1797 1801 1798 1802 = 2.0.10 = 1799 1803 * Add Post Formats support 1800 1804 * Tested WordPress Version 4.7.1 1801 1805 * New Pro Feature: Create a new form element for the post formats 1802 1806 1803 1807 = 2.0.9 = 1804 1808 * Fixed a issue in the mail notification. Array elements like checkboxes and taxonomies got displayed as 'Array' 1805 1809 * Add a new function to display Checkboxes, eMails, Websites and Taxonomies in mail notifications. 1806 1810 1807 1811 = 2.0.8 = 1808 1812 * Enable Advanced options for the contact form fields 1809 1813 * Spelling correction 1810 1814 * Add some isset checks to prevent nonce in the form select meta box 1811 1815 * Add new parameter to the buddyforms_user_can_edit filter to enable limit user submissions by user role. 1812 1816 * Add all error messages in filter to allow the overwrite from other plugins 1813 1817 1814 1818 = 2.0.7 = 1815 1819 * Check if a mail notification exist to avoid php notice if debugger is enabled 1816 1820 * Update the freemius SDK. 1817 1821 1818 1822 1819 1823 = 2.0.6 = 1820 1824 * Fixed an issue with categories and tax. The form element was only working as taxonomy form element. 1821 1825 * Fixed the admin header for WordPress 4.7 1822 1826 * Update the welcome screen links and screenshots 1823 1827 1824 1828 1825 1829 = 2.0.5 = 1826 1830 * Add a new function remove_admin_scripts to remove styles and scripts added by other plugins and themes 1827 1831 * Add Kleo Theme Support 1828 1832 * 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. 1829 1833 * Make sure any css from other plugins is deregistered if the BuddyForms view is displayed 1830 1834 * Add suffix "buddyforms to all js handle 1831 1835 * remove_all_actions( 'admin_head', 10 ) if BuddyForms is viewed 1832 1836 * 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. 1833 1837 * Fixed a missing attribute in the buddyforms_form_element_multiple function cursing the form element checkbox and select to break. 1834 1838 1835 1839 = 2.0.4 = 1836 1840 * Fixed an issue in the form import function. 1837 1841 * Add a new do action buddyforms_admin_js_footer to add custom extension js to the admin footer 1838 1842 * Add a new filter buddyforms_form_builder_post_type to add new options into the post type select 1839 1843 * Rebuild buddyforms_locate_template function to fix a issue loosing the variables if used locate_template 1840 1844 * Rename buddyforms_add_form_element_to_select to buddyforms_add_form_element_select_option 1841 1845 * Add Text Domain and Domain Path in the header 1842 1846 * Remove indeed function parameter and variables 1843 1847 * Add dynamic version to the welcome screen 1844 1848 * Subject and message have not been unique 1845 1849 * Clean up the code 1846 1850 * Code smell fixes 1847 1851 * Delete unneeded files 1848 1852 * Update translations 1849 1853 1850 1854 = 2.0.3 = 1851 1855 * Remove old select2 dependencies 1852 1856 * Fixed a firefox admin ui css issue with the form type select box 1853 1857 * Make sure the taxonomy form element only get saved during form processing if a taxonomy is selected in the form element 1854 1858 * Separate starter and professional plans in the pro version. They have been accidentally the same. 1855 1859 * New labels for the free starter professional and business plans 1856 1860 * 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. 1857 1861 * If no message text is available BuddyForms will add all form element valuers as table into the eMail. 1858 1862 * Add new option to select the submitter as Sent to address 1859 1863 * 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 1860 1864 * Documentation for the new features 1861 1865 * Fixed smaller issues and css fixes reported by users. 1862 1866 1863 1867 = 2.0.2 = 1864 1868 * smaller submissions loop table css fixes 1865 1869 * fixed an issue with the update form the 1.5.3 version 1866 1870 1867 1871 = 2.0.1 = 1868 1872 * Freemius SDK update 1869 1873 * smaller changes 1870 1874 1871 1875 = 2.0 = 1872 1876 * First public version
Note: See TracChangeset
for help on using the changeset viewer.