New answers tagged

0

to see list of functions or actions hooked to a particular action hook you can use the following code. global $wp_filter; echo '<pre>'; var_dump( $wp_filter['wp_head'] ); echo '</pre>';


0

paste this in your theme's functions.php: add_action( 'comment_form_before', 'my_comment_form_before' ); function my_comment_form_before() { ob_start(); } add_action( 'comment_form_after', 'my_comment_form_after' ); function my_comment_form_after() { $html = ob_get_clean(); $html = preg_replace( '/wp-comments-post.php"/', ...


0

The solution that I used was the following: add_action('my_action', array(&$this, 'classFunctionName')); When scheduling I used the following: wp_schedule_event(time(), 'daily', 'my_action'); So the classFunctionName is triggered on a daily basis and it is called from within the plugin class.


1

We can utilize the add_term_relationship action to check if the current post is already assigned as popular. add_term_relationship fires before a term is inserted. I also think that you are using the wrong hook here to send your mail on. added_term_relationship fires quite early before any error checking. You can still encounter a failure after ...


0

This reason, and others (removing a hook for example) is why you should use for hooks only plain functions or static functions. OOP in plugins and themes rarely has anything to do with proper OO. If you use it as a way to have a separate namespace, then just use a namespace.


0

Firest of all you have to make sure that is_page() is right. I think the right syntax is is_page( 'min-konto' ) or is_page($pageid) then the function should be if( is_page( $account_settings_page_id ) && is_user_logged_in() ) { wp_redirect( home_url( '/dashboard/' ) ); exit(); }


0

I hope I understood you correctly as your question is a bit scrambled BACKGROUND Functions, just like your car, are pretty useless objects until they are put to use of some kind. Simply being defined in functions.php or in a plugin makes functions as useful as a car parked in a garage, it is there, but doing nothing useful at that given point in time. ...


1

Try placing $myquery->the_post(); inside your while loop. I think get_the_ID() and get_the_title() depend on that being setup first. Also, wp_reset_query(); should be replaced with wp_reset_postdata();.


0

Use php Anonymous functions: $my_param = 'my theme name'; add_filter('the_content', function ($content) use ($my_param) { //$my_param is available for you now if (is_page()) { $content = $my_param . ':<br>' . $content; } return $content; }, 10, 1);


0

) first thanks a lot to @swisspidy and the suggestion to modify $_POST on the init hook. but after a bit of more thinking and looking at the code i took a different approach. instead of fixing things afterwards, after the form submit, i decided to fix things via jQuery during the form submit and do the necessary checks about the comment input field there. ...


0

Create a function with the needed arguments that returns a function. Pass this function (anonymous function, also known as closure) to the wp hook. Shown here for an admin notice in wordpress backend. public function admin_notice_func( $message = '') { $class = 'error'; $output = sprintf('<div class="%s"><p>%s</p></div>',$class, ...


2

I think you are on the right track, but that last part is messy. You are using the bw_add_markup_class function for two different purposes : to return the classes that you want to add to list the context of the filters that you want to call If I understand well want you are trying to do, you need a function to return the array and then apply your ...


5

Ok so I think I figured it out... Both of these work for the most part as you'd expect by sending http / php headers to the browser. wp_headers is actually a filter inside the send_headers() functions.You can use this to modify the headers before they're sent to the browser with some exception. wp_headers won't be able to do anything if it's a static ...


2

You can use the remove_action() function to unhook a function from an action and then add_action() to hook it elsewhere. Note that when removing an action you must specify the tag (hook name), function, and priority exactly as it was added. Edit: Here are some additional details: You'll have to look at the source of the other plugin to determine how to do ...



Top 50 recent answers are included