aut0poietic
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: SVGs in Nested Blocks Causes 503 Error After Update to 5.8Been about 24 hours now and the sites work if I remove the content (not a long-term solution). But I can trigger the error pretty consitently and my users trigger it anytime they use a block with SVG content (think custom logo blocks, etc.).
I’m opening an additional Trac ticket on this. Would really appreciate any thoughts you have, even if they’re just “man, sucks to be you” ??
Still at a complete loss. I suspect my servers are contributing to the issue, but an auto-update shouldn’t be triggering 503 error on successful installs.
Appreciate any help. I’ll try to be patient and hold off updating my other sites.
Forum: Fixing WordPress
In reply to: SVGs in Nested Blocks Causes 503 Error After Update to 5.8Updating, because sharing is caring:
This is 100% an issue with a core
the_content
filter. Adding the following code resolves the error, but breaks dynamic blocks:add_action('init', function(){ remove_filter( 'the_content', 'do_blocks', 9 ); });
For reference, I used https://github.com/WordPress/WordPress/blob/846529de97790b9b866d4dd77a2940167374a52b/wp-includes/default-filters.php#L172-L179 as a guide to remove the filters and re-add until things were either broken/worked.
Has
do_blocks
(https://github.com/WordPress/WordPress/blob/381a720ea96c86b16541951fb89bbb9787712f6b/wp-includes/blocks.php#L897-L913) been updated in some way that would chew memory? I’m going to guess it’sparse_blocks(...)
that’s at issue here.Forum: Plugins
In reply to: [Akismet Anti-spam: Spam Protection] File change warningGot the same alert:
wp-content/plugins/akismet/changelog.txt
was edited to remove entries from 4.1 to 4.1.5 were removed.It sort of looks like the changelog.txt from version 4.0.8 was restored somehow. File edit date shows it was edited in June, same month 4.0.8 was released.
Be nice to know how this occurred and if it’s associated with an exploit.
Forum: Hacks
In reply to: SVG with Gradients/Filters Disappear in CustomizerOpen Issue in Trac:
https://core.trac.www.ads-software.com/ticket/35824Forum: Hacks
In reply to: How to optimize this function?There’s a pretty nice example on stack exchange here: https://wordpress.stackexchange.com/questions/66963/how-to-display-network-post-count
That post is doing what you are ( with a few details changed ) and appears to address a memory leak issue with switch_to_blog(). However, querying multiple blogs is an expensive operation by nature. Another part of the solution would be to store the information in a transient — essentially a variable that expires after a set amount of time or when flagged as invalid.
Your function would need to 1) check to see if there was a transient 2) if their is,output the data from there 3) if not, rebuild the transient and output the new data.
In addition, you’d have to add an action in save_post for all your blogs that purges the transient any time a post is published.
More information to get you started:
https://codex.www.ads-software.com/Plugin_API/Action_Reference/save_post
https://codex.www.ads-software.com/Transients_APIForum: Hacks
In reply to: Storing data from add_action and retreiving from different add_actionNot sure I can give good advice without knowing more of what you’re doing, but to answer the question you’ve asked:
If this is throw-away information and you don’t plan on using it again ( which your example hints at ) a global might be acceptable, so long as you’re storing a small bit of information and you properly namespace your variable. Using Your example:
add_action ('trigger_1','function_1'); function function_1($user_id){ global $mypluginname_custom_meta ; $mypluginname_custom_meta = get_user_meta( $user_id, 'custom_meta', 'true' ); } /// User meta is changed before second action triggers /// add_action ('trigger_2','function_2'); function function_2($user_id){ global $mypluginname_custom_meta; $var1 = get_user_meta( $user_id, 'custom_meta', 'true' ); if ($var1 != $mypluginname_custom_meta) { wp_mail( '[email protected]', 'subject', 'meta changed' ); } }
I hesitate to say “this is the way to go” only because is has a weird code-smell. That usually hints at an architectural issue. Just thinking it through, if your user_meta can change between 2 actions, that means there are 1 or more additional action hooks that can possibly alter the value. What are you doing in those actions to alter the value and why don’t you know about it?
Would it be better to create non-primitive meta value ( such as an array or object ) that maintains state, change history or has a simple modified flag or timestamp?
Another option might be to have two different user_meta keys and compare them in function_2.
Hope this was of some help.
Forum: Hacks
In reply to: Custom taxonomies: getingt rid of link on display??Sorry my post was confusing — that’s what I get for trying to do too many things at once, with no way to test code ??
I’ll stick with what I’ve said: If what you’re doing works, stick with it. No reason to waste time you could be playing Reach ;-D
However, if you want to see what I was trying to explain, here’s some working code and explanation.
<?php $terms = get_the_terms( $post->ID, 'technology' ) ; ?>
get_the_terms returns an array of objects that look a something like the output below internally:
Array ( [21] => stdClass Object ( [term_id] => 21 [name] => windows xp [slug] => windows-xp [term_group] => 0 [term_taxonomy_id] => 21 [taxonomy] => operating_system [description] => [parent] => 0 [count] => 1 [object_id] => 116 ) ... )
That’s the difference between
the_terms
andget_the_terms
“get” returns the data instead of echoing. This is a pretty common thing in WP, adding “get_” to a function returns what you were after, rather than echoing it — but not always; I wish it were universal.Anyway, so you’ll have to do the work on this one and print out what you need:
<dt>Taxonomy Name:</dt> <?php $terms = get_the_terms( $post->ID, 'technology' ) ; $term_list = array_pop($terms)->name ; foreach( $terms as $os ) { $term_list .= ", " . $os->name ; } echo $term_list ; ?>
That (tested on 3.01, finally) should do what you want and give you the flexibility to output whatever you want. But as I said, if the code you had above does what you want, there’s no real reason to redo it.
Forum: Hacks
In reply to: wp_delete_post / wp_trash_postrjmastey,
Good to know I’m on the right track and not just missing the obvious. Once I get this plugin cleaned up I’ll see if I can create the codex entry, and possibly submit this as a bug in trax.
Thanks for the info.
Forum: Hacks
In reply to: Custom taxonomies: getingt rid of link on display??If what you are doing works for you, good deal. As for the code you posted, you edited the $args parameter incorrectly:
<?php
$terms = get_the_terms( $post->ID, 'operating_system', "fields=names") ;
?>
The
"fields=names"
is required to cause the get_the_terms method to return only the names. The details of how this works are here: https://codex.www.ads-software.com/Function_Reference/get_termsAlso, what does the extra , ‘, ‘, ” at the end of my string mean? This was code taken from the wp codex and on the forum here.
Usage
<?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ; ?>https://codex.www.ads-software.com/Function_Reference/get_the_term_list
Forum: Hacks
In reply to: Custom taxonomies: getingt rid of link on display??Minor error:
The format of get_the_terms follows the same format as get_terms, with an additional parameter for the post id, so the call above should be:
$terms = get_the_terms( $post->ID, 'tagonomy_name', "fields=names") ;
check the codex page for get_terms for available parameters to get_the_terms: https://codex.www.ads-software.com/Function_Reference/get_terms
Forum: Hacks
In reply to: Custom taxonomies: getingt rid of link on display??There’s probably a better way, but since we’re in the ‘Hacks’ Forum, try this hack out:
$terms = get_the_terms( $post->ID, 'taxonomy_name', array( 'fields' => 'names' ) ) ;
You’ll have to check the output of get_the_terms — it is an array, but I’m not sure if that’ll produce a list of links, or a list of objects with ‘name’ properties set ( you know
$term[0]->name
). Sorry, I don’t have the ability to test this at the moment.If it produces a list of links in your foreach loop, call strip_tags on the item to remove the a tag.
Hope this at least points you in the right direction.
Forum: Themes and Templates
In reply to: eval(base64_decode Code Problem!You just need to run the code through an online decoder to see what it is doing. For instance, the first line in your header:
function theme_footer_t() { if (!(function_exists("check_theme_footer") && function_exists("check_theme_header"))) { theme_usage_message(); die; } } theme_footer_t();
and the footer:
function functions_file_exists() { if (!file_exists(dirname(__file__) . "/functions.php") || !function_exists("theme_usage_message") ) { echo ("<p style=\"padding:10px; margin: 10px; text-align:center; border: 2px dashed Red; font-family:arial; font-weight:bold; background: #fff; color: #000;\">This theme is released free for use under creative commons licence. All links in the footer should remain intact. These links are all family friendly and will not hurt your site in any way. This great theme is brought to you for free by these supporters.</p>"); die; } } functions_file_exists();
So in this case, it’s just code included to require that you use their footer. Personally, this kinda thing ticks me off like no other, and I refuse to use a theme that does it. </rant>
If you need to decode more base64 yourself, the decoder I used is here: https://www.opinionatedgeek.com/dotnet/tools/base64decode/
Forum: Hacks
In reply to: Need help with insert_post and custom fieldsIf you’re wanting to add additional fields to a post you can use
add_post_meta()
(https://codex.www.ads-software.com/Function_Reference/add_post_meta).It looks like it is a part of wp-includes/post.php so you should have access to the method if you have access to wp_insert_post.
Hope that hit what you were looking for.
Forum: Networking WordPress
In reply to: What is ID of the root ( / ) Site?Thanks Andrea! Like I said, I suspected as much, but nice to have someone more knowledgeable confirm the fact. Thanks again.