get_theme();
if ( $theme ) {
return [$theme, 'ctc-el-code-snippet'];
}
return ['ctc-el-code-snippet'];
}
/**
* Get style dependencies
*/
public function get_style_depends() {
$theme = $this->get_theme();
if ( $theme ) {
return [$theme, 'ctc-blocks-core'];
}
return ['ctc-blocks-core'];
}
/**
* Get name
*/
public function get_name() {
return 'ctc_code_snippet';
}
/**
* Get title
*/
public function get_title() {
return esc_html__( 'Code Snippet', 'copy-the-code' );
}
/**
* Get icon
*/
public function get_icon() {
return 'eicon-code-bold';
}
/**
* Get categories
*/
public function get_categories() {
return ['copy-the-code'];
}
/**
* Get keywords
*/
public function get_keywords() {
return Helpers::get_keywords( [
'code',
'snippet',
'copy code',
'copy snippet',
'copy code snippet'
] );
}
/**
* Render
*/
public function render() {
$code_snippet = $this->get_settings_for_display( 'code_snippet' );
$language = $this->get_settings_for_display( 'language' );
$file_name = $this->get_settings_for_display( 'file_name' );
$theme = $this->get_theme();
$languages = $this->get_languages();
$language = ( isset( $languages[$language] ) ? $languages[$language] : $language );
?>
esc_html__( 'Markup', 'copy-the-code' ),
'html' => esc_html__( 'HTML', 'copy-the-code' ),
'css' => esc_html__( 'CSS', 'copy-the-code' ),
'javascript' => esc_html__( 'JavaScript', 'copy-the-code' ),
'php' => esc_html__( 'PHP', 'copy-the-code' ),
'python' => esc_html__( 'Python', 'copy-the-code' ),
'ruby' => esc_html__( 'Ruby', 'copy-the-code' ),
'sass' => esc_html__( 'Sass', 'copy-the-code' ),
'scss' => esc_html__( 'SCSS', 'copy-the-code' ),
'sql' => esc_html__( 'SQL', 'copy-the-code' ),
'bash' => esc_html__( 'Bash', 'copy-the-code' ),
'c' => esc_html__( 'C', 'copy-the-code' ),
'cpp' => esc_html__( 'C++', 'copy-the-code' ),
'csharp' => esc_html__( 'C#', 'copy-the-code' ),
'go' => esc_html__( 'Go', 'copy-the-code' ),
'java' => esc_html__( 'Java', 'copy-the-code' ),
'kotlin' => esc_html__( 'Kotlin', 'copy-the-code' ),
'objectivec' => esc_html__( 'Objective-C', 'copy-the-code' ),
'swift' => esc_html__( 'Swift', 'copy-the-code' ),
'typescript' => esc_html__( 'TypeScript', 'copy-the-code' ),
'vbnet' => esc_html__( 'VB.Net', 'copy-the-code' ),
];
}
/**
* Register controls
*/
protected function _register_controls() {
/**
* Group: Code Section
*/
$this->start_controls_section( 'code_section', [
'label' => esc_html__( 'Code Snippet', 'copy-the-code' ),
] );
$this->add_control( 'file_name', [
'label' => esc_html__( 'File Name', 'copy-the-code' ),
'type' => Controls_Manager::TEXT,
'default' => 'index.js',
] );
$this->add_control( 'language', [
'label' => esc_html__( 'Language', 'copy-the-code' ),
'type' => Controls_Manager::SELECT,
'default' => 'javascript',
'options' => $this->get_languages(),
] );
$this->add_control( 'code_snippet', [
'label' => esc_html__( 'Code Snippet', 'copy-the-code' ),
'type' => Controls_Manager::TEXTAREA,
'default' => 'console.log("Hello World");',
'rows' => 10,
] );
$this->end_controls_section();
// Copy Button Section.
Helpers::register_copy_button_section( $this, [
'button_text' => esc_html__( 'Copy Code Snippet', 'copy-the-code' ),
] );
Helpers::register_pro_sections( $this, [
'Quote Box',
'Message Box',
'Quote',
'Author'
] );
Helpers::register_copy_button_style_section( $this );
}
}