- Repapeating.
- Still functioning.
- Plugin version: 7.2.0, PHP 8.1 and WordPress 6.2.
- In the admin/settings.php file you call an action by passing $this into a hook:
add_action( 'wp_ajax_c4wp_nocaptcha_plugin_notice_ignore', array( $this, 'c4wp_nocaptcha_plugin_notice_ignore' ), 10, 1 );
and in the anr-capthca-class.php file — statically (without passing $this or new instance of class): add_action( 'wp_ajax_c4wp_nocaptcha_plugin_notice_ignore', array( 'C4WP_Settings', 'c4wp_nocaptcha_plugin_notice_ignore' ), 10, 1 );
In PHP, static methods can be called both statically and from within an object context, but not the other way around.
P. S. To reproduce an error you can run your own JS-code in the browser console when admin dashboard with c4wp_nocaptcha_plugin_notice_ignore
action:
let ourButton = jQuery(this);
var nonce = ourButton.attr('data-nonce');
var type = ourButton.attr('data-notice-type');
jQuery.ajax({
? ? type: 'POST',
? ? url: ajaxurl,
? ? async: true,
? ? data: {
? ? ? ? action: 'c4wp_nocaptcha_plugin_notice_ignore',
? ? ? ? nonce: nonce,
? ? ? ? notice_type: type,
? ? },
? ? success: function (result) {
? ? ? ? jQuery(ourButton).closest('.notice').slideUp();
? ? }
});