Category Archives: Plugins

01) Intro to Plugins

Plugins extend & add functionality & features.

  1. Download/Upload
    1. Contact Form
    2. Calendar
    3. Mapping
    4. Photo Gallery
    5. Security
    6. Backup
    7. miscellaneous functionality, etc.
  2. Install/Activate
  3. Upgrade Version
  4. Troubleshoot Problem
  5. Manage
  6. Develop New/Own

WordPress Plugins Repository
wordpress.org/plugins

Default Plugins included with fresh installation:

  • Akismet
  • hello.php

05) Security

For security, consider blocking direct access to your files by adding the following line of code at the top of each file:

defined('ABSPATH') or die("permission denied!");

or

if (!defined('ABSPATH')) exit;

Direct access to your files could cause PHP errors which would disclose your WordPress install path.

The ABSPATH constant is set in the bootstrap file wp-load.php. It will define ABSPATH as wp-load.php’s directory:

define( 'ABSPATH', dirname(__FILE__) . '/' );

Here are the first two files executed when your WordPress site is accessed:

wordpress/index.php
wp-blog-header
wordpress/wp-blog-header.php

And at the top of wordpress/wp-load.php you will find this:

wp-load
wordpress/wp-load.php

index.php > wp-blog-header.php > wp-load.php > wp-config.php > wp-settings.php > functions.php

06) File Header Format

repository

akismet


The WordPress plugin repository takes the “Requires” and “Tested up to” versions from the wordpress/wp-content/plugins/akismet/readme.txt file.

=== Akismet ===
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
Tags: akismet, comments, spam
Requires at least: 3.2
Tested up to: 4.1.1
Stable tag: 3.1.1
License: GPLv2 or later

Akismet checks your comments against the Akismet Web service to see if they look like spam or not.

== Description ==

Akismet checks your comments against the Akismet Web service to see if they look like spam or not and lets you review the spam it catches under your blog's "Comments" admin screen.

Stable tag should indicate the Subversion “tag” of the latest stable version, or “trunk,” if you use `/trunk/` for stable.

See https://wordpress.org/plugins/about/readme.txt


Top of the Akismet plugin PHP file:

<?php
/**
 * @package Akismet
 */
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
Version: 3.1.1
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
Text Domain: akismet
*/

* General Public License, version 2

07) Hooks

At various times while running, WordPress checks to see if any plugins have functions that are registered to run at that time. If so, those functions are executed.


Plugins register their functions to execute at various times using “filter” and “action” hooks.

Action functions return nothing but true, while Filter functions are expected to return something.


 

Use these commands in your plugin:

 add_action( $hook, $myFunction );
 add_filter( $hook, $myFunction );

Look for these commands in the source code of the templates to see where the hooks are executed:

 do_action( "$hook" )
 apply_filters( "$hook", "what_to_filter" )

Look into the wordpress/wp-admin/admin-footer.php template to find the admin_footer_text filter hook. It looks like this:


And, look into the wordpress/wp-admin/admin-header.php template to find the admin_notices action hook.

The conditionals in the code above show that not all admin pages use the same template.


wordpress.org/plugins/search/simply+show+hooks

Glossary

archive page – a list of posts based on a category, taxonomy, post type.

category – to access a limited set of posts.

class – 1) identifies the style to use in the HTML markup.
class – 2) the uninstantiated object in object oriented progamming (OOPS).

directory – what you see as a folder in your GUI, can be referred to as a “directory” in your command-line interface.

footer – bottom of the web page.

GUI – Graphical User Interface, pronounced goo•ey.

head – the HTML tag inside a web page holding data not displayed.

header – the top part of a web page.

hook – a place in core code made accessible to themes & plugins.

id – an identifier in CSS like class, but unique within the web page.

index – 1) points to an element of an array.
index – 2) the first HTML (or PHP) file sought within a directory.

mapping – using a domain you own to access your wp.com blog.

masking – an extreme form of mapping.

menu – list of links to pages or a category of posts.

navigation – menus to other places in a web site.

page – a “post” of the post type page.

permalink – a custom url structure, the permanent link to individual posts.

plugin – a file added to a theme usually to provide widget(s).

post – 1) a single item of “content” stored in the wp_posts database table, which is one of the five types: post, page, attachment, revision, nav_menu_item.
post – 2) a “post” of the post type post.

sanitize – author name, category, and postname get sanitized in permalinks by having spaces replaced with hyphens.

selector –  – in CSS, the rule set with declaration blocks (property name & value) pointing to the HTML element to style.

sidebar – navagation links, to the right or left.

slug – a user-friendly short text used in a permalink.

style – in CSS, a rule consisting of selectors, and declaration blocks.

tag – 1) an element of the HTML markup language.
tag – 2) used like a category (but without hierarchy) to provide more detail to a post.
$tag – 3) the hook parameter in an action function.
tag, template – 4) PHP function that instructs WordPress to “do” or “get” something. Conditional tags are used in template files to change the content displayed on a particular page depending on what conditions that page matches.

template – a PHP file controlling the structure of part of the web page.

theme – a collection of templates creating the look & feel (design) of the website.

UTC – Coordinated Universal Time is a “time standard” and not a time zone like Greenwich Mean Time (GMT) but, in practice, share the same current time.

widget – provided by a plugin to give extra function & structure.

 

frank_ernest