Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,675 @@
<?php
/**
* This file handles the Block Patterns Register.
*
* @package BWFBlocks
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Register Block Patterns.
*
*/
if ( ! class_exists( 'BWF_EMAILBLOCKS_CSS' ) ) {
#[AllowDynamicProperties]
class BWF_EMAILBLOCKS_CSS {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private static $gFonts = [
'Arvo',
'Lato',
'Lora',
'Merriweather',
'Merriweather Sans',
'Noticia Text',
'Open Sans',
'Playfair Display',
'Roboto',
'Source Sans Pro'
];
/**
* Initiator.
*
* @return object initialized object of class.
* @since 1.2.0
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get Border Radius CSS
*
* @param array $attributes Border array
* @param string $key Key to lookup in attributes
* @param string $screen Screen value
* @param bool $important Flag for !important
* @param string $default Default CSS value
* @param string $g_key Global key for fallback values
*
* @return string CSS for border radius
*/
public function getBorderRadius( $attributes, $key, $screen, $important = false, $default = '', $g_key = '' ) {
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
$isImportant = $important ? ' !important' : '';
$unit = isset( $attributes[ $key ][ $screen ]['radius_unit'] ) ? $attributes[ $key ][ $screen ]['radius_unit'] : 'px';
// Function to get value from attributes or return null if not found
$getValue = function ( $attributeKey ) use ( $attributes, $key, $screen ) {
return isset( $attributes[ $key ][ $screen ][ $attributeKey ] ) && $attributes[ $key ][ $screen ][ $attributeKey ] !== '' ? $attributes[ $key ][ $screen ][ $attributeKey ] : null;
};
// Get the radius values from attributes
$topLeft = $getValue( 'top-left' );
$topRight = $getValue( 'top-right' );
$bottomLeft = $getValue( 'bottom-left' );
$bottomRight = $getValue( 'bottom-right' );
// Check if all attributes values are missing and if g_key is available in globals
if ( ( $topLeft === null && $topRight === null && $bottomLeft === null && $bottomRight === null ) && isset( $globals[ $g_key ][ $screen ] ) ) {
$topLeft = isset( $globals[ $g_key ][ $screen ]['top-left'] ) ? $globals[ $g_key ][ $screen ]['top-left'] : null;
$topRight = isset( $globals[ $g_key ][ $screen ]['top-right'] ) ? $globals[ $g_key ][ $screen ]['top-right'] : null;
$bottomLeft = isset( $globals[ $g_key ][ $screen ]['bottom-left'] ) ? $globals[ $g_key ][ $screen ]['bottom-left'] : null;
$bottomRight = isset( $globals[ $g_key ][ $screen ]['bottom-right'] ) ? $globals[ $g_key ][ $screen ]['bottom-right'] : null;
$unit = isset( $globals[ $g_key ][ $screen ]['radius_unit'] ) ? $globals[ $g_key ][ $screen ]['radius_unit'] : 'px';
}
// If all values are still missing, return the default
if ( $topLeft === null && $topRight === null && $bottomLeft === null && $bottomRight === null ) {
return $default;
}
// Construct a single border-radius property
$radius = sprintf( 'border-radius: %s%s %s%s %s%s %s%s%s;', $topLeft !== null ? $topLeft : '0', $unit, $topRight !== null ? $topRight : '0', $unit, $bottomRight !== null ? $bottomRight : '0', $unit, $bottomLeft !== null ? $bottomLeft : '0', $unit, $isImportant );
return $radius;
}
public function getBorderWidth( $attributes, $key, $screen, $important = false ) {
$width = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ) {
$border = $attributes[ $key ];
if ( isset( $border[ $screen ]['top'] ) && $border[ $screen ]['top'] !== '' && $border[ $screen ]['top'] !== '0' ) {
$width .= 'border-top-width: ' . $border[ $screen ]['top'] . $border[ $screen ]['unit'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ]['bottom'] ) && $border[ $screen ]['bottom'] !== '' && $border[ $screen ]['bottom'] !== '0' ) {
$width .= 'border-bottom-width: ' . $border[ $screen ]['bottom'] . $border[ $screen ]['unit'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ]['left'] ) && $border[ $screen ]['left'] !== '' && $border[ $screen ]['left'] !== '0' ) {
$width .= 'border-left-width: ' . $border[ $screen ]['left'] . $border[ $screen ]['unit'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ]['right'] ) && $border[ $screen ]['right'] !== '' && $border[ $screen ]['right'] !== '0' ) {
$width .= 'border-right-width: ' . $border[ $screen ]['right'] . $border[ $screen ]['unit'] . ( $important ? ' !important;' : ';' );
}
}
return $width;
}
public function getBorderStyle( $attributes, $key, $screen, $important = false ) {
$style = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ) {
$border = $attributes[ $key ];
if ( isset( $border[ $screen ] ) && isset( $border[ $screen ]['top'] ) && ( $border[ $screen ]['top'] === '' || $border[ $screen ]['top'] === '0' ) ) {
$style .= ! $important ? 'border-top-style:none;' : '';
} else if ( isset( $border[ $screen ]['style'] ) ) {
$style .= 'border-top-style: ' . $border[ $screen ]['style'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ] ) && isset( $border[ $screen ]['bottom'] ) && ( $border[ $screen ]['bottom'] === '' || $border[ $screen ]['bottom'] === '0' ) ) {
$style .= ! $important ? 'border-bottom-style:none;' : '';
} else if ( isset( $border[ $screen ]['style'] ) ) {
$style .= 'border-bottom-style: ' . $border[ $screen ]['style'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ] ) && isset( $border[ $screen ]['left'] ) && ( $border[ $screen ]['left'] === '' || $border[ $screen ]['left'] === '0' ) ) {
$style .= ! $important ? 'border-left-style:none;' : '';
} else if ( isset( $border[ $screen ]['style'] ) ) {
$style .= 'border-left-style: ' . $border[ $screen ]['style'] . ( $important ? ' !important;' : ';' );
}
if ( isset( $border[ $screen ] ) && isset( $border[ $screen ]['right'] ) && ( $border[ $screen ]['right'] === '' || $border[ $screen ]['right'] === '0' ) ) {
$style .= ! $important ? 'border-right-style:none;' : '';
} else if ( isset( $border[ $screen ]['style'] ) ) {
$style .= 'border-right-style: ' . $border[ $screen ]['style'] . ( $important ? ' !important;' : ';' );
}
}
return $style;
}
public function getBorderColor( $attributes, $key, $screen, $important = false ) {
$color = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ) {
$border = $attributes[ $key ];
$color .= ! empty( $border[ $screen ]['color_top'] ) ? ( 'border-top-color: ' . $border[ $screen ]['color_top'] . ( $important ? ' !important;' : ';' ) ) : '';
$color .= ! empty( $border[ $screen ]['color_bottom'] ) ? ( 'border-bottom-color: ' . $border[ $screen ]['color_bottom'] . ( $important ? ' !important;' : ';' ) ) : '';
$color .= ! empty( $border[ $screen ]['color_right'] ) ? ( 'border-right-color: ' . $border[ $screen ]['color_right'] . ( $important ? ' !important;' : ';' ) ) : '';
$color .= ! empty( $border[ $screen ]['color_left'] ) ? ( 'border-left-color: ' . $border[ $screen ]['color_left'] . ( $important ? ' !important;' : ';' ) ) : '';
}
return $color;
}
public function getPadding( $attributes, $key, $screen, $important = false, $default = '', $g_key = '' ) {
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
$isImportant = $important ? ' !important' : '';
$unit = isset( $attributes[ $key ][ $screen ]['unit'] ) ? $attributes[ $key ][ $screen ]['unit'] : 'px';
// Function to get value from attributes or return '0' if not found
$getValue = function ( $attributeKey ) use ( $attributes, $key, $screen ) {
return isset( $attributes[ $key ][ $screen ][ $attributeKey ] ) && $attributes[ $key ][ $screen ][ $attributeKey ] !== '' ? $attributes[ $key ][ $screen ][ $attributeKey ] : '0';
};
// Get padding values from attributes
$top = $getValue( 'top' );
$right = $getValue( 'right' );
$bottom = $getValue( 'bottom' );
$left = $getValue( 'left' );
// Check if all attribute values are missing and if g_key is available in globals
if ( ( $top === '0' && $right === '0' && $bottom === '0' && $left === '0' ) && isset( $globals[ $g_key ][ $screen ] ) ) {
$top = isset( $globals[ $g_key ][ $screen ]['top'] ) ? $globals[ $g_key ][ $screen ]['top'] : '0';
$right = isset( $globals[ $g_key ][ $screen ]['right'] ) ? $globals[ $g_key ][ $screen ]['right'] : '0';
$bottom = isset( $globals[ $g_key ][ $screen ]['bottom'] ) ? $globals[ $g_key ][ $screen ]['bottom'] : '0';
$left = isset( $globals[ $g_key ][ $screen ]['left'] ) ? $globals[ $g_key ][ $screen ]['left'] : '0';
$unit = isset( $globals[ $g_key ][ $screen ]['unit'] ) ? $globals[ $g_key ][ $screen ]['unit'] : 'px';
}
// If all values are still zero, return the default
if ( $top === '0' && $right === '0' && $bottom === '0' && $left === '0' ) {
return $default;
}
// Construct a single padding property
$padding = sprintf( 'padding: %s%s %s%s %s%s %s%s%s;', $top, $unit, $right, $unit, $bottom, $unit, $left, $unit, $isImportant );
return $padding;
}
public function getMsoPadding( $attributes, $key, $screen, $important = false, $default = '', $g_key = '' ) {
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
$isImportant = $important ? ' !important' : '';
$unit = isset( $attributes[ $key ][ $screen ]['unit'] ) ? $attributes[ $key ][ $screen ]['unit'] : 'px';
// Function to get value from attributes or return '0' if not found
$getValue = function ( $attributeKey ) use ( $attributes, $key, $screen ) {
return isset( $attributes[ $key ][ $screen ][ $attributeKey ] ) && $attributes[ $key ][ $screen ][ $attributeKey ] !== '' ? $attributes[ $key ][ $screen ][ $attributeKey ] : '0';
};
// Get padding values from attributes
$top = $getValue( 'top' );
$right = $getValue( 'right' );
$bottom = $getValue( 'bottom' );
$left = $getValue( 'left' );
// Check if all attribute values are missing and if g_key is available in globals
if ( ( $top === '0' && $right === '0' && $bottom === '0' && $left === '0' ) && isset( $globals[ $g_key ][ $screen ] ) ) {
$top = isset( $globals[ $g_key ][ $screen ]['top'] ) ? $globals[ $g_key ][ $screen ]['top'] : '0';
$right = isset( $globals[ $g_key ][ $screen ]['right'] ) ? $globals[ $g_key ][ $screen ]['right'] : '0';
$bottom = isset( $globals[ $g_key ][ $screen ]['bottom'] ) ? $globals[ $g_key ][ $screen ]['bottom'] : '0';
$left = isset( $globals[ $g_key ][ $screen ]['left'] ) ? $globals[ $g_key ][ $screen ]['left'] : '0';
$unit = isset( $globals[ $g_key ][ $screen ]['unit'] ) ? $globals[ $g_key ][ $screen ]['unit'] : 'px';
}
// If all values are still zero, return the default
if ( $top === '0' && $right === '0' && $bottom === '0' && $left === '0' ) {
return $default;
}
// Construct a single mso-padding property
$msoPadding = sprintf( 'mso-padding-alt: %s%s %s%s %s%s %s%s%s;', $top, $unit, $right, $unit, $bottom, $unit, $left, $unit, $isImportant );
return $msoPadding;
}
public function getFontStyles( $attributes, $key, $screen = 'desktop', $important = false, $default = '' ) {
$newFont = '';
$has_important = $important ? ' !important;' : ';';
$font_styles = isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ? $attributes[ $key ][ $screen ] : [];
if ( ! empty( $font_styles ) ) {
if ( isset( $font_styles['size'] ) && $font_styles['size'] !== '' ) {
$newFont .= "font-size: " . $font_styles['size'] . "px$has_important";
}
if ( isset( $font_styles['family'] ) && $font_styles['family'] !== '' ) {
$newFont .= "font-family:" . $font_styles['family'] . $has_important;
} else if ( false !== $default && false === strpos( $newFont, 'font-family' ) ) {
$newFont .= "font-family: arial, Helvetica, sans-serif" . $has_important;
}
if ( isset( $font_styles['weight'] ) && $font_styles['weight'] !== '' ) {
$newFont .= "font-weight:" . $font_styles['weight'] . $has_important;
}
}
// return default if empty
// if( empty( $newFont ) ) {
// $default .= !str_contains($default, 'font-family') && $screen === 'desktop' ? 'font-family: Arial, Helvetica, sans-serif;' : '';
// return $default;
// }
$newFont .= ( false === strpos( $newFont, 'font-size' ) && false !== strpos( $default, 'font-size' ) && $screen === 'desktop' ) ? $default : '';
return '' . $newFont;
}
private function getFontWithBackupFont( $font_family, $globals ) {
if ( in_array( $font_family, self::$gFonts ) && isset( $globals ) && isset( $globals['backupFont'] ) && isset( $globals['backupFont']['desktop'] ) && isset( $globals['backupFont']['desktop']['family'] ) && ! empty( $globals['backupFont']['desktop']['family'] ) ) {
return $font_family . ',' . $globals['backupFont']['desktop']['family'];
}
return $font_family;
}
/**
* Funtion to get font family from attributes / global setting or default
*/
public function getFontFamily( $attrs = [], $key = 'font', $screen = 'desktop', $default_val = '', $important = false ) {
$globals = isset( $attrs['global'] ) ? $attrs['global'] : ( class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [] ); //get global setting from atttributes if wc block else static method
$has_important = false !== $important ? ' !important;' : ';';
$font_family = '';
if ( false === $default_val && ( empty( $attrs[ $key ] ) || empty( $attrs[ $key ][ $screen ] ) ) && ( empty( $globals ) || empty( $globals['font']['desktop']['family'] ) ) ) {
return $font_family;
}
if ( ! empty( $attrs[ $key ] ) && ! empty( $attrs[ $key ][ $screen ] ) && ! empty( $attrs[ $key ][ $screen ]['family'] ) ) {
$font_family = 'font-family: ' . $this->getFontWithBackupFont( $attrs[ $key ][ $screen ]['family'], $globals ) . $has_important;
return $font_family;
}
if ( ! empty( $globals['font'] ) && ! empty( $globals['font']['desktop'] ) && ! empty( $globals['font']['desktop']['family'] ) ) {
$font_family = 'font-family: ' . $this->getFontWithBackupFont( $globals['font']['desktop']['family'], $globals ) . $has_important;
return $font_family;
}
if ( ! empty( $default_val ) ) {
return ( false !== strpos( $default_val, 'font-family' ) ) ? $default_val : 'font-family: ' . $default_val . $has_important;
} else if ( false === $default_val ) {
return '';
}
return 'font-family: Arial, Helvetica, sans-serif' . $has_important;
}
/**
* Funtion to get font size from attributes / global setting or default
* * pass "false" $g_key value if don't need global settings
*/
public function getFontSize( $attrs = [], $key = 'font', $screen = 'desktop', $g_key = 'font', $default_val = '', $important = false ) {
$globals = isset( $attrs['global'] ) ? $attrs['global'] : ( class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [] );
$important = 'mobile' === $screen ? true : $important;
$has_important = false !== $important ? 'px !important;' : 'px;';
$font_size = '';
if ( false === $default_val && ( empty( $attrs ) || empty( $attrs[ $key ] ) || empty( $attrs[ $key ][ $screen ] ) ) && ( empty( $globals[ $g_key ] ) || empty( $globals[ $g_key ][ $screen ]['size'] ) ) ) {
return $font_size;
}
if ( ! empty( $attrs[ $key ] ) && ! empty( $attrs[ $key ][ $screen ] ) && ! empty( $attrs[ $key ][ $screen ]['size'] ) ) {
return 'font-size: ' . $attrs[ $key ][ $screen ]['size'] . $has_important;
}
if ( ! empty( $globals[ $g_key ] ) && ! empty( $globals[ $g_key ][ $screen ] ) && ! empty( $globals[ $g_key ][ $screen ]['size'] ) ) {
return 'font-size: ' . $globals[ $g_key ][ $screen ]['size'] . $has_important;
}
if ( ! empty( $default_val ) ) {
return ( false !== strpos( $default_val, 'font-size' ) ) ? $default_val : 'font-size: ' . $default_val . $has_important;
} else if ( false === $default_val ) {
return '';
}
return '';
}
public function verticalAlignment( $vAlign ) {
if ( $vAlign ) {
$vAlignValue = $vAlign === 'top' ? 'align-self: flex-start;width: 100%;' : '';
$vAlignValue .= $vAlign === 'center' ? 'align-self: center;width: 100%;' : '';
$vAlignValue .= $vAlign === 'bottom' ? 'align-self: flex-end;width: 100%;' : '';
return $vAlignValue;
}
}
public function backgroundCss( $attributes, $key, $screen, $important = false ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ) {
$gradient = '';
$image = '';
$color = '';
$repeat = 'repeat';
$size = 'auto';
$position = 'top';
$background = $attributes[ $key ][ $screen ];
foreach ( $background as $key => $value ) {
if ( $value ) {
if ( $key === 'gradient' ) {
$gradient = $value;
} else if ( $key === 'image' ) {
$image = $value;
} else if ( $key === 'color' ) {
$color = $value;
} else if ( $key === 'repeat' ) {
if ( ! empty( $value ) ) {
$repeat = $value;
}
} else if ( $key === 'size' ) {
if ( ! empty( $value ) ) {
$size = $value;
}
} else if ( $key === 'position' ) {
if ( ! empty( $value ) ) {
$position = ( $value[0] ? $value[0] * 100 : 0 ) . '% ' . ( $value[1] ? $value[1] * 100 : 0 ) . '%';
}
}
}
}
if ( $image && $gradient ) {
$css .= sprintf( "background: %s url(%s) %s / %s %s, %s", $color, $image['url'], $position, $size, $repeat, $gradient . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-repeat: %s", $repeat . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-size: %s", $size . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-position: %s", $position . ( $important ? ' !important;' : ';' ) );
} else if ( $image ) {
$css .= sprintf( "background: %s url(%s) %s / %s %s", $color, $image['url'], $position, $size, $repeat . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-repeat: %s", $repeat . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-size: %s", $size . ( $important ? ' !important;' : ';' ) );
$css .= sprintf( "background-position: %s", $position . ( $important ? ' !important;' : ';' ) );
} else if ( $gradient ) {
$css .= sprintf( "background: %s", $gradient . ( $important ? ' !important;' : ';' ) );
} else {
if ( ! empty( $color ) ) {
$css .= sprintf( "background: %s", $color . ( $important ? ' !important;' : ';' ) );
}
}
}
return $css;
}
public function getAlignment( $attributes, $key, $screen, $important = false ) {
if ( ! isset( $attributes[ $key ] ) ) {
return 'margin-left: auto' . ( $important ? ' !important;' : ';' ) . ' margin-right:auto' . ( $important ? ' !important;' : ';' );
}
if ( isset( $attributes[ $key ][ $screen ] ) ) {
switch ( $attributes[ $key ][ $screen ] ) {
case 'center':
return 'margin: auto' . ( $important ? ' !important;' : ';' );
case 'left':
return 'margin-right: auto' . ( $important ? ' !important;' : ';' ) . 'margin-left:0' . ( $important ? ' !important;' : ';' );
case 'right':
return 'margin-left: auto' . ( $important ? ' !important;' : ';' ) . 'margin-right:0' . ( $important ? ' !important;' : ';' );
default:
return 'margin: auto' . ( $important ? ' !important;' : ';' );
}
}
}
public function getColor( $attributes, $key = '', $screen = 'desktop', $g_key = 'color', $important = false, $default = '' ) {
$css = '';
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
if ( $key !== '' && isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && ! empty( $attributes[ $key ][ $screen ] ) ) {
$css .= 'color: ' . $attributes[ $key ][ $screen ] . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) && isset( $globals[ $g_key ] ) && isset( $globals[ $g_key ][ $screen ] ) && ! empty( $globals[ $g_key ][ $screen ] ) ) {
$css .= 'color: ' . $globals[ $g_key ][ $screen ] . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
public function getWidth( $attributes, $key, $screen, $important = false ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && isset( $attributes[ $key ][ $screen ]['value'] ) ) {
$css .= 'width: ' . $attributes[ $key ][ $screen ]['value'] . ( isset( $attributes[ $key ][ $screen ]['unit'] ) ? $attributes[ $key ][ $screen ]['unit'] : 'px' ) . ( $important ? ' !important;' : ';' );
}
return $css;
}
public function textAlign( $attributes, $key, $screen, $important = false, $default = '' ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && ! empty( $attributes[ $key ][ $screen ] ) ) {
$css .= 'text-align: ' . $attributes[ $key ][ $screen ] . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
/**
* Get color CSS
*
* @param array $attributes block attributes
* @param string $key color key
* @param string $screen screen value
* @param boolean $important include important in css property
*
* @return string css
*/
public function getBgColor( $attributes, $key, $screen, $g_key = 'buttonBackground', $important = false, $default = '' ) {
$css = '';
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && ! empty( $attributes[ $key ][ $screen ] ) ) {
if ( is_array( $attributes[ $key ][ $screen ] ) ) {
foreach ( $attributes[ $key ][ $screen ] as $attr_key => $value ) {
if ( ! empty( $value ) ) {
$css .= 'background-' . $attr_key . ': ' . $value . ( $important ? ' !important;' : ';' );
}
}
} else {
$css .= 'background-color: ' . $attributes[ $key ][ $screen ] . ( $important ? ' !important;' : ';' );
}
}
if ( empty( $css ) && isset( $globals[ $g_key ] ) && isset( $globals[ $g_key ][ $screen ] ) && isset( $globals[ $g_key ][ $screen ]['color'] ) && ! empty( $globals[ $g_key ][ $screen ]['color'] ) ) {
$css .= 'background-color: ' . $globals[ $g_key ][ $screen ]['color'] . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
public function getLineHeight( $attributes, $key, $screen, $important = false ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) ) {
if ( isset( $attributes[ $key ][ $screen ]['value'] ) && ! empty( $attributes[ $key ][ $screen ]['value'] ) ) {
$unit = '';
$css .= 'line-height: ' . $attributes[ $key ][ $screen ]['value'] . $unit . ( $important ? ' !important;' : ';' );
}
}
return $css;
}
public function replaceIfEmpty( $value, $alternate ) {
if ( empty( $value ) ) {
return $alternate;
}
return $value;
}
public function handleAutoWidth( $attributes, $autoWidthKey, $widthKey, $screen, $g_key = [ 'buttonAuto', 'buttonSize' ], $important = false, $subAttr = '', $default_val = '' ) {
$css = '';
$globals = class_exists( 'BWFCRM_Block_Editor' ) ? BWFCRM_Block_Editor::$global_settings : [];
$autoWidthKeyVal = $attributes[ $autoWidthKey ] ?? '';
$widthKeyVal = $attributes[ $widthKey ] ?? '';
if ( empty( $autoWidthKeyVal ) && ! empty( $g_key ) ) {
$autoWidthKeyVal = $globals[ $g_key[0] ] ?? '';
}
if ( empty( $widthKeyVal ) && ! empty( $g_key ) ) {
$widthKeyVal = $globals[ $g_key[1] ] ?? '';
}
$autoWidth = $autoWidthKeyVal;
$width = $widthKeyVal;
if ( $screen === 'desktop' && ( ! isset( $autoWidth ) || ! isset( $autoWidth[ $screen ] ) ) ) {
return $css;
}
if ( $important && isset( $autoWidth[ $screen ] ) && $autoWidth[ $screen ] ) {
return 'width: auto !important; max-width: 100%;';
}
if ( isset( $width[ $screen ] ) && ! ( isset( $autoWidth[ $screen ] ) && $autoWidth[ $screen ] ) ) {
if ( ! empty( $subAttr ) ) {
$css .= 'width: ' . $width[ $screen ][ $subAttr ] . ( $important ? '% !important;' : '%;' );
} else {
$css .= 'width: ' . $width[ $screen ] . ( $important ? '% !important;' : '%;' );
}
}
return empty( $css ) ? $default_val : $css;
}
public function getWidthValue( $attributes, $autoWidthKey, $widthKey, $screen, $subAttr = '' ) {
$css = 'auto';
if ( ! isset( $attributes[ $autoWidthKey ] ) || ! isset( $attributes[ $autoWidthKey ][ $screen ] ) ) {
return $css;
}
if ( isset( $attributes[ $widthKey ][ $screen ] ) && $attributes[ $autoWidthKey ][ $screen ] === false ) {
if ( ! empty( $subAttr ) ) {
$css = $attributes[ $widthKey ][ $screen ][ $subAttr ] . '%';
} else {
$css = $attributes[ $widthKey ][ $screen ] . '%;';
}
}
return $css;
}
public function getProperty( $prop, $attributes, $key, $screen, $important = false, $default = '' ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && ! empty( $attributes[ $key ][ $screen ] ) ) {
$css .= $prop . ': ' . $attributes[ $key ][ $screen ] . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
public function getBold( $attributes, $key, $screen, $important = false, $default = '' ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && $attributes[ $key ][ $screen ] === true ) {
$css .= 'font-weight: 600' . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
public function getItalic( $attributes, $key, $screen, $important = false, $default = '' ) {
$css = '';
if ( isset( $attributes[ $key ] ) && isset( $attributes[ $key ][ $screen ] ) && $attributes[ $key ][ $screen ] === true ) {
$css .= 'font-style: italic' . ( $important ? ' !important;' : ';' );
}
if ( empty( $css ) ) {
return $default;
}
return $css;
}
public function getVisibilityCss( $attributes, $screen ) {
$isHidden = isset( $attributes['isHidden'] ) && isset( $attributes['isHidden'][ $screen ] ) && $attributes['isHidden'][ $screen ] === true;
$css = '';
if ( $screen === 'desktop' ) {
if ( $isHidden ) {
$css .= 'display: none; mso-hide: all;max-height: 0px;overflow: hidden;';
}
} else {
$css .= 'mso-hide: unset !important;';
if ( $isHidden ) {
$css .= 'display: none !important;mso-hide: all !important;max-height: 0px !important;overflow: hidden !important;';
} else {
$css .= 'display: table-cell !important;';
if ( $isHidden ) {
$css .= 'max-height: unset !important;overflow: unset !important;';
}
}
}
return $css;
}
}
}
/**
* Access for css functions
*
* @return bool True if the pattern was registered with success and false otherwise.
*/
if ( ! function_exists( 'bwf_css' ) ) {
function bwf_css() {
return BWF_EMAILBLOCKS_CSS::get_instance();
}
}

