Calling a function via a shortcode in javascript

I’m afraid the code you’ve shared is rather wonky and there isn’t just one thing that is backwards. Here are the first few things that came into my mind. add_filter( ‘learn-press/after-content-item-summary/lp_lesson’, ‘psb_comment_listener_func’); When you attach a callback function to a filter with add_filter, the callback should return a value. If the callback isn’t supposed to … Read more

How to automatically flush permalinks?

To automatically flush permalinks every hour, use the following code: Hook the scheduling function to init. Schedule an hourly event if not already scheduled. Hook the scheduled event to a function. Define the function to flush rewrite rules. // Hook the scheduling function add_action( ‘init’, ‘schedule_my_hourly_event’ ); // Schedule the event function schedule_my_hourly_event() { if … Read more

Is there a way to pull remotely generated XML, process it, and display it on a Managed WordPress page?

Step-by-Step Guide to Create a WordPress Plugin for Fetching and Displaying Remote XML Data 1. Create a New Plugin Directory Connect to your WordPress installation via FTP or use the file manager in your hosting control panel. Navigate to wp-content/plugins/. Create a new directory named remote-xml-fetch. 2. Create the Plugin File Inside the remote-xml-fetch directory, … Read more

Does it make sense to sanitize the output of an SVG file?

It’s not completely pointless, but probably smart to sanitize, because of the following situations: What’s the certainty that the SVGs only come from you directly? Can you guarantee that the SVGs won’t be intercepted during upload? Redundancies for keeping your site secure are generally recommended. I don’t know that wp_kses() is the best for sanitizing … Read more

condition for specific pages

The easiest way to do it would be: if ( is_category (‘4’) ) { echo ‘<a class=”btn” href=””>Enquire</a>’; } else { echo ‘<a class=”btn” href=””>Calendly link</a>’; } Obviously you would change “4” to whatever the specific category number is. Also, the WordPress template hierarchy could be helpful if you have add’l changes: https://developer.wordpress.org/themes/basics/template-hierarchy/#category If you … Read more

wp_logout action hook is not firing

In your code, get_current_user_id() will return 0 because this hook fires after the logout has happened, ie, there is no current user ID. If you want the $user_id to be available to your function, you have to pass it in. Note: the $user_id parameter was added in WordPress 5.5.0. If you’re using an older version, … Read more

wp_mail – send emails after 24 hours from users registration

You can’t schedule a future email from wp_mail * but you can use wp_schedule_single_event to run in 24 hours time, and write an action hook handler that calls wp_mail() to send your mail, e.g. something like wp_schedule_single_event( time() + (60*60*24), ‘send_new_user_next_day_email’, args( $userId ) ); function send_new_user_next_day_email( $userId ) { // look up the user … Read more

PHP Warning: Attempt to read property “id” on null

$product->id only works if $product has a value, and sometimes it does not! E.g. on a login page which product would it be? So you need to check if it’s valid/exists/safe with an if check: global $product; if ( ! empty( $product ) ) { // code that uses $product goes here }