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
234
blocks/mbtnp-single-post/block.php
Normal file
234
blocks/mbtnp-single-post/block.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Single Post
|
||||
* Section: content
|
||||
* Description: Extended text block
|
||||
*
|
||||
*/
|
||||
|
||||
// Don't access this file directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* @var $options array */
|
||||
|
||||
$default_options = array(
|
||||
'wrap_padding_left' => 10,
|
||||
'wrap_padding_right' => 10,
|
||||
'wrap_padding_top' => 10,
|
||||
'wrap_padding_bottom' => 10,
|
||||
'wrap_border_width' => 0,
|
||||
'wrap_border_color' => '#000000',
|
||||
'wrap_border_radius' => 0,
|
||||
'image_align' => 'center',
|
||||
'image_size' => 'medium',
|
||||
'link_image' => '',
|
||||
'border_radius' => 0,
|
||||
'hide_title' => '',
|
||||
'link_title' => '',
|
||||
'title_font_size' => '24',
|
||||
'title_font_align' => 'left',
|
||||
'post_date_font_size' => '16',
|
||||
'post_date_font_align' => 'left',
|
||||
'post_content_font_size' => '16',
|
||||
'post_content_font_align' => 'left',
|
||||
'post_custom_html_font_size' => '16',
|
||||
'post_custom_html_font_align' => 'left',
|
||||
'post_custom_html_font_color' => '#000000',
|
||||
'show_content' => 'excerpt',
|
||||
'hide_button' => '',
|
||||
'button_text' => 'Read more',
|
||||
'button_text_font_size' => '16',
|
||||
'button_color' => '#000000',
|
||||
'button_text_color' => '#ffffff',
|
||||
'button_border_radius' => '3',
|
||||
'button_align' => 'left',
|
||||
'block_padding_left'=>15,
|
||||
'block_padding_right'=>15,
|
||||
'block_padding_top' => 20,
|
||||
'block_padding_bottom' => 20,
|
||||
'block_background'=>'#eeeeee'
|
||||
);
|
||||
|
||||
$options = array_merge($default_options, $options);
|
||||
|
||||
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
||||
$post_date_style = TNP_Composer::get_title_style($options, 'post_date', $composer);
|
||||
$post_content_style = TNP_Composer::get_title_style($options, 'post_content', $composer);
|
||||
$button_text_style = TNP_Composer::get_title_style($options, 'button_text', $composer);
|
||||
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
||||
$post_custom_html_style = TNP_Composer::get_style($options, 'post_custom_html', $composer);
|
||||
|
||||
?>
|
||||
<style>
|
||||
.block-wrap {
|
||||
padding: 10px;
|
||||
padding-top: <?php echo esc_attr( $options['wrap_padding_top'] ); ?>px;
|
||||
padding-bottom: <?php echo esc_attr( $options['wrap_padding_bottom'] ); ?>px;
|
||||
padding-left: <?php echo esc_attr( $options['wrap_padding_left'] ); ?>px;
|
||||
padding-right: <?php echo esc_attr( $options['wrap_padding_right'] ); ?>px;
|
||||
background-color: <?php echo esc_attr( $options['wrap_background_color'] ); ?>;
|
||||
border: <?php echo esc_attr( $options['wrap_border_width'] ) ?>px solid <?php echo esc_attr( $options['wrap_border_color'] ); ?>;
|
||||
border-radius: <?php echo esc_attr( $options['wrap_border_radius'] ); ?>px;
|
||||
}
|
||||
.post-row {
|
||||
padding-bottom: <?php echo esc_attr( $options['post_list_row_gap'] ); ?>px;
|
||||
}
|
||||
.featured-image-wrap {
|
||||
text-align: <?php echo esc_attr( $options['image_align'] ); ?>;
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.featured-image {
|
||||
border-radius: <?php echo esc_attr( $options['border_radius'] ); ?>px;
|
||||
}
|
||||
.title {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.title-link {
|
||||
<?php esc_html( $title_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
<?php if( $options['title_font_color'] ){ ?>
|
||||
color: <?php echo esc_attr( $options['title_font_color'] ); ?>;
|
||||
<?php } ?>
|
||||
}
|
||||
.post-date {
|
||||
<?php esc_html( $post_date_style->echo_css() ) ?>
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-excerpt {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: 1.4em;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-full {
|
||||
<?php esc_html( $post_content_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-custom-html {
|
||||
mso-line-height-rule: exactly;
|
||||
<?php echo esc_html( $post_custom_html_style->echo_css() ) ?>
|
||||
line-height: normal;
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.post-button-wrap {
|
||||
margin: 0 !important;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
text-align: <?php echo esc_attr( $options['button_align'] ); ?>;
|
||||
}
|
||||
.post-button {
|
||||
<?php echo esc_html( $text_style->echo_css() ) ?>
|
||||
<?php echo esc_html( $button_text_style->echo_css() ) ?>
|
||||
background: <?php echo esc_attr( $options['button_color'] ); ?>;
|
||||
color: <?php echo esc_attr( $options['button_text_color'] ); ?>;
|
||||
display: inline-block;
|
||||
<?php if( $options['button_width'] == 'full_width' ){ ?>
|
||||
display: block;
|
||||
<?php } ?>
|
||||
padding: 12px 24px;
|
||||
<?php if( $options['button_text_font_size'] ){ ?>
|
||||
padding: <?php echo esc_attr( $options['button_text_font_size'] ) * 0.5; ?>px <?php echo esc_attr( $options['button_text_font_size'] ) * 1; ?>px;
|
||||
<?php } ?>
|
||||
text-decoration: none;
|
||||
<?php if( $options['button_border_radius'] ){ ?>
|
||||
border-radius: <?php echo esc_attr( $options['button_border_radius'] ); ?>px;
|
||||
<?php } ?>
|
||||
}
|
||||
</style>
|
||||
|
||||
<div inline-class="block-wrap">
|
||||
<table width="100%" style="width: 100% !important;" border="0" cellpadding="0" cellspacing="0">
|
||||
<?php if( $options['post_id'] ){ ?>
|
||||
<?php if( get_post($options['post_id']) ){ ?>
|
||||
<?php
|
||||
$post_id = (int)$options['post_id'];
|
||||
$post_arr[] = $post_id;
|
||||
$post_type = get_post_type( $post_id );
|
||||
$post_list_args = array(
|
||||
'post__in' => $post_arr,
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => $post_type
|
||||
);
|
||||
$posts_list = get_posts($post_list_args); ?>
|
||||
<?php foreach($posts_list as $post){
|
||||
$post_custom_html = $options['post_custom_html']; ?>
|
||||
<tr>
|
||||
<td width="100%" valign="top" align="left" class="post-row" inline-class="post-row">
|
||||
<?php if($options['image_size'] != 'none'){ ?>
|
||||
<div inline-class="featured-image-wrap">
|
||||
<?php if( $options['link_image'] == 1 ){ echo '<a href="' . esc_url( get_the_permalink($post->ID) ) . '" inline-class="featured-image-link">'; } ?>
|
||||
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $post->ID, $options['image_size'] ) ); ?>" inline-class="featured-image" />
|
||||
<?php if($options['link_image'] == 1){ echo '</a>'; } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['hide_title'] != 1){ ?>
|
||||
<p inline-class="title">
|
||||
<?php if($options['link_title'] == 1){ echo '<a href="' . esc_url( get_the_permalink($post->ID) ) . '" inline-class="title-link">'; } ?>
|
||||
<?php echo esc_html( $post->post_title ); ?>
|
||||
<?php if( $options['link_title'] == 1 ){ echo '</a>'; } ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_post_date'] == 1){ ?>
|
||||
<p inline-class="post-date">
|
||||
<?php echo esc_html( gmdate("F j, Y", strtotime($post->post_date) ) ); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'excerpt'){ ?>
|
||||
<div inline-class="post-excerpt">
|
||||
<?php if( $options['excerpt_length'] ){
|
||||
echo wp_kses_post( mbtnp_get_the_excerpt( $post->ID, $options['excerpt_length'] ) );
|
||||
} else {
|
||||
echo wp_kses_post( get_the_excerpt( $post->ID ) );
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if($options['show_content'] == 'full'){ ?>
|
||||
<div inline-class="post-full">
|
||||
<?php echo wp_kses_post( get_the_content('','',$post->ID) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( !empty( trim($post_custom_html) ) ){ ?>
|
||||
<div inline-class="post-custom-html">
|
||||
<?php echo wp_kses_post( mbtnp_replace_tags( $post_custom_html, $post->ID ) ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if( $options['hide_button'] != 1 ){ ?>
|
||||
<div inline-class="post-button-wrap">
|
||||
<a href="<?php echo esc_url( get_the_permalink($post->ID) ); ?>" inline-class="post-button"><?php echo esc_html( mbtnp_replace_tags( $options['button_text'], $post->ID ) ); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><p>That post ID is not valid. <a href="https://mburnette.com/find-postid/" target="_blank">How to find your post ID.</a></p></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><p>Please enter a post ID. <a href="https://mburnette.com/find-postid/" target="_blank">How to find your post ID.</a></p></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue