Quantcast
Channel: Envato Tuts+ Code
Viewing all 5161 articles
Browse latest View live

Scrape the Web at Scale With the scrapestack API

$
0
0

Introduction to Web Scraping

Businesses need better information to target and reach wider audiences. They get this information by scraping the web for content from social media platforms, eCommerce platforms, video platforms, travel platforms, review and ratings, and more.

Web scraping is simply collecting information and data from around the web. It can be done manually, but this is complicated and time-consuming. Automatic web scraping is great, but there are some tricky problems that can arise when you try bulk scraping web data:

  • some websites block web scrapers or limit the number of requests per second
  • some content may be rendered dynamically in the browser and may not appear in a scraper

Here is where the scrapestack API comes in! With scrapestack, you don't have to worry about the tricky programming issues that arise because they are handled by the API provider.  

Using the scrapestack API, you can quickly and efficiently scrape web pages worldwide in milliseconds and turn them into actionable data that you can put to good use. All you need is to input a website URL and the results will be revealed. 

There's a reason why the scrapestack API is trusted by over 2000 satisfied customers. You won't have to worry about IP blocks, proxy-related issues, geolocation, or strategies like IP rotation or retries again.

What Is the scrapestack API?

scrapestack

scrapestack is an API service that allows customers to scrape websites efficiently at unparalleled speeds without having to worry about technical issues like proxies, IP blocking, geo-targeting, CAPTCHA solving and more. Simply send a valid URL and the scrapestack API will return its full HTML content as a response. 

With the scrapestack API, you can scrape:

  • social media pages of platforms like Facebook, Twitter, and Instagram
  • video platforms like YouTube
  • search engines like Google, Bing, and so on
  • eCommerce platforms like Amazon, eBay, and more
  • travel websites like TripAdvisor and Booking.com
  • and many more!

scrapestack is powered by the apilayer cloud infrastructure, making it highly scalable and capable of handling anything from thousands of API requests per month all the way to millions of API requests per minute. 

In addition, the API supports a series of features essential to web scraping, such as: 

  • JavaScript rendering, custom HTTP headers, various geo-targets 
  • POST/PUT requests 
  • an option to use premium residential proxies instead of datacenter proxies

What Can You Use the scrapestack API For?

scrapestack API

There are so many ways the scrapestack API can help you. The following examples are just the tip of the iceberg.

Building a Business

Aggregator websites are built and sustained by drawing data from thousands of sources. They need to continuously extract data by web scraping otherwise they would not exist. Some examples include comparison websites like Kayak and Booking.com, or job board websites like Monster.com

Lead Generation

With web scraping, you can build a database of business leads and exponentially boost your sales and marketing efforts.

Brand Monitoring

You can extract customer reviews and ratings of your products from multiple platforms and aggregate them. This data will help you implement ways to improve your brand image. 

SEO Advantage

You can find out what tags and keywords your competitors use to drive traffic to their website. You can also analyze your SEO to see how your content is performing.

Features: Why Use the scrapestack API?

The scrapestack API boasts 2,000+ satisfied customers, and for a good reason. The answer is in the incredible features. Let's have a look at some: 

35+ Million IPs and Proxies

Tap into an extensive pool of over 35 million proxies and IP addresses worldwide and ensure the highest level of scraping consistency. 

195+ Geolocations

The API supports nearly 200 geo-targets worldwide, including eight major cities. Choose your location and start scraping local results right away.

Datacenter and Residential Proxies

Make use of standard datacenter proxies or go for the premium option of using residential proxies that are tied to a real device and residential address, further lowering the risk of getting blocked by the scraping target.

Rock-Solid Cloud Infrastructure

Thanks to the superior cloud infrastructure on which the API is built, you will receive results in lightning fast speeds of milliseconds.

Scalable

Highly scalable, it can handle thousands to millions of API requests per day.

JSON Format

Results are organized in structured data that can be analyzed easily.

Monitoring

The API is closely monitored around the clock to ensure the highest possible level of consistency and availability. 

99.9% Uptime

The scrapestack API handles over a billion requests per month and consistently reports the unbeatable record of 99.9% API uptime.

Concurrent Requests

Send concurrent API requests to scrapestack and ensure the highest level of speed every time you use it.

JavaScript Rendering

The API will return HTML data exactly as it would be shown in the browser by rendering JavaScript, which is executed on the target web page.

Superior Security

The scrapestack API uses industry-standard 256-bit HTTPS (SSL) encryption.

Easy Integration

The API is fast and easy to set up. You will be ready to start using it within five minutes. It supports several languages out of the box, including PHP, jQuery, Node.js, Python, Go, and Ruby. 

Well Documented

The API comes with extensive documentation to guide you on how to use it. 

How It Works

turn web page into actionable data

The scrapestack API uses the popular JSON format. Results are organized and displayed in an easy-to-understand format and processed in common languages such as JavaScript.

Using the scrapestack API: An Example

Here is an example of the information returned from a scrapestack API request.

scrapestack

It's very easy to get set up and start using scrapestack. This short tutorial will show you how. 

To get started, first sign up for a free account at scrapestack. Once you've registered, you'll be taken to the scrapestack API quick start screen. From here, you can get your API key and try some example API queries.

Make API request

Now you can perform a request. The most basic form of request is called "basic request". Using your API key, you can make a simple API request that scrapes the Apple website as an example.  

The quick start guide shows the following format for the query.

Scrapestack request returned

If your scraping request was successful, the API will respond with the raw HTML data of your target web page URL. If you have enabled HTTP headers, your API response will also contain the HTTP headers sent along with your original API request.

Here is what an actual response includes: all code within the <head> and <body> sections.

successful scrapestack response

For specific integration guides and code examples, please have a look at the scrapestack API documentation.

Note that requests you make on the free plan are not encrypted, so you must use the HTTP protocol for free requests. If you try to use HTTPS, you will get the message that "Your current subscription plan does not support HTTPS encryption". If HTTPS is important to you, then you'll need to go with a paid plan.

Pricing

The scrapestack API has several subscription plans. The Free plan allows you to test the waters to get familiar with the API. It offers the basic functionality of the API, including 1,000 API requests per month and very limited support. 

scrapestack - Real-time, Scalable Proxy & Web Scraping REST API

If you need more advanced features such as concurrent requests and access to premium proxies, you can choose from the following subscription plans: 

Basic: This plan includes additional features like 200,000 requests per month, unlimited support, HTTPS encryption of all your requests, JavaScript rendering, and over 100 geolocations. The plan costs $19.99 per month, or $15.99 per month if billed yearly. 

Professional (Most Popular): On top of all tools available in Basic, you also get 1,000,000 API requests per month. The plan costs $79.99 per month or $63.99 per month if billed yearly. 

Business: This plan gives you all the tools available in Professional and 3,000,000 monthly requests. It costs $199.99 per month or $159.99 per month if billed yearly.

Enterprise: If none of the other plans are adequate, you can get custom pricing that's tailored to your needs. 

Conclusion

The scrapestack API is trusted by 2,000+ companies. It allows customers to scrape websites at lightning fast speeds, without having to worry about technical obstacles. It has the most reliable extensive network of 35 million data centers and premium proxies in over 100 countries where customers can send API requests and receive results in milliseconds. It's built on a rock-solid cloud infrastructure, allowing it to handle over 1 billion requests per month. 

If you're still on the fence, you can try it for free and see if it works for you. 


Create a Sticky Note Effect in 5 Easy Steps with CSS3 and HTML5

$
0
0

In this tutorial, you'll learn how to transform an HTML list into a wall of "sticky notes" that look and work like the following:

The effect is built up gradually and works on all the up-to-date browsers like Chrome, Safari, Firefox and Opera. Older browsers simply get some yellow squares.

Step 1: The HTML and Basic Squares

We will be using some common CSS properties that work across all browsers. As we are using HTML5 for the effect, the basic HTML of our sticky notes is an unordered list with a link containing all the other elements in each list item:

Notice that each note is surrounded by a link. This is a a good element to use for interactive items, as it automatically means that our notes become keyboard accessible. If we used the list item for the effect we'd need to set a tabindex property to get the same access.

The CSS to turn this into the yellow squares is simple:

We reset things the browser normally gives us like margins and paddings and the list style to get rid of the bullets of the list.

We want the list items to be side by side. We would have used the float property to achieve this a while back. However, we can now use the much more powerful flexbox layout module now. This makes it very easy for us to place elements in a two-dimensional layout.

All we have to do is set the display property to flex on the ul element. This will place all our list items in a single row. The list elements will start to overflow at some point. The best way to avoid that is to use the flex-wrap property and set its value to wrap. Extra elements will now keep moving to next row instead of overflowing.

We style the link as a yellow rectangle and float all of the list items to the left. The result is a series of yellow boxes for our list:

Sticky Notes: Basic Yellow Boxes

Flexbox is supported in all major browsers today. This covers around 98.5% users at the time of writing this tutorial. If you need to support older browsers, you can consider using float to lay out the elements.

Step 2: Drop Shadows and Scribbly Font

Now it is time to add a drop shadow to the notes to make them stand out and to use a scribbly, hand-written font as the note font. For this we use Google Fonts and the fonts they provide us with, called "Reenie Beanie" and "Lato".

Google Fonts

Using this, we get a simple line of HTML to include this new font into the page. This is supported by all modern browsers.

We then can set some padding to the headings in the sticky notes, and set the font of the paragraphs to the new font we included. Notice that Reenie Beanie needs to be big to be readable:

In order to give the sticky notes a shadow to make them stand out from the page, we need to apply a box-shadow. Most browsers in use today support this property without use of prefixes.

The box-shadow property sets the offset, spread and color of the shadow. In this case a dark grey with an opacity of 70%. Together with the new font our sticky notes now look like this:

Sticky Notes: Box Shadow

Step 3: Tilting the Notes

Both the tilting of the notes and the zooming we'll add in the next step were already explained in the past, in this article by Zurb. So big thanks to them for publishing this trick.

In order to tilt an element you use the transform:rotate property of CSS3, again adding the prefix for each of the browsers:

This tilts all the links by six degrees to the left. Now to make the sticky notes appear to be randomly tilted, we can use the nth-child property of CSS3:

This tilts every second link four degrees to the right, and offsets it a bit by five pixels from the top. Every third link gets tilted by three degrees to the left and pushed up five pixels. And every fifth link gets rotated five degrees to the right and offset ten pixels from the bottom. All in all this gives the impression of random sticky notes:

Sticky Notes: Random Rotations

Step 4: Zooming the Sticky Notes on Hover and Focus

To make a sticky note stand out we use a larger drop shadow and the scale transformation of CSS3.

We also add a higher z-index to ensure that the enlarged sticky note covers the others. As we apply this on hover and focus, it means that moving the mouse over or tabbing to a link now makes it stand out:

Zooming the Sticky Notes

Step 5: Adding Smooth Transitions and Colors

The last step is to make the change from tilted to zoomed smooth and appealing rather than sudden. For this we use the CSS3 transition module in its different browser vendor implementations:

In essence this says: if something is to change to this element, do not just switch to that other definition but do it gradually during a quarter of a second. As another extra, let's add some color into the mix by making every second sticky note green and every third light blue:

Your sticky notes should now look like this image:

Stixky Demo: Random Colors

Step 6: Making the Sticky Notes Editable

The easiest way to make the sticky notes editable is to use the contenteditable attribute on all the links. This will allow users to click inside the title or the content of the sticky notes and change it.

However, the changes won't stick if the user reloads the page. We can change that by using some JavaScript. Load the latest version of jQuery on the webpage and add the following JavaScript after that.

We will be using localStorage to store the data about our sticky notes. The key will be based on the index of our list item and its value will be the title and content of the sticky note.

The above code attaches a keyup event to all the sticky notes. Whenever, a user types something inside the title or content of a sticky note, we get its content using the text() method. This data is stored in the localStorage of the browser by using the index of the sticky note as a key.

Storing the updated list in localStorage serves no purpose if we can't retrieve it and show it to users. The following code will loop through all the list items and check for their corresponding keys in localStorage. If the key exists, we extract our title and content from it and update the HTML of our list item.

With this code in place, you should now try to edit any of the sticky items and reload the pages to see if the changes stick. Here is a screenshot of my sticky notes.

Sticky Notes: Saved Data

Here is the complete JavaScript code that you need to use in one place. Please make sure that you have also are also loading jQuery on the page.

Summary

There you have it—smoothly animating and tilted sticky notes. Alll supported by Firefox, Opera, Safari and Chrome and falling back to a set of yellow boxes in older browsers. By clever use of the nth-child selector and CSS transformations and transitions, we saved ourselves some scripting. Further, Google's Web Font API made it easy to use a custom font. Using both hover and focus for the effect also means that keyboard users can observe the results as well.

We were also able to add some useful functionality to the sticky notes with use of some JavaScript.

While you're here, check out some of our other CSS tutorials here on Envato Tuts+.

This post has been updated with contributions from Monty Shokeen. Monty is a full-stack developer who also loves to write tutorials, and to learn about new JavaScript libraries.

Boost Engagement With WordPress Top Bar and Notification Bar Plugins

$
0
0

Do you want to create eye-catching announcement that your visitors won't miss? Notification bars are used to immediately grab visitors attention and engage them without intruding into their user experience. 

WordPress top bar and notification bar plugins come with lots of customization options that allow you to create professional-looking notification bars. They are a good way to announce important messages, promotions and sales, collect emails, and display a call to action. 

Apex Notification Bar
Apex Notification Bar plugin is an example of notification bar plugins available on CodeCanyon.

Notification bars get the message across without obstructing users from viewing content. 

Top Selling Top Bar and Notification Bar Plugins on CodeCanyon

For a low one-time payment you can increase your lead generation, boost user engagement and conversion rates by adding a notification bar plugin to your WordPress website. 

Bestselling Notification Bar Plugins for WordPress on CodeCanyon

The uses of notification bars are limitless. You can use them to:

  • show important announcements 
  • promote sales, offers or give aways 
  • direct users to landing pages
  • get emails 
  • show cookie consent notice 
  • countdown clock timers to create a sense of urgency
  • display social media icons 
  • and so much more... 

Best Top Bar and Notification Bar Plugins on CodeCanyon

Let's look at some of the best notification bar plugins for 2021 on CodeCanyon. 

1. Adning Advertising

Adning Advertising - Professional, All In One Ad Manager for Wordpress

While Adning is an advertising plugin that allows you to add banners on your WordPress site, you have the option of choosing from a variety of banner styles including floating content and notification bars.

So if you need to show your ads in notification bars you're covered. Adning makes it super easy to add notification boxes anywhere on your website. The notification bars are non-intrusive, integrate into your content perfectly and become part of your posts. 

The system is responsive so your notification bars and banners will work on mobile, tablets, and desktops. 

2. Apex Notification Bar 

Apex Notification Bar

If you're looking for the most comprehensive notification bar plugin on the market then Apex Notification Bar ticks all the boxes. This fully responsive, feature-packed top bar plugin comes with 15 highly customizable templates that you can use to build numerous notification bars. 

You can add multiple notification bars—top, bottom, left, right—on a single page. You also have the option of uploading custom logos, custom background photos, and setting custom URLs.  Various elements such as custom icons, email subscribe form, contact popup, posts title slider, countdown timer, search form, video popup can be added to notification bars you design.

The plugin is compatible with various modern browsers. It integrates with MailChimp, Constant Contact, and Contact Form 7. It is compatible with all WordPress themes. Best of all, you don't need coding knowledge to use it. 

3. Advanced Floating Content 

Advanced Floating Content

A sticky header warning, sticky footer notice or message that floats into the websites? You can create all that using Advanced Floating Content .

This is an all-in-one WordPress top bar plugin comes with a free theme builder which you can use to create stylish floating content in a matter of minutes by choosing from unlimited themes and layouts.

You get the ability to animate your floating content or restrict it to logged-in users only, and even hide it from displaying in certain mobile devices depending on the width and height of the notification bar.

And if you want to display video from YouTube, Daily Motion, or Vimeo into the floating content you just need to embed the code. 

The plugin is WPML compatible so you can translate your floating content into any language you choose. 

4. WooCommerce Free Shipping Bar

WooCommerce Free Shipping Bar

Customers making a purchase usually enjoy getting free shipping. The WooCommerce Free Shipping Bar plugin helps users to see how much more they need to purchase in order to receive free shipping.

When customers add an item to the shopping cart, a progress bar will show them what amount they still need to spend to get free shipping. A success message will display once they reach the minimum amount.

The plugin automatically detects the customer's IP to get the shipping method of their country. The plugin will detect customers’ countries base on their IP Address and display free shipping bar respectively with that shipping zone at country level.

The plugin is highly customizable and works on both mobile devices and desktop. 

5. Facebook Live Video Auto Embed for WordPress

facebook-live-video-auto-embed-for-wordpress

Whenever your Facebook account, Facebook page or Facebook group goes live you can display the announcement to on a site-wide top notification bar. This plugin is perfect if you have an active book club, sell online course, or you're an influencer promoting products on your Facebook live, or even a public discussion forum, and so on. 

This plugin can be used for your Facebook User account or Facebook Pages you own or public Facebook Groups you are an admin of.

6. 8 Degree Notification Bar

8 Degree Notification Bar

Display engaging notification bars using 8 Degree Notification Bar. Using this responsive, feature-rich premium WordPress plugin you can notify your website visitors about your new releases, offers, messages, and news. 

The plugin allows you to create multiple top bars and scheduled notification bars. It is highly customizable and provides multiple notification bar templates with 10 pre-designed templates and custom design features.

Besides, you can add various bar components such as social icons, email subscription form, contact popup form, Twitter tweets and posts title. You can choose from bar visibility types like: sticky, show after some time, or hide after some time. 

It is compatible with many modern browsers and integrates with email newsletter software like MailChimp and Constant Contact. And because the plugin is translation-ready you can translate your notification bar into any language.  

7. Wiloke Notification Bar

Wiloke Notification Bar Plugin

The Wiloke Notification Bar allows you to announce release of a new item, create promotions and so much more. This plugin will display notifications on top of your page.

The plugin has many customization option available including thumbnail image, background image and color, customized links, and a discount countdown.  

Free WordPress Top Bar and Notification Bar Plugins

1. My Sticky Menu

My Sticky Menu

This plugin for headers and menus that stick to the top of the website has added a welcome bar feature that can be used as a notification bar for announcements, promotion and more.

With this welcome feature you can use custom HTML to create a beautiful notification bar for desktop and mobile, change the font size and font family, show a call-to-action button, or redirect your visitors to another URL when they click.

2. Notification X

Notification X

With Notification X you can let visitors know about your special offers, deals, and announcements with a call to action. This top bar solution for WordPress is absolutely free. You can schedule start and end times of your notifications. You will get detailed analytics on how your notification bar performed as well.

3. WP Notification Bars

WP Notification Bars

WP Notification Bars is a responsive, easy-to-use, lightweight custom notification and alert bar plugin for WordPress. It is perfect for marketing promotions, giving alerts, and increasing click throughs to other pages. You can create unlimited top bars with unlimited colors for customization. The bars can be in fixed or absolute position. 

4. WPFront Notification Bar

wpfront notification bar

WPFront Notification Bar plugin easily lets you display promotions or announcements. You can position the bar at the top or bottom of your website and you can choose to make it sticky. The bars are fully customizable and you can also set start and end dates. 

5. HashBar

HashBar

The HashBar Notification Bar plugin which allows you to create unlimited notification top bars to notify your customers. It has option to show email subscription form, offer text and buttons about your promotions. You can add unlimited background colors and images to make your notification bar more professional.

Notification Bar Best Practices

The purpose of notifications is to provide value and enhance user experience. But notifications can easily become a nuisance. When creating your notification bar and notification message you should be careful not to go overboard. Below are some tips on creating successful notification bars and messages. 

  1. Always give the users a chance to accept or reject whatever the announcement is offering.
  2. Clarity is important, notifications message should provide useful and readable information. 
  3. Maintain consistent choice of color and icons especially if you're going to use several notification bars on the page. 
  4. Make sure your notifications are responsive and display correctly on all types of devices.  

Get a Top Bar or Notification Bar Plugin Now! 

You don't need to intruding into viewers experience in order to catch their attention.  On CodeCanyon you'll find WordPress notification bar plugins that will help you get the message across pleasantly. 

Bestselling Notification Bar Plugins for WordPress on CodeCanyon

While you're here, check out some of our other posts on useful WordPress plugins for notifications and announcements.

Website Cleanup and Maintenance Plugins for WordPress

$
0
0

Do you want to take the headache out of cleaning and maintenance of your website so it can run efficiently and fast? At CodeCanyon you'll find plugins that will automate your website cleaning and maintenance processes.  

Why Should You Use a Website Cleanup and Maintenance Plugin?

As your WordPress website grows so will your content, media files, databases. You will also add more plugins to extend its capabilities. Along the way, some plugins become irrelevant, the database gets too big and disorganized, media gets duplicated or takes up too much space, links break, some content will need to be deleted, and so on. 

As a result websites become bloated over time. Accumulated clutter leads to slow loading speeds which in turn create bad user experiences, high bounce rates and loss of business to competitors. This clutter can also make managing the backend of your site difficult. 

For your website to function at optimum capacity you need to do regular cleaning and maintenance. If not all accumulated clutter will slow it down. Users of both desktop and mobile expect fast loading times. 

Growing your website should go hand in hand with its cleaning and maintenance. That's where a WordPress maintenance and cleanup plugin from CodeCanyon comes in.

WP Cleaner Pro is an example of cleanup, maintainance and optimization plugins available on CodeCanyon

Best-Selling Cleaning and Maintenance Plugins on CodeCanyon

You can improve the performance of your website for a very affordable price with premium cleaning and maintenance plugins for WordPress from CodeCanyon. 

Topselling Cleaning and Maintenance Plugins on CodeCanyon

Here is how regular cleanup and maintenance of your website will benefit your business:

  • improve your website loading speed
  • increase page views and user engagement
  • satisfying user experience for visitors
  • reduce bounce rate
  • increase conversion rates 

Best Cleaning and Maintenance Plugins on CodeCanyon

Let's look at some cleaning and maintenance tools available on CodeCanyon. I'll divide them according to the cleaning and maintenance functions they perform.

Database Cleanup Plugins

Databases if not regularly maintained become cluttered with data that is not useful. Database cleanup can be done manually but it's cumbersome. These plugins will save you the headache of manual cleanup. They delete unnecessary data and leave important files in place. 

Smart Cleanup Tools

Smart Cleanup Tools

Smart Cleanup Tools  helps you take control of junk weighing down your databases. Orphaned records, expired transient records and other clutter be gone! 

This powerful WordPress database cleanup plugin is easy to use and has a total of 37 cleanup, reset and removal tools. With this plugin you can remove data that is no longer in use, or is unneeded.

You can schedule cleanup jobs to run at any time. They can run once or repeatedly within selected periods. All cleanup reports can be exported and saved into files.

The plugin supports WordPress multisite. It also has a few tools designed for network admin that can help you reduce database overhead and speed up database operations.

Smart Cleanup Tools is capable of performing many tasks, some of which include:

  • remove WooCommerce sessions in options table 
  • remove orphaned terms records 
  • remove cached postmeta records 
  • remove orphaned relationships records 
  • remove expired transient records (also in multisite mode)

WP Cleaner Pro

WP Cleaner Pro

Clean your WordPress database and make your website faster. WP Cleaner Pro can clean 26 types of orphaned and obsolete database data. In addition, it can optimize your databases. It can do all these tasks at once or in a scheduled event. The cleaning process is logged for later review. 

Crucially, WP Cleaner Pro also creates a backup of the WordPress database before changing anything.

The plugin is optimized for speed, has a clean mobile-friendly admin dashboard and no back-end errors. Equipped with a friendly user interface, it's developed for WordPress single-site installations, not for multisite. 

Shortcode and Broken Links Cleanup

Broken links contribute to negative user experience and adversely affect your website SEO ranking and credibility. But you can fix broken links by using plugins. 

SEO Cleaner

SEO Cleaner — WordPress Plugin for Site Clean Up

Each redundant part of your website can pull your search engine score down and potentially harm your site’s visibility in search engines. SEO Cleaner will get rid of all the automatic WordPress clutter for you in a few clicks by effortlessly removing: unused meta tags, links, scripts and styles in your head section, redundant server response HTTP headers, and any extra features you don’t use. 

Shortcode Cleaner

Shortcode Cleaner

Shortcode Cleaner helps clean your WordPress content by removing broken links within the post content.

It will clean posts, pages, content, excerpts, title, metabox, side bar widgets, menu links, and setting options. 

The cleaner automatically cleans your content without any click. Once you activate it, it will hide any broken shortcodes within any front-end site content without removing them. 

The cleaner will also automatically hide any broken shortcodes within the back-end admin from editors until you update or save the cleaned content. After that all the broken shortcodes will be removed completely.

Video Link Checker

Video Link Checker

Videos are uploaded and removed or blocked frequently–either by the user or the site itself for usage or copyright violations. If this happens to videos you have embedded on your site, your visitors are going to see broken content instead of the video they expected.

Avoid showing broken video content to your visitors with Video Link Checker. The plugin runs in the background,  protecting your site by automatically validating videos on your site from top video sites like YouTube, VidCloud, VidLoad, Vimeo, DailyMotion and many more.

It does this by extracting video URLs from each post and querying the video site APIs to ensure those videos are still valid. This is a must for any video site that wants to retain their visitors and not annoy them with broken content. 

Video Link Checker can also detect when a YouTube video is or becomes blocked in your target region(s) for whatever reason.

Image Optimization Plugins

You can automatically compress your images and use small version for your website. Image optimizer plugins compress images and reduce their sizes without noticeable loss of image quality. 

Automatic WebP and Image Compression

Automatic WebP & Image Compression for WordPress & WooCommerce

Automatic WebP and Image Compression uses the reSmush API to convert an unlimited number of images to WebP for free even if your server does not support WebP conversion. It also compresses unlimited number of images for free using the reSmush API. 

The compression is lossless, meaning it maintains the original quality of your images and deliver the images in the right format, resolution, dimensions, and size.

There is a built-in tool that allows you to select and compare different qualities, so you can know which quality suits you best.

If your browser does not support WebP images, the plugin will automatically serve the original JPEG or PNG images. Browsers that do not serve WebP include Safari and Internet Explorer.

This plugin also allows you to back up your images and restore them. 

Lana Image Optimizer 

Lana Image Optimizer

With the help of the Lana Image Optimizer you can convert images in your media library into small sized JPG’s. This image optimization plugin helps images displayed on the website matter for search engine optimization.

This WordPress image optimizer plugin comes with intuitive rich features that help save space.

The plugin converts files from formats like PNG to JPEG. The plugin deletes the old files and also replaces the file name in the WordPress database.

Website Speed Optimization Plugins

The code on your website can contain unnecessary comments, long identifiers, spaces, and other code that can affect loading speed. Website optimization can be achieved by compressing CSS and HTML to make the computer read your website code much faster. 

One Click—WordPress Speed and Performance Optimization

one-click-optimization-wordpress-speed-optimization plugin

Once you activate One Click, you can start optimizing your website speed and performance from your WordPress panel using all-in-one optimization features. It is quite fast and will not strain your site. 

This is how it works:

  • compresses and optimizes GZip, HTML, CSS, and JavaScript
  • optimizes images and lazy load features
  • removes query strings, shortlink, embeds, emoji and similes
  • uses Lavarange browser caching

The plugin works with all the themes and plugins and it is compatible with Google PageSpeed, GTMetrix and Pingdom.

Lighthouse

Lighthouse

Increase your website loading speed by up to 300% using Lighthouse. This WordPress performance tuning plugin removes lots of default WordPress behavior such as injected code, native code, third-party actions, and filters. This kind of cleanup allows your website to load fast and error-free by helping the browser cache requested content and caching plugins with work with 100% efficiency. 

Ultimate WordPress Speed Optimizer

Ultimate WordPress Speed Optimizer

WordPress Speed Optimization Plugin helps you optimize your website by removing all unwanted scripts, styles, functions, options, and more. Once you install it and select the recommended options you will see an increase in your Google Page Speed scores, Pingdom Tools Score, and Gtmetrix Score. 

Some important functions this plugin can perform include:

  • remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
  • remove bbPress CSS styles and scripts from non bbPress pages.
  • force JavaScript to load in the footer.
  • remove query string from static resources.
  • remove all sorts of <head> tags (10 different options can be selected)
  • manually select and remove unwanted jetpack styles and functions (24 options )
  • ability to remove comments.
  • ability to remove empty <p> tags

Content Cleanup and Maintenance

Kronos Automatic Post Expirator

Kronos Automatic Post Expirator Plugin for WordPress

Automatically delete WordPress posts using an auto deleter plugin. Kronos Automatic Post Expirator Plugin for WordPress uses a built-in wp-cron engine to automatically delete posts.

Kronos Post Expirator plugin allows the page admin to set expiration dates for both posts and pages and any custom post type you have active on the current WordPress installation. There are a number of different ways that the posts can expire:

  • older vs newer selection
  • by fixed date–ie. posts older than Jan 31, 2020
  • by relative date–posts older than 30 days

Other plugin features include:

  • republish old posts
  • delete posts permanently or move them to trash
  • set old posts as draft or pending
  • reset publish date for old posts, to the current time 
  • detailed plugin activity logging
  • scheduled cleanup running (using wp-cron)

WordPress Bulk Post Editor Professional

WPBE - WordPress Posts Bulk Editor Professional

For robust, flexible management and bulk editing of WordPress posts, pages and custom post types data consider WordPress Bulk Post Editor Professional. It is equipped with an nice and convenient WordPress post editor with rich HTML elements.

You can assign and limit responsibilities of site editors based on their roles. Editors can do joint editing of posts without interference with what the other is doing.

Before bulk editing of posts you have the possibility of preliminary filtering of all product fields: title, content, status, categories, tags, meta fields and custom taxonomies. 

WordPress Advanced Bulk Edit

WordPress Advanced Bulk Edit

WordPress Advanced Bulk Edit allows you to easily edit your posts, pages and custom post types individually or in bulk. 

Some features of this WordPress bulk editing plugin include

  • filter posts by title, category, tags, description and excerpt, status, post author.
  • bulk append, prepend and replace text in text fields 
  • bulk increase or decrease price by value or percent 
  • bulk set, add, remove categories 
  • create posts
  • create new categories
  • delete posts

Free Cleanup and Maintenance Plugins for WordPress

If Premium plugins are beyond your budget at this moment or you want to try free plugins and see how they work for you, I have put together a few that caught my eye.

WP Optimize 

WP Optimize

WP-Optimize is an all-in-one WordPress performance plugin that cleans your database, compresses your images and caches your site. The cache feature is built around the world’s fastest caching engine. This simple, popular and highly effective tool has everything you need to keep your website fast and thoroughly optimized!

Plugins Garbage Collector

Plugins Garbage Collector

Some WordPress plugins create and use their own database tables. Those tables are often left in your database after plugin deactivation and deletion.

Plugins Garbage Collector goes scans the database and shows the tables that do not come with the core WordPress installation.  It selects all table names from your WordPress database, excludes core WordPress installation tables, then scans your plugins directory .php files text for table names and shows you the result. Find out more here.

WP Sweep

WP Sweep

This plugin takes the broom to all the trash in your database. It deletes spam, orphaned data, comments and more. It also optimizes your databases. It uses proper WordPress delete functions as much as possible instead of running direct delete MySQL queries.

Clearfy

Clearfy

Clearfy optimizes your SEO and speeds your website through utilizing the following operations: 

  • Clear website code from trash
  • Eliminate the WordPress vulnerabilities
  • Speed up search engine indexing
  • Fix another plugin’s bugs
  • Make your WordPress easier, more convenient and faster

WP Bulk Delete

WP Bulk Delete

WP Bulk Delete helps in finding and mass deleting unnecessary data clean up. It allows you to delete posts, pages, comments, attachments, users, taxonomy terms and meta fields in bulk based with different powerful filters and conditions. The plugins improves your website speed and reduces database load.

Some Website Cleaning and Maintenance Tips

Before embarking on WordPress version updates, cleaning or maintenance you should regularly back up your files. You want to recover data that you may accidentally delete. 

1. Update Your WordPress to Latest Version

WordPress core infrastructure is updated yearly. To avoid hassles that come with having old versions of a software, you need to update to the latest version of WordPress. This update done is manually on your dashboard with a single click. Also WordPress performs regular security, maintenance, and bug fixes that are done automatically.

2. Get Rid of of Themes and Plugins You no Longer Use

There is a plugin for everything. In fact plugins extend the capabilities of your website immensely. But it doesn't mean you should have them all. Conduct an honest assessment of your plugins and themes you've downloaded. Deactivate then delete those you no longer use. 

3. Schedule Automatic Updates of Your Plugins and Themes

Update your themes and plugins. Simply go to the Themes and Plugins section on your WordPress dashboard and click Update Now. 

4. Clean Out Your Media

Old media files you no longer need or use for example images from delete posts or pages bog down your website. You can delete them manually but it's cumbersome to go through all your media files one by one. So a good media management plugins like Filebird and Real Media Library will make the process easy for you. 

5. Optimize Your Images

Without images your content will look dull and visitors won't stay long on your website. But images take up a lot of space. Your goal should be to have all files and images take up as little space as possible. Besides smaller images load fast. Shrinking your images without losing quality is important. For this I recommend automatic image optimization plugins like Automatic WebP and Image Compression for WordPress.

6. Remove Broken Links 

Links that lead to non-existent pages don't you any favors. They make information your website appear unreliable. If you want your content to instill trust in visitors, you will need weed out links that no longer work. You can enlist SEO CleanerShortcode Cleaner, and Video Link Checker for this task. 

7. Clean Up Your Databases

Obsolete data is a big part of unnoticed clutter builds up in databases. With the help of database cleanup plugins like WP Cleaner Pro you can have lean and useful databases. 

8. Content Review and Cleanup

Over time content needs to be assessed. Delete content that is irrelevant and out of date, articles that are repetitive and need to be deleted, 

Make Your Website Efficient and Fast Now!

The behind-the-scenes operational health of your website is important. Regular cleanup, maintenace and optimization makes your website run faster, improves SEO rankings, and increase visitor engagement and conversion. 

Also make sure to let your clients know your website is under maintenance. These coming soon or maintenance mode plugins will do the trick.

Make your website fast and efficient Now

These additional resources will help you in cleaning and maintaining your WordPress website.

How to Trim Strings in PHP

$
0
0

There are a lot of times when we want to work with strings but they are padded with unwanted characters either at the beginning or the end. PHP has defined specific functions that we can use to trim such strings easily.

In this quick tip, we will discuss to common string trimming situations that you will likely encounter. The first one involves removing specific characters from either one or both ends of a string. The second one involves trimming strings based on how many characters we want to remove from either end.

Trimming Strings to Remove a Set of Characters

There are three different trimming functions in PHP called ltrim(), rtrim() and trim(). They remove either whitespace or any other set of characters from the left end, right end or both ends respectively.

If you don't mention as list of characters to remove as the second parameter, these function will remove whitespace characters like spaces (" "), tabs ("\t"), new lines ("\n"), carriage returns ("\r"), null bytes ("\0") and vertical tabs ("\v").

There is no limit to the number of characters that will be trimmed by these functions. In other words, they will keep trimming the string as long as it contains any of the specified characters at either end.

Here are a few examples of these functions. The main strings that we are trimming will contain a combination of whitespace, tabs or newline characters at both ends.

As you can see, ltrim() removes all the whitespace form the left of the strings while keeping the right end untouched. Similarly, rtrim() removes all the whitespace from the right of the strings while keeping the left end untouched.

It is important to keep in mind that trimming only happens when the characters are exactly at the end or beginning. Here is an example:

You can also trim any other set of characters if you pass them as second parameter of ltrim(), rtrim() or trim().

This time we had specified that we only want to trim the characters 1,2 and 3. Therefore, trim() left the whitespace untouched.

Similarly, in this second example, trim stopped removing digits from the both ends as soon as it found a mismatch from the characters we asked it to trim.

This third example demonstrates how we can use (..) to specify a range of characters that we want trimmed. This way we can avoid listing all the characters if they occur sequentially.

Trimming Strings to Remove a Specific Number of Characters

Just like trimming a specific set of characters, PHP also has dedicated functions to trim a specific number of characters.

The substr($string, $offset, $length) function is best suited for this job. It accepts three parameters and returns a substring. The first parameter is the string you want to trim. The $offset parameter determines the start of the returned substring and the $length parameter determines the length of the substring.

We can control the values of $offset and $length to trim our main string based on number of characters.

  1. You can trim the string from the left side by only specifying an offset and omitting the $length parameter when calling substr(). In this case, substr() will return a substring starting from offset until the end of the string.
  2. You can trim the string from the right side by setting the value of $offset to 0 and making $length negative. This will remove $length number of characters from the right end of the main string.
  3. You can specify a non-zero positive value for $offset and a negative value for $length to make substr() act like trim() and remove a specific number of characters form both ends.

Here is an example that trims a string using the substr() function:

Final Thoughts

In this quick tip, we learned how to trim strings in PHP based on a specific set or a specific number of characters. If you have any questions or tips related to the post, feel free to post them in the comments.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our free online course on PHP fundamentals!

 

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming (OOP). Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.

12 Best WordPress Weather Widgets & Plugins (With 5 Free)

$
0
0

Are you looking to display weather forecasts on your WordPress website? A visually pleasing and powerful WordPress weather widget for your website is indispensable. 

WordPress weather widgets allow you and your customers to plan for the weather. These plugins include WordPress weather widget sidebars, local weather widgets, and weather forecast widgets. This will let your potential customers know what local weather they can expect at your venue, whether it's a golf course, a wedding destination, or a restaurant with patios. 

The weather WordPress widgets and plugins available on CodeCanyon seamlessly integrate an upcoming weather forecast display on your website to keep everyone informed about the weather at your venue. 

Even though we’re powerless against Mother Nature, you and your customers can plan around it. 

The Best Weather Widgets for WordPress on CodeCanyon 

Discover over 7,000 of the best WordPress plugins ever created on Envato Market's CodeCanyon. With a cheap one-time payment, you can purchase one of these high-quality WordPress plugins. 

Here are a few of the best weather widgets for WordPress available on CodeCanyon for 2020.

Weather WordPress Plugins
Weather WordPress plugins available for sale at CodeCanyon

7 Best WordPress Weather Widgets and Plugins (From CodeCanyon for 2020)

Here are seven top-rated WordPress weather widgets and plugins that are available for you to download on CodeCanyon.

1. Best-Selling: Simple Weather Plugin

Simple Weather Best Selling WordPress Plugin

The Simple Weather plugin displays the current weather via widgets and shortcodes that you can display anywhere on your WordPress website.

These WordPress weather widgets for your website and shortcodes are easy to set up and are packed with all the options you need like location, GPS coordinates, customizable update intervals, day and night temperatures, background colors, and more. 

If you use WPBakery on your site, the publisher also offers Weather for Visual Composer.

2. Astero WordPress Weather Plugin

Astero WordPress Plugin Weather Widget

The Astero WordPress Weather Plugin includes much of what you'll ever want in a weather plugin for your WordPress website. This top-selling plugin comes with clean lines, multiple sizes and styles, and a solid feature set that makes this weather widget for your website look good even if the weather isn't. 

Other great features of this WordPress plugin weather widget include HTML5 geolocation with IP fallback, local cache, and support for 600+ Google fonts.

3. Weather for Visual Composer

WordPress Plugin Weather Widget for Visual Composer

Weather for Visual Composer (WPBakery) is perfect for websites that need to add some basic weather functionality in a stylish way. It displays the current weather as simple text or an elegant box widget. It's easily customizable with a set of stylish icons that give it a modern look. It has an easily changeable Celsius/Fahrenheit setting and supports 17 languages. 

For those used to working in WPBakery, getting everything set up using this WordPress weather forecast plugin is as easy as dragging the element into your layout and setting a location.

4. Always Sunny WordPress Weather Widget

Always Sunny WordPress Plugin Weather Widget

One of the more in-depth WordPress weather plugins available, the Always Sunny plugin gives a wide range of data and implementation options.

You can place this plugin on your pages in two ways: as a WordPress weather widget sidebar or as an embeddable shortcode. This mix makes it just as easy to show weather data in your sidebar as it is easy to drop it within a page’s content.

Beyond the basic weather measurements of temperature and weather patterns, this plugin throws a few other data points into the mix. Cloud coverage, wind patterns, and humidity levels make it a great addition for golf course websites, vacation spots, and restaurants with outdoor dining.

5. WP Weather Widget and WPBakery Add-on

WP Weather Widget and WPBakery Add-on Temperature Plugin WordPress

This WordPress weather plugin comes with a customizable element that can easily be dropped into your page template. It also includes a widget that can be used by any WordPress builder.

With all of the standard WPBakery element customization options and five layouts to choose from, you can quickly adjust your weather information to fit your page. Using the OpenWeatherMap API, this temperature plugin for WordPress lets you display the temperature, daily highs and lows, humidity, and more. If you need a weather widget for your website, WP Weather Widget makes a nice option.

6. Elfsight Weather - WordPress Weather Plugin

Elfsight Weather - WordPress Weather Plugin

Elfsight Weather is an easily adaptable WordPress weather plugin. Enter any point, using a ZIP code or GPS coordinates, and it will display current weather information for any location on the map. Your audience will be able to check the updated info on temperature, air pressure, humidity percentage, and active weather. 

The temperature plugin for WordPress has a weather forecast feature to show the forecast for the week ahead or for the next 12 hours. With this plugin, you can choose the colors you prefer for your widget display.

7. aWeather Forecast 

aWeather Temperature Plugin WordPress

The aWeather Forecast plugin is a uniquely designed weather WordPress widget. It can display weather conditions with its cast of 18 animated icons, 4 animated headers, and full-color customization. This is one of the most charming weather widgets you'll find!

This weather widget for your website can display the current weather icon and temperature, current weather conditions, wind speed and direction, pressure, humidity, and more. Not bad for a nifty little temperature plugin for WordPress.

5 Free Weather Widgets for WordPress

Without a doubt, paid weather WordPress plugins will offer you the most comprehensive set of tools and features. Features, customer support, and overall user experience will be better with these premium plugins. However, you might not currently have the budget to spend on these premium weather plugins and still need to show the weather forecast to your website visitors. 

That's why I have collected a list of five of the best weather WordPress plugins available for free online. 

1. WP-Forecast

This WordPress weather plugin that's free will let you display weather data from AccuWeather and WeatherBug. You can also customize the display features such as location and language.

2. Weather Atlas Widget

Weather Atlas Widget weather wordpress plugin free

The Weather Atlas WordPress plugin weather widget features a responsive design, a detailed forecast, and weather icons. It works well for a weather WordPress plugin that's free. This plugin is easy to set up and use. 

3. Weather Underground

weather underground wordpress weather plugin free

This is a simple weather forecast plugin for WordPress. This WordPress weather plugin is free and fits perfectly with many different templates out of the box, including the default WordPress theme.

4. Location Weather

location weather wordpress weather plugin free

Location Weather is an easy-to-use and customizable WordPress weather plugin that's free. It allows you to add unlimited up-to-date weather information to your web pages or through a WordPress weather widget sidebar.

5. Weather Station

weather station weather wordpress plugin free

This weather WordPress plugin is free and collects meteorological data from public or personal weather stations and can display it in many elegant ways on your website. Like most other weather WordPress plugins, it can be installed with a shortcode. 

How to Customize the aWeather Weather Forecast Plugin for WordPress 

Now that we've gone over all the best premium and free weather WordPress plugins available, you might be wondering how you can add them to your website. 

Let's take a look at how you can customize a premium weather plugin so it can fit seamlessly into your website. 

1. Insert aWeather Into Your Website

