»WordPress»On Data Processing Methods and Methods before and after Git Theme Updating
Today, Yunluo briefly talked about the conflict handling method between the theme update and user customization, so that friends can use it more happily.
preface
At present, there seems to be no theme in China that supports online express updates like the git theme of Cloud Cloud. The update is good, but it will affect the customization of some users. Because the usage habit of domestic themes is generally the update of replacement files, Cloud Cloud may be unaccustomed to this way,Today, several friends talked about the trouble of updating the theme. The main thing is what to do after the update. All the things and codes added before the update have been cleared, and the logo and background have become the default. If you have similar troubles, then you can finish this article.
be careful
This article is suitable for users who want to slightly modify the theme and upgrade with Cloudfall. If you plan to make major changes with low themes and special changes, the secondary development article will definitely not be suitable for you.
Add code to header
Give Themesheadr.phpAdding code is often used, such as adding verification code. In fact, the cloud has left room for friends long ago. See the figure below
In the website header code, you can directly add the code js or css with their own tags.
Statistical code
Traffic statistics code is also a mandatory code for websites, which can be added in the background of the theme
Footer Code
Like the header code, sometimes some of our js are added in the footer, and Yunluo also reserves space for users. See the following figure
modify style
Some friends actually don't want to do anything, but just want to modify some css. They want to modify it in the style.css code ocean, but it's totally unnecessary. The theme also has a blank space in the background. Just enter the code directly, as shown below
For example, enter the following code in the custom code box
In this way, you can adjust the distance between the top and bottom of the logo. For example, I wrote a sentence that is 40px above the logo and 20px below. Here is a brief introduction to the use of CSS,In the priority level of CSS, the inline style is the highest, followed by the embedded style, and the external style is the lowest. Our general style.css file is the external style, so it is unnecessary to modify the style file if you modify a few styles. The built-in self defined style of the theme is an embedded style, which can directly overwrite the style in the style file
Function file
The functions.php file in the theme is the most troublesome file for many people. Today, a friend suggested to use two functions files, one for the theme itself and one for the user to customize. When updating the theme, the user-defined functions file is not overwritten. This method has been thought of by Yunluo for a long time, and there are specific operation methods. However, the biggest problem is that,lazy。 It is also said here that the idea of Yunluo before is also relatively simple. Create a new branch of my code warehouse and use this branch as a dedicated code warehouse for updating. Generally, the complete package is downloaded when downloading, and the code extracted when updating the theme in the background is the file of the update package. The complete package and the update package are different from each other by a custom functions file,But the disadvantage is that I need to submit the code to two code repositories when I submit the code, so it is troublesome, so I didn't use this method.Because Yunluo has found another solution to this problem, which is very simple, very simple.
When the above plug-in was released, we didn't make it clear. We'll talk about clearing it here. We know that in general, plug-in code can also be used in the functions file. On the contrary, the code in the functions file can also be used in the plug-in. It would be better to make a plug-in yourself. In fact, it's very simple to make a plug-in yourself. Let's follow the cloud and have a look.
<?php/*Plugin Name: WidgetDescription: Add some small functions to the themeAuthor: Cloudfall*///Add code in the file to make it the same as the functions file?>
Save the above code as a php file, remember the UTF-8 code, and then put it inwp-content/pluginsFolder, right, put it directly into the plug-in folder, and then go to the plug-in center to have a look😀
A plug-in comes out in this way. Although there is no actual code in it, it is just a plug-in that starts to work for the website. Just like adding code in the functions file, adding code in this small plug-in is OK, such as the following small functions. Here is a small function, which is the code of background color switching