Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automattic's updates and new actions and method #5

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b661d29
Don't expose file info in admin page name
mjangda Jun 9, 2011
f97a48e
Escape Theme Name in pagename
mjangda Jun 9, 2011
b97c39a
Use absolute paths for require_once calls
mjangda Jun 9, 2011
0c0ec40
Move CSS and JS callbacks to cheezcap.php
mjangda Jun 9, 2011
072c91f
Switch to PHP5 constructors
mjangda Jun 9, 2011
af8b301
Prefix classes with CheezCap to avoid potential conflicts
mjangda Jun 9, 2011
439df8a
Fix typo in example settings
mjangda Jun 9, 2011
daae665
Whoops, snuck in an extra line
mjangda Jun 9, 2011
6b3bb6a
Move admin action handler to earlier hook so we can do things like re…
mjangda Jun 9, 2011
26b9e8c
Rename, prefix a few more functions
mjangda Jun 9, 2011
d7dc924
Move admin function to cheezcap.php
mjangda Jun 9, 2011
8ce3bfa
Append date and site name to export file
mjangda Jun 9, 2011
103dd44
Switch to PHPDoc style for comment blocks
mjangda Jun 9, 2011
340268b
Move CheezCap class to cheezcap.php
mjangda Jun 10, 2011
c773df9
Move all cap-related functions to CheezCap, and move class to cheezca…
mjangda Jun 10, 2011
fd76e25
Get rid of globals by moving them into the CheezCap class
mjangda Jun 10, 2011
03be2b0
Rename config.php to config-sample.php
mjangda Jun 10, 2011
fed7ae0
Only load CheezCap config if a special const is defined. This is beca…
mjangda Jun 10, 2011
a8329fe
Let's add a whitelist of allowed caps that the dev can set. We don't …
mjangda Jun 10, 2011
03e67af
Redirect after actions to better follow POST-REDIRECT-GET pattern
mjangda Jun 10, 2011
cb2d478
Lowercase action names
mjangda Jun 10, 2011
7f52ebb
More flexible handling of success and error messages with redirect
mjangda Jun 10, 2011
c5cb625
Missed the actual case statements in the lowercase action switch
mjangda Jun 10, 2011
321c09d
Better error handling for imports
mjangda Jun 10, 2011
c29c102
Only allow requests via POST
mjangda Jun 10, 2011
52fba1c
Actually display success and error messages
mjangda Jun 10, 2011
53896b7
Bolder errors and global title
mjangda Jun 10, 2011
e60e61b
Pfft CDATA inside script tags. What is this? 2001?
mjangda Jun 10, 2011
be15c9a
Use submit_button helper function because we're lazy and we're cool.
mjangda Jun 10, 2011
176437d
Let's get nonce-y
mjangda Jun 10, 2011
da704c2
Be gentle when accessing an invalid option and WP_DEBUG isn't on
mjangda Jun 10, 2011
5c3bc5a
Add form labels
mjangda Jun 10, 2011
e9f74b3
Add some really simple javascript validation to the import button
mjangda Jun 10, 2011
6ad7c33
Fix indentation
mjangda Jun 10, 2011
aea0fc2
Use selected helper method
mjangda Jun 10, 2011
533bd94
Prevent undefined index warning
mjangda Jun 10, 2011
1129307
Add note about mods in header
mjangda Jun 10, 2011
34cbec8
Add save function to CheezCapOption
mjangda Jun 10, 2011
1e92968
Restrict dropdown save values to only those defined in options
mjangda Jun 10, 2011
656401e
Allow dropdown option labels to differ from the values
mjangda Jun 10, 2011
c6ca7b0
Args for Update and Reset are optional
mjangda Jun 10, 2011
3f2c2dc
CamelCasing is Lame
mjangda Jun 10, 2011
6687d52
CamelCasing is really lame
mjangda Jun 10, 2011
a5905c3
Clean up i18n
mjangda Jun 10, 2011
0e68567
Better sanitization when saving and getting values
mjangda Jun 10, 2011
7e4065c
Actually sanitize when getting values
mjangda Jun 10, 2011
c743fd0
Readme updates to reflect changes
mjangda Jun 11, 2011
0a459f6
Add helper function to access values. props moimikey
mjangda Jun 16, 2011
5c7d1fb
added validation callback & new CheezCapMultipleCheckboxesOption
Dec 23, 2011
d3ad697
Merge pull request #1 from johnbl4ck/master
mjangda Jan 21, 2012
3a71557
Remove reference to global $cap because it's a bad practice.
mjangda Jan 22, 2012
3b94991
updated config-sample.php with example of CheezCapMultipleCheckboxesO…
rinatkhaziev Apr 3, 2012
2a5d868
Updated readme with explanation of MultipleCheckboxesOption and Valdi…
rinatkhaziev Apr 3, 2012
83e812b
pop confirm dialog whenever user clicks 'reset' button to prevent acc…
rinatkhaziev May 24, 2012
a5c15c6
Merge pull request #2 from rinatkhaziev/master
mjangda May 24, 2012
f2c58db
Use strict null check for non-existant options when building output
mjangda Sep 20, 2013
1803af9
Fix a warning produced when second parameter for in_array check was a…
rinatkhaziev Oct 8, 2013
e858289
Prevent possible notice when trying to get non-existent cheezcap option
rinatkhaziev Jan 28, 2014
821e59d
Revert "Prevent possible notice when trying to get non-existent cheez…
rinatkhaziev Feb 14, 2014
8a08ded
Merge pull request #4 from rinatkhaziev/master
sboisvert Feb 24, 2014
84d0e21
added function to trigger actions for each action being executed in t…
Oct 26, 2014
d4b4a9d
added the get_data function to return all of the cheezcap options at …
Oct 26, 2014
24d0cbd
Converted the README.txt file to a README.md file and added info abou…
Oct 26, 2014
9bea9bc
removed errors detected by phpcs using WordPress.com VIP standard
Oct 26, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 74 additions & 39 deletions README.txt → README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
//
// CheezCap - Cheezburger Custom Administration Panel
// (c) 2008 - 2011 Cheezburger Network (Pet Holdings, Inc.)
// LOL: http://cheezburger.com
// Source: http://github.com/cheezburger/cheezcap/
// Authors: Kyall Barrows, Toby McKes, Stefan Rusek, Scott Porad
// License: GNU General Public License, version 2 (GPL), http://www.gnu.org/licenses/gpl-2.0.html
//
CheezCap - Cheezburger Custom Administration Panel
================
* CheezCap - Cheezburger Custom Administration Panel
* (c) 2008 - 2011 Cheezburger Network (Pet Holdings, Inc.)
* LOL: http://cheezburger.com
* Source: http://github.com/cheezburger/cheezcap/
* Authors: Kyall Barrows, Toby McKes, Stefan Rusek, Scott Porad
* UnLOLs by Mo Jangda ([email protected])
* License: GNU General Public License, version 2 (GPL), http://www.gnu.org/licenses/gpl-2.0.html


