How to remove the ManageBlocksMenuItem in the ToolsMoreMenuGroup in the Gutenberg Editor?

In the Edit Article page of the Gutenberg Editor, click the three buttons on the far right side of the Gutenberg menu bar. You get an overlay with VIEW, EDITOR, PLUGINS, and TOOLS sections. Block Manager is listed under the TOOLS section. How do you permanently remove the Block Manager row, so folks cannot open the Block Manager modal?
Category: Web

Wordpress auto generates small medium and large of an image on upload, how can we guess their links?

WordPress out of the box has an integrated image sizes system, which creates files ( thumbnail, S, M, L) but in the media library, it only shows one original file size link. Let's say, I upload a file named pretty-cat.jpg and I want to use a medium-size image which is around 700px and I know WordPress has it in its images folder but for that, I have to navigate to that folder to find the name of the file. There …
Category: Web

How can I reference external attachments without breaking core WordPress files?

I am developing a site that uses WooCommerce & WordPress to show a fair amount (10,000+) products, and can't accommodate the size of all the images for the products. So, I'm leaving the images on their CDN, and making all the image attachments references to the external URLs. This required a bit of hacking, as WooCommerce/WordPress will try to take the images and upload them and set the attachment URL to a local relative path (eg, 2018/02/), and then when …
Category: Web

How to update the delete user confirmation form?

I want to update the confirmation form for delete user. If user has posts, it shows Attribute all content to - option to reassign other author for his posts. It takes lots-of time to load the page, if there are thousands of users in the system. (we have 55k+ users) So, I want to change the User option (Attribute all content to) from Drop-down to Type and Search. I've tried to found the hooks/action but could not found that I …
Category: Web

Login cookies blocked after customizing hashing method

I get the following error when trying to login: Error: Cookies are blocked due to unexpected output. I customized the wordpress core functions wp_hash_password() and wp_check_password() to use SHA1 algorithm for user authentification instead of MD5. I modified them in the pluggable.php file (not best practice but good for testing). The functions now look like this: function wp_hash_password( $password ) { global $wp_hasher; if ( empty( $wp_hasher ) ) { $wp_hasher = sha1( $password ); } return $wp_hasher->HashPassword( trim( $password …
Category: Web

Error while localizing communityEventsData in script-loader.php

I'm getting an error in my logs: NOTICE: PHP message: PHP Warning: Cannot assign an empty string to a string offset in /usr/share/nginx/wp/wp-includes/class.wp-scripts.php on line 492 So I got the stack trace: Array ( [0] => Array ( [file] => /usr/share/nginx/wp/wp-includes/functions.wp-scripts.php [line] => 221 [function] => localize [class] => WP_Scripts [type] => -> [args] => Array ( [0] => dashboard [1] => communityEventsData [2] => Array ( [nonce] => 0c29524bac [cache] => [time_format] => g:i a ) ) ) I …
Category: Web

Should there be concern about breaking Gutenberg updates to extended core blocks?

I have recently began developing custom/extending core Gutenberg blocks for a custom plugin that I develop for clients I work with. One of my main concerns is about whether extending core blocks will lead to potentially having to refactor a large amount of client sites when Gutenberg updates the core blocks. Is there a safeguard within the way WordPress updates software that can prevent this from being a major concern? Is there anything that I can keep in mind when …
Category: Web

How to Dequeue All WordPress Assets

I want to dequeue all styles and scripts that are loaded on the front-end (EG. not the admin panel) by default. I found this function, but am not sure how to utilize it to accomplish my goal. I'm seeing a ton of assets that I don't need on the front end, loaded by WP core: For example: backbone.js jquery UI jquery UI datepicker 5 different mediaelement assets (js + css) underscore.js wp-embed js wp-util js
Category: Web

How to remove X-Frame-Options: SAMEORIGIN" from WordPress?

I want to temporarily remove X-Frame-Options: SAMEORIGIN and need to allow all domains. I have already tried the following ways. Removing send_frame_options_header from ./wp-includes/default-filters.php remove_action('login_init', 'send_frame_options_header'); Removing @header( ‘X-Frame-Options: SAMEORIGIN’ ); from /wp-includes/functions.php None of the above doesn't work. PS: I don't use any security plugin either.
Category: Web

Attachment metadata has value of '1'

While accessing /wp-json/wp/v2/media endpoint I'd got an error 500. Checking the logs, I'd seen the following issue: PHP Recoverable fatal error: Object of class stdClass could not be converted to string in /Applications/MAMP/htdocs/reinvently.local/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php Basically, the error was caused by prepare_item_for_response function in class-wp-rest-attachments-controller.php because, for some reason, most of the attachments (>1k) had a string 1 as a value for _wp_attachment_metadata key in the database. Which is, I suppose, is not a valid value at all. I've tried to change …
Category: Web

How to overwrite / extent wordpress function is_email

so wordpress' core isn't really up to date with email allowances of unicode domains. Even simple special characters like the german umlauts (äÄöÖüÜß) aren't allowed in the domain part of the name. So I've been thinking to add a filter to the is_email function with high priority and simply return the result. But it doesn't seem to function as I've intended to. Here's what I've tried: // Code written in my themes functions.php function kk_email_validation_override( $email ) { $pattern = …
Category: Web

Who updates the wp-admin/core file?

I can see it's a CDN file and I can't access it. My security plugin alerted me that there had been a modification to the wp-admin/core file, but I didn't change anything. I haven't updated to 5.0 yet. So who changed it? I apologize if this is a duplicate. I can only find "how to" posts about core updates, not anything specifying who actually updated it. I'm just not sure if this is a security concern or a normal process …
Category: Web

What problems maybe happen if I remove "wp-" prefix from wordpress folders and files?

I want to hide wordpress signs from my site. So I don't want other people know that I built the website via WordPress. So I decided to remove wp- prefixes from all wordpress folders and files. And I also removed wp- prefixes from file contents with Notepad++. So my question is what problems maybe happen if I removed wp- prefixes ? Thanks in advance.
Category: Web

Add class to before_widget from within a custom widget

I have a simple custom widget that asks for its width (that is used later in the front end). The width field is a select dropdown, so a user have predefined options. I will have many instances of my widget, each will have its own width setup. Now, in my widget code I have the following code: echo $before_widget; which results in: <div class="widget my" id="my-widget-1"></div> What I'd like to do is somehow hook into $before_widget and add my own …
Category: Web

How to make changes to wordpress core files and make them resistant to wordpress updates?

I have my WordPress setup on IIS and it is rewritten. Because of that I found some probably bug in wp_includes/canonical.php file. I think that when I update my WordPress that all my changes will disapear. I can't wait for WordPress fix this (I don't even know if it is bug or how to report one) because that "bug" causes my homepage to go in redirect loop. I made some change in redirect_canonical function in that file specificly this change: …
Category: Web

Custom Wordpress Core upgrade through wp-cli

I'm trying to do a custom wordpress core upgrade through wp-cli, theres an GUI upgrade hang issue in kubernetes when AWS EFS storage is used. For me wp core upgrade works great. I need somekind of binding to the upgrade button in the gui, when clicked it should invoke the custom_upgrade.php script which will do shell execution. I'm pretty new to php and wordpress. Here's a sample script provided by mwithheld: https://github.com/wp-cli/wp-cli/issues/1924
Category: Web

About

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