a_arr_SettingsTabs); // load tab 'custom' require_once(dirname( __FILE__ ) . "/tab_custom.php"); new MCI_Footnotes_Tab_Custom($this->a_arr_SettingsTabs); // load tab 'how to' require_once(dirname( __FILE__ ) . "/tab_howto.php"); new MCI_Footnotes_Tab_HowTo($this->a_arr_SettingsTabs); } /** * sets the plugin's title for the admins settings menu * called in class constructor @ admin_menu * @since 1.0 */ public function RegisterMenu() { // current user needs the permission to update plugins for further access if (!current_user_can('update_plugins')) { return; } // Add a new sub menu to the standard Settings panel $this->a_str_Pagehook = add_options_page( FOOTNOTES_PLUGIN_PUBLIC_NAME, FOOTNOTES_PLUGIN_PUBLIC_NAME, 'administrator', FOOTNOTES_SETTINGS_PAGE_ID, array($this, 'DisplaySettings') ); } /** * Plugin Options page rendering goes here, checks * for active tab and replaces key with the related * settings key. Uses the plugin_options_tabs method * to render the tabs. * @since 1.0 */ public function DisplaySettings() { // load stylesheets and scripts $this->LoadScriptsAndStylesheets(); // gets active tab, or if nothing set the "general" tab will be set to active self::$a_str_ActiveTab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTES_SETTINGS_TAB_GENERAL; // outputs all tabs echo '
'; echo ''; // outputs a form with the content of the current active tab echo '
'; wp_nonce_field('update-options'); settings_fields(self::$a_str_ActiveTab); // outputs the settings field of the current active tab do_settings_sections(self::$a_str_ActiveTab); do_meta_boxes(self::$a_str_ActiveTab, 'main', NULL); // adds a submit button to the current page if (self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_HOWTO) { submit_button(); } echo '
'; echo '
'; // output settings page specific javascript code $this->OutputJavascript(); } /** * register and loads css and javascript files for settings * @since 1.3 */ private function LoadScriptsAndStylesheets() { // register settings stylesheet wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__)); // add settings stylesheet wp_enqueue_style('footnote_settings_style'); // Needed to allow meta box layout and close functionality wp_enqueue_script('postbox'); } /** * outputs page specific javascript code * @since 1.0.7 */ private function OutputJavascript() { ?> a_arr_Options)) { $this->a_arr_Options = MCI_Footnotes_getOptions(true); } $p_arr_Return = array(); $p_arr_Return["id"] = $this->getFieldID($p_str_FieldID); $p_arr_Return["name"] = $this->getFieldName($p_str_FieldID); $p_arr_Return["value"] = esc_attr($this->getFieldValue($p_str_FieldID)); return $p_arr_Return; } /** * access settings field by name * @since 1.0 * @param string $p_str_FieldName * @return string */ protected function getFieldName($p_str_FieldName) { // general setting if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_GENERAL) { return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName); // custom setting } else if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_CUSTOM) { return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER_CUSTOM, $p_str_FieldName); } // undefined return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName); } /** * access settings field by id * @since 1.0 * @param string $p_str_FieldID * @return string */ protected function getFieldID($p_str_FieldID) { return sprintf( '%s', $p_str_FieldID ); } /** * get settings field value * @since 1.0 * @param string $p_str_Key * @return string */ protected function getFieldValue($p_str_Key) { return $this->a_arr_Options[$p_str_Key]; } /** * outputs a break to have a new line * @since 1.0.7 */ public function AddNewline() { echo '

'; } /** * outputs a simple text * @param string $p_str_Text * @since 1.1.1 */ public function AddText($p_str_Text) { echo '' . $p_str_Text . ''; } /** * outputs a simple text with some highlight * @param string $p_str_Text+ * @return string * @since 1.1.1 */ public function Highlight($p_str_Text) { return '' . $p_str_Text . ''; } /** * outputs a label for a specific input/select box * @param string $p_str_SettingsID * @param string $p_str_Caption * @param string $p_str_Styling * @since 1.0.7 */ public function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "") { // add styling tag if styling is set if (!empty($p_str_Styling)) { $p_str_Styling = ' style="' . $p_str_Styling . '"'; } echo ''; } /** * outputs a input type=text * @param string $p_str_SettingsID [id of the settings field] * @param string $p_str_ClassName [css class name] * @param int $p_str_MaxLength [max length for the input value] * @param bool $p_bool_Readonly [input is readonly] in version 1.1.1 * @param bool $p_bool_Hidden [input is hidden by default] in version 1.1.2 * @since 1.0-beta * removed optional parameter for a label in version 1.0.7 */ public function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0, $p_bool_Readonly = false, $p_bool_Hidden = false) { // collect data for given settings field $l_arr_Data = $this->LoadSetting($p_str_SettingsID); // if input shall have a css class, add the style tag for it if (!empty($p_str_ClassName)) { $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; } // optional add a max length to the input field if (!empty($p_str_MaxLength)) { $p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"'; } if ($p_bool_Readonly) { $p_bool_Readonly = ' readonly="readonly"'; } if ($p_bool_Hidden) { $p_bool_Hidden = ' style="display:none;"'; } // outputs an input field type TEXT echo ''; } /** * outputs a input type=checkbox * @param string $p_str_SettingsID [id of the settings field] * @param string $p_str_ClassName [optional css class name] * @since 1.0-beta */ public function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "") { require_once(dirname(__FILE__) . "/convert.php"); // collect data for given settings field $l_arr_Data = $this->LoadSetting($p_str_SettingsID); // if input shall have a css class, add the style tag for it if (!empty($p_str_ClassName)) { $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; } // lookup if the checkbox shall be pre-checked $l_str_Checked = ""; if (MCI_Footnotes_Convert::toBool($l_arr_Data["value"])) { $l_str_Checked = 'checked="checked"'; } // outputs an input field type CHECKBOX echo sprintf('', $l_str_Checked); } /** * outputs a select box * @param string $p_str_SettingsID [id of the settings field] * @param array $p_arr_Options [array with options] * @param string $p_str_ClassName [optional css class name] * @since 1.0-beta */ public function AddSelect($p_str_SettingsID, $p_arr_Options, $p_str_ClassName = "") { // collect data for given settings field $l_arr_Data = $this->LoadSetting($p_str_SettingsID); // if input shall have a css class, add the style tag for it if (!empty($p_str_ClassName)) { $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; } // select starting tag $l_str_Output = ''; // outputs the SELECT field echo $l_str_Output; } /** * outputs a textarea * @param string $p_str_SettingsID [id of the settings field] * @param int $p_int_Rows [amount of rows] * @param string $p_str_ClassName [css class name] * @since 1.3 */ public function AddTextarea($p_str_SettingsID, $p_int_Rows, $p_str_ClassName = "") { // collect data for given settings field $l_arr_Data = $this->LoadSetting($p_str_SettingsID); // if input shall have a css class, add the style tag for it if (!empty($p_str_ClassName)) { $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; } // outputs an input field type TEXT echo ''; } }// class MCI_Footnotes_Admin endif;