| @@ -4,13 +4,34 @@ | ||
| 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 | + */ | |
| 8 | 29 | public static function menu() { |
| 9 | 30 | // Make sure admins can see the menu items |
| 10 | 31 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 11 | 32 | |
| 12 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); | |
| 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 | |
| 13 | 34 | } |
| 14 | 35 | |
| 15 | 36 | /** |
| 16 | 37 | * Include license box template on demand. |
| @@ -20,23 +41,31 @@ | ||
| 20 | 41 | public static function license_box() { |
| 21 | 42 | if ( ! current_user_can( 'activate_plugins' ) ) { |
| 22 | 43 | return; |
| 23 | 44 | } |
| 24 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); | |
| 45 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php'; | |
| 25 | 46 | } |
| 26 | 47 | |
| 48 | + /** | |
| 49 | + * @param array $errors | |
| 50 | + * @param string $message | |
| 51 | + * | |
| 52 | + * @return void | |
| 53 | + */ | |
| 27 | 54 | public static function display_form( $errors = array(), $message = '' ) { |
| 28 | 55 | global $frm_vars; |
| 29 | 56 | |
| 30 | 57 | $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' ); | |
| 31 | 62 | |
| 32 | - $uploads = wp_upload_dir(); | |
| 33 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 63 | + if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { | |
| 64 | + $current = 'payments_settings'; | |
| 65 | + } | |
| 34 | 66 | |
| 35 | - $sections = self::get_settings_tabs(); | |
| 36 | - $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 37 | - | |
| 38 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); | |
| 67 | + require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php'; | |
| 39 | 68 | } |
| 40 | 69 | |
| 41 | 70 | /** |
| 42 | 71 | * Get sections to use for Global Settings. |
| @@ -44,62 +73,76 @@ | ||
| 44 | 73 | * @return array<array> |
| 45 | 74 | */ |
| 46 | 75 | private static function get_settings_tabs() { |
| 47 | 76 | $sections = array( |
| 48 | - 'general' => array( | |
| 49 | - 'class' => __CLASS__, | |
| 77 | + 'general' => array( | |
| 78 | + 'class' => self::class, | |
| 50 | 79 | 'function' => 'general_settings', |
| 51 | 80 | 'name' => __( 'General Settings', 'formidable' ), |
| 52 | - 'icon' => 'frm_icon_font frm_settings_icon', | |
| 81 | + 'icon' => 'frmfont frm_settings_icon', | |
| 53 | 82 | ), |
| 54 | - 'messages' => array( | |
| 55 | - 'class' => __CLASS__, | |
| 83 | + 'messages' => array( | |
| 84 | + 'class' => self::class, | |
| 56 | 85 | 'function' => 'message_settings', |
| 57 | 86 | 'name' => __( 'Message Defaults', 'formidable' ), |
| 58 | - 'icon' => 'frm_icon_font frm_stamp_icon', | |
| 87 | + 'icon' => 'frmfont frm_stamp_icon', | |
| 59 | 88 | ), |
| 60 | - 'permissions' => array( | |
| 61 | - 'class' => __CLASS__, | |
| 89 | + 'permissions' => array( | |
| 90 | + 'class' => self::class, | |
| 62 | 91 | 'function' => 'permission_settings', |
| 63 | 92 | 'name' => __( 'Permissions', 'formidable' ), |
| 64 | - 'icon' => 'frm_icon_font frm_lock_icon', | |
| 93 | + 'icon' => 'frmfont frm_lock_icon', | |
| 65 | 94 | ), |
| 66 | - 'custom_css' => array( | |
| 95 | + 'payments' => array( | |
| 96 | + 'name' => __( 'Payments', 'formidable' ), | |
| 97 | + 'icon' => 'frmfont frm_simple_cc_icon', | |
| 98 | + 'class' => self::class, | |
| 99 | + 'function' => 'payments_settings', | |
| 100 | + ), | |
| 101 | + 'custom_css' => array( | |
| 67 | 102 | 'class' => 'FrmStylesController', |
| 68 | 103 | 'function' => 'custom_css', |
| 69 | 104 | 'name' => __( 'Custom CSS', 'formidable' ), |
| 70 | - 'icon' => 'frm_icon_font frm_code_icon', | |
| 105 | + 'icon' => 'frmfont frm_code_icon', | |
| 71 | 106 | ), |
| 72 | 107 | 'manage_styles' => array( |
| 73 | 108 | 'class' => 'FrmStylesController', |
| 74 | 109 | 'function' => 'manage', |
| 75 | 110 | 'name' => __( 'Manage Styles', 'formidable' ), |
| 76 | - 'icon' => 'frm_icon_font frm_pallet_icon', | |
| 111 | + 'icon' => 'frmfont frm_pallet_icon', | |
| 77 | 112 | ), |
| 78 | - 'captcha' => array( | |
| 79 | - 'class' => __CLASS__, | |
| 113 | + 'captcha' => array( | |
| 114 | + 'class' => self::class, | |
| 80 | 115 | 'function' => 'captcha_settings', |
| 81 | - 'name' => __( 'Captcha', 'formidable' ), | |
| 82 | - 'icon' => 'frm_icon_font frm_shield_check_icon', | |
| 116 | + 'name' => __( 'Captcha/Spam', 'formidable' ), | |
| 117 | + 'icon' => 'frmfont frm_shield_check_icon', | |
| 83 | 118 | ), |
| 84 | - 'white_label' => array( | |
| 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( | |
| 85 | 126 | 'name' => __( 'White Labeling', 'formidable' ), |
| 86 | - 'icon' => 'frm_icon_font frm_ghost_icon', | |
| 127 | + 'icon' => 'frmfont frm_ghost_icon', | |
| 87 | 128 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 88 | 129 | 'data' => array( |
| 89 | 130 | 'medium' => 'white-label', |
| 90 | 131 | 'upgrade' => __( 'White labeling options', 'formidable' ), |
| 91 | 132 | 'screenshot' => 'white-label.png', |
| 133 | + 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ), | |
| 92 | 134 | ), |
| 93 | 135 | ), |
| 94 | - 'inbox' => array( | |
| 136 | + 'inbox' => array( | |
| 95 | 137 | 'name' => __( 'Inbox', 'formidable' ), |
| 96 | - 'icon' => 'frm_icon_font frm_email_icon', | |
| 138 | + 'icon' => 'frmfont frm_email_icon', | |
| 97 | 139 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 98 | 140 | 'data' => array( |
| 99 | 141 | 'medium' => 'inbox-settings', |
| 100 | 142 | 'upgrade' => __( 'Inbox settings', 'formidable' ), |
| 101 | 143 | 'screenshot' => 'inbox.png', |
| 144 | + 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ), | |
| 102 | 145 | ), |
| 103 | 146 | ), |
| 104 | 147 | ); |
| 105 | 148 | |
| @@ -106,10 +149,11 @@ | ||
| 106 | 149 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 107 | 150 | // If no addons need a license, skip this page |
| 108 | 151 | $show_licenses = false; |
| 109 | 152 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 153 | + | |
| 110 | 154 | foreach ( $installed_addons as $installed_addon ) { |
| 111 | - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 155 | + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name !== 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 112 | 156 | $show_licenses = true; |
| 113 | 157 | break; |
| 114 | 158 | } |
| 115 | 159 | } |
| @@ -118,23 +162,25 @@ | ||
| 118 | 162 | $sections['licenses'] = array( |
| 119 | 163 | 'class' => 'FrmAddonsController', |
| 120 | 164 | 'function' => 'license_settings', |
| 121 | 165 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 122 | - 'icon' => 'frm_icon_font frm_keyalt_icon', | |
| 166 | + 'icon' => 'frmfont frm_key_icon', | |
| 123 | 167 | 'ajax' => true, |
| 124 | 168 | ); |
| 125 | 169 | } |
| 126 | - } | |
| 170 | + }//end if | |
| 127 | 171 | |
| 128 | 172 | /** |
| 129 | 173 | * @param array<array> $sections |
| 130 | 174 | */ |
| 131 | 175 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 176 | + self::add_inactive_addon_sections( $sections ); | |
| 177 | + self::remove_payments_sections( $sections ); | |
| 132 | 178 | |
| 133 | 179 | $sections['misc'] = array( |
| 134 | 180 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| 135 | - 'icon' => 'frm_icon_font frm_shuffle_icon', | |
| 136 | - 'class' => __CLASS__, | |
| 181 | + 'icon' => 'frmfont frm_shuffle_icon', | |
| 182 | + 'class' => self::class, | |
| 137 | 183 | 'function' => 'misc_settings', |
| 138 | 184 | ); |
| 139 | 185 | |
| 140 | 186 | foreach ( $sections as $key => $section ) { |
| @@ -141,9 +187,9 @@ | ||
| 141 | 187 | $original = $section; |
| 142 | 188 | $defaults = array( |
| 143 | 189 | 'html_class' => '', |
| 144 | 190 | 'name' => ucfirst( $key ), |
| 145 | - 'icon' => 'frm_icon_font frm_settings_icon', | |
| 191 | + 'icon' => 'frmfont frm_settings_icon', | |
| 146 | 192 | 'anchor' => $key . '_settings', |
| 147 | 193 | 'data' => array(), |
| 148 | 194 | ); |
| 149 | 195 | |
| @@ -158,13 +204,159 @@ | ||
| 158 | 204 | $section['function'] = $original; |
| 159 | 205 | } |
| 160 | 206 | |
| 161 | 207 | $sections[ $key ] = $section; |
| 208 | + }//end foreach | |
| 209 | + | |
| 210 | + return $sections; | |
| 211 | + } | |
| 212 | + | |
| 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; | |
| 162 | 236 | } |
| 163 | 237 | |
| 164 | - return $sections; | |
| 238 | + self::insert_section_after( $sections, 'inbox', 'api', self::get_api_placeholder_section() ); | |
| 165 | 239 | } |
| 166 | 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 | + | |
| 167 | 359 | public static function load_settings_tab() { |
| 168 | 360 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 169 | 361 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 170 | 362 | |
| @@ -169,8 +361,9 @@ | ||
| 169 | 361 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 170 | 362 | |
| 171 | 363 | $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' ); |
| 172 | 364 | $sections = self::get_settings_tabs(); |
| 365 | + | |
| 173 | 366 | if ( ! isset( $sections[ $section ] ) ) { |
| 174 | 367 | wp_die(); |
| 175 | 368 | } |
| 176 | 369 | |
| @@ -178,67 +371,122 @@ | ||
| 178 | 371 | |
| 179 | 372 | if ( isset( $section['class'] ) ) { |
| 180 | 373 | call_user_func( array( $section['class'], $section['function'] ) ); |
| 181 | 374 | } else { |
| 182 | - call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) ); | |
| 375 | + call_user_func( $section['function'] ?? $section ); | |
| 183 | 376 | } |
| 377 | + | |
| 184 | 378 | wp_die(); |
| 185 | 379 | } |
| 186 | 380 | |
| 187 | 381 | /** |
| 382 | + * Render the general global settings section. | |
| 383 | + * | |
| 188 | 384 | * @since 4.0 |
| 385 | + * | |
| 386 | + * @return void | |
| 189 | 387 | */ |
| 190 | 388 | public static function general_settings() { |
| 191 | 389 | $frm_settings = FrmAppHelper::get_settings(); |
| 390 | + $uploads = wp_upload_dir(); | |
| 391 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 192 | 392 | |
| 193 | - $uploads = wp_upload_dir(); | |
| 194 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 393 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php'; | |
| 394 | + } | |
| 195 | 395 | |
| 196 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' ); | |
| 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'; | |
| 197 | 411 | } |
| 198 | 412 | |
| 199 | 413 | /** |
| 200 | 414 | * @since 4.0 |
| 415 | + * | |
| 416 | + * @return void | |
| 201 | 417 | */ |
| 202 | 418 | public static function message_settings() { |
| 203 | 419 | $frm_settings = FrmAppHelper::get_settings(); |
| 204 | - | |
| 205 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' ); | |
| 420 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php'; | |
| 206 | 421 | } |
| 207 | 422 | |
| 208 | 423 | /** |
| 209 | 424 | * @since 4.0 |
| 425 | + * | |
| 426 | + * @return void | |
| 210 | 427 | */ |
| 211 | 428 | public static function captcha_settings() { |
| 212 | 429 | $frm_settings = FrmAppHelper::get_settings(); |
| 213 | 430 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| 214 | 431 | |
| 215 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' ); | |
| 432 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php'; | |
| 216 | 433 | } |
| 217 | 434 | |
| 218 | 435 | /** |
| 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 | + /** | |
| 219 | 448 | * @since 4.0 |
| 449 | + * | |
| 450 | + * @return void | |
| 220 | 451 | */ |
| 221 | 452 | public static function permission_settings() { |
| 222 | 453 | $frm_settings = FrmAppHelper::get_settings(); |
| 223 | 454 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 224 | 455 | |
| 225 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' ); | |
| 456 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php'; | |
| 226 | 457 | } |
| 227 | 458 | |
| 228 | 459 | /** |
| 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 | + /** | |
| 229 | 476 | * @since 4.0 |
| 477 | + * | |
| 478 | + * @return void | |
| 230 | 479 | */ |
| 231 | 480 | public static function misc_settings() { |
| 232 | 481 | $frm_settings = FrmAppHelper::get_settings(); |
| 233 | - | |
| 234 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); | |
| 482 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php'; | |
| 235 | 483 | } |
| 236 | 484 | |
| 237 | 485 | /** |
| 238 | 486 | * Save form data submitted from the Global settings page. |
| 239 | 487 | * |
| 240 | - * @param string|bool $stop_load | |
| 488 | + * @param bool|string $stop_load | |
| 241 | 489 | * |
| 242 | 490 | * @return void |
| 243 | 491 | */ |
| 244 | 492 | public static function process_form( $stop_load = false ) { |
| @@ -247,9 +495,15 @@ | ||
| 247 | 495 | $frm_settings = FrmAppHelper::get_settings(); |
| 248 | 496 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 249 | 497 | |
| 250 | 498 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 251 | - wp_die( esc_html( $frm_settings->admin_permission ) ); | |
| 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; | |
| 252 | 506 | } |
| 253 | 507 | |
| 254 | 508 | $errors = array(); |
| 255 | 509 | $message = ''; |
| @@ -278,8 +532,10 @@ | ||
| 278 | 532 | /** |
| 279 | 533 | * Include the Update button on the global settings page. |
| 280 | 534 | * |
| 281 | 535 | * @since 4.0.02 |
| 536 | + * | |
| 537 | + * @return void | |
| 282 | 538 | */ |
| 283 | 539 | public static function save_button() { |
| 284 | 540 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 285 | 541 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| @@ -284,16 +540,21 @@ | ||
| 284 | 540 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 285 | 541 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| 286 | 542 | } |
| 287 | 543 | |
| 544 | + /** | |
| 545 | + * @param bool|string $stop_load | |
| 546 | + * | |
| 547 | + * @return void | |
| 548 | + */ | |
| 288 | 549 | public static function route( $stop_load = false ) { |
| 289 | 550 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 290 | 551 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 291 | 552 | FrmAppHelper::include_svg(); |
| 292 | 553 | |
| 293 | - if ( $action == 'process-form' ) { | |
| 554 | + if ( $action === 'process-form' ) { | |
| 294 | 555 | self::process_form( $stop_load ); |
| 295 | - } elseif ( $stop_load != 'stop_load' ) { | |
| 556 | + } elseif ( $stop_load !== 'stop_load' ) { | |
| 296 | 557 | self::display_form(); |
| 297 | 558 | } |
| 298 | 559 | } |
| 299 | 560 | |
| @@ -300,34 +561,17 @@ | ||
| 300 | 561 | /** |
| 301 | 562 | * Add CTA to the bottom on the plugin settings pages. |
| 302 | 563 | * |
| 303 | 564 | * @since 3.04.02 |
| 565 | + * | |
| 566 | + * @return void | |
| 304 | 567 | */ |
| 305 | - public static function settings_cta( $view ) { | |
| 306 | - | |
| 568 | + public static function settings_cta() { | |
| 307 | 569 | if ( get_option( 'frm_lite_settings_upgrade', false ) ) { |
| 308 | 570 | return; |
| 309 | 571 | } |
| 310 | 572 | |
| 311 | - $features = array( | |
| 312 | - __( 'Extra form features like file uploads, pagination, etc', 'formidable' ), | |
| 313 | - __( 'Repeaters & cascading fields for advanced forms', 'formidable' ), | |
| 314 | - __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ), | |
| 315 | - __( 'Display entries with virtually limitless Formidable views', 'formidable' ), | |
| 316 | - __( 'Create surveys & polls', 'formidable' ), | |
| 317 | - __( 'WordPress user registration and login forms', 'formidable' ), | |
| 318 | - __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ), | |
| 319 | - __( 'Powerful conditional logic for smart forms', 'formidable' ), | |
| 320 | - __( 'Integrations with 1000+ marketing & payment services', 'formidable' ), | |
| 321 | - __( 'Collect digital signatures', 'formidable' ), | |
| 322 | - __( 'Accept user-submitted content with Post submissions', 'formidable' ), | |
| 323 | - __( 'Email routing', 'formidable' ), | |
| 324 | - __( 'Create calculator forms', 'formidable' ), | |
| 325 | - __( 'Save draft entries and return later', 'formidable' ), | |
| 326 | - __( 'Analyze form data with graphs & stats', 'formidable' ), | |
| 327 | - ); | |
| 328 | - | |
| 329 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' ); | |
| 573 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php'; | |
| 330 | 574 | } |
| 331 | 575 | |
| 332 | 576 | /** |
| 333 | 577 | * Dismiss upgrade notice at the bottom on the plugin settings pages. |
| @@ -334,11 +578,12 @@ | ||
| 334 | 578 | * |
| 335 | 579 | * @since 3.04.02 |
| 336 | 580 | */ |
| 337 | 581 | public static function settings_cta_dismiss() { |
| 582 | + check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 338 | 583 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 339 | 584 | |
| 340 | - update_option( 'frm_lite_settings_upgrade', time(), 'no' ); | |
| 585 | + update_option( 'frm_lite_settings_upgrade', time(), false ); | |
| 341 | 586 | |
| 342 | 587 | wp_send_json_success(); |
| 343 | 588 | } |
| 344 | 589 | |
| @@ -352,9 +597,9 @@ | ||
| 352 | 597 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 353 | 598 | |
| 354 | 599 | global $wpdb; |
| 355 | 600 | |
| 356 | - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 601 | + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 357 | 602 | $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' ); |
| 358 | 603 | |
| 359 | 604 | $where = array( |
| 360 | 605 | 'post_status' => 'publish', |
| @@ -366,11 +611,11 @@ | ||
| 366 | 611 | 'limit' => 25, |
| 367 | 612 | 'order_by' => 'post_title', |
| 368 | 613 | ); |
| 369 | 614 | |
| 370 | - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 615 | + $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 616 | + $results = array(); | |
| 371 | 617 | |
| 372 | - $results = array(); | |
| 373 | 618 | foreach ( $pages as $page ) { |
| 374 | 619 | $results[] = array( |
| 375 | 620 | 'value' => $page->ID, |
| 376 | 621 | 'label' => $page->post_title, |
| @@ -380,11 +625,22 @@ | ||
| 380 | 625 | wp_send_json( $results ); |
| 381 | 626 | } |
| 382 | 627 | |
| 383 | 628 | /** |
| 384 | - * @deprecated 6.0 use FrmSettingsController::captcha_settings(). | |
| 629 | + * Shows a fake color picker. | |
| 630 | + * | |
| 631 | + * @since 6.25 | |
| 632 | + * | |
| 633 | + * @param string $color Color value. | |
| 634 | + * | |
| 635 | + * @return void | |
| 385 | 636 | */ |
| 386 | - public static function recaptcha_settings() { | |
| 387 | - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' ); | |
| 388 | - self::captcha_settings(); | |
| 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 | |
| 389 | 645 | } |
| 390 | 646 | } |