الأربعاء، 31 يوليو 2019

Previewing themes on the WordPress website

While you’re visiting the WordPress Theme Directory, you can easily browse the
various themes by using the following features:
  • » Search: Type a keyword in the search box near the top of the page (refer to Figure 2-1), and press the Enter (or Return on a Mac) key. A new page opens, displaying themes related to the keyword you searched for.
  • » Featured: Click the Featured link to view the themes that WordPress has chosen to feature in the directory. WordPress changes the featured themes listing regularly.
  • » Popular: Click the Popular link to view the themes that have been downloaded most often.
  • » Latest: Click the Latest link to view themes recently added to the directory.
  • » Feature Filter: Click the Feature Filter to view choices available to filter your theme search by, such as layout, features and subject.


Getting Started with Free Themes

Getting Started with Free Themes


WordPress comes packaged with one very useful default theme called Twenty
Nineteen (named after the year 2019 and released in version 5.0 of WordPress).
Most bloggers who use WordPress usually don’t waste any time at all in finding a
theme that they like better than the default theme. The Twenty Nineteen theme is
meant to get you started. Although you’re not limited to the default theme, it’s a
very functional theme for a basic website. Feel free to use it to get started.

Free WordPress themes are popular because of their appealing designs and their
ease of installation and use. They’re great tools to use when you launch your new
site, and if you dabble a bit in graphic design and CSS (Cascading Style Sheets),
you can customize one of the free WordPress themes to fit your needs. (See Book 6,
chapters 4 and 5 for some resources and tools for templates and template tags, as
well as a few great HTML and CSS references.)

With thousands of free WordPress themes available and new ones appearing all
the time, your challenge is to find the right one for your site. Here are a few things
to remember while you explore. (Also see the nearby sidebar “Are all WordPress
themes free?” for information about free versus commercial themes.)
  • Free themes are excellent starting places. Find a couple of free themes, and use them as starting points for understanding how themes work and what you can do with them. Testing free themes, their layouts, and their options helps you identify what you want in a theme.
  • You’ll switch themes frequently. Typically, you’ll find a WordPress theme that you adore and then, a week or two later, find another theme that fits you or your site better. Don’t expect to stay with your initial choice. Something new will pop up on your radar screen. Eventually, you’ll want to stick with a theme that fits your needs best and doesn’t aggravate visitors because of continual changes.
  • You get what you pay for. Although a plethora of free WordPress themes exists, largely, you receive limited or no support for them. Free themes are often a labor of love. The designers have full-time jobs and responsibilities; they often release these free projects for fun, passion, and a desire to contribute to the WordPress community. Therefore, you shouldn’t expect (or demand) support for these themes. Some designers maintain very active and helpful forums to help users, but those forums are rare. Just be aware that with most free themes, you’re on your own.
  • Download themes from reputable sources. Themes are essentially pieces of software. Therefore, they can contain things that could be scammy, spammy, or potentially harmful to your site or computer. It’s vital that you do your homework by reading online reviews and downloading themes from credible, trusted sources. The best place to find free WordPress themes is the Themes Directory of the WordPress website (see Figure 2-1) at https://wordpress.org/themes.

ARE ALL WordPress THEMES FREE? 

Not all WordPress themes are created equal, and it’s important for you, the user, to know the difference between free and premium themes:
  • Free: These themes are free, period. You can download and use them on your website at absolutely no cost. It’s a courtesy to include a link to the designer in the footer of your site, but you can remove that link if you want to.
  • Commercial: These themes cost money. You usually find commercial themes available for download only after you’ve paid anywhere from $10 to $500. The designer feels that these themes are a cut above the rest and, therefore, are worth the money you spend for them. Commercial themes also come with a mechanism to obtain support for the use of the theme. Generally, you aren’t allowed to remove any designer credits that appear in these themes, and you aren’t allowed to redistribute the themes. See “Exploring Premium Theme Options” later in this chapter for information about where to find premium themes.


Creating Your First Plugin

Creating Your First Plugin

When you’re developing something new, taking very small steps is usually best.
This way, if something breaks, the problem is clear. Doing multiple new things at
one time makes finding where something went wrong difficult.

Sticking with this concept, the first plugin you create in this chapter is a plugin
that can be activated and deactivated but doesn’t do anything — in other words, a
fully functional plugin shell that’s ready for code to be added.
Because this plugin is an example and doesn’t do anything, I named it Example
Plugin: Do Nothing

Setting up the plugin files


For this plugin, all you need is a main plugin file. Follow these steps to upload it
to its own directory:

1. Connect to your web server via Secure File Transfer Protocol (SFTP).
Check out Book 2, Chapter 2 for details on using SFTP.
2. Browse to the /wp-content/plugins directory in your WordPress
installation directory.
If you’re unsure where your WordPress installation directory is located, see
Book 2, Chapter 4, where I cover installing WordPress on your web server.
3. Create a new directory within /wp-content/plugins called /
example-do-nothing.
Most SFTP programs allow you to right-click in the SFTP window and choose
Add New Folder or Add New Directory from the shortcut menu.
4. Create an empty .php file with the filename init.php.
Use your favorite text editor, such as Notepad for PC or TextEdit for Mac, to
open a new file and then save it with the filename init.php.
5. Upload your blank do-nothing.php file to /wp-content/plugins/
example-do-nothing.
Your plugin directory and plugin file are set up.

In the next section, you add code to the do-nothing.php plugin file.

Adding the file header

Open the do-nothing.php file you created in the preceding section. (Most SFTP
programs have built-in text editors that allow you to right-click the file and
choose Edit from the shortcut menu.) Add the following lines of code to create the
file header:

<?php
/**
Plugin Name: Example Plugin: Do Nothing
Plugin URI: https://lisasabin-wilson.com
Description: This plugin literally does nothing. It is an example of how to
create a valid WordPress plugin.
Version: 1.0
Author: Lisa Sabin-Wilson
Author URI: https://lisasabin-wilson.com
License: GPLv2 or later
Text Domain: nothing
*/
?>
 Adding the closing ?> tag at the end of a PHP file is optional at this point. Leaving it out is helpful because it prevents you from accidentally adding code after it, which may cause the PHP code to break. Adding a plugin description isn’t necessary, but it makes the purpose of the plugin clear to anyone who reads your code. Additionally, the plugin description displays on the Plugins screen on your Dashboard to give users a good idea of the purpose of your plugin. When developing, you wind up with many plugins that you used for simple tests or left unfinished. Having solid names and descriptions adds order to the chaos so that you don’t forget or accidentally delete important code. Be sure to save the do-nothing.php file and upload it to your /wp-content/ plugins/example-do-nothing directory on your web server.