Skip to content

Commit 382a420

Browse files
committed
Cleaned up and documented customizer functionality
1 parent 398d85a commit 382a420

4 files changed

Lines changed: 99 additions & 68 deletions

File tree

customize/actions.php

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,62 @@
99
* @since 1.0.0
1010
*/
1111

12-
// Prevent direct access.
1312
defined( 'ABSPATH' ) || exit;
1413

14+
/**
15+
* Callback defined in includes/customize/styles.php
16+
*
17+
* @see carelib_customize_register_controls_styles
18+
*/
1519
add_action( 'customize_controls_enqueue_scripts', 'carelib_customize_register_controls_styles', 0 );
16-
add_action( 'init', 'carelib_customize_load_breadcrumb_settings', 0 );
20+
21+
/**
22+
* Callback defined in includes/customize/register.php
23+
*
24+
* @see carelib_customize_load_breadcrumb_settings
25+
*/
1726
add_action( 'customize_register', 'carelib_customize_load_classes', 0 );
27+
28+
/**
29+
* Callback defined in includes/customize/register.php
30+
*
31+
* @see carelib_customize_register_layouts
32+
*/
33+
add_action( 'customize_register', 'carelib_customize_register_layouts', 10 );
34+
35+
if ( carelib_breadcrumb_plugin_is_active() ) {
36+
/**
37+
* Callback defined in includes/customize/register.php
38+
*
39+
* @see carelib_register_breadcrumb_settings
40+
*/
41+
add_action( 'customize_register', 'carelib_register_breadcrumb_settings', 15 );
42+
}
43+
44+
/**
45+
* Callback defined in includes/customize/scripts.php
46+
*
47+
* @see carelib_customize_register_controls_scripts
48+
*/
1849
add_action( 'customize_controls_enqueue_scripts', 'carelib_customize_register_controls_scripts', 0 );
19-
add_action( 'customize_preview_init', 'carelib_customize_register_preview_scripts', 0 );
20-
add_action( 'customize_preview_init', 'carelib_customize_enqueue_preview_scripts', 10 );
21-
add_action( 'customize_controls_enqueue_scripts', 'carelib_customize_register_controls_styles', 0 );
2250

23-
add_action( 'customize_register', 'carelib_customize_register_layouts' );
51+
/**
52+
* Callback defined in includes/customize/scripts.php
53+
*
54+
* @see carelib_customize_register_preview_scripts
55+
*/
56+
add_action( 'customize_preview_init', 'carelib_customize_register_preview_scripts', 0 );
57+
58+
/**
59+
* Callback defined in includes/customize/scripts.php
60+
*
61+
* @see carelib_customize_enqueue_preview_scripts
62+
*/
63+
add_action( 'customize_preview_init', 'carelib_customize_enqueue_preview_scripts', 10 );
64+
65+
/**
66+
* Callback defined in includes/customize/styles.php
67+
*
68+
* @see carelib_customize_register_controls_styles
69+
*/
70+
add_action( 'customize_controls_enqueue_scripts', 'carelib_customize_register_controls_styles', 0 );

customize/register-breadcrumbs.php

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,48 @@ function carelib_customize_register_layouts( $wp_customize ) {
6666
)
6767
);
6868
}
69+
70+
/**
71+
* Register our customizer breadcrumb options for the parent class to load.
72+
*
73+
* @since 1.0.0
74+
* @access public
75+
* @param object $wp_customize The WordPress customizer API object.
76+
* @return void
77+
*/
78+
function carelib_register_breadcrumb_settings( $wp_customize ) {
79+
$section = "{$GLOBALS['carelib_prefix']}_breadcrumbs";
80+
81+
$wp_customize->add_section(
82+
$section,
83+
array(
84+
'title' => __( 'Breadcrumbs', 'carelib' ),
85+
'description' => __( 'Choose where you would like breadcrumbs to display.', 'carelib' ),
86+
'priority' => 110,
87+
'capability' => 'edit_theme_options',
88+
)
89+
);
90+
91+
$priority = 10;
92+
93+
foreach ( carelib_get_breadcrumb_options() as $breadcrumb => $setting ) {
94+
95+
$wp_customize->add_setting(
96+
$breadcrumb,
97+
array(
98+
'default' => $setting['default'],
99+
'sanitize_callback' => 'absint',
100+
)
101+
);
102+
103+
$wp_customize->add_control(
104+
$breadcrumb,
105+
array(
106+
'label' => $setting['label'],
107+
'section' => $section,
108+
'type' => 'checkbox',
109+
'priority' => $priority++,
110+
)
111+
);
112+
}
113+
}

includes/init.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
if ( is_customize_preview() ) {
6666
require_once CARELIB_DIR . 'customize/control-radio-image.php';
6767
require_once CARELIB_DIR . 'customize/control-layout.php';
68-
require_once CARELIB_DIR . 'customize/register-breadcrumbs.php';
69-
require_once CARELIB_DIR . 'customize/register-layouts.php';
68+
require_once CARELIB_DIR . 'customize/register.php';
7069
require_once CARELIB_DIR . 'customize/scripts.php';
7170
require_once CARELIB_DIR . 'customize/styles.php';
7271
require_once CARELIB_DIR . 'customize/actions.php';

0 commit comments

Comments
 (0)