Access Your Desktop Development Environment from Your Mobile Device

It’s possible to get an iPhone, iPad, or Android device to access a local web server running on your development machine. All you need is an HTTP proxy such as Charles Proxy running on your development machine. Once that’s running:

Make sure your device is connected to the same network as your development machine. Go into the Settings -> Wi-Fi menu and find the HTTP proxy settings. On Android, this means a long-press on your Wi-Fi network (Modify Settings, then Show advanced settings). On iOS this means pressing the (i) icon next to your Wi-Fi network.

Switch your proxy over to ‘Manual’ and enter your development environment machine’s network IP address (eg. 192.168.0.4) as the server, and 8888 as the port (Charles’ default port unless you’ve changed it).

Voila. All your HTTP traffic from your device will now route through your host machine (Charles will prompt you to allow access first) and you’ll have access to your local development server. Awesome!

Pro Tip: Are you still editing your hosts file in order to manage the host name mapping for sites on your development environment? Stop it. Just use the Tools -> DNS Spoofing menu in Charles and make life easier for yourself.

WordPress Plugin: User Switching

Latest version: 1.4.0– Released 17/09/2018:

Description

This plugin allows you to quickly swap between user accounts in WordPress at the click of a button. You’ll be instantly logged out and logged in as your desired user. This is handy for test environments where you regularly log out and in between different accounts, or for administrators who need to switch between multiple accounts.

Features

  • Switch user: Instantly switch to any user account from the Users screen.
  • Switch back: Instantly switch back to your originating account.
  • Switch off: Log out of your account but retain the ability to instantly switch back in again.
  • It’s completely secure (see the Security section below).
  • Compatible with WordPress, WordPress Multisite, BuddyPress, and bbPress.

Security

  • Only users with the ability to edit other users can switch user accounts. By default this is only Administrators on single site installations, and Super Admins on Multisite installations.
  • Passwords are not (and cannot be) revealed.
  • Uses the cookie authentication system in WordPress when remembering the account(s) you’ve switched from and when switching back.
  • Implements the nonce security system in WordPress, meaning only those who intend to switch users can switch.
  • Full support for user session validation where appropriate.
  • Full support for administration over SSL (if applicable).

Usage

  1. Visit the Users menu in WordPress and you’ll see a Switch To link in the list of action links for each user.
  2. Click this and you will immediately switch into that user account.
  3. You can switch back to your originating account via the Switch back link on each dashboard screen or in your profile menu in the WordPress toolbar.

See the FAQ for information about the Switch Off feature.

Privacy Statement

User Switching makes use of browser cookies in order to allow users to switch to another account. Its cookies operate using the same mechanism as the authentication cookies in WordPress core, therefore their values contain the user’s user_login field in plain text which should be treated as potentially personally identifiable information. The names of the cookies are:

  • wordpress_user_sw_{COOKIEHASH}
  • wordpress_user_sw_secure_{COOKIEHASH}
  • wordpress_user_sw_olduser_{COOKIEHASH}

User Switching does not send data to any third party, nor does it include any third party resources, nor will it ever do so.

Screenshots

  1. The <em>Switch To</em> link on the Users screen

    The Switch To link on the Users screen

  2. The <em>Switch To</em> link on a user's profile

    The Switch To link on a user's profile

Installation

FAQ

What does “Switch off” mean?

Switching off logs you out of your account but retains your user ID in an authentication cookie so you can switch straight back without having to log in again manually. It’s akin to switching to no user, and being able to switch back.

The Switch Off link can be found in your profile menu in the WordPress toolbar. Once you’ve switched off you’ll see a Switch back link in the footer of your site.

Does this plugin work with WordPress Multisite?

Yes, and you’ll also be able to switch users from the Users screen in Network Admin.

Does this plugin work with BuddyPress?

Yes, and you’ll also be able to switch users from member profile screens and the member listing screen.

Does this plugin work with bbPress?

Yes, and you’ll also be able to switch users from member profile screens.

Does this plugin work if my site is using a two-factor authentication plugin?

Yes, mostly.

One exception I’m aware of is Duo Security. If you’re using this plugin, you should install the User Switching for Duo Security add-on plugin which will prevent the two-factor authentication prompt from appearing when you switch between users.

What capability does a user need in order to switch accounts?

A user needs the edit_users capability in order to switch user accounts. By default only Administrators have this capability, and with Multisite enabled only Super Admins have this capability.

Can the ability to switch accounts be granted to other users or roles?

Yes. The switch_users meta capability can be explicitly granted to a user or a role to allow them to switch users regardless of whether or not they have the edit_users capability. For practical purposes, the user or role will also need the list_users capability so they can access the Users menu in the WordPress admin area.

If you know what you’re doing with user capabilities, this capability can also be denied from a user or role to prevent the ability to switch users, regardless of whether or not they have the edit_users capability.

Can regular admins on Multisite installations switch accounts?

No. This can be enabled though by installing the User Switching for Regular Admins plugin.

Can I switch users directly from the admin toolbar?

Yes, there’s a third party add-on plugin for this: Admin Bar User Switching.

Are any plugin actions called when a user switches account?

Yes. When a user switches to another account, the switch_to_user hook is called:

/**
 * Fires when a user switches to another user account.
 *
 * @since 0.6.0
 * @since 1.4.0 The `$new_token` and `$old_token` parameters were added.
 *
 * @param int    $user_id     The ID of the user being switched to.
 * @param int    $old_user_id The ID of the user being switched from.
 * @param string $new_token   The token of the session of the user being switched to. Can be an empty string
 *                            or a token for a session that may or may not still be valid.
 * @param string $old_token   The token of the session of the user being switched from.
 */
do_action( 'switch_to_user', $user_id, $old_user_id, $new_token, $old_token );

When a user switches back to their originating account, the switch_back_user hook is called:

/**
 * Fires when a user switches back to their originating account.
 *
 * @since 0.6.0
 * @since 1.4.0 The `$new_token` and `$old_token` parameters were added.
 *
 * @param int       $user_id     The ID of the user being switched back to.
 * @param int|false $old_user_id The ID of the user being switched from, or false if the user is switching back
 *                               after having been switched off.
 * @param string    $new_token   The token of the session of the user being switched to. Can be an empty string
 *                               or a token for a session that may or may not still be valid.
 * @param string    $old_token   The token of the session of the user being switched from.
 */

When a user switches off, the switch_off_user hook is called:

/**
 * Fires when a user switches off.
 *
 * @since 0.6.0
 * @since 1.4.0 The `$old_token` parameter was added.
 *
 * @param int    $old_user_id The ID of the user switching off.
 * @param string $old_token   The token of the session of the user switching off.
 */

In addition, User Switching respects the following filters from WordPress core when appropriate:

  • login_redirect when switching to another user.
  • logout_redirect when switching off.
  • send_auth_cookies before setting any cookies.

Download

This plugin requires WordPress version 3.7 or later.

Download the plugin on WordPress.org. Any comments, questions, queries, suggestions, complaints, etc, please leave a comment!

WordPress Plugin: Plugin Info

Latest version: 0.9.0– Released 29/08/2017

Description

This plugin provides a simple way of displaying up-to-date information about specific plugins hosted on the WordPress Plugin Directory in your blog posts and pages. It is intended for plugin authors who want to display details of their own plugins from the WP Plugin Directory on their blog and want those details to remain up to date. It’s also useful for bloggers who may blog about plugins and would like the details in their blog posts to remain up to date.

Er, what?

You want to blog about a particular plugin on your blog and include various details of it in your blog post (eg. the number of downloads or the last updated date). You could manually type this information into your post but this means that in a few days/weeks/months’ time the information will be out of date.

This plugin allows you to use shortcodes in your blog posts and pages which fetches this information right from the WordPress Plugin Directory, therefore ensuring the information always remains up to date.

Here’s an example

This plugin uses shortcodes so it’s ridiculously easy to include any information about a particular plugin in your post or page:

This plugin has been downloaded [plugin downloaded] times!

This will produce the following content in your blog post:

This plugin has been downloaded 1,650 times!

The download count will remain current without you having to touch your blog post again.

Is this plugin for me?

This plugin is only going to be of use to you if:

  1. You are a plugin author and you want a ridiculously easy way to include up to date information about any of your plugins in your blog posts or pages.
  2. You are the author of a blog that highlights plugins of interest and you want to ensure that information in your posts remains up to date.

Installation

  1. Unzip the ZIP file and drop the folder straight into your wp-content/plugins directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Now read the usage guidelines below.

Usage

  1. Write a new blog post or page, or open an existing post or page for editing.
  2. In the ‘Plugin Info’ box on that screen, type the slug of the plugin like this:
    'Plugin Info' plugin screenshot
    (The plugin slug is the last part of the URL of the plugin’s page on wordpress.org.)
  3. Add a shortcode to your blog entry like this: [plugin downloaded] and save the post. (That’s the word ‘plugin’ and not the slug of your plugin by the way).
  4. Take a look at your post and the number of dowloads of the plugin will be displayed.

Which attributes can I display?

Below is a list of all the available shortcodes.

