File: /disk001/machen/www/support/wp-content/themes/wp-moose/inc/shapes.php
<?php
if ( ! function_exists( 'wp_moose_get_shapes' ) ) {
/**
* Get all shapes
*/
function wp_moose_get_shapes( $shape = null ) {
$shapes = array(
'none' => array(
'title' => _x( 'None', 'Shapes', 'wp-moose' ),
'options' => array(),
),
'mountains' => array(
'title' => _x( 'Mountains', 'Shapes', 'wp-moose' ),
'options' => array( 'wp_moose_hero_shape_flip' ),
),
'drops' => array(
'title' => _x( 'Drops', 'Shapes', 'wp-moose' ),
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'clouds' => array(
'title' => _x( 'Clouds (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'zigzag' => array(
'title' => _x( 'Zigzag (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array(),
),
'pyramids' => array(
'title' => _x( 'Pyramids (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'triangle' => array(
'title' => _x( 'Triangle (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_invert' ),
),
'triangle-asymmetrical' => array(
'title' => _x( 'Triangle Asymmetrical (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'tilt' => array(
'title' => _x( 'Tilt (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip' ),
),
'opacity-tilt' => array(
'title' => _x( 'Tilt Opacity (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip' ),
),
'opacity-fan' => array(
'title' => _x( 'Fan Opacity (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array(),
),
'curve' => array(
'title' => _x( 'Curve (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_invert' ),
),
'curve-asymmetrical' => array(
'title' => _x( 'Curve Asymmetrical (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'waves' => array(
'title' => _x( 'Waves (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip', 'wp_moose_hero_shape_invert' ),
),
'wave-brush' => array(
'title' => _x( 'Waves Brush (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip' ),
),
'waves-pattern' => array(
'title' => _x( 'Waves Pattern (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_flip' ),
),
'arrow' => array(
'title' => _x( 'Arrow (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_invert' ),
),
'split' => array(
'title' => _x( 'Split (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_invert' ),
),
'book' => array(
'title' => _x( 'Book (Pro)', 'Shapes', 'wp-moose' ),
'folder' => 'images/shapes__premium_only',
'options' => array( 'wp_moose_hero_shape_invert' ),
),
);
if ( $shape !== null ) {
return isset( $shapes[ $shape ] ) ? $shapes[ $shape ] : null;
}
return $shapes;
}
}
if ( ! function_exists( 'wp_moose_get_shape_path' ) ) {
/**
* Get shape path
*
* @param $shape
* @param false $is_negative
*
* @return array|mixed|string|string[]
*/
function wp_moose_get_shape_path( $shape, $is_negative = false ) {
$shape_data = wp_moose_get_shapes( $shape );
if ( ! $shape_data ) {
return '';
}
if ( isset( $shape_data['path'] ) ) {
$path = $shape_data['path'];
return ( $is_negative ) ? str_replace( '.svg', '-negative.svg', $path ) : $path;
}
$folder = 'images/shapes/';
if ( isset( $shape_data['folder'] ) ) {
$folder = trailingslashit( $shape_data['folder'] );
}
$file_name = $shape;
if ( $is_negative ) {
$file_name .= '-negative';
}
return wp_moose_asset_path( $folder . $file_name . '.svg' );
}
}
if ( ! function_exists( 'wp_moose_hero_shape_divider' ) ) {
/**
* Output shape divider
*/
function wp_moose_hero_shape_divider() {
$shape = get_wp_moose_option( 'wp_moose_hero_shape_divider' );
$shape_data = wp_moose_get_shapes( $shape );
if ( ! $shape_data ) {
return;
}
$negative = get_wp_moose_option( 'wp_moose_hero_shape_invert' )
&& in_array( 'wp_moose_hero_shape_invert', $shape_data['options'] );
$shape_path = wp_moose_get_shape_path( $shape, $negative );
if ( ! is_file( $shape_path ) || ! is_readable( $shape_path ) ) {
return;
}
?>
<div class="wp-moose-hero-shape-divider" data-negative="<?php
// PHPCS - the variable $negative is getting a setting value with a strict structure.
echo var_export( $negative ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>">
<?php
// PHPCS - The file content is being read from a strict file path structure.
echo file_get_contents( $shape_path ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</div>
<?php
}
}