-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
I'm sorry about title, I have no idea what is the best title for my question.
I'm trying to split the customizer option into seperated files, so I tried to added 'hook' in the middle of code, somethin like this
function standard_customizer_register() {
// Stores all the controls that will be added
$options = array();
// Stores all the sections to be added
$sections = array();
// Stores all the panels to be added
$panels = array();
// Adds the sections to the $options array
$options['sections'] = $sections;
// Hook to add the custom customizer.
do_action( 'standard_register_customizer', $options, $sections, $panels );
// Adds the sections to the $options array
$options['sections'] = $sections;
// Adds the panels to the $options array
$options['panels'] = $panels;
$customizer_library = Customizer_Library::Instance();
$customizer_library->add_options( $options );
}
add_action( 'init', 'standard_customizer_register' );
then I called the file and hook in to add the panels/sections.
$path = trailingslashit( get_template_directory() ) . 'admin/panels/';
require_once( $path . 'general.php' );
general.php
function standard_customizer_general_panel( $sections, $panels, $options) {
// Panel ID
$panel = 'panel';
$panels[] = array(
'id' => $panel,
'title' => __( 'General', 'Standard' ),
'priority' => 10
);
// Logo
$section = 'logo';
$sections[] = array(
'id' => $section,
'title' => __( 'Image Example', 'demo' ),
'priority' => '30',
'description' => __( 'Example section description.', 'demo' ),
'panel' => $panel
);
$options['logo'] = array(
'id' => 'logo',
'label' => __( 'Logo', 'demo' ),
'section' => $section,
'type' => 'image',
'default' => ''
);
}
add_action( 'standard_register_customizer', 'standard_customizer_general_panel', 10, 3 );
But it didn't worked. My question:
- Is it possible to split the options files?
- Am I missing something in the code?
Thank you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels