Skip to content

Instantly share code, notes, and snippets.

@mdjwel
Last active October 26, 2019 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdjwel/0d7d3908857cdb6cfa5b95c3d93eb591 to your computer and use it in GitHub Desktop.
Save mdjwel/0d7d3908857cdb6cfa5b95c3d93eb591 to your computer and use it in GitHub Desktop.
Elementor widget development snippets
<?php
/// -------------------- Buttons ----------------------------
$this->start_controls_section(
'buttons_sec',
[
'label' => __( 'Buttons', 'saasland-core' ),
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'btn_title', [
'label' => __( 'Button Title', 'saasland-core' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => 'Get Started'
]
);
$repeater->add_control(
'btn_url', [
'label' => __( 'Button URL', 'saasland-core' ),
'type' => Controls_Manager::URL,
'default' => [
'url' => '#'
]
]
);
$repeater->start_controls_tabs(
'style_tabs'
);
/// Normal Button Style
$repeater->start_controls_tab(
'style_normal_btn',
[
'label' => __( 'Normal', 'plugin-name' ),
]
);
$repeater->add_control(
'font_color', [
'label' => __( 'Font Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}' => 'color: {{VALUE}}',
)
]
);
$repeater->add_control(
'bg_color', [
'label' => __( 'Background Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}' => 'background-color: {{VALUE}}; border-color: {{VALUE}}',
)
]
);
$repeater->add_control(
'border_color', [
'label' => __( 'Border Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}' => 'border-color: {{VALUE}}',
)
]
);
$repeater->end_controls_tab();
/// ----------------------------- Hover Button Style
$repeater->start_controls_tab(
'style_hover_btn',
[
'label' => __( 'Hover', 'plugin-name' ),
]
);
$repeater->add_control(
'hover_font_color', [
'label' => __( 'Font Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}:hover' => 'color: {{VALUE}}',
)
]
);
$repeater->add_control(
'hover_bg_color', [
'label' => __( 'Background Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}:hover' => 'background: {{VALUE}}',
)
]
);
$repeater->add_control(
'hover_border_color', [
'label' => __( 'Border Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} {{CURRENT_ITEM}}:hover' => 'border-color: {{VALUE}}',
)
]
);
$repeater->end_controls_tab();
$this->add_control(
'buttons', [
'label' => __( 'Create buttons', 'saasland-core' ),
'type' => Controls_Manager::REPEATER,
'title_field' => '{{{ btn_title }}}',
'fields' => $repeater->get_controls(),
]
);
$this->end_controls_section(); // End Buttons
$i = 0;
foreach ($settings['buttons'] as $button) {
++$i;
$strip_class = ($i % 2 == 1) ? 'download-button' : 'hire-button';
echo "<li>
<a href='{$button['btn_url']['url']}' class='$strip_class hire-btn elementor-repeater-item-{$button['_id']}'>
{$button['btn_title']}
</a>
</li>";
}
<?php
// Gradient Color
$this->add_control(
'bg_color', [
'label' => __( 'Background Color', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
]
);
$this->add_control(
'bg_color2', [
'label' => __( 'Background Color 02', 'saasland-core' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .feedback_area_two' => 'background-image: -webkit-linear-gradient(30deg, {{bg_color.VALUE}} 0%, {{VALUE}} 100%);',
],
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment