do_items( ( array ) $handles ); } // Force style enqueue static function do_styles( $handles ) { self::do_scripts( 'jquery' ); global $wp_styles; if ( ! is_a( $wp_styles, 'WP_Styles' ) ) $wp_styles = new WP_Styles(); ob_start(); $wp_styles->do_items( ( array ) $handles ); $content = str_replace( array( "'", "\n" ), array( '"', '' ), ob_get_clean() ); echo ""; } // Enable delayed activation ( to be used with scb_init() ) static function add_activation_hook( $plugin, $callback ) { if ( defined( 'SCB_LOAD_MU' ) ) register_activation_hook( $plugin, $callback ); else add_action( 'scb_activation_' . plugin_basename( $plugin ), $callback ); } // Have more than one uninstall hooks; also prevents an UPDATE query on each page load static function add_uninstall_hook( $plugin, $callback ) { register_uninstall_hook( $plugin, '__return_false' ); // dummy add_action( 'uninstall_' . plugin_basename( $plugin ), $callback ); } // Get the current, full URL static function get_current_url() { return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } // Apply a function to each element of a ( nested ) array recursively static function array_map_recursive( $callback, $array ) { array_walk_recursive( $array, array( __CLASS__, 'array_map_recursive_helper' ), $callback ); return $array; } static function array_map_recursive_helper( &$val, $key, $callback ) { $val = call_user_func( $callback, $val ); } // Extract certain $keys from $array static function array_extract( $array, $keys ) { _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_array_slice_assoc()' ); return wp_array_slice_assoc( $array, $keys ); } // Extract a certain value from a list of arrays static function array_pluck( $array, $key ) { _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_list_pluck()' ); return wp_list_pluck( $array, $key ); } // Transform a list of objects into an associative array static function objects_to_assoc( $objects, $key, $value ) { _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'r41', 'scb_list_fold()' ); return scb_list_fold( $objects, $key, $value ); } // Prepare an array for an IN statement static function array_to_sql( $values ) { foreach ( $values as &$val ) $val = "'" . esc_sql( trim( $val ) ) . "'"; return implode( ',', $values ); } // Example: split_at( '', '' ) => array( '', '' ) static function split_at( $delim, $str ) { $i = strpos( $str, $delim ); if ( false === $i ) return false; $start = substr( $str, 0, $i ); $finish = substr( $str, $i ); return array( $start, $finish ); } } // Transform a list of objects into an associative array function scb_list_fold( $list, $key, $value ) { $r = array(); if ( is_array( reset( $list ) ) ) { foreach ( $list as $item ) $r[ $item[ $key ] ] = $item[ $value ]; } else { foreach ( $list as $item ) $r[ $item->$key ] = $item->$value; } return $r; } //_____Minimalist HTML framework_____ /* * Examples: * * html( 'p', 'Hello world!' );
Hello world!
* html( 'a', array( 'href' => 'http://example.com' ), 'A link' ); A link * html( 'img', array( 'src' => 'http://example.com/f.jpg' ) );
* html( 'ul', html( 'li', 'a' ), html( 'li', 'b' ) );