First, we need to insert the aWeather plugin into the site once the plugin is installed. Choose Appearance > Widgets from the WordPress admin sidebar. From there, we will look for the aWeather Forecast tab under Available Widgets. We would like the widget to appear in the footer of our website, so click on the tab and choose Footer. The widget will now be added to our website, and we can begin customizing it. 

Adding aWeather To Footer

2. Type in Your OpenWeather Map API ID

Next, click on the aWeather widget under the Footer section of the widget editor. This will open up the customization options for the widget. 

In order for the widget to display the current weather forecast for your desired location, we must add an API key in the OpenWeatherMap App ID text field. To do this, click on the Get App ID link next to the field title. 

You'll then need to create an account on the OpenWeather website in order to obtain the API keys. Click the Sign-Up link on the webpage. Once you've signed up with a valid email, click on the API keys link on the second-level menu header. Copy and paste the API key called default back into the OpenWeatherMap App ID text field. Your widget will now be ready to display current forecasts from around the world. 

Getting OpenWeather API key

3. Configure the Display

Finally, we can adjust the widget to display the weather forecast how we would like. Under the aWeather widget, type in "London, UK" as we would like to show the weather forecast for London. Next, click the drop-down menu titled Units format, and choose Fahrenheit. Lastly, click the save button at the bottom of the widget. You can now view the weather widget on the footer of all your pages. 

aWeather widget display

Find WordPress Video Tutorials From Envato Tuts+ on YouTube

You're using the Envato Tuts+ website to find some excellent WordPress plugin weather widgets, but did you know we're also on YouTube? You can learn about graphic design, video editing, and everything in between on our YouTube channel.

Learn useful tips, tricks, and skills with our WordPress video tutorials and guides. Here's a quick peek at what you can find from Envato Tuts+ on YouTube.

Install a WordPress Weather Widget or Plugin Now! 

If you've got a business that relies on the weather, then add a stylish-looking weather WordPress plugin from CodeCanyon. 

The WordPress weather widgets and plugins available will allow you to seamlessly integrate a weather display into your website and give you the option to customize the display so it will fit with your website's theme.

Need icons to go with your new plugin? You can find free weather icons on Envato Elements.

Also, there are thousands of other high-quality WordPress plugins on CodeCanyon that can help enhance your business's website. Have a look through this large collection of plugins, and you'll find helpful plugins in all different types of categories, from marketing to eCommerce to social media.

Find the perfect WordPress plugin to help your business succeed and motivate your customers. You can find even more plugin ideas and inspiration in our new free course on finding the best WordPress plugins for your site.

This post has been updated with contributions from Nathan Umoh. Nathan is a staff writer for Envato Tuts+.

Lead Generation Plugins for WordPress

$
0
0

Are you looking to generate more leads, convert visitors into subscribers, build a vibrant email subscriber list and boost your sales? With lead generation plugins for WordPress, you can build your email list, bigger, faster and more targeted than ever before. 

What is Lead Generation for WordPress?

You can generate more leads by running effective marketing campaigns that convert your website visitors into subscribers to your email lists. 

I will look at WordPress plugins that will help you in this journey. 

  • email marketing and newsletter plugins
  • popup plugins 
  • social locker plugins
  • abandoned cart plugins
Green Popups
Green Popups one example of plugins on CodeCanyon that will boost your lead generation efforts.

Best-Selling Email Newsletter Plugins for WordPress on CodeCanyon

If you want to run dynamic email campaigns you will find some of the best email newsletter plugins on CodeCanyon for a very affordable one-time payment.

Topselling Email Newsletter plugins on WordPress

These two plugins are standalone digital marketing platforms. You don't have to pay monthly subscriptions. They come with tons of features to help you run campaigns and sales that can significantly help grow your leads.  

Mailster

Mailster

Mailster allows you to host, create, manage and send email newsletter campaigns from your WordPress dashboard. This means you don't have to pay recurring monthly subscription fees, and you get to own your subscriber data and digital assets for your campaigns. 

This WordPress lead generation plugin comes with an intuitive drag-and-drop editor which lets you create stunning email campaigns, and even embed images into your newsletter without coding knowledge. 

Its powerful automation tools allow you to easily engage with your contacts by sending automatic welcome emails, birthday emails, trigger campaigns from actions, follow-ups, and more.

You can take advantage of its tracking and analysis tool to improve your email campaigns and get the best conversion possible. With the help of these tools you can find out where your subscribers come from, which email client they are using, their click rate and any other activity. 

This translation ready WordPress email marketing plugin also integrates with popular WordPress plugins that can be added to have an even greater impact on your business. 

BeeMail

BeeMail

BeeMail is powerful digital marketing and sales management platform that equips your WordPress or WooCommerce website with capabilities like: contacts and list management, email marketing, form design, and publishing. 

It is equipped with a powerful drag-and-drop editor that allows you to create beautiful email campaigns and target the right people with personalized messages. 

It also has a form builder that enables you to create beautiful forms and publish them to your WooCommerce pages or landing pages so you can easily collect and store contacts.

You can inject a web version to every email campaign so that receipients can read it online using a browser. You can track your contacts engagement with your marketing campaigns for example open and clicks then follow up with those who have not taken any action.

BeeMail can deliver marketing emails directly using the hosting server. It is also powered by versatile integration support to any local mailer or remote SMTP services like Amazon SES, SendGrid, Elasticemail, SparkPost, Mailgun. 

Best-Selling Popup Plugins on CodeCanyon

Popups are some of the most effective lead generation tools that help you build targeted email subscriber lists. They come with many tools including ability to integrate forms that make email collection easy.

For a one-time payment you can grab a popup plugin and get started building your email subscriber list. The popup and opt-in WordPress plugins available on CodeCanyon will allow you to integrate a popup or form into your website to capture your website user's email addresses, giving you the opportunity to market to them in the future.  

Topselling Popup plugins on CodeCanyon

Let's look at some of my favorite popup plugins on CodeCanyon.

Green Popups

Green Popups

Make your website more attractive with Green Popups. This plugin allows you to create unique multi-layers animated popups. You even have a library of over 200 professionally designed ready-made templates to choose from.

For easy collection of subscriber data to grow your leads, the popups can be embedded with AJAX subscription or contact forms which work with a lot of CRM, marketing and newsletter systems.

The popups display in any part of the web page or as a sidebar widget. They can display on page load, on exit intent, on scrolling down, or on user’s inactivity. They can come up when AdBlock is detected or when users click something. 

Green Popups integrates with HTML forms, payment gateways, SMS gateways, CRM and newsletter systems, email verification services, and more. 

In addition to working with WordPress Multisite, this plugin supports WPML so you can create popups for different languages. 

ConvertPlus

ConvertPlus popup plugin for wordpress

ConvertPlus is the all-in-one WordPress Popup plugin that transforms your website into a lead generation powerhouse. It allows you to build your email list, bigger, faster and more targeted than ever before.

Features like the exit popup, opt-in popup, slide-in popup, video popup, on-click popup, social popup, embedded forms, widget boxes, info bars make it the most powerful popup and lead generation plugin.

You can create a campaign by choosing from huge library of over 100 beautifully designed and high converting ready-made templates. You can customize it per you needs, add triggers and filters, and publish it, and track its performance. 

It is easy to set up. You only need to follow a few intuitive steps and you be ready to create beautiful popups in minutes and start converting your website visitors into subscribers, social followers and customers.

Ninja Popups

Optin Panda For WordPress

