Sharon’s PHPMailer

Easily manage PHPMAiler settings within WordPress with this plugin.

the code below will help you set up PHPMailer from within your WordPress dashboard. You’ll need to have a preexisting email address for this to work properly.

This code creates an admin page under Settings where you can specify the email address to use for sending emails from WordPress. You can specify who the messages come from, set CC and BCC options, and check errors (a “mail.log” file is created within the plugin directory should any errors occur).

A sendmail.php file is included. Use this file to test your PHPMailer settings before activating this plugin.


6 Stages of Debugging

  1. That can’t happen.
  2. That doesn’t happen on my machine.
  3. That shouldn’t happen.
  4. Why does that happen?
  5. Oh, I see.
  6. How did that ever work?

Shortcode Emojis

Implement emojis into your posts and pages. Using CSS, transparent PNGs seamlessly integrate with your favorite theme and color scheme.

This plugin shows emojis by using shortcodes. It will not override the default Smileys.

How To Use:

  1. After activating this plugin, an emoji icon will appear next to your “Add Media” button above the editor window.
  2. Click on that button to display the dropdown list of available emojis.
  3. Click “Add Shortcode”, and the shortcode will automatically be added to your editor window.

Alternatively, you can type in your shortcode by hand using this format:
[sce emoji="happy" /]

View on the WordPress Plugins Repository

== Installation ==

1. Download and extract the file, then upload the plugin files to the ‘/wp-content/plugins/’ directory. Or, search “Shortcode Emojis” in the WordPress plugins screen and click install.
2. Activate the plugin in your Plugins admin panel.
3. Enjoy!


== ChangeLog ==

– Version 1.2:
+ Added holiday emojis.
+ Added Doctor Strange emojis.

– Version 1.1:
+ Added missing emojis.

– Version 1.0:
+ First release.


== Upgrade Notice ==

### 1.2 ###
Added Doctor Strange and holiday emojis.

### 1.1 ###
Emojis found alphabetically after “powerpoint” were missing. In this version I regenerated the emojis and added them back into the proper directory.





Featured Image Replacement

Use this snippet of code to display an image when the featured image isn't set. Works with images inserted in posts (and galleries!).

It took me a few days, but  I finally got this working! I have a photo gallery theme I’m working on, and I’d like it to always display a featured image in the loop. Here were my requirements:

  1. If the featured image isn’t set, look for images within the post and display the first one.
  2. If an image isn’t in the post but there’s a gallery, display the first image from the gallery.
  3. If there is no image and is no gallery, display a default image.

Setting a default image when the featured image is blank (3) was pretty easy.  Looking for an image within the post (1) was fairly doable. But, finding an image within a gallery (2) was giving me problems.

What happens when WordPress has you drop a gallery in a post is shortcode processing. That means the code looks something like this (with brackets instead of curly braces)…

{gallery link="file" ids="1,2,3,4,5,6"}

…until you visit the page it sits on. Then, WordPress processes that line to show your gallery based on the IDs of the images added.

So, with the ability to call an image from its ID, I was able to implement wp_get_attachment_image_src to return the image I needed from the gallery!

Here’s what you do:

Add a Function to your functions.php File

Open up your functions.php file and drop this bit of code into it (change
sharons_new_image to whatever you prefer):