Plain info:

  • [plugin author_name] – The plugin author’s name
  • [plugin author_url] – The URL of the plugin author’s homepage
  • [plugin compatibility] – The compatibility concensus with the most recent version of WordPress (as a %)
  • [plugin compat_with] – The version of WordPress used for the compatibility concensus (ie. the latest WordPress version, eg. “2.8.5”)
  • [plugin download_url] – The URL of the plugin’s ZIP file
  • [plugin donate_url] – The URL of the plugin’s donation page
  • [plugin downloaded] – The all time download count with comma-separated thousands (eg. “12,345”)
  • [plugin homepage_url] – The URL of the plugin’s homepage
  • [plugin link_url] – The URL of the plugin’s page on the WP Plugin Directory
  • [plugin name] – The plugin name
  • [plugin profile_url] – The URL of the author’s profile on WP.org
  • [plugin requires] – The ‘Requires at least’ WP version number
  • [plugin rating] – The plugin’s star rating as a whole number out of 5 (given by visitors to wp.org)
  • [plugin slug] – The plugin slug
  • [plugin tags] – A comma-separated list of the plugin’s tags
  • [plugin tested] – The ‘Tested up to’ WP version number
  • [plugin updated_ago] – How long ago the plugin was last updated (eg. “20 days ago”)
  • [plugin updated] – The date the plugin was last updated, formatted according to your Date Format settings under Settings->General (eg. “20 January 2009”)
  • [plugin version] – The plugin version number

Formatted info (eg. links and ordered lists):

Most shortcodes which display a formatted link can have their default link text overridden by adding a ‘text’ parameter. For example: [plugin homepage text=’Homepage’] will display a link to the plugin homepage with the link text ‘Homepage’.

  • [plugin author] – A formatted link to the plugin author’s homepage with the author’s name as the link text (if the author doesn’t have a homepage this will just display their name)
  • [plugin description] – The full description of the plugin
  • [plugin download] – A formatted link to the plugin’s ZIP file with ‘Download’ as the link text
  • [plugin donate] – A formatted link to the plugin’s donation page with ‘Donate’ as the link text
  • [plugin homepage] – A formatted link to the plugin’s homepage with ‘Visit plugin homepage’ as the link text
  • [plugin link] – A formatted link to the plugin’s page on the WP Plugin Directory with the plugin name as the link text
  • [plugin profile] – A formatted link to the author’s WP.org profile page with the author’s name as the link text
  • [plugin screenshots] – The list of the screenshots attached to the plugin (an <ol> list of <img> tags with descriptions)
  • [plugin changelog] – The list of changelog entries
  • [plugin latest_change] – Just the latest changelog entry
  • [plugin other_notes] – The ‘Other Notes’ section of the plugin

Some less useful raw data:

  • [plugin downloaded_raw] – The all time download count as a raw number (eg. “12345”)
  • [plugin num_ratings] – The number of people who’ve rated the plugin on wp.org
  • [plugin rating_raw] – The plugin’s actual average rating as a score out of 100 (given by visitors to wp.org)
  • [plugin updated_raw] – The date the plugin was last updated, in the format “yyyy-mm-dd”

The geek stuff

The plugin information is collected from wp.org each time you save your post or page. It is updated hourly using WordPress’ cron system and uses the Plugin API available in WordPress 2.7 or later. The plugin data is stored as an associative array in a custom field called ‘plugin-info’, and the plugin slug you enter is saved as a custom field called ‘plugin’. For supergeeks, this means you can also access the plugin data using get_post_meta(), but I’ll let you figure that out for yourself.

Todo list

  • A shortcode for a standard information box which contains all the essential plugin info in a nice format.
  • Possibly allow shortcodes in the title of posts.
  • Clickable shortcoces listed on the post editing screen.
  • A shortcode for a link to the author’s wordpress.org profile page (pending support in the Plugin API).
  • A shortcode for the ‘Other Notes’ section of the plugin (pending support in the Plugin API).
  • A simple UI for adding the plugin slug info to posts so you don’t have to use the Custom Fields directly.
  • Periodically update the data for all of your plugins from wordpress.org.

Download

This plugin requires WordPress version 2.7 or later.

Version 0.9.0 ZIP file from downloads.wordpress.org

Any comments, questions, queries, suggestions, complaints, etc, please leave a comment!

WordPress Plugin: Image Upload HTTP Error Fix

This plugin is extremely oldno longer maintained and should no longer be used.

Description

Fixes the media uploader HTTP Error that some WordPress configurations suffer from.

If your WordPress 2.5 installation shows an HTTP Error when uploading files using the media uploader, then this plugin should fix that problem. Simply upload and activate the plugin, then you’ll be able to upload files with no problem.

Technical details:

The plugin adds a few lines to WordPress’ .htaccess file which deactivates mod_security on the file which handles file uploads.

Installation

  1. Unzip the ZIP file and drop the folder straight into your wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. That’s it! Try uploading a file with the media uploader and the HTTP error should be gone.

Download

ZIP file from downloads.wordpress.org

Any comments, questions, queries, suggestions, complaints, etc, please leave a comment!