PHP Classes

File: includes/compatibility.php

Recommend this page to a friend!
  Classes of Marco Cesarato   PHP API Database   includes/compatibility.php   Download  
File: includes/compatibility.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP API Database
Provide access to database records via REST API
Author: By
Last change: Reformatted code (php-cs-fixer)

Added code standard,
Added hooks git for code standard,
Fixed parse where on null elements
Date: 5 years ago
Size: 1,359 bytes
 

Contents

Class file image Download
<?php
/**
 * Compatibility.
 *
 * @author Marco Cesarato <cesarato.developer@gmail.com>
 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
 *
 * @see https://github.com/marcocesarato/Database-Web-API
 */
if (!function_exists('shortcode_atts')) {
   
/**
     * Combine user attributes with known attributes and fill in defaults when needed.
     * The pairs should be considered to be all of the attributes which are
     * supported by the caller and given as a list. The returned attributes will
     * only contain the attributes in the $pairs list.
     * If the $atts list has unsupported attributes, then they will be ignored and
     * removed from the final returned list.
     *
     * @from Wordpress
     *
     * @param array $pairs entire list of supported attributes and their defaults
     * @param array $atts user defined attributes in shortcode tag
     *
     * @return array combined and filtered attribute list
     *
     * @since 2.5
     */
   
function shortcode_atts($pairs, $atts)
    {
       
$atts = (array)$atts;
       
$out = [];
        foreach (
$pairs as $name => $default) {
            if (
array_key_exists($name, $atts)) {
               
$out[$name] = $atts[$name];
            } else {
               
$out[$name] = $default;
            }
        }

        return
$out;
    }
}