Stephane Daury, Doug Stewart, and Viper007Bond **************************************************************************/ class WPhone_Example { /** * Registers filters and actions. * * @since 1.0.0 * @return NULL */ function WPhone_Example() { // DEPRECATED add_filter( 'wphone_linkslist', array(&$this, 'AddListItem'), 10, 2 ); add_filter( 'wphone_menulist', array(&$this, 'UpdateMenuItems') ); add_filter( 'wphone_submenulist', array(&$this, 'UpdateSubmenuItems') ); add_filter( 'wphone_commentsmenu_countlist', array(&$this, 'ReplaceSpamSums') ); // COULD add_filter( 'wphone_includefile', array(&$this, 'FunctionToIncludeCustomFile') ); add_action( 'wphone_dashboard', array(&$this, 'OptionsList') ); add_action( 'wphone_dashboard_init', array(&$this, 'MaybeOptionsPage') ); } /** * If the current user can manage options, modify the primary navigation (initial screen + primary nav). * * Designed for the "wphone_menulist" filter. * * @since 1.5.0 * @param array $links The primary nav links, as defined in WPhone->set_nav_menu(). */ function UpdateMenuItems( $links ) { if ( current_user_can('manage_options') ) { // adding our own primary nav item $links[55] = array( __('Options [EG]', 'wphone_example'), 'manage_options', '', 'options' ); // overriding a default primary nav item $links[60] = array( __('What’s New [EG]', 'wphone_example'), 'manage_options', '', 'activity' ); } return $links; } /** * If the current user can moderate comments, modify the comments submenu. * * Designed for the "wphone_submenulist" filter. * * @since 1.5.0 * @param array $links The submenu links, as defined in WPhone->set_nav_menu(). */ function UpdateSubmenuItems( $links ) { if ( current_user_can('moderate_comments') ) { // overriding a default item in the Comments submenu $links['comments'][30] = array( __('Evil Spam (%d) [EG]', 'wphone_example'), 'moderate_comments', 'edit-comments.php?wphone=ajax&parent=edit-comments&type=spam' ); // adding our own item to the Comments submenu $links['comments'][40] = array( __('Standard Spam List (%d) [EG]', 'wphone_example'), 'moderate_comments', 'edit-comments.php?wphone=ajax&parent=edit-comments&type=spam' ); } return $links; } /** * If the current user can moderate comments, modify the sums displayed in the comments submenu. * * Designed for the "wphone_commentsmenu_countlist" filter. * * @since 1.5.0 * @param array $sums The comment count sums as defined in wphone/includes/comment/php -> apply_filters('wphone_commentsmenu_countlist', ...). */ function ReplaceSpamSums( $sums ) { if ( current_user_can('moderate_comments') ) { // displaying standard spam sum in our new comments menu item. $sums[40] = $sums[30]; // displaying our own custom spam count where we replaced the standard comments menu spam entry. $sums[30] = 157; // we caught 157 more spams! } return $sums; } /** * Outputs the sub-menu for the options menu. * * Designed for the "wphone_dashboard" filter. * * @since 1.0.0 * @return NULL */ function OptionsList() { global $WPhone; if ( !current_user_can('manage_options') ) return; // Tells WPhone not to load the header/footer when in AJAX mode $query_string = ($WPhone->iscompat) ? '?wphone=ajax' : ''; echo '
This would be the general options page.
'; break; case 'options-writing.php' : $text = 'This would be the writing options page.
'; break; case 'options-reading.php' : $text = 'This would be the reading options page.
'; break; case 'options-discussion.php' : $text = 'This would be the discussion options page.
'; break; case 'options-privacy.php' : $text = 'This would be the privacy options page.
'; break; case 'options-permalink.php' : $text = 'This would be the permalink options page.
'; break; case 'options-misc.php' : $text = 'This would be the miscellaneous options page.
'; break; default : return; // Unknown options page, so don't do anything } // Load header if not in AJAX mode if ( 'ajax' != $_GET['wphone'] ) $WPhone->load_interface('header'); // Page contents echo $text; // Load footer if not in AJAX mode if ( 'ajax' != $_GET['wphone'] ) $WPhone->load_interface('footer'); // Needed to abort showing the regular WPhone dashboard (a bit dirty, I know) exit(); } } $WPhone_Example = new WPhone_Example(); ?>