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
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() ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue