Simple Tips for Developing Plugins and Themes Against WordPress Trunk

Simple Tips for Developing Plugins and Themes Against WordPress Trunk

If you often develop plugins or themes for WordPress, you may have heard about one of the strategies that are often recommended, which is doing so against trunk of WordPress. This practice often works best to any web developers or someone who is looking for ways to improve their development practices. Not to mention how easy you can view the source code on the web at any time, since WordPress is open source software.

Besides, you can also work with it easily as you can download it to your local computer. Therefore, in this article we would like to describe how to work with the current snapshot of code with WordPress and why it may be beneficial to use this codebase when working on projects of others. So, if you are curious to know how to develop plugins and themes against WordPress trunk, you can continue reading the article below.

Developing Against WordPress Trunk

We recommend you to have Subversion or a Subversion client installed before getting started. By having a package manager like Homebrew to handle software and a command-line client, you can easily enter this in your terminal:

$ brew install subversion

If you are looking to use a front-end, you can also use something like Versions or Cornerstone. Below are the steps that you have to follow:

Download the Latest Code

Download the latest snapshot of the WordPress codebase by using this command:

$ svn co https://core.svn.wordpress.org/trunk/ .

However, if you’re using a front-end then you might need to use the following URL in your client of choice to browse the repository:

https://core.svn.wordpress.org/trunk

Then, you can download the contents of the trunk directory to your computer and prepare to install it on your computer.

Or you can use your front-end of choice:

Web developer tips

In order to do this, you have to make sure that a database is prepared and then walk through the standard installation procedure.

Setup Debug Mode

After all is installed, you can set your WordPress into debug mode, so you are able to see information in the debug logs as well as in your browser.

To do this, you can open wp-config.php and change the line that reads:

define( ‘WP_DEBUG’, false );

To read:

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

@ini_set( ‘display_errors’, 0 );

define( ‘SCRIPT_DEBUG’, true );

At this point, you will see information printed out to the screen every time you’re working with code and every time you have information written to debug.log which you can also view in your preferred text editor or console.

Work with the Proper Directories

After all of your WordPress is set, you’re ready to work on your project, note on whether or not you’re working plugins or themes. Furthermore, in general, you’ll find each in wp-content/plugins or wp-content/themes.

Web development tips

For instance, if you’re working on a plugin then you’re going to keep your plugin in the plugins’ directory. You can see on the screenshot above that you may need to use Scheduled Post Shortcut against trunk.

A Word about Stable Versions

So, whenever you are working with a plugin or a theme that runs against a stable version of WordPress, remember the choices you have to make:

  • Work against the stable version of the code that’s available at WordPress.org.
  • Work against the snapshot of code in trunk.

If you happen to use the former, then your code is going to work with the latest stable version. However, if you choose to work with the latter, then you will need to work with the upcoming version of WordPress in order to make it work. However, remember that things can change between what’s in trunk and what’s ultimately released. Therefore, if you prefer to work with trunk, you may need to keep testing your work against the code until the core team tags trunk as a stable version.

4 Brilliant Image Optimisation Tips

4 Brilliant Image Optimisation Tips

A fast loading website is what everyone is looking for; no one loves to wait even for a little more seconds to have their site loaded. Therefore, many web developers and web designers think about how to make faster loading websites. This situation can be obtained through many ways; one of them is to focus on image optimisation. With a good image optimisation, many believe that a site can load faster.

So, whether you’re building full-size e-commerce websites or simply learning a few tips about it, you have to make sure  your images load faster.

Be Selective and Preload Critical Images

First, you need to take a look at your site, then identify if there is any critical image asset.  In most cases, logo or hero images are usually the critical image assets where the preload resource hint comes in. Preload is actually a way of hinting to the client that an asset should be retrieved before the browser parser would otherwise discover it. Therefore, you can use it for almost everything, but most of all, it works amazing for preloading critical imagery. The example below will show you how to use it in the HTML <head> element on order to preload a hero banner image:

Image optimisation

Furthermore, you can also use preload in an HTTP header:

Web design tips

Below, we present two screenshot rolls of the same page loading in Chrome. You can see the different result between the two, since one scenario uses preload to load a hero banner image, while the other doesn’t.

web design tips 2

Tips for web designer

From the example above, with preload the banner image appears in the browser window half a second faster, since a quick one liner gives the browser a head start.

Tips to optimise images

