secret
Last active

  • Download Gist
text-block.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
<?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;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.