Ninja Popups for WordPress is power popup plugin tool that brings you high quality leads and increases opt-ins on your mailing list. This WordPress lead generation plugin will help increase your subscriber count and social count of your site by using professionally designed popups to do the following:

  • direct visitors on your site into taking an action whether it`s subscribing into your newsletter
  • offer a discount or coupon for departing customers
  • lock content that can only be accessed when they share their email

Through its powerful drag and drop editor you can create unlimited colorful and dynamic popups by choosing from many layouts and colors. You can choose to delay popup display for seconds after the website opens. You also have tools to track how the popups are performing. 

Ninja Popups for WordPress integrates all popular mailing systems like MailChimp, GetResponse, InfusionSoft, JetPack, ConvertKit, and many more.

Master Popups

master popoups

Transform your traffic into leads, sales and signups using the Master Popups WordPress plugin to convert your website visitors into subscribers and clients by saving their email, first name, last name, phone and other data through popups and subscription forms.

Master Popups has a powerful drag-and-drop visual popup editor with which you can easily create subscription forms, contact forms, images, videos, offers notices, discounts, and any other type of popup.

You can select from over 70 ready to use popup templates to create modal popups, full screen popups, notification bars, and slide-in popups including inline and widget popups.

Master Popups integrates with more than 50 email marketing services such as MailChimp, Mailster, MailPoet, Sendinblue, MailWizz, MailerLite, Active Campaign, and Mautic.

Ultimate Popup Builder

Ultimate Popup Builder

Bright popups with notification of upcoming discounts and promotions? Go for it. 

Popups with subscription forms, popups with contact forms, GDPR popups? You got it.

Easily make any popup you want with Ultimate Popup Builder. Your plugin of choice for endless popup options where you are only limited by your imagination.

With Ultimate Popup Builder you can easily customize size, positioning, background, and animation. You can choose the type of appearance on load, on scroll, on click, or on page exit intent. You can easily customize the overlay and select the background, as well as the popup close button.

You can use Ultimate Popup Builder with any page builder, be it Elementor, WPBakery, or Gutenberg. There are 14 ready-made popup templates that you can import, they are available for Elementor and WPBakery Page Builders. 

Ultimate Popup Builder is compatible with many plugins. You can easily create a popup with a subscription form using the Mailchimp plugin shortcode. To add a contact form just add the form shortcode from Contact Form 7 plugin. You can even come up with any pop-up variations using your plugin shortcodes. 

Social Locker and Content Locker Plugins on CodeCanyon

Locking your best content is another proven way of getting subscribers and social followers. In the case of social lockers, the more shares your content gets, the more visitors to your website that you can convert into social followers, subscribers and customers. 

You can increase your social count and get more views for your content by purchasing one of these social locker for a small one time payment. 

Topselling social locker plugins on CodeCanyon

Now let's have a look at some social lockers 

Opt-in Panda

Optin Panda

If you want to see your email subscription rates burst through the roof then you should try Opt-in Panda. Here is how it works: Opt-In Panda locks a portion of content on a webpage by hiding or blurring it, then asks the visitor to enter their email address (opt-in) to unlock the content. In other words, it gives visitors a reason to subscribe immediately in return to instant access to your valuable content like downloads, discounts, videos and so on. 

The plugin equally well works with Single Opt-In (without email confirmation) and Double Opt-In (with email confirmation) modes. You decide which mode to use.

The Opt-In Panda integrates directly with all the major mailing services and plugins: MailChimp, Aweber, GetResponse, Mailster, MailPoet, and more. 

Also supports any transactional mailing services like Mandrill, Postmark, Mailjet, Amazon SES, and SMTP after installing their respective WordPress plugins.

Social Locker for WordPress

Social Locker for WordPress

Social Locker for WordPress locks your most valuable content behind a set of social buttons until the visitor likes, shares, or tweets your page.

Once they "pay" with likes, shares or tweets they can get access to your content, download freebies, read an ending of your article, watch a video, get a discount and so on.

It helps improve social performance of your website, get more likes, shares, build quality followers and attract more traffic from social networks.

All you need to do is select the part of your content you want to lock, click a button and you’re done.

This way, you can use articles, videos, audio, images, download links, coupon codes or anything else you can think of as an incentive for people to give you likes or shares.

ARSocial

ARSocial - Social Share Buttons & Social Locker Plugin

ARSocial has the ability to build your brand overnight by sheer connectivity. This plugin can propel your content across up to 40 networks at the click of a button ensuring the maximum possible visibility, viral growth and popularity.

In fact, it is several plugins rolled up in one: social locker, social fan counter, social share, social like-follow and subscribe.

The social locker feature comes in handy when you have material that you do not want shared, but only seen by those who subscribe. You can choose what material can be shared. 

ARSocial provides feature that places social network buttons section wise and site wide as well as with shortcode on all pages and posts. It also provides various display positions like mobile display settings with footer bar.

Subscribe to Unlock

Subscribe to Unlock Opt In Content Locker WordPress Plugin

Subscribe to Unlock makes it fast and easy to capture subscribers by simply locking some specific content of your site until users subscribe to your site. You can even lock the whole site with a popup or give a countdown to users until they can view the content without subscribing.

You can create unlimited locker forms by choosing a stunning layout from 10 beautifully pre-designed templates. You can also connect the forms directly to popular third party subscription services such as Mailchimp, and Constant Contact. 

Opt-In Downloads for WordPress

Opt-in Downloads

Opt-In Downloads is a WordPress plugin that allows you to distribute files through subscriptions. If people want to download something from your website they must submit their contact details. After submission they'll receive the download link by email. Very simple workflow.

All submitted data is saved in a database and can be exported as a CSV file to popular email marketing providers such as MailChimp, iContact, or GetResponse. 

Other additional features of this WordPress lead generation plugin include: 

  • responsive design: the opt-in form looks nice even on small screens.
  • GDPR-ready: enable or disable the “terms and conditions” checkbox for the opt-in form
  • shortcode-driven: use shortcodes to place the opt-in form
  • easy to install
  • translation-ready

Subscribe-to-Download

Subscribe-to-Download

Subscribe-to-Download makes it fast and easy to capture subscribers right from your WordPress site by simply providing them a freebie to download when they give their email. 

You can create unlimited subscription forms by choosing a stunning layout from 20 beautifully pre-designed templates. 

You can also connect the forms directly to popular third-party subscription services such as Mailchimp and Constant Contact, making it easy to collect subscribers from your WordPress website. 

In addition, you can track the download status and export subscribers.

Best Abandoned Cart (Remarketing) Plugins on CodeCanyon

Not all is lost when a cart is abandoned. It is an opportunity to get leads from potential customers so you can follow up with enticing deals. Grab one of these abandoned cart plugins and see for yourself!

Topselling Abandoned Cart Plugins on CodeCanyon

CartBack—WooCommerce Abandoned Cart and Remarketing in Facebook Messenger

CartBack - WooCommerce Abandoned Cart & Remarketing in Facebook Messenger

CartBack is the most effect way to recover abandoned carts and generate leads because it is connected with Facebook Messenger.

When a customer abandons their cart, you can send them a personalized message to their Facebook Messenger inbox with a discount coupon that has a call-to-action button where they can enter their email. Once they opt in, you can maintain the relationship between you and your customers by sending them deals.

CartBack helps you keep those customers in a database. On the analytics section on your dashboard you will see number of add to cart users, number of messages sent in each reminder, first reminder, second reminder or third reminder including clicks, purchases and revenue.

WooCommerce Recover Abandoned Cart

WooCommerce Recover Abandoned Cart

WooCommerce Recover Abandoned Cart monitors carts that are abandoned by members and guests. It automatically sends mails using the mail templates at specified times to recover the abandoned carts.

For members, as soon as a products is added to their cart, it will be captured in case the cart is later abandoned.

Guests will have to reach the step of inputting their email address in the checkout page, but one their email has been entered their abandoned carts will be captured.

Lead Generation Tips

  1. Harness the full potential of social media channels. Each platform attracts a particular audience based on age or other factors. Know what plaform your target audience is likely to spend time on. 
  2. Become a master of forms since you will be using them to collect visitors information. Test and see which forms get you more subscriptions.
  3. Make you content shareable. The more your content is shared, the more traffic comes your way. 
  4. If you're going to lock content, make sure it is of very high quality or else you will lose the trust of your subscribers and they will move on.
  5. Make call-to action an indispensable part of your campaign messaging. You can create some really stunning campagins, but if you don't get users to take the next step then your efforts are for naught.
  6. Your website is the most important lead generation tool. If it's sluggish then you lose your leads. Make sure it performs and optimum level by investing in regular updates, site cleanup, and maintenance.   
  7. Master SEO, its full potential is still under-exploited. 
  8. Harness the power of testimonials, comments, and reviews. Hearing what other users think of your products or services increases your credibility and give your leads the push to join in. 

Conclusion

We have looked at plugins that are necessary for building your subscribers list and converting visitors to customer. Without these lead generation tools, it would be difficult to capture emails on your website and your marketing campaigns will not be as effective. 

Additional Resources

Below are some articles with resources that will help in your help to generate more leads and build a successful business. 

String Concatenation in PHP

$
0
0

String concatenation is a very common and useful operation in PHP. There are many ways in which you might want to join strings together like prepending, appending or combining them at some other point.

In this quick tip, I'll teach you string concatenation in PHP. You'll learn how to prepend or append strings in PHP and how to concatenate strings together at specific positions.

Prepend and Append Strings in PHP

Concatenating strings in PHP by either appending or prepending is actually pretty simple. There are two string operators in PHP meant for this specific purpose.

  1. You can use the concatenation operator . if you want to join strings and assign the result to a third variable or output it. This is useful for both appending and prepending strings depending on their position.
  2. You can use the concatenating assignment operator .= if you want to join the strings and assign the result to same variable. It is a shorter way for appending the argument on the right side to the argument on the left side.

Here is an example which shows how to append strings in PHP:

Here is an example that prepends different strings to a name in PHP:

Concatenating Strings at a Particular Point

There are two common cases when you need to join strings at some place other than the beginning or the end of a string. These are splitting the main string at a particular index, or splitting the main string after a particular word. We will cover both these situations in this section.

Concatenating Strings at a Particular Index

We can use the substr() function in PHP to split the main string in two parts at desired index and then join the parts back together with our string in the middle.

In the above code, the value of variable $index is simply the position at which we will like to concatenate our substring inside the main string.

Concatenating Strings Before or After a Particular Word

Concatenating a string before or after a particular word works just like joining strings at a particular index. The only extra step we need to take is figure out the index. The strpos($haystack, $needle) function is perfect for this purpose. It simply finds the position of our $needle string inside the main text block or $haystack.

Here is an example of concatenating strings before a particular word.

The big difference here is that we have moved the $index variable inside our loop. This is because the position of our word will probably be different in each string and we need to adjust the value of index accordingly.

The strpos() function gives us the position of the first character of our substring inside the main string. This makes it easier for us to concatenate substring at the beginning of a particular word.

When adding substrings at the end of words, we also need to take the length of words into account. Adding the word length to our initial index gives us the correct position to concatenate substring at the end of a particular word.

Final Thoughts

In this quick tip, I have covered different scenarios for concatenating strings in PHP. You should now be able to append, prepend or join the strings at any other position you like.

The key to joining the strings at a particular place is to simply find its index. This is exactly what we did when we wanted to concatenate strings before or after a particular word.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our free online course on PHP fundamentals!

 

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming (OOP). Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.


How to Use Sessions and Session Variables in PHP

$
0
0

Session handling is a key concept in PHP that enables user information to be persisted across all the pages of a website or app. In this post, you'll learn the basics of session handling in PHP.

We'll start with an explanation of how sessions work and how they are related to cookies. Then we'll look at a few code snippets that demonstrate how to work with sessions. You'll learn how to create and destroy sessions, and how to change session variables.

Cookies vs Session Variables

Not sure if you need cookies or session variables? Session variables are a way to store data about a user in a database and to retrieve it later. Cookies are a way to store data about a user on the user's computer. Session variables are typically used in applications that need to keep track of a user's activity. Cookies are typically used in applications that need to store information about a user for a single site.

You can learn also learn about session variables in my post on using cookies in PHP.

What Is a Session in PHP?

A session is a mechanism to persist information across the different web pages to identify users as they navigate a site or app. Are you wondering why sessions are needed for a website? To see why sessions are necessary, we have to go back and see how the HTTP protocol is designed to work.

The HTTP protocol is a stateless protocol, which means that there's no way a server can remember a specific user between multiple requests. For example, when you access a web page, the server is just responsible for providing the contents of the requested page. So when you access other pages of the same website, the web server interprets each and every request separately, as if they were unrelated to one another. There's no way for the server to know that each request originated from the same user.

The following diagram depicts the HTTP protocol in a nutshell.

The HTTP Protocol and a Stateless Request

In this model, if you wanted to display user-specific information, you'd have to authenticate a user in each request. Imagine if you had to type your username and password on every page that displayed your profile information! Yes, it would be cumbersome and not practical at all, and that's where sessions come into the picture.

A session allows you to share information across the different pages of a single site or app—thus it helps maintain state. This lets the server know that all requests originate from the same user, thus allowing the site to display user-specific information and preferences.

Login Flow With Sessions and Cookies

Let's quickly go through a common login flow for a website to understand what happens behind the scenes.

  1. A user opens the login page of a website.
  2. After submitting the login form, a server on the other end authenticates the request by validating the credentials that were entered.
  3. If the credentials entered by the user are valid, the server creates a new session. The server generates a unique random number, which is called a session id. It also creates a new file on the server which is used to store the session-specific information.
  4. Next, a session id is passed back to the user, along with whatever resource was requested. Behind the scenes, this session id is sent in the PHPSESSID cookie in the response header.
  5. When the browser receives the response from the server, it comes across the PHPSESSID cookie header. If cookies are allowed by the browser, it will save this PHPSESSID cookie, which stores the session id passed by the server.
  6. For subsequent requests, the PHPSESSID cookie is passed back to the server. When the server comes across the PHPSESSID cookie, it will try to initialize a session with that session id. It does so by loading the session file which was created earlier during session initialization. It will then initialize the super-global array variable $_SESSION with the data stored in the session file.

In this way, the user data is preserved across multiple requests, and the user is kept logged in throughout a session.

The following diagram depicts how the HTTP protocol works with sessions.

The HTTP Protocol and a Request With Sessions

Now that you've seen a brief introduction to how sessions work, we'll create a few practical examples to demonstrate how to create and manipulate session variables.

How to Start a Session

In this section, we’ll discuss how to start a session in PHP.

Whenever you want to deal with session variables, you need to make sure that a session is already started. There are a couple of ways you can start a session in PHP.

Use the session_start Function

This is the method that you'll see most often, where a session is started by the session_start function.

The important thing is that the session_start function must be called at the beginning of the script, before any output is sent to the browser. Otherwise, you’ll encounter the infamous Headers are already sent error.

Automatically Start a Session

If there’s a need to use sessions throughout your application, you can also opt in to starting a session automatically without using the session_start function.

There’s a configuration option in the php.ini file which allows you to start a session automatically for every request—session.auto_start. By default, it’s set to 0, and you can set it to 1 to enable the auto startup functionality.

On the other hand, if you don’t have access to the php.ini file, and you're using the Apache web server, you could also set this variable using the .htaccess file.

If you add the above line in the .htaccess file, that should start a session automatically in your PHP application.

How to Get a Session Id

As we discussed earlier, the server creates a unique number for every new session. If you want to get a session id, you can use the session_id function, as shown in the following snippet.

That should give you the current session id. The session_id function is interesting in that it can also take one argument—a session id. If you want to replace the system-generated session id with your own, you can supply it to the first argument of the session_id function.

It’s important to note that the session_id function must be placed before the session_start call when you want to start a session with a custom session id.

How to Create Session Variables

In this section, we’ll explore how to initialize session variables in PHP.

As we discussed earlier, once a session is started, the $_SESSION super-global array is initialized with the corresponding session information. By default, it’s initialized with a blank array, and you can store more information by using a key-value pair.

Let’s go through the following example script that demonstrates how to initialize session variables.

As you can see, we’ve started a session at the beginning of the script using the session_start function. Following that, we’ve initialized a couple of session variables. Finally, we’ve accessed those variables using the $_SESSION super-global.

When you store the data in a session using the $_SESSION super-global, it’s eventually stored in a corresponding session file on the server which was created when the session was started. In this way, the session data is shared across multiple requests.

As we discussed, the session information is shared across requests, and thus the session variables initialized on one page can be accessed from other pages as well, until the session expires. Generally, a session expires when the browser is closed.

How to Modify and Delete Session Variables

You can modify or delete session variables created earlier in the application the same way as for regular PHP variables.

Let’s see how to modify the session variables.

In the above script, we’ve checked if the $_SESSION[‘count’] variable is set in the first place. If it’s not set, we’ll set it to 1, otherwise we’ll increment it by 1. So, you if refresh this page multiple times, you should see that the counter is incremented by one every time! 

On the other hand, if you would like to delete a session variable, you can use the unset function, as shown in the following snippet.

Thus, you can no longer access the $_SESSION[‘logged_in_user_id’] variable as it’s deleted by the unset function. So that’s how you can alter the session information.

How to Destroy a Session

In this section, we’ll see how you could destroy a session. In the previous section, we discussed the unset function, which is used if you want to delete specific session variables. On the other hand, if you want to delete all session-related data at once, you can use the session_destroy function.

The session_destroy function deletes everything that’s stored in the current session. Having said that, it doesn't unset global variables associated with session or unset the session cookie.

So if you're using the session_destroy function to log out a user, you must unset the $_SESSION variable and unset the session cookie as well . Thus, the recommended way to destroy a session completely is:

Session Handlers

So far, we've discussed how you can perform different operations with session variables. In this section, we'll discuss what a session handler is and how you can use it.

A PHP session handler is a mechanism which instructs PHP how it should manage sessions. The default session handler is a file system, and it means that PHP stores sessions on the disk. Basically, it's a small file on the server which is associated with the unique session id. It's the same id which is stored in a session cookie on the client browser.

The default session handler in PHP provides you all the features that are needed, but sometimes you want to store sessions differently. For example, you might want to manage sessions in a database, Redis or some other storage. In this case, you need to implement a custom session handler which overrides the default behavior.

To understand how custom session handlers work, we'll briefly discuss how you can implement a database session handler which manages sessions in a MySQL database.

How to Implement a Database Session Handler

In the PHP session life cycle, there are different stages like open, read, write and close. Additionally, there are two more stages: destroy and garbage collection. So when you implement a custom session handler, you have to handle each of these stages to manage the session data properly.

There are two ways you could implement a custom session handler, either you could define callback functions for different stages in the session life cycle or you could write a class which implements the SessionHandlerInterface interface. In both cases, you need to use the session_set_save_handler function to initialize your custom session handler. In our case, we’ll use the SessionHandlerInterface interface implementation.

In our example, we’re going to store sessions in the MySQL database. So let’s create a table which stores the session data by using the following snippet.

Next, let’s see how our custom database session handler looks:

Our custom session handler class MySQLSessionHandler implements the SessionHandlerInterface interface. Thus, it must implement methods that are declared in the SessionHandlerInterface interface. We'll look at these methods one by one to understand how each one works.

First, to use this code, make sure to replace the HOST_NAMEUSERNAME, and other placeholders with actual values in the __construct method.

When the session is started, the open method is called. It returns TRUE if the database connection was successful. If there was any problem setting up the database connection, it returns FALSE.

Next, PHP calls the read method to read the session data. The read method receives the session id as the first argument. We’ll check if there’s any entry available for this session id in the session_data table. If it exists, we’ll return the session data otherwise an empty string will be returned.

When PHP needs to save or close a session, it calls the write method. It’s used to write the session data in a database. We’ve used the REPLACE syntax to make sure that if an entry exists then it would be updated, otherwise it’ll be inserted.

The close method is called after the session write method has been called. It works similar to a destructor in classes. In our case, there is nothing particular that needs to be done in the close method.

The destroy method is called when the session is destroyed with either the session_destroy or session_regenerate_id function. In this method, the session data is deleted from a database if it exists.

When PHP runs the garbage collector periodically, the gc method is called. The $lifetime variable holds the value of the session.gc_maxlifetime configuration option in the php.ini file. In this method, we’ll delete all sessions that are expired as a part of the garbage collection process.

Using the MySQL Session Handler Class

Now, let’s see how to use the MySQLSessionHandler handler class.

As you can see, we just need to initialize the MySQLSessionHandler class and pass it to the session_set_save_handler function to instruct PHP that it needs to use the MySQLSessionHandler class for session management. Next, we’ve called the session_start function to start a session. Finally, we’ve initialized a session variable for testing purposes.

If everything goes well, you should see the session entry in the sessions table as shown in the following screenshot.

And with that, you’ve a working custom session handler which manages sessions in a database!

Conclusion

In this article, we’ve explored the basics of session handling in PHP. It’s a key concept which allows you to persist information across web pages.

In the first half of the article, we discussed the basic concepts of sessions, and later on we created a few PHP examples to demonstrate how you could create and destroy sessions as well as manipulating session variables.

A related topic is cookies. You can learn how to use cookies in PHP right here at Envato Tuts+!

How to Work With Cookies in PHP

$
0
0

You might have heard about cookies, but what exactly are they and what can we actually do with them? In this tutorial, we will focus on the basics of cookies, and learn about their functionality in various web applications and site environments. We will also learn how to work with cookies in PHP.

Cookies vs Session Variables

Not sure if you need cookies or session variables? Session variables are a way to store data about a user in a database and to retrieve it later. Cookies are a way to store data about a user on the user's computer. Session variables are typically used in applications that need to keep track of a user's activity. Cookies are typically used in applications that need to store information about a user for a single site.

You can learn also learn about session variables in my post on using session variables in PHP.

What Is a Cookie?

Let’s start with the definition:

An HTTP cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie) is a small piece of data stored on the user's computer by the web browser while browsing a website.

We can think of cookies as text files, which are saved to your computer. When you request any web page, a web server sends the response of that web page to your browser. Along with the response, a web server could also send Set-Cookie HTTP headers that request your browser to create cookie files on your computer. Once cookies are created for a website, a web server can read and write content from and to these files subsequently.

Cookies have an expiration date along with the cookie data. This date is set so that a browser can delete old cookies when they are no longer needed by a web server. If the expiration date is empty, the cookie will be deleted when the connection with the server is closed. This occurs when the site's window or tab is closed by the user, or when the user closes the entire browser. These cookies, sometimes called session cookies, are mostly used for storing temporary settings.

Let’s quickly see how the Set-cookie HTTP header looks like with the following example:

In the above example, a web server asks the browser to create the LastVisitedSection cookie. The browser would store CodeTutsplus as the cookie data. A cookie file can store a text string or a number up to 4KB in size.

The expires attribute is used to specify the expiration date. And thus, the LastVisitedSection cookie will be deleted from your computer after the 31-Mar-2021 23:59:59 GMT date: March 31, 2021 at midnight.

The domain attribute is used to specify the domain in which the cookie will be active. If the domain is ads.google.com, the cookie will only be sent to the server of that domain, and if the domain is .google.com, the cookie will be sent to any server of any of the subdomains of Google, including google.com itself. In our example, the LastVisitedSection cookie will be available to tutsplus.com and any of the subdomains of tutsplus.com as well.

The path is the path of the domain to which the cookie is sent. This means that, if the path is set to /images/, and the domain is set to ads.google.com, the cookie will only be sent to the server if the browser requests a file from ads.google.com/images/. If the path is set to /, the cookie will be sent to the server regardless of the location of the requested file on the server. In our example, the LastVisitedSection cookie will be sent to all pages of the tutsplus.com domain.

So that’s how a web server creates cookies on your computer. In the next section, we’ll discuss the purpose of cookies.

What is the Purpose of Cookies?

The HTTP protocol is a stateless protocol, which means that there's no built-in way a server can remember a specific user between multiple requests. For example, when you access a web page, the server is just responsible for providing the contents of the requested page. When you access other pages of the same website, the web server interprets each and every request separately, as if they were unrelated to one another. There's no way for the server to know that each request originated from the same user.

Now, if you want to implement features like user login or shopping carts, you'll need to identify if two requests came from the same browser. This is not possible with a stateless protocol. We need to maintain state or session between requests that are made by a browser to identify a user. That’s where cookies come to the rescue!

Cookies allow you to share information across the different pages of a single site or app—thus they helps maintain state. This lets the server know that all requests originate from the same user, thus allowing the site to display user-specific information and preferences.

The following diagram depicts how the HTTP protocol works with cookies.

Stateful Flow

How to Create Cookies in PHP

In this section, we’ll discuss how you can create cookies in PHP.

To create cookies in PHP, you need to use the setcookie function. Let’s have a look at the basic syntax which is used to create a cookie.

The argument list in the setcookie function should look familiar to you as we’ve already discussed most of these parameters earlier in this article. However, there are two more arguments, $secure and $httponly, that are important to understand.

If you set the $secure parameter to TRUE, the cookie will only be created if a secure connection exists. The $httponly parameter allows you to make cookies HTTP only, and thus it will be accessible only through the HTTP protocol. Cookies that are set as HTTP only won't be accessible by scripting languages like JavaScript.

So that’s about the syntax, let’s have a look at a real-world example.

It would create the LastVisitedSection cookie with the CodeTutsplus value, and it would expire in an hour. The path argument is set to /, so it would be sent to all pages of the tutsplus.com domain.

Now, let’s have a look at the following example.

As we’ve set the path argument to /courses/, the favCourse cookie will be only sent if a browser requests pages from https://code.tutsplus.com/courses/.

In this way, you can create cookies in PHP. The most important thing to remember, when creating a cookie in PHP, is that you must set all cookies before you send any data to the browser. Cookies belong in the header, so you should always initialize new cookies before any output. This includes echo or print commands, and the <html> or <body> tags.

How to Read Cookies in PHP

Reading cookies in PHP is straightforward. You need to use the $_COOKIE superglobal variable to read available cookies. In fact, the $_COOKIE variable is an array which contains all cookies.

Let’s have a look at the following snippet.

You can use the print_r or var_dump function to check all available cookies for debugging purposes.

It's that easy to read cookies in PHP!

In the next section, we’ll see how to delete cookies.

How to Delete Cookies in PHP

It would be interesting for you to know that you can use the setcookie function to delete cookies as well. The catch is that you need to set the expiration date in the past and a cookie will be deleted.

Let’s see it in action in the following example.

As you can see, we’ve specified the expiration date in the past by setting it to time() - 3600. It’s important to note that we’ve also used the unset function to remove the LastVisitedSection cookie from the $_COOKIE superglobal variable to make sure that the LastVisitedSection cookie is not accessible later in the code.

Best Practices for Using Cookies in PHP

To wrap up I would like to sum up some best practices:

  • Never insert sensitive data into a cookie. A client could be browsing on a public computer, so don't leave any personal information behind.
  • Never trust data coming from cookies. Always filter strings and numbers! Client computers can change cookies at will, so an attacker could write malicious data to the cookie in order to do something you don't want your service to do.
  • Try to estimate how long the cookie should be valid, and set the expiration date accordingly. You don't want to hog the client's computer with old cookies which are set to expire in a hundred years.
  • Always set the secure and httponly flags when possible. If your application doesn't edit the cookies with JavaScript, enable httponly. If you always have an HTTPS connection, enable secure. This improves the data's integrity and confidentiality.

Conclusion

Today, we discussed the basics of cookies and how to use them in PHP. A related topic is sessions and session variables. You can learn how to use session and session variables in PHP right here at Envato Tuts+!

Functions in PHP: Return Values and Parameters

$
0
0

Functions are an important part of programming languages. They help us avoid code duplication by allowing us to run same set of instruction over and over again on different data.

In this tutorial, we will talk about functions in PHP. We will cover all the basics concepts of functions in PHP. This tutorial will teach you how to create your own user-defined functions in PHP. You will learn about return values from a function and function parameters in PHP. You'll also learn other concepts like setting default argument values or passing an argument by reference. 

Internal Functions in PHP

PHP comes with a lot of built-in functions that you can use in your program. Some of these functions come with PHP as standard while others become available to you through specific PHP extensions.

PHP comes with a lot of functions to work with strings. For example, you can use the str_contains() function to check if a string contains a substring and wordwrap() function to wrap wrap a string to given number of characters. These functions are available for you to use as standard.

Another set of PHP functions to manipulate images are available if you install the GD extension library. Once the extension is enabled, you will be able to use functions like imagecreatetruecolor(), imagecreatefrompng() and imagefill() to create and manipulate images.

If you ever get a fatal undefined function error in PHP but you are certain that it is an internal function, make sure that you have installed the respective extensions to use that function.

User Defined Functions in PHP

You can also define your own functions in PHP. Defining your own functions becomes a necessity in almost every non-trivial program you write. They are a great way to avoid code duplication and errors.

Here is some basic code to define a function that outputs a greeting when we call the function later.

In the above example, we just passed a name to the greet() function and it echoed different output based on the specified name.

You have to follow specific rules when defining a function. The name of a function has to start with a letter or an underscore. After that, you can use different length of numbers, letters and underscores in the name. This means that greet01(), _greet() and greet_01() are all valid function name in PHP. However, using 01_greet() as a function name will throw a syntax error.

Return From a Function in PHP

In the previous example, our user-defined greet() function did not return anything. It just echoed a couple of sentences based on the input. It is entirely up to us to return anything back inside any function we define in PHP.

When you want to return something, you need to use the return statement. A function can return any type of value in PHP. This includes strings, integers, floats, arrays or even objects.

In the above example, the palindrome() function turns any given string into a palindrome by appending it to its reversed version. Now instead of echoing the output directly, we assign it to a variable. We can now further manipulate the variable but just echo it in this example.

A function can have multiple return values and the execution of the function stops immediately once it encounters a return statement. This means that you can only return one value from a function. However, you can work around this limitation by returning an array that consists of all the values that you want to return as its elements.

In the above example, we wanted the function to return a bunch of information about the name passed to it. So, we used an array with mixed values. The passed values are then assigned to different variables using list().

You should also note that the greet() function did not echo Bye Monty! in our program. This is because the function execution was stopped as soon as it encountered a return statement.

Function Parameters in PHP

Function parameters (also known as "function arguments") are used to pass input to a function upon which it can act to give us the desired output. We have only defined functions with a single parameter so far in this tutorial.

However, it is entirely up to us how many parameters we want to pass to a function. It can be zero for functions which don't require any kind of input from us. It can also be two, three, five, or ten. You can also pass arrays as parameters.

Here is an example of PHP functions that accept zero and two parameters respectively.

We can rewrite the second function to pass an array as our only parameter. We will just extract different values from the array inside our function. This can be helpful in situations where you want to either manipulate arrays or pass a lot of values to a function.

Specifying Default Argument Values

Let's say you create a greeting function that is mostly used to wish users good morning. The value of $time in our greeting_time() function will usually be morning then. In such cases, you can make the your program shorter and code easier to read by assigning sensible default values to specific arguments.

This is actually quite common in built-in PHP functions. The strpos() function is used to find the location of a substring in a string. The function takes three arguments: the string, the substring, and the position where you want to start. The function returns the index of the substring in the string.

The position parameter is the pooint at which you want to start looking for the substring. Usually, we want to look inside the main string from its starting position. This means that the value of offset will usually be zero.

Instead of asking us to specify the offset as 0 each time we call the function, PHP sets it value to 0 by default. Now, we only need to specify the third parameter when we want to change the offset to something else.

We can also set a default value for different parameters in our own functions. Here is an example:

There are two things that you need to keep in mind about default parameters or arguments. First, they have to be a constant value like morning in our case. Any arguments with default values should always be on the right side. For example, the following function definition will cause an error during the first call.

The reason for the error is the ambiguity about the argument Monty. PHP has no way of knowing if you want it to be the value of $name or if you want to use it in place of default $time value.

Passing Arguments by Value vs Passing by Reference

By default, different arguments are passed to a PHP function by value. This way we can avoid changing the value of the argument passed to a function. However, if you intend to change the value of arguments passed to a PHP function, you can pass those arguments by reference.

The following example should help you understand the difference between these two approaches.

The argument in r_palindrome() is passed by reference. This means that when we pass $word_b to r_palindrome() the value of $word_b itself is changed to a palindrome.

Conclusion

In this tutorial, we have covered a lot of basics related to functions in PHP. Hopefully, you can now write your own user-defined functions that take advantage of everything we learned here. Feel free to ask any questions you have about this topic in comments.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our free online course on PHP fundamentals!

 

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming (OOP). Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.

How to Call a PHP Function From JavaScript

$
0
0

PHP comes with a lot more built-in functions to work with strings, arrays and other types of data in comparison to JavaScript. Therefore, it is natural for a lot of people to feel the urge to call PHP functions from JavaScript. However, as you might have guessed or found out this does not work as expected.

There can be a lot of other cases, where you might want to run some PHP code inside JavaScript—for example to save some data on your server. Simply placing the PHP code inside JavaScript will not work in this case either.

The reason you can't simply call a PHP function from JavaScript has to do with the order in which these languages are run. PHP is a server side language and JavaScript is primarily a client-side language.

Whenever you want to visit a page, the browser sends a request to the server which then processes the request and generates some output by running the PHP code. The output or generated webpage is then sent back to you. The browser usually expects the webpage to consist of HTML, CSS and JavaScript. Any PHP that you might have placed or echoed inside JavaScript would either have run already or won't run at all when the webpage loads in the browser.

All hope is not lost though. In this tutorial, we will explain how you can call PHP functions from JavaScript and JavaScript functions from PHP.

Call a PHP Function From JavaScript

We can use AJAX to call a PHP function on data generated inside a browser. AJAX is used by a lot of websites to update parts of webpages without a full page reload. It can significantly improve user experience when done properly.

Keep in mind that the PHP code will still run on the server itself. We will just provide it data from within our script.

Using jQuery AJAX to run PHP Code

If you are using jQuery on your website, it becomes incredibly easy to call any PHP file with code that you want to run.

You can pass one or two parameters to the ajax() function. When two parameter are passed, the first one will be the URL of the webpage where the browser will send your request. When you pass only one parameter to ajax(), the URL will be specified in the configuration.

The second parameter contains a bunch of different configuration options to specify the data your intend to process and what to do in case of success or failure etc. The configuration options are passed in JSON format.

You can use the method parameter to specify the HTTP method which should be used for making the request. We will be setting it to POST because we will be sending data to the server as well.

Now, let's see an example of a basic AJAX request where we will pass data to a PHP file and call the PHP function wordwrap() within that file. Here is our complete webpage:

Place the following code in a file called wrap.php in the same directory.

Remember that you have to echo the data that you want to send back to the browser. Your webpage will look like the image below if everything goes well.

Calling PHP Function in JavaScript with AJAX

Using Fetch API to Run PHP Code

You can also use the Fetch API to run PHP code on data collected inside the browser by sending a POST request to the server. In the previous example, we could replace the AJAX code with the following JavaScript to get the exact same result.

Just like the AJAX example, we specify the URL and provide additional header information that we will be sending our data in URL encoded form. This allows us to use $_POST on server side to read the data.

Call a JavaScript Function From PHP

As you know by now, PHP will run before JavaScript when you request a webpage from some server. We can also output anything we want to show on the webpage using echo. The same echo can be used to output JavaScript that will run in client's browser.

Here is some example code that will check an array of strings to find the index of last palindrome. This index is stored in a PHP variable which is then passed to JavaScript written inside the script tag using echo.

The above example shows how you can pass data from PHP to JavaScript by simply echoing it. Just make sure that the code you echo is valid JavaScript.

Conclusion

We all know that PHP runs on servers and JavaScript usually runs in browsers. Since they both execute at different times, you cannot just simply call functions from one language inside another and expect the code to work. However, there are ways to work around that issue which it is possible to exchange information between PHP and JavaScript.

To summaries, you can use AJAX when you want to call a PHP function from JavaScript or run PHP code on some data generated inside browsers. You can use echo in PHP to output JavaScript code which will run later in client's browser. If you have any questions about the article, please let me know in the comments.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our free online course on PHP fundamentals!

 

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming (OOP). Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.

Make a Simple Mobile App With Material Design: Create a Login Screen

$
0
0

Material Design is a design system that helps teams build high-quality digital experiences. It brings together style, interaction, and motion to create hierarchy, meaning, and continuity throughout the application.

Material Design comes with material components for Android that are necessary to ensure developers come up with beautiful designs. In this tutorial, you'll get an overview of several of these Android components and build a login page using Material Design.

The login page will contain the following components

  • the app logo
  • username and password text fields
  • a login button
  • a reset password link

Prerequisites

  • basic knowledge of Android development
  • Android Studio (learn more here if you don't have it already)
  • an Android emulator or physical device 

Getting Started

To create a new project in Android Studio, select the Empty Activity, and click Next. Enter a name, pick a location, and select an API level. Click Finish to create the project.

Add Project Dependencies

Navigate to the app module's build.gradle file and add the MDC Android support library as shown below and sync the project.

The Main Activity Layout

We edit the main Activity layout main_activity.xml. in The main activity contains a simple Constraint Layout which acts as a container for the TextView component.

Constraint layout provides a drag-and-drop interface that allows you to position a given widget relative to another one. You can constrain a widget on the horizontal and vertical axis.

AppCompat Theme and Colors

The theme for our application is set to Theme.MaterialComponents.DayNight.DarkActionBar by default. Let's change it to Theme.Appcompact.Light.DarkActionBar. The theme.xml file also defines other colors as shown below.

The color system allows us to quickly change the color scheme of the entire application.

  • colorPrimary and colorSecondary are the colors of your brand. colorSecondary provides more ways to accent select parts of your UI.
  • colorPrimaryVariant  and colorSecondaryVariant are lighter or darker shades of colorPrimary and colorSecondary
  • colorOnPrimary is used to tint elements displayed on top of the primary colors, such as text and icons.
  • colorOnSecondary is used to tint elements displayed on top of the secondary colors such as text and icons)
  • colorBackground is the background color of your app

The Material Design color system is meant to create harmony in apps. Google standards describe how to create a color palette that is intended to enhance the user experience. The diagram below shows an example of a color palette that can be used with Material Design.

Material design color palette

How to Use the Material Design Color Palette

When choosing the colors for you app, it is recommended to limit to three primary hues and one secondary color. The primary color is the color that appears most frequently across your app's screens and components. A secondary color is optional and provides a contrast to your application. You can also use a primary color to provide contrast. The secondary color should be used for specific actions such as:

  • text fields and cursors
  • floating buttons
  • text selection
  • progress bars
  • selection controls, buttons and sliders
  • links

The UI below shows a representation of the correct use of color in Material Design.

material design

Material Design Components

As mentioned earlier in the tutorial, Material Design apps use Material Design components. Some of these include:

  • Android menus and tool bar
  • floating action buttons (FABs), snack bar, and coordinator layout
  • floating labels
  • AppBar
  • collapsing toolbar
  • navigation drawer and menus
  • Android animations
  • recycler view and card view

Lets start by adding the logo using the material design ImageView component. Delete the TextView and add the following to main_activity.xml

Next, add the username and password text fields . We'll use the Material Design text field component, which includes built-in functionality that displays a floating label and error messages.

The android:inputType="textPassword" attribute hides the input text when someone is entering the password.

Don't forget to add the string resources for the text fields in the strings.xml file.

Configure a Vector Asset

Vector assets allow you to configure images with a single vector graphic. Let's add vector assets for the username and password text fields. Go to  drawable > New > Vector asset and choose a person clip art image for the username text field.

vector asset

Repeat the same process and select a lock for the password text field.

Two XML files have now been created in the drawable folder, and you can use the drawable file with the attribute android:drawableStart, as shown below. 

 

The app should now look like this.

material login

Next, add the Login button. We'll use the Material Design component Button component, which comes with a built-in ink ripple effect.

Lastly, add the forgot password text view below the login button.

Round Background

Lets create a round background for the elements. Go to Drawable > New drawable resource and add the folllowing.

Add the background to the text fields and button.

 The final app should look like this:

material login

Conclusion

In this tutorial, you've learned about Material Design fundamentals and how to apply colors in material design to fit your brand. The key to a beautiful application in Material Design lies in bringing different elements together while following the Material Design principles.

11 Best PHP Blog Scripts and Blogging Platforms

$
0
0

Are you looking to start an independent blog or add a business blog to your website?

Blogs are the most reliable means of growing a business and boosting revenue. They are the best way of letting visitors know what your business is about. In addition to help you generate leads, blogs build trust in existing customers and keep them coming back.

If you want to add a blog to your existing website or create an independent blog then blogging scripts are the way to go. 

PHP blog scripts are software that provide solutions that help you install and run a self-hosted content management system. A content management system is a blogging platform. 

These PHP blog scripts are installed on your server where you run a self-hosted blog platform independent of any third-party rules.

Blogging scripts come with features that allow you to build robust blogs that will engage visitors and convert them into customers. They have built in content management systems that make it easy for you to create and management different types of content. 

Using the PHP blog scripts featured in this article, you can run a self-hosted blogging platform, build an independent blog or you can add a blog to your existing website. 

Active Newspaper CMS
Active Newspaper CMS is an example of PHP Blog Scripts available on CodeCanyon

Some features you'll expect with PHP blog scripts include: an admin section where you can build blogs, a live preview screen to where you can review your blog before publishing it, customizable style, and a place to put articles and ads.

Best-Selling PHP Blog Scripts on CodeCanyon

Your blog is a place to have conversation with visitors to your website. Grab one of these best-selling PHP blog scripts and turn your website into a traffic magnet. PHP blog scripts are loaded with tons of features that allow visitors to engage with your website and content. 

Topselling PHP Blog Scripts on CodeCanyon

Using blogging scripts you can:

  • add a blogging section to your website
  • build your own independent blog or magazine 
  • increase engagement with visitors 
  • improve your visibility
  • convert visitors into customers 

Best Blog PHP Scripts on CodeCanyon

Whether you want to build a PHP blog with thousands of pages, or a PHP microblog, these PHP blog scripts will help. Let's have a look:

1.Best-Selling: Varient News Magazine Script

Varient News Magazine Script

Varient is a multi-purpose news and magazine PHP blogging platform that comes with all the features you need to start and run a dynamic news and magazine blog. You get unlimited pages and categories like news, sports, politics, and lifestyle. It has a clean, responsive and user-friendly design.

You can get authors to write for you through a multi-author system. Each author has their own panel to manage their posts and videos. And also through its powerful admin panel you can grant or limit access or responsibility for each editor or author.

You can even highlight some of your best articles and posts using featured posts and sliders. You can create memberships for readers who can gain access using their social logins. Readers can comment on articles. 

It has RSS aggregator system and you can use it as an autopilot script. It is secure, SEO optimized, fast and easy to use.

2. Best-Selling: Blog Manager Module for CMS Pro

Blog Manager Module for CMS pro

If you want to create unique blogs, articles, and news items, then look no further than the Blog Manager Module for CMS Pro. This very comprehensive blog script is made up of five plugins that make it so easy to create a blog: search, category menu, latest comments, archive list, and most popular.

It doesn't overwhelm you with too many layout options. It gives you 4 unique layouts to assign to each article and category. Each layout depends on the image size. You can also assign ratings, voting and social sharing for each article.

3. Trending: Infinite Blog and Magazine Script

infinite-blog-magazine-script

Infinite is a multi-purpose blog and magazine PHP script. It has a clean, responsive and user-friendly design. You can manage your posts, custom pages, categories, user comments, advanced settings and contact messages with its powerful admin panel.

It also has a useful ad management system to help you manage your ad spaces. It is secure, SEO-optimized, fast and easy to use.

4. Active Newspaper CMS

Active Newspaper CMS

To generate revenue through blogging you need to stand head and shoulders above your competition. Active Newspaper CMS has the impressive UX and UI to help distinguish your site. Through the powerful admin panel of this newspaper PHP script you can manage news reporters and bloggers, video uploads, and create polls. On the front-end users can log in through their social media and they can also share articles on their social media. 

But that's not all! It's built with monetization of your blog articles in mind. You can take advantage of the 47 premium advertisement spots by offering them on the headers, homepage, news categories, image gallery and more. You can also create subscription packages for bloggers. It accomodates nearly all international payment gateways, so receiving payments is easy.

Active Newspaper CMS  doesn't leave you to figure it out on your own. To show you how to use it so you can get your blog up and running without any delays, it comes with extensive knowledge base that includes video tutorials, diagrams, how-tos, and other info.

5. Instant Blog—Fast and Simple Blog PHP Script

Instant Blog - Fast & Simple Blog Php Script

You can distribute articles and upload them to Facebook or Google and they will display 10 times faster than the standard mobile web. Instant Blog will help you create instant articles for Facebook and Google AMP pages. This SEO-optimized, fast, and simple-to-use PHP script can be easily installed through a wizard. It has a clean, responsive and user-friendly design.

From its powerful admin panel you can manage your posts, categories, and users. You have access to dynamic forms for creating posts. You can auto embed content with URLs from YouTube, Twitter, Facebook, Instagram and Pinterest. It also comes with an ad management system so you an easily add ads to your posts. 

6. phpBlog—News, Blog, and Magazine Script

phpBlog - News, Blog & Magazine Script

phpBlog is a multi-purpose CMS blogging platform built using procedural PHP without any framework so it can be easily customized. It has clean, simple, lightweight, responsive and user-friendly design. It can be used for blogs, portals, company and agency websites, magazines, newspapers, and more. 

With its powerful admin panel you can manage posts, categories, user comments, gallery, custom pages, widgets, ads, website settings, and contact messages. It is very well secured, SEO-optimized, fast, and easy to use. 

7. Viavi News Magazine Blog Script

Viavi News Magazine Blog Script

Viavi is a responsive news and magazine-focused blog script that allows you to create a stunning blogs by choosing from customizations option that include: 12 color styles, page layouts where you can decide how many columns you need, sidebar placements, custom headers, and footers. 

To generate more engagement for your articles and posts, this news magazine blog script is integrated with the Disqus and Facebook comments systems. Social share is also incorporated to allow visitors to share articles and posts. 

8. Newspaper—Responsive News, Magazine and Blog CMS Script

Newspaper - Responsive News, Magazine and Blog CMS Script

Newspaper is complete solution for any kind of news, magazine and blog management system. This fully responsive CMS script comes with four attractive templates so you can choose which look you want for your magazine or blog.

The back-end has a lot of awesome features that help you manage categories and sub-categories, pages, galleries, posts, polls, and advertising spaces. It also allows multiple admin with different roles.

There is also a built-in newsletter system that allows you to send posts and messages to all your subscribers via email. Finally, its advanced security makes sure your magazine or blog is protected from SQL injection, invalid submissions and session hijacking.  

9. Fibonacci—Laravel Portfolio and Blog CMS Script

fibonacci-laravel-portfolio-cms-script

Fibonacci is the perfect choice for web designers who want to set up their own portfolio websites that also have a built-in blog. This PHP portfolio and blog script is fully responsive and has a clean, modern design that allows you to give clients an interactive presentation experience of projects you've done, products and services you have to offer. 

It comes with an easy to understand admin panel that allows you to create your website in just a few clicks, no coding experience required. It has seven homepage versions to choose from, working contact form, Google analytics, Open Graph tags, light or dark mode, comment system and more. There even is a maintenance mode to let your visitors know you're doing updates. 

10. Laramagz—Laravel News and Blog CMS Script

laramagz-laravel-news-blog-cms-script

Laramagz is a powerful CMS that you can use to build a news, magazine, or blog portal. It comes with powerful admin panel where you can customize your magazine or blog, change logos, favicons, site title, site description and more. It supports multi-author system and lets you assign permissions by roles. 

On the admin panel you also have access to Google analytics and reCAPTCHA to protect against spamming. On top of that, it has a built-in newsletter that allows you to send HTML email to all registered emails. It is SEO-friendly and supports MailChimp. 

11. Easyee CMS—Blog, News, Magazine in Yii

Easyee CMS - Blog, News, Magazine in Yii

Easyee CMS  is a blogging CMS script. It has a clean, responsive and user-friendly design. You can manage almost everything in your site with its powerful admin panel. It has a multi-author system and all authors have their own panel to manage their posts. It is secured, SEO-optimized, fast, and easy to use.

Why is a Blog Important for Your Business?

A blog is the perfect platform for telling your brand stories. Customers look to blogs as a source of information and advice. This means a blog enhances credibility of your website. Blogging also helps in building relationships with your customers. It also provides your company with a voice. A blog can help you connect with the audience. You get a chance to share ideas and thoughts with the customers. Finally, a blog helps you build traffic to your website. A blog is an excellent source of referral traffic.

What Are the Keys to a Successful Blog?

Be Persistent

A successful blog is not just about the time you spend on it. It is about the quality of writing. You need to be very consistent in your posting schedule. This is because it takes time for your blog to build a reputation. It is important to understand that blogging is a long-term strategy. You need to be very patient if you want to see results.

Active blogs generate around 60% of leads. Consistency is key to your success, decide the frequency with which you want to release content on your blog. 

Know Your Audience

When you target everyone you will reach no one. Your message will not be heard. It's important to have a target audience and a niche in mind. You can also use tools like Google Analytics to keep track of the audience. This will help you in improving your content strategy.

Understand the needs of your audience, target your content to their needs, targeted content will bring more traffic to your website. Offer them information that is relevant to their needs, with solutions or suggestions of how they can solve their problem. This is how you build trust and get your visitors to come back as lead and customers. 

Connect With Your Customers

Think of a blog as a place where you have conversations with your customers in a way they can relate to you. The language is casual, relatable, easy going. It will help you connect with visitors who are looking for solutions to their problem.

Plan to engage with visitors by creating a vibrant, engaging comment section. Answer any questions and reply to comments from visitors. Comments sections offer a way of understanding what your visitors and customers are looking for. Look at it as fertile ground for topics to address in your blogs. When you do this you will be meeting their most pressing needs. 

Choose A PHP Blog Script and Start Blogging Now!

On CodeCanyon you will find many more PHP blog scripts and of course many other kinds of PHP scripts to choose from. With these scripts, you can easily set up a blog from your website without coding knowledge. 

Topselling Blog PHP Scripts on CodeCanyon

Check out some of our other posts on PHP and PHP scripts.

How to Create a Custom WordPress Plugin From Scratch

$
0
0

Every WordPress site needs a theme to pull content from the database and display that in a design. And theoretically you could run a site with just a theme and nothing else. But that site would be very limited without the addition of plugins.

Plugins add extra functionality to your WordPress site over and above what comes with WordPress core. Everything from a booking calendar or animated slider, to a full-featured learning management system or online marketplace—you can add them all to your site with plugins. 

In this guide, I’ll show you how to create your own WordPress plugin. I’ll show you how to use best practice in plugin development, how to get the code in your plugin to run, and how to structure your plugin’s code and files. I’ll also walk you through the process of creating your first plugin and answer some FAQs.

Free and Paid WordPress Plugins

If you want to add some specific features to your website, there are plenty of places you can buy or download plugins. The WordPress plugin directory includes thousands of free plugins that’ll help you create the site you need. But if you’re looking for more advanced features, a better user interface, or improved support, it’s worth buying premium plugins from authors on CodeCanyon.

CodeCanyon WordPress Plugins

But sometimes you might need to code your own plugin! This can be more efficient than using a third-party plugin, as you might only need a part of the code provided by those. It also means you can develop a plugin that meets your needs more precisely, or you can customize an existing plugin to adapt it for your site.

What Do You Need to Make a Plugin?

To build your own plugin and run it on your WordPress site, you’ll need:

  • a code editor
  • a development WordPress installation with a copy of your live site for testing

Don't test your plugin on your live site until you know it works!

If you don’t already have a local WordPress installation, follow our guide to copying your site to a local install. Or if you can’t install WordPress locally, use a duplicate of your site on a testing installation on your server. Find out how to copy your site.

Types of WordPress Plugin

Plugins can carry out lots of tasks. What they all have in common is that they add extra functionality to your site. Types of WordPress plugin include:

  • site maintenance plugins for things like security, performance, or backups
  • marketing and sales plugins for things like SEO, social media, or eCommerce
  • content plugins such as custom post types, widgets, shortcodes, forms, galleries, and video feeds
  • API plugins that work with the WordPress REST API or pull in external content from services like Google Maps
  • community plugins that add social networking features

…and lots more! For an idea of what plugins can do, check out the WordPress plugin directory and the CodeCanyon marketplace.

WordPress plugin directory

What Goes Into a Plugin? 

Before you get started building your plugin, it’s worth knowing what goes into a plugin. Exactly what the plugin code will look like will depend on your plugin: some are small, with just one plugin file, while others are massive, with multiple include files, scripts, stylesheets and template files. And there are plenty that fall somewhere in the middle.

The elements you’ll probably have in your plugin are:

  • the main plugin file (this is essential)
  • folders for different file types
  • scripts
  • stylesheets
  • include files to organize the code

Let’s have a look at each of these.

The Main Plugin File

The main plugin file is essential. It will always be a PHP file, and it will always contain commented-out text that tells WordPress about your plugin.

Here’s an example, from the Akismet plugin:

This tells WordPress what your plugin does, where to find out more about it, and who developed it. It also gives information about the version number and the text domain and path for internationalisation, as well as the license.

WordPress takes this information and uses it to populate the plugins screen in your site. Here’s how Akismet looks on that screen:

Akismet in the plugins admin screen

You can see that the information provided in the plugin file is used to populate this entry and provide links.

Other information about the plugin is contained in the README.txt file, which is used to populate the plugin's page in the plugin directory:

Akismet in the plugins directory

The main plugin file will also contain the code that makes the plugin run. Sometimes that will be all the PHP for the plugin, but for larger plugins, there’ll be calls to include files containing extra code. This helps you organize your code and means you don’t have one long disorganized file that’s difficult to work with. I’ll show you how to use include files later in this guide.

Folder Structure

While there are no hard and fast rules on how you organize the folders in your plugin, it makes sense to adopt the same structure that other plugin developers use. This will familiarize you with the way other plugins are built and mean that if you share your code in future, it will make sense to other people.

Folders in your plugin might include:

  • css or styles for stylesheets
  • scripts for JavaScript
  • includes for include files
  • templates for template files that your plugin outputs
  • assets for media and other asset files
  • i18n for internationalisation files

You might find you need to use more folders if your plugin is large or complex. For example, WooCommerce has folders for packages, sample data, and more. These in turn include subfolders for things like blocks and admin files.

WooCommerce files

Scripts and Stylesheets

If your plugin outputs content that needs styling, either in the front-end or in the admin screens, you may need stylesheets. And if your plugin will use scripts, you’ll need files for these.

It makes sense to keep these in their own folder, even if you only have one of each. You’ll need to enqueue these scripts and stylesheets using a dedicated function in your main plugin file. I’ll show you how to do this when we’re building the plugin.

Include Files

If your plugin needs organisation, you can do this by splitting your code into multiple files, called include files. You then put these files into their own folder and call them in your main plugin file using an include or require function.

This way, you can keep the bulk of your code in a well-organized file structure while your main plugin file remains lean and minimal.

If your plugin isn’t all that big, you don’t need to use include files: just add your code to the main plugin file. But you might find you need to organize this file and reorder functions within it as you add them, to maintain a logical structure.

These are the most common elements of a plugin. We’ve seen in the WooCommerce example that there can be many more. Or in smaller plugins there can be many fewer. But as you develop more plugins, you’ll find yourself using these elements more and more.

How to Run Your Plugin Code: Options

When you add code to your plugin, it won’t do anything until you activate it in some way. There are a few methods you can use to activate your code or pull in code from WordPress:

  • functions
  • action and filter hooks
  • classes

Let’s take a look each of these.

Functions

Functions are the building blocks of WordPress code. They’re the easiest way to get started writing your own plugins and the quickest to code. You’ll find plenty of them in your themes' files too.

Each function will have its own name, followed by braces and the code inside those braces.

The code inside your plugin won’t run unless you call the function somehow. The simplest (but least flexible) way to do that is by directly calling the code in your theme or somewhere else in your plugin.

Here’s an example function:

To directly call that function in your theme, you’d simply type tutsplus_myfunction() in the place in your theme template files where you want it to run. Or you might add it somewhere in your plugin... but you’d also need to activate the code that calls it!

There are a few limitations to this:

  • If the function does something that isn’t just adding content somewhere in a theme template file, you can’t activate it this way.
  • If you want to call the function in multiple places, you’ll have to call it again and again.
  • It can be hard to keep track of all the places you’ve manually called a function.

It’s much better practice to call functions by attaching them to a hook.

Action and Filter Hooks

By attaching your function to a hook, you run its code whenever that hook is fired. There are two types of hook: action hooks and filter hooks.

Action hooks are empty. When WordPress comes to them, it does nothing unless a function has been hooked to that hook.

Filter hooks contain code that will run unless there is a function hooked to that hook. If there is a function, it’ll run the code in that function instead. This means you can add default code to your plugin but override it in another plugin, or you can write a function that overrides default code that’s attached to a filter hook in WordPress itself.

Hooks are fired in three ways:

  • By WordPress itself. The WordPress core code includes hundreds of hooks that fire at different times. Which one you hook your function to will depend on what your function does and when you want its code to run. You can find a list of WordPress hooks in the developer handbook.
  • By your theme. Many themes include action and filter hooks that you can use to add extra content in key places in your website’s design. And all themes will include a wp_head and wp_footer hook. Combine these with conditional tags and you can run specific code on certain types of pages in your site.
  • By your plugin or other plugins. You might add an action hook to your plugin and then add functions in your include files that attach code to that hook. Or you might write a filter hook and then have a function that overrides its contents under certain circumstances. Alternatively, if you’re creating a plugin to complement another plugin, you can hook your functions to the existing hook in the third-party plugin. I’ve done this with WooCommerce, for example, to customize what’s output on product pages.

Some of this is more advanced, but with your first plugin, you’ll probably be hooking your functions to an action or filter hook output by WordPress itself, most likely an action hook.

Classes

Classes are a way of coding more complex features such as widgets and customizer elements, that make use of the existing WordPress APIs. 

When you write a class in your plugin, you’ll probably be extending an existing class that’s coded into WordPress. This way, you can make use of the code provided by the class and tweak it to make it your own. An example would be the customizer, where you might write a class including a color picker, making use of the color picker UI that’s provided in the existing class for the customizer.

Using classes is more advanced than functions, and it’s unlikely you’ll do it in your first plugin. To find out more, see our guide to classes in WordPress.

If you do write classes, you’ll still have to use actions or filters to get them to run.

Plugin Best Practices

Before you start coding your plugin, it helps to understand best practices for plugins so your code can be high quality right from the start. 

These include:

  • Write your code according to WordPress coding standards. If you want to submit your plugin to the plugin directory, you’ll have to do this.
  • Use comments throughout your code so other people can work with it—and so you remember how your code works when you come back to it in the future.
  • Name your functions, hooks, and classes using prefixes so they are unique to your plugin. You don’t want to give a function the same name as another function in a different plugin or in WordPress core.
  • Organize your folders logically, and keep your code separated so other people can understand it and so you can add to it over time without it becoming a mess.

You might think that using best practice isn’t necessary because it’s just you working with the plugin. But your plugin might grow over time, you might let other people use it, or you might sell it. Or you might come back to it in two years and not be able to remember how the code is organized!

Creating Your First Plugin in 4 Steps

At last! You have a grounding in how plugins work, and it’s time to roll your sleeves up and create your first plugin. I’m going to take you through the process of creating a simple plugin that registers a custom post type.

This is a very common use of a plugin, and something you might then build on over time to add custom template files for your custom post type or other functionality.

I’ll show you the basic code for the plugin and give you an introduction to how you might add to it over time.

1. Create the Plugin Folder and File

Even if your plugin is starting out small with just one file, it’s good practice to give it its own folder. Start by creating a folder in your wp-content/plugins directory. Inside that, create a PHP file for your plugin.

Give them both a name that makes sense and includes a prefix. I’m calling my folder tutsplus-register-post-types and my file tutsplus-register-post-types.php.

Now open your plugin file and add the commented-out information at the top. You can take mine below and edit it to reflect the fact that this is your plugin, not mine.

Now, if you save your file and go to the Plugins screen in your development site, you’ll see the plugin on the screen:

New plugin in the plugins admin screen

You can activate it if you want, but it won’t do anything yet because you haven’t added any code to it. Let’s do that.

2. Add Functions

Now it’s time to write the first function in our plugin. Start by making your plugin and adding the braces which will contain the code. Here’s mine:

This includes all the labels and arguments for your post type and (crucially) the register_post_type() function which is provided by WordPress.

I’ve used movies as my post type here as I’m creating an imaginary movie review site. You might want to use something different.

Now, if you save your file and go back to your site, you’ll see that nothing has changed. That’s because you haven’t activated your code. The method we use to activate the function here is by hooking it to an action hook provided by WordPress, the init hook. When you use a function provided by WordPress (such as register_post_type), you’ll find that there’s a hook that you should use. You can find details in the WordPress handbook entry for registering custom post types.

So let’s add the hook. Under your code, and outside the braces, add this line:

We use the add_action() function to hook our code to an action hook, with two parameters: the name of the action hook and the name of our function.

Now try saving your files and going back to your site. You’ll see that the custom post type has been added to your admin menu (assuming you’ve activated the plugin).

New post type in admin menu

Nice!

Now let’s add an extra function, to register a custom taxonomy. Below the code you’ve written so far, add this:

Again, you might want to change the name of your custom taxonomy. Here, I’ve made the taxonomy apply to the post type I’ve just registered (the third parameter of the register_taxonomy function). If you gave your post type a different name, make sure to edit that bit.

Now save your file and take a look at your admin screens. When you hover over your post type in the admin menu, you’ll see the new taxonomy.

New taxonomy inn WordPress admin

You now have a working plugin. Well done!

Let’s take a look at how you might add to it.

3. Enqueue Stylesheets and Scripts

If you need to use custom styling or scripts in your plugin, you could add them right into your plugin file—but that’s not best practice. Instead, you should create stylesheets and scripts as separate files in your plugin folder and enqueue those, using a function provided by WordPress.

Let’s imagine you want to add styling for your custom post type. You could add this to your theme, but you might want to add some specific styling to the plugin to make the post type stand out from other post types in any theme.

To do this, you create a new folder inside your plugin folder called css (or styles, it’s up to you). Inside that folder, create a stylesheet called style.css, or you can give it a more specific name for clarity. I’m going to call mine movies.css.

You then need to enqueue that file in your plugin so that it can be used by WordPress. Add this to your main plugin file, above the functions you already have. I like to add enqueuing and includes first in my plugin file so I can see what other files are being activated.

If you save your file, you won’t see any difference in your admin screens—but if you’ve added posts of the custom post type and your stylesheet includes styling for them, you’ll now see that in the front-end of your site.

Note that the hook used for enqueuing both stylesheets and scripts is the same: they both use wp_enqueue_scripts. There isn’t a separate hook for styles.

Enqueuing scripts works in a very similar way. Follow these steps:

  • Add a scripts or js folder to your plugin folder.
  • Save your script files in that folder.
  • Enqueue the script in the same way as the stylesheet above, replacing the wp_enqueue_style() function with wp_enqueue_script().

4. Using Include Files

Another option as you develop your plugin is to create extra PHP files, known as include files. If you have a lot of these, you might create multiple folders for different types of include file, or you might just create one folder called includes.

There are a few functions you can use to include files, which you’ll find in our comprehensive guide to including and requiring files.

For example, in our custom post type plugin, we might create some code to vary the way the content of the page is output, using the the_content filter hook to amend the code being run each time the content is output on a product page.

Instead of adding this code to the main plugin file, you could add it to a separate file called movie-content.php and then write the code in that file for the way the content is output for movies.

To include this file in your plugin, you add a folder called includes to your plugin, and then inside that folder you add the content-movie.php file.

To include that file in your plugin, you add this code at the beginning for the main plugin file:

You don’t need to hook this to an action or filter hook—just use the include_once() function in your plugin file. That will then call the code from the include file as if it was in your main plugin file at that point.

How to Extend or Edit an Existing Plugin

Sometimes you might find a plugin in the plugin directory or from a plugin vendor that does most of what you need a plugin to do, but not quite all. Or you might be running a plugin and want to make some tweaks and customisations.

The fact that WordPress is open source makes this possible. You can take another plugin’s code and extend or edit it to make it work the way you want it to.

There are two ways to do this:

  • Take an existing plugin and fork it—ie. edit it so it works differently, is more reliable or has extra features.
  • Write your own plugin that extends the original plugin.

Taking an existing plugin and editing it is fairly straightforward: you make your own copy on a development site (never live!) and make edits to it as needed. Make sure you use version control to track your changes in case something goes wrong.

Extending a plugin by writing your own plugin is slightly more complicated, and won’t work with every plugin, but is a more robust way of doing things in my opinion.

Many of the most popular plugins will make extensive use of hooks and classes in their code. You can hook into action and filter hooks and extend classes to write your own code which uses the existing plugin’s code as a base but then adds to or edits it.

For example, WooCommerce has so many functions, hooks and classes that it has its own API and developer documentation. Each part of the WooCommerce system is powered by one or more of these functions, hooks, or classes. To make changes, you need to identify which code is driving the part of the system you want to change, and then write your own plugin which either attaches to the same hook(s) or extends the classes.

You’ll find you can create significant customizations to a plugin like WooCommerce in this way: I once used it to power a listings site that didn’t even include a checkout. I used hooks to remove all the elements I didn’t want and add new ones.

For some examples of how you can hook into WooCommerce and extend or edit it with your own plugin, see our guide to adding product descriptions to archive pages and to adding a product-based blog to your store. These examples scratch the surface of what you can achieve but give you an idea of how to start.

Taking It Further: Plugin Features

In this guide, I’ve shown you how plugins are coded and how to get started building a simple plugin.

Once you’ve got the hang of plugin development, you can build more complex and full-featured plugins to carry out more complex tasks on your site.

Let’s take a look at some examples.

Widget Plugins

Widget plugins involve working with classes but are a good introduction to the topic. Our guide to creating a widget plugin will help you do it.

You can also find plenty of widget plugins on CodeCanyon, which will save you coding them yourself. In our blog, we’ve identified the best widget plugins for 2020, the best Facebook widgets, and the best Twitter widgets.

Code Canyon widget plugins

Shortcode Plugins

Creating a shortcode is a great place to start creating plugins as they’re relatively simple and very useful. Find out how to create them with our guide to coding shortcodes in WordPress.

CodeCanyon also has a bunch of useful shortcode plugins you can use to add extra functionality to your site.

Code Canyon shortcode plugins

Social Media Plugins

Social media plugins are incredibly popular as they let you display your Facebook, Twitter, or Instagram feed on your site and let your visitors share your content via their own social media accounts.

CodeCanyon has dozens of social media plugins. Learn about the best social media plugins and how to create an online community for your WordPress site.

Gallery and Media Plugins

If you want to optimize the media on your site and display galleries or video feeds, a plugin will make everything look more professional. Find out how to find the best gallery plugins for images or video and how to code your own gallery plugin. Or browse the professional gallery and video plugins on CodeCanyon.

media plugins on Code Canyon

Form Plugins

Adding forms to your site lets your visitors get in touch and helps build a relationship. CodeCanyon has plenty of premium form plugins that will make it easy for your visitors to contact you. Learn how to create a form with the bestselling QuForm plugin.

FAQs

Here are the answers to some of the most frequently asked questions about WordPress plugins.

Why can’t I just add the code I need to my theme functions file?

It’s tempting to simply keep on adding code to the functions.php file, and there is some code that should be there.

But if your code is related to functionality in your site, rather than the design or the output of content, then you should code it into a plugin. This means that if you switch themes in the future, you still have that functionality. And you can use the plugin on another site running a different theme.

I’ve added code to my plugin. Why is nothing happening?

This is probably because you haven’t hooked your code to an action or filter hook. Until you do that, nothing will happen.

When I edit my plugin and check my site, I get a white screen. Help!

You’ve probably added some code that’s got an error in it somewhere. PHP is an unforgiving language, and this might be as minor as a semicolon in the wrong place.

Try turning on WP_DEBUG in your wp-config.php file, and you’ll see a message telling you where the error is. Then you can fix it.

When I activate my plugin, I get an error message telling me too many headers have been output. What does this mean?

All this normally means is that there are too many empty lines in your plugin file. Go back and check there are no empty lines at the beginning of the file.

If that doesn’t fix it, try turning on WP_DEBUG.

Where can I find out more about developing plugins?

We have lots of tutorials and courses helping you to build all kinds of plugins here on Envato Tuts+. See if you can find anything that inspires you.

tutsplus plugins courses

Where can I download plugins for my site?

You can choose from thousands of free plugins in the WordPress plugin directory. You can also buy third-party plugins from CodeCanyon. Always buy plugins from a reputable supplier so you can be sure they follow WordPress coding standards and don’t contain malicious code.

Summary

Plugins will turn your site from a simple blog into a powerful website that includes advanced features and is secure and robust. Try adding plugins to your site today and coding your own to see how you can use plugins to improve your WordPress site.

The Best WordPress Themes and Plugins on Envato Market

Explore thousands of the best WordPress themes ever created on ThemeForest and leading WordPress plugins on CodeCanyon. Purchase these high-quality WordPress themes and plugins and improve your website experience for you and your visitors. 

Popular WordPress themes on ThemeForest

Here are a few of the best-selling and up-and-coming WordPress themes and plugins available for 2020.


19 Best HTML5 and JavaScript Game Engines and Templates

$
0
0

Do you want to code an online game? You're in luck—this is a great time for any online game developer and those aspiring to be online game developers. 

The days of Flash are over, and this has paved the way for dozens (maybe hundreds!) of different engines, libraries, and variants of common web languages.

HTML5 and JavaScript games have quickly taken over, powering a huge number of games on the web.

That’s where HTML5 and JavaScript browser game templates come in.

Top-Selling HTML5 Game and JavaScript Game Engines for 2020 on CodeCanyon

CodeCanyon is one of the best sources for professional-quality game engines and templates—as well as countless other scripts and tools. If you want to try your hand at creating online games with HTML5 and JavaScript, grab one of these HTML5 and JavaScript game engines and templates. They come with ready-to-use designs and functionality. All the time-consuming programming has already been done for you, so you can focus on designing games that are fun to play. 

19 Best HTML5 and JavaScript Game Engines and Templates

Some of these templates are just that—templates—while others border on complete game concepts or flexible game engines. Whether you're finding something for your website or learning how to flesh out your own idea, you can clearly see how diverse HTML5 and JavaScript game templates can be.

For now, let’s take a look at the top game engines and templates available on CodeCanyon.

1. Canvas Puzzle

Canvas Puzzle

Canvas Puzzle was the first HTML5 game on Envato Market. The concept is simple but can easily be built on to create a fully fledged game. Compatible with all modern browsers, this HTML5 game template has an Internet Explorer 9 or less fallback, while also working great on the most current iPads.

Users can use any image—just drag and drop with Firefox and Chrome—and the game generates any number of different pieces.

Canvas Puzzle is lightweight, simple, clean, and ready for you to customize to your liking.

2. 3D Roulette

3D Roulette

Like the HTML5 3D BlackJack game template, the 3D Roulette HTML5 casino game has a great 3D hi-res look. 

It has also been developed using HTML5, JavaScript, and CreateJS

Easily modify 3D Roulette by downloading and editing the Photoshop and Illustrator files. The HTML casino game source coded can also be installed directly into WordPress using CTL Arcade WordPress plugin.

3. Bubble Shooter

Bubble Shooter

Bubble Shooter reminds me a lot of Snood and other games like it. This simple and addictive game can be installed as is or modified to your liking.

This HTML5 game template comes in 870x1504 resolution, is fully responsive, and can be easily modified using the Photoshop and Illustrator files.

It has been developed with HTML5, JavaScript, and CreateJS, is ready to play, and can be installed directly into WordPress using the CTL Arcade WordPress plugin.

4. The Sorcerer

The Sorcerer

Enjoy the magic of HTML5 game templates with The Sorcerer. This game build was inspired by Zuma gameplay and includes three different progressive levels.

It has been developed with HTML5, JavaScript, and CreateJS

The 960x540 resolution scales to fit and can be used with the CTL Arcade WordPress plugin. Customize The Sorcerer and start making some puzzle magic!

5. Katana Fruits

Katana Fruits

Become the next fruit ninja with the highly customizable Katana Fruits template.

This HTML5 game template was developed with the following code chops:

You can edit the look and feel with the included Photoshop and Illustrator files and install it directly into WordPress using the CTL Arcade WordPress plugin.

6. Slot Machine: The Fruits

Slot Machine The Fruit

Slot Machine: The Fruits is optimized for both mobile and desktop and includes high-quality images that support up to 1500x640 resolution. It comes with HTML5 casino games source code. 

This colorful game was developed with HTML5, JavaScript, and CreateJS.

Games made with the Slot Machine: The Fruits template can even be installed using the CTL Arcade WordPress plugin.

7. Indiara and the Skull Gold

Indiara and the Skull Gold

Just like many of the other HTML5 and JavaScript game templates, Indiara and the Skull Gold works on all platforms.

Are you ready to go on an adventure collecting ancient artifacts in caves full of traps?

This fantastic HTML game template includes:

  • 8 levels
  • Construct 2 files
  • layered Photoshop and Illustrator files
  • and more

Indiara and the Skull Gold is fully touch and mouse supported, includes social media share buttons, and can be visually customized by swapping out the image files or completely modified with Construct 2.

8. Game FlapCat Steampunk

Game FlapCat Steampunk

Game FlapCat Steampunk is based on similar blockbuster games with its simple design and playability. Enjoy this touch and mouse compatible game in full 1280x720 resolution.

This cool cat includes infinite levels, Construct 2 files, layered Photoshop and Illustrator files, and more.

Game FlapCat Steampunk has a great art style and is ready to play or customize.

9. HTML5 3D BlackJack

HTML5 3DBlack Jack

HTML5 3D BlackJack has all the features you'd expect in a realistic blackjack game: split hand, double bet, and insurance. 

But the best part is the hi-res 3D graphic style.

This game has been developed with HTML5, JavaScript, and CreateJS, and is both ready to play and very customizable.

You can even ante up HTML5 3D BlackJack with the CTL Arcade WordPress plugin.

10. Ultimate Swish

Ultimate Swish HTML5 game template

Want to add some jump shots to your upcoming project? Ultimate Swish gives you the framework to do just that.

Ultimate Swish provides a short, addictive game cycle that could be expanded into its own full game or customized to fit within your current project.

The game is based on HTML5, JavaScript, and CreateJS, with all source code included, so it's easy to see how it works and start customizing in no time!

11. Panda Love

Panda Love

Ready, set, run!

This fast-running panda needs to be guided over obstacles to collect prizes and finish each of the over 20 levels.

This template includes the following Construct 2 files and features: autosave, ad support, and one touch control. Show some pixel love with Panda Love.

12. Game Christmas Furious

Game Christmas Furious

'Tis the season for some fun! The Game Christmas Furious HTML5 game template brings touch and mouse-supported fun to all platforms.

It includes six levels, Construct 2 files, layered Photoshop and Illustrator files, and more. 

Balloons invade the North Pole—can Santa catch all the gifts and avoid the balloons? The Game Christmas Furious HTML5 game template is ready to play or transform into your own creation.

13. Don't Crash

Dont Crash

Don't Crash. That's it. It sounds easy, but this mesmerizing HTML5 game template will keep you guessing. Don't crash includes Construct 2 files. It is fully responsive and has touch support, with 1280 x 720 resolution.

And never forget—Don't Crash!

14. Jumper Frog

Jumper Frog

Built on HTML5, JavaScript, and CreateJS, this title includes full source code and is ready to be customized. This combination makes it great for learning all of the pieces that go into a game, for building your own games from, or as a head start for an app project.

PSD and Adobe Illustrator files are also available separately for easier customization.

15. Balloon Fight

Balloon Fight

Balloon Fight is a charming and addictive retro-style game built with Construct 2. 

Pop the balloons of the other cats—and you win!

It comes with all sounds and music, PNG graphic files, and unlimited levels. It also supports AdMob advertising. Balloon Fight is easy to control, but difficult to master.

16. Formula Racing

If you have a need for speed, Formula Racing is what you want. Fully responsive and ready for any screen size, this game has been built with Construct 2.

It includes rival car AI, the ability to easily modify existing tracks or create your own, and PNG and PSD graphic files, and it supports AdMob Advertising. 

Formula Racing is fully customizable and ready for you to race away with something new.

17. Spaghetti HTML 5 Mobile Game 

Make the longest spaghetti ever. Touch for right turn. Release for left turn. Buon appetito

This mobile HTML 5 game is made with Construct 2. It has touch and mouse control. It is easy to export to Android and iOS. It comes with HTML5 file, Cap X file, and extensive documentation. You can share your high score on Twitter. 

18. American Football Santa's Run 

American Football Santa's Run is a fun game! All you need is to avoid the players of the enemy team. Collect stars and get acceleration for ten seconds. During acceleration, you can go through all the players except the one wearing black. Also, do not step on the spikes!

It's very easy to customize and to reskin, and it works on all popular browsers. You can embed it on iFrames and change the size and location of the on-screen buttons. It comes with HTML5 and Construct 2 (.capx) files, images, and sounds. 

19. Find The Twins

Find the Twins is a simple game to understand. You need to find two identical pictures and connect them. But remember that you can only bend the line twice!

At your disposal are 30 complete game levels, but only one attempt to pass them all! The higher the level, the more difficult. For example, after level 10, your pictures will begin to shift around.

Find the Twins comes with: Construct 2 file, HTML5 file, documentation, logo from 16px to 550px, AdSense documentation, and plug-in documentation. 

If you're still looking for the perfect HTML5 game engine or template, CodeCanyon has lots more to choose from. You can find another great list of HTML5 game engines and templates here—along with tips on connecting to your audience and making a great game trailer!

5 Open-Source HTML5 and JavaScript Games 

The following is a selection of open-source game templates and engines you can use to build games that users can play on their browsers. You can easily download the source code on your computer and modify it according to your requirements. You can then run the games on your browser, and even distribute them. 

2048

2048

2048 is based on the 1024 game. To play this game, you use your arrow keys to move the times. When two tiles with the same number touch, they merge into one. It's written using HTML5, CSS3, and JavaScript.

You can download the source code from GitHub.

Canvas Tetris

CANVAS TETRIS

Canvas Tetris is perfect for new developers learning to understand 2D game concepts. It's built using HTML5 and JavaScript. A careful study of the game's source code will help advance your game development skills. 

Download the source code for free from GitHub!

MelonJS

MelonJS

MelonJS is a game engine and framework with a very lightweight footprint. You can create games that only need an HTML5 web browser. 

Pixel Defense

Pixel Defense

This HTML5 and JavaScript game is based on the tower defense game genre. The source code is available on GitHub, so you can learn how the game was developed. You only need to understand how HTML5 and JavaScript work. 

Quantum Game 

Quantum Game

Quantum Game has the following components: photon sources to emit photon particles, a rock to act as an obstacle, a mirror that deflects the photon particle, and a photon detector that receives the photon particle. 

Your goal is to arrange the mirror in a way that a photon particle emitted from the photon source evades the rocks and reaches the photon detector.

The game is developed using HTML5, CSS, JavaScript, and sound plugins. It has a simple layout and can be played in your browser. And the source code is available free from GitHub!

Why Use an HTML5 Game Template?

Building a game is difficult. With several distinct skill sets nestled into a complex package, it can be difficult to start a whole project from scratch.

For those new to game programming, using a game template can help to fill in those gaps in skills, such as user interface or graphic design, giving insight into the workings behind a completed game. This is a great learning experience and helps you get your first couple of projects done without getting too overwhelmed.

Experienced game programmers can find plenty of use from these game templates too. They can help to build the skeleton for a larger game or act as the base for a new project, cutting down on creating repetitive code for each new game you make.

Designing Online Games 

So you have an idea for an online game or several. But how do you start building one? 

You can build a game from scratch. It requires you to have a knowledge of programming. If you don't know how to code you can use templates. There are thousands of them. 

But either way, you have to have a roadmap. Have a basic and detailed description of:

  • What kind of game do you want to create?
  • What is your game is about?
  • In what genre?
  • For what platform: is it a mobile game (iOS or Android) or a desktop game (Windows or Mac)?
  • How do you want it to look?
  • What visual features do you want to include?

In addition, some game design software allows you to build games with drag-and-drop—without even knowing how to code! 

Drag-and-drop game making software includes:

These platforms all have free versions that allow you to publish to the web, but you'll need to pay for professional editions that allow you to make mobile games. 

Text-Based Game Engines

The most basic game design software allows complete beginners with no coding experience to create text-based games. Quest is the perfect beginners' software, and so is Twine

Create 2D Games Without Coding

To create 2D games you can use StencylGame Maker, or Construct 2. These are beginner-friendly, with no coding experience needed, and they have drag-and-drop interfaces.

Choosing Game Design Software

  1. Choose software that publishes to HTML5 and is oriented to publishing games in mobile browsers. You don't want to miss out on mobile users. 
  2. If you want to make money as a game designer, think of software that comes with end-user data collection and game monetization choices.
  3. It should be easy to use and come with extensive documentation and tutorials
  4. It should have access to a robust community of users sharing technical knowledge. 
  5. It should also come with a rich library of stock images and stock music. 

Publishing and Distributing Your Game

Option 1: Distribute and Host Your Game Independently

To distribute independently, you will need a hosting service with a reliable infrastructure that can handle a lot of traffic and also make your game website available at lightning-fast speeds. Of course, you'll pay a lot in hosting fees. You will also need to build and maintain a vibrant online community in order to be profitable.  

Option 2: Outsource Hosting and Distributing to a Gaming Platform 

Platforms offer a ready-made audience through their vibrant built-in communities. Keep in mind they do charge submission fees for each game you submit. They also charge a percentage for every sale. 

To outsource the hosting and distribution, you can use the following platforms:

  • Android: Google Play Store or Amazon Appstore
  • iOS: App Store
  • Desktop and Mobile apps: Steam, Game House, Gamers Gate, Humble Bundle, Kongregate, Gog, Itch.co 

20 Chart Plugins for WooCommerce and WordPress (With 5 Free)

$
0
0

Do you want to turn boring data into visually stimulating charts that will engage your website visitors? 

Some things can be communicated better using charts. And how do you build charts in a way that saves you time to focus on running your business?

This is where chart plugins for WordPress and WooCommerce come in. They help you turn data into interactive charts. On CodeCanyon you will find chart plugins that will help you build visually engaging charts so you can share information easily. 

UberChart
UberChart is an example of Chart plugings for WordPress and WooCommerce available on CodeCanyon

Best-Selling Chart Plugins on CodeCanyon

With a one-time payment, you can purchase these high-quality WordPress chart plugins and improve how visitors engage with data on your website.

Here are some of the weekly best-selling chart plugins for WooCommerce and WordPress on CodeCanyon for 2021.

Topselling Chart Plugins on CodeCanyon

There are several advantages to using chart plugins:

  • all resources you need to build your charts are collected in one place: spreadsheet editor, chart editors, table editors, chart rendering engines, chart layouts and more
  • as your data changes you can keep your charts up to date
  • you have access to tools that can make your charts interactive

Best Chart Plugins for WordPress

Let's have a look at some of the popular chart plugins available on CodeCanyon.

1. wpDataTables

wpDataTables - Tables and Charts Manager for WordPress

You can't go wrong with a bestselling WordPress plugin like wpDataTables—trusted by over 21,000 companies and individuals. This chart, tables and spreadsheet management plugin will help you build tables and charts from various data sources including Excel, Google spreadsheets and more.

Your charts are built using tables you have as data source or you can build charts using a wizard. There is a wide range of chart types to choose from. Charts are rendered by three powerful engines and can be changed in real-time: Google Charts, Highcharts, and Chart.js.

2. UberChart

UberChart

Create a great variety of charts with exceptional customizability using UberChart. This advanced WordPress chart plugin comes with 240 customizable options per chart and 30 customizable options per dataset. You can import and export data to and from UberChart embedded spreadsheet editor. You can install this multi-language ready WordPress chat plugin in a stand-alone site or a multisite network. 

3. Modal Survey

Modal Survey - WordPress Poll, Survey & Quiz Plugin

Modal Survey is a WordPress poll, survey and quiz plugin that allows you to visualize any poll results as charts. Polls are displayed in six different kinds of poll charts: pie chart, doughnut chart, bar chart, radar chart, line chart or polar chart.

All charts are interactive and display the exact values of the WordPress poll with a mouse hover. You have the option to hide survey values and only show percentages. For this you can use the progress bar or the line bar. 

You can also export the whole WordPress poll with the results to CSV, JSON, PDF, XML, and Excel. 

Modal Survey supports many newsletter providers including: Constant Contact, Freshmail, GetRespons, MailChimp, MailPoet and more.

4. Responsive Charts

Responsive Charts

Responsive Charts  allows you to create HTML5 animated charts easily in WordPress. It comes with seven types of fully customizable animated chart types rendered using Charts.js 

This WordPress chart plugin allows for multiple charts on a single page. Types of charts you can make include:

  • pie chart
  • doughnut chart
  • bar chart
  • line chart
  • polar chart
  • radar chart
  • bootstrap progress bars

You can use multiple data sets for bar and line charts. You can also import data sets from CSV. 

5. Responsive Polls

Responsive Polls

The Responsive Poll plugin allows you to easily create polls in WordPress.  It comes with seven fully customizable, animated chart types for displaying voting results. You can create multiple polls on a single page and view poll results in the WordPress admin. This responsive WordPress poll plugins is built using Bootstrap 3 and has three layers of security to ensure your poll results are as accurate as possible. 

6. Premium Stock Market and Forex Widgets

Premium Stock Market & Forex Widgets | WordPress Plugin

You can make sense of stock market data from many exchanges around the world through beautifully crafted interactive charts created using Premium Stock & Forex Market Widgets. This multilingual WordPress stock chart plugin is equipped with dozens of unique handcrafted widget templates including financial widgets, news widgets, market widgets, search widgets, chart and table widgets. You have the ability to choose any color for smooth integration into your website. 

This is a must have tool for a wide range of websites—from news media and financial blogs to asset management firms and publicly traded companies. It supports FOREX and many exchanges around the globe, including, but not limited to: NASDAQ, the New York Stock Exchange, the Toronto Stock Exchange, the London Stock Exchange and more. It's compatible with all modern browsers and responsive on mobiles and tablets.

7. Corvid

Corvid — Covid-19 data Maps & Widgets for WordPress

The Coronavirus pandemic has turned the world upside down. To keep visitors informed, presenting the data in quickly digestible format is important. You can do that using Corvid: a WordPress chart plugin that allows you to add statistic table and widgets on your website via shortcode.  

8. Corona Charts 

Corona Charts - Live COVID-19 Stats WordPress Shortcode Plugin

You can also keep visitors updated on the Covid 19 using Corona Charts in your posts, pages, widgets, sidebar, footer and everywhere on your WordPress website.

Historical data and day-to-day live updates from 195 countries and all USA states are presented in vertical column charts, line column charts, pie charts or doughnut charts. 

The charts are responsive and can be viewed on mobile and tablets. The text is available in all languages. All data comes from https://worldometers.info/coronavirus and is updated every 10 minutes. 

9. WooCommerce Product Size Guide

WooCommerce Product Size Guide

WooCommerce Product Size Guide allows you to create detailed size guides for whole categories of products or single products. You can build your own size charts from three size guide layouts. Or you can edit the sample size guides with your details so you can get started fast. You can create unlimited numbers of size guides. 

The product size guide can be accessed by a link button. You can place the product size guide in different positions like next to the add to cart button or above the product summary tab. You can also make it a tab or embed it manually with shortcodes. It's mobile ready and the size guide can be viewed from any device. 

10. Interactive World Map with Cities

Interactive World Map with Cities

Interactive World Map with Cities is an interactive template of the world map that gives you an easy way to install and customize a professional-looking interactive world map with six clickable continents. It includes an option to add unlimited numbers of clickable pins anywhere on the map then embed the map in your website. You can also link each continent or city to any webpage.

11. Cryptocurrency Widgets Pro

Cryptocurrency widgets pro - WordPress Crypto Plugin

Cryptocurrency Widgets Pro displays current prices, market cap, volume, coin charts of crypto coins of more than 2000 coins including bitcoin, litecoin, ethereum and more. You can display crypto widget anywhere on your site using simple shortcodes. This cypto plugin uses third-party crypto APIs to show current market prices of virtual coins by grabbing data from major crypto exchanges in real time.

12. Stock Market and Forex Charts WordPress Plugin

Stock Market & Forex Chart Plugin for WordPress

Stock Market Charts for WordPress Plugin allows to easily embed fully customizable interactive financial and stock charts into a WordPress website. This Wordpress stock chart plugin supports line, smoothed line, column, and step chart types. You can feature unlimited number of charts on a single page. You get daily and intraday data for equities, stock indexes, currencies, commodity futures and ETFs.

Stock market charts can be easily customized through the native WordPress admin interface and added to any page or post by copying and pasting the chart shortcode. Absolutely no technical skills are required to use the plugin.

13. WooCommerce Dashboard Widget Stats

WooCommerce Dashboard Widgets Stats

WooCommerce Dashboard Widget Stats adds easy-to-read chart widgets directly to the WordPress dashboard. This way the store admin has a set of tools to immediately see stats like current month sales, sales per day, bestselling products, payment methods, refund, average and estimated sales, and which customers who spend the most. 

Store admin can restrict who sees the reports based on user roles, set custom time ranges, and display data by day, month or year. The admin can also exclude all the pending payment orders in order to have more accurate stats about real earned money.

14. Infographic Maker—iList Pro

Infographic Maker - iList Pro

If you want to effortlessly visualize data through infographics then go for Infographic Maker—iList Pro.

This WordPress infographic creator plugin allows you to create infographics and elegant text or graphic lists then integrate them charts and graphs. You can create and add charts and graphs directly from the iList interface. But if you want to create only charts or graphs, that is possible also.

iList comes with iChart visual editor button. iChart allows you to create stand-alone, beautiful HTML5 responsive charts and graphs using Google ChartJS. iChart supports multiple charts and graphs on the same page. Use the iChart button to generate and embed a chart on any page directly from WordPress visual page or post editor. iChart can be used in conjunction with your iList infographic maker or by itself from any of your WordPress page or post. 

15. Ultimate Charts Builder

Advanced Charts Builder

Ultimate Charts Builder helps musicians to create top or trending charts for their websites including audio and video songs. This WordPress music chart plugin can also be used by other artists to display any other types of video collections: trending funny videos, trending sports videos, and more. 

You can build unlimited song charts or video charts and also display charts on specific pages. In addition to your own custom audio (MP3) and video (MP4) uploads from your computer, it supports YouTube, Sound Cloud, and Daily Motion.  

Free Chart Plugins for WordPress 

The premium chart plugins available on CodeCanyon will definitely give you the most advanced features but if you are on a tight budget there are free chart plugins that come with enough features that will help you get the job done. 

Below you'll find a collection of the five best free chart plugins for WooCommerce WordPress plugins available.

1. Product Size Charts Plugin for WooCommerce

Product Size Charts Plugin for WooCommerce

Product Size Charts for WooCommerce allows you to assign size charts to any product or category, and create a custom size chart for any of your WooCommerce products.

You can also clone ready-made size chart templates to create your own size charts and assign them to a category or specific products.

2. M Chart

M Chart

M Chart allows you to manage data sets via a spreadsheet interface and present that data in chart form via the Chart.js or Highcharts chart libraries. The charts can then be embedded into a regular post via a handy shortcode.

3. WP Charts & Graphs

WP Charts & Graphs

The WP Charts and Graphs plugin gives you a powerful chart generator in your WordPress admin and allows you to see the chart immediately on the admin before you publish it. Easy to use: you specify the titles and the values, choose the chart type, then the plugin automatically generates the shortcode which you can include on any page or post.

4. Ninja Charts

Ninja Charts

Ninja Charts  is a powerful free WordPress data visualization plugin that allows you to create and use numerous types of charts in WordPress. Just by following a few simple steps, you can generate amazing charts in different formats. Its JavaScript-based chart rendering engine makes the chart creation process easier than ever.

5. Product Size Charts for WooCommerce

Product Size charts for Woocommerce

Product Size Charts for WooCommerce is another free WordPress size chart plugin, which allows you to place custom sizes on each of your product pages so that your customers could easily pick up the right size of the item they want to buy.

Get Your Chart Plugin for WordPress Now! 

If the chart plugins I've covered in this article are just a few that stood out for me. You can find more WordPress chart plugins for WooCommerce and WordPress on CodeCanyon.

Topselling Chart Plugins for WordPress on CodeCanyon

There are thousands of other high-quality WordPress plugins on CodeCanyon that can help enhance your business's website. Have a look through this large collection of plugins, and you'll find helpful plugins in all different types of categories, from marketing to eCommerce to social media.

Find the perfect WordPress plugin to help your business succeed and motivate your customers. You can find even more plugin ideas and inspiration in our new free course on finding the best WordPress plugins for your site.

How to Make a Drop-Down Menu in WordPress

$
0
0
Final product image
What You'll Be Creating

Navigation menus are having a bit of a moment in the spotlight. From burger menus for mobile through mega menus for stores to sticky menus for enhanced user experience, there's a great choice in the way you can present your navigation menu in your WordPress site.

But what if you want to create a straightforward menu with a few top-level items and some more items that drop down from them when the user hovers over them?

Before you start getting into coding advanced menus like mega menus and burger menus, it's a good idea to learn how to create a drop-down menu. This will come in useful on more sites than you might imagine (not every site needs a fancy menu), and it will give you the foundation you need to start building more advanced menus.

In this tutorial, I'm going to show you how to create a drop-down menu in your WordPress theme, using CSS to target the HTML that's output by the WordPress menu function. This is designed to be used in a theme you're coding yourself, and not for a third-party theme, which will already have its own menu. However, if you're working with a third-party theme whose menu isn't drop-down and you want to add this, then you'll need to create a child theme and add your menu code to that.

What You'll Need

To follow along with this tutorial, you'll need:

  • a development installation of WordPress
  • a theme you're coding yourself, or a child theme of a third-party theme if you want to modify the menu
  • a code editor

WordPress's Built-in Menu Functionality

The first thing you'll need to understand is how WordPress generates menus. Unlike for static sites, menus aren't hard-coded into your site. Instead, WordPress uses a PHP function to query the database and fetch navigation menu items, then display them in the correct structure.

Each item in your navigation menu is actually a post in the wp_posts table in your database—not a normal post, but a special kind of post that's used just for navigation menu items, with its own metadata including the text to be displayed and the target of the link.

In your theme, open up the header.php file. You should be able to find this line:

Your function may look a little different depending on the parameters, but let's break down the example above and see what each element does:

  • wp_nav_menu() is the function that fetches a navigation menu and outputs it.
  • The parameters are then wrapped in an array.
  • container_class is the CSS class that will be given to the container in which the menu is wrapped. In this case, it's main-nav. That's what we'll be targeting with our CSS later on.
  • theme_location => primary tells WordPress that this is the primary navigation. If I create a menu in the admin screens and check the Primary box, then this menu will be used for this spot in the code.

Sometimes you might want to add a navigation menu elsewhere in your theme, for example in the footer, in which case you don't want to use theme_location => primary. You can only use this for one menu. But you may want to use additional parameters, which you can find in the WordPress handbook page on wp_nav_menu().

Here's the checkbox for the primary navigation in the Menus admin screen:

Primary navigation setting

Code Output by the wp_nav_menu() Function

Before we can add CSS to create the dropdown menu, it helps to be familiar with the code that WordPress generates for menus.

Here's a typical menu for a small business, shown in the Menus admin screen:

Navigation menu in admin screen

Now here's the HTML output for that menu:

If you examine that code, you'll see that it consists of:

  • A div with the main-nav class, defined in the wp_nav_menu() function.
  • Inside that, a ul with the ID menu-navbar and the class menu. These are defaults defined by WordPress.
  • Inside that, a number of li elements, each with the class of menu-item menu-item-type-post_type, plus other classes specific to the type of post that the menu item leads to and the state of that menu item at the time. Each one also has a unique ID, with a number corresponding to the post ID of the navigation menu item in the database.
  • Inside one of the li elements is another ul with its own li elements inside—the second-level menu items. It's this that we want to drop down when the user hovers over the top-level menu item.

Coding the CSS to Create the Drop-Down Menu

So now we know what's being output by WordPress, we can determine which elements we want to target with our CSS.

We want to achieve a couple of things:

  • When the page is opened, the second-level menu items are hidden.
  • When the user hovers over a top-level item, the second-level items below it appear.

Hiding the Second-Level Items by Default

In your theme's stylesheet, start by hiding the second-level items by default.

Add this:

This will hide the ul element inside another ul element inside the main-nav element. It won't hide a top-level ul element, however, as it requires one ul to be nested inside another ul inside the menu.

Now, if you open the page and try to view the second-level items, it won't be possible—they'll be hidden. Let's fix that.

Making Second-Level Items Appear on Hover

Now we need to ensure that the ul nested inside the top-level li will be displayed when the top-level li is hovered over.

Add this to your stylesheet:

Now, when you hover your mouse over the top-level item, the list beneath it will appear. But you'll find that it won't display the way you want it. Specifically, it will be pushing down the content below the menu. We want it to appear as if it's floating on top of the content. To fix that, we need to add some layout styling to our ul ul element.

Adding Layout Styling to the Second-Level List

Open your stylesheet and find the line with display: none in it. Edit that block to add layout styling:

You also need to give the top-level list item relative positioning:

Let's take a look at what that code does:

  • position: absolute gives the second-level list absolute positioning, taking it out of the flow of elements in the page. For the higher-level item, position: relative puts the top-level list in the flow of the page and allows for an absolutely positioned element to be placed inside it.
  • top: 3em positions the top of the list relative to the top of the element it's inside, namely the top-level list item. This 3em value reflects the height of the top-level navigation bar. Edit yours if your top-level navigation has a different height.
  • left: 0 places the list to the left, relative to the item above it.
  • z-index: 99999 defines where the element sits in a three-dimensional model of the page. A high value of 99999 ensures that it is displayed on top of everything else.
  • The remaining code gives the list width and also adds display styling to it, including a shadow to make it look as if it's on top of the page.

Now let's take a look at what we see when we hover over the top-level item:

Hovering over menu

It works! When I hover over the top-level item, the drop-down menu is now displayed.

Making Your Drop-Down Menu Mobile-Friendly

The code above is great for the desktop version of the site, but the reality is that most people will be visiting your site on a mobile phone.

The menu here is too big to fit onto a small screen, so the best solution is to edit the CSS on small screens and use some JavaScript to create a burger menu.

Here’s how to do it.

Adding a Menu Icon to the Banner

First, add the icon that will people will need to tap on to access the menu in a small screen.

Add this to the header.php file, in the place where you want the menu icon to go:

That will output the burger symbol, using the HTML code for the symbol, inside an element with a class we’ll use to hide it on larger screens.

Adding the CSS for the Burger Menu

Now you need to add the CSS to your stylesheet. First, hiding the icon on larger screens:

Now inside a media query, add the CSS for the menu:

Note that you’ll need to edit this if you’re using different classes and IDs in your theme.

Adding the Javascript

The final steps is to add a script to make the menu appear when a user taps on the icon. Create a folder in your theme called scripts, and inside that, a new file called burger-menu.js and add this to it:

Now make sure the script is called by the theme. In your theme’s functions.php file, add a function to enqueue the script:

Now save all your files and you’ll have a burger menu on small screens.

Burger menu

Drop-Down Menus Are Useful for Small, Multi-Level Menus

When your site needs a menu with multiple levels but you don't need a lot of links outside your top-level menu, a drop-down menu is the simplest way to achieve this. The site I've used to demonstrate this only has one item in its menu with other items below it, and there are only three of those. Using a mega menu would be overkill, and a single-level menu wouldn't allow me to display everything I want.

Being able to add a menu like this to your themes will give you more flexibility with your menus and enhance the user experience. And you can do it with just a few lines of CSS.

22 Best WPBakery Page Builder (Visual Composer) Addons and Extensions of 2021

$
0
0

Add the best WPBakery add-ons and extensions ever developed to your page builder and give your website visitors the experience they need. From carousel add-ons to extra WooCommerce product extensions, these WPBakery add-ons and extensions will provide endless new possibilities.

The massive WPBakery add-ons and extensions available on CodeCanyon will allow you to add extra features not only for your website visitors but for you in the back end of your site, making it much easier to manage your WordPress website. 

Create a more powerful website by adding an extension or add-on to your WPBakery page builder today!

The Best WordPress WPBakery Page Builder Add-Ons & Extensions on CodeCanyon

Discover over 7,000 of the best WordPress plugins ever created on Envato Market's CodeCanyon. With a cheap one-time payment, you can purchase one of these high-quality WordPress plugins, extensions, and add-ons. 

Here are a few of the best WPBakery (Visual Composer) add-ons and extensions available on CodeCanyon for 2021.

Best-Selling WordPress WPBakery Page Builder Addons  Plugins on CodeCanyon
WordPress WPBakery page builder addons and plugins available for sale at CodeCanyon 

These versatile and unique WPBakery add-ons and extensions will help you get the most out of your website. While WPBakery is a complete page builder, the feature-rich add-ons and extensions will allow you to add a wide variety of features to your website, such as:

  • carousels 
  • extra WooCommerce features
  • audio players
  • content boxes
  • and much more

These extra features and functionality are a must-have for your WordPress website, so don't miss out! Head on over to CodeCanyon and choose from the premium add-ons and extensions available. 

18 Best WPBakery Page Builder Addons & Plugins

Here are 18 of the top-rated WPBakery (Visual Composer) add-ons and extensions that are available for you to download on CodeCanyon:

1. Ultimate Addons for Visual Composer

Ultimate Addons for Visual Composer

It’s no surprise that Ultimate Addons for Visual Composer is one of the highest-rated and best-selling addons for WPBakery Page Builder. With 20 updates since its inception, this is an addon that works consistently to stay ahead of the competition and deliver a product that meets the needs of a wide range of designers. Notable features:

  • parallax and video backgrounds
  • video tutorials
  • over 40 unique elements
  • 15 demo pages for inspiration
  • and more

2. WooCommerce Extra Product Options

WooCommerce Extra Product Options

WooCommerce Extra Product Options helps you extend the functionality of your WooCommerce store by creating more product options, add conditional logic (within the form builder), and build a wide variety of forms. Notable features:

  • control the placement of your new fields 
  • full support for checkboxes, radio buttons, and select boxes
  • prices can change depending on the selected product variation 
  • enable different options for certain roles
  • and more

3. Composium WPBakery WordPress Plugin

Composium

One of the top sellers at CodeCanyon, Composium WPBakery WordPress plugin is packed with a dizzying amount of features, including a Google Font Manager with more than 810 fonts, over 70 CSS3 animations, and the option to use any WPBakery Page Builder element in a sidebar. In addition, when you download this extension, you also get a built-in downtime/maintenance manager for your site, which allows you to create a custom maintenance page. Notable features:

  • over 150 different elements
  • icon and Google Font managers
  • custom premium lightbox
  • template and widget builder
  • and more

4. Massive Addons WPBakery WordPress Plugin

Massive Addons for WPBakery Page Builder

Massive Addons WPBakery WordPress plugin is an all-in-one extension that's packed with enough features to make even the most demanding web designer happy. The latest version of this unlimited addons for wpbakery page builder plugin has incorporated a ton of user-suggested improvements. Most notably, it has integrated a feature called "container presets", allowing users to preset entire rows or columns.

Notable features:

  • over 70 customisable shortcodes and addons
  • 31 page templates
  • supports WooCommerce
  • over 15 training videos
  • and more

5. Calendarize it! WPBakery (Visual Composer) Plugin

Calendarize it

Calendarize it! is a feature-rich calendar for your WordPress site that can be used as a standalone plugin or as an addon for WPBakery Page Builder. Notable features include:

  • events countdown
  • events year view
  • payment options
  • social share panel
  • and more

6. Templatera WPBakery WordPress Plugin

Templatera WPBakery WordPress plugin

Created by the authors of WPBakery Page Builder, Templatera is a WordPress template manager that allows users to create, manage and set access to templates based on user roles or content types. Notable features include:

  • easy content reuse across templates
  • edit content across templates from one central place
  • ability to import or export templates in XML format
  • and more

7. Visual Composer All In One Addons

Visual Composer All In One Addons

One of our most popular WPBakery (Visual Composer) plugins, Visual Composer All In One Addons combines 64 different functions in one powerful tool that extends WPBakery Page Builder wonderfully. Notable features:

  • carousel and gallery
  • to-do list and price table
  • draggable timeline
  • iHover with 35 transitions
  • and more

8. WPBakery Page Builder Clipboard

WPBakery Page Builder Clipboard

Clipboard is a best-selling WPBakery WordPress plugin. This WPBakery (Visual Composer) add-on allows you to copy/cut and paste single elements to a stack of elements across pages without leaving the WPBakery interface.

Not only that, but you can also import and export content or save it in the cloud. A five-star rating proves this is one of the most loved plugins for Visual Composer. 

9. Unlimited Addons for WPBakery Page Builder

Unlimited Addons for WPBakery Page Builder

With over 700 addons and 30 predefined templates, Unlimited Addons for WPBakery Page Builder is the largest add-on bundle available for WPBakery Page Builder (Visual Composer). This mega-pack of components for WPBakery page builder will help you:

  • build website headers and footers
  • create pages or sections for team member profiles, testimonials, and reviews
  • design simple sliders, carousels, and banners 

Notable features include:

  • one-click import layout from any WPBakery Page Builder page
  • import only the addons you want to use
  • lifetime updates
  • 24/7 support
  • well-documented

10. Kaswara Modern Visual Composer Addons

Kaswara Modern Visual Composer Addons

Kaswara Modern Visual Composer Addons offers 45 fabulous elements and over 550 shortcode options, and in just two years it has become a powerful contender in the WPBakery Page Builder add-ons and extensions market. Notable features:

  • contact form designer
  • shortcode manager
  • replica section
  • icon and Google font managers
  • and more

11. Super Bundle WPBakery WordPress Plugin

Super Bundle

If you’re looking for a whole host of great effects all in one place, check out this bundle of over 20 fabulous plugins in a single add-on called Super Bundle WPBakery WordPress plugin. Notable features:

  • hover animation
  • animated text effects
  • carousel
  • background gradient
  • and more

12. WPBakery Page Builder Add-on Image Hotspot With Tooltip

Image Hotspot with Tooltip

The Image Hotspot with Tooltip comes bundled with another best-selling CodeCanyon addon, All In One Addons, but for those who don’t own that plugin, this standalone enables you to add a hotspot icon with a popup tooltip to any image on your site. The plugin may not be for everyone but will be of great value to photographers and e-commerce or educational sites. Notable features:

  • the tooltip feature supports text, images, video, and other kinds of content
  • hotspot icon’s position easily customisable
  • hotspot icons come in a variety of colours
  • and more

13. VCKit WPBakery (Visual Composer) Plugin 

VCKit

VCKit WPBakery (Visual Composer) plugin is a feature-rich collection of over 45 beautifully designed elements with highly customisable features. This handy addon continues to go from strength to strength every year. Notable features:

  • five pre-designed demo homepage templates
  • over 45 animation effects
  • 30 gorgeous effects
  • one-click installation
  • and more

14. Cost Calculator WPBakery WordPress Plugin

Cost Calculator

If you’re looking for a WPBakery Page Builder addon that will enable you to create price estimates that give clients an idea of the costs involved in your service or product, Cost Calculator might be the perfect plugin for you. Cost Calculator allows you to easily create quote or price estimation forms for your WordPress site. Notable features:

  • dropdown menus with image icons
  • numeric slider
  • on/off switch
  • reCAPTCHA
  • and more

15. FullPage for WPBakery Page Builder

FullPage for WPBakery Page Builder

This trending WPBakery WordPress plugin is the perfect addition to your website. This Full Page WPBakery (Visual Composer) add-on allows you to create full-page scrolling websites in WordPress in no time.

It's a great WPBakery plugin to download: it's fully responsive, easy to customize, and has clean code.

16. WooCommerce Page Builder

WooCommerce Page Builder

If you have an online store supported by WooCommerce, this WPBakery WordPress plugin is great for you. This WPBakery (Visual Composer) WooCommerce Page Builder provides a full set of easy-to-use WooCommerce shortcodes.

Use this trending WPBakery WordPress plugin to create fresh and unique WooCommerce stores thanks to its customized Single Product and Product Archive pages. 

17. Mega Addons for WPBakery Page Builder (Visual Composer)

Mega Addons For WPBakery Page Builder Visual Composer

This is a great WPBakery WordPress plugin to have. Mega Addons is a superb WPBakery (Visual Composer) plugin bundle. See what you'll get in this fully responsive plugin with 32+ unique elements like:

  • team profile
  • info banner
  • advanced carousel
  • flip box
  • timeline
  • countdown
  • modal popup
  • testimonial
  • and more

It's one of our best-rated plugins for Visual Composer.

18. WP Post Modules

WP Post Modules

WP Post Modules is ideal for creating online magazine layouts, newspaper blocks, creative portfolio showcases, and regular blog feeds using a drag-and-drop interface. Notable features:

  • seven display styles
  • 20 pre-built home page layouts
  • grid and list modes
  • 100% responsive design, optimised for retina display
  • and more

Free WPBakery Page Builder Addons & Extensions for Download in 2021

The premium plugins for Visual Composer available on CodeCanyon will offer you the most comprehensive set of features. If your current budget will not allow for the purchase of these high-quality add-ons and extensions, there are free alternatives that you can take advantage of.

Below is a collection of the four best WPBakery templates for free download.

1. Livemesh Visual Composer WordPress Free Plugin

Livemesh is a great tool to add to your arsenal if you don't have the budget for a premium WPBakery (Visual Composer) plugin. It features many different website building items such as post grids, bar charts, testimonial cards, and much more. Each element can easily be added to your website by dragging and dropping. 

2. Mega Addons Visual Composer WordPress Free Plugin

This add-on collection includes a whopping 28 add-ons that can help enhance your WordPress website. You can expect features such as member profiles, pricing tables, timelines, and countdowns.

3. Ultimate Carousel Visual Composer WordPress Free Plugin

Ultimate Carousel is a versatile extension for your WPBakery Page Builder that allows you to create carousels for any kind of content. Ultimate Carousel is responsive and touch-enabled and is compatible with mobile devices.

4. Image Hover Effects Visual Composer WordPress Free Plugin

This extension gives you the option to add over 80 hover effects for your images with captions. Most of the transitions have thumbnail support, lightboxes, or custom links. This gives your images an interactive component that your users will love. 

More Great WPBakery Resources on Envato Tuts+

In this article, we've gone over some of the best premium WPBakery (Visual Composer) addons and free WPBakery plugins available. However, just owning the WPBakery page builder and the add-ons and extensions will not be enough to create a feature-rich website that your users will love. You need to know how to use these tools in order to build a successful website.

Check out the articles below on how you can get the most out of WPBakery and its extensions and add-ons.

Learn More About WordPress

We know WordPress can seem intimidating if you're just starting to use this awesome platform. But don't worry—here are some resources that might help you with your WordPress website.

Additionally, you can check our fantastic course: A Beginner’s Guide to Using WordPress and our Tuts+ YouTube channel, where you'll find awesome videos like these:

Install a WPBakery Page Builder Addon or Extension Now! 

In order to give your website visitors the best possible experience on your WordPress website, you will need to have a feature-rich website.

The premium WPBakery add-ons and extensions available on CodeCanyon will help you add these extra features to your website so that you can gain more traffic and run your business more effectively. 

This list of WPBakery Page Builder add-ons and extensions just scratches the surface of the products available at CodeCanyon. So if none of the add-ons and extensions seem to suit your website's needs, there are plenty of other great options to choose from. 

In addition to the WPBakery extensions and add-ons, there are thousands of other high-quality WordPress plugins on CodeCanyon that can help you improve your website. The large library of plugins contains everything from marketing to eCommerce and social media plugins.

Find a WordPress plugin that helps your business succeed today!

 

30 CSS Best Practices for Beginners

$
0
0

CSS is a language that is used by nearly every developer at some point. While it's a language that we sometimes take for granted, it is powerful and has many nuances that can help (or hurt) our designs. Here are thirty of the best CSS practices that will keep you writing solid CSS and avoiding some costly mistakes.

1. Make it Readable

The readability of your CSS is incredibly important, though most people overlook why it's important. Great readability of your CSS makes it much easier to maintain in the future, as you'll be able to find elements quicker. Also, you'll never know who might need to look at your code later on.

2. Keep it Consistent

Along the lines of keeping your code readable is making sure that the CSS is consistent. You should start to develop your own "sub-language" of CSS that allows you to quickly name things. There are certain classes that I create in nearly every theme, and I use the same name each time. For example, I use .caption-right to float images which contain a caption to the right.

Think about things like whether or not you'll use underscores or dashes in your ID's and class names, and in what cases you'll use them. When you start creating your own standards for CSS, you'll become much more proficient.

3. Start with a Framework

Some design purists scoff at the thought of using a CSS framework with each design, but I believe that if someone else has taken the time to maintain a tool that speeds up production, why reinvent the wheel? I know frameworks shouldn't be used in every instance, but most of the time they can help.

Many designers have their own framework that they have created over time, and that's a great idea too. It helps keep consistency within the projects.

At the same time, I would also like to say that you should use frameworks only if you already know a good deal of CSS. There will almost certainly come a time when you will have to create a certain aspect of some layout all by yourself and your deep understanding of CSS will help you get things done.

4. Use a Reset

Most CSS frameworks have a reset built-in, but if you're not going to use one then at least consider using a reset. Resets essentially eliminate browser inconsistencies such as heights, font sizes, margins, and headings. The reset allows your layout look consistent in all browsers.

The MeyerWeb is a classic reset. Normalize.css is another very popular reset.

5. Organize the Stylesheet With a Top-Down Structure

It always makes sense to lay your stylesheet out in a way that allows you to quickly find parts of your code. I recommend a top-down format that tackles styles as they appear in the source code. So, an example stylesheet might be ordered like this:

  1. Generic classes (bodyaph1, etc.)
  2. #header
  3. #nav-menu
  4. #main-content

It also helps if you keep track of different section of the website in the stylesheet with comments.

6. Combine Elements

Elements in a stylesheet sometimes share properties. Instead of re-writing previous code, why not just combine them? For example, your h1h2, and h3 elements might all share the same font and color:

We could add unique characteristics to each of these header styles if we wanted (ie. h1 {size: 2.1em}) later in the stylesheet.

7. Create Your HTML First

Many designers create their CSS at the same time they create the HTML. It seems logical to create both at the same time, but actually you'll save even more time if you create the entire HTML mockup first. The reasoning behind this method is that you know all the elements of your site layout, but you don't know what CSS you'll need with your design. Creating the HTML layout first allows you to visualize the entire page as a whole, and allows you to think of your CSS in a more holistic, top-down manner.

8. Use Multiple Classes

Sometimes it's beneficial to add multiple classes to an element. Let's say that you have a div "box" that you want to float right, and you've already got a class .right in your CSS that floats everything to the right. You can simply add an extra class in the declaration, like so:

You can add as many classes as you'd like (space separated) to any declaration.

This is one of those situations where you have to take individual cases into account. While it is helpful to create class names that provide some hint of how they affect the layout, you should also avoid using class names that require you to constantly switch between HTML and CSS.

Be very careful when using ids and class-names like "left" and "right." I will use them, but only for things such as examples in blog posts. How come? Let's imagine that, down the road, you decide that you'd rather see the box floated to the left. In this case, you'd have to return to your HTML and change the class name—all in order to adjust the presentation of the page. This is unsemantic. Remember: HTML is for markup and content. CSS is for presentation.

If you must return to your HTML to change the presentation (or styling) of the page, you're doing it wrong!

9. Use the Right Doctype

The doctype declaration matters a whole lot on whether or not your markup and CSS will validate. In fact, the entire look and feel of your site can change greatly depending on the doctype that you declare.

Learn more about which doctype to use at A List Apart. You can simply start using <!DOCTYPE html> when creating pages based on HTML5.

10. Use Shorthand

You can shrink your code considerably by using shorthand when crafting your CSS. For elements like padding, margin, font and some others, you can combine styles in one line. For example, a div might have these styles:

You could combine those styles in one line, like so:

If you need more help, here's a comprehensive guide on CSS shorthand properties.

11. Comment your CSS

Just like any other language, it's a great idea to comment your code in sections. To add a comment, simply add /* behind the comment, and */ to close it, like so:

12. Understand the Difference Between Block and Inline Elements

Block elements are elements that naturally clear each line after they're declared, spanning the whole width of the available space. Inline elements take only as much space as they need, and don't force a new line after they're used.

Here are the lists of elements that are typically inline:

And the block elements:

13. Alphabetize your Properties

While this is more of a frivolous tip, it can come in handy for quick scanning.

This is a bit controversial because you have to sacrifice speed for slightly improved readabilityHowever, you should not hesitate in trying it out if you think it will help you.

14. Use CSS Compressors

CSS compressors help shrink CSS file size by removing line breaks, white spaces, and combining elements. This combination can greatly reduce the the file size, which speeds up browser loading. CSS Optimizer and HTML Compressor are two excellent online tools that can shrink CSS.

It should be noted that shrinking your CSS can provide gains in performance, but you lose some of the readability of your CSS.

15. Make Use of Generic Classes

You'll find that there are certain styles that you're applying over and over. Instead of adding that particular style to each ID, you can create generic classes and add them to the IDs or other CSS classes (using tip #8).

For example, I find myself using float:right and float:left over an over in my designs. So I simply add the classes .left and .right to my stylesheet, and reference it in the elements.

This way you don't have to constantly add float:left to all the elements that need to be floated.

16. Use margin: 0 auto to Center Layouts

Many beginners to CSS can't figure out why you can't simply use float: center to achieve that centered effect on block-level elements. If only it were that easy! Unfortunately, you'll need to use

to center a div, paragraphs or other elements in your layout.

By declaring that both the left AND the right margins of an element must be identical, the browsers have no choice but to center the element within its containing element.

17. Don't Just Wrap a div Around It

When starting out, there's a temptation to wrap a div with an ID or class around an element and create a style for it.

Sometimes it might seem easier to just create unique element styles like the above example, but you'll start to clutter your stylesheet. This would have worked just fine:

Then you can easily add a style to the h1 instead of a parent div.

18. Use Browser Developer Tools

Modern web browsers come bundled with some vital tools that are must haves for any web developer. These developer tools are now part of all the major browsers, including Chrome, Firefox, Safari and Edge. Among the many features that come bundled with the Chrome and Firefox developer tools (like debugging JavaScript, inspecting HTML, and viewing errors), you can also visually inspect, modify, and edit CSS in real-time.

19. Hack Less

Avoid using browser-specific hacks if at all possible. There is a tremendous pressure to make sure that designs look consistent across all browsers, but using hacks only makes your designs harder to maintain in the future. Plus, using a reset file (see #4) can eliminate nearly all of the rendering irregularities between browsers.

20. Use Absolute Positioning Sparingly

Absolute positioning is a handy aspect of CSS that allows you to define where exactly an element should be positioned on a page to the exact pixel. However, because of absolute positioning's disregard for other elements on the page, the layouts can get quite hairy if there are multiple absolutely positioned elements running around the layout.

21. Use Text-transform

text-transform is a highly-useful CSS property that allows you to "standardize" how text is formatted on your site. For example, say you're wanting to create some headers that only have lowercase letters. Just add the text-transform property to the header style like so:

Now all of the letters in the header will be lowercase by default. text-transform allows you to modify your text (first letter capitalized, all letters capitalized, or all lowercase) with a simple property.

22. Don't Use Negative Margins to Hide Your h1

Oftentimes people will use an image for their header text, and then either use display:none or a negative margin to float the h1 off the page. Matt Cutts, then head of Google's Webspam team, has officially said that this is a bad idea, as Google might think it's spam.

As Mr. Cutts explicitly says, avoid hiding your logo's text with CSS. Just use the alt tag. While many claim that you can still use CSS to hide a h1 tag as long as the h1 is the same as the logo text, I prefer to err on the safe side.

23. Validate Your CSS and XHTML

Validating your CSS and XHTML does more than give a sense of pride: it helps you quickly spot errors in your code. If you're working on a design and for some reason things just aren't looking right, try running the markup and CSS validator and see what errors pop up. Usually you'll find that you forgot to close a div somewhere, or a missed semi-colon in a CSS property.

24. Rems and Ems vs. Pixels

There's always been a strong debate as to whether it's better to use pixels (px) or ems and rems when defining font sizes. Pixels are a more static way to define font sizes, and ems are more scalable with different browser sizes and mobile devices. With the advent of many different types of web browsing (laptop, mobile, etc.), ems and rems are increasingly becoming the default for font size measurements as they allow the greatest form of flexibility.

25. Don't Underestimate the List

Lists are a great way to present data in a structured format that's easy to modify the style. Thanks to the display property, you don't have to just use the list as a text attribute. Lists are also great for creating navigation menus and things of the sort.

Many beginners use divs to make each element in the list because they don't understand how to properly use lists. It's well worth the effort to use brush up on learning list elements to structure data in the future.

26. Avoid Extra Selectors

It's easy to unknowingly add extra selectors to our CSS that clutters the stylesheet. One common example of adding extra selectors is with lists.

In this instance, just the .someclass li would have worked just fine.

Adding extra selectors won't bring Armageddon or anything of the sort, but they do keep your CSS from being as simple and clean as possible.

27. Add Margins and Padding to All

Modern browsers are fairly uniform in the way they render elements, but legacy browsers tend to render elements differently. For example, Internet Explorer renders certain elements differently than Firefox or Chrome, and different versions of Internet Explorer render differently from one another.

One of the main differences between versions of older browsers is how padding and margins are rendered. If you're not already using a reset, you might want to define the margin and padding for all elements on the page, to be on the safe side. You can do this quickly with a global reset, like so:

Now all elements have a padding and margin of 0, unless defined by another style in the stylesheet.

28. Use Multiple Stylesheets

Depending on the complexity of the design and the size of the site, it's sometimes easier to make smaller, multiple stylesheets instead of one giant stylesheet. Aside from it being easier for the designer to manage, multiple stylesheets allow you to leave out CSS on certain pages that don't need them.

For example, I might having a polling program that would have a unique set of styles. Instead of including the poll styles to the main stylesheet, I could just create a poll.css and the stylesheet only to the pages that show the poll.

However, be sure to consider the number of HTTP requests that are being made. Many designers prefer to develop with multiple stylesheets, and then combine them into one file. This reduces the number of HTTP requests to one. Also, the entire file will be cached on the user's computer.

29. Check for Closed Elements First When Debugging

If you're noticing that your design looks a tad wonky, there's a good chance it's because you've left off a closing </div>. You can use the XHTML validator to help sniff out all sorts of errors like this.

30. Try to Use Flexbox and Grid Layout Instead of Floats

In the past, it was very common and necessary to use floats to create any kind of layout. Unfortunately, floats come with a lot of problems. You can instead start using the much more powerful layout modules called flexbox and grid layout. Flexbox will help you create one dimensional layout and grid will help you with two dimensional layouts.

31. Use !important Sparingly

The keyword !important is used to bypass any styling rules specified elsewhere for an element. This allows you to use less specific selectors to change the appearance of an element. As a beginner, this might seem like an easy way to style elements without worrying about what selectors you should be using. However, you should avoid that as using !important with a lot of elements will ultimately result in !important losing its meaning as every CSS rule will now bypass the selector specificity.

One possible use for !important is to specify the style of third-party elements added to a webpage where you cannot alter the original stylesheet or its loading order etc.

You Might Also Enjoy...

This post has been updated with contributions from Monty Shokeen. Monty is a full-stack developer who also loves to write tutorials, and to learn about new JavaScript libraries.

Viewing all 5161 articles
Browse latest View live