All created and committed tabs. * ABDWPSM_Settings_Manager::$options_groups ---> All created and committed options groups. * ABDWPSM_Settings_Manager::$sections ---> All created and committed settings. * ABDWPSM_Settings_Manager::$fields ---> All created and committed fields. */ class ABDWPSM_Settings_Manager{ public static $tabs = array(); public static $options_groups = array(); public static $sections = array(); public static $fields = array(); protected static $query_args_to_strip = array(); // Keep this from being instantiated... It's a static class. protected function __construct() {} public static function initialize() { // Collect start state for performance logging $start_time = microtime( true ); $start_mem = memory_get_usage( true ); //wp_die('
' . htmlspecialchars( print_r( self::$options_groups, true ) ) . '
' ); foreach( self::$options_groups as $OG ) { register_setting( $OG->get_db_option_name(), // Option group name $OG->get_db_option_name(), // DB option name array( get_class( $OG ), 'validation_handler' ) // Sanitize/Validate callback ); } ABD_Log::perf_summary( 'ABDWPSM_Settings_Manager::initialize()', $start_time, $start_mem ); } public static function display_settings_page_content( $page_identifier ) { // Collect start state for performance logging $start_time = microtime( true ); $start_mem = memory_get_usage( true ); // Do we have the basic building block for the settings... an array of tabs in $tabs? if( !is_array( self::$tabs ) ) { // Oh noes! We must die a horrible death. self::die_with_message( "Expected array of ABDWPSM_Tab objects." ); } // Do we have any tabs in the array? if( empty( self::$tabs ) ) { self::die_with_message( "No tabs. You must create a tab!" ); } // Output any errors from previous submissions settings_errors(); // Output the tab nav // What's the current tab slug? if( isset( $_GET['tab'] ) ) { $active_tab_slug = $_GET['tab']; } else { // None provided, use the first tab. $active_tab_slug = null; } ?> 0 ) { // Yes, we have tabs, so output the tab contents for the active tab // Get the tab $Active_Tab = ABDWPSM_Tab::get_tab_by_url_slug( $active_tab_slug, $page_identifier ); if( is_null( $Active_Tab ) ) { echo '

Invalid tab!

'; return; } $Active_Tab->display_tab_contents( $page_identifier ); } else { // No tabs echo '

No tabs are set to display on this page.

'; } // Save memory by unsetting everything and triggering garbage collection (if possible) now that we've committed what we have. // Force the unset with =null since there have been memory exceeding problems and we want to get rid of everything. self::$fields = null; self::$sections = null; self::$options_groups = null; self::$tabs = null; ABD_Perf_Tools::force_garbage_collection(); ABD_Log::perf_summary( 'ABDWPSM_Settings_Manager::display_settings_page_content()', $start_time, $start_mem ); } public static function add_query_arg_to_strip( $query_arg_name ) { if( !is_string( $query_arg_name ) ) { self::die_with_message( 'Query arg name must be string!' ); } array_push( self::$query_args_to_strip, $query_arg_name ); } public static function die_with_message( $message ) { // Get calling location as pretty HTML. // http://php.net/manual/en/function.debug-backtrace.php $trace = debug_backtrace(); $trace_str = print_r( $trace, true ); $caller = array_shift( $trace ); $second_caller = array_shift( $trace ); // Function $function = ''; if( isset( $second_caller['class'] ) ) { $function .= $second_caller['class'] . '::'; } $function .= $second_caller['function'] . '()'; // Line number $line = $caller['line']; // File $file = $caller['file']; $loc_string = '

Error Location:

'; $loc_string .= 'Function: ' . $function; $loc_string .= '
File: ' . $file; $loc_string .= '
Line #: ' . $line; $loc_string .= '

Complete Backtrace

'; $loc_string .= '
' . htmlentities( $trace_str ) . '
'; // Now output the error. wp_die( '

ERROR

' . $message . '


' . $loc_string . 'WPSM Error' ); } /** * Returns a string representation of what the passed item is. (e.g. * "ABDWPSM_Field object" or "integer"). * @param {mixed} $the_thing The item for which you want to know what it is. * @return {string} Text description of what the passed item is. */ public static function wtf_is_this( $the_thing ) { if( is_object( $the_thing ) ) { $type = get_class( $the_thing ) . ' object'; } else { $type = gettype( $the_thing ); } return $type; } } // end class } // end if( !class_exists( ...