File: //proc/self/cwd/wp-content/plugins/extensive-vc-addon/shortcodes/process/process-item.php
<?php
namespace ExtensiveVC\Shortcodes\EVCProcess;
use ExtensiveVC\Shortcodes;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'EVCProcessItem' ) ) {
class EVCProcessItem extends Shortcodes\EVCShortcode {
/**
* Singleton variables
*/
private static $instance;
/**
* Constructor
*/
function __construct() {
$this->setBase( 'evc_process_item' );
$this->setParentBase( 'evc_process' );
$this->setShortcodeName( esc_html__( 'Process Item', 'extensive-vc' ) );
$this->setShortcodeParameters( $this->shortcodeParameters() );
// Parent constructor need to be loaded after setter's method initialization
parent::__construct( array( 'hasParent' => true ) );
}
/**
* Get the instance of ExtensiveVCFramework
*
* @return self
*/
public static function getInstance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Set shortcode parameters for WPBakery Page Builder shortcodes options panel
*/
function shortcodeParameters() {
$params = array(
array(
'type' => 'textfield',
'param_name' => 'custom_class',
'heading' => esc_html__( 'Custom CSS Class', 'extensive-vc' ),
'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'extensive-vc' )
),
array(
'type' => 'textfield',
'param_name' => 'title',
'heading' => esc_html__( 'Title', 'extensive-vc' )
),
array(
'type' => 'dropdown',
'param_name' => 'title_tag',
'heading' => esc_html__( 'Title Tag', 'extensive-vc' ),
'value' => array_flip( extensive_vc_get_title_tag_array( true, array( 'p' => 'p' ) ) ),
'dependency' => array( 'element' => 'title', 'not_empty' => true ),
'group' => esc_html__( 'Design Options', 'extensive-vc' )
),
array(
'type' => 'colorpicker',
'param_name' => 'title_color',
'heading' => esc_html__( 'Title Color', 'extensive-vc' ),
'dependency' => array( 'element' => 'title', 'not_empty' => true ),
'group' => esc_html__( 'Design Options', 'extensive-vc' )
),
array(
'type' => 'textarea',
'param_name' => 'text',
'heading' => esc_html__( 'Text', 'extensive-vc' )
),
array(
'type' => 'colorpicker',
'param_name' => 'text_color',
'heading' => esc_html__( 'Text Color', 'extensive-vc' ),
'dependency' => array( 'element' => 'text', 'not_empty' => true ),
'group' => esc_html__( 'Design Options', 'extensive-vc' )
),
array(
'type' => 'textfield',
'param_name' => 'text_top_margin',
'heading' => esc_html__( 'Text Top Margin (px)', 'extensive-vc' ),
'dependency' => array( 'element' => 'text', 'not_empty' => true ),
'group' => esc_html__( 'Design Options', 'extensive-vc' )
)
);
return $params;
}
/**
* Renders shortcodes HTML
*
* @param $atts array - shortcode params
* @param $content string - shortcode content
*
* @return html
*/
function render( $atts, $content = null ) {
$args = array(
'custom_class' => '',
'title' => '',
'title_tag' => 'h4',
'title_color' => '',
'text' => '',
'text_color' => '',
'text_top_margin' => ''
);
$params = shortcode_atts( $args, $atts, $this->getBase() );
$params['holder_classes'] = $this->getHolderClasses( $params );
$params['title_tag'] = ! empty( $params['title_tag'] ) ? $params['title_tag'] : $args['title_tag'];
$params['title_styles'] = $this->getTitleStyles( $params );
$params['text_styles'] = $this->getTextStyles( $params );
$html = extensive_vc_get_module_template_part( 'shortcodes', 'process', 'templates/process-item', '', $params );
return $html;
}
/**
* Get shortcode holder classes
*
* @param $params array - shortcode parameters value
*
* @return string
*/
private function getHolderClasses( $params ) {
$holderClasses = array();
$holderClasses[] = ! empty( $params['custom_class'] ) ? esc_attr( $params['custom_class'] ) : '';
return implode( ' ', $holderClasses );
}
/**
* Get title styles
*
* @param $params array - shortcode parameters value
*
* @return string
*/
private function getTitleStyles( $params ) {
$styles = array();
if ( ! empty( $params['title_color'] ) ) {
$styles[] = 'color: ' . $params['title_color'];
}
return implode( ';', $styles );
}
/**
* Get text styles
*
* @param $params array - shortcode parameters value
*
* @return string
*/
private function getTextStyles( $params ) {
$styles = array();
if ( ! empty( $params['text_color'] ) ) {
$styles[] = 'color: ' . $params['text_color'];
}
if ( $params['text_top_margin'] !== '' ) {
$styles[] = 'margin-top: ' . intval( $params['text_top_margin'] ) . 'px';
}
return implode( ';', $styles );
}
}
}
EVCProcessItem::getInstance();