| @@ -11,11 +11,18 @@ | ||
| 11 | 11 | |
| 12 | 12 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | + /** | |
| 16 | + * Include license box template on demand. | |
| 17 | + * | |
| 18 | + * @return void | |
| 19 | + */ | |
| 15 | 20 | public static function license_box() { |
| 16 | - $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 17 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); | |
| 21 | + if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 22 | + return; | |
| 23 | + } | |
| 24 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php'; | |
| 18 | 25 | } |
| 19 | 26 | |
| 20 | 27 | public static function display_form( $errors = array(), $message = '' ) { |
| 21 | 28 | global $frm_vars; |
| @@ -27,9 +34,9 @@ | ||
| 27 | 34 | |
| 28 | 35 | $sections = self::get_settings_tabs(); |
| 29 | 36 | $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
| 30 | 37 | |
| 31 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); | |
| 38 | + require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php'; | |
| 32 | 39 | } |
| 33 | 40 | |
| 34 | 41 | /** |
| 35 | 42 | * Get sections to use for Global Settings. |
| @@ -37,27 +44,27 @@ | ||
| 37 | 44 | * @return array<array> |
| 38 | 45 | */ |
| 39 | 46 | private static function get_settings_tabs() { |
| 40 | 47 | $sections = array( |
| 41 | - 'general' => array( | |
| 48 | + 'general' => array( | |
| 42 | 49 | 'class' => __CLASS__, |
| 43 | 50 | 'function' => 'general_settings', |
| 44 | 51 | 'name' => __( 'General Settings', 'formidable' ), |
| 45 | 52 | 'icon' => 'frm_icon_font frm_settings_icon', |
| 46 | 53 | ), |
| 47 | - 'messages' => array( | |
| 54 | + 'messages' => array( | |
| 48 | 55 | 'class' => __CLASS__, |
| 49 | 56 | 'function' => 'message_settings', |
| 50 | 57 | 'name' => __( 'Message Defaults', 'formidable' ), |
| 51 | 58 | 'icon' => 'frm_icon_font frm_stamp_icon', |
| 52 | 59 | ), |
| 53 | - 'permissions' => array( | |
| 60 | + 'permissions' => array( | |
| 54 | 61 | 'class' => __CLASS__, |
| 55 | 62 | 'function' => 'permission_settings', |
| 56 | 63 | 'name' => __( 'Permissions', 'formidable' ), |
| 57 | 64 | 'icon' => 'frm_icon_font frm_lock_icon', |
| 58 | 65 | ), |
| 59 | - 'custom_css' => array( | |
| 66 | + 'custom_css' => array( | |
| 60 | 67 | 'class' => 'FrmStylesController', |
| 61 | 68 | 'function' => 'custom_css', |
| 62 | 69 | 'name' => __( 'Custom CSS', 'formidable' ), |
| 63 | 70 | 'icon' => 'frm_icon_font frm_code_icon', |
| @@ -67,15 +74,15 @@ | ||
| 67 | 74 | 'function' => 'manage', |
| 68 | 75 | 'name' => __( 'Manage Styles', 'formidable' ), |
| 69 | 76 | 'icon' => 'frm_icon_font frm_pallet_icon', |
| 70 | 77 | ), |
| 71 | - 'captcha' => array( | |
| 78 | + 'captcha' => array( | |
| 72 | 79 | 'class' => __CLASS__, |
| 73 | 80 | 'function' => 'captcha_settings', |
| 74 | - 'name' => __( 'Captcha', 'formidable' ), | |
| 81 | + 'name' => __( 'Captcha/Spam', 'formidable' ), | |
| 75 | 82 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 76 | 83 | ), |
| 77 | - 'white_label' => array( | |
| 84 | + 'white_label' => array( | |
| 78 | 85 | 'name' => __( 'White Labeling', 'formidable' ), |
| 79 | 86 | 'icon' => 'frm_icon_font frm_ghost_icon', |
| 80 | 87 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 81 | 88 | 'data' => array( |
| @@ -83,9 +90,9 @@ | ||
| 83 | 90 | 'upgrade' => __( 'White labeling options', 'formidable' ), |
| 84 | 91 | 'screenshot' => 'white-label.png', |
| 85 | 92 | ), |
| 86 | 93 | ), |
| 87 | - 'inbox' => array( | |
| 94 | + 'inbox' => array( | |
| 88 | 95 | 'name' => __( 'Inbox', 'formidable' ), |
| 89 | 96 | 'icon' => 'frm_icon_font frm_email_icon', |
| 90 | 97 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 91 | 98 | 'data' => array( |
| @@ -111,13 +118,13 @@ | ||
| 111 | 118 | $sections['licenses'] = array( |
| 112 | 119 | 'class' => 'FrmAddonsController', |
| 113 | 120 | 'function' => 'license_settings', |
| 114 | 121 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 115 | - 'icon' => 'frm_icon_font frm_keyalt_icon', | |
| 122 | + 'icon' => 'frmfont frm_key_icon', | |
| 116 | 123 | 'ajax' => true, |
| 117 | 124 | ); |
| 118 | 125 | } |
| 119 | - } | |
| 126 | + }//end if | |
| 120 | 127 | |
| 121 | 128 | /** |
| 122 | 129 | * @param array<array> $sections |
| 123 | 130 | */ |
| @@ -151,9 +158,9 @@ | ||
| 151 | 158 | $section['function'] = $original; |
| 152 | 159 | } |
| 153 | 160 | |
| 154 | 161 | $sections[ $key ] = $section; |
| 155 | - } | |
| 162 | + }//end foreach | |
| 156 | 163 | |
| 157 | 164 | return $sections; |
| 158 | 165 | } |
| 159 | 166 | |
| @@ -177,17 +184,37 @@ | ||
| 177 | 184 | wp_die(); |
| 178 | 185 | } |
| 179 | 186 | |
| 180 | 187 | /** |
| 188 | + * Render the general global settings section. | |
| 189 | + * | |
| 181 | 190 | * @since 4.0 |
| 191 | + * | |
| 192 | + * @return void | |
| 182 | 193 | */ |
| 183 | 194 | public static function general_settings() { |
| 184 | 195 | $frm_settings = FrmAppHelper::get_settings(); |
| 196 | + $uploads = wp_upload_dir(); | |
| 197 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 185 | 198 | |
| 186 | - $uploads = wp_upload_dir(); | |
| 187 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 199 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php'; | |
| 200 | + } | |
| 188 | 201 | |
| 189 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' ); | |
| 202 | + /** | |
| 203 | + * Render the global currency selector if Pro is up to date. | |
| 204 | + * | |
| 205 | + * @param FrmSettings $frm_settings | |
| 206 | + * @param string $more_html | |
| 207 | + * @return void | |
| 208 | + */ | |
| 209 | + public static function maybe_render_currency_selector( $frm_settings, $more_html ) { | |
| 210 | + if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) { | |
| 211 | + FrmProSettingsController::add_currency_settings(); | |
| 212 | + return; | |
| 213 | + } | |
| 214 | + | |
| 215 | + $currencies = FrmCurrencyHelper::get_currencies(); | |
| 216 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php'; | |
| 190 | 217 | } |
| 191 | 218 | |
| 192 | 219 | /** |
| 193 | 220 | * @since 4.0 |
| @@ -194,9 +221,9 @@ | ||
| 194 | 221 | */ |
| 195 | 222 | public static function message_settings() { |
| 196 | 223 | $frm_settings = FrmAppHelper::get_settings(); |
| 197 | 224 | |
| 198 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' ); | |
| 225 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php'; | |
| 199 | 226 | } |
| 200 | 227 | |
| 201 | 228 | /** |
| 202 | 229 | * @since 4.0 |
| @@ -204,9 +231,9 @@ | ||
| 204 | 231 | public static function captcha_settings() { |
| 205 | 232 | $frm_settings = FrmAppHelper::get_settings(); |
| 206 | 233 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| 207 | 234 | |
| 208 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' ); | |
| 235 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php'; | |
| 209 | 236 | } |
| 210 | 237 | |
| 211 | 238 | /** |
| 212 | 239 | * @since 4.0 |
| @@ -214,9 +241,9 @@ | ||
| 214 | 241 | public static function permission_settings() { |
| 215 | 242 | $frm_settings = FrmAppHelper::get_settings(); |
| 216 | 243 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 217 | 244 | |
| 218 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' ); | |
| 245 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php'; | |
| 219 | 246 | } |
| 220 | 247 | |
| 221 | 248 | /** |
| 222 | 249 | * @since 4.0 |
| @@ -223,15 +250,15 @@ | ||
| 223 | 250 | */ |
| 224 | 251 | public static function misc_settings() { |
| 225 | 252 | $frm_settings = FrmAppHelper::get_settings(); |
| 226 | 253 | |
| 227 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); | |
| 254 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php'; | |
| 228 | 255 | } |
| 229 | 256 | |
| 230 | 257 | /** |
| 231 | 258 | * Save form data submitted from the Global settings page. |
| 232 | 259 | * |
| 233 | - * @param string|bool $stop_load | |
| 260 | + * @param bool|string $stop_load | |
| 234 | 261 | * |
| 235 | 262 | * @return void |
| 236 | 263 | */ |
| 237 | 264 | public static function process_form( $stop_load = false ) { |
| @@ -240,9 +267,15 @@ | ||
| 240 | 267 | $frm_settings = FrmAppHelper::get_settings(); |
| 241 | 268 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 242 | 269 | |
| 243 | 270 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 244 | - wp_die( esc_html( $frm_settings->admin_permission ) ); | |
| 271 | + $error_args = array( | |
| 272 | + 'title' => __( 'Verification failed', 'formidable' ), | |
| 273 | + 'body' => $frm_settings->admin_permission, | |
| 274 | + 'cancel_text' => __( 'Cancel', 'formidable' ), | |
| 275 | + ); | |
| 276 | + FrmAppController::show_error_modal( $error_args ); | |
| 277 | + return; | |
| 245 | 278 | } |
| 246 | 279 | |
| 247 | 280 | $errors = array(); |
| 248 | 281 | $message = ''; |
| @@ -282,9 +315,9 @@ | ||
| 282 | 315 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 283 | 316 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 284 | 317 | FrmAppHelper::include_svg(); |
| 285 | 318 | |
| 286 | - if ( $action == 'process-form' ) { | |
| 319 | + if ( $action === 'process-form' ) { | |
| 287 | 320 | self::process_form( $stop_load ); |
| 288 | 321 | } elseif ( $stop_load != 'stop_load' ) { |
| 289 | 322 | self::display_form(); |
| 290 | 323 | } |
| @@ -295,32 +328,13 @@ | ||
| 295 | 328 | * |
| 296 | 329 | * @since 3.04.02 |
| 297 | 330 | */ |
| 298 | 331 | public static function settings_cta( $view ) { |
| 299 | - | |
| 300 | 332 | if ( get_option( 'frm_lite_settings_upgrade', false ) ) { |
| 301 | 333 | return; |
| 302 | 334 | } |
| 303 | 335 | |
| 304 | - $features = array( | |
| 305 | - __( 'Extra form features like file uploads, pagination, etc', 'formidable' ), | |
| 306 | - __( 'Repeaters & cascading fields for advanced forms', 'formidable' ), | |
| 307 | - __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ), | |
| 308 | - __( 'Display entries with virtually limitless Formidable views', 'formidable' ), | |
| 309 | - __( 'Create surveys & polls', 'formidable' ), | |
| 310 | - __( 'WordPress user registration and login forms', 'formidable' ), | |
| 311 | - __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ), | |
| 312 | - __( 'Powerful conditional logic for smart forms', 'formidable' ), | |
| 313 | - __( 'Integrations with 1000+ marketing & payment services', 'formidable' ), | |
| 314 | - __( 'Collect digital signatures', 'formidable' ), | |
| 315 | - __( 'Accept user-submitted content with Post submissions', 'formidable' ), | |
| 316 | - __( 'Email routing', 'formidable' ), | |
| 317 | - __( 'Create calculator forms', 'formidable' ), | |
| 318 | - __( 'Save draft entries and return later', 'formidable' ), | |
| 319 | - __( 'Analyze form data with graphs & stats', 'formidable' ), | |
| 320 | - ); | |
| 321 | - | |
| 322 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' ); | |
| 336 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php'; | |
| 323 | 337 | } |
| 324 | 338 | |
| 325 | 339 | /** |
| 326 | 340 | * Dismiss upgrade notice at the bottom on the plugin settings pages. |
| @@ -327,8 +341,9 @@ | ||
| 327 | 341 | * |
| 328 | 342 | * @since 3.04.02 |
| 329 | 343 | */ |
| 330 | 344 | public static function settings_cta_dismiss() { |
| 345 | + check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 331 | 346 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 332 | 347 | |
| 333 | 348 | update_option( 'frm_lite_settings_upgrade', time(), 'no' ); |
| 334 | 349 | |
| @@ -345,9 +360,9 @@ | ||
| 345 | 360 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 346 | 361 | |
| 347 | 362 | global $wpdb; |
| 348 | 363 | |
| 349 | - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 364 | + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 350 | 365 | $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' ); |
| 351 | 366 | |
| 352 | 367 | $where = array( |
| 353 | 368 | 'post_status' => 'publish', |
| @@ -370,14 +385,6 @@ | ||
| 370 | 385 | ); |
| 371 | 386 | } |
| 372 | 387 | |
| 373 | 388 | wp_send_json( $results ); |
| 374 | - } | |
| 375 | - | |
| 376 | - /** | |
| 377 | - * @deprecated 6.0 use FrmSettingsController::captcha_settings(). | |
| 378 | - */ | |
| 379 | - public static function recaptcha_settings() { | |
| 380 | - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' ); | |
| 381 | - self::captcha_settings(); | |
| 382 | 389 | } |
| 383 | 390 | } |