I AM LISTENING TO
|
WHAT I LIKE
  • en
  • de
BLOG FILTER

Again another Google AMP article, this time dealing with Syntax Highlighting. If you have a code centric website, this is important.

In one of my last articles I talked about a Generic Syntax Highlighter.   This time I want to show you, how to add Syntax Highlighting with GeSHi to a custom template in AMP-WP.

FIRST SOME RESOURCES

Please read up on documentation, as I am not diving into every detail.

  1. AMP-WP – github.com/Automattic/amp-wp / Documentation
    The WordPress AMP integration. We will be using a custom template for our AMP pages.
  2. Crayon Syntax Highlighter github.com/aramk/crayon-syntax-highlighter
    I am using this for Syntax Highlighting on none AMP pages. It adds specific language classes to the code / pre areas, that I am using to configure GeSHi.
  3. GeSHi – github.com/GeSHi/geshi-1.0
    The Syntax Highlighter
  4. phpQuery – github.com/punkave/phpQuery
    DOM Document transversal & modification simplified. You should be able to apply the things below with any other tool as well.
  5. My tweaks on GitHub

ADDING GESHI TO AMP-WP

  1. Upload GeSHi and phpQuery to your desired location on your webserver.
  2. Call the custom template for AMP-WP in your functions.php

    I have an example stored on GitHub
  3. Create a custom template in your themes folder.We could use the following filters, but its easier to use the custom template, due to the GeSHi style setup. The problem is, that the style action is called before the content action within the template. But I am planning to build a TWIG template for myself, as I am running Timber everywhere. That will detach logic and content completely, allowing to rethink some of these things and make styling a lot easier :) So watch out for my next article!

    Add this to the top of your custom template:

    I have an example stored on GitHub. The above works, if you are using Crayon Syntax Highlighter for standard pages.
    If you use something else, this needs to be changed.
  4. Add the GeSHi styles to the amp-custom style tag


    I have an example stored on GitHub.
  5. Output updated amp-wp-content


    I have an example stored on GitHub.
  6. Save and check that your AMP page validates, by adding #development=1 to the end of the url. Check the console for errors.
    Show this page as AMP

Enjoy coding …

readmore
29. February 2016

AMP-WP Tweaks & Tips

The AMP (Accelerated Mobile Pages Project) plugin for WordPress is still pretty young and under heavy development.

There are little things that can help to fix current validation problems. I have a couple of fresh AMP pages, that are already indexed by Google.

0. RESOURCES


1. MISSING IMAGE (schema.org-NewsArticle)

The currently registered Microformats template (schema.org-NewsArticle) requires an image.
The AMP-WP documentation explains how to add a featured image to your pages (documentation).

I extended that a bit,  to link a default attachment image, I uploaded before. This needs to be added to your themes functions.php.

Next we adjust the Microformats definition. This needs to be added to your themes functions.php.


2. ADD YOUR OWN AMP TEMPLATE

Read the AMP-WP documentation first :) This forces AMP-WP to override the core template with your own. Use the default template as a reference.


3. REMOVE NONE VALIDATING CONTENT

Normally the core sanitizer should take care of that.  I am sure a filter will be added in the future. For now, this is a quick workaround. You can use a RegExp or DOMDocument to alter the amp-content in your custom template and filter things that break validation.

I am using phpQuery for now, as it allows me to add quick fixes. DOMNode or QueryPath works nicely as well :) Will be looking at the core sanitizer and options later this week. All of this is currently added to the custom template.

  1. Remove REL attributes that are not allowed. Only registered Microformat rel attributes are allowed.
  2. Remove attribute ALIGN
  3. Fix TARGET Attribute

Finally output the fixed content as HTML.

The above examples need to be tweaked to your specific content requirements.

The custom template “post_amp_content” before:

The custom template “post_amp_content” after:


4. ADD PREVIOUS & NEXT POST NAVIGATION

From the AMP specification :”Note, that AMP document may also be linked to directly…”

This is being added to the custom template as well.

Next:

Previous:


5. SYNTAX HIGHLIGHTING

You can find a simple pure PHP highlighter here. Not perfect, but a start. Don not forget to include the CSS :)

 

I will extend on this as new validation errors or tweaks come up. The core sanitizer of AMP-WP still needs some work and should allow us to do some of the above directly, when the content is parsed / converted for AMP.


 

 6. OTHER AMP ARTICLES

Make Syntax Highlighting work in AMP-WP using GeSHi

Time to get AMP ready

 

Enjoy coding …

 

readmore
26. February 2016

Time to get AMP ready

Google’s AMP is here to save us from slow mobile content delivery, by enforcing strict standards and limiting what is allowed within AMP pages. The pages only allow a subset of tags and introduce their own tags for fast prefetching of content (images, videos … AMP Specs)

THIS IS AMP

“The Accelerated Mobile Pages (“AMP”) Project is an open source initiative that came out of discussions between publishers and technology companies about the need to improve the entire mobile content ecosystem for everyone – publishers, consumer platforms, creators, and users.

