How Can I Retrieve post ID in plugin file
That’s not working for you because you’ve hooked the dompdf generation to init, which is too early for $post to be populated. Hook to something later like template_redirect instead.
That’s not working for you because you’ve hooked the dompdf generation to init, which is too early for $post to be populated. Hook to something later like template_redirect instead.
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
When calling WP_Query directly, you should use posts_per_page and not numberposts — it is an alias for posts_per_page, but only used with get_posts(). // These work, but I strongly advise against using 999: $fs_ski_resorts = get_posts( array( ‘numberposts’ => 999 ) ); $fs_ski_resorts = get_posts( array( ‘posts_per_page’ => 999 ) ); $the_query = new WP_Query( … Read more
I would approach this in different way. In this original index.php file, keep it simple, like this: if ( ! defined( ‘ABSPATH’ ) ) { exit; } if ( ! class_exists( ‘My_Plugin’ ) ) { require_once __DIR__ . ‘/includes/class-my-plugin.php’; $my_plugin = My_Plugin::get_instance(); } In this new file you create class: class My_Plugin { protected static … Read more
As noted in the documentation, the wp_enqueue_scripts hook (emphasis mine): …is the proper hook to use when enqueuing scripts and styles that are meant to appear on the front end. If you want to enqueue scripts in the admin, you need to use admin_enqueue_scripts.
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
You’ve shared that this is how the member variable is defined: class PropertySearch { private static $listing_details_template_name; This means it is a private static variable and can be accessed using static accessor such as self::$listing_details_template_name or PropertySearch::$listing_details_template_name. Additionally, you’ve declared that it’s a private member variable, so it can only be referred to from within … Read more
To insert or modify text in the Gutenberg Rich Text Editor when a menu choice is selected, you need to interact with the Gutenberg block editor’s rich text APIs. Here’s a general approach to achieve this: Access the Block’s Attributes: The first step is to retrieve the current attributes of the block you’re working with. … Read more
If you run get_current_user_id() too early, like you’re doing, it will just return 0. Wrap your logic containing that function inside a hook, like init, or inside the rt_* callbacks, to avoid that. Note that init fires right after current user setup and before admin_menu (src)
This is because the response from MapBox’s API is a string, which is then passed to wp_json_encode. e.g. echo wp_json_encode( [ ‘fs_tileset_data’ => ‘this is already a JSON string’ ] ); This is the cause of the problem, it’s not 5256 rows of unset data, it’s a double JSON encoded string that’s 5256 characters long, … Read more