The method and code for WordPress background to prohibit non administrator users from viewing website comments

The [Comment] on the background of the WordPress website can be accessed and viewed by other roles, such as contributors, in addition to the administrator. This is obviously unreasonable and will reveal the privacy of the comment user, because who has the comment content and also has the commenter's email, IP or other user-defined extension information. Therefore, it is necessary to modify the access permissions of WordPress background comments. It is suggested to remove the [Comment] menu from the background for non administrator roles, and then prohibit non administrator roles from accessing. Implementation code and modification method: 1. Add code in the functions.php file of the current topic: function remove_edit_comments_m
, 149 ℃

Solution to the problem that WordPress Baidu Sitemap Generator plug-in cannot generate xml files in PHP 7+version

When using the WordPress Baidu sitemap generation plug-in in Liucheng to generate the XML file, when clicking the "Update XML file" button to generate the XML file, the prompt "This site has encountered a fatal error" appears. The check found that the WordPress Baidu Sitemap Generator plug-in may not work properly in PHP 7+. Since the plug-in author has not updated and maintained this plug-in for a long time, the author's website has been unable to open and feed back problems. At the same time, it seems that there is no better solution to replace the generation of Baidu sitemap xml files. So think about it, you can only repair and update it by yourself, so that it can
, 741 ℃
 Tutorial method of changing domain name in WordPress multi site subdirectory mode

Tutorial method of changing domain name in WordPress multi site subdirectory mode

The method of WordPress domain name change Blog Bar has shared the "Two Simple Methods of WordPress Website Domain Name Change Tutorial" before. The method of WordPress multi site mode domain name change is similar to the previous one. The difference is that the data table and data field are different. There are several more statements that need SQL query, and the domain name of the multi site configuration code in wp-config.php needs to be modified. Operating steps: Note: The following tutorials involve website data, so be sure to back up the website data before operation. 1. Edit Web

WordPress calls the media library component wp.media to upload pictures, videos, documents and other media files

WordPress theme or plug-in application development often requires uploading function of media files such as pictures, videos, documents, etc. If developers write media upload components independently, they need to spend a lot of time and effort. However, by calling the media library components provided with WordPress, they can achieve twice the result with half the effort. Only simple js code can be written to have a powerful media upload function. Wp.media code parameter var mediaObj=wp.media ({frame: 'select',//Select the media type to call the media library. You can select, post, image, audio, video, and select s
, 974 ℃

WordPress calls to delete the classic-themes.min.css style file of the front-end page

After WordPress is updated to version 6.1, WordPress will automatically generate and reference a class-themes.min.css style file with the ID of class-theme-styles-css in the front end head. The file contains a style code for the class selector.wp-block-button__link, which seems to work on Gutenberg blocks, It can be deleted through the wp_enqueue_scripts hook. The generated calling code is as follows: Delete classic theme
, 1209 ℃
 WordPress TinyMCE editing mode to add the code of size prompt for characteristic image upload

WordPress TinyMCE editing mode to add the code of size prompt for characteristic image upload

There is no hint about the size of the image when uploading the featured image edited by WordPress articles. If the theme is developed for your own use, it will have no impact. But if it is a custom theme, it will obviously affect the size selection of the thumbnail when the customer uploads it, thus affecting the display effect of the front page of the website. Therefore, when developing WordPress applications that use featured images, you can effectively avoid some details by adding a hint of image size to the location where featured images are uploaded. The code for adding prompts is relatively simple
, 1362 ℃

WordPress adds tutorial codes for custom fields to categories and labels

The previous blog has shared the tutorial code for WordPress to add custom fields for category keywords. This time, the core code for adding custom fields for categories and labels is the same as the code for custom fields for category keywords, with only minor optimization and expansion and the addition of hook functions for labels. The following steps are taken to add custom titles Sample code for custom fields of custom keywords and custom descriptions. Add the following code to the functions.php file of the topic: The output code code is very simple. You can copy it directly or add more custom fields by reference.
 WordPress Security Settings Change Login Error Prompt

WordPress Security Settings Change Login Error Prompt

When logging into the WordPress background, if the user or password entered is incorrect, a targeted prompt will appear. If you enter an incorrect user name, you will be prompted that the user name is not registered on this site; Entering an incorrect password will prompt that the password specified by the user name is incorrect. If the user name and password are entered incorrectly at the same time, according to the default error prompt priority of WordPress, it will first prompt that the user name is not registered, and then prompt that the password is incorrect if the user name is registered. Prompt that the user name is correct and the password is incorrect. Prompt that the user name does not exist
1628 ℃

The function is_active_widget used by WordPress to determine whether the specified appearance widget is enabled

The WordPress function is_active_widget() detects whether a visual gadget (such as a search gadget) is enabled (added to the sidebar) after the gadget is initialized. If the gadget is enabled, it returns true or the ID of the sidebar where the gadget is located. If the gadget is not enabled, it returns false or the ID of the sidebar where the gadget is located is empty. It should be noted that the test shows that this function is only effective for old gadgets, and does not support block gadgets. Function code is_active_widget (call | false $callback=fa
, 1080 ℃
 WordPress removes the language selection setting code of the background login page

WordPress removes the language selection setting code of the background login page

The login page starting from WordPress 5.9 has a language selection setting (as shown in the figure below). You can change the language of the login page, such as "Simplified Chinese", so the language of the login page is Chinese; Select "English", and the language of the login page is English. After the blog bar test, it seems that this setting only changes the language and text of the login page, and has no effect on other pages (perhaps not found), then this function does not seem to have much effect, and removing it should
1571 ℃

How does WordPress disable its own XML sitemap wp-sitemap.xml

WordPress 5.5 started with its own XML site map, but many WordPress users used plug-ins or third-party tools to generate the site map XML file, and did not intend to replace it with the wp-sitemap.xml provided by WordPress, so that the XML site map provided by WordPress would become redundant, You can also choose to disable WordPress wp-sitemap.xml. Blog Bar currently knows that there are two ways to disable WordPress wp-sitemap.xml, one of which is

WordPress code hook jpeg_quality for modifying the compression quality of uploaded JPEG images

Many people may not have noticed that WordPress has always compressed the image quality of uploaded JPEG formats (such as. jpeg and. jpg) by default. Before WordPress 4.5, the image quality will be compressed to 90%. After WordPress 4.5, the image quality will be compressed to 82%. This is to reduce the image size and optimize the loading speed. But not everyone wants the uploaded image to be compressed, because the compression quality means that the uploaded image will be blurred or distorted. Of course, some people think that the image quality is not compressed low enough and want to compress it smaller. Perhaps the WordPress official also took these situations into consideration, so it also provided modifications
, 1338 ℃