ADDED Code of Version 2.0.0 of the Advanced Composer Blocks for Newsletter Plugin
This commit is contained in:
commit
028d595144
28 changed files with 2187 additions and 0 deletions
160
blocks/mbtnp-cover/block.php
Normal file
160
blocks/mbtnp-cover/block.php
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Cover
|
||||
* Section: content
|
||||
* Description: Email cover block
|
||||
*/
|
||||
|
||||
/* @var $options array */
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// On future releases of Newsletter, default options will be part of the options.php
|
||||
// file, it is the best place to have them. By now, be patience.
|
||||
|
||||
// The "block_*" options are reserved and could be processed dutrectly by Newsletter. For example the
|
||||
// "block_background" and "block_padding_*" are used to generated the wrapper of the block content.
|
||||
|
||||
$defaults = array(
|
||||
'title' => 'Cover Title',
|
||||
'title_font_family' => '',
|
||||
'title_font_size' => '',
|
||||
'title_font_weight' => '',
|
||||
'title_font_color' => '',
|
||||
'title_font_align' => 'center',
|
||||
'text' => 'Cover block text (optional)',
|
||||
'font_family' => '',
|
||||
'font_size' => '',
|
||||
'font_weight' => '',
|
||||
'font_color' => '',
|
||||
'overlay-opacity' => 50,
|
||||
'padding-top' => 40,
|
||||
'padding-bottom' => 40,
|
||||
'padding-left' => 40,
|
||||
'padding-right' => 40,
|
||||
'block_padding_top' => 30,
|
||||
'block_padding_bottom' => 30,
|
||||
'block_padding_left' => 0,
|
||||
'block_padding_right' => 0,
|
||||
'block_background' => '',
|
||||
);
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
|
||||
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
||||
$text_style = TNP_Composer::get_text_style($options, '', $composer);
|
||||
|
||||
$media = false;
|
||||
|
||||
if ( !empty($options['image']['id']) ) {
|
||||
$td_width = round(($composer['width'] - $options['block_padding_left'] - $options['block_padding_right'] - 20) / 2);
|
||||
//$image_width = 300 - $options['block_padding_left'];
|
||||
$media = tnp_resize_2x( $options['image']['id'], [$td_width, 0] );
|
||||
} ?>
|
||||
|
||||
<style>
|
||||
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
||||
.title {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0;
|
||||
padding: 40px;
|
||||
<?php if( $options['padding-top'] ){
|
||||
echo 'padding-top: ' . esc_attr( $options['padding-top'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-bottom'] ){
|
||||
echo 'padding-bottom: ' . esc_attr( $options['padding-bottom'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-left'] ){
|
||||
echo 'padding-left: ' . esc_attr( $options['padding-left'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-right'] ){
|
||||
echo 'padding-right: ' . esc_attr( $options['padding-right'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['text'] ){ echo 'padding-bottom: 0px;'; } ?>
|
||||
}
|
||||
|
||||
.text {
|
||||
<?php esc_html( $text_style->echo_css() ) ?>
|
||||
padding: 40px;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
<?php if( $options['padding-top'] ){
|
||||
echo 'padding-top: ' . esc_attr( $options['padding-top'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-bottom'] ){
|
||||
echo 'padding-bottom: ' . esc_attr( $options['padding-bottom'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-left'] ){
|
||||
echo 'padding-left: ' . esc_attr( $options['padding-left'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['padding-right'] ){
|
||||
echo 'padding-right: ' . esc_attr( $options['padding-right'] ) . 'px;';
|
||||
} ?>
|
||||
<?php if( $options['title'] ){ echo 'padding-top: 0px;'; } ?>
|
||||
}
|
||||
|
||||
.img-background {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color: #ddd;
|
||||
<?php if ($media) { ?>
|
||||
background: url(<?php echo esc_url( $media->url ); ?>);
|
||||
background-size: cover;
|
||||
background-position: center center;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-radius'] ){
|
||||
echo 'border-radius: ' . esc_attr( $options['border-radius'] ) . 'px;';
|
||||
echo 'overflow: hidden;';
|
||||
} ?>
|
||||
<?php if( $options['box-shadow-x'] || $options['box-shadow-y'] || $options['box-shadow-blur'] || $options['box-shadow-spread'] || $options['box-shadow-color'] ){
|
||||
|
||||
if( empty($options['box-shadow-x']) ){ $options['box-shadow-x'] = '0'; }
|
||||
if( empty($options['box-shadow-y']) ){ $options['box-shadow-y'] = '0'; }
|
||||
if( empty($options['box-shadow-blur']) ){ $options['box-shadow-blur'] = '0'; }
|
||||
if( empty($options['box-shadow-spread']) ){ $options['box-shadow-spread'] = '0'; }
|
||||
if( empty($options['box-shadow-color']) ){ $options['box-shadow-color'] = '#000000'; }
|
||||
|
||||
echo ' box-shadow: ' . esc_attr( $options['box-shadow-x'] ) . 'px ' . esc_attr( $options['box-shadow-y'] ) . 'px ' . esc_attr( $options['box-shadow-blur'] ) . 'px ' . esc_attr( $options['box-shadow-spread'] ) . 'px ' . esc_attr( $options['box-shadow-color'] ) . ';';
|
||||
} ?>
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<?php
|
||||
// convert hex+opacity to rgba
|
||||
if( $options['overlay-color'] || $options['overlay-opacity'] ){
|
||||
if( empty($options['overlay-color']) ){ $options['overlay-color'] = '#ffffff'; }
|
||||
if( empty($options['overlay-opacity']) ){ $options['overlay-opacity'] = 0; }
|
||||
|
||||
$hex = $options['overlay-color'];
|
||||
list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
|
||||
|
||||
$overlay_color = "rgba($r, $g, $b, " . ($options['overlay-opacity']/100) . ")";
|
||||
}
|
||||
?>
|
||||
|
||||
<div inline-class="img-background">
|
||||
<table width="100%" class="responsive" border="0" cellspacing="0" cellpadding="0" inline-class="table">
|
||||
|
||||
<?php if ($options['title']) { ?>
|
||||
<tr style="background-color: <?php echo esc_attr( $overlay_color ); ?>;">
|
||||
<td align="center" inline-class="title">
|
||||
<?php echo esc_html( $options['title'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($options['text']) { ?>
|
||||
<tr style="background-color: <?php echo esc_attr( $overlay_color ); ?>;">
|
||||
<td align="center" inline-class="text">
|
||||
<?php echo esc_html( $options['text'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
BIN
blocks/mbtnp-cover/icon.png
Normal file
BIN
blocks/mbtnp-cover/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
64
blocks/mbtnp-cover/options.php
Normal file
64
blocks/mbtnp-cover/options.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/* @var $options array It contains all the options of the current block, but usually there is no need to access it directly */
|
||||
/* @var $fields NewsletterFields */
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $controls->hidden('image_url') ?>
|
||||
|
||||
<?php $fields->media('image', __('Image', 'advanced-composer-blocks-for-newsletter'), array('alt' => false)) ?>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->color('overlay-color', __('Overlay color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->number('overlay-opacity', __('Overlay opacity', 'advanced-composer-blocks-for-newsletter'), array('min' => 0, 'max' => 100)) ?>
|
||||
<script>jQuery('#options-overlay-opacity').after('%');</script>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->size('border-radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $fields->text('title', __('Title', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<?php $fields->font('title_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
|
||||
<?php $fields->textarea('text', __('Text', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<?php $fields->font( 'font', '', [ 'family_default' => true, 'size_default' => true, 'weight_default' => true, 'align'=>true ] ) ?>
|
||||
|
||||
<div class="tnp-field-row" style="padding: 10px;">
|
||||
<div class="tnp-field-col">
|
||||
<p style="margin: 0; font-size: 14px; font-weight: 300; padding-bottom: 5px; color: #666;">Padding</p>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php $fields->size('padding-left', __('← Left', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('padding-top', __('↑ Top', 'advanced-composer-blocks-for-newsletter')) ?><?php $fields->size('padding-bottom', __('↓ Bottom', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('padding-right', __('→ Right', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row" style="padding: 10px;">
|
||||
<div class="tnp-field-col">
|
||||
<p style="margin: 0; font-size: 14px; font-weight: 300; padding-bottom: 5px; color: #666;">Box shadow</p>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php $fields->color('box-shadow-color', __('Color', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('box-shadow-x', __('↔ X-offset', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('box-shadow-y', __('↕ Y-offset', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('box-shadow-blur', __('Blur', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('box-shadow-spread', __('Spread', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr style="clear:both; margin: 20px 0;" />
|
||||
|
||||
<?php $fields->block_commons() ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue