Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cleaner Themes: A Persil.co.uk Case Study

Cleaner Themes: A Persil.co.uk Case Study

Persil may say “Dirt is Good”, but when it comes to WordPress themes you want to make sure they're as clean as possible, especially when you're building a global network of websites for one of the world's leading washing detergent brands. This case study will take a close look inside the theme and front end code powering the Persil.co.uk website and it's international counterparts.

Using WordPress Multisite, some select plugins, parent and child theming, as well as custom plugins, Sass, and Compass we were able to tackle problems such as: internationalisation, complex page content, and lots of Ajax interactivity. All the while making sure the sites would be easily updatable and extensible by the local content teams, good for SEO, and easily customised for each market.

Adam Onishi

April 29, 2014
Tweet

More Decks by Adam Onishi

Other Decks in Technology

Transcript

  1. @onishiweb The project: ‣ WordPress backend ‣ 35+ Markets Worldwide

    ‣ Multi-language support ‣ Customisable per market - features, styling, etc ‣ Manageable by local teams ‣ Integrate with external campaigns
  2. @onishiweb The solution... ‣ Work with a team of developers

    ‣ Modify styles/functionality on a per-site basis ‣ Managed through a simple codebase ‣ Easy to keep up to date and easy to deploy ‣ Extendible when necessary
  3. ‣ Multisite ‣ Parent/Child Themes ‣ Git ‣ Frontend Tools

    - Sass/Compass/Grunt ‣ Plugins @onishiweb Tools
  4. ‣ Functions file ‣ Pluggable functions ‣ Post type &

    taxonomy slugs ‣ Mail settings @onishiweb Child theme config
  5. if( ! function_exists('dig_mail_from_address') ) : function dig_mail_from_address( $old ) {

    return '[email protected]'; } endif; add_filter('wp_mail_from', 'dig_mail_from_address'); @onishiweb
  6. @onishiweb Sass & Compass benefits ‣ Easier to work in

    collaboration ‣ More modular way of writing styles ‣ Makes working with child themes a breeze ‣ Good for performance ‣ Easily modify base styles
  7. $count = 1; foreach( $tax_labels as $slug => $labels )

    { $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => $slug ), ); register_taxonomy( 'dig_product_filter_' . $count, 'dig_product', $args ); $count++; } @onishiweb
  8. if( ! function_exists( 'dig_get_post_type_title' ) ) : function dig_get_post_type_title() {

    if( is_tag() ) { $query = get_queried_object(); return __('Topic: ', 'dirtisgood') . $query->name; } $type_name = dig_current_post_type(); if( '' !== $type_name ) { $post_type = get_post_type_object( $type_name ); return $post_type->labels->name; } } endif; @onishiweb
  9. // Set up Nonce in the arguments args.nonce = coreData.ajaxData.postUserNonce;

    // Run ajax call $.ajax({ type: 'POST', dataType: 'json', url: coreData.ajaxData.ajaxurl, data: args, success: callback }); @onishiweb
  10. wp_enqueue_script( 'core', $javascript_file, 'jquery', '1.1.1', true ); $ajaxData = array(

    'ajaxurl' => admin_url('admin-ajax.php' ), 'postUserNonce' => wp_create_nonce( 'ajax-users-nonce' ), ); wp_localize_script( 'core', 'coreData', $ajaxData ); @onishiweb
  11. // Set up and send the response $response = json_encode(array(

    'results' => true, 'pages' => $pages, 'data' => $data, )); die( $response ); @onishiweb
  12. $labels = array( 'name' => __('Laundry Products', 'dirtisgood'), 'singular_name' =>

    __('Product', 'dirtisgood'), [...] ); <h2><?php _e('Sign in with', 'dirtisgood'); ?></h2> <p class="page-error"> <?php printf( __( 'Sorry, no %s were found.', 'dirtisgood' ), strtolower( dig_get_post_type_title() ) ); ?> </p> @onishiweb
  13. $strings = array( 'close' => __('close', 'dirtisgood'), 'all' => __('All',

    'dirtisgood'), 'both' => __('Both', 'dirtisgood'), [...] ); wp_localize_script( 'core', 'coreData', $localisations ); @onishiweb