Updating WordPress core with zero downtime - I mean zero

I have a critical website which is under version control. When I update the core WordPress files I do so locally, then commit the changes. When I do that the live site (obviously) does not even display a maintenance notice, it simply errors out for a few minutes as the core files are deployed, and presumably are either read part way through, or are temporarily incompatible one to the other. I could update from the live admin, and then deploy, …
Category: Web

Is there a way to opt out of or block having the newest core themes installed on update?

We generally keep our custom theme in non-auto-update mode and one core WP theme in auto-update mode as an emergency backup as our only 2 themes in the wp-content/themes directory. If we had twentytwenty installed when we launched the site in 2020, that's sufficient for our purposes - we don't need twentytwentyone and twentytwentytwo, etc. It's annoying to have to delete these manually after WP updates add them. Is there any way to block that from happening?
Category: Web

Display Custom Column in CPT Taxonomy

I am trying to add a column to one of my custom post types, but only on the edit taxonomy page. I have a taxonomy registered called "event-categories" for my custom post type "events". I can successfully add the custom column to the custom post type edit screen, but can't seem to get the hook to work on the edit taxonomy page. Digging through some of the core, I was able to locate the hook $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, …
Category: Web

Disable "auto embed" feature when pasting text and links

I want to disable the auto embed feature of Wordpress, when pasting arbitrary text that includes links in Gutenberg. I tried this with something like: add_filter('allowed_block_types', 'remove_default_blocks'); function remove_default_blocks($allowed_blocks){ // Get all registered blocks $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); // unset embed block unset($registered_blocks['core/embed']); // Get keys from array $registered_blocks = array_keys($registered_blocks); // Merge allowed core blocks with plugins blocks return $registered_blocks; } This works - but unfortunately this disables all embed blogs and I want the user to manually embed e.g. …
Category: Web

Should /wp-includes/js/* folder be blocked in robots.txt file for a WordPress website?

In my WordPress website. I am disallowing /wp-includes/js/* folder in the robots file. Is that bad? I use SEMRush to audit my site and it shows an error that a resource at the above location is being blocked. This is my robots.txt User-agent: * Allow: /wp-content/uploads/ Disallow: /wp-admin/ Disallow: /wp-includes/ Disallow: /wp-content/plugins/ Disallow: /linkout/ Disallow: /recommended/ Disallow: /comments/feed/ Disallow: /trackback/ Disallow: /index.php Disallow: /xmlrpc.php Disallow: /readme.html Disallow: /refer/ Disallow: /search/ Allow: /wp-admin/admin-ajax.php Sitemap: https://www.example.com/post-sitemap.xml Sitemap: https://www.example.com/page-sitemap.xml Sitemap: https://www.example.com/video_portal-sitemap.xml Sitemap: https://www.example.com/press_release-sitemap.xml …
Category: Web

WP_Site_Query vs. WP_Network_Query in WordPress 4.6

Can someone explain the difference between WP_Site_Query and WP_Network_Query in WordPress 4.6? WP_Network_Query() : Core class used for querying networks. WP_Site_Query() : Core class used for querying sites. WP_Term_Query() : Class used for querying terms. Are there examples when you would query the Network vs. the Site vs. Posts? Wouldn't a WP_Site_Query just be a WP_Query? I've been hoping for a way to query posts across multiple sites but I don't think this is that. I wonder if Multisite Focused …
Category: Web

Plugins download & install fine, wordpress update fails

I've setup all permissions and directories/files correctly according to Wordpress. Adding plugins/installing/updating works perfectly, but when it comes to updating to 4.7.2, it asks me for FTP details or if I force FileSystem (direct) in the WP config file, it says it couldn't update due to inconsistent file permissions or not being able to create the directory. Literally all file permissions and user permissions are setup as per the recommondation from wordpress, however I can't update the core. The log …
Category: Web

Create custom page to author.php

How can i add new pages to author page? normal url is like https://www.example.com/author/exampleUser i wanna make a settings page located in like this: https://www.example.com/author/exampleUser/settings or https://www.example.com/author/exampleUser/saved etc...
Category: Web

Trying to get property 'ID' of non-object in /wp-includes/class-wp-query.php on line 4044

I've made a custom plugin, but somehow I've made something that fills up my debug.log with garbage. It looks a bit like something this is faulty in the WordPress-core, but I'm not 100% sure. Here is an extract of one of the 3 errors, that get's repeated 5 times per page request: PHP Notice: Trying to get property 'ID' of non-object in /wp/wp-includes/class-wp-query.php on line 4044 PHP Stack trace: PHP 1. {main}() /index.php:0 PHP 2. require() /index.php:4 PHP 3. wp() …
Category: Web

Show notice just below the search form on the themes page

I want to show a notice on the theme installation page. I have used the admin_notices hook but it is showing the message above the search box. I want to print the notice at the place of a black line in the image. For the plugin page, we have the pre_current_active_plugins hook but for the themes page, I didn't find one.
Category: Web

Gutenberg button removed on save if its empty

I have buttons with no text in my design which has icons designed in :before of the a tag. It was working fine with the WP 5.5, but now I have updated in live and when I save any page it removes all those buttons. I understand that because it is empty WP removes it on save. Is there a way that I can skip a block or skip this removing block stuff because most of my blocks have empty …
Category: Web

wordpress wp-admin/includes/shema.php file has been modify alone

I have a problem, a file from wp-admin has been modified alone or after deactivated/activated my own plugin . I never modified any files inside wp-admin, I don't know why now. I am currently creating a plugin to add some information inside database from a form . After updating a table inside database, i must deactivated and activated the plugin to apply the changes. Also I have to get a backup of one file inside wp-content from my host ! …
Category: Web

Notice on core function

I have this weird error (I guess) since this morning in my logs : [23-Nov-2021 14:46:50 UTC] PHP Notice: Undefined offset: 3322309 in ..../wp-includes/class-wp-query.php on line 3275 Where the 3322309 is increasing for no reason. I see this in my PHP logs, but it's increasing even if my server are down. This is the code concerned
Category: Web

What is the role and history of the $content_width global variable?

I just stumbled over a global variable called $content_width. It was new to me, so far I could see that it's used in themes, both the standard twenty ten one and third party ones. It looks like that it contains the width of the content area in pixels. Since global variables are not documented in the codex, I had trouble finding information about it. When was the $content_width global variable introduced and for what reason? Is there a ticket related …
Category: Web

Understanding SHORTINIT with Wordpress 5

What I am trying to achieve I am looking at using Wordpress decoupled, and most tutorials and guides go into detail on using the Rest API. Recently, I discovered the SHORTINIT option to load a very minimal Wordpress instance. There is next to no documentation, and very few questions about its use, however I am interested in making use of it. What have I tried So far, I have setup a simple test php file in the root directory: define('WP_DEBUG', …
Category: Web

Remove annoying WP Adminbar CSS

I am trying to remove the annoying WP Admin bar css. <style type="text/css" media="screen"> html { margin-top: 32px !important; } * html body { margin-top: 32px !important; } @media screen and ( max-width: 782px ) { html { margin-top: 46px !important; } * html body { margin-top: 46px !important; } } </style> I have tried (according to other OLD answers): /** * Remove admin bar CSS */ function remove_admin_login_header() { remove_action('wp_head', '_admin_bar_bump_cb'); } add_action('get_header', 'remove_admin_login_header'); It does not work.
Category: Web

approach to pass additional parameter in post URL

I am trying to automatically pass an additional parameter whenever the post is saved as Draft or Published. When a post is saved as Draft or Published, the URL is updated to /wp-admin/post.php?post=postid I want to add additional parameter in post URL on click publish so the URL becomes /wp-admin/post.php?post=postid&new_param=postid My approach so far: wp-includes/post.php '_edit_link' => 'post.php?post=%d' I added the additional parameter and it worked fine but I need the additional parameter to have post id too i.e post=123&new_parameter=123&new_para=true …
Category: Web

wp_insert_post always returns 0 on one site, extensive testing done, can't get to the bottom

I have two sites. One, a fresh install, the other an existing site with errors/white screen of death on the wp-admin/post-new.php screen. I've disabled all of the active plugins, and enabled a default theme, and am still getting these errors (because the draft post is not created properly in the DB during the page load). Notice: Trying to get property 'post_type' of non-object Warning: Creating default object from empty value Notice: Trying to get property 'post_status' of non-object Notice: Trying …
Category: Web

Updating wordpress from my Linux distro's repository

I installed wordpress with apt, which ties in a lot of directories, so I suspect that using the built-in core update tool will break the installation; but wordfence constantly demands that I update using said tool -- which is probably much more up-to-date than the linux distro repository. Do I have to wipe it out and start over in order to resolve this annoying bind?
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.