Tag Info

New answers tagged

0

I think here is something which can help you. Some hooks which work when WordPress core is upgraded. Is there a Wordpress core & plugins update action hook?


0

I use thiss to find the order of hooks. To get the the filters just change add_action to add_filter. function echo_all_hooks() { $not_arr = array('gettext','sanitize_key','gettext_with_context','attribute_escape'); if(!in_array(current_filter(),$not_arr)) echo current_filter()."<br/>"; } add_action('all','echo_all_hooks');


0

There are two more possible ways Use the browser's history API to manipulate the URL displayed at the address bar/ history. Use AJAX Redirection is the best solution for 100% browser support and it is probably the easiest to implement. You don't need to use any hook with that just do the processing without generating output and then redirect back to the ...


0

While there is no hook, there is a small workaround that makes your end-goal possible. You can create a new shortcode that, on a per-instance basis, you always wrap around any other shortcode whose output you want to filter. Usage in a post, etc: Here is some post text. Blah blah... [filter][target_annoying_shortcode size="small" limit="20"][/filter] Here ...


1

I always thought that the memory size was the limit for the string length, but according to the PHP documentation: string can be as large as up to 2GB (2147483647 bytes maximum) There is also the maximum allowed memory size (memory_limit) for the PHP script, to consider. Testing: Do not perform this on a production server: You could always use the ...


1

The $tag is used as a key in an array, so it is converted to either a string or an integer. There is no maximum size for strings, the available memory is the only real restriction. The size of an integer depends on the platform: The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits ...


0

Try this way : add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'nav-menus.php' ); For more info visit this link


0

When working outside the loop, you'll need to get the post ID from the post. For this to work, you have to use the $post global variable and get the post ID from that Try something like this function notify_new_posts() { global $post; $post_id = $post->ID; EDIT I have checked your code at home now, also what I've given in my answer, and checked ...


1

I think the path to the image is wrong, use get_stylesheet_directory_uri() to retrieve the style.css path. If this isn't it let me know and I will take a closer look. I just dug out an example which worked for me in the past: function my_login_logo() { ?> <style type="text/css"> body.login div#login h1 a { background-image: ...


0

I'm in a hurry so don't have time to provide any code, pseudo or otherwise, but you could probably do this in the the_content filter by using a regex to find all links and for each one find the page/post ID using url_to_postid and then replacing as appropriate. Good luck!


0

Another method is to insert this script into ADMIN HEAD to add anything to TinyMce: http://stackoverflow.com/a/24907894/2165415


0

You can use get_the_ID(); function to fetch the Id of the current post For more Please visit here


0

You are slightly confusing $wp_query global variable with WP_Query class/objects. $wp_query is an object instance of WP_Query, but not every WP_Query object has anything to do with $wp_query global. Function version of conditionals, such as is_search(), always act on main global query. You shouldn't use them inside filters, since global state might be one ...


0

Did you try this? function sort_query($query) if ($query->is_tax() && $query->is_main_query()){ echo $query->query_vars['taxonomy']; $query->set( 'orderby', 'post_title' ); $query->set( 'order', 'ASC' ); //do other stuff } } add_action('pre_get_posts', 'sort_query'); Happy Coding, ...


2

The save_post hook is called every time someone calls the function wp_insert_post(). Plugins do that, unfortunately some themes too, and WordPress itself on several places when … someone uses post per email or XML RPC an auto-draft is created the Quick Draft feature on the dashboard is used a navigation menu item is added a revision is created You really ...


0

You could create a static method inside your Cpt class and call that instead with register_deactivation_hook; Then you create your object and send it data as usual.


1

Use a complete function as callback, so you can pass the argument to the method. Example: register_deactivation_hook( __FILE__, function() { $cpt = new Cpt; $cpt->delete_cpt( 'post_type_name' ); } );


-1

You should replace the register_deactivation_hook code line with below code: register_deactivation_hook( __FILE__, array( 'Cpt', 'delete_cpt' ) );


0

Ok i got it. The solution is to use an earlier hook for checking plugins. But then the function get_plugins() is not available so i have to include it for using. The working code: class acf_multisite_sync { function __construct() { add_action('plugins_loaded', array($this, 'acf_sync_init')); } function acf_sync_init() { if ...


1

There are two flaws in the code that I can see. The first one is a bug in this code if($post->post_type != 'product') If no post exists, you get the following error Notice: Trying to get property of non-object... This can be fixed by first checking if a post isset if(isset($post) && $post->post_type != 'product') Secondly, ...


0

save_post is actually called on saving a post through the Quick Edit feature as well. As we find from the source code, the save_post action is called from two functions: wp_publish_post and wp_insert_post, the latter being called both when saving a post through the normal process and when saving a post through the quick edit process! So, the code as you ...


1

query - you will get sql as argument of the callback. add_filter('query', 'some_callback_that_change_query'); function some_callback_that_change_query($sql){ remove_filter('query', 'some_callback_that_change_query'); // your banny wrote add_filter('query', 'some_callback_that_change_query'); return $sql; }


0

As ungestaltbar said, the variable "data" should contain an object, not a string. function show_trend() { var data = { action: "render_admin_charts_page" } jQuery.ajax({ type: "POST", url: "../wp-admin/admin-ajax.php", data: data, dataType: 'json', ...


1

There is no actions/filters to hook to. You need to override standard WC_Email_Customer_New_Account class and implement your own logic. To do it you need to create your own class which will inherit that class and register it. class WPSE8170_Email_Customer_New_Account extends WC_Email_Customer_New_Account { function trigger( $user_id, $user_pass = '', ...



Top 50 recent answers are included