@@ -1,243 +1,243 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmSettings{ |
| 4 | - public $option_name = 'frm_options'; |
|
| 5 | - public $menu; |
|
| 6 | - public $mu_menu; |
|
| 7 | - public $preview_page_id; |
|
| 8 | - public $use_html; |
|
| 9 | - public $jquery_css; |
|
| 10 | - public $accordion_js; |
|
| 11 | - |
|
| 12 | - public $success_msg; |
|
| 13 | - public $blank_msg; |
|
| 14 | - public $unique_msg; |
|
| 15 | - public $invalid_msg; |
|
| 16 | - public $failed_msg; |
|
| 17 | - public $submit_value; |
|
| 18 | - public $login_msg; |
|
| 19 | - public $admin_permission; |
|
| 20 | - |
|
| 21 | - public $email_to; |
|
| 22 | - public $load_style; |
|
| 23 | - public $custom_style; |
|
| 24 | - |
|
| 25 | - public $pubkey; |
|
| 26 | - public $privkey; |
|
| 27 | - public $re_lang; |
|
| 28 | - public $re_msg; |
|
| 4 | + public $option_name = 'frm_options'; |
|
| 5 | + public $menu; |
|
| 6 | + public $mu_menu; |
|
| 7 | + public $preview_page_id; |
|
| 8 | + public $use_html; |
|
| 9 | + public $jquery_css; |
|
| 10 | + public $accordion_js; |
|
| 11 | + |
|
| 12 | + public $success_msg; |
|
| 13 | + public $blank_msg; |
|
| 14 | + public $unique_msg; |
|
| 15 | + public $invalid_msg; |
|
| 16 | + public $failed_msg; |
|
| 17 | + public $submit_value; |
|
| 18 | + public $login_msg; |
|
| 19 | + public $admin_permission; |
|
| 20 | + |
|
| 21 | + public $email_to; |
|
| 22 | + public $load_style; |
|
| 23 | + public $custom_style; |
|
| 24 | + |
|
| 25 | + public $pubkey; |
|
| 26 | + public $privkey; |
|
| 27 | + public $re_lang; |
|
| 28 | + public $re_msg; |
|
| 29 | 29 | public $re_multi; |
| 30 | 30 | |
| 31 | - public function __construct() { |
|
| 32 | - if ( ! defined('ABSPATH') ) { |
|
| 33 | - die('You are not allowed to call this page directly.'); |
|
| 34 | - } |
|
| 31 | + public function __construct() { |
|
| 32 | + if ( ! defined('ABSPATH') ) { |
|
| 33 | + die('You are not allowed to call this page directly.'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $settings = get_transient($this->option_name); |
|
| 36 | + $settings = get_transient($this->option_name); |
|
| 37 | 37 | |
| 38 | - if ( ! is_object($settings) ) { |
|
| 39 | - $settings = $this->translate_settings($settings); |
|
| 40 | - } |
|
| 38 | + if ( ! is_object($settings) ) { |
|
| 39 | + $settings = $this->translate_settings($settings); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - foreach ( $settings as $setting_name => $setting ) { |
|
| 43 | - $this->{$setting_name} = $setting; |
|
| 44 | - unset($setting_name, $setting); |
|
| 45 | - } |
|
| 42 | + foreach ( $settings as $setting_name => $setting ) { |
|
| 43 | + $this->{$setting_name} = $setting; |
|
| 44 | + unset($setting_name, $setting); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $this->set_default_options(); |
|
| 48 | - } |
|
| 47 | + $this->set_default_options(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | private function translate_settings( $settings ) { |
| 51 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 52 | - return unserialize(serialize($settings)); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $settings = get_option($this->option_name); |
|
| 56 | - if ( is_object($settings) ) { |
|
| 57 | - set_transient($this->option_name, $settings); |
|
| 58 | - return $settings; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - // If unserializing didn't work |
|
| 62 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 63 | - $settings = unserialize(serialize($settings)); |
|
| 64 | - } else { |
|
| 65 | - $settings = $this; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - update_option($this->option_name, $settings); |
|
| 69 | - set_transient($this->option_name, $settings); |
|
| 70 | - |
|
| 71 | - return $settings; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return array |
|
| 76 | - */ |
|
| 51 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 52 | + return unserialize(serialize($settings)); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $settings = get_option($this->option_name); |
|
| 56 | + if ( is_object($settings) ) { |
|
| 57 | + set_transient($this->option_name, $settings); |
|
| 58 | + return $settings; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + // If unserializing didn't work |
|
| 62 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 63 | + $settings = unserialize(serialize($settings)); |
|
| 64 | + } else { |
|
| 65 | + $settings = $this; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + update_option($this->option_name, $settings); |
|
| 69 | + set_transient($this->option_name, $settings); |
|
| 70 | + |
|
| 71 | + return $settings; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | 77 | public function default_options() { |
| 78 | - return array( |
|
| 79 | - 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
| 80 | - 'mu_menu' => 0, |
|
| 81 | - 'preview_page_id' => 0, |
|
| 82 | - 'use_html' => true, |
|
| 83 | - 'jquery_css' => false, |
|
| 84 | - 'accordion_js' => false, |
|
| 78 | + return array( |
|
| 79 | + 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
| 80 | + 'mu_menu' => 0, |
|
| 81 | + 'preview_page_id' => 0, |
|
| 82 | + 'use_html' => true, |
|
| 83 | + 'jquery_css' => false, |
|
| 84 | + 'accordion_js' => false, |
|
| 85 | 85 | |
| 86 | 86 | 're_multi' => 0, |
| 87 | 87 | |
| 88 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 89 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 90 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 91 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 92 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 93 | - 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 94 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 95 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 88 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 89 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 90 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 91 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 92 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 93 | + 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 94 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 95 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 96 | 96 | |
| 97 | - 'email_to' => '[admin_email]', |
|
| 98 | - ); |
|
| 99 | - } |
|
| 97 | + 'email_to' => '[admin_email]', |
|
| 98 | + ); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | private function set_default_options() { |
| 102 | - $this->fill_recaptcha_settings(); |
|
| 103 | - |
|
| 104 | - if ( ! isset($this->load_style) ) { |
|
| 105 | - if ( ! isset($this->custom_style) ) { |
|
| 106 | - $this->custom_style = true; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $this->load_style = 'all'; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $this->fill_with_defaults(); |
|
| 113 | - |
|
| 114 | - if ( is_multisite() && is_admin() ) { |
|
| 115 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 116 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 117 | - $this->menu = $mu_menu; |
|
| 118 | - $this->mu_menu = 1; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 123 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 124 | - if ( ! isset($this->$frm_role) ) { |
|
| 125 | - $this->$frm_role = 'administrator'; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 102 | + $this->fill_recaptcha_settings(); |
|
| 103 | + |
|
| 104 | + if ( ! isset($this->load_style) ) { |
|
| 105 | + if ( ! isset($this->custom_style) ) { |
|
| 106 | + $this->custom_style = true; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $this->load_style = 'all'; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $this->fill_with_defaults(); |
|
| 113 | + |
|
| 114 | + if ( is_multisite() && is_admin() ) { |
|
| 115 | + $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 116 | + if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 117 | + $this->menu = $mu_menu; |
|
| 118 | + $this->mu_menu = 1; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 123 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 124 | + if ( ! isset($this->$frm_role) ) { |
|
| 125 | + $this->$frm_role = 'administrator'; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | public function fill_with_defaults( $params = array() ) { |
| 131 | - $settings = $this->default_options(); |
|
| 131 | + $settings = $this->default_options(); |
|
| 132 | 132 | |
| 133 | - foreach ( $settings as $setting => $default ) { |
|
| 133 | + foreach ( $settings as $setting => $default ) { |
|
| 134 | 134 | if ( isset( $params[ 'frm_' . $setting ] ) ) { |
| 135 | 135 | $this->{$setting} = $params[ 'frm_' . $setting ]; |
| 136 | - } else if ( ! isset($this->{$setting}) ) { |
|
| 137 | - $this->{$setting} = $default; |
|
| 138 | - } |
|
| 136 | + } else if ( ! isset($this->{$setting}) ) { |
|
| 137 | + $this->{$setting} = $default; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | if ( $setting == 'menu' && empty( $this->{$setting} ) ) { |
| 141 | 141 | $this->{$setting} = $default; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - unset($setting, $default); |
|
| 145 | - } |
|
| 146 | - } |
|
| 144 | + unset($setting, $default); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - private function fill_recaptcha_settings() { |
|
| 149 | - $privkey = ''; |
|
| 148 | + private function fill_recaptcha_settings() { |
|
| 149 | + $privkey = ''; |
|
| 150 | 150 | $re_lang = ''; |
| 151 | 151 | |
| 152 | - if ( ! isset($this->pubkey) ) { |
|
| 153 | - // get the options from the database |
|
| 154 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 155 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 156 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 157 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 158 | - } |
|
| 152 | + if ( ! isset($this->pubkey) ) { |
|
| 153 | + // get the options from the database |
|
| 154 | + $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 155 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 156 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 157 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 161 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 162 | - } |
|
| 160 | + if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 161 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - if ( ! isset($this->privkey) ) { |
|
| 165 | - $this->privkey = $privkey; |
|
| 166 | - } |
|
| 164 | + if ( ! isset($this->privkey) ) { |
|
| 165 | + $this->privkey = $privkey; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - if ( ! isset($this->re_lang) ) { |
|
| 169 | - $this->re_lang = $re_lang; |
|
| 170 | - } |
|
| 171 | - } |
|
| 168 | + if ( ! isset($this->re_lang) ) { |
|
| 169 | + $this->re_lang = $re_lang; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public function validate( $params, $errors ) { |
|
| 174 | - $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 175 | - return $errors; |
|
| 176 | - } |
|
| 173 | + public function validate( $params, $errors ) { |
|
| 174 | + $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 175 | + return $errors; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | public function update( $params ) { |
| 179 | - $this->fill_with_defaults($params); |
|
| 180 | - $this->update_settings($params); |
|
| 179 | + $this->fill_with_defaults($params); |
|
| 180 | + $this->update_settings($params); |
|
| 181 | 181 | |
| 182 | - if ( $this->mu_menu ) { |
|
| 183 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
| 184 | - } else if ( current_user_can('administrator') ) { |
|
| 185 | - update_site_option('frm_admin_menu_name', false); |
|
| 186 | - } |
|
| 182 | + if ( $this->mu_menu ) { |
|
| 183 | + update_site_option('frm_admin_menu_name', $this->menu); |
|
| 184 | + } else if ( current_user_can('administrator') ) { |
|
| 185 | + update_site_option('frm_admin_menu_name', false); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - $this->update_roles($params); |
|
| 188 | + $this->update_roles($params); |
|
| 189 | 189 | |
| 190 | - do_action( 'frm_update_settings', $params ); |
|
| 191 | - } |
|
| 190 | + do_action( 'frm_update_settings', $params ); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | private function update_settings( $params ) { |
| 194 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 194 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 195 | 195 | |
| 196 | - $this->pubkey = trim($params['frm_pubkey']); |
|
| 197 | - $this->privkey = $params['frm_privkey']; |
|
| 198 | - $this->re_lang = $params['frm_re_lang']; |
|
| 196 | + $this->pubkey = trim($params['frm_pubkey']); |
|
| 197 | + $this->privkey = $params['frm_privkey']; |
|
| 198 | + $this->re_lang = $params['frm_re_lang']; |
|
| 199 | 199 | $this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0; |
| 200 | 200 | |
| 201 | - $this->load_style = $params['frm_load_style']; |
|
| 202 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 201 | + $this->load_style = $params['frm_load_style']; |
|
| 202 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 203 | 203 | |
| 204 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 205 | - //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
| 204 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 205 | + //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
| 206 | 206 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
| 207 | 207 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
| 208 | - } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | private function update_roles( $params ) { |
| 211 | - global $wp_roles; |
|
| 211 | + global $wp_roles; |
|
| 212 | 212 | |
| 213 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 214 | - $roles = get_editable_roles(); |
|
| 215 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 216 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 213 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 214 | + $roles = get_editable_roles(); |
|
| 215 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 216 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 217 | 217 | |
| 218 | - // Make sure administrators always have permissions |
|
| 219 | - if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 218 | + // Make sure administrators always have permissions |
|
| 219 | + if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 220 | 220 | array_push( $this->$frm_role, 'administrator' ); |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - foreach ( $roles as $role => $details ) { |
|
| 224 | - if ( in_array($role, $this->$frm_role) ) { |
|
| 225 | - $wp_roles->add_cap( $role, $frm_role ); |
|
| 226 | - } else { |
|
| 227 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 228 | - } |
|
| 229 | - } |
|
| 223 | + foreach ( $roles as $role => $details ) { |
|
| 224 | + if ( in_array($role, $this->$frm_role) ) { |
|
| 225 | + $wp_roles->add_cap( $role, $frm_role ); |
|
| 226 | + } else { |
|
| 227 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | } |
| 231 | - } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | 233 | public function store() { |
| 234 | - // Save the posted value in the database |
|
| 234 | + // Save the posted value in the database |
|
| 235 | 235 | |
| 236 | - update_option('frm_options', $this); |
|
| 236 | + update_option('frm_options', $this); |
|
| 237 | 237 | |
| 238 | - delete_transient('frm_options'); |
|
| 239 | - set_transient('frm_options', $this); |
|
| 238 | + delete_transient('frm_options'); |
|
| 239 | + set_transient('frm_options', $this); |
|
| 240 | 240 | |
| 241 | - do_action( 'frm_store_settings' ); |
|
| 242 | - } |
|
| 241 | + do_action( 'frm_store_settings' ); |
|
| 242 | + } |
|
| 243 | 243 | } |
@@ -7,71 +7,71 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | - |
|
| 17 | - $values = array(); |
|
| 18 | - |
|
| 19 | - foreach ( $defaults as $var => $default ) { |
|
| 20 | - if ( $var == 'field_options' ) { |
|
| 21 | - $values['field_options'] = array(); |
|
| 22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $values[ $var ] = $default; |
|
| 28 | - } |
|
| 29 | - unset($var, $default); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | - $values['field_options']['data_type'] = $setting; |
|
| 35 | - } else { |
|
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | - $values['options'] = serialize( array( |
|
| 42 | - __( 'Option 1', 'formidable' ), |
|
| 43 | - __( 'Option 2', 'formidable' ), |
|
| 44 | - ) ); |
|
| 45 | - } else if ( $type == 'select' ) { |
|
| 46 | - $values['options'] = serialize( array( |
|
| 47 | - '', __( 'Option 1', 'formidable' ), |
|
| 48 | - ) ); |
|
| 49 | - } else if ( $type == 'textarea' ) { |
|
| 50 | - $values['field_options']['max'] = '5'; |
|
| 51 | - } else if ( $type == 'captcha' ) { |
|
| 52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | - $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | - } else if ( 'url' == $type ) { |
|
| 55 | - $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | - } |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | + |
|
| 17 | + $values = array(); |
|
| 18 | + |
|
| 19 | + foreach ( $defaults as $var => $default ) { |
|
| 20 | + if ( $var == 'field_options' ) { |
|
| 21 | + $values['field_options'] = array(); |
|
| 22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | + unset($opt_var, $opt_default); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $values[ $var ] = $default; |
|
| 28 | + } |
|
| 29 | + unset($var, $default); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | + $values['field_options']['data_type'] = $setting; |
|
| 35 | + } else { |
|
| 36 | + $values['field_options'][ $setting ] = 1; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | + $values['options'] = serialize( array( |
|
| 42 | + __( 'Option 1', 'formidable' ), |
|
| 43 | + __( 'Option 2', 'formidable' ), |
|
| 44 | + ) ); |
|
| 45 | + } else if ( $type == 'select' ) { |
|
| 46 | + $values['options'] = serialize( array( |
|
| 47 | + '', __( 'Option 1', 'formidable' ), |
|
| 48 | + ) ); |
|
| 49 | + } else if ( $type == 'textarea' ) { |
|
| 50 | + $values['field_options']['max'] = '5'; |
|
| 51 | + } else if ( $type == 'captcha' ) { |
|
| 52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | + $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | + } else if ( 'url' == $type ) { |
|
| 55 | + $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $fields = FrmField::field_selection(); |
| 59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 59 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 60 | 60 | |
| 61 | - if ( isset( $fields[ $type ] ) ) { |
|
| 62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | - } |
|
| 61 | + if ( isset( $fields[ $type ] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset($fields); |
|
| 66 | 66 | |
| 67 | - return $values; |
|
| 68 | - } |
|
| 67 | + return $values; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | public static function get_html_id( $field, $plus = '' ) { |
| 71 | 71 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 74 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 75 | 75 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
| 76 | 76 | $defaults = array( |
| 77 | 77 | 'name' => $record->name, |
@@ -84,86 +84,86 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | if ( $doing_ajax ) { |
| 87 | - $values = $values + $defaults; |
|
| 88 | - $values['form_name'] = ''; |
|
| 87 | + $values = $values + $defaults; |
|
| 88 | + $values['form_name'] = ''; |
|
| 89 | 89 | } else { |
| 90 | 90 | foreach ( $defaults as $var => $default ) { |
| 91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | - unset($var, $default); |
|
| 93 | - } |
|
| 91 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset($var, $default); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | unset( $defaults ); |
| 99 | 99 | |
| 100 | - $values['options'] = $record->options; |
|
| 101 | - $values['field_options'] = $record->field_options; |
|
| 100 | + $values['options'] = $record->options; |
|
| 101 | + $values['field_options'] = $record->field_options; |
|
| 102 | 102 | |
| 103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 103 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 104 | 104 | |
| 105 | 105 | if ( $values['type'] == 'captcha' ) { |
| 106 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | - } |
|
| 106 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | foreach ( $defaults as $opt => $default ) { |
| 111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | - unset($opt, $default); |
|
| 113 | - } |
|
| 111 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | + unset($opt, $default); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 115 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 116 | 116 | |
| 117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | - $field_options = array( |
|
| 122 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 120 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | + $field_options = array( |
|
| 122 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 125 | 125 | 'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light', |
| 126 | - ); |
|
| 126 | + ); |
|
| 127 | 127 | |
| 128 | 128 | if ( $limit ) { |
| 129 | - return $field_options; |
|
| 129 | + return $field_options; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - global $wpdb; |
|
| 132 | + global $wpdb; |
|
| 133 | 133 | |
| 134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 134 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | 135 | |
| 136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 137 | 137 | |
| 138 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 138 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 139 | 139 | |
| 140 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | - return array( |
|
| 142 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 140 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | + return array( |
|
| 142 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 143 | 143 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
| 144 | 144 | 'field_order' => $field_count + 1, 'required' => false, |
| 145 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 145 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 147 | 147 | 'field_options' => $field_options, |
| 148 | - ); |
|
| 149 | - } |
|
| 148 | + ); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | - global $wpdb; |
|
| 151 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | + global $wpdb; |
|
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | - $values['form_id'] = $form_id; |
|
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | - |
|
| 159 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @since 2.0 |
|
| 166 | - */ |
|
| 155 | + $values['form_id'] = $form_id; |
|
| 156 | + $values['options'] = maybe_serialize($field->options); |
|
| 157 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | + |
|
| 159 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | + $values[ $col ] = $field->{$col}; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @since 2.0 |
|
| 166 | + */ |
|
| 167 | 167 | public static function get_error_msg( $field, $error ) { |
| 168 | 168 | $frm_settings = FrmAppHelper::get_settings(); |
| 169 | 169 | $default_settings = $frm_settings->default_options(); |
@@ -183,21 +183,21 @@ discard block |
||
| 183 | 183 | return $msg; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public static function get_form_fields( $form_id, $error = false ) { |
|
| 187 | - $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 189 | - return $fields; |
|
| 190 | - } |
|
| 186 | + public static function get_form_fields( $form_id, $error = false ) { |
|
| 187 | + $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | + $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 189 | + return $fields; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | public static function get_default_html( $type = 'text' ) { |
| 193 | 193 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 194 | 194 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 195 | - $for = ''; |
|
| 195 | + $for = ''; |
|
| 196 | 196 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 197 | - $for = 'for="field_[key]"'; |
|
| 198 | - } |
|
| 197 | + $for = 'for="field_[key]"'; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $default_html = <<<DEFAULT_HTML |
|
| 200 | + $default_html = <<<DEFAULT_HTML |
|
| 201 | 201 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 202 | 202 | <label $for class="frm_primary_label">[field_name] |
| 203 | 203 | <span class="frm_required">[required_label]</span> |
@@ -207,138 +207,138 @@ discard block |
||
| 207 | 207 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | - } else { |
|
| 210 | + } else { |
|
| 211 | 211 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | - } |
|
| 214 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 219 | 219 | |
| 220 | - $defaults = array( |
|
| 220 | + $defaults = array( |
|
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 222 | 222 | 'field_id' => $field['id'], |
| 223 | - 'field_plus_id' => '', |
|
| 224 | - 'section_id' => '', |
|
| 225 | - ); |
|
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 227 | - $field_name = $args['field_name']; |
|
| 228 | - $field_id = $args['field_id']; |
|
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 223 | + 'field_plus_id' => '', |
|
| 224 | + 'section_id' => '', |
|
| 225 | + ); |
|
| 226 | + $args = wp_parse_args($args, $defaults); |
|
| 227 | + $field_name = $args['field_name']; |
|
| 228 | + $field_id = $args['field_id']; |
|
| 229 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | - $field_name .= '[]'; |
|
| 233 | - } |
|
| 231 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | + $field_name .= '[]'; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - //replace [id] |
|
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 235 | + //replace [id] |
|
| 236 | + $html = str_replace('[id]', $field_id, $html); |
|
| 237 | 237 | |
| 238 | - // Remove the for attribute for captcha |
|
| 239 | - if ( $field['type'] == 'captcha' ) { |
|
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | - } |
|
| 238 | + // Remove the for attribute for captcha |
|
| 239 | + if ( $field['type'] == 'captcha' ) { |
|
| 240 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - // set the label for |
|
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 243 | + // set the label for |
|
| 244 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 245 | 245 | |
| 246 | - //replace [key] |
|
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 246 | + //replace [key] |
|
| 247 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 248 | 248 | |
| 249 | - //replace [description] and [required_label] and [error] |
|
| 249 | + //replace [description] and [required_label] and [error] |
|
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | - if ( ! is_array( $errors ) ) { |
|
| 252 | - $errors = array(); |
|
| 253 | - } |
|
| 251 | + if ( ! is_array( $errors ) ) { |
|
| 252 | + $errors = array(); |
|
| 253 | + } |
|
| 254 | 254 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 255 | 255 | |
| 256 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | - if ( $field['type'] == 'divider' ) { |
|
| 258 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | - } else { |
|
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | - } |
|
| 263 | - } |
|
| 256 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | + if ( $field['type'] == 'divider' ) { |
|
| 258 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | + } else { |
|
| 261 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
| 266 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | - } |
|
| 266 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - //replace [required_class] |
|
| 269 | + //replace [required_class] |
|
| 270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 272 | 272 | |
| 273 | - //replace [label_position] |
|
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 273 | + //replace [label_position] |
|
| 274 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 277 | 277 | |
| 278 | - //replace [field_name] |
|
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 278 | + //replace [field_name] |
|
| 279 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | - //replace [entry_key] |
|
| 284 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 283 | + //replace [entry_key] |
|
| 284 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 286 | 286 | |
| 287 | - //replace [input] |
|
| 288 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 289 | - global $frm_vars; |
|
| 290 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 287 | + //replace [input] |
|
| 288 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 289 | + global $frm_vars; |
|
| 290 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 291 | 291 | |
| 292 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 293 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 292 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 293 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 294 | 294 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 295 | 295 | |
| 296 | - $replace_with = ''; |
|
| 296 | + $replace_with = ''; |
|
| 297 | 297 | |
| 298 | - if ( $tag == 'input' ) { |
|
| 299 | - if ( isset($atts['opt']) ) { |
|
| 300 | - $atts['opt']--; |
|
| 301 | - } |
|
| 298 | + if ( $tag == 'input' ) { |
|
| 299 | + if ( isset($atts['opt']) ) { |
|
| 300 | + $atts['opt']--; |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 304 | - if ( isset($atts['class']) ) { |
|
| 305 | - unset($atts['class']); |
|
| 306 | - } |
|
| 303 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 304 | + if ( isset($atts['class']) ) { |
|
| 305 | + unset($atts['class']); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $field['shortcodes'] = $atts; |
|
| 309 | - ob_start(); |
|
| 308 | + $field['shortcodes'] = $atts; |
|
| 309 | + ob_start(); |
|
| 310 | 310 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 311 | - $replace_with = ob_get_contents(); |
|
| 312 | - ob_end_clean(); |
|
| 313 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 314 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 315 | - } |
|
| 311 | + $replace_with = ob_get_contents(); |
|
| 312 | + ob_end_clean(); |
|
| 313 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 314 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 318 | - } |
|
| 317 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | if ( $form ) { |
| 321 | - $form = (array) $form; |
|
| 321 | + $form = (array) $form; |
|
| 322 | 322 | |
| 323 | - //replace [form_key] |
|
| 324 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 323 | + //replace [form_key] |
|
| 324 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 325 | 325 | |
| 326 | - //replace [form_name] |
|
| 327 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 328 | - } |
|
| 329 | - $html .= "\n"; |
|
| 326 | + //replace [form_name] |
|
| 327 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
| 328 | + } |
|
| 329 | + $html .= "\n"; |
|
| 330 | 330 | |
| 331 | - //Return html if conf_field to prevent loop |
|
| 332 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 333 | - return $html; |
|
| 334 | - } |
|
| 331 | + //Return html if conf_field to prevent loop |
|
| 332 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 333 | + return $html; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - //If field is in repeating section |
|
| 337 | - if ( $args['section_id'] ) { |
|
| 338 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 339 | - } else { |
|
| 340 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 341 | - } |
|
| 336 | + //If field is in repeating section |
|
| 337 | + if ( $args['section_id'] ) { |
|
| 338 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 339 | + } else { |
|
| 340 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | self::remove_collapse_shortcode( $html ); |
| 344 | 344 | |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | $html = do_shortcode( $html ); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return $html; |
|
| 350 | - } |
|
| 349 | + return $html; |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Add classes to a field div |
@@ -401,46 +401,46 @@ discard block |
||
| 401 | 401 | return $classes; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 405 | - if ( $no_vars ) { |
|
| 404 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 405 | + if ( $no_vars ) { |
|
| 406 | 406 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 407 | 407 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 408 | - } else { |
|
| 408 | + } else { |
|
| 409 | 409 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 410 | - } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 416 | 416 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 417 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 418 | - $args['conditional_check'] = true; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - $prefix = ''; |
|
| 422 | - if ( $args['conditional_check'] ) { |
|
| 423 | - if ( $args['conditional'] ) { |
|
| 424 | - $prefix = 'if '; |
|
| 425 | - } else if ( $args['foreach'] ) { |
|
| 426 | - $prefix = 'foreach '; |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 431 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 432 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 433 | - $tag = str_replace(']', '', $tag); |
|
| 434 | - $tags = explode(' ', $tag); |
|
| 435 | - if ( is_array($tags) ) { |
|
| 436 | - $tag = $tags[0]; |
|
| 437 | - } |
|
| 438 | - } else { |
|
| 439 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $tag; |
|
| 443 | - } |
|
| 417 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 418 | + $args['conditional_check'] = true; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + $prefix = ''; |
|
| 422 | + if ( $args['conditional_check'] ) { |
|
| 423 | + if ( $args['conditional'] ) { |
|
| 424 | + $prefix = 'if '; |
|
| 425 | + } else if ( $args['foreach'] ) { |
|
| 426 | + $prefix = 'foreach '; |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 431 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 432 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 433 | + $tag = str_replace(']', '', $tag); |
|
| 434 | + $tags = explode(' ', $tag); |
|
| 435 | + if ( is_array($tags) ) { |
|
| 436 | + $tag = $tags[0]; |
|
| 437 | + } |
|
| 438 | + } else { |
|
| 439 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $tag; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * Remove [collapse_this] if it's still included after all processing |
@@ -478,46 +478,46 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 480 | 480 | |
| 481 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 482 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 481 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 482 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 483 | 483 | |
| 484 | 484 | ?> |
| 485 | 485 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div> |
| 486 | 486 | <?php |
| 487 | - } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | 489 | public static function show_single_option( $field ) { |
| 490 | - $field_name = $field['name']; |
|
| 491 | - $html_id = self::get_html_id($field); |
|
| 492 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 493 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 494 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 490 | + $field_name = $field['name']; |
|
| 491 | + $html_id = self::get_html_id($field); |
|
| 492 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 493 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 494 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 495 | 495 | |
| 496 | - // If this is an "Other" option, get the HTML for it |
|
| 496 | + // If this is an "Other" option, get the HTML for it |
|
| 497 | 497 | if ( self::is_other_opt( $opt_key ) ) { |
| 498 | - // Get string for Other text field, if needed |
|
| 498 | + // Get string for Other text field, if needed |
|
| 499 | 499 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 500 | 500 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 501 | - } else { |
|
| 501 | + } else { |
|
| 502 | 502 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 503 | - } |
|
| 504 | - } |
|
| 505 | - } |
|
| 503 | + } |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | public static function get_term_link( $tax_id ) { |
| 508 | - $tax = get_taxonomy($tax_id); |
|
| 509 | - if ( ! $tax ) { |
|
| 510 | - return; |
|
| 511 | - } |
|
| 508 | + $tax = get_taxonomy($tax_id); |
|
| 509 | + if ( ! $tax ) { |
|
| 510 | + return; |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - $link = sprintf( |
|
| 514 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 513 | + $link = sprintf( |
|
| 514 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 515 | 515 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 516 | - ); |
|
| 517 | - unset($tax); |
|
| 516 | + ); |
|
| 517 | + unset($tax); |
|
| 518 | 518 | |
| 519 | - return $link; |
|
| 520 | - } |
|
| 519 | + return $link; |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | 522 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 523 | 523 | // Remove white space from hide_opt |
@@ -528,195 +528,195 @@ discard block |
||
| 528 | 528 | $observed_value = wp_kses_post( $observed_value ); |
| 529 | 529 | $hide_opt = wp_kses_post( $hide_opt ); |
| 530 | 530 | |
| 531 | - if ( is_array($observed_value) ) { |
|
| 532 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - $m = false; |
|
| 536 | - if ( $cond == '==' ) { |
|
| 537 | - $m = $observed_value == $hide_opt; |
|
| 538 | - } else if ( $cond == '!=' ) { |
|
| 539 | - $m = $observed_value != $hide_opt; |
|
| 540 | - } else if ( $cond == '>' ) { |
|
| 541 | - $m = $observed_value > $hide_opt; |
|
| 542 | - } else if ( $cond == '<' ) { |
|
| 543 | - $m = $observed_value < $hide_opt; |
|
| 544 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 545 | - $m = stripos($observed_value, $hide_opt); |
|
| 546 | - if ( $cond == 'not LIKE' ) { |
|
| 547 | - $m = ( $m === false ) ? true : false; |
|
| 548 | - } else { |
|
| 549 | - $m = ( $m === false ) ? false : true; |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - return $m; |
|
| 553 | - } |
|
| 531 | + if ( is_array($observed_value) ) { |
|
| 532 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + $m = false; |
|
| 536 | + if ( $cond == '==' ) { |
|
| 537 | + $m = $observed_value == $hide_opt; |
|
| 538 | + } else if ( $cond == '!=' ) { |
|
| 539 | + $m = $observed_value != $hide_opt; |
|
| 540 | + } else if ( $cond == '>' ) { |
|
| 541 | + $m = $observed_value > $hide_opt; |
|
| 542 | + } else if ( $cond == '<' ) { |
|
| 543 | + $m = $observed_value < $hide_opt; |
|
| 544 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 545 | + $m = stripos($observed_value, $hide_opt); |
|
| 546 | + if ( $cond == 'not LIKE' ) { |
|
| 547 | + $m = ( $m === false ) ? true : false; |
|
| 548 | + } else { |
|
| 549 | + $m = ( $m === false ) ? false : true; |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + return $m; |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | 555 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 556 | - $m = false; |
|
| 557 | - if ( $cond == '==' ) { |
|
| 558 | - if ( is_array($hide_opt) ) { |
|
| 559 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 560 | - $m = empty($m) ? false : true; |
|
| 561 | - } else { |
|
| 562 | - $m = in_array($hide_opt, $observed_value); |
|
| 563 | - } |
|
| 564 | - } else if ( $cond == '!=' ) { |
|
| 565 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 566 | - } else if ( $cond == '>' ) { |
|
| 567 | - $min = min($observed_value); |
|
| 568 | - $m = $min > $hide_opt; |
|
| 569 | - } else if ( $cond == '<' ) { |
|
| 570 | - $max = max($observed_value); |
|
| 571 | - $m = $max < $hide_opt; |
|
| 572 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 573 | - foreach ( $observed_value as $ob ) { |
|
| 574 | - $m = strpos($ob, $hide_opt); |
|
| 575 | - if ( $m !== false ) { |
|
| 576 | - $m = true; |
|
| 577 | - break; |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - if ( $cond == 'not LIKE' ) { |
|
| 582 | - $m = ( $m === false ) ? true : false; |
|
| 583 | - } |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - return $m; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Replace a few basic shortcodes and field ids |
|
| 591 | - * @since 2.0 |
|
| 592 | - * @return string |
|
| 593 | - */ |
|
| 556 | + $m = false; |
|
| 557 | + if ( $cond == '==' ) { |
|
| 558 | + if ( is_array($hide_opt) ) { |
|
| 559 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 560 | + $m = empty($m) ? false : true; |
|
| 561 | + } else { |
|
| 562 | + $m = in_array($hide_opt, $observed_value); |
|
| 563 | + } |
|
| 564 | + } else if ( $cond == '!=' ) { |
|
| 565 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 566 | + } else if ( $cond == '>' ) { |
|
| 567 | + $min = min($observed_value); |
|
| 568 | + $m = $min > $hide_opt; |
|
| 569 | + } else if ( $cond == '<' ) { |
|
| 570 | + $max = max($observed_value); |
|
| 571 | + $m = $max < $hide_opt; |
|
| 572 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 573 | + foreach ( $observed_value as $ob ) { |
|
| 574 | + $m = strpos($ob, $hide_opt); |
|
| 575 | + if ( $m !== false ) { |
|
| 576 | + $m = true; |
|
| 577 | + break; |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + if ( $cond == 'not LIKE' ) { |
|
| 582 | + $m = ( $m === false ) ? true : false; |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + return $m; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Replace a few basic shortcodes and field ids |
|
| 591 | + * @since 2.0 |
|
| 592 | + * @return string |
|
| 593 | + */ |
|
| 594 | 594 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 595 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 596 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 597 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 598 | - } |
|
| 595 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 596 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 597 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 601 | - $value = do_shortcode($value); |
|
| 600 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 601 | + $value = do_shortcode($value); |
|
| 602 | 602 | |
| 603 | - return $value; |
|
| 604 | - } |
|
| 603 | + return $value; |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | 606 | public static function get_shortcodes( $content, $form_id ) { |
| 607 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 608 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 609 | - } |
|
| 607 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 608 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 611 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 612 | 612 | |
| 613 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 613 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 614 | 614 | |
| 615 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 615 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 616 | 616 | |
| 617 | - return $matches; |
|
| 618 | - } |
|
| 617 | + return $matches; |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | 620 | public static function allowed_shortcodes( $fields = array() ) { |
| 621 | - $tagregexp = array( |
|
| 622 | - 'editlink', 'id', 'key', 'ip', |
|
| 623 | - 'siteurl', 'sitename', 'admin_email', |
|
| 624 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 621 | + $tagregexp = array( |
|
| 622 | + 'editlink', 'id', 'key', 'ip', |
|
| 623 | + 'siteurl', 'sitename', 'admin_email', |
|
| 624 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 625 | 625 | 'parent[-|_]id', |
| 626 | - ); |
|
| 626 | + ); |
|
| 627 | 627 | |
| 628 | - foreach ( $fields as $field ) { |
|
| 629 | - $tagregexp[] = $field->id; |
|
| 630 | - $tagregexp[] = $field->field_key; |
|
| 631 | - } |
|
| 628 | + foreach ( $fields as $field ) { |
|
| 629 | + $tagregexp[] = $field->id; |
|
| 630 | + $tagregexp[] = $field->field_key; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | - $tagregexp = implode('|', $tagregexp); |
|
| 634 | - return $tagregexp; |
|
| 635 | - } |
|
| 633 | + $tagregexp = implode('|', $tagregexp); |
|
| 634 | + return $tagregexp; |
|
| 635 | + } |
|
| 636 | 636 | |
| 637 | 637 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 638 | - $shortcode_values = array( |
|
| 639 | - 'id' => $entry->id, |
|
| 640 | - 'key' => $entry->item_key, |
|
| 641 | - 'ip' => $entry->ip, |
|
| 642 | - ); |
|
| 638 | + $shortcode_values = array( |
|
| 639 | + 'id' => $entry->id, |
|
| 640 | + 'key' => $entry->item_key, |
|
| 641 | + 'ip' => $entry->ip, |
|
| 642 | + ); |
|
| 643 | 643 | |
| 644 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 645 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 644 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 645 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 646 | 646 | |
| 647 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 647 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 648 | 648 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 649 | - $tags = explode(' ', $tag); |
|
| 650 | - if ( is_array($tags) ) { |
|
| 651 | - $tag = $tags[0]; |
|
| 652 | - } |
|
| 653 | - } else { |
|
| 654 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - switch ( $tag ) { |
|
| 658 | - case 'id': |
|
| 659 | - case 'key': |
|
| 660 | - case 'ip': |
|
| 661 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 662 | - break; |
|
| 663 | - |
|
| 664 | - case 'user_agent': |
|
| 665 | - case 'user-agent': |
|
| 666 | - $entry->description = maybe_unserialize($entry->description); |
|
| 649 | + $tags = explode(' ', $tag); |
|
| 650 | + if ( is_array($tags) ) { |
|
| 651 | + $tag = $tags[0]; |
|
| 652 | + } |
|
| 653 | + } else { |
|
| 654 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + switch ( $tag ) { |
|
| 658 | + case 'id': |
|
| 659 | + case 'key': |
|
| 660 | + case 'ip': |
|
| 661 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 662 | + break; |
|
| 663 | + |
|
| 664 | + case 'user_agent': |
|
| 665 | + case 'user-agent': |
|
| 666 | + $entry->description = maybe_unserialize($entry->description); |
|
| 667 | 667 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 668 | - break; |
|
| 669 | - |
|
| 670 | - case 'created_at': |
|
| 671 | - case 'created-at': |
|
| 672 | - case 'updated_at': |
|
| 673 | - case 'updated-at': |
|
| 674 | - if ( isset($atts['format']) ) { |
|
| 675 | - $time_format = ' '; |
|
| 676 | - } else { |
|
| 677 | - $atts['format'] = get_option('date_format'); |
|
| 678 | - $time_format = ''; |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - $this_tag = str_replace('-', '_', $tag); |
|
| 682 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 683 | - unset($this_tag); |
|
| 684 | - break; |
|
| 685 | - |
|
| 686 | - case 'created_by': |
|
| 687 | - case 'created-by': |
|
| 688 | - case 'updated_by': |
|
| 689 | - case 'updated-by': |
|
| 690 | - $this_tag = str_replace('-', '_', $tag); |
|
| 668 | + break; |
|
| 669 | + |
|
| 670 | + case 'created_at': |
|
| 671 | + case 'created-at': |
|
| 672 | + case 'updated_at': |
|
| 673 | + case 'updated-at': |
|
| 674 | + if ( isset($atts['format']) ) { |
|
| 675 | + $time_format = ' '; |
|
| 676 | + } else { |
|
| 677 | + $atts['format'] = get_option('date_format'); |
|
| 678 | + $time_format = ''; |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + $this_tag = str_replace('-', '_', $tag); |
|
| 682 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 683 | + unset($this_tag); |
|
| 684 | + break; |
|
| 685 | + |
|
| 686 | + case 'created_by': |
|
| 687 | + case 'created-by': |
|
| 688 | + case 'updated_by': |
|
| 689 | + case 'updated-by': |
|
| 690 | + $this_tag = str_replace('-', '_', $tag); |
|
| 691 | 691 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 692 | - unset($this_tag); |
|
| 693 | - break; |
|
| 694 | - |
|
| 695 | - case 'admin_email': |
|
| 696 | - case 'siteurl': |
|
| 697 | - case 'frmurl': |
|
| 698 | - case 'sitename': |
|
| 699 | - case 'get': |
|
| 700 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 701 | - break; |
|
| 702 | - |
|
| 703 | - default: |
|
| 704 | - $field = FrmField::getOne( $tag ); |
|
| 705 | - if ( ! $field ) { |
|
| 706 | - break; |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 710 | - |
|
| 711 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 712 | - |
|
| 713 | - $atts['entry_id'] = $entry->id; |
|
| 714 | - $atts['entry_key'] = $entry->item_key; |
|
| 715 | - |
|
| 716 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 717 | - $replace_with = $field->name; |
|
| 718 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 719 | - $replace_with = $field->description; |
|
| 692 | + unset($this_tag); |
|
| 693 | + break; |
|
| 694 | + |
|
| 695 | + case 'admin_email': |
|
| 696 | + case 'siteurl': |
|
| 697 | + case 'frmurl': |
|
| 698 | + case 'sitename': |
|
| 699 | + case 'get': |
|
| 700 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 701 | + break; |
|
| 702 | + |
|
| 703 | + default: |
|
| 704 | + $field = FrmField::getOne( $tag ); |
|
| 705 | + if ( ! $field ) { |
|
| 706 | + break; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 710 | + |
|
| 711 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 712 | + |
|
| 713 | + $atts['entry_id'] = $entry->id; |
|
| 714 | + $atts['entry_key'] = $entry->item_key; |
|
| 715 | + |
|
| 716 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 717 | + $replace_with = $field->name; |
|
| 718 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 719 | + $replace_with = $field->description; |
|
| 720 | 720 | } else { |
| 721 | 721 | $string_value = $replace_with; |
| 722 | 722 | if ( is_array( $replace_with ) ) { |
@@ -730,82 +730,82 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - unset($field); |
|
| 734 | - break; |
|
| 735 | - } |
|
| 733 | + unset($field); |
|
| 734 | + break; |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | - if ( isset($replace_with) ) { |
|
| 738 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 739 | - } |
|
| 737 | + if ( isset($replace_with) ) { |
|
| 738 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - unset($atts, $conditional, $replace_with); |
|
| 741 | + unset($atts, $conditional, $replace_with); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | return $content; |
| 745 | - } |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * Get the value to replace a few standard shortcodes |
|
| 749 | - * |
|
| 750 | - * @since 2.0 |
|
| 751 | - * @return string |
|
| 752 | - */ |
|
| 753 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 754 | - $new_value = ''; |
|
| 755 | - switch ( $tag ) { |
|
| 756 | - case 'admin_email': |
|
| 757 | - $new_value = get_option('admin_email'); |
|
| 758 | - break; |
|
| 759 | - case 'siteurl': |
|
| 760 | - $new_value = FrmAppHelper::site_url(); |
|
| 761 | - break; |
|
| 762 | - case 'frmurl': |
|
| 763 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 764 | - break; |
|
| 765 | - case 'sitename': |
|
| 766 | - $new_value = FrmAppHelper::site_name(); |
|
| 767 | - break; |
|
| 768 | - case 'get': |
|
| 769 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 770 | - break; |
|
| 771 | - } |
|
| 772 | - |
|
| 773 | - return $new_value; |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * Process the [get] shortcode |
|
| 778 | - * |
|
| 779 | - * @since 2.0 |
|
| 780 | - * @return string|array |
|
| 781 | - */ |
|
| 782 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 783 | - if ( ! isset($atts['param']) ) { |
|
| 784 | - return ''; |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - if ( strpos($atts['param'], '[') ) { |
|
| 788 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 789 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 790 | - } |
|
| 791 | - |
|
| 792 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 793 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 794 | - |
|
| 795 | - if ( $new_value == '' ) { |
|
| 796 | - if ( ! isset($atts['prev_val']) ) { |
|
| 797 | - $atts['prev_val'] = ''; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 804 | - $new_value = implode(', ', $new_value); |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - return $new_value; |
|
| 808 | - } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * Get the value to replace a few standard shortcodes |
|
| 749 | + * |
|
| 750 | + * @since 2.0 |
|
| 751 | + * @return string |
|
| 752 | + */ |
|
| 753 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 754 | + $new_value = ''; |
|
| 755 | + switch ( $tag ) { |
|
| 756 | + case 'admin_email': |
|
| 757 | + $new_value = get_option('admin_email'); |
|
| 758 | + break; |
|
| 759 | + case 'siteurl': |
|
| 760 | + $new_value = FrmAppHelper::site_url(); |
|
| 761 | + break; |
|
| 762 | + case 'frmurl': |
|
| 763 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 764 | + break; |
|
| 765 | + case 'sitename': |
|
| 766 | + $new_value = FrmAppHelper::site_name(); |
|
| 767 | + break; |
|
| 768 | + case 'get': |
|
| 769 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 770 | + break; |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + return $new_value; |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Process the [get] shortcode |
|
| 778 | + * |
|
| 779 | + * @since 2.0 |
|
| 780 | + * @return string|array |
|
| 781 | + */ |
|
| 782 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 783 | + if ( ! isset($atts['param']) ) { |
|
| 784 | + return ''; |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + if ( strpos($atts['param'], '[') ) { |
|
| 788 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 789 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 790 | + } |
|
| 791 | + |
|
| 792 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 793 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 794 | + |
|
| 795 | + if ( $new_value == '' ) { |
|
| 796 | + if ( ! isset($atts['prev_val']) ) { |
|
| 797 | + $atts['prev_val'] = ''; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 804 | + $new_value = implode(', ', $new_value); |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + return $new_value; |
|
| 808 | + } |
|
| 809 | 809 | |
| 810 | 810 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 811 | 811 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 814 | 814 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 815 | 815 | |
| 816 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 817 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 818 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 819 | - if ( is_array($replace_with) ) { |
|
| 820 | - $replace_with = implode("\n", $replace_with); |
|
| 821 | - } |
|
| 822 | - $replace_with = wpautop($replace_with); |
|
| 823 | - } |
|
| 816 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 817 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 818 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 819 | + if ( is_array($replace_with) ) { |
|
| 820 | + $replace_with = implode("\n", $replace_with); |
|
| 821 | + } |
|
| 822 | + $replace_with = wpautop($replace_with); |
|
| 823 | + } |
|
| 824 | 824 | unset( $autop ); |
| 825 | 825 | } else if ( is_array( $replace_with ) ) { |
| 826 | 826 | $replace_with = implode( $sep, $replace_with ); |
@@ -830,58 +830,58 @@ discard block |
||
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | public static function get_field_types( $type ) { |
| 833 | - $single_input = array( |
|
| 834 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 835 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 836 | - 'user_id', 'tag', 'password', |
|
| 837 | - ); |
|
| 833 | + $single_input = array( |
|
| 834 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 835 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 836 | + 'user_id', 'tag', 'password', |
|
| 837 | + ); |
|
| 838 | 838 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 839 | 839 | $other_type = array( 'html', 'break' ); |
| 840 | 840 | |
| 841 | 841 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 842 | 842 | |
| 843 | - $field_types = array(); |
|
| 844 | - if ( in_array($type, $single_input) ) { |
|
| 845 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 846 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 847 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 848 | - } else if ( in_array($type, $other_type) ) { |
|
| 849 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 843 | + $field_types = array(); |
|
| 844 | + if ( in_array($type, $single_input) ) { |
|
| 845 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 846 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 847 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 848 | + } else if ( in_array($type, $other_type) ) { |
|
| 849 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 850 | 850 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 851 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 852 | - } |
|
| 851 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | 854 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 855 | - return $field_types; |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 859 | - foreach ( $inputs as $input ) { |
|
| 860 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 861 | - unset($input); |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * Check if current field option is an "other" option |
|
| 867 | - * |
|
| 868 | - * @since 2.0.6 |
|
| 869 | - * |
|
| 870 | - * @param string $opt_key |
|
| 871 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 872 | - */ |
|
| 873 | - public static function is_other_opt( $opt_key ) { |
|
| 874 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 875 | - } |
|
| 876 | - |
|
| 877 | - /** |
|
| 878 | - * Get value that belongs in "Other" text box |
|
| 879 | - * |
|
| 880 | - * @since 2.0.6 |
|
| 881 | - * |
|
| 882 | - * @param array $args |
|
| 883 | - */ |
|
| 884 | - public static function get_other_val( $args ) { |
|
| 855 | + return $field_types; |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 859 | + foreach ( $inputs as $input ) { |
|
| 860 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 861 | + unset($input); |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * Check if current field option is an "other" option |
|
| 867 | + * |
|
| 868 | + * @since 2.0.6 |
|
| 869 | + * |
|
| 870 | + * @param string $opt_key |
|
| 871 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 872 | + */ |
|
| 873 | + public static function is_other_opt( $opt_key ) { |
|
| 874 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 875 | + } |
|
| 876 | + |
|
| 877 | + /** |
|
| 878 | + * Get value that belongs in "Other" text box |
|
| 879 | + * |
|
| 880 | + * @since 2.0.6 |
|
| 881 | + * |
|
| 882 | + * @param array $args |
|
| 883 | + */ |
|
| 884 | + public static function get_other_val( $args ) { |
|
| 885 | 885 | $defaults = array( |
| 886 | 886 | 'opt_key' => 0, 'field' => array(), |
| 887 | 887 | 'parent' => false, 'pointer' => false, |
@@ -957,20 +957,20 @@ discard block |
||
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | return $other_val; |
| 960 | - } |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 964 | - * Intended for front-end use |
|
| 965 | - * |
|
| 966 | - * @since 2.0.6 |
|
| 967 | - * |
|
| 968 | - * @param array $args should include field, opt_key and field name |
|
| 969 | - * @param boolean $other_opt |
|
| 970 | - * @param string $checked |
|
| 971 | - * @return string $other_val |
|
| 972 | - */ |
|
| 973 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 960 | + } |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 964 | + * Intended for front-end use |
|
| 965 | + * |
|
| 966 | + * @since 2.0.6 |
|
| 967 | + * |
|
| 968 | + * @param array $args should include field, opt_key and field name |
|
| 969 | + * @param boolean $other_opt |
|
| 970 | + * @param string $checked |
|
| 971 | + * @return string $other_val |
|
| 972 | + */ |
|
| 973 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 974 | 974 | //Check if this is an "Other" option |
| 975 | 975 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 976 | 976 | return; |
@@ -986,8 +986,8 @@ discard block |
||
| 986 | 986 | $checked = 'checked="checked" '; |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | - return $other_args; |
|
| 990 | - } |
|
| 989 | + return $other_args; |
|
| 990 | + } |
|
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | 993 | * @param array $args |
@@ -1036,8 +1036,8 @@ discard block |
||
| 1036 | 1036 | * @since 2.0.6 |
| 1037 | 1037 | */ |
| 1038 | 1038 | public static function include_other_input( $args ) { |
| 1039 | - if ( ! $args['other_opt'] ) { |
|
| 1040 | - return; |
|
| 1039 | + if ( ! $args['other_opt'] ) { |
|
| 1040 | + return; |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | $classes = array( 'frm_other_input' ); |
@@ -1058,15 +1058,15 @@ discard block |
||
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /** |
| 1061 | - * Get the HTML id for an "Other" text field |
|
| 1062 | - * Note: This does not affect fields in repeating sections |
|
| 1063 | - * |
|
| 1064 | - * @since 2.0.08 |
|
| 1065 | - * @param string $type - field type |
|
| 1066 | - * @param string $html_id |
|
| 1067 | - * @param string|boolean $opt_key |
|
| 1068 | - * @return string $other_id |
|
| 1069 | - */ |
|
| 1061 | + * Get the HTML id for an "Other" text field |
|
| 1062 | + * Note: This does not affect fields in repeating sections |
|
| 1063 | + * |
|
| 1064 | + * @since 2.0.08 |
|
| 1065 | + * @param string $type - field type |
|
| 1066 | + * @param string $html_id |
|
| 1067 | + * @param string|boolean $opt_key |
|
| 1068 | + * @return string $other_id |
|
| 1069 | + */ |
|
| 1070 | 1070 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1071 | 1071 | $other_id = $html_id; |
| 1072 | 1072 | |
@@ -1124,10 +1124,10 @@ discard block |
||
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | public static function switch_field_ids( $val ) { |
| 1127 | - global $frm_duplicate_ids; |
|
| 1128 | - $replace = array(); |
|
| 1129 | - $replace_with = array(); |
|
| 1130 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1127 | + global $frm_duplicate_ids; |
|
| 1128 | + $replace = array(); |
|
| 1129 | + $replace_with = array(); |
|
| 1130 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1131 | 1131 | $replace[] = '[if ' . $old . ']'; |
| 1132 | 1132 | $replace_with[] = '[if ' . $new . ']'; |
| 1133 | 1133 | $replace[] = '[if ' . $old . ' '; |
@@ -1142,153 +1142,153 @@ discard block |
||
| 1142 | 1142 | $replace_with[] = '[' . $new . ']'; |
| 1143 | 1143 | $replace[] = '[' . $old . ' '; |
| 1144 | 1144 | $replace_with[] = '[' . $new . ' '; |
| 1145 | - unset($old, $new); |
|
| 1146 | - } |
|
| 1145 | + unset($old, $new); |
|
| 1146 | + } |
|
| 1147 | 1147 | if ( is_array( $val ) ) { |
| 1148 | 1148 | foreach ( $val as $k => $v ) { |
| 1149 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1150 | - unset($k, $v); |
|
| 1151 | - } |
|
| 1152 | - } else { |
|
| 1153 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - return $val; |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - public static function get_us_states() { |
|
| 1160 | - return apply_filters( 'frm_us_states', array( |
|
| 1161 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1162 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1163 | - 'DC' => 'District of Columbia', |
|
| 1164 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1165 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1166 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1167 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1168 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1169 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1170 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1171 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1172 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1173 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1174 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1175 | - ) ); |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - public static function get_countries() { |
|
| 1179 | - return apply_filters( 'frm_countries', array( |
|
| 1180 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1181 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1182 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1183 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1184 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1185 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1186 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1187 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1188 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1189 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1190 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1191 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1192 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1193 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1194 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1195 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1196 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1197 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1198 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1199 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1200 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1201 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1202 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1203 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1204 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1205 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1206 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1207 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1208 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1209 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1210 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1211 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1212 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1213 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1214 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1215 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1216 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1217 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1218 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1219 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1220 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1221 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1222 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1223 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1224 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1225 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1226 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1227 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1228 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1229 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1230 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1231 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1232 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1233 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1234 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1235 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1236 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1237 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1238 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1239 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1240 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1241 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1242 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1243 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1244 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1245 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1246 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1247 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1248 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1249 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1250 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1251 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1252 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1253 | - ) ); |
|
| 1254 | - } |
|
| 1149 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1150 | + unset($k, $v); |
|
| 1151 | + } |
|
| 1152 | + } else { |
|
| 1153 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + return $val; |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + public static function get_us_states() { |
|
| 1160 | + return apply_filters( 'frm_us_states', array( |
|
| 1161 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1162 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1163 | + 'DC' => 'District of Columbia', |
|
| 1164 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1165 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1166 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1167 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1168 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1169 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1170 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1171 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1172 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1173 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1174 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1175 | + ) ); |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + public static function get_countries() { |
|
| 1179 | + return apply_filters( 'frm_countries', array( |
|
| 1180 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1181 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1182 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1183 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1184 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1185 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1186 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1187 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1188 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1189 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1190 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1191 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1192 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1193 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1194 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1195 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1196 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1197 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1198 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1199 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1200 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1201 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1202 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1203 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1204 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1205 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1206 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1207 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1208 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1209 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1210 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1211 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1212 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1213 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1214 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1215 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1216 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1217 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1218 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1219 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1220 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1221 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1222 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1223 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1224 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1225 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1226 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1227 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1228 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1229 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1230 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1231 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1232 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1233 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1234 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1235 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1236 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1237 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1238 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1239 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1240 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1241 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1242 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1243 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1244 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1245 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1246 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1247 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1248 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1249 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1250 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1251 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1252 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1253 | + ) ); |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | 1256 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1257 | 1257 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1258 | 1258 | |
| 1259 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1260 | - $state_abv = array_keys($states); |
|
| 1261 | - sort($state_abv); |
|
| 1259 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1260 | + $state_abv = array_keys($states); |
|
| 1261 | + sort($state_abv); |
|
| 1262 | 1262 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1263 | 1263 | |
| 1264 | - $states = array_values($states); |
|
| 1265 | - sort($states); |
|
| 1264 | + $states = array_values($states); |
|
| 1265 | + sort($states); |
|
| 1266 | 1266 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1267 | - unset($state_abv, $states); |
|
| 1267 | + unset($state_abv, $states); |
|
| 1268 | 1268 | |
| 1269 | 1269 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1270 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1271 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1272 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1273 | - ); |
|
| 1270 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1271 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1272 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1273 | + ); |
|
| 1274 | 1274 | |
| 1275 | 1275 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1276 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1277 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1278 | - ); |
|
| 1276 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1277 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1278 | + ); |
|
| 1279 | 1279 | |
| 1280 | 1280 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1281 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1282 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1283 | - ); |
|
| 1281 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1282 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1283 | + ); |
|
| 1284 | 1284 | |
| 1285 | 1285 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1286 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1287 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1288 | - ); |
|
| 1286 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1287 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1288 | + ); |
|
| 1289 | 1289 | |
| 1290 | 1290 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1291 | - } |
|
| 1291 | + } |
|
| 1292 | 1292 | |
| 1293 | 1293 | public static function field_selection() { |
| 1294 | 1294 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1325,10 +1325,10 @@ discard block |
||
| 1325 | 1325 | return FrmField::is_required( $field ); |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | - public static function maybe_get_field( &$field ) { |
|
| 1328 | + public static function maybe_get_field( &$field ) { |
|
| 1329 | 1329 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1330 | 1330 | FrmField::maybe_get_field( $field ); |
| 1331 | - } |
|
| 1331 | + } |
|
| 1332 | 1332 | |
| 1333 | 1333 | public static function dropdown_categories( $args ) { |
| 1334 | 1334 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |