Creating a product from ground zero is never fun. Let’s see if we can ease your pain some. There are several different ways in which you can begin using Redux Framework.
Use the Redux Generator
We at Redux understand how difficult it can be to get started. That’s why we built the Redux Generator. It automatically generates, according to your specifications, a theme or admin folder packed with all things Redux and/or TGM. Give it a try. It will be sure to save you time and pain. http://generate.reduxframework.com/
A walkthrough of Redux Framework and it’s features. Warning, it’s 16 mins long.
Don’t have the stomach to dive right into code? Would you like us to prove to you it’s worth your time? Check out the online demo of Redux. We promise, it won’t disappoint!
Step 1: Installing the Redux Framework Plugin
There are a few ways in which to install the Redux Framework into your WordPress instance, plugin, or theme. Choose which case best serves you, and move on to step two.
Install from WordPress.org
Installing Redux as a WordPress.org plugin, you can ensure both your users and you always have the most stable version installed. It’s suggested you using something like the TGM Plugin Activation to activate the Redux plugin within your theme/plugin. Your users will appreciate it many times over.
Install from the Github Repository
Do you have a need to be on the cutting edge? Or perhaps there is a bug we’ve recently fixed and you’re waiting to see if it worked? Might we suggest using out Github repository then. Our master branch is designed to be our most stable, up-to-date code. Grabbing it will result in the best possible experience. The Redux Framework deploy to WordPress.org might be behind 3-5 days from the master branch. Should you decide to go the route of installing Redux via Github, there are a couple of installation alternatives.
Github Method 1: Install Using GitHub Master Branch Zip Archive
This method is by far the easiest. Simply install the contents of the zip file as a plugin into your WordPress instance. It’s the same method as installing from WordPress.org, but with the very latest code. You’ll still get the same update notifications from WordPress.org. If you’d like to update to a new version of the Github repo, you’ll need to re-install the plugin with a fresh copy.
Github Method 2: Cloning the Repository Using Git
In staying with the latest trends, using Git is recommended. It allows you to pull updates from the repository any time you want. Also, there are a few great GUI tools available to make using Git easier. Github for Windows, Github for Mac, or SourceTree are recommended. They’re all fine (and free) utilities. But by far the coolest way to use Git would require the use of a command line git client. However, there is a bit of a learning curve. If you’re not familiar with Git, this particular method can be a bit daunting. It’s suggested that beginners read Git Immersion. For those desire a more thorough understanding of Git, another great resource is Pro Git. Here is how to clone the master branch of Redux from the command line, if you’re using Linux/Unix:
NOTE: Because Linux is the most popular server distro (and the one we recommend), these guides are told from the point of view of a Linux user. That said, the same commands generally apply to all operating systems.
cd my-project git clone https://github.com/ReduxFramework/ReduxFramework.git
This clones the repository into a directory titled ReduxFramework. Place this directory within your plugin directory, usually located at:
~/wp-content/plugins/. Once this step is completed, move on to step 2.
Step 2: Initialize with a New Config File
In order for the new options panel to appear, it needs to be initialized. Working with a new system for the first time can be daunting, so we’ve included a sample config file outlining many of the configurations possible with Redux. If you want the easiest way to get started, this is a great reference. Before we get started, it worth recommending that you never modify the sample-config.php file itself!! Editing this file directly will result in a loss of your configuration data when updating the Redux code base. Rather, the sample-config.php file should be copied to another location, where modifications may then be made. You have been warned! Once you have copied the sample-config.php file to a new location, or decided to throw all caution to the wind and use the sample-config.php file where it currently resides, you’re ready to require the config file.
NOTE: The sample-config.php file is located at: ReduxFramework/sample/sample-config.php.
NOTE: Don’t forget to update the path so it matches the path to your copy!
NOTE: Don’t forget to change your config class name or you’ll conflict with other vendors!
require_once (dirname(__FILE__) . '/sample/sample-config.php');
Now all you need to do is login to your admin panel. There you should see an Options menu at the bottom of the WordPress menu.
Step 3: Using the Saved Option Values
Now the options panel should be open. There it is, all nice and neat, looking perfect. So how do you begin using saved values throughout your theme or plugin? This is where the true magic of Redux comes into play. We understand the frustrations that come with working through a new system. This is why we’ve done our best to outline the most common use cases to simplify the process of getting your new project live!
To begin, you’ll need to define an
opt_name. This is a key component in the use of Redux. Choose a name this is not only descriptive, but easy to remember. The
opt_name variable is how Redux is able to be accessed by multiple plugins and themes at once, without conflict. For the purpose of this example, let’s assume the value of this variable is
test_theme. Now, to access the data saved via the control panel, simply reference the value from the
$test_theme global variable. In its default configuration, Redux automatically creates an array of the saved options and sets it to a variable defined by
But let’s say you don’t want your variable to be the
opt_name? Redux contains another definable argument titled
global_variable. When set, this argument overrides the default name used in creation of the global variable.
NOTE: To disable the creation of the global variable, set
global_variable to false. But with such a cool feature, why would you want to?
This variable may be used without anything else within your
functions.php file and other files, provided your code is not within another function. Should it be, the variable must be defined as global for the function. It’s an annoying PHP limitation. An example of how to accomplish this is shown below. In short, it’s necessary to use
global $test_theme; within the function before attempting to use the variable.
Because WordPress template files (header, footer, archive, etc) are run within a function, the variable will need to be massaged, as previously mentioned. Here’s a full example of what needs to be done within a function to get the option values.
// Due to a limitations of variables and functions, you must globally define // variables inside functions. global $redux_demo // This is your opt_name. print_r ($redux_demo);
There you go. That’s it!
You may now begin using Redux in your own theme or plugin. We sincerely hope you love it as much as we enjoyed bringing it to you.
Want a deeper integration?
Should you have a need to embed Redux within your theme/plugin, please read the Learn how to Embed Redux into your theme/plugin page to learn more!