_pluginOptionsArray; } // --------------------------------------------------------------------------- // Methods used to handle initialization of this plugin. // --------------------------------------------------------------------------- /** * Initialize() - Initializes the standard parameter set associated with this plugin. * * This function initializes the standard parameter set associated with this plugin so that the plugin * may be safely integrated into the Wordpress core. * * @param string $title The title of the plugin. * @param string $version The version of the plugin. * @param string $subfolderName The name of the plugin subfolder installed under the root plugins directory. * @param string $fileName The name of the plugin's main file. * * @return void None. * * @access public * @since {WP 2.3} * @author Keith Huster */ function Initialize( $title, $version, $subfolderName, $fileName ) { // Store the specified plugin parameters. $this->_pluginTitle = $title; $this->_pluginVersion = $version; $this->_pluginSubfolderName = $subfolderName; $this->_pluginFileName = $fileName; } // --------------------------------------------------------------------------- // Methods used to handle the administration page for this plugin. // --------------------------------------------------------------------------- /** * RegisterAdministrationPage() - Registers the plugin's administration page. * * This function registers the plugin's administration page with the Wordpress core via the add_action() * hook. This hook allows the plugin's administration paege to be processed as any standard Wordpress * administration page (such as the dashboard). * * @param string $parentMenu Parent menu of the plugin's administration menu. * @param string $minimumAccessLevel Minimum user access rights required to access the plugin's administration page. * @param string $adminMenuTitle Name of the plugin's administration menu. * @param string $adminMenuPageTitle Browser title of the plugin's administration page. * @param string $adminMenuPageSlug URI slug displayed for the plugin's administration webpage. * * @return void None. * * @access public * @since {WP 2.3} * @author Keith Huster */ function RegisterAdministrationPage( $parentMenu, $minimumAccessLevel, $adminMenuTitle, $adminMenuPageTitle, $adminMenuPageSlug ) { // Store the specified administration page parameters. $this->_pluginAdminMenuParentMenu = $parentMenu; $this->_pluginAdminMenuMinimumAccessLevel = $minimumAccessLevel; $this->_pluginAdminMenuTitle = $adminMenuTitle; $this->_pluginAdminMenuPageTitle = $adminMenuPageTitle; $this->_pluginAdminMenuPageSlug = $adminMenuPageSlug; // Wordpress hook for adding plugin admininistration menus. add_action( 'admin_menu', array( $this, '_AddAdministrationPage' ) ); } /** * _AddAdministrationPage() - Adds the plugin's administration page to the Wordpress core. * * This function adds the plugin's administration page to the Wordpress core by acting as a callback * function that was registered to the "admin_menu" function in the Wordpress core. * * @param void None. * * @return void None. * * @access private Access via admin_menu() callback only. * @since {WP 2.3} * @author Keith Huster */ function _AddAdministrationPage() { add_submenu_page( $this->_pluginAdminMenuParentMenu, $this->_pluginAdminMenuPageTitle, $this->_pluginAdminMenuTitle, $this->_pluginAdminMenuMinimumAccessLevel, $this->_pluginAdminMenuPageSlug, array( $this, '_DisplayPluginAdministrationPage' ) ); } /** * AddAdministrationPageBlock() - Adds a block of content to be displayed in the plugin's administration page. * * This function adds a block of content (i.e. an instance of a dbx-box class) to the plugin's administration * page. The placement and size of the block is controlled by the $blockType parameter. * * @param string $blockId ID of the content block used in HTML formatting (no spaces allowed). * @param string $blockTitle Title of the content block. * @param string $blockType Type of content block (one of CONTENT_BLOCK_TYPE_xxx). * @param string $blockFunctionPtr Function containing the content to be displayed. * * @return void None. * * @access public * @since {WP 2.3} * @author Keith Huster */ function AddAdministrationPageBlock( $blockId, $blockTitle, $blockType, $blockFunctionPtr ) { // Add a new page block to the array of available page blocks. $this->_pluginAdminMenuBlockArray[$blockId] = array( $blockTitle, $blockType, $blockFunctionPtr ); } /** * _DisplayAdministrationPageBlocks() - Displays the plugin's administration page blocks. * * This function displays each of the content blocks, of the specified type, that have been added to the * _pluginAdminMenuBlockArray via calls to the AddAdministrationPageBlock() function. The content blocks * are displayed from top to bottom in the order that they were added to the array. * * @param string $blockType Type of content block (one of CONTENT_BLOCK_TYPE_xxx). * * @return void None. * * @access private * @since {WP 2.3} * @author Keith Huster */ function _DisplayAdministrationPageBlocks( $blockType ) { if( is_array( $this->_pluginAdminMenuBlockArray ) ) { foreach( $this->_pluginAdminMenuBlockArray AS $blockKey=>$blockValue ) { if( $blockValue[$this->CONTENT_BLOCK_INDEX_TYPE] == $blockType ) { switch( $blockType ) { case $this->CONTENT_BLOCK_TYPE_SIDEBAR: // Create the markup necessary to display a SIDEBAR area content block. ?>
CONTENT_BLOCK_TYPE_MAIN: // Create the markup necessary to display a MAIN area content block. ?> ' ); echo( $htmlMessage ); echo( '' ); } /** * _DisplayPluginAdministrationPage() - Displays the plugin's administration page. * * This function displays the plugin's administration page that previously registered by a call * to the AddAdministrationPage() function. This function utilizes the DBX Management system created * by the _InitializeDbxManagementSystem() function to properly parse and display the page. This function * acts as a callback for the add_submenu_page() Wordpress core function. * * @param void None. * * @return void None. * * @access private Access via add_submenu_page() callback only. * @since {WP 2.3} * @author Keith Huster */ function _DisplayPluginAdministrationPage() { ?>The "' . $this->_pluginTitle . '" plugin options have been updated in the database.
'; $this->_DisplayFadingMessageBox( $updatedMessage ); } /** * _ResetPluginOptions() - Resets the plugin options in the Wordpress database. * * This function retrieves the plugin's default options from the options array and updates the associated * options stored within the Wordpress options database. * * @param void None. * * @return void None. * * @access private * @since {WP 2.3} * @author Keith Huster */ function _ResetPluginOptions() { // Update the plugin's options using the default values from the options array. foreach( $this->_pluginOptionsArray AS $optionKey => $optionValueArray ) { update_option( $optionKey, $optionValueArray[$this->OPTION_INDEX_VALUE] ); } // Now display to the user that the plugins have been reset to default values. $resetMessage = 'The "' . $this->_pluginTitle . '" plugin options have been reset to default values in the database.
'; $this->_DisplayFadingMessageBox( $resetMessage ); } /** * GetOptionValue() - Retrieves the option value for the specified option ID. * * This function retrieves the option value for the specified option ID from the Wordpress options database. * * @param string $optionName Name of the option whose value you are attempting to retrieve. * * @return mixed $optionValue Value of the requested option or "OPTION_PARAMETER_NOT_FOUND". * * @access public * @since {WP 2.3} * @author Keith Huster */ function GetOptionValue( $optionName ) { $optionValue = get_option( $optionName ); return $optionValue; } /** * GetOptionType() - Retrieves the option type for the specified option ID. * * This function retrieves the option type for the specified option ID from the plugin's option array. * This option parameter is not stored in the Wordpress options database so it is only accessible via the * plugin's options array. * * @param string $optionName Name of the option whose value you are attempting to retrieve. * * @return string $optionType Type of the requested option or "OPTION_PARAMETER_NOT_FOUND". * * @access public * @since {WP 2.3} * @author Keith Huster */ function GetOptionType( $optionName ) { $optionDescription = $this->OPTION_PARAMETER_NOT_FOUND; if( array_key_exists( $optionName, $this->_pluginOptionsArray ) ) { $optionDescription = $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_TYPE]; } return $optionDescription; } /** * GetOptionDescription() - Retrieves the option description for the specified option ID. * * This function retrieves the option description for the specified option ID from the plugin's option array. * This option parameter is not stored in the Wordpress options database so it is only accessible via the * plugin's options array. * * @param string $optionName Name of the option whose value you are attempting to retrieve. * * @return string $optionDescription Description of the requested option or "OPTION_PARAMETER_NOT_FOUND". * * @access public * @since {WP 2.3} * @author Keith Huster */ function GetOptionDescription( $optionName ) { $optionDescription = $this->OPTION_PARAMETER_NOT_FOUND; if( array_key_exists( $optionName, $this->_pluginOptionsArray ) ) { $optionDescription = $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_DESCRIPTION]; } return $optionDescription; } /** * GetOptionValuesArray() - Retrieves the option values array for the specified option ID. * * This function retrieves the option values array for the specified option ID from the plugin's option array. * This option parameter is not stored in the Wordpress options database so it is only accessible via the * plugin's options array. * * @param string $optionName Name of the option whose value you are attempting to retrieve. * * @return string $optionValuesList Comma-delimited list of the option values array. * * @access public * @since {WP 2.3} * @author Keith Huster */ function GetOptionValuesArray( $optionName ) { $optionValuesList = $this->OPTION_PARAMETER_NOT_FOUND; if( array_key_exists( $optionName, $this->_pluginOptionsArray ) ) { $optionValues = $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_VALUES_ARRAY]; if( is_array( $optionValues ) ) { $optionValuesList = ''; foreach( $optionValues AS $optionValue ) { $optionValuesList .= ',' . $optionValue; } $optionValuesList = trim( $optionValuesList, ',' ); } else { $optionValuesList = $optionValues; } } return $optionValuesList; } /** * DisplayPluginOption() - Displays the plugin's specified option. * * This function generates the markup required to display the specified option and displays it on the * plugin's administration page via the echo() function. * * @param string $optionName Name of the option to display. * * @return void None. * * @access public * @since {WP 2.3} * @author Keith Huster */ function DisplayPluginOption( $optionName ) { $optionMarkup = ''; if( array_key_exists( $optionName, $this->_pluginOptionsArray ) ) { switch( $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_TYPE] ) { case $this->OPTION_TYPE_TEXTBOX: // Generate the markup required to display an XHTML compliant textbox. $optionMarkup = $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_DESCRIPTION] . ' '; $optionMarkup .= ' '; break; case $this->OPTION_TYPE_TEXTAREA: // Generate the markup required to display an XHTML compliant textarea. $optionMarkup = $this->_pluginOptionsArray[$optionName][$this->OPTION_INDEX_DESCRIPTION] . '