/** * get_options() * * @return array options **/ static function get_options() { static $o; if (isset($o) && !is_admin()) { return $o; } $o = get_option('script_manager'); if ($o === false || !isset($o['body'])) { $o = script_manager::init_options(); } return $o; }
/** * edit_options() * * @return void **/ static function edit_options() { echo '<div class="wrap">' . "\n" . '<form method="post" action="">' . "\n"; wp_nonce_field('script_manager'); $options = script_manager::get_options(); echo '<h2>' . __('Script Manager Settings', 'script-manager') . '</h2>' . "\n"; echo '<p>' . __('The script manager lets you insert arbitrary <script> tags on your site, and hook into its <body> tag\'s onload event. Fields similar to the ones below let you do the same on individual posts and pages.', 'script-manager') . '</p>' . "\n"; echo '<table class="form-table">' . "\n"; $fields = script_manager_admin::get_fields(); foreach ($fields as $field => $details) { echo '<tr valign="top">' . "\n" . '<th scope="row">' . $details['label'] . '</th>' . "\n" . '<td>' . "\n" . '<textarea name="' . $field . '" cols="58" rows="8" class="code widefat">' . esc_html($options[$field]) . '</textarea>' . "\n" . $details['desc'] . '</td>' . "\n" . '</tr>' . "\n"; } echo '</table>' . "\n"; echo '<p class="submit">' . '<input type="submit"' . ' value="' . esc_attr(__('Save Changes', 'script-manager')) . '"' . ' />' . '</p>' . "\n"; echo '</form>' . "\n" . '</div>' . "\n"; }