Fibro Jedi
Forum Replies Created
-
No, I’m a bit mystified by that myself. As it’s site-wide for me, I can’t pin it down to any particular script, template file, or plugin. And I’ve coded much of the functionality myself so I was 100% open to this being my fault.
So it’s tough to trace what, on my side, could be triggering it. Looking at your bug report, it seems you have some support, along with a defensive approach to prevent misuse. So thanks for that.
Am I safe to put back into place some of what I undid for testing, or should I leave it as-is for now?
(Finally, as the issue isn’t, strictly-speaking “mine” as it’s been pushed up to WP, I can also mark this as resolved if that helps?)
Additional Check – htaccess
I just spotted in the error log that xmlrpc.php was still blocked. So I checked the
htaccessand I still had a <Files> rule doing just that.I’ve deactivated that (for now).
I won’t disable Cloudflare yet, under the “Change one thing at once else no one knows what caused anything” approach.
Edit: Out of curiosity, if this does seem to fix it, how can I make the rule so JP can do its work while keeping it blocked from everyone else?
<Files xmlrpc.php>
Order deny,allow
Deny from all
Allow from .wp.com
</Files>I took
.wp.comfrom the fact that you’re matching^http(s)?://i[\d]{1}.wp.comin class-image-cdn.php (Line 689)- This reply was modified 9 months, 3 weeks ago by Fibro Jedi.
Sorry for the delay. We had really warm temperatures and horrid humidity – my office is a large shed in the garden so it got over warm so I couldn’t be in there.
Enhancement Suggestion…Suggestion
I certainly can!
Debugging?
I’m not sure what was left to do at this point. I made the changes to XML-RPC and the wp-config files a few days ago and they haven’t stopped the exact same error from re-surfacing today.
Evidence
[Tue Aug 19 23:09:24.668598 2025] [proxy_fcgi:error] [pid 1256790:tid 1256790] [client 172.71.223.96:60126] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught TypeError: WP_HTML_Tag_Processor::get_updated_html(): Return value must be of type string, null returned in /home/site/public_html/wp-includes/html-api/class-wp-html-tag-processor.php:4146\nStack trace:\n#0 /home/site/public_html/wp-content/plugins/jetpack-boost/jetpack_vendor/automattic/jetpack-image-cdn/src/class-image-cdn.php(699): WP_HTML_Tag_Processor->get_updated_html()\n#1 /home/site/public_html/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Image_CDN\Image_CDN::filter_the_content(NULL)\n#2 /home/site/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array)\n#3 /home/site/public_html/wp-includes/formatting.php(3984): apply_filters(‘the_content’, ‘One of the more…’)\n#4 /home/site/public_html/wp-includes/class-wp-hook.php(324): wp_trim_excerpt(‘One of the more…’, Object(WP_Post))\n#5 /home/site/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(”, Array)\n#6 /home/site/public…’
Cloudflare Things Done
From the two articles you linked re: Cloudflare, here are my notes:- SSL/HTTPS
- It’s not a 5XX error
- Rocket Loader isn’t on
- Anything that is in a Cloudflare paid package or tier is irrelevant as I’ve always been on free.
- I’m not blocking XML-RPC (currently)
What’s Left?
As far as I can tell, the only thing I haven’t done yet is disable Cloudflare completely to see if the error goes away. Is that right?
Thanks.
I hadn’t even thought about Cloudflare being a potential conflict TBH. I’ll have a look into it after the weekend.
Some of those steps I have in place (like excluding the dashboard from cache) but I don’t use the CF plugin as I didn’t see a benefit before. But I can, as part of testing.
Did the Errors Return?
Sadly, yes. I’ll look at this specific URL now, as it’s a particular post type and I can’t afford (traffic-wise) for that content to break.
But this post_type doesn’t include the shortcodes I looked out from other posts. I’ll see what could possibly causing a
nullin the code now before I break for the weekend.'PHP message: PHP Fatal error: Uncaught TypeError: WP_HTML_Tag_Processor::get_updated_html(): Return value must be of type string, null returned in /home/site/public_html/wp-includes/html-api/class-wp-html-tag-processor.php:4146\nStack trace:\n#0 /home/site/public_html/wp-content/plugins/jetpack-boost/jetpack_vendor/automattic/jetpack-image-cdn/src/class-image-cdn.php(699): WP_HTML_Tag_Processor->get_updated_html()\n#1 /home/site/public_html/wp-includes/class-wp-hook.php(324): Automattic\\Jetpack\\Image_CDN\\Image_CDN::filter_the_content(NULL)\n#2 /home/site/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array)\n#3 /home/site/public_html/wp-includes/formatting.php(3984): apply_filters('the_content', 'Because there a...')\n#4 /home/site/public_html/wp-includes/class-wp-hook.php(324): wp_trim_excerpt('Because there a...', Object(WP_Post))\n#5 /home/site/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters('', Array)\n#6 /home/site/public...', referer: https://fibrojedi.me.uk/ffxiv-enemies/nix/Edit: Looking at the error log, it’s not just posts or post_types. This error is also being tripped on a category page like – https://fibrojedi.me.uk/category/lotro/.
Excerpt?
I was curious – looking at the error – because it seems to be the wp_trim_excerpt() causing and issue. Why, though, I don’t know.
AFAIK, the only interaction my site has directly with the excerpt is this function
function fibrojedi_remove_shortcode_from_excerpt($content) {
//https://wordpress.stackexchange.com/questions/112010/strip-shortcode-from-excerpt
if(!is_null($content)){
$content = str_replace(“[fj_toc]”,””,$content);
$content = str_replace(“[fj_dfi]”,””,$content);
$content = str_replace(“[menu_anchor]”,””,$content);
$content = str_replace(“Post Sections”,””,$content);
$content = str_replace(“Hide”,””,$content);
$content = str_replace(“Show”,””,$content);
$content = strip_shortcodes( $content );
}
return $content;
}
add_filter(‘the_excerpt’, ‘fibrojedi_remove_shortcode_from_excerpt’);I had seen, in categories, that if I hadn’t pre-populated an excerpt (ain’t nobody always got time for that) then the system was inserting one but including printing out shortcodes. Odd for WP to do that at all.
So I did my own function to clear out certain shortcodes and phrases on UI elements that had nothing to do with the intro text.
I don’t know if it’s related, but, as you can see, it should not return
nullprovided that$contentisn’tnullat the start.Thinking about it, maybe I should force it to return a blank string if it’s
nullbut I might be looking in the wrong rabbit hole here.XML-RPC
However, I may have manually added my own off-cloudflare rule around
xmlrpc.phpwhich, without knowing in advance, may have also caused hiccups. I’ve been hit a few times with…outside forces…trying to do their thing on that PHP file in the past, but I’m not totally blocking it either.Edit: Using the plugin WP-Hide, I had, in fact, renamed xmlrpc as I don’t use another plugin that requires “outside in” access. I’ve put it back to the default for now. Their setting did allow for a block on the default file but I didn’t enable that, so in theory it shouldn’t have caused the issue. But there’s theory…then there’s reality!
Occasionally in the log there is a reference like the below. But not all the IPs that triggered the original error could be linked to the below error either. In fact, it was the minority where they were linked (by IP and timestamp).
[access_compat:error] [pid 397775:tid 397775] [client 172.70.55.38:56194] AH01797: client denied by server configuration: …/xmlrpc.php
SSL/HTTPS
Re: HTTPS: everything is SSL, but I don’t mind adding the extra wp-config rule. It won’t make a difference to my SSL-everywhere-and-redirects-in-case-of-HTTP approach – but it won’t harm to add them either.
I’ll run the other tests and things next week (it’s late on Saturday and I have Sundays off blog stuff).
I know Jetpack can’t (and shouldn’t) offer customer support for Cloudflare, but if one of your plugins detects it in use, sending a notification to read the articles you just linked might be an idea?
- This reply was modified 9 months, 3 weeks ago by Fibro Jedi. Reason: Adding edits to clarify where the error was found on-site and additional info on xmlrpc.php
- This reply was modified 9 months, 3 weeks ago by Fibro Jedi. Reason: added a thought about excerpts as they are mentioned in the original error
Hey,
I have an update:
- I fixed the possibility of
[fj_dfi]returningnull, though usually it only goes in in pages where it will output something. [menu_anchor]and[fj_toc]shortcodes always output something, even if it’s an empty string (so they’re never null).- “boost-cache” and related folders are CHMOD 755 as they should be.
- When I deactivated the image CDN the errors went away. (Without clearing the cache)
- I did a deactivate and reactivate of the whole plugin and let it regenerate critical CSS. Then I re-enabled image CDN. Apart from getting error messages from my Redis Cache during that time, it went smoothly.
- I can’t tell you if the errors are back yet as I’ll need time for different people to use the site to check that.
Initial note: fixing the “returning null of a shortcode” may have helped, so potentially that’s just an edge case to handle in the Image CDN integration?
[fj_dfi]inserts the featured image in place of the shortcode. So it is image-related.I’ll check back tomorrow and let you know whether or not more errors have cropped up from the above changes. If they do, I’ll do the cache clear check.
Thanks,
FJThanks – I can try some of those, but this is a live – and very busy – site, so deactivating plugins and switching theme will just break everything.
My site does not need to remain private, I just didn’t want my paths “out there”. https://fibrojedi.me.uk/
I have a fair amount to do on the blog today but will try to do some of those tests tonight or tomorrow. In the least I can check the shortcodes – AFAIK those ones should return an empty string rather than
null, but I’ll double-check.Summary
I will test:
1. Shortcode output fornullvalues
2. Disabling the image CDN
3. Clearing the Cache folder and check folder permissions.
Feel free to see what you can from an outsider’s perspective.Thanks!
FJ
Forum: Plugins
In reply to: [Sticky Preview and Publish Buttons by FibroJedi] Translation of buttonsHi Jan,
You’re welcome – and sorry for the lack of Internationalization. If you would like to provide the German translations, then I can work it into my next version and give you the credit for it.
Would that work for you?
I am going away for a couple of weeks but can look into this when I get back.
Thanks again,
FJ
Forum: Plugins
In reply to: [Sticky Preview and Publish Buttons by FibroJedi] WordPress 6.7 CompatibilityVersion 1.4.4 is here. What’s new?
- Several bug fixes tied to typos and brainsplats where my Fibro Fog did the typing.
- A few settings page style tweaks for visual clarity.
- Compatibility with 6.7 checked.
So, this is a minor update, but necessary. I’ll be looking at the code in the near future for improvements. And please do report any bugs (or ideas, even).
What Did I Mess Up in 1.4.4?
I did the “tagging” stage at the wrong point in the update process. So the “1.4.3” tag here on WP.org actually contains 1.4.4 code. I don’t know if I can actually fix that.
The Workaround
However, 1.4.4 was two updates back-to-back, because I forgot I had added tweaks to my local copy. So, here on WP.org the 1.4.2 tag is correct and that’s the one to roll back to if you need that.
Thanks!
Forum: Plugins
In reply to: [Dark Mode for WP Dashboard] Load js file errorThe other way you could place it would be to swap
admin_print_stylestoadmin_footerpretty much ensuring it’s the last style call on the <body> tag (depending on other plugins and browser extensions, anyway).Forum: Plugins
In reply to: [Dark Mode for WP Dashboard] Load js file error@tonyquicktech hey, okay so I had a look and there is only one
.cssfile mentioned in the PHP and it should be loading, even though there are others in the main PHP file (others in the/assets/scss/pluginsfolder).It’s appearing correctly in my View Source, and I don’t see the header/background issues you do.
Though now I look at it, the // in the css path, might not be helping.
Change Line 28 (from my re-worked bit) to
$dark_mode_dashboard_style = apply_filters( 'dark_mode_dashboard_css', DARK_MODE_DASHBOARD_PLUGIN_PATH . 'assets/css/dark-mode-dashboard.css' );As I’m not seeing the white background, can you just check you’re not also using a Dark Mode browser extension as sometimes these can invert the colours. The background colour is set in
.cssand.scssfiles.In your case, the issue is the background colour, not the text, as the text is supposed to be light as a contrast to the background which is supposed to be dark.
Try adding this in, which is my extremely-simple-code so you can blame me:
function dark_mode_dashboard_force_background_color(){
?>
<style>
/* Overriding background colour: by @fibrojedi for @tonyquicktech
This is the same colour as in the CSS files, but injected here to be certain */
body{
background:#23282d!important;
}
</style>
<?php
}
add_action('admin_print_styles','dark_mode_dashboard_force_background_color');- This reply was modified 1 year, 7 months ago by Fibro Jedi. Reason: spell checking and formatting
Forum: Plugins
In reply to: [Dark Mode for WP Dashboard] Load js file errorOkay, I cheated to get the answer, so I am not claiming this is my work. But I have tested it and I’m not getting nonce errors, and switching mode still functions.
- Go to about Line 99 where this function starts: dark_mode_dashboard_toolbar_change_js()
- Add this code before the ?> that immediately follows the function declaration: $nonce =
wp_create_nonce('dark_mode_dashboard_nonce'); - A few lines down, replace this line
'security': darkModeDashboard.noncewith
'security': '<?php echo $nonce; ?>'4. A couple of lines down replace
$.post(darkModeDashboard.ajax_url, data, function(response){with$.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {I wanted to put it line-by-line so you can see the changes.
That make my full code:
<?php
/**
* Plugin Name: Dark Mode for WP Dashboard
* Plugin URI: https://ww.wp.xz.cn/plugins/dark-mode-for-wp-dashboard/
* Description: Enable dark mode for the WordPress dashboard
* Author: Naiche
* Author URI: https://profiles.ww.wp.xz.cn/naiches/
* Text Domain: dark-mode-for-wp-dashboard
* Version: 1.2.4
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ! defined( 'ABSPATH' ) ) {
die();
}
define('DARK_MODE_DASHBOARD_VERSION', '1.2.4'); // Updated version
define('DARK_MODE_DASHBOARD_PLUGIN_PATH', plugin_dir_url(__FILE__));
/**
* Add styles and scripts
*/
function dark_mode_dashboard_add_styles() {
/**
* Check if dark mode is disable for the current user
*/
if(wp_get_current_user()->dark_mode_dashboard != 1) {
$dark_mode_dashboard_style = apply_filters( 'dark_mode_dashboard_css', DARK_MODE_DASHBOARD_PLUGIN_PATH . '/assets/css/dark-mode-dashboard.css' );
wp_register_style( 'dark-mode-dashboard', $dark_mode_dashboard_style, array(), DARK_MODE_DASHBOARD_VERSION );
wp_enqueue_style( 'dark-mode-dashboard');
}
}
add_action( 'admin_enqueue_scripts', 'dark_mode_dashboard_add_styles' );
/**
* Add field to user profile page
*/
add_action( 'show_user_profile', 'dark_mode_dashboard_user_profile_fields' );
add_action( 'edit_user_profile', 'dark_mode_dashboard_user_profile_fields' );
function dark_mode_dashboard_user_profile_fields( $user ) { ?>
<h3><?php esc_html_e("Dark Mode for WP Dashboard", "dark-mode-for-wp-dashboard"); ?></h3>
<table class="form-table">
<tr>
<th><label for="darkmode"><?php esc_html_e("Disable darkmode?", "dark-mode-for-wp-dashboard"); ?></label></th>
<td>
<input type="checkbox" name="dark_mode_dashboard" id="darkmode" value="1" <?php checked($user->dark_mode_dashboard, true, true); ?>>
</td>
</tr>
</table>
<?php }
/**
* Save data from user profile field to database
*/
add_action( 'personal_options_update', 'dark_mode_dashboard_save_user_profile_fields' );
add_action( 'edit_user_profile_update', 'dark_mode_dashboard_save_user_profile_fields' );
function dark_mode_dashboard_save_user_profile_fields( $user_id ) {
if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-user_' . $user_id ) ) {
return;
}
if ( !current_user_can( 'edit_user', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'dark_mode_dashboard', $_POST['dark_mode_dashboard'] );
}
/**
* Admin toolbar add toggle
*/
function dark_mode_dashboard_toolbar_link($wp_admin_bar) {
$args = array(
'id' => 'dark-mode-dashboard',
'title' => 'Dark Mode Toggle',
'href' => '#',
'meta' => array(
'class' => 'dark-mode-dashboard',
'title' => 'Dark Mode Toggle'
)
);
$wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'dark_mode_dashboard_toolbar_link', 999);
/**
* Admin toolbar toggle, trigger the ajax handler function using jQuery
*/
add_action( 'admin_footer', 'dark_mode_dashboard_toolbar_change_js' );
function dark_mode_dashboard_toolbar_change_js() {
$nonce = wp_create_nonce('dark_mode_dashboard_nonce'); ?>
<script type="text/javascript" >
jQuery(document).ready(function($) {
$('#wp-admin-bar-dark-mode-dashboard .ab-item').on('click', function() {
var data = {
'action': 'dark_mode_dashboard_change_user_profile_mode',
'security': '<?php echo $nonce; ?>'
};
$.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
if (response.success) {
document.location.reload(true);
} else {
alert('Failed to change mode');
}
});
});
});
</script>
<style>
#wpadminbar #wp-admin-bar-dark-mode-dashboard .ab-item:before {
content: "\f339";
top: 2px;
}
</style> <?php
}
/**
* Admin toolbar toggle, hook and define ajax handler function
*/
add_action( 'wp_ajax_dark_mode_dashboard_change_user_profile_mode', 'dark_mode_dashboard_change_user_profile_mode' );
function dark_mode_dashboard_change_user_profile_mode() {
// Verify the nonce
check_ajax_referer('dark_mode_dashboard_nonce', 'security');
$user_id = get_current_user_id();
if ( !current_user_can( 'edit_user', $user_id ) ) {
wp_send_json_error('Unauthorized user');
return false;
}
if(get_user_meta($user_id, 'dark_mode_dashboard', true) == 1) {
update_user_meta( $user_id, 'dark_mode_dashboard', '' );
} else {
update_user_meta( $user_id, 'dark_mode_dashboard', 1 );
}
wp_send_json_success();
wp_die(); // this is required to terminate immediately and return a proper response
}Let me know if you hit bugs/issues though, it’s got to be better to patch this than start a whole new plugin. I didn’t need Dark Mode for the front as such, only the back office, which is why I ended up with this plugin.
- This reply was modified 1 year, 7 months ago by Fibro Jedi.
- This reply was modified 1 year, 7 months ago by Fibro Jedi. Reason: Minor formatting changes
Forum: Plugins
In reply to: [Dark Mode for WP Dashboard] Load js file errorValid points, I’ll work on a fix myself that’s better. It’s never safe to assume people have security elsewhere and that’s not an excuse for an insecure plugin. I’ll see what I can do.
Forum: Plugins
In reply to: [Dark Mode for WP Dashboard] Load js file errorI was just about to start a ticket with the same issue. So I’ll reply here instead.
If you just comment out lines 33-37, then the error goes away (including in Dev Console). Then if the dev can push a permanent fix, it doesn’t matter that the change gets overwritten 🙂
/*
wp_enqueue_script('dark-mode-dashboard-js', plugins_url('js/dark-mode-dashboard.js', __FILE__), array('jquery'), DARK_MODE_DASHBOARD_VERSION, true);
wp_localize_script('dark-mode-dashboard-js', 'darkModeDashboard', array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('dark_mode_dashboard_nonce')
));
*/Hope this helps you (and others).
I certainly can, thank you. 🙂
Okay, in my local environment I get a load of react errors on the settings page, e.g.
Warning: Failed prop type: H: prop type
nameis invalid; it must be a function, usually from theprop-typespackage, but receivedundefined.This often happens because of typos such asPropTypes.functioninstead ofPropTypes.func. H vr@https://localhost/wp-content/plugins/media-cleaner/app/index.js:1:119404 v@https://localhost/wp-content/plugins/media-cleaner/app/vendor.js:18:7496 m@https://localhost/wp-content/plugins/media-cleaner/app/vendor.js:18:7753 qt@https://localhost/wp-content/plugins/media-cleaner/app/index.js:1:103624 react.js:199:32React 5
vr https://localhost/wp-content/plugins/media-cleaner/app/index.js:1
React 13
5209 https://localhost/wp-content/plugins/media-cleaner/app/index.js:1
I still got the 404 on the vendor.js (and my local system does not have URL rewriting).
Additionally, when the scan is running debug.log throws these errors (again local system, hence the unusual folder structure)
[26-Apr-2024 11:33:32 UTC] PHP Warning: Cannot modify header information – headers already sent by (output started at /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/domain/wp-content/plugins/media-cleaner/classes/core.php:1296) in /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/domain/wp-includes/rest-api/class-wp-rest-server.php on line 1831
It’s been paused at 40% for a long time now – 15 minutes in on auto-retry.
It has thrown a JSON error, but because the error is being returns in HTML form, so it’s getting HTML rather than the JSON response you’re expecting.e.g. this from console:
XHRPOST https://localhost/wp-json/media-cleaner/v1/extract_references [HTTP/1.1 200 OK 29ms] SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data <br /> <b>Deprecated</b>: explode(): Passing null to parameter #2 ($string) of type string is deprecated in <b>/mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/domain/wp-content/plugins/media-cleaner/classes/parsers/common.php</b> on line <b>165</b><br />Then lastly, there’s this in
debug.log:[26-Apr-2024 11:21:30 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/domain/wp-content/plugins/media-cleaner/classes/core.php on line 1296
This second error is, yes, a deprecated notice so technically not an error, but it may help me find what the error actually is because, I assume a value what supposed to be sent to the preg_replace() function but it didn’t get one for some reason.
Does this help at all?
I’ll try the disabling plugins, but I have so many that’s not a quick job either.
Thanks.- This reply was modified 2 years, 1 month ago by Fibro Jedi.
- This reply was modified 2 years, 1 month ago by Fibro Jedi. Reason: Adding extra error information in the hope it helps