Jay
Forum Replies Created
-
Forum: Hacks
In reply to: Placing in head vs functions.phpI, personally, keep as much separated from the theme as I can, this allows me as a dev to edit what I need to without having to worry about a designer stepping on my toes.
Plus, by putting it in functions.php you allow future devs to override it should they feel the need to do so.
Honestly unless you’re doing a crazy loop of some kind to generate the content in the head, you will not see a huge performance change/gain rather than using it in functions.php
Forum: Hacks
In reply to: Redirect to homepageDo this all the time on projects, use wp_redirect()
https://codex.wordpress.org/Function_Reference/wp_redirectLogging is quite easy, but this function should have most of what you want. https://gist.github.com/JayWood/a3c1614fe643a5cb3dbf
Added some notes regarding logging lines and files, since line and file are file and function specific, you aren’t really able to log those unless you pass them into your function.
Forum: Hacks
In reply to: Multiple User Role Upgrades on Purchase with WooCommerceHave you considered storing and checking against user meta data? Sounds like that may be more fitting.
Forum: Themes and Templates
In reply to: [Cosparell] [ Request ] Github RepositoryI can see that this will never happen. Thank you for your time. Status updated.
@tranny – Can you provide more information in regards to your caching methods? Any sort of auto-minification of javascript going on, cloudflare rocket maybe?
Also, please verify there are not other JavaScript errors on the page via your native console inspector. If there’s a fatal error somewhere up the page when you turn on caching, it may interfere with the JavaScript I coded, not saying that I can’t be at fault as well, but I’ve confirmed this works well with W3TC, but does have problems when W3TC is working with cloudflare’s rocket in the past.
@tangerine – I’ve opened the issue at the github repository and you can view the progress here.
If you open issues on the github repo I get emails instantly. I rarely check this forum. Unless you have the deny option checked they shouldn’t get redirected just by hitting back. I’ll add this to my weekend list to check.
Not sure what it would be but I’ve noticed some 4.3 issues on other plugins as well. Ill definitely take a look this weekend
Forum: Hacks
In reply to: Adding script to backend pagesIf it’s pure javascript, you’ll want to use
admin_enqueue_scripts– https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scriptsIf the ‘script’ you’re referring to is a plugin, well that’s an entirely different method and would more than likely require you asking the dev!
Forum: Hacks
In reply to: How to change the WordPress WHOIS URLLooking for the strings in core, you’ll find that the string occurs in three locations:
- https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/pluggable.php#L1582
- https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/pluggable.php#L1451
- https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-admin/edit-form-comment.php#L96
The first two are from what appears to be the emailing section of the code. The first you will need to use the filter
comment_moderation_textto filter it’s content. The second location you will need to use thecomment_notification_textfilter however.In both of these, you will pretty much need to completely over-write the message, or use some
preg_replacemagic to replace the whois.arin.net instances with the one you desire.The third location however, I can’t see an easy way of filtering it without using the
clean_urlfilter. Which is a filter foresc_url()Forum: Plugins
In reply to: [WordTwit Twitter Plugin] Problems publishing postsNot that this matters for you, and since this is about 1+ months old, I wanted to post here so future viewers are aware as well.
We had the same issue. Initial tweet would go out, but any future tweet would not. After a really long investigation last night it was actually two factors that played into it.
Factor #1
WP_Cron – We were using a system level cron job, following a tutorial from here: https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/However, the issue was with our host now allowing our tasks to fire from crontab under our user. Updating the code set the user as root for the cron fixed the issue for us:
*/5 * * * * root wget http://mysite.com/wp-cron.php &> /dev/nullWith a quick cron testing plugin, I found the cron to be firing at this point.
Factor #2
W3TC – There’s a known issue with W3TC and cron jobs which use object data. WordTwit is one of those issues. See here: https://wordpress.org/support/topic/self-diagnosed-and-fixed-w3-total-cache-bug-in-faulty-object-caching?replies=9Once I disabled database & object cache, our tweets started going out automatically again.
I elected to edit W3TC myself and put in the first patch mentioned by archon in tha thread. Once I did that, and re-enabled object cache, things seem to flow normal again ( with the added system cron fix from factor #1 )
Forum: Hacks
In reply to: How to setup new thumbnail size and regenerate thumbnailsTry this from the official documentation: https://codex.wordpress.org/Function_Reference/add_image_size
add_action( 'after_setup_theme', 'baw_theme_setup' ); function baw_theme_setup() { add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height) add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped) }Notice the action hook is after_setup_theme, not init…
Forum: Hacks
In reply to: How can I apply stripslashes to the comment content before it's saved to DB?This should do what you’re looking for. For future reference though, there’s a filter for comment data before insertion.
https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/comment.php#L2260You can also find all known filters here: https://codex.wordpress.org/Plugin_API/Filter_Reference#Comment.2C_Trackback.2C_and_Ping_Filters
The field is already ran through strip_invalid_text_for_column, which I’d hope does this already, but maybe not.
<?php /** * Strip slashes from comment content * @param array $comment_data Comment data * @return array Comment Data */ function my_comment_filter( $comment_data ) { if ( isset( $comment_data['comment_content'] ) ) { $comment_data['comment_content'] = stripslashes( $comment_data['comment_content'] ); } return $comment_data; } add_filter( 'preprocess_comment', 'my_comment_filter' );Forum: Plugins
In reply to: [W3 Total Cache] issues in w3tc: wp cron and page cacheThis quick patch fixed the WP_Cron issue for me: https://wordpress.org/support/topic/self-diagnosed-and-fixed-w3-total-cache-bug-in-faulty-object-caching
Granted, my situation was object-caching specific. We also had scheduled posts not firing/publishing, but after we added in this patch ( the first code block ) it seems to have fixed it for us. ( thus far )
Short of it, disable object caching unless you absolutely have to have it, or if you don’t mind editing the plugin like I did.
As per your question regarding cache purging on post saving, go to Performance > Page Cache under the Purge Policy, set it up there.
To answer question #2 we’d need to see your code, and that may not really be specific to this plugin, but would be more fitting in the hacks forum: https://wordpress.org/support/forum/hacks