View File

@@ -0,0 +1,3 @@
<?php
// Silence is golden.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,3 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,251 @@
<?php
if ( ! class_exists( 'BWFBE_WC_Cart_Link_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_WC_Cart_Link_Template {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private $responsive_style;
private $wrapper_selector = '';
private $tableAttrs = '';
private $settings = [];
public static $cart_data;
private static $is_preview = false;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_cart_link', [ $this, 'cart_link_block' ] );
}
public function cart_link_block( $atts, $content ) {
self::$cart_data = [];
$mergetagdata = BWFAN_Merge_Tag_Loader::get_data();
$lang = $mergetagdata['language'] ?? '';
self::$is_preview = isset( $mergetagdata['is_preview'] ) && $mergetagdata['is_preview'];
if ( isset( $mergetagdata['cart_details'] ) ) {
//set cart
if ( isset( $mergetagdata['cart_details']['items'] ) ) {
$mergetagdata['cart_details']['items'] = maybe_unserialize( $mergetagdata['cart_details']['items'] );
}
self::$cart_data = $mergetagdata['cart_details'];
} else if ( isset( $mergetagdata['cart_abandoned_id'] ) && ! empty( $mergetagdata['cart_abandoned_id'] ) ) {
// get cart data
$cart_details = BWFAN_Model_Abandonedcarts::get( intval( $mergetagdata['cart_abandoned_id'] ) );
if ( isset( $cart_details['items'] ) ) {
$cart_details['items'] = maybe_unserialize( $cart_details['items'] );
}
self::$cart_data = $cart_details;
}
$screen = 'desktop';
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
if ( ! self::$is_preview && isset( self::$cart_data['token'] ) ) {
$coupon = isset( $attributes['coupon'] ) ? $attributes['coupon'] : '';
$url = BWFAN_Common::wc_get_cart_recovery_url( self::$cart_data['token'], BWFAN_Common::decode_merge_tags( $coupon ), $lang );
} else {
$url = site_url();
}
ob_start();
$defaults = array(
'content' => 'Continue to Checkout',
'rowHasBgImage' => false,
'target' => '_blank',
'uniqueID' => '',
'containerPadding' => [
'desktop' => [
'top' => '8',
'right' => '16',
'bottom' => '8',
'left' => '16',
'unit' => 'px'
],
],
);
$this->settings = wp_parse_args( $attributes, $defaults );
$alignment = isset( $this->settings['alignment'] ) ? $this->settings['alignment'][ $screen ] : 'center';
$hasContainerPadding = isset( $this->settings['containerPadding'] ) && isset( $this->settings['containerPadding'][ $screen ] ) && ! empty( $this->settings['containerPadding'][ $screen ]['left'] );
$rowHasBgImage = isset( $this->settings['rowHasBgImage'] ) && $this->settings['rowHasBgImage'];
$hasUrl = isset( $url ) && ! empty( $url );
$this->settings['classname'] = [
'bwf-email-cart-link',
'bwf-email-cart-link-' . $this->settings['uniqueID']
];
$this->wrapper_selector = '.bwf-email-cart-link.bwf-email-cart-link-' . $this->settings['uniqueID'];
$this->tableAttrs = 'cellpadding="0" cellspacing="0" role="presentation" border="0"';
?>
<tr>
<td align="<?php echo $alignment; //phpcs:ignore WordPress.Security.EscapeOutput ?>" class="<?php echo implode( ' ', $this->settings['classname'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo $this->get_block_wrapper_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php if ( $rowHasBgImage && $hasContainerPadding ) { ?>
'<!--[if mso | IE]><span style="<?php echo 'margin-left: ' . $this->settings['containerPadding'][ $screen ]['left'] . $this->settings['containerPadding'][ $screen ]['unit'] . ';'; //phpcs:ignore WordPress.Security.EscapeOutput ?>"><![endif]-->
<?php } ?>
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> role="presentation" class="bwf-email-cart-link-container" style="border-collapse:separate;<?php echo $this->getButtonWidth(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<tbody>
<tr>
<td align="center" class="bwf-cart-link-btn-wrap" style="font-size:16px;<?php echo $this->getBtnStyle(); //phpcs:ignore WordPress.Security.EscapeOutput ?>" bgcolor="<?php ( isset( $this->settings['bgColor'][ $screen ] ) ? $this->settings['bgColor'][ $screen ] : '' ); ?>">
<?php if ( $hasUrl ) { ?>
<a class="bwf-cart-link-btn" href="<?php echo $url; //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo $this->getBtnTextStyle(); //phpcs:ignore WordPress.Security.EscapeOutput ?>" target="_blank">
<?php } else { ?>
<p class="bwf-cart-link-btn" style="margin: 0;<?php echo $this->getBtnTextStyle(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php } ?>
<?php echo $this->settings['content']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
<?php echo $hasUrl ? '</a>' : '</p>'; ?>
</td>
</tr>
</tbody>
</table>
<?php if ( $rowHasBgImage && $hasContainerPadding ) { ?>
<!--[if mso | IE]></span><![endif]-->
<?php } ?>
</td>
</tr>
<?php
?>
<style data-id='woofunnels'>
@media only screen and (max-width: 768px) {
<?php echo $this->responsive_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>
}
</style>
<?php
$this->responsive_style = '';
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
public function getBorderStyle() {
$style = bwf_css()->getBorderRadius( $this->settings, 'border', 'desktop', false, '', 'buttonBorder' );
if ( isset( $this->settings['border'] ) && isset( $this->settings['border']['desktop'] ) ) {
$style .= bwf_css()->getBorderWidth( $this->settings, 'border', 'desktop' );
$style .= bwf_css()->getBorderColor( $this->settings, 'border', 'desktop' );
$style .= ( isset( $this->settings['border']['desktop']['style'] ) && ! in_array( $this->settings['border']['desktop']['style'], [
'',
'none'
] ) ? ( bwf_css()->getBorderStyle( $this->settings, 'border', 'desktop' ) ) : 'border:none;' );
}
return $style;
}
public function getPadding() {
return bwf_css()->getPadding( $this->settings, 'padding', 'desktop', false, 'padding: 10px 20px;', 'buttonPadding' ) . 'mso-padding-alt: 0px;';
}
public function getAlignment() {
$style = isset( $this->settings['alignment'] ) ? bwf_css()->getAlignment( $this->settings, 'alignment', 'desktop' ) : 'margin: auto;';
}
public function getButtonWidth() {
$style = bwf_css()->handleAutoWidth( $this->settings, 'autoWidth', 'widthPercent', 'desktop', [ 'buttonAuto', 'buttonSize' ], false, 'value' );
$style .= 'border-collapse:separate;';
$mStyle = bwf_css()->handleAutoWidth( $this->settings, 'autoWidth', 'widthPercent', 'mobile', '', true, 'value' );
$this->responsive_style .= sprintf( '%1$s .bwf-email-cart-link-container {%2$s}', $this->wrapper_selector, $mStyle );
return $style;
}
public function getBtnStyle() {
$borderStyle = $this->getBorderStyle();
$style = bwf_css()->getBgColor( $this->settings, 'bgColor', 'desktop', 'buttonBackground', false, 'background:#0073aa;' );
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'font', 'desktop', 'buttonFont' );
$style .= ( $borderStyle ?? 'border-style:none;' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'padding', 'desktop', false, 'mso-padding-alt:10px 20px;', 'buttonPadding' );
$style .= bwf_css()->textAlign( $this->settings, 'textAlignment', 'desktop' );
$style .= 'cursor: auto;';
return $style;
}
public function getBtnTextStyle() {
$style = bwf_css()->getBgColor( $this->settings, 'bgColor', 'desktop', 'buttonBackground', false, 'background:#0073aa;' );
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'font', 'desktop', 'buttonFont' );
$style .= 'display: inline-block;';
$style .= ( $borderStyle ?? 'border-style:none;' );
$style .= $this->getPadding();
$style .= bwf_css()->getColor( $this->settings, 'color', 'desktop', 'buttonColor', false );
$style .= bwf_css()->getBorderRadius( $this->settings, 'border', 'desktop', false, '', 'buttonBorder' );
$style .= 'text-decoration: none; text-transform:none;line-height:1.5;';
$mStyle = bwf_css()->getFontSize( $this->settings, 'font', 'mobile', 'buttonFont' );
$mStyle .= bwf_css()->getPadding( $this->settings, 'padding', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s .bwf-cart-link-btn {%2$s}', $this->wrapper_selector, $mStyle );
return $style;
}
/**
* Get Block Container style
*/
private function get_block_wrapper_style() {
$style = 'word-break:break-word;';
$style .= bwf_css()->getPadding( $this->settings, 'containerPadding', 'desktop', false, 'padding: 10px; mso-padding-alt:10px;' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'containerPadding', 'desktop' );
$style .= bwf_css()->getVisibilityCss( $this->settings, 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getPadding( $this->settings, 'containerPadding', 'mobile', true );
$mStyle .= isset( $this->settings['alignment'] ) ? '-webkit-' . $this->settings['alignment']['mobile'] : '';
$mStyle .= bwf_css()->getVisibilityCss( $this->settings, 'mobile' );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Block default and common style
*/
private function get_default_style( $type = '' ) {
$defaultStyle = [
'font-size' => 'font-size:16px;',
'text-style' => 'margin:0;line-height: 1.5;' . bwf_css()->getFontStyles( $this->settings, 'font', 'desktop' ),
'color' => bwf_css()->getColor( $this->settings, 'color', 'desktop' )
];
if ( ! empty( $type ) && is_string( $type ) ) {
return $defaultStyle[ $type ];
}
return $defaultStyle;
}
function globalSettingsCheck( $attrName, $otherCheck = true ) {
$global = BWFCRM_Block_Editor::$global_settings;
return isset( $global ) && isset( $global[ $attrName ] ) && $otherCheck;
}
}
}
BWFBE_WC_Cart_Link_Template::get_instance();

View File

@@ -0,0 +1,423 @@
<?php
if ( ! class_exists( 'BWFBE_WC_Coupon_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_WC_Coupon_Template {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private $responsive_style;
private $wrapper_selector = '';
private $tableAttrs = '';
private $settings = [];
public static $order;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_coupon', [ $this, 'coupon_block' ] );
}
public function coupon_block( $atts, $content ) {
ob_start();
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
$defaults = [
'padding' => [
'desktop' => [
'top' => '8',
'right' => '16',
'bottom' => '8',
'left' => '16',
'unit' => 'px'
],
'mobile' => [
'top' => '8',
'right' => '16',
'bottom' => '8',
'left' => '16',
'unit' => 'px'
],
],
'headingText' => '<strong>10% OFF DISCOUNT<strong>',
'msg' => "As thanks for shopping with us, we're giving you a discount coupon to use on your next purchase.",
'code' => 'TAKE10OFF',
'btnText' => 'SHOP NOW',
'url' => get_site_url(),
'codeBorder' => [
'desktop' => [
'style' => 'dashed',
'left' => '2',
'right' => '2',
'top' => '2',
'bottom' => '2',
'unit' => 'px',
'color_top' => '#353030',
'color_right' => '#353030',
'color_bottom' => '#353030',
'color_left' => '#353030',
],
],
'codeAutoWidth' => [
'desktop' => false,
'mobile' => false,
],
'codeWidth' => [
'desktop' => [
'value' => '100',
'unit' => 'px'
]
],
'codePadding' => [
'desktop' => [
'top' => '8',
'right' => '8',
'bottom' => '8',
'left' => '8',
'unit' => 'px'
],
],
'btnAutoWidth' => [
'desktop' => false,
'mobile' => false,
],
'btnWidth' => [
'desktop' => [
'value' => '100',
'unit' => 'px'
]
],
'alignment' => [
'desktop' => 'center',
],
'btnURL' => get_site_url(),
'btnTarget' => '_blank',
'uniqueID' => '',
'headingFont' => [
'desktop' => [
'size' => '18'
]
],
'msgFont' => [
'desktop' => [
'size' => '14'
]
],
'btnTextFont' => [
'desktop' => [
'size' => '18'
]
],
'enabledContentOptions' => [
'desktop' => [ 'heading', 'paragraph', 'code', 'button' ]
],
];
$this->settings = wp_parse_args( $attributes, $defaults );
$this->settings['classname'] = [
'bwf-email-coupon',
'bwf-email-coupon-' . ( $attributes['uniqueID'] ?? '' )
];
$this->wrapper_selector = '.bwf-email-coupon.bwf-email-coupon-' . $this->settings['uniqueID'];
$this->tableAttrs = 'cellpadding="0" cellspacing="0" role="presentation" border="0"';
$isHeadingEmpty = empty( str_replace( ' ', '', $this->settings['headingText'] ) );
$isMsgEmpty = empty( str_replace( ' ', '', $this->settings['msg'] ) );
$alignment = isset( $this->settings['alignment'] ) && isset( $this->settings['alignment']['desktop'] ) ? $this->settings['alignment']['desktop'] : 'center';
?>
<tr>
<td class="<?php echo implode( ' ', $this->settings['classname'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo $this->get_block_wrapper_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?><?php echo $this->getAlignment(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> align="<?php echo $alignment; //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="width: 100%;<?php echo $this->getAlignment(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php if ( $this->is_section_enable( 'heading' ) || $this->is_section_enable( 'paragraph' ) ) { ?>
<tr>
<td class="heading-wrap" style="<?php echo $this->getAlignment(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php if ( $this->is_section_enable( 'heading' ) ) { ?>
<p class="coupon-heading" style="<?php echo $this->get_heading_style( '.coupon-heading', $isHeadingEmpty ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $this->settings['headingText']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<?php } ?>
<?php if ( $this->is_section_enable( 'paragraph' ) ) { ?>
<p class="coupon-msg" style="<?php echo $this->get_msg_style( '.coupon-msg' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $this->settings['msg']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php if ( $this->is_section_enable( 'code' ) ) { ?>
<tr>
<td class="coupone-code-outer-wrap" style="<?php echo 'padding:16px 0 0;mso-padding-alt:16px 0 0 0;' ?>" align="<?php echo $alignment; //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="<?php echo $this->getCodeWidth(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<tr>
<td class="coupone-code-wrap" style="<?php echo $this->get_code_wrap_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<p class="coupon-code" style="<?php echo $this->get_code_text_style( '.coupon-code' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $this->settings['code']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
</td>
</tr>
</table>
</td>
</tr>
<?php } ?>
<?php if ( $this->is_section_enable( 'button' ) ) { ?>
<tr>
<td class="coupon-btn-wrap" align="<?php echo $alignment; //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo 'padding:16px 0 0;mso-padding-alt:16px 0 0 0;' ?>">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="<?php echo $this->getButtonWidth(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<tr>
<td class="coupon-btn" style="<?php echo $this->get_btn_style( '.coupon-btn' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<a class="coupon-btn-text" href="<?php echo ! empty( $this->settings['btnURL'] ) ? $this->settings['btnURL'] : get_site_url(); //phpcs:ignore WordPress.Security.EscapeOutput ?>" target="_blank" style="<?php echo $this->get_btn_text_style( '.coupon-btn-text' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>" rel="noopener noreferrer">
<?php echo $this->settings['btnText']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</a>
</td>
<tr>
</table>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>
<?php
$this->getRespAlignment();
?>
<style data-id='woofunnels'>
@media only screen and (max-width: 768px) {
<?php echo $this->responsive_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>
}
</style>
<?php
$this->responsive_style = '';
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
private function is_section_enable( $section = '', $screen = 'desktop' ) {
$section_enabled = isset( $this->settings['enabledContentOptions'][ $screen ] ) ? $this->settings['enabledContentOptions'][ $screen ] : [];
if ( in_array( $section, $section_enabled ) ) {
return true;
}
return false;
}
/**
* Get Block Container style
*/
private function get_block_wrapper_style() {
$style = 'word-break:break-word;text-align: center;';
$style .= bwf_css()->getPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getVisibilityCss( $this->settings, 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getPadding( $this->settings, 'padding', 'mobile', true );
$mStyle .= bwf_css()->getVisibilityCss( $this->settings, 'mobile' );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Get Heading style
*/
private function get_heading_style( $classname = '', $isHeadingEmpty = false ) {
$default_style = $this->get_default_style();
$style = 'font-weight:600;';
$style .= $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'headingFont', 'desktop' );
$style .= bwf_css()->getColor( $this->settings, 'headingColor', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'headingFont', 'mobile', true );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Message style
*/
private function get_msg_style( $classname = '' ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'msgFont', 'desktop' );
$style .= bwf_css()->getColor( $this->settings, 'msgColor', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
$style .= 'padding-top: 8px; mso-padding-alt: 8px 0 0 0;';
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'msgFont', 'mobile', true );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Code wrapper style
*/
public function get_code_wrap_style() {
$style = 'text-align: center;padding: 10px 0px; mso-padding-alt: 10px 0px;border-color: #0073aa;';
$style .= bwf_css()->getBorderWidth( $this->settings, 'codeBorder', 'desktop' );
$style .= bwf_css()->getBorderColor( $this->settings, 'codeBorder', 'desktop' );
$style .= bwf_css()->getBorderStyle( $this->settings, 'codeBorder', 'desktop' );
$style .= bwf_css()->getBorderRadius( $this->settings, 'codeBorder', 'desktop', false, '', 'buttonBorder' );
$style .= bwf_css()->getPadding( $this->settings, 'codePadding', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'codePadding', 'desktop' );
$mStyle = bwf_css()->getPadding( $this->settings, 'codePadding', 'desktop' );
$this->responsive_style .= sprintf( '%1$s .coupone-code-wrap {%2$s}', $this->wrapper_selector, $mStyle );
return $style;
}
/**
* Get Code text style
*/
public function get_code_text_style( $classname ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'codeFont', 'desktop', false, $default_style['font-size'] );
$style .= bwf_css()->getColor( $this->settings, 'codeColor', 'desktop' );
$style .= 'line-height:1.5';
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'codeFont', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
public function getButtonWidth() {
$style = bwf_css()->handleAutoWidth( $this->settings, 'btnAutoWidth', 'btnWidth', 'desktop', [ 'buttonAuto', 'buttonSize' ], false, 'value' );
$style .= 'border-collapse:separate;';
$mStyle = bwf_css()->handleAutoWidth( $this->settings, 'btnAutoWidth', 'btnWidth', 'mobile', [ 'buttonAuto', 'buttonSize' ], true, 'value' );
$this->responsive_style .= sprintf( '%1$s .coupon-btn-wrap > table {%2$s}', $this->wrapper_selector, $mStyle );
return $style;
}
public function getCodeWidth() {
$style = bwf_css()->handleAutoWidth( $this->settings, 'codeAutoWidth', 'codeWidth', 'desktop', [ 'buttonAuto', 'buttonSize' ], false, 'value' );
$style .= 'border-collapse:separate;';
$mStyle = bwf_css()->handleAutoWidth( $this->settings, 'codeAutoWidth', 'codeWidth', 'mobile', [ 'buttonAuto', 'buttonSize' ], true, 'value' );
$this->responsive_style .= sprintf( '%1$s .coupone-code-outer-wrap > table {%2$s}', $this->wrapper_selector, $mStyle );
return $style;
}
public function getAlignment() {
$style = isset( $this->settings['alignment'] ) && isset( $this->settings['alignment']['desktop'] ) ? 'text-align: ' . $this->settings['alignment']['desktop'] . ';' : 'text-align: center;';
return $style;
}
public function getRespAlignment() {
$mStyle = isset( $this->settings['alignment'] ) && isset( $this->settings['alignment']['mobile'] ) ? 'text-align: ' . ( $isTable ? ' -webkit-' : '' ) . $this->settings['alignment']['mobile'] . ' !important;' : '';
$mStyle1 = isset( $this->settings['alignment'] ) && isset( $this->settings['alignment']['mobile'] ) ? 'text-align: -webkit-' . ( $isTable ? ' -webkit-' : '' ) . $this->settings['alignment']['mobile'] . ' !important;' : '';
if ( ! empty( $mStyle ) ) {
$this->responsive_style .= sprintf( '%1$s, %1$s .heading-wrap {%2$s}', $this->wrapper_selector, $mStyle );
$this->responsive_style .= sprintf( '%1$s .coupon-btn-wrap, %1$s .coupone-code-outer-wrap {%2$s}', $this->wrapper_selector, $mStyle1 );
}
return '';
}
/**
* Get Button style
*/
public function get_btn_style() {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= 'mso-padding-alt: 10px 0px;text-align: center;';
$style .= bwf_css()->getBgColor( $this->settings, 'btnBgColor', 'desktop', 'buttonBackground', false, 'background:#0073aa;' );
$style .= bwf_css()->getBorderRadius( $this->settings, 'btnBorder', 'desktop', false, 'border-radius:3px;', 'buttonBorder' );
$style .= bwf_css()->getBorderWidth( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getBorderColor( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getBorderStyle( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'btnPadding', 'desktop', false, '', 'buttonPadding' );
return $style;
}
/**
* Get Buton text style
*/
public function get_btn_text_style( $classname ) {
$default_style = $this->get_default_style();
$style = 'padding: 10px 0px;text-decoration:none;display:inline-block;mso-padding-alt:0;line-height:1.5;';
$style .= bwf_css()->getBgColor( $this->settings, 'btnBgColor', 'desktop', 'buttonBackground', false, 'background:#0073aa;' );
$style .= bwf_css()->getColor( $this->settings, 'btnTextColor', 'desktop', 'buttonColor', false, 'color: #ffffff;' );
$style .= $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'btnTextFont', 'desktop', 'buttonFont', 'font-size: 16px;' );
$style .= bwf_css()->getPadding( $this->settings, 'btnPadding', 'desktop', false, '', 'buttonPadding' );
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'btnTextFont', 'mobile', 'buttonFont' );
$mStyle .= bwf_css()->getPadding( $this->settings, 'btnPadding', 'mobile' );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Block default and common style
*/
private function get_default_style( $type = '' ) {
$defaultStyle = [
'font-size' => 'font-size:16px;',
'text-style' => 'margin:0;line-height: 1.5;' . bwf_css()->getFontFamily( $this->settings ),
'color' => bwf_css()->getColor( $this->settings, 'color', 'desktop' )
];
if ( ! empty( $type ) && is_string( $type ) ) {
return $defaultStyle[ $type ];
}
return $defaultStyle;
}
function globalSettingsCheck( $attrName, $otherCheck = true ) {
$global = BWFCRM_Block_Editor::$global_settings;
return isset( $global ) && isset( $global[ $attrName ] ) && $otherCheck;
}
}
}
BWFBE_WC_Coupon_Template::get_instance();

View File

@@ -0,0 +1,371 @@
<?php
if ( ! class_exists( 'BWFBE_WCAddress_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_WCAddress_Template {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private $responsive_style;
private $wrapper_selector = '';
private $tableAttrs = '';
private $settings = [];
private $g_sets = []; // global settings
public static $order;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_customer_addresses', [ $this, 'customer_addresses_block' ] );
}
public function customer_addresses_block( $atts, $content ) {
self::$order = ! empty( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) ? wc_get_order( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) : '';
do_action( 'bwfan_email_setup_locale', BWFAN_Common::get_order_language( self::$order ) );
ob_start();
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
$defaults = [
'padding' => [
'desktop' => [
'top' => '8',
'right' => '16',
'bottom' => '8',
'left' => '16',
'unit' => 'px'
],
'mobile' => [
'top' => '8',
'right' => '8',
'bottom' => '8',
'left' => '8',
'unit' => 'px'
],
],
'showBilling' => true,
'showShipping' => true,
'billingHeading' => 'Billing Address',
'shippingHeading' => 'Shipping Address',
'headingBold' => [ 'desktop' => true ],
'uniqueID' => '',
'headingFont' => [
'desktop' => [
'size' => '18'
]
],
'addrFont' => [
'desktop' => [
'size' => '13'
]
],
'alignment' => [
'desktop' => 'left',
],
];
$this->settings = wp_parse_args( $attributes, $defaults );
$this->g_sets = isset( $this->settings['globals'] ) ? $this->settings['globals'] : [];
$this->settings['classname'] = [
'bwf-email-order-address',
'bwf-email-order-address-' . ( $attributes['uniqueID'] ?? '' )
];
$this->wrapper_selector = '.bwf-email-order-address.bwf-email-order-address-' . $this->settings['uniqueID'];
$this->tableAttrs = 'cellpadding="0" cellspacing="0" role="presentation" border="0"';
$this->customer_addresses_html();
?>
<style data-id='woofunnels'>
.bwf-email-order-address .bwfbe-addr-wrap .bwfbe-addr-content.bwfbe-addr span {
font-size: 0;
}
@media only screen and (max-width: 768px) {
.bwf-email-order-address .bwfbe-addr-wrap,
.bwf-email-order-address .bwfbe-addr-gap {
display: inline-block !important;
}
.bwf-email-order-address .bwfbe-addr-wrap {
width: 100% !important;
}
.bwf-email-order-address .bwfbe-addr-wrap .bwfbe-addr-content.bwfbe-addr br {
display: none;
}
.bwf-email-order-address .bwfbe-addr-wrap .bwfbe-addr-content.bwfbe-addr span {
font-size: inherit !important;
}
<?php echo $this->responsive_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>
}
</style>
<?php
$this->responsive_style = '';
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
public function customer_address_data() {
$mergetagdata = BWFAN_Merge_Tag_Loader::get_data();
$is_preview = isset( $mergetagdata['is_preview'] ) && $mergetagdata['is_preview'];
$has_order_exist = ! $is_preview && self::$order ? true : false;
$dummy_data = $this->customer_dummy_address();
$filter_callback = function ( $args ) {
$args['{first_name}'] = '';
$args['{last_name}'] = '';
$args['{name}'] = '';
return $args;
};
add_filter( 'woocommerce_formatted_address_replacements', $filter_callback );
$data = [
'billingHeading' => $this->settings['billingHeading'],
'shippingHeading' => $this->settings['shippingHeading'],
'shipping_name' => $has_order_exist ? self::$order->get_formatted_shipping_full_name() : $dummy_data['name'],
'billing_name' => $has_order_exist ? self::$order->get_formatted_billing_full_name() : $dummy_data['name'],
'address' => $has_order_exist ? self::$order->get_formatted_billing_address() : $dummy_data['address'],
'shipping' => $has_order_exist ? self::$order->get_formatted_shipping_address() : $dummy_data['address'],
'billing_email' => $has_order_exist ? self::$order->get_billing_email() : $dummy_data['email'],
'billing_phone' => $has_order_exist ? self::$order->get_billing_phone() : $dummy_data['phone'],
'shipping_phone' => $has_order_exist ? self::$order->get_shipping_phone() : $dummy_data['phone'],
];
remove_filter( 'woocommerce_formatted_address_replacements', $filter_callback );
return $data;
}
public function customer_dummy_address() {
return [
'name' => 'John Doe',
'address' => '548 Market St 70640<br/>San Francisco CA<br/>United States',
'phone' => '94104-5401',
'email' => 'johndoe@gmail.com',
];
}
public function customer_addresses_html() {
$showBilling = $this->settings['showBilling'];
$showShipping = $this->settings['showShipping'];
if ( ! $showBilling && ! $showShipping ) {
return '';
}
$data = $this->customer_address_data();
$show_shipping = ( self::$order && ! wc_ship_to_billing_address_only() && self::$order->needs_shipping_address() && $data['shipping'] && $showShipping ) || ( ! self::$order && $showShipping ) ? true : false;
$width_style = $show_shipping && $showBilling ? 'width:50%;' : 'width:100%;';
$classes = implode( ' ', $this->settings['classname'] );
$alignment = isset( $this->settings['alignment']['desktop'] ) ? $this->settings['alignment']['desktop'] : 'left';
?>
<tr>
<td class="<?php echo $classes; ?>" style="<?php echo $this->get_block_wrapper_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<table <?php echo is_rtl() ? 'dir="rtl"' : '' ?> <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:100%;<?php echo $this->get_block_align_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<tbody>
<tr>
<td style="font-size:0" align="<?php echo $alignment; //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<!--[if mso | IE]><table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:100%"><tr><![endif]-->
<?php if ( $showBilling ) : ?>
<!--[if mso | IE]><td class="bwfbe-addr-wrap bwf-billing-addr" style="<?php echo $width_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>" valign="top"><![endif]-->
<div class="bwfbe-addr-wrap bwf-billing-addr" style="display:table-cell;vertical-align:top;<?php echo $width_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>" valign="top">
<p class="bwfbe-addr-head" style="<?php echo $this->get_heading_style( '.bwfbe-addr-wrap .bwfbe-addr-head' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $data['billingHeading']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="bwfbe-addr-content bwfbe-addr-name" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $data['billing_name']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="bwfbe-addr-content bwfbe-addr" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo str_replace( "<br/>", '<span>, </span><br/>', $data['address'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="bwfbe-addr-content bwfbe-addr-phone-mail" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php if ( $data['billing_phone'] ) : ?>
<?php echo $data['billing_phone']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
<?php endif; ?>
<?php if ( $data['billing_email'] ) : ?>
<br/><?php echo esc_html( $data['billing_email'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
<?php endif; ?>
</p>
</div>
<!--[if mso | IE]></td><![endif]-->
<?php endif; ?>
<?php if ( $showBilling && $show_shipping ) : ?>
<!--[if mso | IE]>
<td class="bwfbe-addr-gap" style="width:16px;" valign="top"><![endif]-->
<div class="bwfbe-addr-gap" style="display:table-cell;vertical-align:top;width:16px;height:16px;" valign="top">
<table width="16" <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:16px;">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><![endif]-->
<?php endif; ?>
<?php if ( $show_shipping ) : ?>
<!--[if mso | IE]><td class="bwfbe-addr-wrap bwf-shipping-addr" style="<?php echo $width_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>" valign="top"><![endif]-->
<div class="bwfbe-addr-wrap bwf-shipping-addr" style="display:table-cell;vertical-align:top;<?php echo $width_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>" valign="top">
<p class="bwfbe-addr-head" style="<?php echo $this->get_heading_style( '.bwfbe-addr-wrap .bwfbe-addr-head' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $data['shippingHeading']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="bwfbe-addr-content bwfbe-addr-name" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $data['shipping_name']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="bwfbe-addr-content bwfbe-addr" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo str_replace( '<br/>', '<span>, </span><br/>', $data['shipping'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<?php if ( $data['shipping_phone'] ) : ?>
<p class="bwfbe-addr-content bwfbe-addr-phone-mail" style="<?php echo $this->get_content_style( '.bwfbe-addr-wrap .bwfbe-addr-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $data['shipping_phone']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<?php endif; ?>
</div>
<!--[if mso | IE]></td><![endif]-->
<?php endif; ?>
<!--[if mso | IE]></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php
}
/**
* Get Block Container style
*/
private function get_block_wrapper_style() {
$style = 'word-break:break-word;';
$style .= bwf_css()->getPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->textAlign( $this->settings, 'alignment', 'desktop', false, is_rtl() ? 'text-align:right;' : '' );
$style .= bwf_css()->getVisibilityCss( $this->settings, 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getPadding( $this->settings, 'padding', 'mobile', true );
$mStyle .= bwf_css()->textAlign( $this->settings, 'alignment', 'mobile', true );
$mStyle .= bwf_css()->getVisibilityCss( $this->settings, 'mobile' );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
private function get_block_align_style() {
$style = '';
$style .= bwf_css()->textAlign( $this->settings, 'alignment', 'desktop', false, is_rtl() ? 'text-align:right;' : '' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->textAlign( $this->settings, 'alignment', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Get Block Container style
*/
private function get_heading_style( $classname ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= 'font-weight:600;padding: 0px 0px 10px; mso-padding-alt: 0px 0px 10px;font-size:16px;';
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'headingFont', 'desktop' );
$style .= bwf_css()->getColor( $this->settings, 'headingColor', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'headingFont', 'mobile' );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
private function get_content_style( $classname ) {
$default_style = $this->get_default_style();
$style = 'font-size:15px;';
$style .= $default_style['text-style'];
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'addrFont' );
$style .= bwf_css()->getFontStyles( $this->settings, 'addrFont', 'desktop', false, false );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop', false, 'line-height: 1.5;' );
$style .= bwf_css()->getColor( $this->settings, 'addrColor', 'desktop' );
$style .= bwf_css()->getBold( $this->settings, 'addrBold', 'desktop' );
$style .= bwf_css()->getItalic( $this->settings, 'addrItalic', 'desktop' );
$style .= $default_style['font-family'];
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'addrFont', 'mobile' );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Block default and common style
*/
private function get_default_style( $type = '' ) {
$defaultStyle = [
'font-size' => 'font-size:16px;',
'font-family' => bwf_css()->getFontFamily( $this->settings, 'font', 'desktop' ),
'text-style' => 'margin:0;line-height:1.6;',
'color' => bwf_css()->getColor( $this->settings, 'Gcolor', 'desktop' )
];
if ( empty( $this->settings['font']['desktop']['family'] ) && ! empty( $this->settings['global']['fontFamily'] ) ) {
$defaultStyle['font-family'] = 'font-family:' . $this->settings['global']['fontFamily'] . ';';
}
if ( ! empty( $type ) && is_string( $type ) ) {
return $defaultStyle[ $type ];
}
return $defaultStyle;
}
}
}
BWFBE_WCAddress_Template::get_instance();

View File

@@ -0,0 +1,457 @@
<?php
if ( ! class_exists( 'BWFBE_WCDownloadProduct_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_WCDownloadProduct_Template {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private $responsive_style;
private $wrapper_selector = '';
private $tableAttrs = '';
private $settings = [];
private static $is_preview = false;
public static $order;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_downloadable_product', [ $this, 'downloadable_product_block' ] );
}
public function downloadable_product_block( $atts, $content ) {
$mergetagdata = BWFAN_Merge_Tag_Loader::get_data();
self::$is_preview = isset( $mergetagdata['is_preview'] ) && $mergetagdata['is_preview'];
self::$order = isset( $mergetagdata['order_id'] ) && ! empty( $mergetagdata['order_id'] ) ? wc_get_order( $mergetagdata['order_id'] ) : '';
$download_products = self::$order instanceof WC_Order ? self::$order->get_downloadable_items() : [];
if ( ! self::$is_preview && empty( $download_products ) ) {
return '';
}
do_action( 'bwfan_email_setup_locale', BWFAN_Common::get_order_language( self::$order ) );
ob_start();
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
$defaults = [
'padding' => [
'desktop' => [ 'top' => '16', 'right' => '16', 'bottom' => '16', 'left' => '16', 'unit' => 'px' ],
'mobile' => [ 'top' => '8', 'right' => '8', 'bottom' => '8', 'left' => '8', 'unit' => 'px' ]
],
'dividerStyle' => [ 'desktop' => 'solid' ],
'btnTextLH' => [ 'desktop' => [ 'value' => 120 ] ],
'fileNameBold' => [ 'desktop' => true ],
'productTitleBold' => [ 'desktop' => true ],
'uniqueID' => '',
'productTitleFont' => [
'desktop' => [
'size' => '14'
]
],
'productExpiryFont' => [
'desktop' => [
'size' => '12'
]
],
'productExpiryColor' => [
'desktop' => '#82838e'
],
'fileNameFont' => [
'desktop' => [
'size' => '14'
]
],
'headingFont' => [
'desktop' => [
'size' => '18'
]
],
'headingText' => '<strong>Download Files</strong>',
'dividerStyle' => [
'desktop' => 'solid'
],
'dividerColor' => [
'desktop' => '#f6f6f6'
],
'headingBold' => [
'desktop' => true
],
'productTitleBold' => [
'desktop' => true
],
'fileNameBold' => [
'desktop' => true
],
'enabledContentOptions' => [
'desktop' => [ 'heading', 'title', 'expiry', 'fileName', 'button' ]
],
];
$this->settings = wp_parse_args( $attributes, $defaults );
$this->settings['classname'] = [
'bwf-email-down-products',
'bwf-email-down-products-' . ( $attributes['uniqueID'] ?? '' )
];
$this->wrapper_selector = '.bwf-email-down-products.bwf-email-down-products-' . $this->settings['uniqueID'];
$this->tableAttrs = 'cellpadding="0" cellspacing="0" role="presentation" border="0"';
$this->downloadable_product_html();
?>
<style data-id='woofunnels'>
@media only screen and (max-width: 768px) {
.bwf-email-down-products p, .bwf-email-down-products a {
font-size: 13px !important;
}
.bwf-email-down-products .download-heading p {
font-size: 16px !important;
}
.bwf-email-down-products .file-name {
width: 25% !important;
}
.bwf-email-down-products .download-btn {
width: 25% !important;
}
.bwf-email-down-products .download-btn a {
padding: 8px 6px !important;
}
.bwf-email-down-products .download-btn td {
padding: 0px !important;
background-color: unset !important;
}
<?php echo $this->responsive_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>
}
</style>
<?php
$this->responsive_style = '';
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
public function downloadable_products_data() {
$data = ! self::$is_preview && self::$order instanceof WC_Order ? self::$order->get_downloadable_items() : $this->dummy_products();
return $data;
}
public function dummy_products() {
return [
[
"product_id" => 1,
"product_name" => "Test Product 1",
"download_name" => "[Download File Name]",
"access_expires" => "Never",
],
];
}
/**
* Get expired date
*
* @param string $expiry Expiry date.
*
* @return string
*/
public function get_expired_date( $expiry = '' ) {
if ( empty( $expiry ) ) {
return __( 'Never', 'woocommerce' ); //phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
$date_format = get_option( 'date_format' ) ?? 'd M, Y';
if ( $expiry instanceof DateTime ) {
return $expiry->format( $date_format );
}
if ( strtotime( $expiry ) ) {
return date_i18n( $date_format, strtotime( $expiry ) );
}
return '-';
}
public function downloadable_product_html() {
$counter = 1;
$classes = implode( ' ', $this->settings['classname'] );
?>
<tr>
<td class="<?php echo $classes; //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo $this->get_block_wrapper_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:100%;">
<tbody>
<?php if ( $this->is_section_enable( 'heading' ) ) : ?>
<tr>
<td class="download-heading" style="padding: 0px 0px 16px;mso-padding-alt: 0px 0px 16px;">
<p class="down-products-heading" style="<?php echo $this->get_heading_style( '.down-products-heading' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo isset( $this->settings['headingText'] ) && $this->settings['headingText'] !== '' ? $this->settings['headingText'] : __( 'Downloads', 'wp-marketing-automations-pro' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
</td>
</tr>
<?php endif; ?>
<?php foreach ( $this->downloadable_products_data() as $product ) { ?>
<tr>
<td class="download-product-wrap" style="<?php echo $this->get_divider_style() . ( 1 == $counter && $this->is_section_enable( 'heading' ) ? 'padding: 0 0 24px 0;mso-padding-alt: 0 0 24px 0;' : 'padding: 24px 0px;mso-padding-alt: 24px 0px;' ) . ( count( $this->downloadable_products_data() ) === 1 && $this->is_section_enable( 'heading' ) ? 'border-bottom:0;padding:0;' : "" ) . ( 1 == $counter && ! $this->is_section_enable( 'heading' ) ? $this->get_divider_style( 'top' ) : '' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:100%;">
<tbody>
<tr>
<?php if ( $this->is_section_enable( 'title' ) || $this->is_section_enable( 'expiry' ) ) : ?>
<td class="product-info" style="width: 50%;padding: 0px 4px 0px 0px; mso-padding-alt:0px 4px 0px 0px;">
<?php if ( $this->is_section_enable( 'title' ) ) : ?>
<p class="down-product-title" style="<?php echo $this->get_product_title_style( '.down-product-title' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $product['product_name']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<?php endif; ?>
<?php if ( $this->is_section_enable( 'expiry' ) ) : ?>
<p class="down-product-expiry" style="<?php echo $this->get_product_expiry_style( '.down-product-expiry' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo ( isset( $this->settings['productExpiryText'] ) && $this->settings['productExpiryText'] !== '' ? $this->settings['productExpiryText'] : __( 'Expires On', 'wp-marketing-automations-pro' ) ) . ' : ' . ( $this->get_expired_date( $product['access_expires'] ?? '' ) ); //phpcs:ignore WordPress.Security.EscapeOutput
?>
</p>
<?php endif; ?>
</td>
<?php endif; ?>
<?php if ( $this->is_section_enable( 'fileName' ) ) : ?>
<td class="file-name" style="width: 30%;padding: 0px 4px 0px 0px; mso-padding-alt:0px 4px 0px 0px;">
<p style="<?php echo $this->get_file_name_style( '.file-name p' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $product['download_name']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
</td>
<?php endif; ?>
<?php if ( $this->is_section_enable( 'button' ) ) : ?>
<td class="download-btn">
<table <?php echo $this->tableAttrs; //phpcs:ignore WordPress.Security.EscapeOutput ?> style="width:100%;border-collapse:separate;">
<tbody>
<tr>
<td class="download-button-wrap" style="<?php echo $this->get_btn_wrap_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<a class="download-button" href="<?php echo esc_url( isset( $product['download_url'] ) ? $product['download_url'] : get_site_url() ) ?>" style="<?php echo $this->get_btn_text_style( '.download-btn a' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>" target="_blank">
<?php echo isset( $this->settings['btnText'] ) && $this->settings['btnText'] !== '' ? $this->settings['btnText'] : __( 'Download', 'woocommerce' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
</a>
</td>
</tr>
</tbody>
</table>
</td>
<?php endif; ?>
</tr>
</tbody>
</table>
</td>
</tr>
<?php $counter ++;
} ?>
</tbody>
</table>
</td>
</tr>
<?php
}
private function is_section_enable( $section = '', $screen = 'desktop' ) {
$section_enabled = isset( $this->settings['enabledContentOptions'][ $screen ] ) ? $this->settings['enabledContentOptions'][ $screen ] : [];
if ( in_array( $section, $section_enabled ) ) {
return true;
}
return false;
}
/**
* Get Block Container style
*/
private function get_block_wrapper_style() {
$style = 'word-break:break-word;';
$style .= bwf_css()->getPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getVisibilityCss( $this->settings, 'desktop' );
if ( isset( $this->wrapper_selector ) ) {
$mStyle = bwf_css()->getPadding( $this->settings, 'padding', 'mobile', true );
$mStyle .= bwf_css()->getVisibilityCss( $this->settings, 'mobile' );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Get Block Heading style
*/
private function get_heading_style( $classname ) {
$default_style = $this->get_default_style();
$style = bwf_css()->getFontSize( $this->settings, 'headingFont', 'desktop', false, 'font-size:24px;' );
$style .= bwf_css()->getColor( $this->settings, 'headingColor', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
$style .= $default_style['text-style'];
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'headingFont', 'mobile', true );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Product Title style
*/
private function get_product_title_style( $classname ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'productTitleFont', 'desktop', false, 'font-size:16px;' );
$style .= bwf_css()->getColor( $this->settings, 'productTitleColor', 'desktop' );
$style .= bwf_css()->getBold( $this->settings, 'productTitleBold', 'desktop' );
$style .= bwf_css()->getItalic( $this->settings, 'productTitleItalic', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'productTitleFont', 'mobile', true );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Product Expiry style
*/
private function get_product_expiry_style( $classname ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'productExpiryFont', 'desktop', false, 'font-size:14px;' );
$style .= bwf_css()->getColor( $this->settings, 'productExpiryColor', 'desktop', 'color', false, 'color: #8c8f94;' );
$style .= bwf_css()->getBold( $this->settings, 'productExpiryBold', 'desktop' );
$style .= bwf_css()->getItalic( $this->settings, 'productExpiryItalic', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'productExpiryFont', 'mobile', true );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get File Name style
*/
private function get_file_name_style( $classname ) {
$default_style = $this->get_default_style();
$style = $default_style['text-style'];
$style .= bwf_css()->getFontSize( $this->settings, 'fileNameFont', 'desktop', false, 'font-size:14px;' );
$style .= bwf_css()->getColor( $this->settings, 'fileNameColor', 'desktop' );
$style .= bwf_css()->getBold( $this->settings, 'fileNameBold', 'desktop' );
$style .= bwf_css()->getItalic( $this->settings, 'fileNameItalic', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'fileNameFont', 'mobile', true );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Download button style
*/
private function get_btn_wrap_style( $classname = '' ) {
$style = 'cursor: auto;text-align: center;mso-padding-alt:8px 20px;border-radius: 3px;';
$style .= bwf_css()->getFontSize( $this->settings, 'btnTextFont', 'desktop', 'buttonFont', 'font-size:15px;' );
$style .= bwf_css()->getBgColor( $this->settings, 'btnBgColor', 'desktop', 'buttonBackground', false, 'background-color: #236fa1;' );
$style .= bwf_css()->getBorderStyle( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getBorderWidth( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getBorderColor( $this->settings, 'btnBorder', 'desktop' );
$style .= bwf_css()->getBorderRadius( $this->settings, 'btnBorder', 'desktop', false, '', 'buttonBorder' );
return $style;
}
/**
* Get Download button text style
*/
private function get_btn_text_style( $classname ) {
$default_style = $this->get_default_style();
$style = 'word-break:normal;padding: 8px 20px; mso-padding-alt: 0px;display: inline-block;text-decoration: none;text-transform:none;line-height:1.5;';
$style .= bwf_css()->getFontSize( $this->settings, 'btnTextFont', 'desktop', 'buttonFont', false, 'font-size:15px;' );
$style .= bwf_css()->getBgColor( $this->settings, 'btnBgColor', 'desktop', 'buttonBackground', false, 'background:#236fa1;' );
$style .= bwf_css()->getBorderRadius( $this->settings, 'btnBorder', 'desktop', false, '', 'buttonBorder' );
$style .= bwf_css()->getColor( $this->settings, 'btnTextColor', 'desktop', 'buttonColor', false, 'color: #ffffff;' );
$style .= $default_style['text-style'];
if ( ! empty( $classname ) ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'btnTextFont', 'mobile', 'buttonFont' );
$this->responsive_style .= sprintf( '%1$s %2$s {%3$s}', $this->wrapper_selector, $classname, $mStyle );
}
return $style;
}
/**
* Get Divider style
*/
private function get_divider_style( $position = 'bottom' ) {
if ( $this->settings['dividerColor']['desktop'] === 'none' ) {
return '';
}
$dividerColor = isset( $this->settings['dividerColor']['desktop'] ) ? $this->settings['dividerColor']['desktop'] : '';
$dividerStyle = isset( $this->settings['dividerStyle']['desktop'] ) ? $this->settings['dividerStyle']['desktop'] : '';
$css = 'border-' . $position . ': 1px ' . $dividerStyle . ' ' . $dividerColor . ';';
return $css;
}
/**
* Block default and common style
*/
private function get_default_style( $type = '' ) {
$defaultStyle = [
'font-size' => 'font-size:15px;',
'text-style' => 'margin:0;line-height:1.5;' . bwf_css()->getFontFamily( $this->settings ),
'color' => bwf_css()->getColor( $this->settings, 'color', 'desktop' )
];
if ( ! empty( $type ) && is_string( $type ) ) {
return $defaultStyle[ $type ];
}
return $defaultStyle;
}
}
}
BWFBE_WCDownloadProduct_Template::get_instance();

View File

@@ -0,0 +1,206 @@
<?php
if ( ! class_exists( 'BWFBE_WCOrder_Note_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_WCOrder_Note_Template {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.2.0
*/
private static $instance;
private $responsive_style;
private $wrapper_selector = '';
private $tableAttrs = '';
private $settings = [];
private static $is_preview = false;
public static $order;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_order_note', [ $this, 'order_note_block' ] );
}
public function order_note_block( $atts, $content ) {
$mergetagdata = BWFAN_Merge_Tag_Loader::get_data();
self::$is_preview = isset( $mergetagdata['is_preview'] ) && $mergetagdata['is_preview'];
self::$order = isset( $mergetagdata['order_id'] ) && ! empty( $mergetagdata['order_id'] ) ? wc_get_order( $mergetagdata['order_id'] ) : '';
if ( ! self::$is_preview && ( ! self::$order instanceof WC_Order || empty( self::$order->get_customer_note() ) ) ) {
return '';
}
do_action( 'bwfan_email_setup_locale', BWFAN_Common::get_order_language( self::$order ) );
ob_start();
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
$defaults = [
'padding' => [
'desktop' => [
'top' => '8',
'right' => '16',
'bottom' => '8',
'left' => '16',
'unit' => 'px'
],
'mobile' => [
'top' => '8',
'right' => '8',
'bottom' => '8',
'left' => '8',
'unit' => 'px'
],
],
'headingText' => '<strong>Customer Note</strong>',
'uniqueID' => '',
'headingFont' => [
'desktop' => [
'size' => '18'
]
]
];
$this->settings = wp_parse_args( $attributes, $defaults );
$this->settings['classname'] = [
'bwf-email-order-note',
'bwf-email-order-note-' . ( $attributes['uniqueID'] ?? '' )
];
$this->wrapper_selector = '.bwf-email-order-note.bwf-email-order-note-' . $this->settings['uniqueID'];
$this->tableAttrs = 'cellpadding="0" cellspacing="0" role="presentation" border="0"';
?>
<tr>
<td class="<?php echo implode( ' ', $this->settings['classname'] ); //phpcs:ignore WordPress.Security.EscapeOutput ?>" style="<?php echo $this->get_block_wrapper_style(); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<p class="order-note-heading" style="<?php echo $this->get_order_note_heading_style( '.bwf-email-order-note .order-note-heading' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $this->settings['headingText']; //phpcs:ignore WordPress.Security.EscapeOutput ?>
</p>
<p class="order-note-content" style="<?php echo $this->get_content_style( '.bwf-email-order-note .order-note-content' ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php
if ( ! self::$is_preview && self::$order instanceof WC_Order ) {
echo self::$order->get_customer_note(); //phpcs:ignore WordPress.Security.EscapeOutput
} else {
echo esc_html__( 'This is a sample note the real not will appear.', 'wp-marketing-automations-pro' );
}
?>
</p>
</td>
</tr>
<?php
?>
<style data-id='woofunnels'>
@media only screen and (max-width: 768px) {
<?php echo $this->responsive_style; //phpcs:ignore WordPress.Security.EscapeOutput ?>
}
</style>
<?php
$this->responsive_style = '';
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
/**
* Get Block Container style
*/
private function get_block_wrapper_style() {
$style = 'word-break:break-word;';
$style .= bwf_css()->getPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->getMsoPadding( $this->settings, 'padding', 'desktop' );
$style .= bwf_css()->textAlign( $this->settings, 'alignment', 'desktop' );
$style .= bwf_css()->getVisibilityCss( $this->settings, 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getPadding( $this->settings, 'padding', 'mobile', true );
$mStyle .= bwf_css()->textAlign( $this->settings, 'alignment', 'mobile', true );
$mStyle .= bwf_css()->getVisibilityCss( $this->settings, 'mobile' );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Get Block Container style
*/
private function get_order_note_heading_style( $classname ) {
$default_style = $this->get_default_style();
$style = 'padding: 0px 0px 16px;mso-padding-alt: 0px 0px 16px;font-size:24px;margin:0;';
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'headingFont', 'desktop', false );
$style .= bwf_css()->getColor( $this->settings, 'headingColor', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'headingFont', 'mobile', true );
$mStyle .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
private function get_content_style( $classname ) {
$default_style = $this->get_default_style();
$style = 'margin:0;';
$style .= $default_style['font-size'];
$style .= bwf_css()->getFontFamily( $this->settings );
$style .= bwf_css()->getFontSize( $this->settings, 'font', 'desktop', 'font' );
$style .= bwf_css()->getColor( $this->settings, 'color', 'desktop' );
$style .= bwf_css()->getBold( $this->settings, 'contentBold', 'desktop' );
$style .= bwf_css()->getItalic( $this->settings, 'contentItalic', 'desktop' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'desktop' );
if ( $this->wrapper_selector ) {
$mStyle = bwf_css()->getFontSize( $this->settings, 'font', 'mobile', 'font' );
$style .= bwf_css()->getLineHeight( $this->settings, 'lineHeight', 'mobile', true );
$this->responsive_style .= sprintf( '%1$s {%2$s}', $this->wrapper_selector, $mStyle );
}
return $style;
}
/**
* Block default and common style
*/
private function get_default_style( $type = '' ) {
$defaultStyle = [
'font-size' => 'font-size:16px;',
'text-style' => 'margin:0;' . bwf_css()->getFontFamily( $this->settings ),
'color' => bwf_css()->getColor( $this->settings, 'color', 'desktop' )
];
if ( ! empty( $type ) && is_string( $type ) ) {
return $defaultStyle[ $type ];
}
return $defaultStyle;
}
}
}
BWFBE_WCOrder_Note_Template::get_instance();

View File

@@ -0,0 +1,107 @@
<?php
if ( ! class_exists( 'BWFBE_Social_Icons_Template' ) ) {
#[AllowDynamicProperties]
class BWFBE_Social_Icons_Template {
private static $instance;
private $settings = [];
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
add_shortcode( 'bwfbe_social_icons', [ $this, 'social_icons_block' ] );
}
public function social_icons_block( $atts, $content ) {
$attributes = json_decode( BWFCRM_Block_Editor::decode_content( $content ), true );
$defaults = [
'spacing' => [
'desktop' => 8
],
'padding' => [
'top' => '10',
'right' => '10',
'bottom' => '10',
'left' => '10',
'unit' => 'px',
]
];
$block_editor_setting = BWFAN_Common::get_block_editor_settings();
$icons = $block_editor_setting['setting']['social'];
$this->settings = wp_parse_args( $attributes, $defaults );
$assetsURL = 'https://d241ue3yrqqwem.cloudfront.net/';
$size = $this->settings['size'] . 'px';
$spacing = $this->settings['spacing']['desktop'];
$type = isset( $this->settings['type'] ) ? $this->settings['type'] : $block_editor_setting['setting']['socialType'];
ob_start();
foreach ( $icons as $index => $icon ) : ?>
<!--[if mso | IE]><td style="width: <?php echo intval( $size ); ?>; height: <?php echo intval( $size ); ?>; padding-right: 0 !important;"><![endif]-->
<table style="display: inline-block; border-collapse: collapse;">
<tbody>
<tr>
<td class='bwfbe-social-icon-wrap' style="<?php echo $this->getSpacing( $spacing ); //phpcs:ignore WordPress.Security.EscapeOutput ?>">
<?php echo $this->getIconHtml( $icon, $assetsURL, $size, $type ); //phpcs:ignore WordPress.Security.EscapeOutput ?>
</td>
</tr>
</tbody>
</table>
<!--[if mso | IE]></td><![endif]-->
<?php endforeach;
return BWFAN_Common::decode_merge_tags( ob_get_clean() );
}
private function getSpacing( $spacing ) {
$align = 'center';
switch ( $align ) {
case 'left':
return sprintf( 'padding-right: %1$spx; mso-padding-right: %1$spx;', $spacing );
case 'right':
return sprintf( 'padding-left: %1$spx; mso-padding-left: %1$spx;', $spacing );
default:
return sprintf( 'padding-left: %1$spx; mso-padding-left: %1$spx; padding-right: %1$spx; mso-padding-right: %1$spx;', $spacing / 2 );
}
}
private function getIconHtml( $icon, $assetsURL, $size, $type ) {
$iconType = $type ?? 'circle';
$iconHtml = $this->createElement( 'img', [
'src' => $assetsURL . 'social-icons/' . $iconType . '/' . $icon['iconName'] . '.png',
'width' => $size,
'height' => $size,
'alt' => $icon['iconName'],
] );
if ( ! empty( $icon['link'] ) ) {
$iconHtml = $this->createElement( 'a', [
'href' => $icon['link'],
'target' => '_blank',
], $iconHtml );
}
return $iconHtml;
}
private function createElement( $tag, $attributes = [], $content = '' ) {
$attributeString = '';
foreach ( $attributes as $key => $value ) {
$attributeString .= " {$key}='{$value}'";
}
$html = "<{$tag}{$attributeString}>{$content}</{$tag}>";
return $html;
}
}
}
BWFBE_Social_Icons_Template::get_instance();

View File

@@ -0,0 +1,48 @@
<?php
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'BWFBE_WC_BLOCKS' ) ) {
/**
* EMAILBLOCKS
*/
#[AllowDynamicProperties]
class BWFBE_WC_BLOCKS {
/**
* __construct
*
* @return void
*/
public function __construct() {
$this->loaded_shortcode();
}
/**
* Plugin Loaded
*
* @return void
*/
public function loaded_shortcode() {
if ( class_exists( 'WooCommerce' ) ) {
$this->load_wc_order_block();
}
}
public static function load_wc_order_block() {
$wc_block_dir = __DIR__ . '/includes/';
foreach ( glob( $wc_block_dir . '/class-*.php' ) as $_field_filename ) {
$file_data = pathinfo( $_field_filename );
if ( isset( $file_data['basename'] ) && 'index.php' === $file_data['basename'] ) {
continue;
}
require_once( $_field_filename );
}
}
}
new BWFBE_WC_BLOCKS();
}