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.
| Key | Value |
|---|---|
| Key | Value |