This is a fork of the original CheezCap developed by the fine Cheez-loving Cats over at ICHC. In has various bits of cleanup, the biggest being that it can be shared across multiple themes.

The fork lives at https://github.com/mjangda/cheezcap

"I'm In Yur Dashburd Tweakin' Yur Settings."

##
## Quick Start
##

1. Copy the CheezCap folder into your theme directory
2. Add the follwowing line to functions.php (if you don't have a functions.php, create one in your theme directory)

require_once('cheezcap/cheezcap.php');

3. Edit cheezcap/config.php
1. Copy the cheezcap folder into an appropriate location (maybe where you store your other shared plugins).
2. Add the following line to functions.php (if you don't have a functions.php, create one in your theme directory). Adjust the path as needed.
<br/><br/><pre><code>
require_once( WP_PLUGINS_DIR . '/cheezcap/cheezcap.php');
</code></pre><br/>
3. Use the included config-sample.php as a starting point to set up your options. Copy the modified version into your theme and include it.
<br/><br/><pre><code>
require_once( dirname( __FILE__ ) . '/cheezcap-config.php');
</code></pre><br/>
4. Sprinkle theme options around your code, like this:

<br/><br/><pre><code>
global $cap;
if ($cap->my_boolean_option) {
// do stuff
}

</code></pre><br/>
4b. Or use the helper function
<br/><br/><pre><code>
cheezcap_get_option( 'my_boolean_option', true, 'esc_html' );
</code></pre><br/>
5. Enjoy!


Expand All @@ -31,7 +47,7 @@
## Background
##

In order to use the same Wordpress theme for many different Wordpress sites, one of the things we've
In order to use the same WordPress theme for many different Wordpress sites, one of the things we've
done at Cheezburger is create themes with lots and lots of theme options. CheezCap is a simple library
we've made for creating custom wp-admin panels really, really easily.

Expand All @@ -43,13 +59,10 @@ It's just that easy!
##
## Installation
##
Installation is a two step process. First, copy the CheezCap folder into your theme directory. Next,
add the following line to functions.php in your theme (if you don't have a functions.php, create one
in the root of your theme directory).

require_once('cheezcap/cheezcap.php');
Follow the "Quick Start" instructions above.

Finally, to verify that CheezCap has installed correctly, simply open wp-admin and look for the
Finally, to verify that CheezCap has installed correctly, simply open /wp-admin and look for the
"CheezCap Settings" link on the left navigation panel toward the bottom.

##
Expand Down Expand Up @@ -77,6 +90,7 @@ are three types of Options available to create:
1. Boolean Option
2. Text Option
3. Dropdown Option
4. Multiple Checkboxes Option

## 1. Boolean Option
The simplest form of option...creates a true or false dropdown that can be used to turn features on or off.
Expand All @@ -91,49 +105,70 @@ The simplest form of option...creates a true or false dropdown that can be used
## 2. Text Option
A simple text field that can be used for configurable text, etc.

new TextOption(Name, Description, OptionID, Default, UseTextArea)
new TextOption(Name, Description, OptionID, Default, UseTextArea, ValidationCallback)

Name = a human readable name for the option.
Description = a human readable description for the option.
OptionID = a machine readable option identifier, cannot have spaces and must be unique
Default = a string as the default value for the option; if not specified, the default is ""
UseTextArea = a boolean describing if the text option should be written as a text area; if not specified, the
default is false;
ValidationCallback = optional custom validation callback (see example)

## 3. Dropdown Option
Allows you to create a dropdown with custom values by passing the constructor an array of options

new DropdownOption(Name, Description, OptionID, OptionsArray, DefaultIndex)
new DropdownOption(Name, Description, OptionID, OptionsArray, DefaultIndex, OptionsLabelsArray, ValidationCallback)

Name = a human readable name for the option.
Description = a human readable description for the option.
OptionID = a machine readable option identifier, cannot have spaces and must be unique
OptionsArray = an array containing the values for the dropdown menu
DefaultIndex = an integer identifying the item in the array that is the default value; if not specified,
the default is 0.
OptionsLabelsArray = if you want to seperate the labels from values, pass in an array with the labels matching indexes in the
OptionsArray
ValidationCallback = optional custom validation callback (see example)

## 4. Multiple Checkboxes Option
Allows you to create a multiple checkboxes option with custom values by passing the constructor an array of options
new MultipleCheezcapOption( Name, Description, OptionID, OptionsValues, OptionsLabels, OptionsChecked, ValidationCallback )

Name = a human readable name for the option.
Description = a human readable description for the option.
OptionID = a machine readable option identifier, cannot have spaces and must be unique
OptionsValues = an array containing the values for the dropdown menu
OptionsLabels = an array of labels correponding to OptionValues
OptionsChecked = an array of keys in OptionsValues that should be checked (selected)
ValidationCallback = optional custom validation callback (see example)

##
## Usage
##
CheezCap makes it easy to access the values that are set in your custom admin pages is easy. A global
variable $cap exists to allow you to access any variable by OptionID. (Hence, the need for OptionID
to be unique.)

For example, if you have created a DropdownOption with the OptionID "my_first_dropdown" then you
would access the value of that option like so:
CheezCap makes it easy to access the values that are set in your custom admin pages is easy.
You can use the built-in helper function:

cheezcap_get_option( $option, $echo = false, $sanitize_callback = '' )

##
## Actions
##

$cap->my_first_dropdown
Below are all of the actions you can hook in to:

For example, you might want to write that value to the screen:
* cheezcap_update
* cheezcap_reset
* cheezcap_export
* cheezcap_import

echo($cap->my_first_dropdown);
##
## Methods
##

And, in many cases, you will be accessing $cap from inside a function, so you will need to call
the global variable declaration in order to access $cap, like so:
Calling the get_data method returns all of the input.

function some_function() {
global $cap;
echo($cap->my_first_dropdown);
}
```
$data_arr = $cap->get_data();
```

*/
Loading