Featured_Content::validate_settings PHP Méthode

validate_settings() public static méthode

Make sure that all user supplied content is in an expected format before saving to the database. This function will also delete the transient set in Featured_Content::get_featured_content().
public static validate_settings ( array $input ) : array
$input array
Résultat array $output
        public static function validate_settings($input)
        {
            $output = array();
            if (empty($input['tag-name'])) {
                $output['tag-id'] = 0;
            } else {
                $term = get_term_by('name', $input['tag-name'], 'post_tag');
                if ($term) {
                    $output['tag-id'] = $term->term_id;
                } else {
                    $new_tag = wp_create_tag($input['tag-name']);
                    if (!is_wp_error($new_tag) && isset($new_tag['term_id'])) {
                        $output['tag-id'] = $new_tag['term_id'];
                    }
                }
                $output['tag-name'] = $input['tag-name'];
            }
            $output['hide-tag'] = isset($input['hide-tag']) && $input['hide-tag'] ? 1 : 0;
            $output['show-all'] = isset($input['show-all']) && $input['show-all'] ? 1 : 0;
            self::delete_transient();
            return $output;
        }