/** * Sanitize checkbox fields * From WordPress SEO by Yoast class-wpsep-options.php * * @since 1.0.0 * @param array $input The field value * @return string $input '1' if true, empty string otherwise */ public function sanitize_checkbox_field($input) { $true = array('1', 'true', 'True', 'TRUE', 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'); // String if (is_string($input)) { $input = trim($input); if (in_array($input, $true, true)) { return '1'; } } // Boolean if (is_bool($input) && $input) { return '1'; } // Integer if (is_int($input) && 1 === $input) { return '1'; } // Float if (is_float($input) && !is_nan($input) && (double) 1 === $input) { return '1'; } return __return_empty_string(); }
/** * Grab CSS styles from styles array into CSS string. * * @since 1.0.0 * * @param array $style Defined styles array. */ public static function prepare_styles($style = array()) { if (empty($style)) { __return_empty_string(); } $result = ''; foreach ($style as $property => $value) { if (empty($value)) { continue; } if ('background-image' == $property) { $value = 'url(' . $value . ')'; } $result .= $property . ':' . $value . ';'; } return $result; }