Skip to content

Commit

Permalink
Hardcode connectors' filenames
Browse files Browse the repository at this point in the history
.. as they don't change often and is waste of resources to loop on then on each run, also to maintain interoperability #517
  • Loading branch information
shadyvb committed May 10, 2014
1 parent 61f7d59 commit 4d69bb5
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions includes/connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@ public static function load() {

require_once WP_STREAM_INC_DIR . 'connector.php';

$found = wp_cache_get( 'connectors_glob', 'wp_stream' );
if ( empty( $found ) ) {
$found = glob( WP_STREAM_DIR . 'connectors/*.php' );
wp_cache_set( 'connectors_glob', $found, 'wp_stream' );
}
$connectors = array(
'blogs',
'comments',
'editor',
'installer',
'media',
'menus',
'posts',
'settings',
'taxonomies',
'users',
'widgets',
);
$classes = array();
foreach ( $found as $class ) {
include_once $class;
$class_name = ucwords( preg_match( '#(.+)\.php#', basename( $class ), $matches ) ? $matches[1] : '' );
$class = "WP_Stream_Connector_$class_name";
foreach ( $connectors as $connector ) {
include_once WP_STREAM_DIR . '/connectors/' . $connector .'.php';
$class = "WP_Stream_Connector_$connector";
$classes[] = $class;
}

Expand Down

0 comments on commit 4d69bb5

Please sign in to comment.