Different from optimising JPEGs or PNGs, SVGs are comprised of text, specifically XML markup which means that typical optimisations you would apply to text-based assets can and should also be applied to SVGs. Beyond that, to tamp down the size of SVGs, you can use an optimiser, such as SVGO. However, if you are not only using vector artwork, but also creating it, you can automatically simplify your artwork to reduce the amount of anchor points in paths via the Simplify dialog window.

If you are using Illustrator CC, you can find this dialog’s menu by going to Object>Path>Simplify. By reducing Curve Precision, it is possible to remove extra path points in your artwork. If you want to remove extra path points in your artwork, you can reduce the Curve Precision, then optionally adjusting Angle Threshold. For example, if you reduce the Curve Precision of as little as 6%, you will remove 54 path points. Therefore, whenever you want to improve the appearance of your artwork, you can use judiciously.

image optimisation tips

Please remember that this tool will run aggressively, so at first, you might need to lower Curve Precision too much and once you are carefully crafted, artwork will devolve into a blob. You’ll read the rewards, as long as you strike the right balance.

Convert Animate GIFs to Video

Everyone loves a good animated GIF, since they can convey almost any sentiment using that. However, in terms of loading, they can really make your loading run so slow. Therefore, image optimisers such as gifsicle can help you shave off excess kilobytes by converting those GIFs into videos and embed them in the HTML5 <video> tag. The ffmpeg command line utility is well suited for this task:

brilliant tips to optimise images

The example of the commands above takes a source GIF (animated.gif) as input in the –I argument, and output videos with a variable bitrate maximum of 512 Kbps. In a test, a 989 Kb animated GIF is able to reduce to a 155Kb MP4, a 109Kb OGV, and an 85Kb WebM. This makes all video files comparable in quality to the source GIF. Therefore, since the ubiquity of <video> tag support in browsers, you can use these three video formats, as follows:

Image optimisation

If you want to try the command above, remember to order your <source> tags, so that the most optimal format is specified, and the least optimal is specified last. Therefore, you will start with WebM videos first, but check the output file size of each video and go with whatever is smallest first and end with whatever is largest. So, wait no more to install the FFmpeg if you don’t have one.

Lazy Load with Intersection Observer

Most of us may have done lazy loading images, but many lazy loading scripts use CPU-intensive scroll event handlers. Such methods can contribute to sluggish interactions on a page. In fact, older hardware with less processing power is even more prone to the ill effects of this type of code. Even though execution throttling does help, it’s still messy and rather inefficient workaround for determining when elements are in the viewport.

Fortunately, with Intersection Observer API, you can have a simpler and far more efficient way to determine when elements are in the viewport. Below is the example of some basic lazy loading image markup:

<img class=”lazy” data-src=”/images/lazy-loaded-image.jpg” src=”/images/placeholder.jpg” alt=”I’m lazy.” width=”320″ height=”240″>

Here, we would like to load a placeholder image in the src attribute, and then store the URL for the image we want to lazily load in the data-src attribute.  The <img> element a class of lazy for easy access with querySelectorAll is given to top it all off.. Then, we can simply use this code:

document.addEventListener(“DOMContentLoaded”, function(){
if(“IntersectionObserver” in window && “IntersectionObserverEntry” in window && “intersectionRatio” in window.IntersectionObserverEntry.prototype){
elements = document.querySelectorAll(“img.lazy”);

var imageObserver = new IntersectionObserver(function(entries, observer){
entries.forEach(function(entry){
if(entry.isIntersecting){
entry.target.setAttribute(“src”, entry.target.getAttribute(“data-src”));
entry.target.classList.remove(“lazy”);
imageObserver.unobserve(entry.target);
}
});
});

elements.forEach(function(image){
imageObserver.observe(image);
});
}
});

Here, we bind code to the document object’s DOMContentLoaded event in which this code will find out if Intersection Observer is supported by the current browser. We can grab all img elements with a class of lazy with querySelectorAll and then attach observers to them.

The observer contains reference to the elements we’re observing (entries) and the observer itself (observer). This code hinges on each observer entry’s is intersecting value. The observed element is intersecting returns 0, when the element is out of the viewport. It will return a value greater than 0, as the element enters the viewport. Then, we can swap the content of the image’s data-src attribute into the src attribute, and remove its lazy class. You can remove the observer with the observer’s unobserved method.

