Skip to content

Instantly share code, notes, and snippets.

@iamcanadian1973
Created October 28, 2020 20:50
Show Gist options
  • Save iamcanadian1973/5b385e04cd397e64a331cf7de2372ebd to your computer and use it in GitHub Desktop.
Save iamcanadian1973/5b385e04cd397e64a331cf7de2372ebd to your computer and use it in GitHub Desktop.
<?php
/**
* Module - Get Started
*
* @since 1.0
*/
if ( fusion_is_element_enabled( 'icertis_get_started' ) ) {
if ( ! class_exists( 'Icertis_Get_Started' ) ) {
/**
* Shortcode class.
*
* @since 1.0
*/
class Icertis_Get_Started extends Fusion_Element {
/**
* Parent SC arguments.
*
* @access protected
* @since 1.0
* @var array
*/
protected $parent_args;
/**
* Child SC arguments.
*
* @access protected
* @since 1.0
* @var array
*/
protected $child_args;
/**
* Constructor.
*
* @access public
* @since 1.0
*/
public function __construct() {
parent::__construct();
// add_filter( 'fusion_attr_icertis_home_hero-main-wrapper', [ $this, 'attr' ] );
add_shortcode( 'icertis_get_started', [ $this, 'render_shortcode' ] );
add_shortcode( 'icertis_get_started_grid', [ $this, 'render_child' ] );
}
/**
* Gets the default values.
*
* @static
* @access public
* @since 2.0.0
* @return array
*/
public static function get_element_defaults() {
$fusion_settings = fusion_get_fusion_settings();
return [
'class' => '',
'id' => ''
];
}
/**
* Maps settings to param variables.
*
* @static
* @access public
* @param string $context Whether we want parent or child.
* @since 2.0.0
* @return array
*/
public static function settings_to_params( $context = '' ) {
return [];
}
/**
* Used to set any other variables for use on front-end editor template.
*
* @static
* @access public
* @since 2.0.0
* @return array
*/
public static function get_element_extras() {
return [];
}
/**
* Maps settings to extra variables.
*
* @static
* @access public
* @since 2.0.0
* @return array
*/
public static function settings_to_extras() {
return [];
}
/**
* Render the parent shortcode.
*
* @access public
* @since 1.0
* @param array $args Shortcode parameters.
* @param string $content Content between shortcode.
* @return string HTML output.
*/
public function render_shortcode( $args, $content = '' ) {
$title = $args['icertis_get_started_title'];
$text = $args['icertis_get_started_text'];
fusion_element_rendering_elements( true );
$html = $title;
fusion_element_rendering_elements( false );
return $html;
}
public function render_child( $args, $content = '' ) {
return 'test';
}
}
}
new Icertis_Get_Started();
}
/**
* Map shortcode to Fusion Builder.
*
* @since 1.0
*/
function fusion_element_icertis_get_started() {
$builder_status = function_exists( 'is_fusion_editor' ) && is_fusion_editor();
fusion_builder_map(
fusion_builder_frontend_data(
'Icertis_Get_Started',
[
'name' => esc_attr__( 'Icertis Get Started', 'fusion-builder' ),
'shortcode' => 'icertis_get_started',
'multi' => 'multi_element_parent',
'element_child' => 'icertis_get_started_grid',
'child_ui' => true,
'icon' => 'fusiona-bubbles',
'params' => [
[
'type' => 'textfield',
'heading' => esc_attr__( 'Title', 'fusion-builder' ),
'param_name' => 'icertis_get_started_title',
'value' => '',
'placeholder' => true,
],
[
'type' => 'textarea',
'heading' => esc_attr__( 'Text', 'fusion-builder' ),
'param_name' => 'icertis_get_started_text',
'value' => '',
'placeholder' => true,
],
[
'type' => 'upload',
'heading' => esc_attr__( 'Background Image', 'fusion-builder' ),
'description' => esc_attr__( 'Upload an image to display in background.', 'fusion-builder' ),
'param_name' => 'element_content',
'value' => '',
'dynamic_data' => true,
],
],
]
,
'parent'
)
);
}
add_action( 'fusion_builder_before_init', 'fusion_element_icertis_get_started' );
function fusion_element_icertis_get_started_grid() {
fusion_builder_map(
fusion_builder_frontend_data(
'Icertis_Get_Started',
[
'name' => esc_attr__( 'Grid', 'fusion-builder' ),
'description' => esc_attr__( 'Slider', 'fusion-builder' ),
'shortcode' => 'icertis_get_started_grid',
'hide_from_builder' => true,
'allow_generator' => true,
'params' => [
[
'type' => 'upload',
'heading' => esc_attr__( 'Icon', 'fusion-builder' ),
'description' => esc_attr__( 'Upload an icon to display.', 'fusion-builder' ),
'param_name' => 'icertis_get_started_grid_image',
'value' => '',
'dynamic_data' => true,
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'Title', 'fusion-builder' ),
'param_name' => 'icertis_get_started_grid_title',
'value' => '',
'placeholder' => true,
],
[
'type' => 'textarea',
'heading' => esc_attr__( 'Text', 'fusion-builder' ),
'param_name' => 'icertis_get_started_grid_text',
'value' => '',
'placeholder' => true,
],
[
'type' => 'link_selector',
'heading' => esc_attr__( 'Link', 'fusion-builder' ),
'description' => esc_attr__( 'Link to page', 'fusion-builder' ),
'param_name' => 'icertis_get_started_grid_url',
'value' => '',
]
],
'child'
]
)
);
}
add_action( 'fusion_builder_before_init', 'fusion_element_icertis_get_started_grid' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment