Can’t we use strings defined as PHP constants if we want to translate them in a plugin?

I think this is happening because Constants cannot be redefined later. Once they are set, they are fixed. http://php.net/manual/en/language.constants.php I’m not exactly sure how WP language constructs work, but part of me thinks that they are defined, then changed later on the fly when plugins/themes use them. I don’t have a reference for this but … Read more

Is there any reason only 1 (my) IP would be added to this table using $wpdn->insert?

Are you using the same internet connection on multiple devices? Perhaps your mobile is connected to the same wifi network. Visit http://icanhazip.com in your mobile to see its IP. As for browserstack perhaps they aren’t accepting the cookie so their IP doesn’t get recorded. You should record the timestamp as well so you can correlate … Read more

Resize Image without cropping

When you upload an image to WordPress, the following happens: The file is checked and moved into the appropriate location in the uploads folder A post is created of type ‘attachment’ This post is filled with metadata from the uploaded file For each image size defined, a copy of the original image is created according … Read more

What is $tab in `install_plugins_{$tab}` hook?

If you go to the plugin-install.php inside the WordPress dashboard, there may be many tabs: wp-admin/plugin-install.php?tab=featured wp-admin/plugin-install.php?tab=popular wp-admin/plugin-install.php?tab=recommended … Here is the function you referenced: File: wp-admin/plugin-install.php 145: /** 146: * Fires after the plugins list table in each tab of the Install Plugins screen. 147: * 148: * The dynamic portion of the action … Read more

Save user-specific options in WordPress admin

When you register your setting (assuming you’re using the settings API), you can get the current user object with wp_get_current_user. It returns a user object, and the property you’ll want to use in your setting is user_nicename — think of it like the user slug. <?php add_action( ‘admin_init’, ‘wpse27690_register_setting’ ); function wpse27690_register_setting() { $user = … Read more

Remove POST_TYPE from custom post type permalink

As @WebElaine commented on this question I tried the following code which worked for me. First, remove the slug from the permalink function na_remove_slug( $post_link, $post, $leavename ) { if ( ‘services’ != $post->post_type || ‘publish’ != $post->post_status ) { return $post_link; } $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, $post_link ); return … Read more