Skip to content

Instantly share code, notes, and snippets.

@fahidjavid
Last active February 26, 2024 19:29
Show Gist options
  • Save fahidjavid/0b2fc36dbd4e0ec96f98e80eba745008 to your computer and use it in GitHub Desktop.
Save fahidjavid/0b2fc36dbd4e0ec96f98e80eba745008 to your computer and use it in GitHub Desktop.
A custom customizer control that provide a nice separator between the customizer fields.
<?php
if ( ! class_exists( 'Prefix_Separator_Control' ) ) {
return null;
}
/**
* Class Prefix_Separator_Control
*
* Custom control to display separator
*/
class Prefix_Separator_Control extends WP_Customize_Control {
public function render_content() {
?>
<label> <br>
<hr>
<br> </label>
<?php
}
}
<?php
// separator
$wp_customize->add_setting( 'prefix_sample_separator', array(
'sanitize_callback' => 'themename_sanitize',
) );
$wp_customize->add_control(
new Prefix_Separator_Control(
$wp_customize,
'prefix_sample_separator',
array(
'section' => 'prefix_sample_section',
)
)
);
@yratof
Copy link

yratof commented Jan 17, 2018

If the class you're creating doesn't exist... return null?

@AmirHosseinKarimi
Copy link

@yratof yea, its wrong logic, Should not use ! in statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment