File: /home/agritoday/www/wp-content/plugins/td-cloud-library/shortcodes/author/tdb_author_name.php
<?php
/**
* Class tdb_author_name
*/
class tdb_author_name extends td_block {
public function get_custom_css() {
// $unique_block_class - the unique class that is on the block. use this to target the specific instance via css
$in_composer = td_util::tdc_is_live_editor_iframe() || td_util::tdc_is_live_editor_ajax();
$in_element = td_global::get_in_element();
$unique_block_class_prefix = '';
if( $in_element || $in_composer ) {
$unique_block_class_prefix = 'tdc-row .';
if( $in_element && $in_composer ) {
$unique_block_class_prefix = 'tdc-row-composer .';
}
}
$unique_block_class = $unique_block_class_prefix . $this->block_uid;
$compiled_css = '';
$raw_css =
"<style>
/* @style_general_author_name */
.tdb-title-line {
display: none;
position: relative;
}
.tdb-title-line:after {
content: '';
width: 100%;
position: absolute;
background-color: #4db2ec;
top: 0;
left: 0;
margin: auto;
}
/* @title_color_solid */
.$unique_block_class .tdb-single-auth-text {
color: @title_color_solid;
}
/* @title_color_gradient */
.$unique_block_class .tdb-single-auth-text {
@title_color_gradient
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
html[class*='ie'] .$unique_block_class .tdb-single-auth-text {
background: none;
color: @title_color_gradient_1;
}
/* @style_bg */
.$unique_block_class .tdb-single-auth-text {
-webkit-text-fill-color: initial;
background: @style_bg;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
padding: 5px 16px;
display: inline;
}
/* @style_bg_gradient */
.$unique_block_class .tdb-single-auth-text {
-webkit-text-fill-color: initial;
background: @style_bg_gradient;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
padding: 5px 16px;
display: inline;
}
/* @style_bg_space */
.$unique_block_class .tdb-single-auth-text {
padding: @style_bg_space;
}
/* @line_width */
.$unique_block_class .tdb-title-line {
display: table;
width: @line_width;
}
/* @line_height */
.$unique_block_class .tdb-title-line:after {
height: @line_height;
}
/* @line_space */
.$unique_block_class .tdb-title-line {
height: @line_space;
}
/* @line_alignment */
.$unique_block_class .tdb-title-line:after {
bottom: @line_alignment;
}
/* @line_color */
.$unique_block_class .tdb-title-line:after {
background: @line_color;
}
/* @line_color_gradient */
.$unique_block_class .tdb-title-line:after {
@line_color_gradient
}
/* @align_center */
.td-theme-wrap .$unique_block_class {
text-align: center;
}
.$unique_block_class .tdb-title-line {
margin-left: auto;
margin-right: auto;
}
/* @align_right */
.td-theme-wrap .$unique_block_class {
text-align: right;
}
.$unique_block_class .tdb-title-line {
margin-left: auto;
}
/* @align_left */
.td-theme-wrap .$unique_block_class {
text-align: left;
}
/* @f_title */
.$unique_block_class .tdb-single-auth-text {
@f_title
}
</style>";
$td_css_res_compiler = new td_css_res_compiler( $raw_css );
$td_css_res_compiler->load_settings( __CLASS__ . '::cssMedia', $this->get_all_atts() );
$compiled_css .= $td_css_res_compiler->compile_css();
return $compiled_css;
}
static function cssMedia( $res_ctx ) {
$res_ctx->load_settings_raw( 'style_general_author_name', 1 );
// title color
$res_ctx->load_color_settings( 'title_color', 'title_color_solid', 'title_color_gradient', 'title_color_gradient_1', '' );
// content align
$content_align = $res_ctx->get_shortcode_att('content_align_horizontal');
if ( $content_align == 'content-horiz-center' ) {
$res_ctx->load_settings_raw( 'align_center', 1 );
} else if ( $content_align == 'content-horiz-right' ) {
$res_ctx->load_settings_raw( 'align_right', 1 );
} else if ( $content_align == 'content-horiz-left' ) {
$res_ctx->load_settings_raw( 'align_left', 1 );
}
/*-- LINE -- */
// line width
$line_width = $res_ctx->get_shortcode_att('line_width');
$res_ctx->load_settings_raw( 'line_width', $line_width );
if( $line_width != '' && is_numeric( $line_width ) ) {
$res_ctx->load_settings_raw( 'line_width', $line_width . 'px' );
}
// line height
$line_height = $res_ctx->get_shortcode_att('line_height');
$res_ctx->load_settings_raw( 'line_height', '2px' );
if( $line_height != '' ) {
if( is_numeric( $line_height ) ) {
$res_ctx->load_settings_raw( 'line_height', $line_height . 'px' );
}
}
// line space
$line_space = $res_ctx->get_shortcode_att('line_space');
$res_ctx->load_settings_raw( 'line_space', '50px' );
if( $line_space != '' ) {
if( is_numeric( $line_space ) ) {
$res_ctx->load_settings_raw( 'line_space', $line_space . 'px' );
}
}
// line alignment
$line_alignment = $res_ctx->get_shortcode_att( 'line_alignment' );
if( is_numeric( $line_alignment ) ) {
$res_ctx->load_settings_raw( 'line_alignment', $line_alignment . '%' );
}
// style_bg
$res_ctx->load_color_settings( 'style_bg', 'style_bg', 'style_bg_gradient', '', '' );
// style_bg_space
$style_bg_space = $res_ctx->get_shortcode_att( 'style_bg_space' );
$res_ctx->load_settings_raw( 'style_bg_space', $style_bg_space );
if( $style_bg_space != '' && is_numeric( $style_bg_space ) ) {
$res_ctx->load_settings_raw( 'style_bg_space', $style_bg_space . 'px' );
}
// line color
$res_ctx->load_color_settings( 'line_color', 'line_color', 'line_color_gradient', '', '' );
/*-- FONTS -- */
$res_ctx->load_font_settings( 'f_title' );
}
function __construct() {
parent::disable_loop_block_features();
}
function render( $atts, $content = null ) {
parent::render( $atts ); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
global $tdb_state_author;
$author_title_data = $tdb_state_author->title->__invoke( $atts );
// title line
$title_line_position = $this->get_att( 'line_position' );
$title_tag = $this->get_att( 'title_tag' );
$buffy = ''; //output buffer
$buffy .= '<div class="' . $this->get_block_classes() . '" ' . $this->get_block_html_atts() . '>';
//get the block css
$buffy .= $this->get_block_css();
//get the js for this block
$buffy .= $this->get_block_js();
$buffy .= '<div class="tdb-block-inner td-fix-index">';
if( $title_line_position == 'above' ) {
$buffy .= '<div class="tdb-title-line"></div>';
}
$buffy .= '<' . $title_tag . ' class="tdb-single-auth-text">' . $author_title_data['title'] . '</' . $title_tag . '>';
if( $title_line_position == '' ) {
$buffy .= '<div class="tdb-title-line"></div>';
}
$buffy .= '</div>';
$buffy .= '</div>';
return $buffy;
}
}