How to check if which hook triggered the call to a function?

I found the magic code you need. Use current_filter(). This function will return name of the current filter or action. add_action(‘my_test_hook_1′,’my_test_callback_function’); add_action(‘my_test_hook_2′,’my_test_callback_function’); add_action(‘my_test_hook_3′,’my_test_callback_function’); add_action(‘my_test_hook_4′,’my_test_callback_function’); function my_test_callback_function(){ $called_action_hook = current_filter(); // ***The magic code that will return the last called action echo “This function is called by action: ” . $called_action_hook ; } For reference: https://developer.wordpress.org/reference/functions/current_filter/

Using a private method as an action callback from within a class

It’s not possible to call a private method through an action or filter. When calling add_action or add_filter, WordPress adds the callback to a list of callbacks for that specific action or filter. Then, when do_action or apply_filters is called, WordPress uses call_user_func_array to call the linked functions and methods. As call_user_func_array is not called … Read more

WordPress REST API – Permission Callbacks

The issue was because I wasn’t generating and sending a nonce value with the request. In order to generate a nonce value. Localize the value of a wp_create_nonce(‘wp_rest’) function call. wp_localize_script(‘application’, ‘api’, array( ‘root’ => esc_url_raw(rest_url()), ‘nonce’ => wp_create_nonce(‘wp_rest’) )); This will then be accessible to the window object of the browser which can be … Read more

Image upload callback in new 3.5 media

There is a FileUploaded event being fired in wp-includes/js/plupload/wp-plupload.js. Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback . (function($){ $.extend( wp.Uploader.prototype, { success : function( file_attachment ){ console.log( file_attachment ); } }); })(jQuery);

How to pass arguments from add_settings_field() to the callback function?

Look at the declaration for the function: function add_settings_field( $id, $title, $callback, $page, $section = ‘default’, $args = array() ) { } The last parameter takes your arguments and passes them to the callback function. Example from my plugin Public Contact Data foreach ($this->fields as $type => $desc) { $handle = $this->option_name . “_$type”; $args … Read more

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