Admin settings update updating every time home page is hit?

A much better hook to use would the the update_option_{option_name} dynamic hook, which only runs after your specific option has been updated. So something like: add_action(‘update_option_woocommerce_email_send_time’, ‘send_time’) function update_send_time() { // Add code here to update cron job } The only problem you’ll get here is that scheduling the cron job for a time earlier … Read more

Does hooking into the same action multiple times drain memory?

I guess you mean add_action( ‘pre_get_posts’, ‘private_groups’ ); add_action( ‘pre_get_posts’, ‘search_results’ ); add_action( ‘pre_get_posts’, ‘name_profiles’ ); versus add_action( ‘pre_get_posts’, ‘combined_into_single_callback’ ); You can just check the difference using e.g. memory_get_usage() and timer_stop(). Many good plugins out there to help with that. I would say go with the first one, as they seems to be unrelated … Read more

Clarification on filters and hooks

I am confused because add_filter uses the word add when I feel like it is more on the lines of replace or overwrite (unless I am misunderstanding) You are misunderstanding. Both add_action and add_filter insert function callbacks into a kind of queue. You can add many callbacks to the same hook and they will fire … Read more

add_action(‘wp_ajax_[action name]’, myfunction) problem

In my projects I do it like that PHP function foo() { echo ‘bar’; } add_action(‘wp_ajax_foo’, ‘foo’ ); // executed when logged in add_action(‘wp_ajax_nopriv_foo’, ‘foo’ ); // executed when logged out Javascript data = { action: ‘foo’, avalue: ‘some value’, ‘anothervalue’: ‘another value’ }; jQuery.post(ajaxurl, data, function(response){ alert(response); });

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