Basic function call on init failing

I am going to suggest that what you are doing is overly complex, at least insofar as I understand you. You can determine whether your shortcode has been registered using the Core function shortcode_exists, which returns a boolean. As far as I can tell, using that should provide completely equivalent functionality to your code above.

WordPress ignore init for crawlers

Just added this to functions.php: // Returns TRUE if it’s a crawler function check_is_crawler() { if (isset($_SERVER[‘HTTP_USER_AGENT’]) && preg_match(‘/bot|wget|crawl|google|slurp|spider/i’, $_SERVER[‘HTTP_USER_AGENT’])) { return true; } else { return false; } } And I’m using it on critical functions to lower resource usage. Also, created a robots.txt with the following content: User-agent: * Crawl-delay: 10 It puts … Read more

Add a filter inside an action init

To alter the page ID before the query is run, hook the request filter. If you’re using pretty permalinks, pagename will be set, you can overwrite pagename with another page slug: function wpd_265903_request( $request ) { if( isset( $request[‘pagename’] ) ){ // any page $request[‘pagename’] = ‘some-other-slug’; } return $request; } add_filter(‘request’, ‘wpd_265903_request’); or you … Read more

Plugin init hook fires repeatedly

This happens because you are not excluding ajax requests. Check this example from the WordPress Codex for the admin_init hook which is also valid for the init hook and see how AJAX requests are exluded in the if using the DOING_AJAX constant: /** * Restrict access to the administration screens. * * Only administrators will … Read more

add_action in a custom plugin

It errors because class method is not a function. It’s not uniquely identified by its name alone. You need to provide instance of the object (or name of the class for static methods). In your context it would be: add_action( ‘init’, [ $this, ‘newsletterSuscriber’ ] );

Form Shortcode not saving data to WP database

Ok, for some reason it’s now working. Instead of hooking into ‘init’ I’ve used ‘the_post’ and the form shortcode does it’s job. I no longer have an issue with publishing a new post or the data not saving. Also, no “Cannot modify header information – headers already sent” error. The function function el_process_form(){ if( $_SERVER[‘REQUEST_METHOD’] … Read more

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