Problem with Class, Filters and Callbacks

Here’s a slightly modified version of your code snippet: add_action( ‘login_head’, [ ‘WPSE_Admin’, ‘plugin_setup’ ] ); class WPSE_Admin { public static function plugin_setup() { add_filter( ‘login_headerurl’, [ ‘WPSE_Admin’, ‘the_logo_url’ ] ); } public function the_logo_url() { return get_bloginfo(‘url’); } } The filter callbacks must be public, not private. The reason for this is that apply_filters()/apply_filters_ref_array() … Read more

Retrieve post in AJAX Callback

It’s possible to capture the $post_id using a combination of wp_get_referer() and url_to_postid() then reset the $post using setup_postdata. That should work easy enough for the front-end. But on the admin side we’ll need to pull the query with parse_url and grab the ID using parse_str. For good measure we should double check if we’re … Read more

Warning: call_user_func() expects parameter 1 to be a valid callback, function

I just found the solution. use this code instead public function register_voguepay_woocommerce_payouts_dashboard_widget(){ add_meta_box( ‘withdraw_to_bank’, ‘Withdraw to Bank’, array($this, ‘voguepay_woocommerce_payouts_dashboard_widget_display’), ‘dashboard’, ‘side’, ‘high’ ); } public function voguepay_woocommerce_payouts_dashboard_widget_display(){ echo “Hello World, I’m a great Dashboard Widget”; }

register_settings callback function erases data

in case of wrong value, the function has to return the original value then try this : function email_validation($data, $option, $original_value) { if (null == $data) { add_settings_error( ‘requiredTextFieldEmpty’, ’empty’, ‘Notification Email cannot be empty’, ‘error’ ); return $original_value; } else { if (!is_email($data)){ add_settings_error( ‘requiredTextFieldEmpty’, ’empty’, ‘Notification Email is not valid email address’, ‘error’ … Read more

Detect device change (desktop, tablet or mobile) in Customizer

Yes, the way to accomplish this would be to send messages from the Customizer controls pane window to the Customizer preview window when the wp.customize.previewedDevice value changes. So you can enqueue a script at the customize_controls_enqueue_scripts action with customize-controls as its script dependency that does: (function ( api ) { api.bind( ‘ready’, function() { function … Read more

Code works, but warning about call_user_func_array() appears

Somewhere in your theme or plugins, you must have a line like this add_action( ‘something’, ‘yoursite_pre_user_query’ ). Find it and remove or fix it. Also, the get_users function has since been updated. Your first parameter must be an array. <ul> <?php $blogusers = get_users( array(‘blog_id’ => 1, ‘orderby’ => ‘nicename’) ); foreach ( $blogusers as … Read more

Where is this function’s callback getting its arguments from?

If you have a look at function do_meta_boxes() in wp-admin/includes/template.php then you’ll see this line close to the end of the function: call_user_func($box[‘callback’], $object, $box); That calls the callback function and provides the two arguments. The $box argument holds all the information about the metabox, like ID, title, callback function. In wp-admin/edit-form-advanced.php, which displays your … Read more

Ajax insert or update data

I’m not entirely sure you want to call exit at the end of that function, since exit terminates all further PHP execution. This is likely the cause of your troubles. http://php.net/manual/en/function.exit.php That said, you can always test for the result of your queries by setting a variable to be the result, and then sending that … Read more

Customiser sections not being displayed with `active_callback`

The is_single template tag takes an optional parameter and therefore does not work for an active callback. Try this instead: function callback_single() { return is_single(); } $wp_customize->add_section(‘section_template_single’ , array( ‘title’ => __(‘Single Links’, $this->text_domain), ‘priority’ => 10, ‘panel’ => ‘panel_templates’, ‘active_callback’ => ‘callback_single’ )); You also have “wp_customise” instead of “wp_customize.” Source: http://ottopress.com/2015/whats-new-with-the-customizer/

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