Wp Theme CustomizerCustomizer Wp Topic
I will show you in this article how the customizer can be used in topics to better usability and to add the new grandeur of WordPress 4. Customizer was first used in WordPress 3. 3 and allows you to see changes you make to your design in the thumbnail.
Our development team has full control over key features such as page titles and headers, and we can use the Theme Customizations API as well to customize our own control for anything we want. These are three areas that are of interest when encoding for the customizer. You need to design the customizer control elements, the control elements for customizing the design, the control elements for customizing the design, the control elements for implementing the design and/or the control elements, and - optional - the control elements for the design's ability to provide better usability.
Let us build an enviroment in which we can work before we start.
By visiting the Customizer in the WordPress Administrator, you can already manage the page header, page descriptions and extra style sheet (the last one is a new 4.7 feature) of your website. The reason for this is that the customizer shows changes by updating the entire page by default. However, the customizer does not update the entire page. Let us begin by creating the foundations for our adaptation effort.
I' m creating a customizer. customize it. make sure it is needed in the customizer features. include ('customizer. php'); The customizer starts with a hook operation that contains all our section, setting and control. add_action('customize_register','cd_customizer_settings')); section represents the customizer navigator. The definition of a section allows us to make a new item within the navigational system and fill it with control.
Checks are the visible element - the GUI - that allow us to change preferences. This can be entry boxes, text areas, colour selection and other kinds of control element that are used to make the system more user-friendly. Preferences represents the information that our topic should receive and use.
Creating customizers that allow the user to simply modify preferences. name' =>'Colors','priority' => 30, ) ); remember that the above and any other codes that generate section, checks, or preferences should be placed in the cd_customizer_settings() feature. This area is now registred, but will not be displayed until we have added a container.
Preferences tell WordPress that our design uses a value that can be changed by the end-customer. These are added using the $wp_customize->add_setting() type which requires two parameters: the set ID and an array set of items containing information such as the standard value.
Update means that WordPress should update the display when the preference is changed. Complex customizer implementation allows you to preview only the affected item and not the entire page. Buttons that link the preferences to the entries made by the users. When the first is an object of inspection, only one is needed, an entity of the objects.
We will use the command WP_Customize_Color_Control to generate a colour selection item. Labels' => 'Background color', 'Section' => 'cd_colors', 'settings' => 'background_color', ) ) ) ) ) It should have the $wp_customize itself as its first argument, and the Control ID as its second argument. Well, I have a tendency to equate that with the attitude that drives it.
This third arrray contains some items such as the tag, the ID of the section in which it is placed, and the ID of the preference it is controlling. It' s not doing anything yet, but the attitude is there and its value is actually about to change. For this to actually work, we need to set the value of the preference to our theme.
If this is the case, we want to make sure that the object always has the backgroud value as our new preference value. add_action('wp_head','cd_customizer_css'); Please be aware that this is not the kind of customization that should be added to the cd_customizer_settings() like it is for control, section and preference values. get_theme_mod () retrieves the currently active theme's preferences; the first is the name of the preference, the second is the standard value.
Of course, the feature can be used in the theme source to change the feature. So we could - and will soon - make a command and a preference to show and show the buttons. We use the get_theme_mod() is used in the index. PHP script to fade the buttons in and out selective.
In order to get going, we'll build a customizer. ys install and make sure it's lined up. add_action( 'customize_preview_init', 'cd_customizer'); 'cd_customizer', get_template_directory_uri() . /customizer. js', array('jquery','customize-preview'),'', ); the content of this should be a very easy ending, we place all our stuff in it. jQuery ); then make sure that the value of the setting's transportation options is put to afterMessage.
Then insert the following into the customizer. ys filename, inside the shutter. jQuery ); The customize() command uses two arguments, the name of the preference to hear and a command that executes an operation. In turn, the feature triggers another feature that combines the value of our attitude and allows us to use it at our own pace.
Changing the name and the name of the blogs is already possible because of the kernel codes spell. Although we have not defined these choices and checks, we still have the option to change them. We use the get_setting() from the Customizer category to get and change settings option.
Let's start with some buttons that regulate the behaviour of the buttons. In order to show or hide an item, I decided to make a radiobutton item. We will use two arguments for add_control(), which means that the first one is a single character and not a checkpoint. In the second configuration you will find all the information the controller needs to set up the user interface.
Here is the complete set of arbitrary codes that should be placed in the cd_customizer_settings() command. Titles' =>'The Button','Priority' => 20, ) ) );'Default' => True,'Transport' =>'Update', ) ) ) ); Button Display' =>'Affichage des boutons','Sektion' =>'cd_button','settings' =>'cd_button_display','type' =>'radio' =>'show' =>'Show Button','hide' =>'Hide Button', ), ), ), ), )) ; Im Index.
Continue with our buttons modification, let us make the text workable. All we need is a setup and a basic text box controls. Standard' =>'Come On In','Transport' =>'postMessage', ) ) );'label' =>'Button Text','section' =>'cd_button','type' =>'text', ) ) ); To include the options in the theme, we substitute the hardcoded text with the get_theme_mod() command and set a corresponding standard.
It allows you to create more module coding that is suitable for both theme development and adaptation. Rather than update the entire page when the item changes, you can update that individual item. Let's begin by creating our badge with the help of a feature. Made and used the cd_show_main_button() in the master index by putting it in a box.
You can reuse the feature itself in another place. ächo "" . get_theme_mod( 'cd_button_text', 'Come On In') . " "; The last stage is to instruct WordPress to update the item selection. Change the transportation attribute of the preference settings: see below. Change value 1 of display to mailMessage and insert the following within the functions cd_customizer_settings().
Selektor' =>'#button-container','render_callback' =>'cd_show_main_button', ); This informs WordPress that we want to update selective if the settings of the display cd_button_change. specifies the slider within which we want to update everything in the second argument as well as the name of the command that creates the contents. Now, if you try the customizer, you will see that the icon becomes non-transparent, and then load the right contents, unlike the entire website to be updated.
This customizer has many features, from basic text boxes to uploading images. When working on a large-scale program, you may need more sophisticated input devices such as a band slider or even something of your own. You can use the customizer to simply define your own UI element by creating tax categories. Let's make a customized sliderset that allows the user to choose a value with a small grip on it.
Let's get control: give us publicly $type = 'range'; parent:: If we need the actual value and $this->link() instead of the name argument, we need to print an HTML check and make sure to use $this->value(). I' ve made a very easy sliders implement with a little jQuery magic to make sure the value in a text box is still there, and changing the text box also affects the slide bar.
In order to try it out, I make a small count that shows the number of photographs currently on the site. I add the following to the index. directory name. It is now your turn to set up the settings and set up the controls. It uses our recently added sliders. Standard' => 0,'Transport' =>'PostMessage', ) ) ) ) );'Label' =>'Photo Count','min' => 10,'max' => 9999,'Step' => 10,'Section' =>'title_tagline', ) )))
To keep up to date with everything the Theme Customizer is, take a look at the following links: