ID Conditional User Contact Methods Not Saving

The problem is that $profileuser is only initialised by user-edit.php but the update is posted to /wp-admin/profile.php and does not get as far as user-edit before running your user_contactmethods handler in the context of the save – i.e. $profileuser is not available when actually running the update. Fortunately there is another global $user_id that is … Read more

View the source code of a 3rd party plugin? [closed]

Here are some ways how we can view the .php source code for plugins: 1) via wp-admin access: Visit the Plugins page and press the Edit link beneath the plugin name. For example if we want to check out the bbPress source: this link will take us to: /wp-admin/plugin-editor.php?file=bbpress/bbpress.php We can also visit the /wp-admin/plugin-editor.php … Read more

resize only height using wp_get_image_editor

You can get the original sizes of the image being uploaded: list( $uploaded_width, $uploaded_height ) = getimagesize( $_FILES[‘u_img’][‘tmp_name’] ); Then you can use those values to size the image as you like: $height = 300; $image = wp_get_image_editor( $_FILES[‘u_img’][‘tmp_name’] ); $image->resize( $uploaded_width, $height, true );

How to get Plugin Slugs?

I am hoping there is a better way You can write your code a bit better, like adding some protection should something fail in your function. One should never take code for granted that it will always work, even if looks like it. Always code with the mindset of that your code will fail. I … Read more

Plugin set default setting value when it activated

Your code will certainly use get_option() to retrieve the values for your options. get_option() accepts a second argument that allows you to specify a default. Use that instead of inserted values into the database unnecessarily. get_option( $option, $default ); If you are concerned about third party code, there is there is the option_{$option} filter that … Read more

How to use load_plugin_textdomain from within a theme

It seems there is no easy way to do this as load_plugin_textdomain() won’t work as expected when called from a child theme. A generic workaround was developed by Marius Vetrici but I’ve found it to be incompatible with Polylang under some circumstances. The most reliable solution I have found is explicitly loading the translation using … Read more