Skip to content

The Variable-Solutions plugin extends the WordPress content management system by enabling the creation and management of variables that can be referenced as short codes in WordPress content and/or as defined variables in the supporting PHP files. It is very thin and loads only one file when running in end user mode. The Variable-Solutions plugin…

License

Notifications You must be signed in to change notification settings

jaschwanda/variable-solutions

Repository files navigation

Variable-Solutions

The Variable-Solutions plugin adds global variables to the WordPress content management system.

Description

The Variable-Solutions plugin extends WordPress enabling the creation and management of variables that can be referenced as short codes in WordPress content and/or as defined variables in the supporting PHP files. It is a thin plugin that loads only one file when running in end user mode. The Variable-Solutions plugin is developed and maintained by Universal Solutions.

What are Variables - Say you have some information that changes frequently and appears on multiple pages. It could be the date of your next big event or even the product of the month. Keeping track of where this information appears on your site and making consistent updates can be a labor intensive and error prone process. The Variable-Solutions plugin uses shortcodes to give each piece of information a unique "variable" name. These unique variable names, along with the information the name represents, are easily managed in the admin back end.

What are Shortcodes - Shortcodes are special tags used as shortcuts to easily insert bits of functionality into your content. You can recognize shortcodes by square brackets that surround a simple word or a phrase.

Show Me an Example - If your site features a product of the month, you can create the variable 'product_of_the_month' and set it to "Our New Gadget", then you can include this variable anywhere in your content with the following shortcode:

[variable item="product_of_the_month"]

and your visitors will see "Our New Gadget" wherever the above shortcode is used. Next month when your product changes, you can make one edit and set the 'product_of_the_month' variable to "Our Newest Gadget" and your visitors will see the updated content everywhere the shortcode is used.

Installation

The Variable-Solutions plugin follows the standard WordPress manual plugin installation procedure:

  1. Install the Settings-Solutions plugin.
  2. Clone or Download the Variable-Solutions archive to your computer.
  3. Extract the archive contents to your local file system.
  4. Rename the extracted folder to usi-variable-solutions if not already done so during the extraction.
  5. Upload the .php files from your usi-variable-solutions folder to the wp-content/plugins folder in your target WordPress installation.
  6. Activate the plugin via the WordPress Plugins menu located on the left side bar.

Implementation

The Variable-Solutions plugin stores the variables you create in the WordPress database and writes them to the variables.php file. This file contains PHP define statements that can be referenced by code in your system. Using the example from above, the variables.php file would contain the following line:

define('prefix_PRODUCT_OF_THE_MONTH', 'Our New Gadget');

Any custom theme or plugin code in your WordPress installation can reference the prefix_PRODUCT_OF_THE_MONTH variable and get the value 'Our New Gadget'. The prefix_ string defaults to the WordPress database prefix.

You can control the location of the variables.php file and other configuration options via the Variable-Solutions page under the WordPress Settings menu located on the left side bar.

Settings

The Variable-Solutions settings page contains three tabs: Preferences, Publish and Capabilities.

Preferences - allows you to change the default options set during plugin installation.

Publish - any changes you make to you variables must be published before the changes appear to the world.

Capabilities - allows you to set the role capabilites system-wide or for a specific user on a user-by-user basis.

Usage

Click on the WordPress Variables menu located on the left side bar to see the list of variables that are in your WordPress installation. Click the Add New button to add a new variable or hover over a variable name and click the Edit link to edit an existing variable.

The edit variable page shows the variable category and variable name for the selected variable along with some other parameters. The Variable-Solutions plugin comes with the built-in general category which is used as the default category if no category is given. There is no harm in specifying the general category, in which case the shortcode is written as follows:

[variable category="general" item="product_of_the_month"]

Note - If you edit an existing variable and change it's category or variable name, then the old category and variable name pair are repalced with the new combination. This can cause referencing errors if you don't make the corresponding changes in your content.

Additionally, there is the built-in date category for inserting dates into your content. Enter the date using the 24-hour clock, year first then time format as follows:

1970-01-01 00:00:00

You can then specify how the date is displayed when WordPress processes the shortcode. For example:

[variable category="date" item="unix_epoch" format="F js, Y"]

displays January 1st, 1970, which is the format specified by the F js, Y string. You can find the format string parameter reference here: php.net/manual/en/function.date.php.

Screen Images

Variable List Page Screen Image 1 - Variable List Page


Add Variable Page Screen Image 2 - Add Variable Page

License

Variable-Solutions is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Variable-Solutions is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Variable-Solutions. If not, see http://www.gnu.org/licenses/.

Donations

Donations are accepted at www.usi2solve.com/donate. Thank you for your support!

About

The Variable-Solutions plugin extends the WordPress content management system by enabling the creation and management of variables that can be referenced as short codes in WordPress content and/or as defined variables in the supporting PHP files. It is very thin and loads only one file when running in end user mode. The Variable-Solutions plugin…

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages