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() ?>
|
||||
59
blocks/mbtnp-cta/block.php
Normal file
59
blocks/mbtnp-cta/block.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Call To Action+
|
||||
* Section: content
|
||||
* Description: Call to action button
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$default_options = array(
|
||||
'button_text' => 'Learn more',
|
||||
'button_url' => '',
|
||||
'button_color' => '#000000',
|
||||
'button_border_radius' => '3',
|
||||
'text_color' => '#ffffff',
|
||||
'align' => 'center',
|
||||
'block_background' => '',
|
||||
'button_width' => 'inline',
|
||||
'button_align' => 'center',
|
||||
'block_padding_top' => 20,
|
||||
'block_padding_bottom' => 20,
|
||||
'schema' => ''
|
||||
);
|
||||
|
||||
$options = array_merge($default_options, $options);
|
||||
|
||||
$text_style = TNP_Composer::get_style($options, 'button_text', $composer, 'text');
|
||||
?>
|
||||
|
||||
<style>
|
||||
.button {
|
||||
<?php echo esc_html( $text_style->echo_css() ) ?>
|
||||
background: <?php echo esc_attr( $options['button_color'] ); ?>;
|
||||
color: <?php echo esc_attr( $options['text_color'] ); ?>;
|
||||
display: inline-block;
|
||||
<?php if( $options['button_width'] == 'full_width' ){ ?>
|
||||
display: block;
|
||||
<?php } ?>
|
||||
padding: 12px 24px;
|
||||
<?php if( $options['button_text_font_size'] ){ ?>
|
||||
padding: <?php echo esc_attr( $options['button_text_font_size'] ) * 0.75; ?>px <?php echo esc_attr( $options['button_text_font_size'] ) * 1.5; ?>px;
|
||||
<?php } ?>
|
||||
text-decoration: none;
|
||||
<?php if( $options['button_border_radius'] ){ ?>
|
||||
border-radius: <?php echo esc_attr( $options['button_border_radius'] ); ?>px;
|
||||
<?php } ?>
|
||||
}
|
||||
</style>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; border-collapse: collapse;">
|
||||
<tr>
|
||||
<td align="<?php echo esc_attr( $options['button_align'] ) ?>">
|
||||
<a href="<?php echo esc_url( $options['button_url'] ) ?>" inline-class="button"><?php echo esc_html( $options['button_text'] ); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
BIN
blocks/mbtnp-cta/icon.png
Normal file
BIN
blocks/mbtnp-cta/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
39
blocks/mbtnp-cta/options.php
Normal file
39
blocks/mbtnp-cta/options.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/* @var $fields NewsletterFields */
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $fields->text('button_text', __('Button text', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<?php $fields->font('button_text_font', '', [ 'family_default' => true, 'size_default' => true, 'weight_default' => true, 'align'=>false, 'color'=>false ] ) ?>
|
||||
|
||||
<?php $fields->url('button_url', __('Button link URL', 'advanced-composer-blocks-for-newsletter') ) ?>
|
||||
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->color('text_color', __('Text color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->color('button_color', __('Button color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->size('button_border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('button_width', 'Width', ['inline' => __('Inline'), 'full_width' => __('Full width')]) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('button_align', 'Alignment', ['center' => __('Center'), 'left' => __('Left'), 'right' => __('Right')]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr style="clear:both;margin:20px 0;" />
|
||||
|
||||
<?php $fields->block_commons() ?>
|
||||
110
blocks/mbtnp-image/block.php
Normal file
110
blocks/mbtnp-image/block.php
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Image+
|
||||
* Section: content
|
||||
* Description: Extended image 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(
|
||||
'image' => '',
|
||||
'image-alt' => '',
|
||||
'url' => '',
|
||||
'width' => 0,
|
||||
'border-radius' => '7',
|
||||
'box-shadow-x' => '0',
|
||||
'box-shadow-y' => '0',
|
||||
'box-shadow-blur' => '0',
|
||||
'box-shadow-spread' => '0',
|
||||
'box-shadow-color' => '#ffffff',
|
||||
'align' => 'center',
|
||||
'block_background' => '',
|
||||
'block_padding_left' => 0,
|
||||
'block_padding_right' => 0,
|
||||
'block_padding_bottom' => 15,
|
||||
'block_padding_top' => 15
|
||||
);
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
|
||||
if (empty($options['image']['id'])) {
|
||||
if ( !empty($options['image-url']) ) {
|
||||
$media = new TNP_Media();
|
||||
$media->url = $options['image-url'];
|
||||
$media->width = $composer['width'];
|
||||
} else {
|
||||
$media = new TNP_Media();
|
||||
// A placeholder can be set by a preset and it is kept indefinitely
|
||||
if ( !empty($options['placeholder']) ) {
|
||||
$media->url = $options['placeholder'];
|
||||
$media->width = $composer['width'];
|
||||
$media->height = 250;
|
||||
} else {
|
||||
$media->url = esc_url( MBTNP_PLUGIN_URL . '/images/placeholder-image.jpg' );
|
||||
$media->width = $composer['width'];
|
||||
$media->height = 250;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$media = tnp_resize_2x($options['image']['id'], [$composer['width'], 0]);
|
||||
// Should never happen but... it happens
|
||||
if (!$media) {
|
||||
echo 'The selected media file cannot be processed';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($options['width'])) {
|
||||
$media->set_width( $options['width'] );
|
||||
}
|
||||
$media->link = $options['url'];
|
||||
$media->alt = $options['image-alt'];
|
||||
$media->border_radius = $options['border-radius'];
|
||||
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td align="', esc_attr( $options['align'] ), '">';
|
||||
|
||||
if ( $media->link ) {
|
||||
echo '<a href="', esc_url( $media->link ), '" target="_blank" rel="noopener nofollow" style="display: block; font-size: 0; text-decoration: none; line-height: normal !important;">';
|
||||
} else {
|
||||
}
|
||||
|
||||
echo '<img src="', esc_url( $media->url ), '" width="', esc_attr( $media->width ), '"';
|
||||
if ( $media->height ) {
|
||||
echo ' height="', esc_attr( $media->height ), '"';
|
||||
}
|
||||
echo ' alt="', esc_attr( $media->alt ), '"';
|
||||
// The font size is important for the alt text
|
||||
echo ' border="0" style="display: block; height: auto; max-width: ', esc_attr( $media->width ), 'px !important; width: 100%; padding: 0; border: 0; font-size: 12px;';
|
||||
if( $media->border_radius ){
|
||||
echo ' border-radius: ' . esc_attr( $media->border_radius ) . 'px;';
|
||||
}
|
||||
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'] ) . ';';
|
||||
}
|
||||
echo '">';
|
||||
|
||||
if ( $media->link ) {
|
||||
echo '</a>';
|
||||
} else {
|
||||
}
|
||||
|
||||
echo '</td></tr></table>';
|
||||
BIN
blocks/mbtnp-image/icon.png
Normal file
BIN
blocks/mbtnp-image/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
53
blocks/mbtnp-image/options.php
Normal file
53
blocks/mbtnp-image/options.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?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 */
|
||||
|
||||
/**
|
||||
* This is a simple options panel for a Newsletter Composer Block.
|
||||
* $fields contains many useful methods to create controls in a easy way.
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $controls->hidden('placeholder') ?>
|
||||
<?php $fields->media('image', 'Choose an image', array('alt' => false)) ?>
|
||||
<?php $fields->url('image-url', 'or full path to an external image') ?>
|
||||
<?php $fields->text('image-alt', 'Alternative text') ?>
|
||||
<?php $fields->url('url', __('Link URL (if you want to link the image)', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->size('width', __('Width', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->align() ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr style="clear:both; margin: 20px 0;" />
|
||||
|
||||
<div class="tnp-field-row" style="padding: 10px;">
|
||||
<div class="tnp-field-col">
|
||||
<?php $fields->size('border-radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<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;" />
|
||||
|
||||
<?php $fields->block_commons() ?>
|
||||
223
blocks/mbtnp-posts-list/block.php
Normal file
223
blocks/mbtnp-posts-list/block.php
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Posts List
|
||||
* Section: content
|
||||
* Description: Extended text block
|
||||
*
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* @var $options array */
|
||||
|
||||
$default_options = array(
|
||||
'post_type'=>'post',
|
||||
'number_posts' => 3,
|
||||
'wrap_padding_left' => 10,
|
||||
'wrap_padding_right' => 10,
|
||||
'wrap_padding_top' => 10,
|
||||
'wrap_padding_bottom' => 10,
|
||||
'wrap_border_width' => 0,
|
||||
'wrap_border_color' => '#000000',
|
||||
'wrap_border_radius' => 0,
|
||||
'post_list_row_gap' => 0,
|
||||
'image_align' => 'left',
|
||||
'image_size' => 'none',
|
||||
'border_radius' => 0,
|
||||
'hide_titles' => '',
|
||||
'link_titles' => '',
|
||||
'title_font_size' => '24',
|
||||
'title_font_align' => 'left',
|
||||
'post_date_font_size' => '14',
|
||||
'post_date_font_align' => 'left',
|
||||
'post_content_font_size' => '16',
|
||||
'post_content_font_align' => 'left',
|
||||
'show_content' => 'none',
|
||||
'button_text' => 'Read more',
|
||||
'button_text_font_size' => '16',
|
||||
'button_color' => '#000000',
|
||||
'button_text_color' => '#ffffff',
|
||||
'button_border_radius' => '3',
|
||||
'button_align' => 'left',
|
||||
'block_padding_left'=>15,
|
||||
'block_padding_right'=>15,
|
||||
'block_padding_top' => 20,
|
||||
'block_padding_bottom' => 20,
|
||||
'block_background'=>'#eeeeee'
|
||||
);
|
||||
|
||||
$options = array_merge($default_options, $options);
|
||||
|
||||
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
||||
$post_date_style = TNP_Composer::get_title_style($options, 'post_date', $composer);
|
||||
$post_content_style = TNP_Composer::get_title_style($options, 'post_content', $composer);
|
||||
$button_text_style = TNP_Composer::get_title_style($options, 'button_text', $composer);
|
||||
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
||||
$post_custom_html_style = TNP_Composer::get_style($options, '', $composer, 'post_custom_html');
|
||||
|
||||
?>
|
||||
<style>
|
||||
.block-wrap {
|
||||
padding: 10px;
|
||||
padding-top: <?php echo esc_attr( $options['wrap_padding_top'] ); ?>px;
|
||||
padding-bottom: <?php echo esc_attr( $options['wrap_padding_bottom'] ); ?>px;
|
||||
padding-left: <?php echo esc_attr( $options['wrap_padding_left'] ); ?>px;
|
||||
padding-right: <?php echo esc_attr( $options['wrap_padding_right'] ); ?>px;
|
||||
background-color: <?php echo esc_attr( $options['wrap_background_color'] ); ?>;
|
||||
border: <?php echo esc_attr( $options['wrap_border_width'] ) ?>px solid <?php echo esc_attr( $options['wrap_border_color'] ); ?>;
|
||||
border-radius: <?php echo esc_attr( $options['wrap_border_radius'] ); ?>px;
|
||||
}
|
||||
.post-row {
|
||||
padding-bottom: <?php echo esc_attr( $options['post_list_row_gap'] ); ?>px;
|
||||
}
|
||||
.featured-image-wrap {
|
||||
text-align: <?php echo esc_attr( $options['image_align'] ); ?>;
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.featured-image {
|
||||
border-radius: <?php echo esc_attr( $options['border_radius'] ); ?>px;
|
||||
}
|
||||
.title {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.title-link {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
<?php if( $options['title_font_color'] ){ ?>
|
||||
color: <?php echo esc_attr( $options['title_font_color'] ); ?>;
|
||||
<?php } ?>
|
||||
}
|
||||
.post-date {
|
||||
<?php esc_html( $post_date_style->echo_css() ) ?>
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-excerpt {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-full {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-button-wrap {
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
text-align: <?php echo esc_attr( $options['button_align'] ); ?>;
|
||||
}
|
||||
.post-button {
|
||||
<?php echo esc_html( $text_style->echo_css() ) ?>
|
||||
<?php echo esc_html( $button_text_style->echo_css() ) ?>
|
||||
background: <?php echo esc_attr( $options['button_color'] ); ?>;
|
||||
color: <?php echo esc_attr( $options['button_text_color'] ); ?>;
|
||||
display: inline-block;
|
||||
<?php if( $options['button_width'] == 'full_width' ){ ?>
|
||||
display: block;
|
||||
<?php } ?>
|
||||
padding: 12px 24px;
|
||||
<?php if( $options['button_text_font_size'] ){ ?>
|
||||
padding: <?php echo esc_attr( $options['button_text_font_size'] ) * 0.5; ?>px <?php echo esc_attr( $options['button_text_font_size'] ) * 1; ?>px;
|
||||
<?php } ?>
|
||||
text-decoration: none;
|
||||
<?php if( $options['button_border_radius'] ){ ?>
|
||||
border-radius: <?php echo esc_attr( $options['button_border_radius'] ); ?>px;
|
||||
<?php } ?>
|
||||
}
|
||||
</style>
|
||||
|
||||
<div inline-class="block-wrap">
|
||||
<table width="100%" style="width: 100% !important;" border="0" cellpadding="0" cellspacing="0">
|
||||
<?php if( $options['post_type'] ){ ?>
|
||||
<?php
|
||||
$post_list_args = array(
|
||||
'post_type' => $options['post_type'],
|
||||
'posts_per_page' => $options['number_posts']
|
||||
);
|
||||
if( $options['post_order'] == 'title_asc' ){
|
||||
$post_list_args['orderby'] = 'title';
|
||||
$post_list_args['order'] = 'ASC';
|
||||
} else if( $options['post_order'] == 'title_desc' ){
|
||||
$post_list_args['orderby'] = 'title';
|
||||
$post_list_args['order'] = 'DESC';
|
||||
} else if( $options['post_order'] == 'date_asc' ){
|
||||
$post_list_args['orderby'] = 'date';
|
||||
$post_list_args['order'] = 'ASC';
|
||||
} else if( $options['post_order'] == 'date_desc' ){
|
||||
$post_list_args['orderby'] = 'date';
|
||||
$post_list_args['order'] = 'DESC';
|
||||
}
|
||||
$posts_list = get_posts($post_list_args); ?>
|
||||
<?php foreach($posts_list as $post){
|
||||
$post_custom_html = $options['post_custom_html']; ?>
|
||||
<tr>
|
||||
<td width="100%" valign="top" align="left" class="post-row" inline-class="post-row">
|
||||
<?php if($options['image_size'] != 'none'){ ?>
|
||||
<div inline-class="featured-image-wrap">
|
||||
<?php if($options['link_images'] == 1){ echo '<a href="'.esc_url( get_the_permalink($post->ID) ).'" inline-class="featured-image-link">'; } ?>
|
||||
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $post->ID, $options['image_size'] ) ); ?>" inline-class="featured-image" />
|
||||
<?php if($options['link_images'] == 1){ echo '</a>'; } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['hide_titles'] != 1){ ?>
|
||||
<p inline-class="title">
|
||||
<?php if($options['link_titles'] == 1){ echo '<a href="'. esc_url( get_the_permalink($post->ID) ).'" inline-class="title-link">'; } ?>
|
||||
<?php echo esc_html( $post->post_title ); ?>
|
||||
<?php if($options['link_titles'] == 1){ echo '</a>'; } ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_post_dates'] == 1){ ?>
|
||||
<p inline-class="post-date">
|
||||
<?php echo esc_html( gmdate("F j, Y", strtotime($post->post_date) ) ); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'excerpt'){ ?>
|
||||
<div inline-class="post-excerpt">
|
||||
<?php if( $options['excerpt_length'] ){
|
||||
echo wp_kses_post( mbtnp_get_the_excerpt( $post->ID, $options['excerpt_length'] ) );
|
||||
} else {
|
||||
echo wp_kses_post( get_the_excerpt( $post->ID ) );
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'full'){ ?>
|
||||
<div inline-class="post-full">
|
||||
<?php echo wp_kses_post( get_the_content('','',$post->ID) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( !empty( trim($post_custom_html) ) ){ ?>
|
||||
<div>
|
||||
<?php echo wp_kses_post( mbtnp_replace_tags( $post_custom_html, $post->ID ) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( $options['hide_buttons'] != 1 ){ ?>
|
||||
<div inline-class="post-button-wrap">
|
||||
<a href="<?php echo esc_url( get_the_permalink($post->ID) ); ?>" inline-class="post-button"><?php echo esc_html( mbtnp_replace_tags( $options['button_text'], $post->ID ) ); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
BIN
blocks/mbtnp-posts-list/icon.png
Normal file
BIN
blocks/mbtnp-posts-list/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
246
blocks/mbtnp-posts-list/options.php
Normal file
246
blocks/mbtnp-posts-list/options.php
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
/*
|
||||
* @var $options array contains all the options the current block we're ediging contains
|
||||
* @var $controls NewsletterControls
|
||||
* @var $fields NewsletterFields
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// get all post type options
|
||||
$post_types = get_post_types( array( 'public' => true ), 'objects' );
|
||||
$post_type_options = [];
|
||||
foreach($post_types as $post_type){
|
||||
$post_type_options[$post_type->name] = $post_type->label;
|
||||
}
|
||||
|
||||
// get all thumbnail size options
|
||||
$image_sizes = wp_get_registered_image_subsizes();
|
||||
$image_size_options = ['none' => 'None'];
|
||||
foreach($image_sizes as $name => $details){
|
||||
$image_size_options[$name] = ucfirst(str_replace('_', ' ', $name)) . ' (' . $details['width'] . 'x' . $details['height'] . ')';
|
||||
}
|
||||
$image_size_options['full'] = 'Full';
|
||||
?>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->select('post_type', __('Post type'), $post_type_options) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->select('post_order', __('Post order'), ['title_asc' => 'Title ASC', 'title_desc' => 'Title DESC', 'date_asc' => 'Post date ASC', 'date_desc' => 'Post date DESC']) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->number('number_posts', __('Number of posts'), ['min' => 1]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Featured images</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('image_size', __('Image size'), $image_size_options) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-link_images">
|
||||
<?php $fields->checkbox('link_images', __('Link image to post')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2" id="o-image_align">
|
||||
<?php $fields->select('image_align', __('Align'), ['left' => 'Left', 'center' => 'Center', 'right' => 'Right']) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-border_radius">
|
||||
<?php $fields->size('border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Titles</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->checkbox('hide_titles', __('Hide titles')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-link_titles">
|
||||
<?php $fields->checkbox('link_titles', __('Link title to post')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-title_font">
|
||||
<?php $fields->font('title_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Post dates</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->checkbox('show_post_dates', __('Show post dates')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-post_date_font">
|
||||
<?php $fields->font('post_date_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Post content</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('show_content', __('Show content'), ['none' => 'None', 'excerpt' => 'Excerpt', 'full' => 'Full']) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-excerpt_length">
|
||||
<?php $fields->number('excerpt_length', __('Excerpt length (characters)')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-post_content_font">
|
||||
<?php $fields->font('post_content_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Custom content</p>
|
||||
<p style="font-size: 0.9em; margin-top: 0;">Add custom fields by using brackets. Ex: for "custom_name", use <strong>{field_custom_name}</strong></p>
|
||||
<?php $fields->wp_editor( 'post_custom_html', 'Content', [
|
||||
'post_custom_html_font_family' => $composer['post_custom_html_font_family'],
|
||||
'post_custom_html_font_size' => $composer['post_custom_html_font_size'],
|
||||
'post_custom_html_font_weight' => $composer['post_custom_html_font_weight'],
|
||||
'post_custom_html_font_color' => $composer['post_custom_html_font_color'],
|
||||
] ) ?>
|
||||
|
||||
<p class="mbtnp-section-title">Buttons</p>
|
||||
<?php $fields->checkbox('hide_buttons', __('Hide buttons')) ?>
|
||||
<div id="o-button_text">
|
||||
<?php $fields->text('button_text', __('Button text', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<?php $fields->font('button_text_font', '', [ 'family_default' => true, 'size_default' => true, 'weight_default' => true, 'align'=>false, 'color'=>false ] ) ?>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3" id="o-button_text_color">
|
||||
<?php $fields->color('button_text_color', __('Text color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3" id="o-button_color">
|
||||
<?php $fields->color('button_color', __('Button color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3" id="o-button_border_color">
|
||||
<?php $fields->size('button_border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2" id="o-button_width">
|
||||
<?php $fields->select('button_width', 'Width', ['inline' => __('Inline'), 'full_width' => __('Full width')]) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2"id="o-button_align">
|
||||
<?php $fields->select('button_align', 'Alignment', ['center' => __('Center'), 'left' => __('Left'), 'right' => __('Right')]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Layout</p>
|
||||
<?php $fields->size('post_list_row_gap', __('Row gap', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->size('wrap_border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->color('wrap_background_color', __('Background color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->size('wrap_border_width', __('Border width', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->color('wrap_border_color', __('Border color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row" style="padding: 10px;">
|
||||
<div class="tnp-field-col">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php $fields->size('wrap_padding_left', __('← Left', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('wrap_padding_top', __('↑ Top', 'advanced-composer-blocks-for-newsletter')) ?><?php $fields->size('wrap_padding_bottom', __('↓ Bottom', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('wrap_padding_right', __('→ Right', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<hr style="clear:both; margin:20px 0;" />
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
function mbtnp_post_list_visibility(){
|
||||
|
||||
// thumbnail rules
|
||||
var image_size = $('#options-image_size').val();
|
||||
if(image_size == 'none'){
|
||||
$('#o-link_images').hide();
|
||||
$('#o-image_align').hide();
|
||||
$('#o-border_radius').hide();
|
||||
} else {
|
||||
$('#o-link_images').show();
|
||||
$('#o-image_align').show();
|
||||
$('#o-border_radius').show();
|
||||
}
|
||||
|
||||
// title rules
|
||||
var hide_titles = $('#options-hide_titles').is(':checked');
|
||||
if(hide_titles){
|
||||
$('#o-link_titles').hide();
|
||||
$('#o-title_font').hide();
|
||||
} else {
|
||||
$('#o-link_titles').show();
|
||||
$('#o-title_font').show();
|
||||
}
|
||||
|
||||
// post date rules
|
||||
var show_post_dates = $('#options-show_post_dates').is(':checked');
|
||||
if(show_post_dates){
|
||||
$('#o-post_date_font').show();
|
||||
} else {
|
||||
$('#o-post_date_font').hide();
|
||||
}
|
||||
|
||||
// content rules
|
||||
var show_content = $('#options-show_content').val();
|
||||
if(show_content == 'none'){
|
||||
$('#o-excerpt_length').hide();
|
||||
$('#o-post_content_font').hide();
|
||||
} else {
|
||||
$('#o-excerpt_length').show();
|
||||
$('#o-post_content_font').show();
|
||||
}
|
||||
|
||||
// button rules
|
||||
var hide_buttons = $('#options-hide_buttons').is(':checked');
|
||||
if(hide_buttons){
|
||||
$('#o-button_text').hide();
|
||||
$('#o-button_text_color').hide();
|
||||
$('#o-button_color').hide();
|
||||
$('#o-button_border_color').hide();
|
||||
$('#o-button_width').hide();
|
||||
$('#o-button_align').hide();
|
||||
} else {
|
||||
$('#o-button_text').show();
|
||||
$('#o-button_text_color').show();
|
||||
$('#o-button_color').show();
|
||||
$('#o-button_border_color').show();
|
||||
$('#o-button_width').show();
|
||||
$('#o-button_align').show();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).delegate('input, select', 'change', function(e){
|
||||
e.preventDefault();
|
||||
mbtnp_post_list_visibility();
|
||||
});
|
||||
|
||||
// if mouse hovers #tnpc-block-options
|
||||
$('#tnpc-block-options').hover(function(){
|
||||
mbtnp_post_list_visibility();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php $fields->block_commons() ?>
|
||||
234
blocks/mbtnp-single-post/block.php
Normal file
234
blocks/mbtnp-single-post/block.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Single Post
|
||||
* Section: content
|
||||
* Description: Extended text block
|
||||
*
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* @var $options array */
|
||||
|
||||
$default_options = array(
|
||||
'wrap_padding_left' => 10,
|
||||
'wrap_padding_right' => 10,
|
||||
'wrap_padding_top' => 10,
|
||||
'wrap_padding_bottom' => 10,
|
||||
'wrap_border_width' => 0,
|
||||
'wrap_border_color' => '#000000',
|
||||
'wrap_border_radius' => 0,
|
||||
'image_align' => 'center',
|
||||
'image_size' => 'medium',
|
||||
'link_image' => '',
|
||||
'border_radius' => 0,
|
||||
'hide_title' => '',
|
||||
'link_title' => '',
|
||||
'title_font_size' => '24',
|
||||
'title_font_align' => 'left',
|
||||
'post_date_font_size' => '16',
|
||||
'post_date_font_align' => 'left',
|
||||
'post_content_font_size' => '16',
|
||||
'post_content_font_align' => 'left',
|
||||
'post_custom_html_font_size' => '16',
|
||||
'post_custom_html_font_align' => 'left',
|
||||
'post_custom_html_font_color' => '#000000',
|
||||
'show_content' => 'excerpt',
|
||||
'hide_button' => '',
|
||||
'button_text' => 'Read more',
|
||||
'button_text_font_size' => '16',
|
||||
'button_color' => '#000000',
|
||||
'button_text_color' => '#ffffff',
|
||||
'button_border_radius' => '3',
|
||||
'button_align' => 'left',
|
||||
'block_padding_left'=>15,
|
||||
'block_padding_right'=>15,
|
||||
'block_padding_top' => 20,
|
||||
'block_padding_bottom' => 20,
|
||||
'block_background'=>'#eeeeee'
|
||||
);
|
||||
|
||||
$options = array_merge($default_options, $options);
|
||||
|
||||
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
||||
$post_date_style = TNP_Composer::get_title_style($options, 'post_date', $composer);
|
||||
$post_content_style = TNP_Composer::get_title_style($options, 'post_content', $composer);
|
||||
$button_text_style = TNP_Composer::get_title_style($options, 'button_text', $composer);
|
||||
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
||||
$post_custom_html_style = TNP_Composer::get_style($options, 'post_custom_html', $composer);
|
||||
|
||||
?>
|
||||
<style>
|
||||
.block-wrap {
|
||||
padding: 10px;
|
||||
padding-top: <?php echo esc_attr( $options['wrap_padding_top'] ); ?>px;
|
||||
padding-bottom: <?php echo esc_attr( $options['wrap_padding_bottom'] ); ?>px;
|
||||
padding-left: <?php echo esc_attr( $options['wrap_padding_left'] ); ?>px;
|
||||
padding-right: <?php echo esc_attr( $options['wrap_padding_right'] ); ?>px;
|
||||
background-color: <?php echo esc_attr( $options['wrap_background_color'] ); ?>;
|
||||
border: <?php echo esc_attr( $options['wrap_border_width'] ) ?>px solid <?php echo esc_attr( $options['wrap_border_color'] ); ?>;
|
||||
border-radius: <?php echo esc_attr( $options['wrap_border_radius'] ); ?>px;
|
||||
}
|
||||
.post-row {
|
||||
padding-bottom: <?php echo esc_attr( $options['post_list_row_gap'] ); ?>px;
|
||||
}
|
||||
.featured-image-wrap {
|
||||
text-align: <?php echo esc_attr( $options['image_align'] ); ?>;
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.featured-image {
|
||||
border-radius: <?php echo esc_attr( $options['border_radius'] ); ?>px;
|
||||
}
|
||||
.title {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.title-link {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
<?php if( $options['title_font_color'] ){ ?>
|
||||
color: <?php echo esc_attr( $options['title_font_color'] ); ?>;
|
||||
<?php } ?>
|
||||
}
|
||||
.post-date {
|
||||
<?php esc_html( $post_date_style->echo_css() ) ?>
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-excerpt {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: 1.4em;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-full {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-custom-html {
|
||||
mso-line-height-rule: exactly;
|
||||
<?php echo esc_html( $post_custom_html_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-button-wrap {
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
text-align: <?php echo esc_attr( $options['button_align'] ); ?>;
|
||||
}
|
||||
.post-button {
|
||||
<?php echo esc_html( $text_style->echo_css() ) ?>
|
||||
<?php echo esc_html( $button_text_style->echo_css() ) ?>
|
||||
background: <?php echo esc_attr( $options['button_color'] ); ?>;
|
||||
color: <?php echo esc_attr( $options['button_text_color'] ); ?>;
|
||||
display: inline-block;
|
||||
<?php if( $options['button_width'] == 'full_width' ){ ?>
|
||||
display: block;
|
||||
<?php } ?>
|
||||
padding: 12px 24px;
|
||||
<?php if( $options['button_text_font_size'] ){ ?>
|
||||
padding: <?php echo esc_attr( $options['button_text_font_size'] ) * 0.5; ?>px <?php echo esc_attr( $options['button_text_font_size'] ) * 1; ?>px;
|
||||
<?php } ?>
|
||||
text-decoration: none;
|
||||
<?php if( $options['button_border_radius'] ){ ?>
|
||||
border-radius: <?php echo esc_attr( $options['button_border_radius'] ); ?>px;
|
||||
<?php } ?>
|
||||
}
|
||||
</style>
|
||||
|
||||
<div inline-class="block-wrap">
|
||||
<table width="100%" style="width: 100% !important;" border="0" cellpadding="0" cellspacing="0">
|
||||
<?php if( $options['post_id'] ){ ?>
|
||||
<?php if( get_post($options['post_id']) ){ ?>
|
||||
<?php
|
||||
$post_id = (int)$options['post_id'];
|
||||
$post_arr[] = $post_id;
|
||||
$post_type = get_post_type( $post_id );
|
||||
$post_list_args = array(
|
||||
'post__in' => $post_arr,
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => $post_type
|
||||
);
|
||||
$posts_list = get_posts($post_list_args); ?>
|
||||
<?php foreach($posts_list as $post){
|
||||
$post_custom_html = $options['post_custom_html']; ?>
|
||||
<tr>
|
||||
<td width="100%" valign="top" align="left" class="post-row" inline-class="post-row">
|
||||
<?php if($options['image_size'] != 'none'){ ?>
|
||||
<div inline-class="featured-image-wrap">
|
||||
<?php if( $options['link_image'] == 1 ){ echo '<a href="' . esc_url( get_the_permalink($post->ID) ) . '" inline-class="featured-image-link">'; } ?>
|
||||
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $post->ID, $options['image_size'] ) ); ?>" inline-class="featured-image" />
|
||||
<?php if($options['link_image'] == 1){ echo '</a>'; } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['hide_title'] != 1){ ?>
|
||||
<p inline-class="title">
|
||||
<?php if($options['link_title'] == 1){ echo '<a href="' . esc_url( get_the_permalink($post->ID) ) . '" inline-class="title-link">'; } ?>
|
||||
<?php echo esc_html( $post->post_title ); ?>
|
||||
<?php if( $options['link_title'] == 1 ){ echo '</a>'; } ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_post_date'] == 1){ ?>
|
||||
<p inline-class="post-date">
|
||||
<?php echo esc_html( gmdate("F j, Y", strtotime($post->post_date) ) ); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'excerpt'){ ?>
|
||||
<div inline-class="post-excerpt">
|
||||
<?php if( $options['excerpt_length'] ){
|
||||
echo wp_kses_post( mbtnp_get_the_excerpt( $post->ID, $options['excerpt_length'] ) );
|
||||
} else {
|
||||
echo wp_kses_post( get_the_excerpt( $post->ID ) );
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'full'){ ?>
|
||||
<div inline-class="post-full">
|
||||
<?php echo wp_kses_post( get_the_content('','',$post->ID) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( !empty( trim($post_custom_html) ) ){ ?>
|
||||
<div inline-class="post-custom-html">
|
||||
<?php echo wp_kses_post( mbtnp_replace_tags( $post_custom_html, $post->ID ) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( $options['hide_button'] != 1 ){ ?>
|
||||
<div inline-class="post-button-wrap">
|
||||
<a href="<?php echo esc_url( get_the_permalink($post->ID) ); ?>" inline-class="post-button"><?php echo esc_html( mbtnp_replace_tags( $options['button_text'], $post->ID ) ); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><p>That post ID is not valid. <a href="https://mburnette.com/find-postid/" target="_blank">How to find your post ID.</a></p></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><p>Please enter a post ID. <a href="https://mburnette.com/find-postid/" target="_blank">How to find your post ID.</a></p></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
BIN
blocks/mbtnp-single-post/icon.png
Normal file
BIN
blocks/mbtnp-single-post/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
248
blocks/mbtnp-single-post/options.php
Normal file
248
blocks/mbtnp-single-post/options.php
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/*
|
||||
* @var $options array contains all the options the current block we're ediging contains
|
||||
* @var $controls NewsletterControls
|
||||
* @var $fields NewsletterFields
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// get all post type options
|
||||
$post_types = get_post_types( array( 'public' => true ), 'objects' );
|
||||
$post_type_options = [];
|
||||
foreach($post_types as $post_type){
|
||||
$post_type_options[$post_type->name] = $post_type->label;
|
||||
}
|
||||
|
||||
// get all thumbnail size options
|
||||
$image_sizes = wp_get_registered_image_subsizes();
|
||||
$image_size_options = ['none' => 'None'];
|
||||
foreach($image_sizes as $name => $details){
|
||||
$image_size_options[$name] = ucfirst(str_replace('_', ' ', $name)) . ' (' . $details['width'] . 'x' . $details['height'] . ')';
|
||||
}
|
||||
$image_size_options['full'] = 'Full';
|
||||
?>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->text('post_id', __('Post ID', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Featured image</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('image_size', __('Image size', 'advanced-composer-blocks-for-newsletter'), $image_size_options) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-link_image">
|
||||
<?php $fields->checkbox('link_image', __('Link image to post', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2" id="o-image_align">
|
||||
<?php $fields->select('image_align', __('Align', 'advanced-composer-blocks-for-newsletter'), ['center' => 'Center', 'left' => 'Left', 'right' => 'Right']) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-border_radius">
|
||||
<?php $fields->size('border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Title</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->checkbox('hide_title', __('Hide title', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-link_title">
|
||||
<?php $fields->checkbox('link_title', __('Link title to post', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-title_font">
|
||||
<?php $fields->font('title_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Post date</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->checkbox('show_post_date', __('Show post date', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-post_date_font">
|
||||
<?php $fields->font('post_date_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Post content</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2">
|
||||
<?php $fields->select('show_content', __('Show content', 'advanced-composer-blocks-for-newsletter'), ['none' => 'None', 'excerpt' => 'Excerpt', 'full' => 'Full']) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2" id="o-excerpt_length">
|
||||
<?php $fields->number('excerpt_length', __('Excerpt length (characters)', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;" id="o-post_content_font">
|
||||
<?php $fields->font('post_content_font', '', ['family_default'=>true, 'size_default'=>true, 'weight_default'=>true, 'align'=>true]) ?>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Custom content</p>
|
||||
<p style="font-size: 0.9em; margin-top: 0;">Add custom fields by using brackets. Ex: for "custom_name", use <strong>{field_custom_name}</strong></p>
|
||||
<?php $fields->wp_editor( 'post_custom_html', 'Content', [
|
||||
'post_custom_html_font_family' => $composer['post_custom_html_font_family'],
|
||||
'post_custom_html_font_size' => $composer['post_custom_html_font_size'],
|
||||
'post_custom_html_font_weight' => $composer['post_custom_html_font_weight'],
|
||||
'post_custom_html_font_color' => $composer['post_custom_html_font_color'],
|
||||
] ) ?>
|
||||
|
||||
<p class="mbtnp-section-title">Button</p>
|
||||
<?php $fields->checkbox('hide_button', __('Hide button', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<div id="o-button_text">
|
||||
<?php $fields->text('button_text', __('Button text', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
<?php $fields->font('button_text_font', '', [ 'family_default' => true, 'size_default' => true, 'weight_default' => true, 'align'=>false, 'color'=>false ] ) ?>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3" id="o-button_text_color">
|
||||
<?php $fields->color('button_text_color', __('Text color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3" id="o-button_color">
|
||||
<?php $fields->color('button_color', __('Button color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3" id="o-button_border_color">
|
||||
<?php $fields->size('button_border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-2" id="o-button_width">
|
||||
<?php $fields->select('button_width', 'Width', ['inline' => __('Inline', 'advanced-composer-blocks-for-newsletter'), 'full_width' => __('Full width', 'advanced-composer-blocks-for-newsletter')]) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-2"id="o-button_align">
|
||||
<?php $fields->select('button_align', 'Alignment', ['center' => __('Center'), 'left' => __('Left'), 'right' => __('Right')]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mbtnp-section-title">Layout</p>
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->size('wrap_border_radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->color('wrap_background_color', __('Background color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->size('wrap_border_width', __('Border width', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-4">
|
||||
<?php $fields->color('wrap_border_color', __('Border color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tnp-field-row" style="padding: 10px;">
|
||||
<div class="tnp-field-col">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php $fields->size('wrap_padding_left', __('← Left', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('wrap_padding_top', __('↑ Top', 'advanced-composer-blocks-for-newsletter')) ?><?php $fields->size('wrap_padding_bottom', __('↓ Bottom', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('wrap_padding_right', __('→ Right', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<hr style="clear:both; margin:20px 0;" />
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
function mbtnp_post_list_visibility(){
|
||||
|
||||
// thumbnail rules
|
||||
var image_size = $('#options-image_size').val();
|
||||
if(image_size == 'none'){
|
||||
$('#o-link_images').hide();
|
||||
$('#o-image_align').hide();
|
||||
$('#o-border_radius').hide();
|
||||
} else {
|
||||
$('#o-link_images').show();
|
||||
$('#o-image_align').show();
|
||||
$('#o-border_radius').show();
|
||||
}
|
||||
|
||||
// title rules
|
||||
var hide_title = $('#options-hide_title').is(':checked');
|
||||
if(hide_title){
|
||||
$('#o-link_title').hide();
|
||||
$('#o-title_font').hide();
|
||||
} else {
|
||||
$('#o-link_title').show();
|
||||
$('#o-title_font').show();
|
||||
}
|
||||
|
||||
// post date rules
|
||||
var show_post_date = $('#options-show_post_date').is(':checked');
|
||||
if(show_post_date){
|
||||
$('#o-post_date_font').show();
|
||||
} else {
|
||||
$('#o-post_date_font').hide();
|
||||
}
|
||||
|
||||
// content rules
|
||||
var show_content = $('#options-show_content').val();
|
||||
if(show_content == 'none'){
|
||||
$('#o-post_content_font').hide();
|
||||
} else {
|
||||
$('#o-post_content_font').show();
|
||||
}
|
||||
if(show_content == 'full' || show_content == 'none'){
|
||||
$('#o-excerpt_length').hide();
|
||||
} else {
|
||||
$('#o-excerpt_length').show();
|
||||
}
|
||||
|
||||
// button rules
|
||||
var hide_button = $('#options-hide_button').is(':checked');
|
||||
if(hide_button){
|
||||
$('#o-button_text').hide();
|
||||
$('#o-button_text_color').hide();
|
||||
$('#o-button_color').hide();
|
||||
$('#o-button_border_color').hide();
|
||||
$('#o-button_width').hide();
|
||||
$('#o-button_align').hide();
|
||||
} else {
|
||||
$('#o-button_text').show();
|
||||
$('#o-button_text_color').show();
|
||||
$('#o-button_color').show();
|
||||
$('#o-button_border_color').show();
|
||||
$('#o-button_width').show();
|
||||
$('#o-button_align').show();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).delegate('input, select', 'change', function(e){
|
||||
e.preventDefault();
|
||||
mbtnp_post_list_visibility();
|
||||
});
|
||||
|
||||
// if mouse hovers #tnpc-block-options
|
||||
$('#tnpc-block-options').hover(function(){
|
||||
mbtnp_post_list_visibility();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php $fields->block_commons() ?>
|
||||
96
blocks/mbtnp-text/block.php
Normal file
96
blocks/mbtnp-text/block.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Text+
|
||||
* Section: content
|
||||
* Description: Extended text block
|
||||
*
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/* @var $options array */
|
||||
|
||||
$default_options = array(
|
||||
'html'=>'<p>Insert your text here.</p>',
|
||||
'font_family'=>'',
|
||||
'font_size'=>'',
|
||||
'font_color'=>'',
|
||||
'block_padding_left'=>15,
|
||||
'block_padding_right'=>15,
|
||||
'block_padding_top' => 20,
|
||||
'block_padding_bottom' => 20,
|
||||
'block_background'=>'#eeeeee'
|
||||
);
|
||||
|
||||
$options = array_merge($default_options, $options);
|
||||
|
||||
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
||||
|
||||
?>
|
||||
<style>
|
||||
.text {
|
||||
mso-line-height-rule: exactly;
|
||||
<?php echo esc_html( $text_style->echo_css() ) ?>
|
||||
line-height: 1.5;
|
||||
<?php if( $options['background-color'] ){ ?>
|
||||
background-color: <?php echo esc_attr( $options['background-color'] ); ?>;
|
||||
<?php } ?>
|
||||
<?php if( $options['padding-top'] ){ ?>
|
||||
padding-top: <?php echo esc_attr( $options['padding-top'] ); ?>px;
|
||||
<?php } ?>
|
||||
<?php if( $options['padding-bottom'] ){ ?>
|
||||
padding-bottom: <?php echo esc_attr( $options['padding-bottom'] ); ?>px;
|
||||
<?php } ?>
|
||||
<?php if( $options['padding-left'] ){ ?>
|
||||
padding-left: <?php echo esc_attr( $options['padding-left'] ); ?>px;
|
||||
<?php } ?>
|
||||
<?php if( $options['padding-right'] ){ ?>
|
||||
padding-right: <?php echo esc_attr( $options['padding-right'] ); ?>px;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-color'] ){ ?>
|
||||
border-color: <?php echo esc_attr( $options['border-color'] ); ?>;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-top'] ){ ?>
|
||||
border-top-width: <?php echo esc_attr( $options['border-top'] ); ?>px;
|
||||
border-top-style: solid;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-right'] ){ ?>
|
||||
border-right-width: <?php echo esc_attr( $options['border-right'] ); ?>px;
|
||||
border-right-style: solid;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-bottom'] ){ ?>
|
||||
border-bottom-width: <?php echo esc_attr( $options['border-bottom'] ); ?>px;
|
||||
border-bottom-style: solid;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-left'] ){ ?>
|
||||
border-left-width: <?php echo esc_attr( $options['border-left'] ); ?>px;
|
||||
border-left-style: solid;
|
||||
<?php } ?>
|
||||
<?php if( $options['border-radius'] ){ ?>
|
||||
border-radius: <?php echo esc_attr( $options['border-radius'] ); ?>px;
|
||||
<?php } ?>
|
||||
|
||||
<?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>
|
||||
|
||||
<table width="100%" style="width: 100% !important;" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="100%" valign="top" align="left" class="text" inline-class="text">
|
||||
<?php echo wp_kses_post( $options['html'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
BIN
blocks/mbtnp-text/icon.png
Normal file
BIN
blocks/mbtnp-text/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
83
blocks/mbtnp-text/options.php
Normal file
83
blocks/mbtnp-text/options.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/*
|
||||
* @var $options array contains all the options the current block we're ediging contains
|
||||
* @var $controls NewsletterControls
|
||||
* @var $fields NewsletterFields
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$background = empty($options['block_background']) ? $composer['block_background'] : $options['block_background'];
|
||||
$background = empty($options['background-color']) ? $background : $options['background-color'];
|
||||
?>
|
||||
<p>
|
||||
<a href="https://www.thenewsletterplugin.com/documentation/newsletters/newsletter-tags/" target="_blank">You can use tags to inject subscriber fields</a>.
|
||||
</p>
|
||||
|
||||
<?php $fields->wp_editor( 'html', 'Content', [
|
||||
'text_font_family' => $composer['text_font_family'],
|
||||
'text_font_size' => $composer['text_font_size'],
|
||||
'text_font_weight' => $composer['text_font_weight'],
|
||||
'text_font_color' => $composer['text_font_color'],
|
||||
'background' => $background
|
||||
] ) ?>
|
||||
|
||||
<div class="tnp-field-row">
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->size('border-radius', __('Border radius', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->color('background-color', __('Background color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</div>
|
||||
<div class="tnp-field-col-3">
|
||||
<?php $fields->color('border-color', __('Border color', 'advanced-composer-blocks-for-newsletter')) ?>
|
||||
</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;">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;">Border</p>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php $fields->size('border-left', __('← Left', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('border-top', __('↑ Top', 'advanced-composer-blocks-for-newsletter')) ?><?php $fields->size('border-bottom', __('↓ Bottom', 'advanced-composer-blocks-for-newsletter')) ?></td>
|
||||
<td><?php $fields->size('border-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