theme['authorURI'] = $theme->{'Author URI'}; } else { $theme = wp_get_theme( get_stylesheet_directory() . '/style.css' ); $this->theme['authorURI'] = $theme['AuthorURI']; } // Set constants for theme info $this->theme['name'] = $theme['Name']; $this->theme['nicename'] = strtolower( str_replace( " ", "-", $this->theme['name'] ) ); $this->theme['version'] = $theme['Version']; $this->theme['author'] = $theme['Author']; $this->theme['uri'] = $this->theme['authorURI'] . "themes/" . $this->theme['nicename']; $this->theme['support'] = $this->theme['authorURI'] . 'support/'; $this->theme['readme'] = get_template_directory_uri() . '/readme.txt'; // This will keep track of the checkbox options for the formHandler function. $this->checkboxes = array(); $this->settings = array(); $this->getSettings(); add_action( 'admin_menu', array( &$this, 'addPages' ) ); add_action( 'admin_init', array( &$this, 'registerSettings' ) ); add_action( 'admin_notices', array( &$this, 'updateNotice') ); add_action( 'wp_ajax_readme', array( &$this, 'displayReadme' ) ); /* if ( ! get_option( 'blogy_options' ) ) $this->initializeSettings(); */ } /** * Add options page * * */ public function addPages() { $admin_page = add_theme_page( __( 'Theme Options', 'blogy' ), __( 'Theme Options', 'blogy' ), 'manage_options', 'blogy-options', array( &$this, 'displayPage' ) ); add_action( 'admin_print_scripts-' . $admin_page, array( &$this, 'addScripts' ) ); add_action( 'admin_print_styles-' . $admin_page, array( &$this, 'addStyles' ) ); } /** * Create settings field * * */ public function createSetting( $args = array() ) { $defaults = array( 'id' => 'default_field', 'title' => __( 'Default Field', 'blogy' ), 'desc' => __( 'This is a default description.', 'blogy' ), 'std' => '', 'type' => 'text', 'section' => 'general', 'choices' => array(), 'class' => '', 'html' => '' ); extract( wp_parse_args( $args, $defaults ) ); $field_args = array( 'type' => $type, 'id' => $id, 'desc' => $desc, 'std' => $std, 'choices' => $choices, 'label_for' => $id, 'class' => $class, 'html' => $html ); if ( $type == 'checkbox' ) $this->checkboxes[] = $id; add_settings_field( $id, $title, array( $this, 'buildOptions' ), 'blogy-options', $section, $field_args ); } public function updateNotice( $notice=null, $message=null ) { if ( is_null( $message ) ) { $message = __( 'Settings updated.', 'blogy' ); } // our default notice if ( is_null( $notice ) && ! empty( $_GET['settings-updated'] ) ) { $notice = $_GET['settings-updated']; } // additional classes for styling and fading // i.e. 'updated other class more class' $classes = __( 'updated ', 'blogy' ); if ( $notice ) { add_settings_error( 'blogy-notices', 'blogy-updated', $message, $classes ); } settings_errors( 'blogy-notices' ); } /** * Display options page * * */ public function displayPage() { echo '
\\1', $readme);
$readme = preg_replace('/[\040]\*\*(.*?)\*\*/', ' \\1', $readme);
$readme = preg_replace('/[\040]\*(.*?)\*/', ' \\1', $readme);
// headings
$readme = preg_replace('/=== (.*?) ===/', '