Prefill the textarea in comment_form

I was answered in the WordPress Forums. The solution is to pass the entire HTML for the comment_field, like this: ‘comment_field’ => ‘<textarea id=”comment” name=”comment” cols=”45″ rows=”5″ maxlength=”65525″ required=””>’. __(‘Prewritten comment’,’textdomain’).'</textarea>’,

Is it smart to require_once wp-admin/includes/plugin.php when you need only one function from it

So, the answer isn’t as straightforward as I initially hoped. A quick test using memory_get_usage() on a local environment with only Twenty Sixteen enabled as the theme gives the following results: Memory usage before requiring plugin.php: 8496336 Memory usage after requiring plugin.php: 8583912 So, loading plugin.php takes up 87.576 bytes, or roughly 85KB. If you … Read more

Virus injected to my wordpress site

Although hacked sites are not within scope here (and your question will be closed because of that policy), there are questions here about hacked sites that have answers that will be helpful (I’ve written a couple of them). Cleanup is time-consuming, but possible. Generally – Change passwords on everything, including your admin-level user and hosting … Read more

WooCommerce, change “Add to Cart” to “Link to Product”, only for specific categories

You can just add another check within that filter – get the category of the product the filter is currently active on and compare it with the category you want to target. add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘replace_loop_add_to_cart_button’, 10, 2 ); function replace_loop_add_to_cart_button( $button, $product ) { if( $product->is_type( ‘variable’ ) ) return $button; // array of slugs … Read more

How to add embed image in comments?

You can do that by using the comment_text filter. It runs for each comment, so with some regex you can find all links in the comment and loop through them. You make one more check to make sure the link has an image extension (jpg, jpeg, png, etc). If it does, we can embed it … Read more

WPDB query suddenly not working

You should only interact with the DB via WP, not directly. It’s not a big deal in your case because you just want to see a value, but you’ll be more aligned with the best practices if you go in trying to solve a problem with $wpdb as a last resort. In your case, you … Read more