ADDED Code of Version 2.0.0 of the Advanced Composer Blocks for Newsletter Plugin
81
README.txt
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
=== Advanced Composer Blocks for Newsletter ===
|
||||
Contributors: mdburnette
|
||||
Tags: email, newsletter, composer, blocks
|
||||
License: GPLv2 or later
|
||||
Requires at least: 6.0
|
||||
Tested up to: 6.7
|
||||
Requires PHP: 7.0
|
||||
Stable tag: 2.0.0
|
||||
|
||||
A set of enhanced composer blocks and additional settings to extend The Newsletter Plugin.
|
||||
|
||||
== Description ==
|
||||
The WordPress plugin that lets you craft <em>modern</em> email newsletters with <em>custom fields</em> and new <em>design options</em>.
|
||||
|
||||
With upgraded blocks and custom field functionality, Advanced Composer Blocks elevates your newsletter with design and content options not available anywhere else for the Newsletter plugin.
|
||||
|
||||
<em>NOTE: Requires at least free version of the [Newsletter](https://wordpress.org/plugins/newsletter/) plugin.</em>
|
||||
|
||||
## Plugin features:
|
||||
|
||||
- <strong>6 new, feature-packed blocks</strong> - Six additional, advanced composer blocks open up a ton of new design and content options.
|
||||
- <strong>Composer editing enhancement</strong> - Make testing your newsletters even easier with the "Live Preview" button that allows you to quickly preview your email newsletter in a new tab.
|
||||
- <strong>Composer editing enhancement</strong> - Make crafting your newsletters faster with composer block "COPY" and "PASTE" features - which allows you to duplicate blocks between emails as well!
|
||||
- <strong>WordPress custom field tags</strong> - Take advantage of the custom fields you already have to further simplify creating post listings.
|
||||
|
||||
## Blocks included:
|
||||
|
||||
- Text+ [Watch demo video](https://youtu.be/Im6x9rhhYqs)
|
||||
- Image+ [Watch demo video](https://youtu.be/bbLuWLMpkms)
|
||||
- Posts List [Watch demo video](https://youtu.be/IgBt_GlWT6w)
|
||||
- Cover [Watch demo video](https://youtu.be/xl7HzM2PmXE)
|
||||
- Call to Action+ [Watch demo video](https://youtu.be/cW2Am-ehr0c)
|
||||
- Single Post+ [Watch demo video](https://youtu.be/8s4DFUUJ4NI)
|
||||
|
||||
== Screenshots ==
|
||||
1. Included composer blocks, each with a distinct dark blue icon
|
||||
2. Font, color, and layout options for the Posts List block
|
||||
3. Example of Text+ block and options
|
||||
4. Cover block with image upload, overlay, and layout options
|
||||
|
||||
== Changelog ==
|
||||
→ 11.29.24 - 2.0.0
|
||||
- Rolled premium features into the free version, discontinued paid offering
|
||||
|
||||
→ 06.26.24 - 1.3.2
|
||||
- Fixed issue with copy/paste links showing in final email
|
||||
|
||||
→ 06.24.24 - 1.3.1
|
||||
- Fixed CSS nesting issue
|
||||
- Updated Freemius SDK to 2.7.2
|
||||
|
||||
→ 06.24.24 - 1.3.0
|
||||
- Added ability to copy/paste blocks between emails
|
||||
|
||||
→ 04.11.24 - 1.2.0
|
||||
- Fixed double-declaring of a function
|
||||
- Misc typos
|
||||
|
||||
→ 03.23.24 - 1.1.1
|
||||
- Additional cleanup for inclusion in the WordPress.org repo
|
||||
|
||||
→ 03.13.24 - 1.1
|
||||
- Lots of PHP cleanup for inclusion in the WordPress.org repo
|
||||
|
||||
→ 01.26.24 - 1.0.4
|
||||
- Added free version of plugin with Posts List and Image+ as free blocks!
|
||||
- Updates to be WordPress.org repository compliant
|
||||
- Fixed Posts List thumbnail showing by default
|
||||
|
||||
→ 01.18.24 - 1.0.3
|
||||
- Fixed Single Post+ button hiding not working.
|
||||
|
||||
→ 01.18.24 - 1.0.2
|
||||
- Fixed naming of a couple of blocks.
|
||||
|
||||
→ 01.17.24 - 1.0.1
|
||||
- Removed "row gap" option from Single Post+ (not needed).
|
||||
- Changed how custom field tags are used and updated instructions.
|
||||
|
||||
→ 01.16.24 - 1.0.0
|
||||
- Initial soft release.
|
||||
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
|
After Width: | Height: | Size: 5.2 KiB |
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
|
|
@ -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
|
After Width: | Height: | Size: 6.7 KiB |
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
|
|
@ -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
|
After Width: | Height: | Size: 6.1 KiB |
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
|
|
@ -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
|
After Width: | Height: | Size: 5.5 KiB |
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
|
|
@ -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
|
After Width: | Height: | Size: 6.7 KiB |
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
|
|
@ -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
|
After Width: | Height: | Size: 4.1 KiB |
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() ?>
|
||||
39
css/mbtnp-blocks-copy-paste-block.css
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* Copy/Paste styles */
|
||||
.tnpc-row-mbtnp-copy,
|
||||
.tnpc-row-mbtnp-paste {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
top: 0px;
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
color: rgba(102,102,102,1);
|
||||
transition: all 0.2s;
|
||||
opacity: 0;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background-color: #e0e0e0;
|
||||
cursor: pointer;
|
||||
color: rgba(0, 0, 0, 1);
|
||||
|
||||
img {
|
||||
transform: scale(0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tnpc-row-mbtnp-copy {
|
||||
right: 120px;
|
||||
}
|
||||
|
||||
.tnpc-row-mbtnp-paste {
|
||||
right: 90px;
|
||||
}
|
||||
|
||||
.tnpc-row:hover .tnpc-row-mbtnp-copy,
|
||||
.tnpc-row:hover .tnpc-row-mbtnp-paste {
|
||||
opacity: 1;
|
||||
}
|
||||
BIN
images/icon-copy.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
images/icon-paste.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
images/placeholder-image.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
77
inc/menus.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// add menu subpage
|
||||
add_action('admin_menu', 'mbtnp_add_admin_menu');
|
||||
function mbtnp_add_admin_menu() {
|
||||
add_submenu_page(
|
||||
'options-general.php', // Parent menu slug
|
||||
'Advanced Composer Blocks', // Page title
|
||||
'Advanced Composer Blocks', // Menu title
|
||||
'manage_options', // Capability
|
||||
'advanced_composer_blocks', // Menu slug
|
||||
'mbtnp_settings_page' // Function that outputs the page
|
||||
);
|
||||
}
|
||||
|
||||
// add settings page
|
||||
function mbtnp_settings_page() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2>Advanced Composer Blocks Settings</h2>
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields('acb_settings_group');
|
||||
do_settings_sections('advanced_composer_blocks');
|
||||
submit_button();
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// register settings
|
||||
add_action('admin_init', 'mbtnp_register_settings');
|
||||
function mbtnp_register_settings() {
|
||||
register_setting(
|
||||
'acb_settings_group', // Option group
|
||||
'acb_settings' // Option name
|
||||
);
|
||||
}
|
||||
|
||||
// add settings section
|
||||
add_action('admin_init', 'mbtnp_settings_init');
|
||||
|
||||
function mbtnp_settings_init() {
|
||||
add_settings_section(
|
||||
'acb_settings_section', // Section ID
|
||||
'Settings', // Title
|
||||
'mbtnp_settings_section_cb', // Callback
|
||||
'advanced_composer_blocks' // Page
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'acb_disable_live_preview', // Field ID
|
||||
'Disable Live Preview Button', // Title
|
||||
'mbtnp_disable_live_preview_cb', // Callback
|
||||
'advanced_composer_blocks', // Page
|
||||
'acb_settings_section' // Section
|
||||
);
|
||||
}
|
||||
|
||||
function mbtnp_settings_section_cb() {
|
||||
echo '<p>Customize the behavior of Advanced Composer Blocks.</p>';
|
||||
}
|
||||
|
||||
function mbtnp_disable_live_preview_cb() {
|
||||
$options = get_option('acb_settings');
|
||||
?>
|
||||
<input type="checkbox" name="acb_settings[acb_disable_live_preview]" value="1" <?php echo ( !empty($options['acb_disable_live_preview']) ) ? 'checked' : ''; ?>/>
|
||||
<?php
|
||||
}
|
||||
171
js/mbtnp-blocks-copy-paste-block.js
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
jQuery(function ($) {
|
||||
|
||||
let copyPasteHTML = '<div class="tnpc-row-mbtnp-copy" title="Copy block"><img src="/wp-content/plugins/mbtnp-blocks/images/icon-copy.png" width="32"></div><div class="tnpc-row-mbtnp-paste" title="Paste block"><img src="/wp-content/plugins/mbtnp-blocks/images/icon-paste.png" width="32"></div>';
|
||||
|
||||
function showToast(message, type = 'info') {
|
||||
let backgroundColor = '#000'; // Default color for 'info'
|
||||
if (type === 'success') {
|
||||
backgroundColor = '#234567'; // MBTNP blue for success
|
||||
} else if (type === 'error') {
|
||||
backgroundColor = '#dc3545'; // Red for error
|
||||
}
|
||||
|
||||
Toastify({
|
||||
text: message,
|
||||
backgroundColor: backgroundColor,
|
||||
duration: 3000,
|
||||
gravity: 'top', // 'top' or 'bottom'
|
||||
position: 'center', // 'left', 'center' or 'right'
|
||||
}).showToast();
|
||||
}
|
||||
|
||||
function addCopyPasteButtons() {
|
||||
// add new copy/paste buttons
|
||||
$('.tnpc-row .tnpc-row-clone').each(function () {
|
||||
console.log($(this).parents('table').find('.tnpc-row-mbtnp-copy').length);
|
||||
if ($(this).parents('table').find('.tnpc-row-mbtnp-copy').length < 1) {
|
||||
$(this).after(copyPasteHTML);
|
||||
}
|
||||
});
|
||||
// remove any instances not in a table element
|
||||
$('.tnpc-row-mbtnp-copy.ui-sortable-handle, .tnpc-row-mbtnp-paste.ui-sortable-handle').each(function () {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
|
||||
function initializeCopyPasteFunctionality() {
|
||||
$(document).delegate('.tnpc-row-mbtnp-copy', 'click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let row = $(this).closest('.tnpc-row');
|
||||
let new_row = row.clone();
|
||||
let row_operations = new_row.find('.tnpc-row-delete, .tnpc-row-edit-block, .tnpc-row-clone, .tnpc-row-mbtnp-copy, .tnpc-row-mbtnp-paste');
|
||||
|
||||
// remove row operations
|
||||
row_operations.remove();
|
||||
|
||||
// save row outer HTML to localStorage
|
||||
localStorage.setItem('mbtnp-row-ops-copy', row_operations[0].outerHTML);
|
||||
localStorage.setItem('mbtnp-row-copy', new_row[0].outerHTML);
|
||||
|
||||
showToast('Block copied!', 'success');
|
||||
});
|
||||
|
||||
$(document).delegate('.tnpc-row-mbtnp-paste', 'click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let row = $(this).closest('.tnpc-row');
|
||||
let row_copy = localStorage.getItem('mbtnp-row-copy');
|
||||
let row_ops = localStorage.getItem('mbtnp-row-ops-copy');
|
||||
|
||||
if (row_copy) {
|
||||
// Create a jQuery object from the copied HTML string
|
||||
let new_row = $(row_copy);
|
||||
|
||||
// Append the new row after the current row
|
||||
row.after(new_row);
|
||||
|
||||
// Add row operations inside the new row
|
||||
new_row.append(row_ops);
|
||||
|
||||
// Re-add delete, edit, and clone functionality
|
||||
new_row.add_delete();
|
||||
new_row.add_block_edit();
|
||||
new_row.add_block_clone();
|
||||
|
||||
// Add copy/paste buttons to new block
|
||||
new_row.find('.tnpc-row-clone').after(copyPasteHTML);
|
||||
|
||||
// Scroll to the new row within the tnpb-content div
|
||||
$('#tnpb-content').animate({
|
||||
scrollTop: new_row.offset().top - $('#tnpb-content').offset().top + $('#tnpb-content').scrollTop()
|
||||
}, 500);
|
||||
|
||||
showToast('Block pasted successfully!', 'success');
|
||||
} else {
|
||||
showToast('No copied block found. Please copy a block first.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function customInitBuilderArea() {
|
||||
init_builder_area(); // Call the original builder initialization
|
||||
addCopyPasteButtons(); // Add custom copy/paste buttons
|
||||
initializeCopyPasteFunctionality(); // Initialize copy/paste functionality
|
||||
|
||||
// Add copy/paste buttons to any new blocks inserted into the editor
|
||||
$(document).on('DOMNodeInserted', '.tnpc-row', function () {
|
||||
addCopyPasteButtons();
|
||||
});
|
||||
}
|
||||
|
||||
// Override the original start_composer function
|
||||
function customStartComposer() {
|
||||
customInitBuilderArea();
|
||||
|
||||
// The rest of the original start_composer code
|
||||
// Closes the block options layer (without saving)
|
||||
jQuery("#tnpc-block-options-cancel").click(function () {
|
||||
tnpc_hide_block_options();
|
||||
var _target = target;
|
||||
jQuery.post(ajaxurl, start_options, function (response) {
|
||||
_target.html(response);
|
||||
jQuery("#tnpc-block-options-form").html("");
|
||||
});
|
||||
});
|
||||
|
||||
// Fires the save event for block options
|
||||
jQuery("#tnpc-block-options-save").click(function (e) {
|
||||
e.preventDefault();
|
||||
var _target = target;
|
||||
|
||||
// fix for Codemirror
|
||||
if (typeof templateEditor !== 'undefined') {
|
||||
templateEditor.save();
|
||||
}
|
||||
|
||||
if (window.tinymce)
|
||||
window.tinymce.triggerSave();
|
||||
|
||||
var data = jQuery("#tnpc-block-options-form").serializeArray();
|
||||
tnpc_add_global_options(data);
|
||||
tnpc_hide_block_options();
|
||||
|
||||
jQuery.post(ajaxurl, data, function (response) {
|
||||
_target.html(response);
|
||||
jQuery("#tnpc-block-options-form").html("");
|
||||
});
|
||||
});
|
||||
|
||||
jQuery('#tnpc-block-options-form').change(function (event) {
|
||||
var data = jQuery("#tnpc-block-options-form").serializeArray();
|
||||
var _container = tnp_container;
|
||||
var _target = target;
|
||||
tnpc_add_global_options(data);
|
||||
|
||||
jQuery.post(ajaxurl, data, function (response) {
|
||||
_target.html(response);
|
||||
if (event.target.dataset.afterRendering === 'reload') {
|
||||
_container.find(".tnpc-row-edit-block").click();
|
||||
}
|
||||
}).fail(function () {
|
||||
showToast("Block rendering failed", 'error');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Assign the new start_composer function to be called
|
||||
window.start_composer = customStartComposer;
|
||||
|
||||
// Call the new start_composer function on document ready
|
||||
$(document).ready(function () {
|
||||
start_composer();
|
||||
});
|
||||
|
||||
|
||||
// when hovering over tnpc-button[value="Save"], remove copy/paste buttons
|
||||
$(document).on('mouseenter', '.tnpc-button', function () {
|
||||
$('.tnpc-row-mbtnp-copy, .tnpc-row-mbtnp-paste').remove();
|
||||
});
|
||||
|
||||
});
|
||||
26
js/mbtnp-blocks-live-preview.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
jQuery(function ($) {
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Extract the ID from the URL
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var id = urlParams.get('id');
|
||||
|
||||
// Only proceed if the ID is present
|
||||
if (id) {
|
||||
// Get the root domain
|
||||
var domain = window.location.protocol + '//' + window.location.hostname;
|
||||
|
||||
// Create the new button
|
||||
var livePreviewButton = $('<a/>', {
|
||||
class: 'button-primary',
|
||||
href: domain + '/?na=view&id=' + id,
|
||||
target: '_blank',
|
||||
html: '<i class="fas fa-eye"></i>'
|
||||
});
|
||||
|
||||
// Append the button to the menu
|
||||
$('.tnpb-actions').append(livePreviewButton);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
});
|
||||
150
mbtnp-blocks.php
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin Name: Advanced Composer Blocks for Newsletter
|
||||
* Plugin URI: https://mburnette.com/advanced-composer-blocks/
|
||||
* Description: A set of enhanced composer blocks and additional settings to extend The Newsletter Plugin
|
||||
* Version: 2.0.0
|
||||
* Requires Plugins: newsletter
|
||||
* Author: Marcus Burnette
|
||||
* Author URI: https://mburnette.com
|
||||
* Text Domain: advanced-composer-blocks-for-newsletter
|
||||
* License: GPLv2 or later
|
||||
*
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// enqueue styles
|
||||
function mbtnp_enqueue_styles() {
|
||||
wp_enqueue_style( 'mbtnp-styles', plugin_dir_url( __FILE__ ) . 'styles.css' );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'mbtnp_enqueue_styles' );
|
||||
|
||||
|
||||
// include menu.php from inc folder
|
||||
require_once plugin_dir_path( __FILE__ ) . 'inc/menus.php';
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- DEFINE PLUGIN FOLDER ------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
define( 'MBTNP_PLUGIN_URL', plugins_url('', __FILE__) );
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- SETTINGS ACTION LINK ------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'mbtnp_add_action_links' );
|
||||
function mbtnp_add_action_links ( $actions ) {
|
||||
$mylinks = array(
|
||||
'<a href="' . admin_url( 'options-general.php?page=advanced_composer_blocks' ) . '">Settings</a>',
|
||||
);
|
||||
$actions = array_merge( $actions, $mylinks );
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- REGISTER NEW BLOCKS -------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
function mbtnp_newsletter_register_blocks() {
|
||||
|
||||
$mbtnp_blocks = [
|
||||
"mbtnp-image",
|
||||
"mbtnp-posts-list",
|
||||
"mbtnp-text",
|
||||
"mbtnp-cover",
|
||||
"mbtnp-cta",
|
||||
"mbtnp-single-post"
|
||||
];
|
||||
|
||||
$dir = __DIR__;
|
||||
|
||||
foreach($mbtnp_blocks as $block){
|
||||
|
||||
if ( file_exists( $dir . '/blocks/' . $block ) ) {
|
||||
TNP_Composer::register_block( $dir . '/blocks/' . $block );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'newsletter_register_blocks', 'mbtnp_newsletter_register_blocks' );
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- ADD LIVE PREVIEW BUTTON TO COMPOSER ---------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
function mbtnp_add_live_preview_button_in_admin() {
|
||||
// Get the current site's URL
|
||||
$site_url = get_site_url();
|
||||
$acb_settings = get_option('acb_settings');
|
||||
$acb_live_preview_disable = isset($acb_settings['acb_disable_live_preview']) ? $acb_settings['acb_disable_live_preview'] : false;
|
||||
|
||||
if ($acb_live_preview_disable) {
|
||||
return;
|
||||
}
|
||||
|
||||
// enqueue live preview script
|
||||
wp_enqueue_script( 'mbtnp-blocks-live-preview', plugin_dir_url( __FILE__ ) . 'js/mbtnp-blocks-live-preview.js', array('jquery'), '', true );
|
||||
}
|
||||
add_action('admin_footer', 'mbtnp_add_live_preview_button_in_admin');
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- ADD COPY/PASTE BUTTONS TO COMPOSER BLOCKS ---------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
function mbtnp_add_blocks_copy_paste() {
|
||||
|
||||
// enqueue live preview script and css
|
||||
wp_enqueue_script( 'mbtnp-blocks-copy-paste', plugin_dir_url( __FILE__ ) . 'js/mbtnp-blocks-copy-paste-block.js', array('jquery'), '', true );
|
||||
wp_enqueue_style( 'mbtnp-blocks-copy-paste', plugin_dir_url( __FILE__ ) . 'css/mbtnp-blocks-copy-paste-block.css' );
|
||||
}
|
||||
add_action('admin_footer', 'mbtnp_add_blocks_copy_paste');
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- GET SHORTENED EXCERPT ------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
function mbtnp_get_the_excerpt( $post_id, $count ) {
|
||||
$excerpt = get_the_content( '', '', $post_id );
|
||||
$excerpt = wp_strip_all_tags( $excerpt );
|
||||
if( strlen($excerpt) > $count ){
|
||||
$excerpt = trim(substr($excerpt, 0, $count));
|
||||
$excerpt .= '...';
|
||||
}
|
||||
return $excerpt;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ----- REPLACE CUSTOM TAGS (helper) ----------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
function mbtnp_replace_tags( $content, $post_id = null ){
|
||||
|
||||
if( empty($post_id) ){
|
||||
return $content;
|
||||
}
|
||||
|
||||
$post = get_post($post_id);
|
||||
|
||||
// replace {field_XYZ} with value from XYZ custom field
|
||||
$content = preg_replace_callback(
|
||||
'/\{field_([^}]+)\}/',
|
||||
function ($matches) use ($post) {
|
||||
return get_post_meta($post->ID, $matches[1], true);
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
// replace {title} with post title
|
||||
$content = preg_replace_callback(
|
||||
'/\{title\}/',
|
||||
function ($matches) use ($post) {
|
||||
return get_the_title($post->ID);
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
28
styles.css
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
.tnpb-actions {
|
||||
text-align: center !important;
|
||||
padding: 0.5rem 1rem !important;
|
||||
}
|
||||
|
||||
.tnpc-row-edit-block:hover img {
|
||||
transform: scale(0.8);
|
||||
}
|
||||
|
||||
.tnpc-row-clone:hover img {
|
||||
transform: scale(0.8);
|
||||
}
|
||||
|
||||
.tnpc-row-delete:hover img {
|
||||
filter: brightness(100);
|
||||
transform: scale(0.8);
|
||||
}
|
||||
|
||||
/* ----- Custom styles ----- */
|
||||
.mbtnp-section-title {
|
||||
clear: both;
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 500 !important;
|
||||
padding-top: 17px;
|
||||
padding-bottom: 5px;
|
||||
color: #666 !important;
|
||||
}
|
||||