| @@ -4,156 +4,86 @@ | ||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmSettingsController { |
| 7 | 7 | |
| 8 | - /** | |
| 9 | - * Icon for the API section, used whether the add-on is active or only a placeholder. | |
| 10 | - * | |
| 11 | - * @since 6.35 | |
| 12 | - * | |
| 13 | - * @var string | |
| 14 | - */ | |
| 15 | - private static $api_section_icon = 'frmfont frm_cloud_icon'; | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * Payments sections are removed from the top level and added to a payments section. | |
| 19 | - * | |
| 20 | - * @since 6.22.1 | |
| 21 | - * | |
| 22 | - * @var array | |
| 23 | - */ | |
| 24 | - private static $removed_payments_sections = array(); | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * @return void | |
| 28 | - */ | |
| 29 | 8 | public static function menu() { |
| 30 | 9 | // Make sure admins can see the menu items |
| 31 | 10 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 32 | 11 | |
| 33 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 12 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); | |
| 34 | 13 | } |
| 35 | 14 | |
| 36 | - /** | |
| 37 | - * Include license box template on demand. | |
| 38 | - * | |
| 39 | - * @return void | |
| 40 | - */ | |
| 41 | 15 | public static function license_box() { |
| 42 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 43 | - return; | |
| 44 | - } | |
| 45 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php'; | |
| 16 | + $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 17 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); | |
| 46 | 18 | } |
| 47 | 19 | |
| 48 | - /** | |
| 49 | - * @param array $errors | |
| 50 | - * @param string $message | |
| 51 | - * | |
| 52 | - * @return void | |
| 53 | - */ | |
| 54 | 20 | public static function display_form( $errors = array(), $message = '' ) { |
| 55 | 21 | global $frm_vars; |
| 56 | 22 | |
| 57 | 23 | $frm_settings = FrmAppHelper::get_settings(); |
| 58 | - $uploads = wp_upload_dir(); | |
| 59 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 60 | - $sections = self::get_settings_tabs(); | |
| 61 | - $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 62 | 24 | |
| 63 | - if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { | |
| 64 | - $current = 'payments_settings'; | |
| 65 | - } | |
| 25 | + $uploads = wp_upload_dir(); | |
| 26 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 66 | 27 | |
| 67 | - require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php'; | |
| 28 | + $sections = self::get_settings_tabs(); | |
| 29 | + $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 30 | + | |
| 31 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); | |
| 68 | 32 | } |
| 69 | 33 | |
| 70 | - /** | |
| 71 | - * Get sections to use for Global Settings. | |
| 72 | - * | |
| 73 | - * @return array<array> | |
| 74 | - */ | |
| 75 | 34 | private static function get_settings_tabs() { |
| 76 | 35 | $sections = array( |
| 77 | - 'general' => array( | |
| 78 | - 'class' => self::class, | |
| 36 | + 'general' => array( | |
| 37 | + 'class' => __CLASS__, | |
| 79 | 38 | 'function' => 'general_settings', |
| 80 | 39 | 'name' => __( 'General Settings', 'formidable' ), |
| 81 | - 'icon' => 'frmfont frm_settings_icon', | |
| 40 | + 'icon' => 'frm_icon_font frm_settings_icon', | |
| 82 | 41 | ), |
| 83 | - 'messages' => array( | |
| 84 | - 'class' => self::class, | |
| 42 | + 'messages' => array( | |
| 43 | + 'class' => __CLASS__, | |
| 85 | 44 | 'function' => 'message_settings', |
| 86 | 45 | 'name' => __( 'Message Defaults', 'formidable' ), |
| 87 | - 'icon' => 'frmfont frm_stamp_icon', | |
| 46 | + 'icon' => 'frm_icon_font frm_stamp_icon', | |
| 88 | 47 | ), |
| 89 | - 'permissions' => array( | |
| 90 | - 'class' => self::class, | |
| 48 | + 'permissions' => array( | |
| 49 | + 'class' => __CLASS__, | |
| 91 | 50 | 'function' => 'permission_settings', |
| 92 | 51 | 'name' => __( 'Permissions', 'formidable' ), |
| 93 | - 'icon' => 'frmfont frm_lock_icon', | |
| 52 | + 'icon' => 'frm_icon_font frm_lock_icon', | |
| 94 | 53 | ), |
| 95 | - 'payments' => array( | |
| 96 | - 'name' => __( 'Payments', 'formidable' ), | |
| 97 | - 'icon' => 'frmfont frm_simple_cc_icon', | |
| 98 | - 'class' => self::class, | |
| 99 | - 'function' => 'payments_settings', | |
| 54 | + 'recaptcha' => array( | |
| 55 | + 'class' => __CLASS__, | |
| 56 | + 'function' => 'recaptcha_settings', | |
| 57 | + 'name' => __( 'reCaptcha', 'formidable' ), | |
| 58 | + 'icon' => 'frm_icon_font frm_shield_check_icon', | |
| 100 | 59 | ), |
| 101 | - 'custom_css' => array( | |
| 102 | - 'class' => 'FrmStylesController', | |
| 103 | - 'function' => 'custom_css', | |
| 104 | - 'name' => __( 'Custom CSS', 'formidable' ), | |
| 105 | - 'icon' => 'frmfont frm_code_icon', | |
| 106 | - ), | |
| 107 | - 'manage_styles' => array( | |
| 108 | - 'class' => 'FrmStylesController', | |
| 109 | - 'function' => 'manage', | |
| 110 | - 'name' => __( 'Manage Styles', 'formidable' ), | |
| 111 | - 'icon' => 'frmfont frm_pallet_icon', | |
| 112 | - ), | |
| 113 | - 'captcha' => array( | |
| 114 | - 'class' => self::class, | |
| 115 | - 'function' => 'captcha_settings', | |
| 116 | - 'name' => __( 'Captcha/Spam', 'formidable' ), | |
| 117 | - 'icon' => 'frmfont frm_shield_check_icon', | |
| 118 | - ), | |
| 119 | - 'email' => array( | |
| 120 | - 'class' => self::class, | |
| 121 | - 'function' => 'email_settings', | |
| 122 | - 'name' => __( 'Email', 'formidable' ), | |
| 123 | - 'icon' => 'frmfont frm_email_icon', | |
| 124 | - ), | |
| 125 | - 'white_label' => array( | |
| 60 | + 'white_label' => array( | |
| 126 | 61 | 'name' => __( 'White Labeling', 'formidable' ), |
| 127 | - 'icon' => 'frmfont frm_ghost_icon', | |
| 128 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 62 | + 'icon' => 'frm_icon_font frm_ghost_icon', | |
| 63 | + 'html_class' => 'frm_show_upgrade frm_noallow', | |
| 129 | 64 | 'data' => array( |
| 130 | - 'medium' => 'white-label', | |
| 131 | - 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 132 | - 'screenshot' => 'white-label.png', | |
| 133 | - 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ), | |
| 65 | + 'medium' => 'white-label', | |
| 66 | + 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 134 | 67 | ), |
| 135 | 68 | ), |
| 136 | - 'inbox' => array( | |
| 69 | + 'inbox' => array( | |
| 137 | 70 | 'name' => __( 'Inbox', 'formidable' ), |
| 138 | - 'icon' => 'frmfont frm_email_icon', | |
| 139 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 71 | + 'icon' => 'frm_icon_font frm_email_icon', | |
| 72 | + 'html_class' => 'frm_show_upgrade frm_noallow', | |
| 140 | 73 | 'data' => array( |
| 141 | - 'medium' => 'inbox-settings', | |
| 142 | - 'upgrade' => __( 'Inbox settings', 'formidable' ), | |
| 143 | - 'screenshot' => 'inbox.png', | |
| 144 | - 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ), | |
| 74 | + 'medium' => 'inbox-settings', | |
| 75 | + 'upgrade' => __( 'Inbox settings', 'formidable' ), | |
| 145 | 76 | ), |
| 146 | 77 | ), |
| 147 | 78 | ); |
| 148 | 79 | |
| 149 | 80 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 150 | - // If no addons need a license, skip this page | |
| 81 | + // if no addons need a license, skip this page | |
| 151 | 82 | $show_licenses = false; |
| 152 | 83 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 153 | - | |
| 154 | 84 | foreach ( $installed_addons as $installed_addon ) { |
| 155 | - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name !== 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 85 | + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 156 | 86 | $show_licenses = true; |
| 157 | 87 | break; |
| 158 | 88 | } |
| 159 | 89 | } |
| @@ -162,25 +92,19 @@ | ||
| 162 | 92 | $sections['licenses'] = array( |
| 163 | 93 | 'class' => 'FrmAddonsController', |
| 164 | 94 | 'function' => 'license_settings', |
| 165 | 95 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 166 | - 'icon' => 'frmfont frm_key_icon', | |
| 96 | + 'icon' => 'frm_icon_font frm_keyalt_icon', | |
| 167 | 97 | 'ajax' => true, |
| 168 | 98 | ); |
| 169 | 99 | } |
| 170 | - }//end if | |
| 171 | - | |
| 172 | - /** | |
| 173 | - * @param array<array> $sections | |
| 174 | - */ | |
| 100 | + } | |
| 175 | 101 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 176 | - self::add_inactive_addon_sections( $sections ); | |
| 177 | - self::remove_payments_sections( $sections ); | |
| 178 | 102 | |
| 179 | 103 | $sections['misc'] = array( |
| 180 | 104 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| 181 | - 'icon' => 'frmfont frm_shuffle_icon', | |
| 182 | - 'class' => self::class, | |
| 105 | + 'icon' => 'frm_icon_font frm_shuffle_icon', | |
| 106 | + 'class' => __CLASS__, | |
| 183 | 107 | 'function' => 'misc_settings', |
| 184 | 108 | ); |
| 185 | 109 | |
| 186 | 110 | foreach ( $sections as $key => $section ) { |
| @@ -187,9 +111,9 @@ | ||
| 187 | 111 | $original = $section; |
| 188 | 112 | $defaults = array( |
| 189 | 113 | 'html_class' => '', |
| 190 | 114 | 'name' => ucfirst( $key ), |
| 191 | - 'icon' => 'frmfont frm_settings_icon', | |
| 115 | + 'icon' => 'frm_icon_font frm_settings_icon', | |
| 192 | 116 | 'anchor' => $key . '_settings', |
| 193 | 117 | 'data' => array(), |
| 194 | 118 | ); |
| 195 | 119 | |
| @@ -204,159 +128,13 @@ | ||
| 204 | 128 | $section['function'] = $original; |
| 205 | 129 | } |
| 206 | 130 | |
| 207 | 131 | $sections[ $key ] = $section; |
| 208 | - }//end foreach | |
| 132 | + } | |
| 209 | 133 | |
| 210 | 134 | return $sections; |
| 211 | 135 | } |
| 212 | 136 | |
| 213 | - /** | |
| 214 | - * Add a placeholder section for each add-on that owns a Global Settings | |
| 215 | - * section but is not active. | |
| 216 | - * | |
| 217 | - * A placeholder reads as disabled and opens a page offering to activate the | |
| 218 | - * add-on or to upgrade, depending on what the license allows. It goes at the | |
| 219 | - * head of the add-on sections, right after Inbox, so it sits with the rest of | |
| 220 | - * the add-on settings instead of trailing them. A section already claimed by | |
| 221 | - * an active plugin is left alone, so nothing stands in for a section that is | |
| 222 | - * really there. | |
| 223 | - * | |
| 224 | - * @since 6.35 | |
| 225 | - * | |
| 226 | - * @param array<array> $sections Sections registered for the Global Settings page so far. | |
| 227 | - * | |
| 228 | - * @return void | |
| 229 | - */ | |
| 230 | - private static function add_inactive_addon_sections( &$sections ) { | |
| 231 | - if ( isset( $sections['api'] ) ) { | |
| 232 | - // The add-on is active, so it owns the section. Only the icon is taken over, | |
| 233 | - // so the tab looks the same whether or not the add-on is installed. | |
| 234 | - $sections['api']['icon'] = self::$api_section_icon; | |
| 235 | - return; | |
| 236 | - } | |
| 237 | - | |
| 238 | - self::insert_section_after( $sections, 'inbox', 'api', self::get_api_placeholder_section() ); | |
| 239 | - } | |
| 240 | - | |
| 241 | - /** | |
| 242 | - * Insert a section directly after another one, leaving the rest of the order alone. | |
| 243 | - * | |
| 244 | - * Assigning a new key lands the section at the end of the array, so the array | |
| 245 | - * is rebuilt to put it where it belongs. | |
| 246 | - * | |
| 247 | - * @since 6.35 | |
| 248 | - * | |
| 249 | - * @param array<array> $sections Sections registered for the Global Settings page so far. | |
| 250 | - * @param string $after Key of the section the new one follows. The new section goes last when this key is not there. | |
| 251 | - * @param string $key Key for the new section. | |
| 252 | - * @param array $section The section to insert. | |
| 253 | - * | |
| 254 | - * @return void | |
| 255 | - */ | |
| 256 | - private static function insert_section_after( &$sections, $after, $key, $section ) { | |
| 257 | - if ( ! isset( $sections[ $after ] ) ) { | |
| 258 | - $sections[ $key ] = $section; | |
| 259 | - return; | |
| 260 | - } | |
| 261 | - | |
| 262 | - $ordered = array(); | |
| 263 | - | |
| 264 | - foreach ( $sections as $section_key => $existing_section ) { | |
| 265 | - $ordered[ $section_key ] = $existing_section; | |
| 266 | - | |
| 267 | - if ( $section_key === $after ) { | |
| 268 | - $ordered[ $key ] = $section; | |
| 269 | - } | |
| 270 | - } | |
| 271 | - | |
| 272 | - $sections = $ordered; | |
| 273 | - } | |
| 274 | - | |
| 275 | - /** | |
| 276 | - * Get the placeholder that stands in for the API add-on's section. | |
| 277 | - * | |
| 278 | - * The upgrade data decides which call to action the page shows. When the | |
| 279 | - * license covers the add-on, it carries the one click install or activate | |
| 280 | - * link. Otherwise it carries the plan the add-on needs, and the page asks | |
| 281 | - * the user to upgrade to it, on a gradient button that sets the upgrade | |
| 282 | - * apart from a one click install. | |
| 283 | - * | |
| 284 | - * @since 6.35 | |
| 285 | - * | |
| 286 | - * @return array | |
| 287 | - */ | |
| 288 | - private static function get_api_placeholder_section() { | |
| 289 | - $data = FrmAppHelper::get_upgrade_data_params( | |
| 290 | - 'api', | |
| 291 | - array( | |
| 292 | - 'medium' => 'api-settings', | |
| 293 | - 'upgrade' => __( 'API settings', 'formidable' ), | |
| 294 | - 'message' => __( 'Send entries to any site with a REST API, and let AI assistants build your forms. Upgrade to get the API add-on.', 'formidable' ), | |
| 295 | - 'learn-more' => FrmAppHelper::get_doc_url( 'formidable-api', 'api-global-settings' ), | |
| 296 | - 'upsell-images' => 'api-settings-1.png,api-settings-2.png,api-settings-3.png', | |
| 297 | - ) | |
| 298 | - ); | |
| 299 | - | |
| 300 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 301 | - $data['gradient-upgrade'] = 1; | |
| 302 | - } | |
| 303 | - | |
| 304 | - return array( | |
| 305 | - 'name' => __( 'API', 'formidable' ), | |
| 306 | - 'icon' => self::$api_section_icon, | |
| 307 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 308 | - 'data' => $data, | |
| 309 | - ); | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | - * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net) | |
| 314 | - * and show them all on the payments section in separate tabs. | |
| 315 | - * | |
| 316 | - * @since 6.22.1 | |
| 317 | - * | |
| 318 | - * @param array $sections | |
| 319 | - * | |
| 320 | - * @return void | |
| 321 | - */ | |
| 322 | - private static function remove_payments_sections( &$sections ) { | |
| 323 | - $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' ); | |
| 324 | - | |
| 325 | - foreach ( $sections as $key => $section ) { | |
| 326 | - if ( ! in_array( $key, $payment_section_keys, true ) ) { | |
| 327 | - continue; | |
| 328 | - } | |
| 329 | - | |
| 330 | - self::$removed_payments_sections[ $key ] = $section; | |
| 331 | - unset( $sections[ $key ] ); | |
| 332 | - } | |
| 333 | - | |
| 334 | - uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) ); | |
| 335 | - } | |
| 336 | - | |
| 337 | - /** | |
| 338 | - * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net) | |
| 339 | - * | |
| 340 | - * @since 6.22.1 | |
| 341 | - * | |
| 342 | - * @param string $a | |
| 343 | - * @param string $b | |
| 344 | - * | |
| 345 | - * @return int | |
| 346 | - */ | |
| 347 | - private static function payment_sections_sort_callback( $a, $b ) { | |
| 348 | - $order = array( 'stripe', 'square', 'paypal', 'authorize_net' ); | |
| 349 | - $first_key = array_search( $a, $order, true ); | |
| 350 | - $second_key = array_search( $b, $order, true ); | |
| 351 | - | |
| 352 | - if ( false === $first_key || false === $second_key ) { | |
| 353 | - return 0; | |
| 354 | - } | |
| 355 | - | |
| 356 | - return $first_key - $second_key; | |
| 357 | - } | |
| 358 | - | |
| 359 | 137 | public static function load_settings_tab() { |
| 360 | 138 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 361 | 139 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 362 | 140 | |
| @@ -361,9 +139,8 @@ | ||
| 361 | 139 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 362 | 140 | |
| 363 | 141 | $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' ); |
| 364 | 142 | $sections = self::get_settings_tabs(); |
| 365 | - | |
| 366 | 143 | if ( ! isset( $sections[ $section ] ) ) { |
| 367 | 144 | wp_die(); |
| 368 | 145 | } |
| 369 | 146 | |
| @@ -371,150 +148,82 @@ | ||
| 371 | 148 | |
| 372 | 149 | if ( isset( $section['class'] ) ) { |
| 373 | 150 | call_user_func( array( $section['class'], $section['function'] ) ); |
| 374 | 151 | } else { |
| 375 | - call_user_func( $section['function'] ?? $section ); | |
| 152 | + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) ); | |
| 376 | 153 | } |
| 377 | - | |
| 378 | 154 | wp_die(); |
| 379 | 155 | } |
| 380 | 156 | |
| 381 | 157 | /** |
| 382 | - * Render the general global settings section. | |
| 383 | - * | |
| 384 | 158 | * @since 4.0 |
| 385 | - * | |
| 386 | - * @return void | |
| 387 | 159 | */ |
| 388 | 160 | public static function general_settings() { |
| 389 | 161 | $frm_settings = FrmAppHelper::get_settings(); |
| 390 | - $uploads = wp_upload_dir(); | |
| 391 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 392 | 162 | |
| 393 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php'; | |
| 394 | - } | |
| 163 | + $uploads = wp_upload_dir(); | |
| 164 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 395 | 165 | |
| 396 | - /** | |
| 397 | - * Render the global currency selector if Pro is up to date. | |
| 398 | - * | |
| 399 | - * @param FrmSettings $frm_settings | |
| 400 | - * | |
| 401 | - * @return void | |
| 402 | - */ | |
| 403 | - public static function maybe_render_currency_selector( $frm_settings ) { | |
| 404 | - if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) { | |
| 405 | - FrmProSettingsController::add_currency_settings(); | |
| 406 | - return; | |
| 407 | - } | |
| 408 | - | |
| 409 | - $currencies = FrmCurrencyHelper::get_currencies(); | |
| 410 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php'; | |
| 166 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' ); | |
| 411 | 167 | } |
| 412 | 168 | |
| 413 | 169 | /** |
| 414 | 170 | * @since 4.0 |
| 415 | - * | |
| 416 | - * @return void | |
| 417 | 171 | */ |
| 418 | 172 | public static function message_settings() { |
| 419 | 173 | $frm_settings = FrmAppHelper::get_settings(); |
| 420 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php'; | |
| 174 | + | |
| 175 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' ); | |
| 421 | 176 | } |
| 422 | 177 | |
| 423 | 178 | /** |
| 424 | 179 | * @since 4.0 |
| 425 | - * | |
| 426 | - * @return void | |
| 427 | 180 | */ |
| 428 | - public static function captcha_settings() { | |
| 181 | + public static function recaptcha_settings() { | |
| 429 | 182 | $frm_settings = FrmAppHelper::get_settings(); |
| 430 | 183 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| 431 | 184 | |
| 432 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php'; | |
| 185 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/recaptcha.php' ); | |
| 433 | 186 | } |
| 434 | 187 | |
| 435 | 188 | /** |
| 436 | - * Shows email settings. | |
| 437 | - * | |
| 438 | - * @since 6.25 | |
| 439 | - * | |
| 440 | - * @return void | |
| 441 | - */ | |
| 442 | - public static function email_settings() { | |
| 443 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 444 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/email/email-styles.php'; | |
| 445 | - } | |
| 446 | - | |
| 447 | - /** | |
| 448 | 189 | * @since 4.0 |
| 449 | - * | |
| 450 | - * @return void | |
| 451 | 190 | */ |
| 452 | 191 | public static function permission_settings() { |
| 453 | 192 | $frm_settings = FrmAppHelper::get_settings(); |
| 454 | 193 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 455 | 194 | |
| 456 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php'; | |
| 195 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' ); | |
| 457 | 196 | } |
| 458 | 197 | |
| 459 | 198 | /** |
| 460 | - * @return void | |
| 461 | - */ | |
| 462 | - public static function payments_settings() { | |
| 463 | - $payment_sections = self::$removed_payments_sections; | |
| 464 | - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 465 | - | |
| 466 | - if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { | |
| 467 | - $tab = str_replace( '_settings', '', $tab ); | |
| 468 | - } else { | |
| 469 | - $tab = 'stripe'; | |
| 470 | - } | |
| 471 | - | |
| 472 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/payments.php'; | |
| 473 | - } | |
| 474 | - | |
| 475 | - /** | |
| 476 | 199 | * @since 4.0 |
| 477 | - * | |
| 478 | - * @return void | |
| 479 | 200 | */ |
| 480 | 201 | public static function misc_settings() { |
| 481 | 202 | $frm_settings = FrmAppHelper::get_settings(); |
| 482 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php'; | |
| 203 | + | |
| 204 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); | |
| 483 | 205 | } |
| 484 | 206 | |
| 485 | - /** | |
| 486 | - * Save form data submitted from the Global settings page. | |
| 487 | - * | |
| 488 | - * @param bool|string $stop_load | |
| 489 | - * | |
| 490 | - * @return void | |
| 491 | - */ | |
| 492 | 207 | public static function process_form( $stop_load = false ) { |
| 493 | 208 | global $frm_vars; |
| 494 | 209 | |
| 495 | 210 | $frm_settings = FrmAppHelper::get_settings(); |
| 211 | + | |
| 496 | 212 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 497 | - | |
| 498 | 213 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 499 | - $error_args = array( | |
| 500 | - 'title' => __( 'Verification failed', 'formidable' ), | |
| 501 | - 'body' => $frm_settings->admin_permission, | |
| 502 | - 'cancel_text' => __( 'Cancel', 'formidable' ), | |
| 503 | - ); | |
| 504 | - FrmAppController::show_error_modal( $error_args ); | |
| 505 | - return; | |
| 214 | + wp_die( esc_html( $frm_settings->admin_permission ) ); | |
| 506 | 215 | } |
| 507 | 216 | |
| 508 | 217 | $errors = array(); |
| 509 | 218 | $message = ''; |
| 510 | 219 | |
| 511 | - if ( empty( $frm_vars['settings_routed'] ) ) { | |
| 220 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 512 | 221 | $errors = $frm_settings->validate( $_POST, array() ); |
| 513 | 222 | |
| 514 | 223 | $frm_settings->update( wp_unslash( $_POST ) ); |
| 515 | 224 | |
| 516 | - if ( ! $errors ) { | |
| 225 | + if ( empty( $errors ) ) { | |
| 517 | 226 | $frm_settings->store(); |
| 518 | 227 | $message = __( 'Settings Saved', 'formidable' ); |
| 519 | 228 | } |
| 520 | 229 | } else { |
| @@ -520,10 +229,11 @@ | ||
| 520 | 229 | } else { |
| 521 | 230 | $message = __( 'Settings Saved', 'formidable' ); |
| 522 | 231 | } |
| 523 | 232 | |
| 524 | - if ( $stop_load === 'stop_load' ) { | |
| 233 | + if ( $stop_load == 'stop_load' ) { | |
| 525 | 234 | $frm_vars['settings_routed'] = true; |
| 235 | + | |
| 526 | 236 | return; |
| 527 | 237 | } |
| 528 | 238 | |
| 529 | 239 | self::display_form( $errors, $message ); |
| @@ -532,10 +242,8 @@ | ||
| 532 | 242 | /** |
| 533 | 243 | * Include the Update button on the global settings page. |
| 534 | 244 | * |
| 535 | 245 | * @since 4.0.02 |
| 536 | - * | |
| 537 | - * @return void | |
| 538 | 246 | */ |
| 539 | 247 | public static function save_button() { |
| 540 | 248 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 541 | 249 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| @@ -540,21 +248,16 @@ | ||
| 540 | 248 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 541 | 249 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| 542 | 250 | } |
| 543 | 251 | |
| 544 | - /** | |
| 545 | - * @param bool|string $stop_load | |
| 546 | - * | |
| 547 | - * @return void | |
| 548 | - */ | |
| 549 | 252 | public static function route( $stop_load = false ) { |
| 550 | 253 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 551 | 254 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 552 | 255 | FrmAppHelper::include_svg(); |
| 553 | 256 | |
| 554 | - if ( $action === 'process-form' ) { | |
| 257 | + if ( $action == 'process-form' ) { | |
| 555 | 258 | self::process_form( $stop_load ); |
| 556 | - } elseif ( $stop_load !== 'stop_load' ) { | |
| 259 | + } elseif ( $stop_load != 'stop_load' ) { | |
| 557 | 260 | self::display_form(); |
| 558 | 261 | } |
| 559 | 262 | } |
| 560 | 263 | |
| @@ -561,17 +264,34 @@ | ||
| 561 | 264 | /** |
| 562 | 265 | * Add CTA to the bottom on the plugin settings pages. |
| 563 | 266 | * |
| 564 | 267 | * @since 3.04.02 |
| 565 | - * | |
| 566 | - * @return void | |
| 567 | 268 | */ |
| 568 | - public static function settings_cta() { | |
| 269 | + public static function settings_cta( $view ) { | |
| 270 | + | |
| 569 | 271 | if ( get_option( 'frm_lite_settings_upgrade', false ) ) { |
| 570 | 272 | return; |
| 571 | 273 | } |
| 572 | 274 | |
| 573 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php'; | |
| 275 | + $features = array( | |
| 276 | + __( 'Extra form features like file uploads, pagination, etc', 'formidable' ), | |
| 277 | + __( 'Repeaters & cascading fields for advanced forms', 'formidable' ), | |
| 278 | + __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ), | |
| 279 | + __( 'Display entries with virtually limitless Formidable views', 'formidable' ), | |
| 280 | + __( 'Create surveys & polls', 'formidable' ), | |
| 281 | + __( 'WordPress user registration and login forms', 'formidable' ), | |
| 282 | + __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ), | |
| 283 | + __( 'Powerful conditional logic for smart forms', 'formidable' ), | |
| 284 | + __( 'Integrations with 1000+ marketing & payment services', 'formidable' ), | |
| 285 | + __( 'Collect digital signatures', 'formidable' ), | |
| 286 | + __( 'Accept user-submitted content with Post submissions', 'formidable' ), | |
| 287 | + __( 'Email routing', 'formidable' ), | |
| 288 | + __( 'Create calculator forms', 'formidable' ), | |
| 289 | + __( 'Save draft entries and return later', 'formidable' ), | |
| 290 | + __( 'Analyze form data with graphs & stats', 'formidable' ), | |
| 291 | + ); | |
| 292 | + | |
| 293 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' ); | |
| 574 | 294 | } |
| 575 | 295 | |
| 576 | 296 | /** |
| 577 | 297 | * Dismiss upgrade notice at the bottom on the plugin settings pages. |
| @@ -578,12 +298,11 @@ | ||
| 578 | 298 | * |
| 579 | 299 | * @since 3.04.02 |
| 580 | 300 | */ |
| 581 | 301 | public static function settings_cta_dismiss() { |
| 582 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 583 | 302 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 584 | 303 | |
| 585 | - update_option( 'frm_lite_settings_upgrade', time(), false ); | |
| 304 | + update_option( 'frm_lite_settings_upgrade', time(), 'no' ); | |
| 586 | 305 | |
| 587 | 306 | wp_send_json_success(); |
| 588 | 307 | } |
| 589 | 308 | |
| @@ -597,9 +316,9 @@ | ||
| 597 | 316 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 598 | 317 | |
| 599 | 318 | global $wpdb; |
| 600 | 319 | |
| 601 | - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 320 | + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 602 | 321 | $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' ); |
| 603 | 322 | |
| 604 | 323 | $where = array( |
| 605 | 324 | 'post_status' => 'publish', |
| @@ -611,11 +330,11 @@ | ||
| 611 | 330 | 'limit' => 25, |
| 612 | 331 | 'order_by' => 'post_title', |
| 613 | 332 | ); |
| 614 | 333 | |
| 615 | - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 334 | + $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 335 | + | |
| 616 | 336 | $results = array(); |
| 617 | - | |
| 618 | 337 | foreach ( $pages as $page ) { |
| 619 | 338 | $results[] = array( |
| 620 | 339 | 'value' => $page->ID, |
| 621 | 340 | 'label' => $page->post_title, |
| @@ -622,25 +341,6 @@ | ||
| 622 | 341 | ); |
| 623 | 342 | } |
| 624 | 343 | |
| 625 | 344 | wp_send_json( $results ); |
| 626 | - } | |
| 627 | - | |
| 628 | - /** | |
| 629 | - * Shows a fake color picker. | |
| 630 | - * | |
| 631 | - * @since 6.25 | |
| 632 | - * | |
| 633 | - * @param string $color Color value. | |
| 634 | - * | |
| 635 | - * @return void | |
| 636 | - */ | |
| 637 | - public static function fake_color_picker( $color ) { | |
| 638 | - ?> | |
| 639 | - <div class="wp-picker-container"> | |
| 640 | - <button type="button" class="button wp-color-result" aria-expanded="false" aria-disabled="true" tabindex="-1" style="background-color:<?php echo esc_attr( $color ); ?>;"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 641 | - <span class="wp-color-result-text" style="color:#a7aaad;"><?php esc_html_e( 'Select Color', 'formidable' ); ?></span> | |
| 642 | - </button> | |
| 643 | - </div> | |
| 644 | - <?php | |
| 645 | 345 | } |
| 646 | 346 | } |