| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/www/wp-content/plugins/eltd-core/shortcodes/process/ |
Upload File : |
<?php
namespace ElatedCore\CPT\Shortcodes\Process;
use ElatedCore\Lib;
class Process implements Lib\ShortcodeInterface {
private $base;
function __construct() {
$this->base = 'eltd_process';
add_action( 'vc_before_init', array( $this, 'vcMap' ) );
}
public function getBase() {
return $this->base;
}
public function vcMap() {
if ( function_exists( 'vc_map' ) ) {
vc_map(
array(
'name' => esc_html__( 'Elated Process', 'eltd-core' ),
'base' => $this->base,
'icon' => 'icon-wpb-process extended-custom-icon',
'category' => esc_html__( 'by ELATED', 'eltd-core' ),
'as_parent' => array( 'only' => 'eltd_process_item' ),
'content_element' => true,
'js_view' => 'VcColumnView',
'params' => array(
array(
'type' => 'textfield',
'param_name' => 'custom_class',
'heading' => esc_html__( 'Custom CSS Class', 'eltd-core' ),
'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'eltd-core' )
),
array(
'type' => 'dropdown',
'param_name' => 'number_of_columns',
'heading' => esc_html__( 'Number Of Columns', 'eltd-core' ),
'value' => array(
esc_html__( '2 Columns', 'eltd-core' ) => 'two',
esc_html__( '3 Columns', 'eltd-core' ) => 'three',
esc_html__( '4 Columns', 'eltd-core' ) => 'four'
),
'save_always' => true
),
array(
'type' => 'dropdown',
'param_name' => 'switch_to_one_column',
'heading' => esc_html__( 'Switch to One Column', 'eltd-core' ),
'value' => array(
esc_html__( 'Default None', 'eltd-core' ) => '',
esc_html__( 'Below 1280px', 'eltd-core' ) => '1280',
esc_html__( 'Below 1024px', 'eltd-core' ) => '1024',
esc_html__( 'Below 768px', 'eltd-core' ) => '768',
esc_html__( 'Below 680px', 'eltd-core' ) => '680',
esc_html__( 'Below 480px', 'eltd-core' ) => '480'
),
'description' => esc_html__( 'Choose on which stage item will be in one column', 'eltd-core' ),
'save_always' => true
)
)
)
);
}
}
public function render( $atts, $content = null ) {
$args = array(
'custom_class' => '',
'number_of_columns' => 'three',
'switch_to_one_column' => ''
);
$params = shortcode_atts( $args, $atts );
$params['holder_classes'] = $this->getHolderClasses( $params, $args );
$params['number_of_items'] = $this->getNumberOfItems( $params['number_of_columns'] );
$params['content'] = $content;
$html = eltd_core_get_shortcode_module_template_part( 'templates/process-template', 'process', '', $params );
return $html;
}
private function getHolderClasses( $params, $args ) {
$holderClasses = array();
$holderClasses[] = ! empty( $params['custom_class'] ) ? esc_attr( $params['custom_class'] ) : '';
$holderClasses[] = ! empty( $params['number_of_columns'] ) ? 'eltd-' . $params['number_of_columns'] . '-columns' : 'eltd-' . $args['number_of_columns'] . '-columns';
$holderClasses[] = ! empty( $params['switch_to_one_column'] ) ? 'eltd-responsive-' . $params['switch_to_one_column'] : '';
return implode( ' ', $holderClasses );
}
private function getNumberOfItems( $params ) {
$number = 3;
switch ($params) {
case 'two':
$number = 2;
break;
case 'three':
$number = 3;
break;
case 'four':
$number = 4;
break;
}
return $number;
}
}