Initial commit

This commit is contained in:
Alexander Agnarson 2020-03-11 14:44:42 +01:00
commit b0607606ae
369 changed files with 85494 additions and 0 deletions

View file

@ -0,0 +1,37 @@
<?php
/**
* Handles CSS output for background-image.
*
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
/**
* Output overrides.
*/
class Kirki_Output_Property_Background_Image extends Kirki_Output_Property {
/**
* Modifies the value.
*
* @access protected
*/
protected function process_value() {
if ( is_array( $this->value ) && isset( $this->value['url'] ) ) {
$this->value = $this->value['url'];
}
if ( false === strpos( $this->value, 'gradient' ) && false === strpos( $this->value, 'url(' ) ) {
if ( empty( $this->value ) ) {
return;
}
if ( preg_match( '/^\d+$/', $this->value ) ) {
$this->value = 'url("' . set_url_scheme( wp_get_attachment_url( $this->value ) ) . '")';
} else {
$this->value = 'url("' . set_url_scheme( $this->value ) . '")';
}
}
}
}

View file

@ -0,0 +1,71 @@
<?php
/**
* Handles CSS output for background-position.
*
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
/**
* Output overrides.
*/
class Kirki_Output_Property_Background_Position extends Kirki_Output_Property {
/**
* Modifies the value.
*
* @access protected
*/
protected function process_value() {
$this->value = trim( $this->value );
// If you use calc() there, I suppose you know what you're doing.
// No need to process this any further, just exit.
if ( false !== strpos( $this->value, 'calc' ) ) {
return;
}
// If the value is initial or inherit, we don't need to do anything.
// Just exit.
if ( 'initial' === $this->value || 'inherit' === $this->value ) {
return;
}
$x_dimensions = array( 'left', 'center', 'right' );
$y_dimensions = array( 'top', 'center', 'bottom' );
// If there's a space, we have an X and a Y value.
if ( false !== strpos( $this->value, ' ' ) ) {
$xy = explode( ' ', $this->value );
$x = trim( $xy[0] );
$y = trim( $xy[1] );
// If x is not left/center/right, we need to sanitize it.
if ( ! in_array( $x, $x_dimensions, true ) ) {
$x = sanitize_text_field( $x );
}
if ( ! in_array( $y, $y_dimensions, true ) ) {
$y = sanitize_text_field( $y );
}
$this->value = $x . ' ' . $y;
return;
}
$x = 'center';
foreach ( $x_dimensions as $x_dimension ) {
if ( false !== strpos( $this->value, $x_dimension ) ) {
$x = $x_dimension;
}
}
$y = 'center';
foreach ( $y_dimensions as $y_dimension ) {
if ( false !== strpos( $this->value, $y_dimension ) ) {
$y = $y_dimension;
}
}
$this->value = $x . ' ' . $y;
}
}

View file

@ -0,0 +1,45 @@
<?php
/**
* Handles CSS output for font-family.
*
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
/**
* Output overrides.
*/
class Kirki_Output_Property_Font_Family extends Kirki_Output_Property {
/**
* Modifies the value.
*
* @access protected
*/
protected function process_value() {
$google_fonts_array = Kirki_Fonts::get_google_fonts();
$family = $this->value;
if ( is_array( $this->value ) && isset( $this->value[0] ) && isset( $this->value[1] ) ) {
$family = $this->value[0];
}
// Make sure the value is a string.
// If not, then early exit.
if ( ! is_string( $family ) ) {
return;
}
// Hack for standard fonts.
$family = str_replace( '&quot;', '"', $family );
// Add double quotes if needed.
if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) {
$this->value = '"' . $family . '"';
}
$this->value = html_entity_decode( $family, ENT_QUOTES );
}
}

View file

@ -0,0 +1,64 @@
<?php
/**
* Handles CSS properties.
* Extend this class in order to handle exceptions.
*
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
/**
* Output for CSS properties.
*/
class Kirki_Output_Property {
/**
* The property we're modifying.
*
* @access protected
* @var string
*/
protected $property;
/**
* The value
*
* @access protected
* @var string|array
*/
protected $value;
/**
* Constructor.
*
* @access public
* @param string $property The CSS property we're modifying.
* @param mixed $value The value.
*/
public function __construct( $property, $value ) {
$this->property = $property;
$this->value = $value;
$this->process_value();
}
/**
* Modifies the value.
*
* @access protected
*/
protected function process_value() {
}
/**
* Gets the value.
*
* @access protected
*/
public function get_value() {
return $this->value;
}
}