Surf the Dream A discourse of links and articles from Justin Avery

Tag Archive: Wordpress

  1. My local wordpress MAMP site slow

    Leave a Comment

    While I was on the train ride home today I was writing an article on my local copy of wordpress when I thought to myself “This is actually slower then working with the patchy wifi and GPRS”.

    The best thing about running your site locally is that you do not require an internet connection to make updates, especially great for train, planes and tube travel. The next best thing about it should be the speed! You’re not relying on the internet connection and you will most likely have a more highly spec’d laptop then you have on your shared server space.

    Why are .local wordpress sites slower with MAMP?

    The answer was quite surprising! It’s not that it is wordpress or that you are running MAMP, although the MAMP bit does have a knock on effect.

    I use MAMP because I use a Mac and I always used Xampp before making the jump from PC to Mac in 2007. THAT is the key to why it’s slow. It’s not that it’s MAMP, but because you are running a .local site on your Mac.

    The Mac OS looks at any .local domains to be part of Bonjur, so it has a whole internal battle before it realises what it should be doing. The fastest way to avoid this is to set your local sites to something like .dev (after all they are dev sites) or follow Chris Coyiers lead and have something completely random (he uses .whatup for his local sites, so you see css-tricks.whatup).

    If you’re doing this then follow these steps for your WordPress site at least.

    1. Update both the URL’s in the Settings > General from surfthedream.local -> surfthedream.dev
    2. Update the MAMP URL from surfthedream.local -> surfthedream.dev and restart the servers
    3. If you’re running something like Migrate DB Pro as well to keep things in sync then you might also want to ensure you update the URL rewrites before you sync all your updates back up again too

    Enjoy a faster site!!! I know I am.

  2. wp-admin redirect loop on https

    Leave a Comment

    Running your website on HTTPS has many benefits which doesn’t stop at being safer, it also allows you to run on http2/SPDY and offers things like Service Workers.

    I use CloudFlare and their Flexible SSL to secure most of my sites. It’s easy to set up and it costs nothing which is just amazing as the upfront and on going costs are ofter a barrier for HTTPS.

    When I updated WordPress to use https://theuniverse.is under General > Settings I suddenly had an issue with the /wp-admin/ throwing redirect errors.

    Fixing the Redirect Loop

    After a lot of searching on the web I found the answer in a couple of different wordpress threads.

    You need get FTP access to your wp-config.php file and drop in the following snippet

    
    define('FORCE_SSL_ADMIN', true);
    define('FORCE_SSL_LOGIN', true);
    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS']='on';
    

    That pretty much fixes it…. pretty much

    Fixing “You do not have sufficient permissions to access this page.”

    So while the above update fixed the redirect problems I was now faced with the error that I can not access the page due to insufficient permissions.

    After a quick search I found that you need to paste the above code ABOVE the following code:

    
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    

    I hope that helps any issues you’re having.

  3. User generated content in a multi platform publishing world

    Leave a Comment

    I’ve just finished reading Snooks article User Generated Content in a Classy World, which is turn was a follow up to Chris Coyiers article Class up Content.

    Recently I’ve been trying to apply AMP templates to the Responsive Design Knowledge Hub and it’s been a learning curve. The thing I can not fix is the embedded content that is contained within the News and Articles I’m applying the AMP template to. The reason is that AMP requires it’s own fancy elements to be declared for Images, Video, Ads, Embeds, Iframes and more. This makes a mockery of the carefully semantic way that I’ve tried to add content and renders some of the pages non-compliant.

    The best implementation I’ve seen from a CMS to separate the concerns from creating content from the way in which it is rendered to the client is WordPress and Responsive Images.

    When adding an image to WordPress I go through a three step process.

    1. Click Add Media
    2. Select or Upload an image
    3. Add the image

    The code that is added to the wysiwyg is shown below…

    
    <img src="https://surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-1024x591.jpg" alt="moon shard" width="1024" height="591" class="alignnone size-large wp-image-1866" />
    

    …. yet the code that is rendered to the browser is:

    
    <img src="//surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-1024x591.jpg" alt="moon shard" width="1024" height="591" class="alignnone size-large wp-image-1866" srcset="//surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-300x173.jpg 300w, //surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-768x443.jpg 768w, //surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-1024x591.jpg 1024w, //surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-500x288.jpg 500w, //surfthedream.com.au/wp-content/uploads/2015/12/moon-shard-800x462.jpg 800w, //surfthedream.com.au/wp-content/uploads/2015/12/moon-shard.jpg 1600w" sizes="(max-width: 1024px) 100vw, 1024px">
    

    … which produces the following responsively wonderful image.

    moon shard

    I haven’t had time to look into the AMP plugin for WordPress, but I assume they’re going to be doing a similar thing where they scan the content for markup that needs to be updated, images iframe embeds and rewrite them into a suitable accepted format for AMP.

    Below are my comments on Snooks article….

    The other issue I have with embedding content into that single block is when you want to retrieve the content for use in other ares besides a HTML template.

    I’ve had RSS feeds clog up because of the funky elements used within content areas (different apostrophe’s in headings the biggest issue), and while these can usually be sorted by using something like CDATA tags

    <!--CDATA 
    // Content here
    -->

    the same issues end up coming back when you look at implementing something like AMP with your database content. All of a sudden it’s less of a class issue and now you have issues with the semantics of the content requiring updates.

    The best approach from a CMS I’ve seen has been the implementation of responsive images into wordpress. The image is inserted in the same way it always has in the WYSIWYG, but when it is rendered on the front end you get the benefit of the Responsive Images markup being added for you with no additional work.

  4. A new blog

    Leave a Comment

    After many many months without being to update this site I was finally able to set aside enough time to finish off the migration, moving from Squiz Matrix CMS across to WordPress.

    This is the second move of this blog. It was originally migrated from Blogspot across to Matrix back in 2007 and it served as a playground for me to test new web trends while ensuring that it could all be done within a CMS that I was working with on a day to day basis.

    The site changed over to a new design when responsive design first made it’s splash and I re-designed the site to be more responsive.

    Why the change?

    The main reason for this change is because the version of Matrix I was using was going to take too long to upgrade, and worse of all I needed an outdated version of Java to create any new content (which is why there was such a huge gap between posts).

    Matrix is a super powerful CMS that gives me the power to build a complex site, however this site has come full circle over the past few years to be back to a basic blog where I can publish my thoughts on a variety of topics (mostly the web these days).

    It was moved to WordPress because I have become just a familiar with it as a CMS over the past few years and run several other sites off WordPress. It’s a great tool if you’re requirements aren’t too robust.

    Has anything been lost in the changes?

    Fortunately not.

    In this process I’ve migrated all of the posts from the previous Surf the Dream Matrix site across to an existing WordPress site I had been running for Javery Design. Once that was done I updated all of the Javery Design URL’s to become surfthedream.com.au and set up a series of 301 redirects to hopefully catch any old site links and google indexes.

    What changes are likely next?

    I’m not entirely happy with the look of the site or the layout of the homepage. I prefer the header in this one but there are some issues with the Archive pages and the Search listings which need to be fixed up.

    The footer needs some work as well, I need to put a link to my other side projects – Am I Responsive, RWD Weekly Newsletter and ResponsiveDesign.is.

    I’m happy with things now though, and it means that I’m able to get back into the swing of writing more often.

  5. Restoring mySQL database from the file system MT

    Leave a Comment

    When you get a flat backup of your server the SQL is useless to you. Unless you’ve run SQL exports and backups your self you’re going to have to recover the databases from these flat unusable files.

    Fortunately there’s a tool in the Media Temple back end that allows for this. Simple connect to the server via SSH and run the following command

    /usr/local/mt/bin/mib --restoredbs --apply

    Note that this doesn’t need to be run from your /old/ section of the site, the command relies on the current working system. You will then be prompted to go with either /restore or /old, and then choose the database you want to restore. I’m not sure if you can restore all of them at once, I tried a comma separated list and it failed so ended up doing one at a time.

  6. Custom Post Type UI | WebDevStudios.com

    Leave a Comment

    The Custom Post Type UI plugin adds easy to use control over post types and custom taxonomies in WordPress.

    New WordPress 3.1 features
    Create and edit custom post types
    Create and edit custom taxonomies
    Attach Built-in and custom taxonomies to post types
    Advanced labeling for post types
    Below is a slightly outdated example video showing Custom Post Type UI in action!

    Visit Link

Surf the Dream is a blog that has been running since the mid 2000's when it started on BlogSpot. Over the years it's been rebranded as justinavery.me (now my resume) and JaveryDesign.com (which now redirects back to this site).

I offer consultation services through Simple Things, produce a range of educational pocket notebooks, write about the Universe and run a responsive design and a RWD Weekly Newsletter