Security of a WordPress (or any) website is a multi-faceted problem. The most important step anyone can take to make sure that a site is secure is to keep in mind that no single process or method is sufficient to ensure nothing bad happens. But there are things you can do to help. One of them is to be on the watch, in the code you write and the code from others you deploy, for functions that can have negative consequences.
Original Source: https://www.hongkiat.com/blog/cmd-challenge-webapp/
We’ve discussed the importance of learning the command line and it’s more important now than ever before. But, it’s also a difficult subject to breach, with a steep learning curve….
Visit hongkiat.com for full content.
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/DqWmwrVbL6g/
If you’ve come this far without using WordPress, this might be a good time to make a switch. The reasons are many. WordPress is a free open source content management system that’s highly flexible, and easy to use. It also has the backing of a large community of users.
There is a nearly endless supply of plugins and themes available to you. Thus, there’s virtually no limitation on the types of websites you can build. The demo content of most of the available themes, like those described here, can be imported.
You will just need to select a theme. Afterward, you can be assured that the layout and structure of your website’s theme will match that of the demo.
Consider using one or more of these world-class WP themes! They will definitely help you to create your own world-class websites in 2018.
Hestia is a single-page design theme that adheres to Google’s Material Design principles. This makes it possible for web designers and website owners to adapt Hestia to virtually any niche, website purpose, or screen size in perfect harmony. Hestia is especially suited for creative agencies and startups, as well as small shops and businesses.
You can easily build a shop in Hestia with WooCommerce. It is compatible with most of the popular plugins, including bbPress, Photo Gallery, Travel Map, Yoast SEO, WP Super cache, and Flat Parallax Slider, to name a few.
Built-in SEO Optimization ensures your website or shop will be correctly indexed, so it can be found by the major search engines. Your content has something to do with this of course, but it is helpful when the theme itself is created with SEO in mind.
Hestia is free. Premium versions are available, but it would be more than worth your while to give the free version a try. It may in fact be all you are likely to need.
Enfold is a ThemeForest best-rated top seller, and as such is well known in WordPress web design circles. Especially noteworthy is Enfold’s large variety of demos. These demos not only contain images you are apt to find uses for, but include a license to use them.
You’ll find demos representing niches large and small, travel niches, and demos suited for everything from blogging to weddings, to construction, to consulting.
Enfold is extremely easy to work with. The demos can be installed with one click, page-building is easy, and no coding is necessary on your part. Once you start Enfold, you’ll soon discover how much time you can save during your web-building adventures, and should you hit a little bump in the road, youll also discover that great support can take on a whole new meaning.
Porto – Ultimate WordPress + Ecommerce Theme
Porto has been around for several years, during which it has enjoyed increasing popularity; and for good reason. For many, Porto has been seen as simply being a better choice for new website design. Its authors have kept abreast of the latest trends in web design, and best practices in coding; resulting in a best solution for you.
Porto is highly optimized, it’s super-fast, and it’s compatible with tons of WP plugins. There are plenty of demos to choose from, ranging from classic website demos, to one pagers, and shop demos. The best way to see what Porto offers, is to visit the website and view the Main Demo, of which there are 18 variations.
You’ll like what you see, plus you’ll come away understanding why Porto’s (happy) customers are presently 53,000+ strong.
TheGem – Creative Multi-Purpose High-Performance WordPress Theme
TheGem is a versatile, responsive, high-performance WordPress theme with a modern creative design to suit a multitude of creative uses for building websites. It’s a top-seller on ThemeForest, it has a 5-star rating, and with more than 14,000 sales the past year alone, it’s a best-selling WordPress creative theme. Since TheGem has too many awesome features to list here, visit their website and see them for yourself. You’ll be impressed.
Houzez – Highly Customizable Real Estate WordPress Theme
Building a website that has all the features and functionality a real estate agency requires, would normally be a daunting task. Not so with Houzez. Everything is there to begin with, and all you need to do is tweak things to the liking of your client. It doesn’t get much easier than this.
Uncode – Creative Multiuse WordPress Theme
Characteristics of the starting theme are often reflected in the final product; one reason why Uncode, a pixel-perfect theme featuring awesome attention to details and performance, should serve you well. Uncode’s massive options, and advanced grid and adaptive images systems, make you the master. If you like “smooth and sleek”, you’ll surely like what this WP theme has to offer.
The Core is a premium, multi-purpose WordPress theme that is well-equipped to take on virtually any task you might demand of it. With its 20+ premade websites, visual page builder, and an awesome assortment of premade layouts, The Core lays claim to having the best WP theme design in the business. Purchase hosting from one of The Core’s partners, and you get the theme, theme installation, and a demo import for free.
Grimag – AD & AdSense Optimized Magazine WordPress Theme
If you’re an AdSense user, or have contemplated using AdSense in your marketing campaigns, Grimag, the AD optimized Magazine WordPress Theme, is right for you. In addition to being AdSense ready, Grimag is bbPress, BuddyPress, and Translation ready. This powerful publishing solution is an ideal solution for anyone looking to get the greatest monetization results from their online publishing efforts.
MOVEDO – We DO MOVE Your World
This top-rated premium multipurpose WordPress theme will take you places in web design you’ve never been before, and you may not wish to return. MOVEDO was crafted with awesomeness in mind, with features such as motion dynamics in columns, super-crispy moldable typography, and the ability to manipulate header elements until they appear “just so”. You can create wild and wonderful websites, and thoroughly enjoy yourself while doing so.
Anariel – A WordPress Fashion Blog Theme
This modern, classy WP Fashion theme is just the thing for a fashion blogger who prefers a minimalist design approach, and who wants to create a modern blog with plenty of options. Anariel is responsive, and comes with 6 pre-defined demos you can install with a single click. If you’re a fashion designer, you absolutely should have a theme that specifically fits your need for a fashion blog. Anariel does precisely that.
Real Homes – Real Estate WordPress Theme
Real Homes is a handcrafted WordPress theme for real estate websites with more than 4.7 out of 5 rating from 950+ real buyers. Its popularity (15,500+ buyers), together with its many features make it well worth considering, but if you dig deeper, you’ll find that what purchasers and users really like, is its flexibility.
You can present listings and properties in so many different ways; including comparisons. Real Homes can also be used by those interested in or charged with property management.
Leadinjection is a WordPress landing page theme that is ideal for marketers, business owners, affiliates, and other professionals who have a need to launch landing pages within minutes. Leadinjection is easy to install and customize. A favorite feature is the Lead Modal Popup, a lead capture form popup that appears on your website per your specification, can’t be blocked, and draws attention to itself, providing you with a genuine marketing advantage.
There’s more than a little variety to choose from in this listing of top WP themes for 2018. We have no doubt you have discovered this by now.
What is a beauty of a listing like this? It includes many multi-purpose themes for a wide variety of different web-building projects. However, that is not it.
There are also those more specialized themes. They address itches you’ve been longing to scratch but haven’t found the means to do it with.
Original Source: http://feedproxy.google.com/~r/tympanus/~3/q3CTVKPSZtM/
Inspirational Website of the Week: Active Theory
Active Theory’s new website is out of-this-worldish awesome. Our pick this week.
This content is sponsored via Syndicate Ads
Northwestern’s Online MS in Information Design & Strategy
Build skills to translate data into compelling visuals and narratives and learn how research and analytics can drive communication strategies and tactics.
Find out more
A tool from IBM that helps teams adopt CSS grid sooner and that enables the creation of more complex layouts. Read more about it in this article.
Check it out
Using CSS Clip Path to Create Interactive Effects
Learn how to make some creative clip-path effects in this article by Mikael Ainalem.
Recreating the GitHub Contribution Graph with CSS Grid Layout
A great tutorial by Ire Aderinokun where she challenges herself to create the GitHub contribution graph with CSS Grid.
In case you missed it: James Sinclair shows how to write good React and Redux code, but explains first why you’d actually want to use it.
Check it out
Grid Experiment No. 4
Jules Forrest shows a beautiful CSS grid example of a menu.
Check it out
50 fantastic free illustrations from the Streamline UX vector illustration pack.
Facebook just open-sourced Detectron, a software system that implements state-of-the-art object detection algorithms.
Check it out
A creative tubugl font rendering demo of twisting letters made by Kenji Saito.
Check it out
How I Got Hired by GitHub
Joel Califa shares the design homework that landed him the job at GitHub.
A simplified zero-configuration wrapper around Karma, Webpack, Jasmine and Puppeteer for automatic (headless) browser testing.
Check it out
Collect your favorite content and share it with this advanced bookmarking tool.
Check it out
A GraphQL Primer: Why We Need A New Kind Of API (Part 1)
Learn how to work with GraphQL in this first article of a two-part series by Eric Baer.
Free Font: College Stencil
Inspired by the architecture of College de France, Corentin Riviere created this creative typeface.
Interesting ECMAScript 2017 proposals that weren’t adopted
Kaelan Cooter writes about the ECMAScript proposal process and showcases some proposals that didn’t become part of the language.
Handwritten Font Collection
A fantastic free set of beautiful handwritten fonts that fit perfectly together. By Julia Dreams.
Multiple routes, bundling and lazy-loading with webpack
Sérgio Gomes shares some thoughts and code on bundling with multiple entry points in webpack.
Learn Flexbox for free
In these 12 interactive screencasts you’ll learn everything about CSS Flexbox. By Per Harald Borgen.
Check it out
A zero-configuration developer toolkit for building WordPress Gutenberg block plugins without configuring React, Webpack, ES6/7/8/Next, ESLint, Babel, etc. By Ahmad Awais.
Check it out
Firefox 58: The Quantum Era Continues
Read about some of the new goodies that Firefox 58 brings.
Collective #385 was written by Pedro Botelho and published on Codrops.
When light strikes a metallic object, it can reflect back onto any nearby object in an unusual way. Normally, light hitting a primary and secondary object gives varying degrees of light, shadow and cast shadows, but reflective light also happens under these circumstances, and will need to be shown in your artwork.
10 expert tips for charcoal drawing
To demonstrate the drawing techniques to make this work, I have produced the images above, working with a dark charcoal pencil and an eraser.
01. Place your objects in light
Position your objects to make the most of the highly lit and shadowed areas
Select interesting objects – such as this highly polished metallic teapot and a ceramic vase – and place them with light catching one side so you can carefully observe the highly lit and shadowed areas. Then draw basic shapes with a charcoal pencil, trying to represent these reasonably accurately, although adjustments can be made later.
02. Get shading
Shading the metallic object is where the fun starts
Shade the object in direct light first – here the ceramic pot to the left – observing the deeper and lighter values. Then move on to shade the object in its shadow – here the metallic object. It was important to really concentrate on the depth of the cast shadow from the ceramic pot as it struck the left side of the metallic one, here. The deepening of the shadow to the right of the metallic pot follows conventional rules of light and shadow.
03. Add some shadows
Add ground shadows to bring your objects down to Earth
The objects appear to be almost floating in space at this stage, so need grounding. Shade the shadows cast by the objects as they fall to the right across the table top, thus sitting the objects on a solid base.
04. Blend and soften
Use an eraser to highlight areas where light is reflected off the metallic object
Using a charcoal eraser, rub out sections of reflections and – here we rubbed out from the already shaded right side of the vase, where the light was reflected back from the teapot. You can see how this is of secondary importance compared to the other highlighted area.
Finally, blend some areas using your finger to soften the transition of tonal variances on the vase for effect.
This article was originally published in issue 13 of Paint & Draw, the magazine offering tips and inspiration for artists everywhere. Buy issue 13 here.
How to choose the right drawing toolsPencil drawing in 6 simple stepsHow to draw and paint – 100 pro tips and tutorials
When it comes to left-field creativity, Berlin is indisputably one of Europe's – if not the world's – most vibrant and inspirational design cities to visit.
Offering a unique blend of subversive counter-culture, bustling cosmopolitan energy and harrowing historical scars, Berlin is a haven for design inspiration.
So whether you're paying the German capital a flying visit, looking to move there to live or just on the hunt for some visual reference material, read on for our guide to 10 of the best off-the-beaten track creative locations in Berlin…
An abandoned amusement park might sound more like the favoured stomping ground of a Scooby Doo villain than a must-see creative attraction, but bear with us.
From a towering, derelict Ferris wheel to derailed go-karts peeking out from the undergrowth, Spreepark – once full of life, bright lights and laughter as the GDR's only permanent amusement park – is now a hugely surreal place to become inspired.
Everywhere you look, there's a visual cue to spark off a story in your mind – whether it's toppled, overgrown dinosaur statues or colourful animal faces adorning tunnels.
Formerly known as Kulturpark Plänterwald, the park was opened in 1961 and used to attract 1.5 million visitors a year, but fell into financial difficulties after reunification, and was declared insolvent in 2001.
If you're passing by, you can peek through the gates into Spreepark for free – or occasionally there are events, screenings and even concerts hosted inside, if you're lucky.
02. Panke art cafe
Berlin is packed with quirky arts venues, of which Panke is a great example. Offering a heady combination of art, food and music, it strives to "support edgy creativity that happens away from mainstream culture".
Its café serves vegan/vegetarian food and coffee by day, and hosts events by night, while the gallery space showcases both established and emerging artists, with a particular interest in digital or net-based art and club culture.
Visual inspiration doesn't stop there, as the bar is continuously redecorated by local and international artists – so you can get a fresh experience every time you visit the city.
03. Monster Kabinett
If you like your artistic inspiration mixed with a dose of mechanised horror, there's no better place to do so than Monster Kabinett – a dark, unsettling showcase of hulking robots and warped, insect-like creatures.
Hosted in a warehouse, it's the brainchild of the Dead Pigeon Collective and features costumed performers among the giant, moving metal sculptures.
It's very literally off the beaten track: you'll find it down a suitably dank, dark alleyway off the side of a busy thoroughfare. It's an unassuming location, and you might not be sure you're in the right place until you're standing directly outside it.
Typography is part of Berlin's design heritage, as the ever-inspiring annual TYPO Berlin conference attests. And you'll find plenty of tangible examples of it in use here.
With an impressive collection gathered from around Berlin and beyond, the Buchstabenmuseum – or Museum of Rescued Letters – is one of the world's first museums to collect letterforms from public spaces and display them as part of urban history.
Featuring all manner of lost, forgotten and abandoned signage that's been saved from the scrapheap, this is a wonderful source of typographical inspiration. Courtesy of LucasFonts, there's even a free Buchstabenmuseum font, based on a selection of the letterforms on display.
05. Haus Schwarzenberg Street Art Alley
Berlin's street art scene is legendary, from the world-renowned East Side Gallery, painted on the remnants of the Berlin Wall, right down to tucked-away alleyways that can be easily missed.
One such example is Haus Schwarzenberg Street Art Alley. A narrow, unassuming passageway beside a cafe – not far from the famous art nouveau courtyards of Hackeschen Höfe – leads to a colourful explosion of inspiring murals, paste-ups and graffiti.
Given the nature of great street art, the specific creations on display are constantly evolving as new murals are painted on, papered over and adapted, although Jimmy C's beautiful painting of Anne Frank, a centrepiece of the space, remains untouched.
The existence of this pocket of inspiration is all thanks to non-profit arts organisation Haus Schwarzenberg, which occupies the adjacent building.
06. The Return of the Cows
A quiet residential street in between the Prenzlauerberg and Friedrichshain areas of the city, Dietrich-Bonhoeffer Strasse is definitely off the beaten track by most standards. In fact, there would be no real reason to visit if it weren't for Sergej Dott’s delightfully whimsical public art installation, Die Rückkehr der Kühe – or The Return of the Cows.
Peek between two buildings halfway down the road, and you'll spot a photo opportunity unlike any other: a herd of giant cows, seemingly wandering up and down the side of an apartment block.
Dott has created several cow-based installations, which he calls 'Kuhunst' – a cheeky pun that will appeal to German-speakers, combining the words 'Kuh' (cow) and 'Kunst' (art).
07. Stand By Me tree
An anonymous fan of Ben E. King has demonstrated their passion for his seminal love song Stand By Me, by carving the lyrics into a tree trunk in Berlin’s Tiergarten Park – turning it into a natural sculpture to inspire all who visit it.
Unlike the transient, temporary nature of some of the street art featured on this list, this lyrical trunk has a pleasing permanence about it. The bark has healed, sealing the words within – and the anonymity of the creator adds to its enigmatic appeal.
While the exact date it was carved is unknown, the tree first became an attraction following King’s death in 2015, and the famous chorus of the song also appeared on a nearby tree at a similar time.
08. Georg von Rauch-Haus
A graffiti-daubed icon of socialist activism, the Georg-von-Rauch-Haus is an infamous Berlin squat that takes its name from a violent German anarchist and so-called 'urban guerilla' who was shot dead by the West German police in 1971.
Shortly after von Rauch's death, squatters and political activists occupied a former nurses’ dormitory near Bethanien Hospital on Mariannenplatz, Kreuzberg. Attempts by the police to evict the inhabitants culminated in a major protest, which was met with tear gas and batons.
With a distinctive ring of graffiti around the lower level, the Georg von Rauch-Haus now operates as a 'free-living' collective, as well as playing host to musical and cultural events.
With an intriguing name that translates as 'devil's mountain', Teufelsberg is a former US spy base from the Cold War. It's built on top of a man-made hill outside the city, formed from the remnants of an incomplete Nazi military-technical college, as well as wartime rubble.
Teufelsberg's most distinctive feature is a collection of 'randomes' – enormous listening domes, now dilapidated and broken, but still strangely beautiful – which, like so many of the locations on this list, are plastered with street art.
Despite its dilapidated state, however, there's an entry fee to visit Teufelsberg as the site is now privately owned. Guided tours are also available.
10. Urban Nation
Rounding up our list is a relatively new addition to Berlin's cultural landscape, having only opened its doors in 2017. Capitalising on Berlin's global reputation on the street art scene, Urban Nation is the world's first museum dedicated to all genres of urban contemporary art: graffiti, paste-ups, sculptures, acrylic designs and more.
For over a decade, Urban Nation has championed street art in Berlin and helped transform the once-depressing, Cold War-era concrete cityscape by inviting high-profile muralists to make their mark. Now the organisation has its own free-to-enter permanent space, which features the works of 150 international and local artists.
20 tools to make you more creative in 20185 fantastic design fails – and what we can learn from themThe top 20 US design studios of 2018
Leeds United has nearly hit its centenary, so to celebrate, the club decided it was time to redesign its badge (above). Despite referencing the 'Leeds Salute', however, the new crest has not been well received by fans.
Unveiled today, Leeds United's new crest took six months of work to complete and involved consultation with more than 10,000 people. For the uninitiated, the 'Leeds Salute' referenced in the new crest is a gesture used by fans on match days, where they place their right hand on heart and sing the club's song Marching on Together.
The redesigned badge is the latest in a series of efforts by the club to re-engage fans and the wider community. Leeds United isn't the first sports organisation to rely on a rebrand to boost interest, of course. Earlier this year, Formula 1 changed its logo to get more people involved.
Leeds United managing director, Angus Kinnear, said “updating the crest is not a decision we have taken lightly, but we are proud to have a new crest that is authentic to Leeds United and honours the quality and loyalty of our fans. It is a symbol of ‘strength in unity’ and a proud expression of the club’s identity and history.”
Currently, however, the only thing Leeds United fans are united by is their dislike of the new crest. Plenty have taken to social media to voice their despair, with some taking aim at how the emblem can be modified to represent other teams. (A popular one sees a Newcastle supporter punching a horse.)
One element that's caused anger and confusion is the crest appears to be covering itself up. If a fan or player does the 'Leeds Salute', of course, by its very nature the gesture obscures the badge – but when it comes to design, blocking your team's badge is a peculiar way to show pride.
With a petition to stop the new badge from being implemented having already racked up over 10,000 signatures, it remains to be seen whether the club holds its ground or gives in to fan pressure.
Photography book celebrates the joy of footballThe 20 posters of the FIFA World Cup5 great EPL football stadium illustrations
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/WiXCTL7xeOg/
Webfonts are all the rage these days for practically every website. We often use them for page headings as well as body text. But you can also use them for code snippets.
Most designers never think about changing the default code text style, but it’s pretty simple with Google Fonts. Not to mention these fonts are free to download and use locally if you’d like to change the font in your IDE.
This is my list of the 10 best options for coding fonts – all available for free. Have a look and see what you think!
The free PT Mono font is an excellent place to start. It’s clean, sharp and very easily blends into any layout.
You may notice there is some odd spacing between certain letters – like the “L” and “E” characters. But this only appears when the text is larger and is not very noticeable at smaller sizes.
I’ve never seen this used for code snippets, but it’s definitely one of the sharpest fonts on the list. It would be excellent for code or even page headers, if you like the design.
Here’s another example of a font that can work well in any format. Fira Mono has been designed for use as a monospaced code font, but the bold style looks nice with headings too.
When you resize this font down to around 12-16px, you’ll notice it actually makes a nice navigation link style, too. Specifically, it works well if you use the bold format and have all of your links in uppercase letters.
This is a great font choice for any site and can be useful for more than styling code snippets.
Cutive Mono is a much more traditional monospaced font. This is typically what I think of when looking for a typeface for code snippets.
This font’s thin letter forms with even-spaced glyphs are perfect for any site. You can organize your code properly with this font and it works very well under syntax highlighting.
The only caveat is that when you resize this font to smaller sizes (below 15px), it can be almost impossible to read. Not to mention the letter spacing looks a bit silly at that size. So you’ll probably want to adjust that using the CSS letter-spacing property.
This is one heck of a font with one pretty cool name. Inconsolata was originally designed for print code listings but has since become a great choice for programmers and IDE fonts.
It works nicely on the screen and should work flawlessly on a website. No matter how large your code snippets or where you’re using them, Inconsolata is a great choice.
You can use the font in regular or bold format – they both look great at all sizes. I personally prefer the bold font when it’s smaller than 15px, but you can always adjust contrast to make it more readable.
One of the few listings that I didn’t track down through Google Fonts, Hack is a true programmer’s font family.
This is a typeface truly designed for code and can be used on any platform – web, mobile or in your desktop IDE.
You can grab a copy from the main GitHub repo, along with further details regarding the font’s development. The font is multilingual, with support for over 1,500 glyphs (and counting!)
This one is well worth testing, even if you only use Hack for a few projects.
The Gohufont typeface is an excellent pick for that “classic” monospaced look. This reminds me more of the old school Nintendo fonts or the typefaces you’d see within old Gameboy games.
If you look over the main page, you’ll find examples with an auto-resizer. You can test the font at 11px or 14px to compare the differences. This includes all-caps and lowercase letters, along with special symbols.
I actually don’t like this much for an IDE, but it can work well on a website. Or, you might also try using this in your terminal window. Gohufont works really well as a CLI typeface since it matches perfectly to all programs.
Source Code Pro
This is perhaps the most famous monospaced font in Google’s entire library. Source Code Pro comes in a bunch of different styles, ranging from super thin to ultra bold.
You can restyle this font family to suit your needs and to match your site’s code tags. If you have any syntax highlighting plugins, this font will work flawlessly.
Note that Source Code Pro was designed as a companion piece to the original Open Sans font. So it works really well on websites that use Open Sans or any of its variations.
I’ve tested the Overpass Mono in my code editor and it works really well. Granted, I’ve never tried using it in a website layout. But I imagine it can work just as well for that, too.
Overpass Mono is an excellent choice, in that it has a variety of styles without veering too far away from a traditional monospace font. It looks just like any other monospace typeface, except it really has its own “feeling” that grows on you over time.
Give it a shot on your website or try it side-by-side in two different IDE windows. You may find that you like this even more than your default font.
With the Oxygen Mono typeface, you get a design very similar to Overpass. The biggest difference is the lack of stylization and fewer formatting options.
This font only comes in one format: normal. You can still bold or italicize the font, but it will be rendered through CSS – rather than through a font file. I recommend this for the web because it’s smaller and easier to blend with different color schemes.
Not to mention it can work just as well alongside any font stack you choose.
I’ve saved the most unique font choice for last with Anonymous Pro. This is a pretty darn creative typeface and it’s one of the easiest fonts to recognize.
One minor complaint I have is the lack of “crispness” of the letters at smaller sizes. You can still recognize the letters and it works fantastic as a code font. But it’ll stand out from all the others in this list, especially anywhere below 12px.
On the plus side, this font straddles the line between monospaced, serif and sans-serif. It borrows ideas from all of them, so you can get this to fit in anywhere on your site.
Over the past few years, the development of a REST API for WordPress has opened new doors for developers. Developers who had previously been limited to writing a WordPress-powered project in PHP now have more flexibility and control in how they can approach the technology stack of their website-to-be.
This means it’s possible to retain all the advantages of the brilliant WordPress control panel, which is made extremely flexible by popular WordPress plugins such as Advanced Custom Fields, and have a completely custom built frontend that only interacts with WordPress when it needs to.
Download the tutorial files
Once completed, you should have created a lean, simple SPA, which has all the reactivity of Vue.js, while displaying posts retrieved from and managed by WordPress.
01. Set up workspace and dependencies
First things first, you should download the project’s files and open them in your preferred editor.
In the console, cd into website-template and run the command below to install the project’s node dependencies (if you don’t have Node installed, do that first). We’ll be working purely in the src directory from here on out.
02. Install Vuex
Next, using the command below, we’ll install Vuex, which is a state management pattern and library for Vue.js applications. This will act as a central information store for all Vue components that depend on the data we receive from WordPress API. For developers familiar with React, Vuex is heavily inspired by Flux.
03. Start development server
In the console, run the command below to start the development server. This will compile the Vue.js project as it currently stands and assign it to a URL so you can access it. This is usually localhost:8080.
One big advantage this brings is live reloading, so once you make changes to the app and save, the page in your browser will update itself without the need to manually reload.
04. Create Vuex store
In src, create a directory called store and within it a new file called index.js. This will be where our Vuex store will be defined. Though before we get to that, we need to first make sure our Vue.js app is aware of its existence. To do this, open main.js and import the store and include it as a dependency, as in the snippet below.
05. Create store scaffolding and install Axios
To help us simplify the AJAX requests our store will be making to WordPress API, we’ll install Axios, which is a Promise-based HTTP client. To do this, open a separate console window, navigate to the website-template directory and run npm install axios — save.
Next, let’s start to scaffold the store by instantiating a new empty Vuex store object. At the moment, it isn’t doing anything, but at least Vue should be aware of it.
06. Create posts state
In Vuex, the state object holds application info, which in this case will be the WordPress post data we’ll grab using the API. Within this object, create a new property called posts and assign it a value of null.
07. Create getPosts action
In Vuex, actions are the main way in which asynchronous requests are handled. These are typically methods defined in the store, which can then be dispatched as required by the app.
In the empty actions object, let’s define one where if our posts state is still null, axios is used to perform an AJAX request to the WordPress API and return a list of posts. Once we’ve received a positive response, we’ll then resolve the promise and commit the posts using the storePosts mutation.
08. Create storePosts mutation
Another concept introduced by Vuex is mutations, which are also typically methods defined in the store. Mutations are the only way to change state in a Vuex store, which allows state to be easily tracked when debugging.
In the empty mutations object, let’s define the storePosts method we referenced in the previous step and make it override the post property in the state object with any data the mutation receives as payload.
09. Trigger getPosts action on load
We’ve created the action and mutation methods that grab posts from WordPress API and commit them to Vuex state, but now we need to actually trigger this process somewhere. In the top level Vue.js component App.vue, add the snippet below.
created() is a lifecycle hook that triggers code as soon as the Vue component is created on load, while the use of the global $store variable allows us to access the contents of our Vuex store and dispatch the getPosts action from step 7.
10. Update attribute paths
The Vue DevTools extension gives you the power to debug your Vue.js app
If you’re working in Chrome or Firefox and have the Vue.js DevTools extension (if not, I recommend that you do as it’s very useful), you should now be able to see the loaded WordPress posts in Base State under the Vuex tab.
Back to the app, in /components/posts/posts.vue, the template HTML needs to point to this data, so let’s tweak a few of the attribute paths.
11. Update v-for loop
In the posts component, there’s a Vue.js directive in use called v-for. This loops through all posts and for each one prints an instance of the post component, displaying them in a list.
We need to update the path passed to this directive as it’s still using the local dummy test data. Update the v-for directive to the snippet below in order to point to our stored posts in the Vuex store.
12. Do some housekeeping
A list of the WordPress posts should now be displaying. As we're no longer using the local post data, let's delete src/data. Then in the posts component, remove the posts: postData.data property in the components local data store and then the postData import.
13. Fix post author
You may notice that for each post the author is showing up as a number. This is because the WordPress API returns an author ID, rather than a name. We need to use this id to query WordPress for the full author information. Let's start by creating a place to store this in our Vuex store, alongside our post info, in store/index.js.
14. Create getAuthors action
As with posts, we'll create an action in /store/index.js to trigger an AJAX request to query WordPress API. Once a successful response is received, the promise will then resolve and trigger the storeAuthors mutation, which we'll create next.
15. Create storeAuthors mutation
Within the mutations object of the Vuex store, create the storeAuthors mutation using the snippet below. Like with storePosts from step 8, this takes the payload its passed and sets it as the value of the authors property in our store's state.
16. Trigger getAuthors on load
We need to get the author info from WordPress as soon as the app begins to load. Let's amend the top level component App.vue again and dispatch the getAuthors action in the same created() lifecycle hook as the getPosts action.
17. Create getUserName method
Now we're querying WordPress for author information on load, all we need to do is define a method in our posts component which lets us pass an author ID and get a name in return. Copy the snippet below into the posts component's methods object, below the existing getSinglePost method.
18. Call getUserName method
Now we just need to call getUsername. Still in the posts component, in the template, replace the author attribute’s reference to post.author so it reflects the snippet below. The author’s name should now be correctly displaying for each post.
19. Blog loading
As we’re loading the post data asynchronously, there is a moment before the request completes where the application is empty. To counter this, we’ll implement a loading state that's active until the blog is fully populated. In the posts component, paste the snippet below just after the opening <script> tag to import the icons we’ll be using.
20. Add icon to components list
Next, still within posts, add a reference to icon in the components objects. This makes the posts component aware of our recently imported icon component.
21. Create loading elements
We now just need to add the loading elements to the posts template so it shows up on the page. Firstly, wrap the second div in the snippet around the two divs with the v-if directives to make sure no posts show up until loading is complete.
Then add the first div from the snippet above it. This contains the loading icon and a v-if directive, which means it will only be visible until the point where the app is fully loaded. Once done, loading should now be implemented.
22. Update single post attribute paths
The only thing left to do is to make sure single posts are correctly set up so they are using the WordPress post data in the Vuex store. The first step is to update the attribute paths in the posts component template within the v-if="this.type === 'single'" div, which handles the display of single posts.
23. Refactor getSinglePost method
We also need to refactor the posts components getSinglePost method. It needs to return a promise that dispatches the getPosts action. In the follow up then function, we'll search the Vuex store's posts for an entry with a slug matching the one passed in the URL. If found, we'll copy the data to our component's local state and resolve the promise. If it isn't found, the promise will be rejected.
24. Refactor posts created() hook
Next, we need to refactor the created() lifecycle hook in the posts component. If we're needing to display a single post, the hook should call the getSinglePost method from the previous step, and if its promise is rejected, send the user to the 404 'page not found' page. This is to account for scenarios where users enter a non-existent post slug in the URL.
25. Add v-if directive
The final step is to add the snippet below to the post component within the v-if="this.type === 'single'" div in the template. This directive means the post will only display when the local post data made available by the getSinglePost method is populated. This is to stop Vue from prematurely rendering the component and thus causing errors.
26. Build the app
Now with everything working, in the console, cancel the npm run dev command or open a new console and run the below command to generate a production ready version to upload to your own server. This will appear in the dist directory.
This article appeared in issue 268 of Web Designer, the creative web design magazine – offering expert tutorials, cutting-edge trends and free resources. Subscribe to Web Designer now.
32 best free WordPress themes10 top WordPress resourcesThe 14 best free blogging platforms
Once upon a time, there lived a web developer who successfully convinced his customers that sites should not look the same in all browsers, cared about accessibility, and was an early adopter of CSS grids. But deep down in his heart it was performance that was his true passion: He constantly optimized, minified, monitored, and even employed psychological tricks in his projects.
Then, one day, he learned about lazy-loading images and other assets that are not immediately visible to users and are not essential for rendering meaningful content on the screen.