PluginProbe
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.4.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.4.2
3.6.1 3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 165 releases
everest-forms / trunk / includes / class-evf-shortcodes.php
class-evf-shortcodes.php
78 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcodes
4 *
5 * @package EverestForms\Classes
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EverestForms Shortcodes class.
13 */
14 class EVF_Shortcodes {
15
16 /**
17 * Init shortcodes.
18 */
19 public static function init() {
20 self::init_shortcode_hooks();
21
22 $shortcodes = array(
23 'everest_form' => __CLASS__ . '::form',
24 );
25
26 foreach ( $shortcodes as $shortcode => $function ) {
27 add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function );
28 }
29 }
30
31 /**
32 * Shortcode Wrapper.
33 *
34 * @param string[] $function Callback function.
35 * @param array $atts Attributes. Default to empty array.
36 * @param array $wrapper Customer wrapper data.
37 *
38 * @return string
39 */
40 public static function shortcode_wrapper(
41 $function,
42 $atts = array(),
43 $wrapper = array(
44 'class' => 'everest-forms',
45 'before' => null,
46 'after' => null,
47 )
48 ) {
49 ob_start();
50
51 // @codingStandardsIgnoreStart
52 echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before'];
53 call_user_func( $function, $atts );
54 echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after'];
55
56 // @codingStandardsIgnoreEnd
57
58 return ob_get_clean();
59 }
60
61 /**
62 * Form shortcode.
63 *
64 * @param array $atts Attributes.
65 * @return string
66 */
67 public static function form( $atts ) {
68 return self::shortcode_wrapper( array( 'EVF_Shortcode_Form', 'output' ), $atts );
69 }
70
71 /**
72 * Initialize shortcode.
73 */
74 public static function init_shortcode_hooks() {
75 self::shortcode_wrapper( array( 'EVF_Shortcode_Form', 'hooks' ) );
76 }
77 }
78