By using this method, you are choosing a much more easier method than mucking around with scroll handlers. So, hopefully, the methods above can be the best alternatives for you to optimise your images. Good Luck!

5 Ways to Optimize Your Business with Instagram SEO

Today, Instagram has been so popular among other social media; in fact, its popularity has clearly beaten Facebook. It shows how people are getting more interested in images than words. No wonder many companies and business owners see this media as a tool to promote their products. For some companies, their products might be sold very well, but others may find themselves still struggling in getting involved. Why? Surely that creativity matters a lot in this media, but not everyone knows that there are some SEO aspects in this strategy. It doesn’t mean that the work might be as hard as SEO service does, but at least you have to know some basic SEO strategies on Instagram that you will find it important to elevate your business promotion. Here are the things you should know:

Do Keyword Research on Hashtags

It can be said that keyword research is one of the traditional SEO techniques onto the network. Even though Instagram is not a search engine,  it does have a search function. You can search anything you want with hashtag “#” put initially before typing for  a keyword. For maximum exposure, you can utilize the hashtags that are getting the most search volume and that are relevant to your photos. Another cool thing as opposed to keywords is that you can add many hashtags up to 30 hashtags at the end of your post. You don’t have to worry about keyword stuffing, for you can simply list the hashtags at the end of your post.

On Instagram, you don’t have to use keyword planner, for you can determine which hashtags that will be relevant. The important thing is never over-used the keywords. Furthermore, you may not have Keyword Planner like you usually have for Google. Therefore, it enables you to determine which hashtags are relevant, but not overly-used.

You can create your own, unique hashtag, but this means you have to compete with other big brands. However, you can ask people to use a specific hashtag in a contest; you could start carving out your own hashtag to get going in the future, which brings us to our next point.

Hold Contests for Prizes

You may have heard this tactic as this is a common social media tactic, but why do we keep mentioning this again? It’s because many companies are still not offering prizes on Instagram. Remember that prizes will go a long way on social media, so create a contest and spend some money here. You can follow what Neil Patel do; he leveraged his giveaways to get more followers and “a single giveaway could score a few thousand extra followers.”

You can select variety of ways to create a contest for social media, but choose the one that will work best on Instagram. Usually, the contest might put focus on images and hashtags to get the most engagement.

Partner with a Nonprofit or Charity Organizations

Companies that support communities usually get more likes from people. For example, you can help  nonprofit or charity organizations that are still related to your industry. This strategy is great for your business and your website in general, but it’s especially helpful on Instagram because images can be so powerful. Furthermore, it’s a good strategy as any partnership could work if done right as long as they are not your competitor.

Make Use of Instagram’s Business Tools for Advertising

Many people usually use it for connecting with the audience through stories, relevant photos, utilizing the right filters and getting the images out of the right people, and then the next step is oftentimes paid advertising. Even though this is the most common facilities, you can also try other features that are created specifically for businesses. Through these features, you can see metrics on how certain posts are performing, so they’re essentially the Insight option of this social platform, and they’re available to everyone. You can find many data for your paid advertisements, such as impressions, engagement and shares, reach, insights, and more.

Buy an Instagram Account with Already Established Followers

Another idea that is also quite popular is buying audience. You can buy audience from an established account, but the biggest problem with this approach is that the audience may be completely irrelevant with your business. No wonder in many cases, once the account is changed, you will likely lose the followers. This is because the audience considers your activities not interesting to them anymore.

Try Influencer Marketing

Using influencer marketing is also another great idea. Many companies partner with influencers within their niche and in turn, the influencer promotes the business. This is because some companies know that when an influencer promotes a brand’s product or service, it works like recommendations in a natural way. In fact, influencer marketing helps build a strong link profile and increase the overall reach and impact of your content. Moreover, this type of campaign will leverage your business credibility and appeal among audience.

Use the Instagram Storiy Feature to Personalize the Brand

A recent feature on Instagram has enabled businesses with a channel to bring their brand to life. This strategy will prevent you from flat posting on Instagram or spammy postings. Story is a great form to space out posts while still staying active. Besides, it helps businesses seem more personable to audience.

So, how does social media relate to SEO especially in this case,  Google? Actually, Google never says clearly whether or not search engine algorithms account for social signals. However, since search engines are continuously tailoring the search experience to be more personal and specific to its users, so it’s entirely possible that social signals will eventually have a part in SEO.