Snippet to Log “Payment Failed” in Syslog [closed]

You can use the woocommerce_order_status_changed action to find a failed order transition, and syslog to write your log, assuming the function is not disabled in your PHP configuration. add_action( ‘woocommerce_order_status_changed’, function ( $order_id, $old_status, $new_status ) { if ( ‘failed’ !== $new_status ) { return; } $order = wc_get_order( $order_id ); if ( ! $order … Read more

Select posts using @wordpress/data with query based on custom field always returns all records

It appears that REST API doesn’t support all the meta_query parameters that WP_Query does. Only the basic meta queries with some comparison operators are supported. Therefore we need to make one of workarounds to get what we want: Add some REST API Filter to our theme/plugin add_filter(‘rest_{post_type}_query’, function($args, $request) { $params = $request->get_params(); if(isset($params[‘meta_compare’])) { … Read more

Can I Log Logged in WordPress users in Apache without a WordPress plugin?

Although a little clunky I’ve found a passable solution to this problem using mod_security. To implement this, enable modsecurity in Apache (presumably with a2enmod security). Then edit the config file. On my Ubuntu based systems this is at /etc/modsecurity/modsecurity.conf and as follows: Ensure SecRequestBodyAccess is On (and I assume SecRuleEngine to DetectionOnly). You may also … Read more

Multiple domains for one wordpress instance

There is no single correct way to achieve this. The work to do this lies outside of WordPress itself. The general process requires the following steps. Point the new domains/subdomains to your WordPress site. I’d recommend using A records as CNAMES have gotchas for new players. Never use a CNAME on example.com (but you can … Read more

Is it necessary to use escape functions on everything or is it only necessary if you’re taking input from a 3rd party? (End Users, APIs, Etc.)

that wordpress.org page was probably written by someone that do not get security. Escaping is done to make sure that your output, when is part of an HTML page, is displayed to the user as you intend it to be which means converting thing like “<” to the appropriate HTML entity. Yes, if you do … Read more

JQuery is not a function error in console

I am using the CookieYes Consent Management plugin. When cookies were accepted, jQuery loaded otherwise I got the error. By accepting cookies in various categories, I was able to narrow down which cookie loaded jQuery. In my case it was a Mailchimp plugin. I made this a ‘necessary’ cookie and now all is well! Thanks … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)