• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Featured_Content::validate_settings() – Validate featured content settings.

You appear to be a bot. Output may be restricted

Description

Validate featured content settings.

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().

Usage

$array = Featured_Content::validate_settings( $input );

Parameters

$input
( array ) required – Array of settings input.

Returns

array Validated settings output.

Source

File name: twentyfourteen/inc/featured-content.php


Lines:

1 to 29 of 29
  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;

    // Delete the featured post IDs transient.
    self::delete_transient();

    return $output;
  }
 

 View on Trac

Published: 19th December 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: Featured_Content::validate_settings
Class ref: Featured_Content
Plugin ref: Twenty Fourteen
Version: 3.0
Sourcefile: inc/featured-content.php
File ref: inc/featured-content.php
Deprecated?: No
API Letters: C,F,S,V

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 5.6.2. PHP: 7.3.27
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites