| @@ -5,9 +5,8 @@ | ||
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @since 2.02.12 |
| 8 | 8 | */ |
| 9 | - | |
| 10 | 9 | class FrmShortcodeHelper { |
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Get the shortcode attributes in key/value pairs from a string |
| @@ -31,14 +30,63 @@ | ||
| 31 | 30 | return $atts; |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | 33 | /** |
| 34 | + * Returns shortcodes that are shown/hidden based on the context. | |
| 35 | + * | |
| 36 | + * @since 6.16.3 | |
| 37 | + * @return array | |
| 38 | + */ | |
| 39 | + public static function get_contextual_shortcodes() { | |
| 40 | + return array( | |
| 41 | + 'address' => array( | |
| 42 | + 'admin_email' => __( 'Admin email', 'formidable' ), | |
| 43 | + 'default-from-email' => __( 'Default from email', 'formidable' ), | |
| 44 | + 'default-email' => __( 'Default email', 'formidable' ), | |
| 45 | + ), | |
| 46 | + 'body' => array( | |
| 47 | + 'default-message' => __( 'Default Msg', 'formidable' ), | |
| 48 | + 'default-html' => __( 'Default HTML', 'formidable' ), | |
| 49 | + 'default-plain' => __( 'Default Plain', 'formidable' ), | |
| 50 | + ), | |
| 51 | + ); | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Get contextual shortcodes. | |
| 56 | + * | |
| 57 | + * @since 6.16.3 | |
| 58 | + * | |
| 59 | + * @return array | |
| 60 | + */ | |
| 61 | + public static function get_contextual_shortcode_values() { | |
| 62 | + $contextual_shortcodes = self::get_contextual_shortcodes(); | |
| 63 | + return array_merge( $contextual_shortcodes['address'], $contextual_shortcodes['body'] ); | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Get flattened format of contextual shortcodes. | |
| 68 | + * | |
| 69 | + * @since 6.16.3 | |
| 70 | + * | |
| 71 | + * @return array | |
| 72 | + */ | |
| 73 | + public static function get_contextual_codes() { | |
| 74 | + $contextual_shortcodes = self::get_contextual_shortcodes(); | |
| 75 | + $result = array(); | |
| 76 | + foreach ( $contextual_shortcodes as $type => $shortcodes ) { | |
| 77 | + $result[ $type ] = array_keys( $shortcodes ); | |
| 78 | + } | |
| 79 | + return $result; | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 35 | 83 | * Get the name of the shortcode from the regEx |
| 36 | 84 | * |
| 37 | 85 | * @since 3.0 |
| 38 | 86 | * |
| 39 | 87 | * @param array $shortcodes |
| 40 | - * @param int $short_key The position in the shortcodes array | |
| 88 | + * @param int $short_key The position in the shortcodes array. | |
| 41 | 89 | * @param array $args |
| 42 | 90 | * |
| 43 | 91 | * @return string |
| 44 | 92 | */ |