السبت، 3 أغسطس 2019

Creating Your Personal Profile

Creating Your Personal Profile

To personalize your site, visit the Profile screen of your WordPress Dashboard. To access the Profile screen, hover over the Users link in the Dashboard navigation menu, and click the Your Profile link. The Profile screen appears, as shown in Figure.

Here are the settings on this page:
» Personal Options: In the Personal Options section, you can set these
preferences for your site:
• Visual Editor: Select this check box to indicate that you want to use the
Visual Editor when writing your posts. The Visual Editor refers to the
formatting options you find on the Write Post screen (discussed in detail in
Book 4, Chapter 1). By default, the check box is deselected, which means
that the Visual Editor is off. To turn it on, select the check box.
• Syntax Highlighting: Select this check box to disable syntax highlighting. This
option disables the feature in the Dashboard theme and plugin code
editors that displays code in different colors and fonts, according to the
type of code being used (HTML, PHP, CSS, and so on). I cover theme and
plugin code in Books 6 and 7, respectively.
• Admin Color Scheme: These options set the colors for your Dashboard. The
Default color scheme is automatically selected for you in a new installation,
but you have other color options, including Light, Blue, Coffee, Ectoplasm,
Midnight, Ocean, and Sunrise.
• Keyboard Shortcuts: This check box enables you to use keyboard shortcuts
for comment moderation. To find out more about keyboard shortcuts,
click the More Information link; you’re taken to the Keyboard Shortcuts
page (https://codex.wordpress.org/Keyboard_Shortcuts) of the
WordPress Codex, which offers helpful information.
• Toolbar: This setting allows you to control the location of the admin toolbar
(see Book 3, Chapter 1) on your site. By default, the admin toolbar appears
at the top of every page of your site when you’re viewing the site in your
browser. It’s important to understand that the admin toolbar appears only
to users who are logged in, however. Regular visitors who aren’t logged in
to your site can’t see the admin toolbar.
» Name: Input personal information (such as your first name, last name, and
nickname), and specify how you want your name to appear publicly. Fill in the
text boxes with the requested information.
The rest of the options aren’t shown in Figure 2-9; you have to scroll down to
see them.
» Contact Info: In this section, provide your email address and other contact
information to tell your visitors who you are and where they can contact you.
Your email address is the only required entry in this section. This address is
the one WordPress uses to notify you when you have new comments or new
user registrations on your site. Make sure to use a real email address so that
you get these notifications. You can also insert your website URL into the
website text field.
» About Yourself: Provide a little bio for yourself, and change the password for
your site, if you want:
• Biographical Info: Type a short bio in the Biographical Info text box. This
information can appear publicly if you’re using a theme that displays your
bio, so be creative!
When your profile is published to your website, anyone can view it, and
search engines, such as Google and Yahoo!, can pick it up. Always be
careful with the information in your profile. Think hard about the information you want to share with the rest of the world!
• Profile Picture: Display the current photo that you’ve set in your Gravatar
account. You can set up a profile picture or change your existing one within
your Gravatar account at https://gravatar.com.
» Account Management: Manage your password and user sessions, as follows:
• New Password: When you want to change the password for your site, click
the Generate Password button in the New Password section. You can use
the password that WordPress generates for you or type your own password in the text field that appears.
Directly below the New Password text field is a password helper, where
WordPress helps you create a secure password. It alerts you if the
password you chose is too short or not secure enough by telling you that
it’s Weak or Very Weak. When creating a new password, use a combination
of letters, numbers, and symbols to make it hard for anyone to guess (such
as b@Fmn2quDtnSLQblhml%jexA). When you create a password that
WordPress thinks is a good one, it lets you know by saying that the
password is Strong.
Change your password frequently. Some people on the Internet make it
their business to attempt to hijack sites for their own malicious purposes. If
you change your password monthly, you lower your risk by keeping
hackers guessing.
• Sessions: If you’re logged in to your site on several devices, you can log
yourself out of those locations by clicking the Log Out Everywhere Else
button. This option keeps you logged in at your current location but logs
you out of any other location where you may be logged in. If you’re not
logged in anywhere else, the button is inactive, and a message appears
that says You are only logged in at this location.

When you finish setting all the options on the Profile screen, don’t forget to click the Update Profile button to save your changes.

Creating .htaccess files

Creating .htaccess files

You and WordPress work together in glorious harmony to create the .htaccess
file that lets you use a pretty-permalink structure in your site.

To create the .htaccess file, you need to be comfortable uploading files via SFTP
and changing permissions. Turn to Book 2, Chapter 2 if you’re unfamiliar with
either of those tasks.

If .htaccess already exists, you can find it in the root of your directory on your
web server — that is, the same directory where you find your wp-config.php file.
If you don’t see it in the root directory, try changing the options of your SFTP
client to show hidden files. (Because the .htaccess file starts with a period [.],
it may not be visible until you configure your SFTP client to show hidden files.)

If you don’t already have an .htaccess file on your web server, follow these
steps to create an .htaccess file on your web server and create a new permalink
structure:

  • 1. Using a plain-text editor (such as Notepad for Windows or TextEdit for a Mac), create a blank file; name it htaccess.txt and upload it to your web server via SFTP.
  • 2. After the file is uploaded to your web server, rename the file .htaccess (notice the period at the beginning), and make sure that it’s writable by the server by changing permissions to 755 or 777.
  • 3. Create the permalink structure on the Customize Permalink Structure page of your WordPress Dashboard.
  • 4. Click the Save Changes button at the bottom of the Customize Permalink Structure page.
WordPress inserts into the .htaccess file the specific rules necessary for
making the permalink structure functional on your site.

If you follow the preceding steps correctly, you have an .htaccess file on your
web server with the correct permissions set so that WordPress can write the correct rules to it. Your pretty-permalink structure works flawlessly. Kudos!

If you open the .htaccess file and look at it now, you see that it’s no longer blank.
It should have a set of code in it called rewrite rules, which looks something like
this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I could delve deeply into .htaccess and all the things you can do with this file, but
I’m restricting this chapter to how it applies to WordPress permalink structures. If
you want to unlock more mysteries about .htaccess, check out “Comprehensive
Guide to .htaccess” at www.javascriptkit.com/howto/htaccess.shtml.


WORKING WITH SERVERS THAT DON’T USE
APACHE MOD_REWRITE

Using permalink structures requires your web hosting provider to have a specific
Apache module option called mod_rewrite activated on its servers. If your web hosting
provider doesn’t have this item activated on its servers, or if you’re hosting your site on
a Windows server, the custom permalinks work only if you type index.php in front of
any custom permalink tags.
Create the custom permalink tags like this:
/index.php/%year%/%month%/%date%/%postname%/
This format creates a permalink like this:
https://yourdomain.com/index.php/2019/01/01/wordpress-all-in-onefor-dummies
You don’t need an .htaccess file to use this permalink structure
 

الأربعاء، 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.