Helpers
11 months ago
Integrations
1 week ago
RestApi
2 weeks ago
abilities
2 weeks ago
abstracts
2 weeks ago
admin
2 weeks ago
blocks
1 year ago
elementor
2 years ago
export
2 months ago
fields
2 weeks ago
interfaces
8 years ago
libraries
2 years ago
log-handlers
1 year ago
shortcodes
2 weeks ago
stats
5 months ago
templates
3 months ago
traits
2 weeks ago
class-everest-forms.php
1 week ago
class-evf-addon-upsell.php
2 weeks ago
class-evf-ajax.php
2 weeks ago
class-evf-autoloader.php
7 years ago
class-evf-background-process-import-entries.php
1 year ago
class-evf-background-updater.php
7 years ago
class-evf-cache-helper.php
2 months ago
class-evf-cron.php
2 years ago
class-evf-deprecated-action-hooks.php
6 years ago
class-evf-deprecated-filter-hooks.php
5 years ago
class-evf-email-entries-report.php
3 months ago
class-evf-emails.php
2 weeks ago
class-evf-fields.php
2 weeks ago
class-evf-form-handler.php
2 weeks ago
class-evf-form-task.php
2 weeks ago
class-evf-forms-features.php
2 weeks ago
class-evf-frontend-scripts.php
2 weeks ago
class-evf-install.php
2 months ago
class-evf-integrations.php
3 months ago
class-evf-log-levels.php
8 years ago
class-evf-logger.php
5 years ago
class-evf-post-types.php
1 year ago
class-evf-privacy.php
6 years ago
class-evf-report-cron.php
2 months ago
class-evf-reporting.php
2 months ago
class-evf-session-handler.php
7 years ago
class-evf-shortcodes.php
1 year ago
class-evf-smart-tags.php
9 months ago
class-evf-template-loader.php
1 year ago
class-evf-validation.php
6 years ago
evf-conditional-functions.php
6 years ago
evf-core-functions.php
2 weeks ago
evf-deprecated-functions.php
6 years ago
evf-entry-functions.php
4 months ago
evf-formatting-functions.php
4 years ago
evf-notice-functions.php
4 years ago
evf-template-functions.php
4 years ago
evf-template-hooks.php
7 years ago
evf-update-functions.php
5 years ago
class-evf-shortcodes.php
84 lines
| 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 | $form_id = isset( $atts['id'] ) ? $atts['id'] : ''; |
| 50 | $is_theme_style = get_post_meta( $form_id, 'everest_forms_enable_theme_style', true ); |
| 51 | if ( 'default' === $is_theme_style ) { |
| 52 | $wrapper['class'] .= ' evf-frontend-form-default'; |
| 53 | wp_register_style( 'evf-frontend-default-css', EVF()->plugin_url() . '/assets/css/everest-forms-default-frontend.css', array(), EVF_VERSION ); |
| 54 | wp_enqueue_style( 'evf-frontend-default-css' ); |
| 55 | } |
| 56 | ob_start(); |
| 57 | |
| 58 | $wrap_before = empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
| 59 | echo wp_kses_post( $wrap_before ); |
| 60 | call_user_func( $function, $atts ); |
| 61 | $wrap_after = empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
| 62 | echo wp_kses_post( $wrap_after ); |
| 63 | |
| 64 | return ob_get_clean(); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Form shortcode. |
| 69 | * |
| 70 | * @param array $atts Attributes. |
| 71 | * @return string |
| 72 | */ |
| 73 | public static function form( $atts ) { |
| 74 | return self::shortcode_wrapper( array( 'EVF_Shortcode_Form', 'output' ), $atts ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Initialize shortcode. |
| 79 | */ |
| 80 | public static function init_shortcode_hooks() { |
| 81 | self::shortcode_wrapper( array( 'EVF_Shortcode_Form', 'hooks' ) ); |
| 82 | } |
| 83 | } |
| 84 |