';
}
public static function get_svg_checked_icon() {
return '';
}
public static function get_copy_button( $args = [] ) {
$show_icon = isset( $args['show_icon'] ) ? $args['show_icon'] : 'yes';
$with_icon = 'yes' === $show_icon ? 'with-icon' : 'without-icon';
$as_raw = isset( $args['as_raw'] ) ? 'yes' : '';
$button_text = isset( $args['button_text'] ) ? $args['button_text'] : esc_html__( 'Copy', 'copy-the-code' );
$button_class = isset( $args['button_class'] ) ? $args['button_class'] : '';
$button_text_copied = isset( $args['button_text_copied'] ) ? $args['button_text_copied'] : esc_html__( 'Copied!', 'copy-the-code' );
$icon_direction = isset( $args['icon_direction'] ) ? $args['icon_direction'] : 'before';
ob_start();
?>
post_content, $shortcode ) ) {
$found = true;
}
return $found;
}
/**
* Get categories
*
* @since 3.2.0
*/
public static function get_categories() {
return [ 'copy-the-code', 'basic' ];
}
/**
* Get common keywords
*
* @param array $keywords New keywords.
* @since 3.2.0
*/
public static function get_keywords( $keywords = [] ) {
$default = [ 'copy', 'paste', 'clipboard', 'copy clipboard', 'copy to clipboard', 'copy anything to clipboard' ];
return array_merge( $default, $keywords );
}
/**
* Register "Copy Content" Section
*
* @param object $self
*/
public static function register_copy_content_section( $self, $args = [] ) {
$self->start_controls_section(
'copy_content_section',
[
'label' => esc_html__( 'Copy Content', 'copy-the-code' ),
]
);
$self->add_control(
'copy_content',
[
'label' => esc_html__( 'Enter Text that Copy to Clipboard', 'copy-the-code' ),
'type' => Controls_Manager::TEXTAREA,
'default' => isset( $args[ 'default' ] ) ? $args[ 'default' ] : '',
'rows' => 10,
]
);
$self->end_controls_section();
}
/**
* Register "Copy Button" Section
*
* @param array $args
* @param object $self
*/
public static function register_copy_button_section( $self, $args = [] ) {
$default = [
'button_text' => isset( $args[ 'button_text' ] ) ? $args[ 'button_text' ] : esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
'button_text_copied' => isset( $args[ 'button_text_copied' ] ) ? $args[ 'button_text_copied' ] : esc_html__( 'Copied!', 'copy-the-code' ),
'show_icon' => 'yes',
'icon_direction' => 'before',
];
$self->start_controls_section(
'copy_button_section',
[
'label' => esc_html__( 'Copy Button', 'copy-the-code' ),
]
);
$self->add_control(
'copy_button_text',
[
'label' => esc_html__( 'Button Text', 'copy-the-code' ),
'type' => Controls_Manager::TEXT,
'default' => $default[ 'button_text' ],
]
);
$self->add_control(
'copy_button_text_copied',
[
'label' => esc_html__( 'After Copy Text', 'copy-the-code' ),
'type' => Controls_Manager::TEXT,
'default' => $default[ 'button_text_copied' ],
]
);
// Show Icon.
$self->add_control(
'copy_show_icon',
[
'label' => esc_html__( 'Show Icon', 'copy-the-code' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'copy-the-code' ),
'label_off' => esc_html__( 'Hide', 'copy-the-code' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$self->add_control(
'copy_icon_direction',
[
'label' => esc_html__( 'Icon Direction', 'copy-the-code' ),
'type' => Controls_Manager::SELECT,
'default' => 'before',
'options' => [
'before' => esc_html__( 'Before', 'copy-the-code' ),
'after' => esc_html__( 'After', 'copy-the-code' ),
],
'condition' => [
'copy_show_icon' => 'yes',
],
]
);
$self->add_responsive_control(
'copy_icon_text_gap',
[
'label' => esc_html__( 'Icon and Text Gap', 'copy-the-code' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
'em' => [
'min' => 0,
'max' => 10,
],
],
'selectors' => [
'{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};',
],
'condition' => [
'copy_show_icon' => 'yes',
],
]
);
$self->end_controls_section();
}
/**
* Register "Copy Button Style" Section
*
* @param object $self
*/
public static function register_copy_button_style_section( $self ) {
$self->start_controls_section(
'copy_button_style_section',
[
'label' => esc_html__( 'Copy Button', 'copy-the-code' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$self->add_control(
'copy_button_align',
[
'label' => esc_html__( 'Alignment', 'copy-the-code' ),
'type' => Controls_Manager::SELECT,
'default' => 'left',
'options' => [
'' => esc_html__( 'Default', 'copy-the-code' ),
'left' => esc_html__( 'Left', 'copy-the-code' ),
'center' => esc_html__( 'Center', 'copy-the-code' ),
'right' => esc_html__( 'Right', 'copy-the-code' ),
],
'selectors' => [
'{{WRAPPER}} .ctc-block-actions' => 'text-align: {{VALUE}};',
],
]
);
// Tabs.
$self->start_controls_tabs(
'copy_button_style_tabs'
);
// button Style Normal.
$self->start_controls_tab(
'copy_button_style_normal_tab',
[
'label' => esc_html__( 'Normal', 'copy-the-code' ),
]
);
$self->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'copy_button_normal_background',
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .ctc-block-copy',
'exclude' => [ 'image' ],
]
);
$self->add_control(
'copy_button_normal_text_color',
[
'label' => esc_html__( 'Text Color', 'copy-the-code' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ctc-block-copy' => 'color: {{VALUE}};',
'{{WRAPPER}} .ctc-block-copy svg' => 'fill: {{VALUE}};',
],
]
);
$self->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'copy_button_normal_typography',
'selector' => '{{WRAPPER}} .ctc-block-copy',
]
);
$self->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'copy_button_normal_border',
'selector' => '{{WRAPPER}} .ctc-block-copy',
]
);
$self->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'copy_button_normal_box_shadow',
'selector' => '{{WRAPPER}} .ctc-block-copy',
]
);
$self->end_controls_tab();
// button Style Normal End.
// button Style Hover.
$self->start_controls_tab(
'copy_button_style_hover_tab',
[
'label' => esc_html__( 'Hover', 'copy-the-code' ),
]
);
$self->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'copy_button_hover_background',
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
'exclude' => [ 'image' ],
]
);
$self->add_control(
'copy_button_hover_text_color',
[
'label' => esc_html__( 'Text Color', 'copy-the-code' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ctc-block-copy:hover' => 'color: {{VALUE}};',
'{{WRAPPER}} .ctc-block-copy:hover svg' => 'fill: {{VALUE}};',
],
]
);
$self->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'copy_button_hover_border',
'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
]
);
$self->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'copy_button_hover_box_shadow',
'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
]
);
$self->end_controls_tab();
// button Style Hover End.
$self->end_controls_tabs();
// button Tabs.
$self->add_responsive_control(
'copy_button_border_radius',
[
'label' => esc_html__( 'Border Radius', 'copy-the-code' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .ctc-block-copy' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$self->add_responsive_control(
'copy_button_padding',
[
'label' => esc_html__( 'Padding', 'copy-the-code' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .ctc-block-copy' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$self->add_responsive_control(
'copy_button_margin',
[
'label' => esc_html__( 'Margin', 'copy-the-code' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .ctc-block-copy' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$self->end_controls_section();
// button Style Section End.
}
/**
* Render "Copy Button"
*
* @param object $self
*/
public static function render_copy_button( $self ) {
$button_text = $self->get_settings_for_display( 'copy_button_text' );
$button_text_copied = $self->get_settings_for_display( 'copy_button_text_copied' );
$show_icon = $self->get_settings_for_display( 'copy_show_icon' );
$icon_direction = $self->get_settings_for_display( 'copy_icon_direction' );
echo Helpers::get_copy_button( [
'as_raw' => 'yes',
'button_text' => $button_text,
'button_text_copied' => $button_text_copied,
'icon_direction' => $icon_direction,
'show_icon' => $show_icon,
] );
}
/**
* Render "Copy Content"
*
* @param object $self
*/
public static function render_copy_content( $self ) {
$copy_content = $self->get_settings_for_display( 'copy_content' );
?>