function sharons_new_image() {
	global $post;
	$galID = str_replace('ids="', '', strstr(strstr($post->post_content, 'ids="'), ',', true));

	$first_img = strstr($post->post_content, '<img');
	$first_gal = wp_get_attachment_image_src( $galID, 'full' );
	$header_image = get_header_image();
	$loop_default_image = home_url() . '/wp-admin/images/w-logo-blue.png';

	if(!empty($first_img)) {
		$returnimage = $first_img;
	} else if(!empty($first_gal)) {
		$returnimage = $first_gal[0];
	} else if(!empty($header_image)) {
		$returnimage = $header_image;
	} else {
		$returnimage = $wp_logo_image;
	return $returnimage;

looks in your post ($post->post_content) for the first instance of img=".

$galID is looking for the first number after ids=" (the rest of that code is cutting out any other text still remaining).

$first_gal is looking for the image based on the ID found in $galID.

get_header_image() is the WordPress default code for calling the header image (set within the Theme Customize window).

If you don’t have a header image set, I’ve set the WordPress logo as the default at $loop_default_image. This image will be called if no other image is found. If you want to set it to a specific image, you can replace $loop_default_image = home_url() . '/wp-admin/images/w-logo-blue.png'; with something like this:

$loop_default_image = get_template_directory_uri() . '/images/loopimage.jpg';

This code above looks in your theme’s “images” folder for an image called “loopimage.jpg”. Customize this link as needed.

Call the Function in your index.php File

Next, we need to tell our theme’s index.php page to use this function. Most themes may have the_post_thumbnail() somewhere; if yours doesn’t, you can add it manually (usually above the the_excerpt() or the_content() line).

Change your the_post_thumbnail() to look like this instead:

<?php if (has_post_thumbnail()) {
} else {
	echo '<img src="' . sharons_new_image() . '" />';
} ?>

That’s it! If you have questions or problems, leave them in the comments. Thanks!

How to Extract Subtitles

lines with $ are commands

### install mkvtoolnix:
$ brew install mkvtoolnix

### list content of the mkv-file:
$ mkvmerge -i mymoviefile.mkv

### what will give you:
File 'mymoviefile.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_DTS)
Track ID 3: subtitles (S_TEXT/UTF8)
Track ID 4: subtitles (S_TEXT/UTF8)
Chapters: 22 entries

### so the subtitle-tracks are number 3 and 4.
### extract all subtitle-tracks into a seperate srt-file / lang
### note: if this is an extraction from a BluRay, you may need to change the extension from “.srt” to “.sup”.

$ mkvextract tracks mymoviefile.mkv

Improving WordPress Media Library (#1)

This post is the first in what I hope will be many describing how I enhanced my media library and turned a WordPress install into a powerful photo organizing platform.

I love WordPress. It’s an amazingly powerful open-source CMS and it’s been my go-to for years. The one drawback I keep running into is how best to utilize its media library.

I have tons of photos and would love to organize them, but most plugins seem to have more than I need. I would rather improve my media library rather than install something that saves photos in a completely separate area.

Hi there. I absolutely adore this plugin called Media Library Assistant. It makes organizing photos so much easier than I ever thought possible. A big thank-you to David Lingren for creating such a genius piece of code!

Having said that, I wanted to assist in an issue I’ve tried to tackle quite a few times:

Convert the Upload Date to match the Photo’s Creation Date

Tonight, with the help of this plugin, I was successful! Please note, anyone who tries this, it is not for the faint of heart, as it required me to go into my database via PHPMyAdmin and make changes with a SQL statement (a harmless statement, but you have been warned). I highly recommend backing up your database just in case before trying this. 🙂

OK, here goes. I’ve wanted the upload date to match the photo date ever since I uploaded my first photo to WordPress when it was already past the date it was taken (which is forever). With the help of MLA, I was able to map the creation date, then update the upload date to match the newly saved creation date. Here’s how I did it:

Under Settings > Media Library Assistant, I went to the IPTC/EXIF tab and created a new mapping. These settings belong under Add a new Field and Mapping Rule:

  • I entered a Field Title of “Date Taken”.
  • The EXIF/Template Value was set to template: DateTimeOriginal
  • Priority was set to “EXIF”.
  • Existing Text was set to “Replace” (this is a preference, not a requirement).

I then clicked “Add Rule” and then “Map All Attachments, Custom Fields Now” button, and my dates were entered! Below is what my settings look like for this item:


Next, I had the problem of getting that date into the upload date field. Here’s where the tricky stuff starts to happen.

The post information is inside the “wp_posts” table, while the data for each post is inside the “wp_postmeta” table. So, the date is saved in one and displayed from the other. Here’s the SQL statement I wrote:

UPDATE `wp_posts`, `wp_postmeta`
SET `wp_posts`.`post_date` = DATE_FORMAT(STR_TO_DATE(`wp_postmeta`.`meta_value`, "%Y:%m:%d %H:%i:%s"), "%Y:%m:%d %H:%i:%s"),
`wp_posts`.`post_date_gmt` = CONVERT_TZ(DATE_FORMAT(STR_TO_DATE(`wp_postmeta`.`meta_value`, "%Y:%m:%d %H:%i:%s"), "%Y:%m:%d %H:%i:%s"),'+00:00','+04:00')
WHERE `wp_posts`.`ID` = `wp_postmeta`.`post_id`
AND `wp_posts`.`post_type` = 'attachment'
AND `wp_postmeta`.`meta_key` = 'Date Taken';

Now, there is a lot going on here. First, we’re telling the database to find the new Field Title (that’s the “meta_key” in the wp_postmeta table), take that date, and then update “post_date” in the wp_posts table to match. We’re also telling it to convert the format from YY:MM:DD hh:mm:ss to YY-MM-DD hh:mm:ss so that WordPress can have the correct date format. Then, since I’m in the EST time zone, change the “post_date_gmt” field to add four hours (see the +04:00 bit). Lastly I tell it to only do this with items that are attachments (this keeps it from accidentally updating a post). It worked wonderfully!

My goal is to try and get as much of this into MLA as possible. That way, I don’t have to keep updating the tables manually.

My only wish now is that I could do something similar to what Media Library Plus has available, which is allowing someone to upload images into any directory within wp_content/uploads. I ask for this, because I’d like my images from September 2015 to show up in the 2015/09 directory without me having to do it manually. If only there were a bit of code for that as well…. Maybe I’ll have a part 2 covering that bit 🙂

How to *Completely* Uninstall Java from your Mac

I found instructions on Oracle's Java web site. However, they weren't complete. This post lists all the steps needed to completely remove Java from your Mac.

This link gives details on how to uninstall Java. The first bit is definitely necessary (snippet added below so you don’t have to visit another link):

Uninstall Oracle Java using the Terminal

Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo.

Remove one directory and one file (a symlink), as follows:

  1. Click on the Finder icon located in your dock
  2. Click on the Utilities folder
  3. Double-click on the Terminal icon
  4. In the Terminal window Copy and Paste the command below:
    sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpane

Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.

While these steps definitely help, they don’t completely uninstall Java, especially if you have multiple versions on your system that you didn’t know about (this was my predicament).

Going back to Terminal, type the following:

cd /Library/Java/JavaVirtualMachines

The first line is a “change directory” command. The next line is a “list” files and directories command. What you might see is this:

macmini~ sharon$ cd /Library/Java/JavaVirtualMachines
macmini:JavaVirtualMachines sharon$ ls

1.6.0.jdk is the old version that’s still sitting on my computer after going through Java/Oracle’s instructions for removing Java. This last bit is fairly simple. In the Terminal, type this:

sudo rm -rf 1.6.0.jdk

If you don’t have the same version I do, you can type sudo rm -rf, then type a space and the first number of the version you see sitting in that directory. Then, hit the tab button immediately after, and the full name of the item should automatically populate. Then, hit Enter. If you haven’t entered your admin password in a while, you may be asked to enter it again here.

I recommend a restart after you’ve uninstalled.

If you have any questions about this process, feel free to post your comments below. Thanks!

Keep WordPress Up-To-Date

If you have a WordPress install, check that you keep your plugins, themes, and version up-to-date. This post will describe how to check the status of these items and how to update them.

When you log in to the admin area of your site (http://yoursitelink/wp-admin), you might see one of these:


You can also check the admin menu bar for additional updates (the number indicates total updates, including plugins, themes, and version):


Go ahead and click “Please update now”, or you can click on the number in your menu bar.

I recommend updating items in this order:

  1. Themes
  2. Plugins
  3. WordPress version

After updating the WordPress version, you may see more numbers pop up. This indicates that a plugin or theme you have installed has an additional update to bring it into compatibility with the new WordPress version you now have.

For the WordPress version, you will see this window:


Click “Update Now”. You should then see this window:


Wait a moment, and the screen will refresh on its own. If it does not, click the “here” at the bottom of your screen. You should now see this (or something close:)


The next section will only apply if you have more than one site within one WordPress install).

If you have a WordPress Multi-Site install, you may be asked to upgrade your network. This process brings all your sites into compatibility with the new WordPress version. Go ahead and click the “Upgrade Network” link on the next page:


WordPress will automatically cycle through all your sites. If it cannot, you will be given a “next” button to click at the bottom of each page.

Once you have completed the Network upgrade, you are done!

Be sure to check on your WordPress install at least once a month. WordPress updates are almost always security updates, so keeping your install, plugins, and themes current will improve the security of your site.

Save your iPhone Photos and Videos

Occasionally, I am asked to help with getting an iPhone to do “something” with a PC running Windows XP. This can be tricky, since (1) Apple’s iCloud Control Panel doesn’t officially run on XP, and (2) recently Microsoft stopped supporting XP. In answer to that, here’s my first in a series of steps on how to get your iPhone to communicate well with your aging PC.

Natively it is not possible to automatically save photos to your Windows XP machine, even if you’ve installed the iCloud Control panel as described here. But, there is a simple way to work around that: cloud services. Using something like OneDrive, Dropbox, Google Drive, or Box will allow you to save files in one location and access them anywhere. In the case of Dropbox, there is an especially neat feature in which Dropbox will automatically save your photos to your Dropbox account, without you needing to do much more than the initial setup! Here’s how:

  1. First, you’ll need an account. Go to and click “Sign up.” Follow the steps to verify your information and your email address; you may be sent a confirmation, so be sure to check your email to activate your account.
  2. Next, install Dropbox on your computer. You’ll need to click the “Download” button in the top-right corner of that same page at You’ll then download a file to your Downloads folder entitled, “DropboxInstaller.exe”. Follow the instructions, including logging in using the Dropbox account you created in step 1. When you’ve done this successfully, you’ll see a folder titled “Dropbox” insider your “My Documents” folder. It will look something like this:
  3. Make sure you also have Dropbox installed on your iPhone. You can do that by visiting the App Store on your iPhone:
    Download Dropbox
  4. Open Dropbox on your phone, and you’ll see a window asking you to sign in:
    Sign in to Dropbox When you take photos, Dropbox keeps them safe for you. Signing in
  5. After signing in, you’ll see a window describing the feature you’re after.
    Each photo and video will be automatically uploaded once to your Camera Uploads folder.
  6. Click “Enable Camera Upload,” and you’ll be asked to give Dropbox permission to do access your photos.
    Dropbox would like to Access Your Photos
  7. In case you already had Dropbox on your iPhone and missed this feature, you can get to it by clicking “Settings” in the bottom-right corner and changing “Camera Upload” from “Off” to “On”.
    Camera Upload
  8. Additionally, I recommend turning on “Background Uploading”. This will make this feature further automatic. Whenever you change locations, Dropbox will check if you’ve taken any photos or videos and will upload them automatically. Touch the slider next to this option, and click “Enable” found in the top-right corner of the following screen.
    Background Uploading Dropbox can periodically start Camera Upload when your location changes. Dropbox needs Location Access to upload in the background.
  9. At this point, you’ll see a message, saying “Dropbox needs Location Access to upload in the background.” To verify that Dropbox has Location Access, you can check this under your Privacy panel inside your Settings. Open “Settings”, scroll down to “Privacy” and tap it, then tap on “Location Services”. Screen shots are included below.
    Settings Settings - Privacy Settings - Privacy - Location Services

That’s it! If you have questions, feel free to comment below.

Web Hosting on OS X

Included in this post is information on those errors and some general suggestions on setting up your own web hosting on your OS X machine.

Setting up your own WordPress installation can be fun and easy, and you can even set it up on your own home computer! When doing so, there are sometimes some very strange errors or screens you’ll start to see that you didn’t see before… for instance, you’ll be asked for FTP information when uploading a plugin or theme, or when you update your version of WordPress. You also may experience strange URL errors or problems browsing to certain areas. Included in this post is information and general suggestions on setting up your own web hosting on your OS X machine. Continue reading “Web Hosting on OS X”