Created
December 28, 2015 20:44
-
-
Save shazdeh/0f2a9fa23eb6beb89cc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** | |
* Module Name: Plain Text | |
* Description: Display plain text | |
*/ | |
class TB_Plain_Text_Module extends Themify_Builder_Module { | |
function __construct() { | |
parent::__construct(array( | |
'name' => __('Plain Text', 'themify'), | |
'slug' => 'plain-text' | |
)); | |
} | |
public function get_title( $module ) { | |
$text = isset( $module['mod_settings']['content_text'] ) ? $module['mod_settings']['content_text'] : ''; | |
$return = wp_trim_words( $text, 100 ); | |
return $return; | |
} | |
public function get_options() { | |
$options = array( | |
array( | |
'id' => 'content_text', | |
'type' => 'textarea', | |
'class' => 'fullwidth', | |
'label' => ' ', | |
'rows' => 25 | |
) | |
); | |
return $options; | |
} | |
public function get_animation() { | |
$animation = array( | |
array( | |
'id' => 'multi_Animation Effect', | |
'type' => 'multi', | |
'label' => __('Effect', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'animation_effect', | |
'type' => 'animation_select', | |
'label' => __( 'Effect', 'themify' ) | |
), | |
array( | |
'id' => 'animation_effect_delay', | |
'type' => 'text', | |
'label' => __( 'Delay', 'themify' ), | |
'class' => 'xsmall', | |
'description' => __( 'Seconds', 'themify' ), | |
), | |
array( | |
'id' => 'animation_effect_repeat', | |
'type' => 'text', | |
'label' => __( 'Repeat', 'themify' ), | |
'class' => 'xsmall', | |
'description' => __( 'Times', 'themify' ), | |
), | |
) | |
) | |
); | |
return $animation; | |
} | |
public function get_styling() { | |
$styling = array( | |
array( | |
'id' => 'separator_image_background', | |
'title' => '', | |
'description' => '', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Background', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'background_image', | |
'type' => 'image', | |
'label' => __('Background Image', 'themify'), | |
'class' => 'xlarge', | |
'prop' => 'background-image', | |
'selector' => '.module-plain-text' | |
), | |
array( | |
'id' => 'background_color', | |
'type' => 'color', | |
'label' => __('Background Color', 'themify'), | |
'class' => 'small', | |
'prop' => 'background-color', | |
'selector' => '.module-plain-text', | |
), | |
// Background repeat | |
array( | |
'id' => 'background_repeat', | |
'label' => __('Background Repeat', 'themify'), | |
'type' => 'select', | |
'default' => '', | |
'meta' => array( | |
array('value' => 'repeat', 'name' => __('Repeat All', 'themify')), | |
array('value' => 'repeat-x', 'name' => __('Repeat Horizontally', 'themify')), | |
array('value' => 'repeat-y', 'name' => __('Repeat Vertically', 'themify')), | |
array('value' => 'repeat-none', 'name' => __('Do not repeat', 'themify')), | |
array('value' => 'fullcover', 'name' => __('Fullcover', 'themify')) | |
), | |
'prop' => 'background-repeat', | |
'selector' => '.module-plain-text' | |
), | |
// Font | |
array( | |
'type' => 'separator', | |
'meta' => array('html'=>'<hr />') | |
), | |
array( | |
'id' => 'separator_font', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Font', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'font_family', | |
'type' => 'font_select', | |
'label' => __('Font Family', 'themify'), | |
'class' => 'font-family-select', | |
'prop' => 'font-family', | |
'selector' => array( '.module-plain-text', '.module-plain-text h1', '.module-plain-text h2', '.module-plain-text h3:not(.module-title)', '.module-plain-text h4', '.module-plain-text h5', '.module-plain-text h6' ) | |
), | |
array( | |
'id' => 'font_color', | |
'type' => 'color', | |
'label' => __('Font Color', 'themify'), | |
'class' => 'small', | |
'prop' => 'color', | |
'selector' => array( '.module-plain-text', '.module-plain-text h1', '.module-plain-text h2', '.module-plain-text h3:not(.module-title)', '.module-plain-text h4', '.module-plain-text h5', '.module-plain-text h6' ), | |
), | |
array( | |
'id' => 'multi_font_size', | |
'type' => 'multi', | |
'label' => __('Font Size', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'font_size', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'font-size', | |
'selector' => '.module-plain-text' | |
), | |
array( | |
'id' => 'font_size_unit', | |
'type' => 'select', | |
'meta' => array( | |
array('value' => '', 'name' => ''), | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => 'em', 'name' => __('em', 'themify')) | |
) | |
) | |
) | |
), | |
array( | |
'id' => 'multi_line_height', | |
'type' => 'multi', | |
'label' => __('Line Height', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'line_height', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'line-height', | |
'selector' => '.module-plain-text' | |
), | |
array( | |
'id' => 'line_height_unit', | |
'type' => 'select', | |
'meta' => array( | |
array('value' => '', 'name' => ''), | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => 'em', 'name' => __('em', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
) | |
) | |
), | |
array( | |
'id' => 'text_align', | |
'label' => __( 'Text Align', 'themify' ), | |
'type' => 'radio', | |
'meta' => array( | |
array( 'value' => '', 'name' => __( 'Default', 'themify' ), 'selected' => true ), | |
array( 'value' => 'left', 'name' => __( 'Left', 'themify' ) ), | |
array( 'value' => 'center', 'name' => __( 'Center', 'themify' ) ), | |
array( 'value' => 'right', 'name' => __( 'Right', 'themify' ) ), | |
array( 'value' => 'justify', 'name' => __( 'Justify', 'themify' ) ) | |
), | |
'prop' => 'text-align', | |
'selector' => '.module-plain-text' | |
), | |
// Link | |
array( | |
'type' => 'separator', | |
'meta' => array('html'=>'<hr />') | |
), | |
array( | |
'id' => 'separator_link', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Link', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'link_color', | |
'type' => 'color', | |
'label' => __('Color', 'themify'), | |
'class' => 'small', | |
'prop' => 'color', | |
'selector' => '.module-plain-text a' | |
), | |
array( | |
'id' => 'text_decoration', | |
'type' => 'select', | |
'label' => __( 'Text Decoration', 'themify' ), | |
'meta' => array( | |
array('value' => '', 'name' => '', 'selected' => true), | |
array('value' => 'underline', 'name' => __('Underline', 'themify')), | |
array('value' => 'overline', 'name' => __('Overline', 'themify')), | |
array('value' => 'line-through', 'name' => __('Line through', 'themify')), | |
array('value' => 'none', 'name' => __('None', 'themify')) | |
), | |
'prop' => 'text-decoration', | |
'selector' => '.module-plain-text a' | |
), | |
// Padding | |
array( | |
'type' => 'separator', | |
'meta' => array('html'=>'<hr />') | |
), | |
array( | |
'id' => 'separator_padding', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Padding', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'multi_padding_top', | |
'type' => 'multi', | |
'label' => __('Padding', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'padding_top', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'padding-top', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'padding_top_unit', | |
'type' => 'select', | |
'description' => __('top', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_padding_right', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'padding_right', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'padding-right', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'padding_right_unit', | |
'type' => 'select', | |
'description' => __('right', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_padding_bottom', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'padding_bottom', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'padding-bottom', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'padding_bottom_unit', | |
'type' => 'select', | |
'description' => __('bottom', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_padding_left', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'padding_left', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'padding-left', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'padding_left_unit', | |
'type' => 'select', | |
'description' => __('left', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
// Margin | |
array( | |
'type' => 'separator', | |
'meta' => array('html'=>'<hr />') | |
), | |
array( | |
'id' => 'separator_margin', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Margin', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'multi_margin_top', | |
'type' => 'multi', | |
'label' => __('Margin', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'margin_top', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'margin-top', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'margin_top_unit', | |
'type' => 'select', | |
'description' => __('top', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_margin_right', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'margin_right', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'margin-right', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'margin_right_unit', | |
'type' => 'select', | |
'description' => __('right', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_margin_bottom', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'margin_bottom', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'margin-bottom', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'margin_bottom_unit', | |
'type' => 'select', | |
'description' => __('bottom', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
array( | |
'id' => 'multi_margin_left', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'margin_left', | |
'type' => 'text', | |
'class' => 'xsmall', | |
'prop' => 'margin-left', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'margin_left_unit', | |
'type' => 'select', | |
'description' => __('left', 'themify'), | |
'meta' => array( | |
array('value' => 'px', 'name' => __('px', 'themify')), | |
array('value' => '%', 'name' => __('%', 'themify')) | |
) | |
), | |
) | |
), | |
// Border | |
array( | |
'type' => 'separator', | |
'meta' => array('html'=>'<hr />') | |
), | |
array( | |
'id' => 'separator_border', | |
'type' => 'separator', | |
'meta' => array('html'=>'<h4>'.__('Border', 'themify').'</h4>'), | |
), | |
array( | |
'id' => 'multi_border_top', | |
'type' => 'multi', | |
'label' => __('Border', 'themify'), | |
'fields' => array( | |
array( | |
'id' => 'border_top_color', | |
'type' => 'color', | |
'class' => 'small', | |
'prop' => 'border-top-color', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_top_width', | |
'type' => 'text', | |
'description' => 'px', | |
'class' => 'xsmall', | |
'prop' => 'border-top-width', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_top_style', | |
'type' => 'select', | |
'description' => __('top', 'themify'), | |
'meta' => Themify_Builder_model::get_border_styles(), | |
'prop' => 'border-top-style', | |
'selector' => '.module-plain-text', | |
), | |
) | |
), | |
array( | |
'id' => 'multi_border_right', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'border_right_color', | |
'type' => 'color', | |
'class' => 'small', | |
'prop' => 'border-right-color', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_right_width', | |
'type' => 'text', | |
'description' => 'px', | |
'class' => 'xsmall', | |
'prop' => 'border-right-width', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_right_style', | |
'type' => 'select', | |
'description' => __('right', 'themify'), | |
'meta' => Themify_Builder_model::get_border_styles(), | |
'prop' => 'border-right-style', | |
'selector' => '.module-plain-text', | |
) | |
) | |
), | |
array( | |
'id' => 'multi_border_bottom', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'border_bottom_color', | |
'type' => 'color', | |
'class' => 'small', | |
'prop' => 'border-bottom-color', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_bottom_width', | |
'type' => 'text', | |
'description' => 'px', | |
'class' => 'xsmall', | |
'prop' => 'border-bottom-width', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_bottom_style', | |
'type' => 'select', | |
'description' => __('bottom', 'themify'), | |
'meta' => Themify_Builder_model::get_border_styles(), | |
'prop' => 'border-bottom-style', | |
'selector' => '.module-plain-text', | |
) | |
) | |
), | |
array( | |
'id' => 'multi_border_left', | |
'type' => 'multi', | |
'label' => '', | |
'fields' => array( | |
array( | |
'id' => 'border_left_color', | |
'type' => 'color', | |
'class' => 'small', | |
'prop' => 'border-left-color', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_left_width', | |
'type' => 'text', | |
'description' => 'px', | |
'class' => 'xsmall', | |
'prop' => 'border-left-width', | |
'selector' => '.module-plain-text', | |
), | |
array( | |
'id' => 'border_left_style', | |
'type' => 'select', | |
'description' => __('left', 'themify'), | |
'meta' => Themify_Builder_model::get_border_styles(), | |
'prop' => 'border-left-style', | |
'selector' => '.module-plain-text', | |
) | |
) | |
), | |
// Additional CSS | |
array( | |
'type' => 'separator', | |
'meta' => array( 'html' => '<hr/>') | |
), | |
array( | |
'id' => 'add_css_text', | |
'type' => 'text', | |
'label' => __('Additional CSS Class', 'themify'), | |
'class' => 'large exclude-from-reset-field', | |
'description' => sprintf( '<br/><small>%s</small>', __( 'Add additional CSS class(es) for custom styling', 'themify' ) ) | |
) | |
); | |
return $styling; | |
} | |
} | |
/////////////////////////////////////// | |
// Module Options | |
/////////////////////////////////////// | |
Themify_Builder_Model::register_module( 'TB_Plain_Text_Module' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('ABSPATH')) | |
exit; // Exit if accessed directly | |
/** | |
* Template Plain Text | |
* | |
* Access original fields: $mod_settings | |
* @author Themify | |
*/ | |
$fields_default = array( | |
'content_text' => '', | |
'add_css_text' => '', | |
'background_repeat' => '', | |
'animation_effect' => '' | |
); | |
$fields_args = wp_parse_args($mod_settings, $fields_default); | |
extract($fields_args, EXTR_SKIP); | |
$animation_effect = $this->parse_animation_effect($animation_effect, $fields_args); | |
$container_class = implode( ' ', apply_filters('themify_builder_module_classes', array( | |
'module', 'module-' . $mod_name, $module_ID, $add_css_text, $background_repeat, $animation_effect | |
), $mod_name, $module_ID, $fields_args) | |
); | |
?> | |
<!-- module text --> | |
<div id="<?php echo esc_attr( $module_ID ); ?>" class="<?php echo esc_attr($container_class); ?>"> | |
<?php do_action( 'themify_builder_before_template_content_render' ); ?> | |
<?php echo do_shortcode( $content_text ); ?> | |
<?php do_action( 'themify_builder_after_template_content_render' ); ?> | |
</div> | |
<!-- /module text --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment