Plugin Directory

Changeset 1782506


Ignore:
Timestamp:
12/07/2017 09:51:16 AM (8 years ago)
Author:
jasie
Message:

added validation and error feedback for font-size fields, on settings page (admin)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • widget-pagination/trunk/admin/class-widget-pagination-admin.php

    r1781203 r1782506  
    221221            if (!empty($value)) {
    222222                // Color picker inputs
    223                 if (strpos($key, 'color') !== false ) {
     223                if (strpos($key, 'color') !== false) {
    224224                    $value = sanitize_text_field($value);
    225225
     
    228228                                $key, // Setting title
    229229                                $key . '_texterror', // Error ID
    230                                 __('Please enter a valid hex value color', $this->plugin_name) . ' (' . $key . ')', // Error message //_e('Please enter a valid hex value color', $this->plugin_name)
     230                                __('Please enter a valid hex value color', $this->plugin_name) . ' (' . $key . ')', // Error message
    231231                                'error' // Type of message
    232232                        );
    233233                    }
    234234                }
    235 //              else {
    236 //              }
     235                // Font size inputs
     236                elseif (strpos($key, 'font-size') !== false) {
     237                    if (strpos($value, 'px') === false && strpos($value, 'em') === false && strpos($value, 'rem') === false) {
     238                        add_settings_error(
     239                                $key, // Setting title
     240                                $key . '_texterror', // Error ID
     241                                __('Please enter a valid font size', $this->plugin_name) . ' (' . $key . ')', // Error message
     242                                'error' // Type of message
     243                        );
     244                    }
     245                }
    237246            }
    238247        }
Note: See TracChangeset for help on using the changeset viewer.