Skip to content

@AyoThemes /text-block.php secret
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
/**
* This file control custom text block class
*
* @package AyoShop
* @author AyoThemes
* @license GPL-2.0+
* @link http://ayothemes.com/go/ayoshop
*/
/** Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) exit;
if( ! class_exists( 'Ayo_Text_Block' ) ) :
class Ayo_Text_Block extends AQ_Block {
function __construct() {
$block_options = array(
'name' => __( 'Text', 'ayoshop' ),
'size' => 'span4',
);
parent::__construct( 'Ayo_Text_Block', $block_options );
}
function form( $instance ) {
$defaults = array(
'title' => '',
'icon' => '',
'content' => '',
'ptag' => false
);
$instance = wp_parse_args( $instance, $defaults );
extract( $instance );
?>
<div class="description half">
<label for="<?php echo $this->get_field_id('title') ?>"><?php _e( 'Title', 'ayoshop' );?></label>
<?php echo aq_field_input('title', $block_id, $title) ?>
</div>
<div class="description half last is-fontawesome">
<label for="<?php echo $this->get_field_id( 'icon' ) ?>"><?php _e( 'Icon', 'ayoshop' );?> *<?php _e( 'Optional', 'ayoshop' );?></label>
<?php echo aq_field_select( 'icon', $block_id, ayo_get_fontawesome(), $icon ) ?>
</div>
<div class="description">
<label for="<?php echo $this->get_field_id( 'content' ) ?>"><?php _e( 'Content', 'ayoshop' );?></label>
<?php echo aq_field_textarea( 'content', $block_id, $content ) ?>
</div>
<div class="description">
<?php echo aq_field_checkbox( 'ptag', $block_id, $ptag ) ?>&nbsp;&nbsp;
<label for="<?php echo $this->get_field_id( 'ptag' ) ?>"><?php _e( 'Automatically add paragraphs.', 'ayoshop' );?></label>
</div>
<?php
}
function block( $instance ) {
extract( $instance );
$icon = ( ! empty( $icon ) ) ? '<i class="icon-'. $icon .'"></i>' : '';
$output = ( ! empty( $title ) ) ? '<h4 class="widget-title"><span>'. $icon . strip_tags( $title ) .'</span></h4>' : '';
$text = apply_filters( 'ayoshop_text_block', htmlspecialchars_decode( $content ) );
if ( ! empty( $content ) ) {
$output .= '<div class="entry-content">';
$output .= ( $ptag == true ) ? wpautop( $text ) : $text ;
$output .= '</div>';
}
echo $output;
}
/* block header */
function before_block($instance) {
extract($instance);
$column_class = $first ? 'aq-first' : '';
echo '<section id="aq-block-'.$template_id.'-'.$number.'" class="aq-block aq-block-'.$id_base.' aq_'.$size.' '.$column_class.' cf">';
}
/* block footer */
function after_block($instance) {
extract($instance);
echo '</section>';
}
}
aq_register_block( 'Ayo_Text_Block' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.