On Data Processing Methods and Methods before and after Git Theme Updating

» 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.

论处理Git主题更新前后的数据处理方法与方式-极客公园

preface

be careful

Add code to header

Give Themes headr.php Adding code is often used, such as adding verification code. In fact, the cloud has left room for friends long ago. See the figure below
论处理Git主题更新前后的数据处理方法与方式-极客公园

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
论处理Git主题更新前后的数据处理方法与方式-极客公园

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
论处理Git主题更新前后的数据处理方法与方式-极客公园

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
论处理Git主题更新前后的数据处理方法与方式-极客公园

For example, enter the following code in the custom code box

 .g-logo h1 { padding-top: 40px; padding-bottom: 20px }

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.

https://gitcafe.net/archives/3877.html

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: Widget Description: Add some small functions to the theme Author: 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 in wp-content/plugins Folder, right, put it directly into the plug-in folder, and then go to the plug-in center to have a look 😀
论处理Git主题更新前后的数据处理方法与方式-极客公园

论处理Git主题更新前后的数据处理方法与方式-极客公园 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

 function Bing_random_admin_color(){ static $color; if( isset( $color ) ) return $color; $color = array_keys( $GLOBALS['_wp_admin_css_colors'] ); $color = $color[array_rand( $color )]; return $color; } add_filter( 'get_user_option_admin_color', 'Bing_random_admin_color' );

Add the above code to the small plug-in file, as shown below

 <? php /* Plugin Name: Widget Description: Add some small functions to the theme Author: Cloudfall */ //code function Bing_random_admin_color(){ static $color; if( isset( $color ) ) return $color; $color = array_keys( $GLOBALS['_wp_admin_css_colors'] ); $color = $color[array_rand( $color )]; return $color; } add_filter( 'get_user_option_admin_color', 'Bing_random_admin_color' ); ?>

Go to the background to enable the plug-in, refresh it, and it will take effect. No problem
论处理Git主题更新前后的数据处理方法与方式-极客公园

--End--

Post reply

Your email address will not be disclosed. Required items have been used * tagging

4 Replies to "On data processing methods and methods before and after Git theme update"