Today, the expectation is that content should load super fast and be easy to explore. The reality is that content can take several seconds to load, or, because the user abandons the slow page, never fully loads at all. Accelerated Mobile Pages are web pages designed to load instantaneously – they are a step towards a better mobile web for all.”

AMP CACHE & VALIDATION

AMP pages are cached within the AMP Cache, providing even faster delivery of your content. The core libs validate your implementation and highlight any problems by pushing errors to the console.

INTEGRATION

The documentation lists all components currently supported within a page and experimental components in development as well.

  1. Introduction to AMP
  2. Video Introduction
  3. AMP for WordPress
  4. AMP Docs
  5. Q&A Video

I have already added AMP support to our blog posts:

  1. Standard page
  2. AMP page

Google’s Webmaster Tools also integrates a new section for AMP, to see how they perform.

WHAT AMP IS NOT

AMP is not supposed to replace your webpage, but offer a faster access point to presented content. It will not solve all use cases, but offer better performance for your simple reading pleasure for now. Its a start and lets see how it evolves ;)

Enjoy coding …

readmore

Simple way to do some Visual Composer Grid cleanup, when you are using Bootstrap within your theme. This removes and cleans up classes.

Visual Composer for WordPress
Bootstrap / Bootstrap Sass

Enjoy coding …

readmore

Depending from where you want to access the page, post or custom post-type data, it might not always be available that easily.

WordPress provides an option to get your data through the page-slug.

The function is called get_page_by_path.

Enjoy coding …

readmore
2. February 2016

LMS meets SaaS

As I said before, Learning Management is really taking off and I get many client requests to do some kind of  integration or custom solution for them.

In one of my latest articles I started listing solutions for WordPress, WordPress and the LMS universe.

But those solutions might not always be the best fit for your project. Many of them actually try too hard to be everything. The amount of cross linked functionality is getting insane and increases the point of failure.

In some cases a trimmed down solid solution might be the better way to go. SaaS (Software as a Service), part of the cloud trend, is providing more and more options, this includes the LMS arena. Stop worrying about the software and concentrate on your content again. The SaaS provider takes care of functionality, support, updates and delivery. This is nothing new, solutions like TalentLMS or Litmos LMS offer this for some time now.

Modern SaaS solutions provide Public APIs, that allow you to seamlessly integrate them with your current solution. So in case of a LMS, that part of your project could be handled by the SaaS provider, while e-commerce, social and other content areas remain under your full control.

One solution I am currently looking at is Intuo, which is a fresh startup out of Gent / Belgium. They provide a solid set of features and a clean API to handle single signons and content access. That would allow a seamless integration into WordPress for example :)

We are looking at a very crowded LMS market, but always nice to have options :)

Enjoy coding …

readmore

CodePress Admin Columns allows you to manage and organize columns, for posts, users, comments and media lists in the WordPress admin panel.

This little tweak allows you to add sorting to your columns. Add and adjust depending on the columns you have setup.

Enjoy coding …

readmore

Anyone using WPLMS 1.9x should wait and not update to 2.0x yet.

Not all bugs are fixed and I see many users having problems, just by reading the support forums and the comments over on Envato.

I have a vanilla test environment of WPLMS 1.9x on my testserver and i had no problems until 2.0 came along.

The last customtypes plugin update today killed the setup completely. Many of the old child themes break or have parts broken. Fresh sample data is not working either. Sadly some of my customers already did an update themselves …. perfect !  Will be a long weekend.

I am doing a complete reset of my test environment and waiting for the next update :)

Rant: This theme / plugin is getting too bloated in many areas. Two many unknown variables, due to the huge amount of dependencies …

UPDATE

  1. 28.01.2016: 2.0.1 – broken customtypes .. 2.0.2 should be around the corner ;)
  2. 29.01.2016: 2.0.2released , tested, a lot of fixes, but its not their yet ! Still having massive problems on a clean system using the modern theme and sample data… 2.0.3 please :) Course section is completely broken now, only shows header and first part of the left sidebar!
  3. 30.01.2016: 2.0.2 clean install still failing and not working 100%, checking upgrade install from 1.9.9.1. Clean install with 1.9.9.1 + Sample data is working. Upgrade to 2.0.2 still has bugs and errors. Modern theme is not working!
  4. 02.02.2016: Another course plugin update to fix Visual Composer errors. Still seeing little errors here and there. I am sure there will be more updates this week :) Upgrade from 1.9.9.1 works now without errors and site is functional. Have not tested all admin / instructor functionality yet. I reset the settings to defaults after the upgrade to make sure nothing is missing …
  5. 11.02.2016: Another update to almost all plugins. Will continue and wait for final fixes. Will see how this version performs …

readmore

  • All PayPal IPN data is saved and available in your WordPress admin panel.
  • Developer hooks are provided for triggering events based on the transaction type or payment status of the IPN.
  • Extend the plugin with your own plugins or theme functions

Author: Andrew Angell

BitBucket Repo

readmore

Favic-o-matic is a favicon generator, that transforms your png design into favicons and the required html to include them.

Favic-o-meter makes sure that every browser shows your favicon perfectly :)

readmore