Tag Info

New answers tagged

0

I always thought that the memory 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) I guess there also the allowed PHP memory to consider. You could always use the str_repeat idea from this answer to test it: // Check the hook name size limit: $long_hook_name = ...


0

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

I found my solution. The function you hook into delete_post (or probably any other similar hook) executes as many times as needed. Considering delete_post needs to delete the post and all of its revisions, it will always run more than once. In order to avoid having your function execute each time WordPress deletes a record from the database you can use ...


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

If you use Classes for your plugin, then you have to add the action like this: add_action( 'delete_post', array( $this, 'delete' ) ); Happy Coding, Kuchenundkakao


0

After further testing, the problem was found to be caused by another filter, posts_where, which was registered to support searching also in custom fields, and that's why only searching is affected. Originally it generates something like this, so if the OR statement returns true (when one of the custom fields includes foo), that post will appear on the ...


1

The way you do it is fine. Also have a look at how Tom McFarlins WordPress Plugin Boilerplate does it: if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { require_once( plugin_dir_path( __FILE__ ) . 'admin/class-plugin-name-admin.php' ); add_action( 'plugins_loaded', array( 'Plugin_Name_Admin', 'get_instance' ) ); ...


0

pls try below code function remove_user_cookie() { setcookie("woak"); setcookie("woai"); } add_action('wp_logout', 'remove_user_cookie'); apart why you use cookie to storing some value ? suggest you to use session


0

wp_login action is available. The wp_login action hook is triggered when a user logs in by the wp_signon() function. It is the very last action taken in the function, immediately following the wp_set_auth_cookie() call. Check this official documentation.


1

In WordPress 'do_action' is used to add an action hook in a plugin, which then can be used to hook our own function with plugin. Check Codex for more details: Hooks API WordPress To add your own function you will have to do the following: add_action('groups_screen_group_request_membership', 'your_function_callback'); function ...


2

Please note, this should not be the accepted answer, this is only an extension to the answer given by @ungestaltbar, so please, @willow, accept the other answer, and if you deemed my answer useful, simply just give me an upvote :-) The biggest issue that should solve your problem have been discussed in the other answer, but I would like to point out some ...


6

Remember Apple's "Goto Fail"? Similar situation: Your code actually does this, when indentation is corrected: foreach ( $post_types as $post_type ) remove_meta_box('trackbacksdiv', $post_type, 'normal'); remove_meta_box('postcustom', $post_type, 'normal'); remove_meta_box('authordiv', $post_type, 'normal'); remove_meta_box('postexcerpt', ...


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 ...


0

The 'wp_insert_post' action is fired for each post that is inserted and passed the ID of the inserted post to the callback function, so I think your $wpdb query is unnecessary - in fact, I think you're running the "custom function" portion for all published posts, not just the inserted post (which may or may not lead to issues depending on what you're ...


0

This workaround is far from ideal, but it gets the job done. On $mail_sent == true set a post meta. In the __construct function add a callback to the admin_head action that checks whether the post meta has been set. If yes, delete the post meta and add the admin_notices action with the callback to the desired admin notice. class Send_mail { public ...


1

Turns out you have to add some special function sniffing in the configuration of the pot file (from http://www.cssigniter.com/ignite/wordpress-poedit-translation-secrets/): __ _e __ngettext:1,2 _n:1,2 __ngettext_noop:1,2 _n_noop:1,2 _c _nc:4c,1,2 _x:1,2c _nx:4c,1,2 _nx_noop:4c,1,2 _ex:1,2c esc_attr__ esc_attr_e esc_attr_x:1,2c esc_html__ esc_html_e ...


1

I thing you are missing the context. $GLOBALS['hook_suffix'] is available on any action fired after admin_init. Now, if you tried something like add_action( 'admin_footer-'. $GLOBALS['hook_suffix'], 'myfunction' ) outside of any function, you are not going to get anything. But if you do it - add_action('admin_menu', 'do_hook_to_footer') and put the ...



Top 50 recent answers are included