prefix = 'chunks-' . sanitize_title(get_current_theme()); // Let's add some actions add_action('admin_menu', array(&$this, 'admin_menu')); } /* * Admin Menu Builder * * Adds an administrative menu under the Appearance section called * Theme Chunks. Also makes sure that chunks are loaded from * the database. * * @uses add_theme_page */ function admin_menu() { add_theme_page('Theme Chunks', 'Theme Chunks', 'manage_options', 'chunks-plugin', array(&$this, 'theme_page')); $this->load_chunks(); } /* * Save Chunks * * Saves the chunks values array to the database, using the * theme prefix. * * @uses update_option */ function save_chunks() { update_option($this->prefix . '-values', $this->values); } /* * Load Chunks * * Loads the chunks values array from the database or cache * using the active theme prefix. * * @uses get_option */ function load_chunks() { $this->values = (array) get_option($this->prefix . '-values'); } /* * Register Chunks * * This function is used from outside this class by a register_chunks * function of it's own. Populates the chunks array. */ function register_chunks($array) { if (!is_array($array)) return false; $this->chunks = $array; } /* * Theme Options * * Theme Chunks page in the administrative area. Handles list, * edit and save actions. */ function theme_page() { if (isset($_POST['edit-chunks-submit'])) { $key = $_POST['edit-chunks-submit']; if (isset($this->chunks[$key])) { $value = stripslashes($_POST['chunk-value']); if (strlen($value) > 0) { $this->values[$key] = $value; $this->save_chunks(); $updated = true; } else { unset($this->values[$key]); $this->save_chunks(); $updated = true; } } } ?>

Chunk updated.

Below is a list of chunks that has registered. Learn more about Using Chunks.

chunks as $key => $description): if (isset($this->values[$key])) $value = substr(htmlspecialchars($this->values[$key]), 0, 400) . '...'; else $value = 'No value set'; ?>
Key Value
Key Value

chunks[$key])): ?>  

Editing "":

chunks[$_GET['key']]; ?>

Note: chunk values are not escaped or sanitized, you can use HTML, javascript and the rest.

or Cancel

register_chunks($array); } } /* * Chunk Function * * Used to request a chunk from the database using a $key and an (optional) * $default value. If WP_DEBUG is switched on, warning messages are * returned. * * @global $chunks */ if (!function_exists('chunk')) { function chunk($key, $default='') { global $chunks; $chunks->load_chunks(); if (WP_DEBUG) { if (!isset($chunks->chunks[$key])) return "Chunk not set: {$key}"; if (!isset($chunks->values[$key])) return "Value for chunk not set: {$key}"; } if (isset($chunks->chunks[$key]) && isset($chunks->values[$key])) return $chunks->values[$key]; return $default; } } // Fire up the global $chunks; add_action('plugins_loaded', create_function('', 'global $chunks; $chunks = new Chunks();'));