PluginProbe
WPBot – ChatBot Conversational Forms / 1.2.0
WPBot – ChatBot Conversational Forms v1.2.0
1.5.0 1.4.8 1.4.7 trunk 0.9.2 0.9.3 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.6 1.1.7 1.1.8 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 All 36 releases
conversational-forms / classes / shortcode / atts.php

atts.php in WPBot – ChatBot Conversational Forms 1.2.0, at classes/shortcode/atts.php

97 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Filters shortcode attributes
5 *
6 * @package Caldera_Forms Modified by QuantumCloud
7 * @author Josh Pollock <Josh@CalderaWP.com>
8 * @license GPL-2.0+
9 * @link
10 * @copyright 2015 CalderaWP LLC
11 */
12 class Qcformbuilder_Forms_Shortcode_Atts {
13
14 /**
15 * Setup field defaults form shortocde attributes
16 *
17 * @since 1.5.0.7
18 *
19 * @uses "shortcode_atts_qcformbuilder_form" filter
20 * @uses "shortcode_atts_qcformbuilder_form_modal" filter
21 *
22 * @param array $out
23 * @param array $pairs
24 * @param array $atts
25 * @param string $shortcode
26 *
27 * @return array
28 */
29 public static function allow_default_set( $out, $pairs, $atts, $shortcode ){
30 $form = array();
31 if ( isset( $atts[ 'id' ] ) ) {
32 $form = Qcformbuilder_Forms_Forms::get_form( $atts[ 'id' ] );
33
34 }
35
36 if ( empty( $form ) && isset( $atts[ 'ID' ] ) ) {
37 $form = Qcformbuilder_Forms_Forms::get_form( $atts[ 'ID' ] );
38
39 }
40
41 if ( empty( $form ) && isset( $form[ 'name' ] ) ) {
42 $form = Qcformbuilder_Forms_Forms::get_form( $atts[ 'name' ] );
43 }
44
45 $defaults = array();
46
47 if( ! empty( $form ) ){
48 $fields = Qcformbuilder_Forms_Forms::get_fields( $form );
49 $field_ids = array_keys( $fields );
50
51 if( ! empty( $field_ids ) ){
52 foreach ( $atts as $att => $value ){
53 if( in_array( $att, $field_ids ) ){
54 $defaults[ $att ] = $value;
55 $out[ $att ] = $value;
56 }
57 }
58 }
59 }
60
61 if( ! empty( $defaults ) ){
62 $obj = new Qcformbuilder_Forms_Shortcode_Defaults( $form[ 'ID' ], $defaults );
63 $obj->add_hooks();
64 add_action( 'qcformbuilder_forms_render_end', array( $obj, 'remove_hooks' ) );
65
66 }
67
68 return $out;
69
70 }
71
72 /**
73 * Whitleist revision shortcode arg if user has permissions
74 *
75 * @since 1.5.3
76 *
77 * @uses "shortcode_atts_qcformbuilder_form" filter
78 * @uses "shortcode_atts_qcformbuilder_form_modal" filter
79 *
80 * @param array $out
81 * @param array $pairs
82 * @param array $atts
83 * @param string $shortcode
84 *
85 * @return array
86 */
87 public static function maybe_allow_revision( $out, $pairs, $atts, $shortcode ){
88 if( current_user_can( Qcformbuilder_Forms::get_manage_cap( 'admin' ) ) ){
89 if( isset( $atts[ 'revision' ] ) ){
90 $out[ 'revision' ] = $atts[ 'revision' ];
91 }
92 }
93
94 return $out;
95 }
96
97 }