options = new ABB_Options(); // Grab an instance of the ABB_Options class if($show_readme_faq) : add_action('abb_after_tabs', array(&$this, 'do_readme_tab')); add_action('abb_after_tab_contents', array(&$this, 'do_readme_tab_content')); endif; } /** * Add the Read Me tab to the plugin settings page */ public function do_readme_tab(){ ?> Read Me FAQ plugin_text_domain) ); $content = $this->get_faq(true); ?>
get_faq($for_readme); } /** * Return the plugin FAQ * * @param required boolean $for_readme Whether or not the FAQ is for the plugin readme * @return string */ public function get_faq($for_readme){ $this->for_readme = $for_readme; $questions = array(); $questions[] = $this->get_faq_options(); $questions[] = $this->get_faq_defaults(); $questions[] = $this->get_faq_animation(); $questions[] = $this->get_faq_reset(); return join("\n\n", $questions); } /** * Return the FAQ question "What options are available?" * * @return string */ private function get_faq_options(){ global $wp_settings_sections, $wp_settings_fields; if(!isset($wp_settings_sections[$this->settings_page])) return; $title = sprintf( $this->get_title_format(), __('What options are available?', $this->plugin_text_domain) ); $sections = array(); $i = 0; foreach((array)$wp_settings_sections[$this->settings_page] as $section) : $section_title = sprintf( $this->get_section_format(), $section['title'] ); $options = array(); foreach ((array)$wp_settings_fields[$this->settings_page][$section['id']] as $field) : $description = (isset($field['args']['control_args']['faq_description'])) // Check to see if a specific FAQ description has been declared... ? $field['args']['control_args']['faq_description'] // ...It has - use that : ((isset($field['args']['control_args']['description'])) // ...It has not - check to see if a control descritption has been declared... ? $field['args']['control_args']['description'] // ......It has - use that : __('Sorry, we can\'t find and details about this option.', $this->plugin_text_domain)); // ......It has not - lie to the user to cover up your mistake *whistles onchalantly* $options[].= sprintf( $this->get_option_format(), /** %1$s - The option title */ $field['title'], /** %2$s - The description to show the user */ $description ); endforeach; $sections[$i] = $section_title . join("\n", $options); $sections[$i] = $this->maybe_wrap($sections[$i], '' ,'
'); return $title . $content; } /** * Return the appropriate format to use when outputting an FAQ question title * * @return string */ private function get_title_format(){ return ($this->for_readme) ? '= %1$s ='."\n\n" : '%1$s
'; } /** * Return the appropriate format to use when outputting a settings option * * @return string */ private function get_option_format(){ return ($this->for_readme) ? '* **%1$s:** > %2$s' : '