הוספת תפריטים להתאמה אישית
הצגת קונטרולר חדש בתבנית, תחת עיצוב –> התאמה אישית, בפאנל האדמין משרתת 2 מטרות,
לאפשר למשתמש יותר אפשרויות.
ומאפשר לתת הגדרות מיוחדות לתבנית הספציפית.
$wp_customize->add_control($id, $args);
- $id
- מזהה ייחודי של הקונטרולר
- $args
- ארגומנטים להגדרת הקונטרולר
אלה הארגומנטים שאפשר להוסיף:
Arguments
- label
- Optional. Displayed label. Example:
'label' => __( 'Base Color Scheme', 'twentyfifteen' ), - description
- Optional. Example:
'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ), - section
- Any readily available or user defined section. Some available sections:
themes,title_tagline,colors,header_image(only when enabled),background_image(only when enabled),static_front_page. Example:'section' => 'colors', - priority
- Optional. themes (0), title_tagline (20), colors (40), header_image (60), background_image (80), static_front_page (120).
- type
- Example:
'type' => 'select', - settings
- Optional. If in https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting you specified "theme_mod" type then you should add here ID of the database setting which you want to modify, e.g. "header_color" (which is your arbitrary name specific to your theme only). It will be stored as a serialized value obtainable with https://codex.wordpress.org/Function_Reference/get_theme_mod like
get_theme_mod('header_color');. If you selected "option" type in https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting then you can add here a plain word like "theme_name_header_color" which will be obtainable withget_option('theme_name_header_color');. Serialized values like "my_namespace[header_color]" are allowed in both cases, however you probably don't need to serialize it when using "theme_mod" as it's already stored in the database as a serialized entry. If not defined, then the $id as the setting ID is used. - choices, height, width etc.
- Optional. It's possible to pass custom parameters for specific control types. These are available only for some control types. Example for "select" and "radio" controls:
'choices'=> twentyfifteen_get_color_scheme_choices(),
https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control