| @@ 112-139 (lines=28) @@ | ||
| 109 | * - Removes any other v2 autoloader functions that have already been registered. This |
|
| 110 | * can occur when the autoloader is being reset by an activating plugin. |
|
| 111 | */ |
|
| 112 | public function update_autoloader_chain() { |
|
| 113 | spl_autoload_register( __NAMESPACE__ . '\autoloader' ); |
|
| 114 | ||
| 115 | $autoload_chain = spl_autoload_functions(); |
|
| 116 | ||
| 117 | foreach ( $autoload_chain as $autoloader ) { |
|
| 118 | if ( ! is_string( $autoloader ) ) { |
|
| 119 | /* |
|
| 120 | * The Jetpack Autoloader functions are registered as strings, so |
|
| 121 | * just continue if $autoloader isn't a string. |
|
| 122 | */ |
|
| 123 | continue; |
|
| 124 | } |
|
| 125 | ||
| 126 | if ( self::V1_AUTOLOADER_NAME === $autoloader ) { |
|
| 127 | // Move the v1.* autoloader function to the end of the spl autoloader chain. |
|
| 128 | spl_autoload_unregister( $autoloader ); |
|
| 129 | spl_autoload_register( $autoloader ); |
|
| 130 | ||
| 131 | } elseif ( |
|
| 132 | self::V2_AUTOLOADER_BASE === substr( $autoloader, 0, strlen( self::V2_AUTOLOADER_BASE ) ) |
|
| 133 | && __NAMESPACE__ !== substr( $autoloader, 0, strlen( __NAMESPACE__ ) ) |
|
| 134 | ) { |
|
| 135 | // Unregister any other v2.* autoloader functions if they're in the chain. |
|
| 136 | spl_autoload_unregister( $autoloader ); |
|
| 137 | } |
|
| 138 | } |
|
| 139 | } |
|
| 140 | } |
|
| 141 | ||
| @@ 170-197 (lines=28) @@ | ||
| 167 | * - Removes any other v2 autoloader functions that have already been registered. This |
|
| 168 | * can occur when the autoloader is being reset by an activating plugin. |
|
| 169 | */ |
|
| 170 | public function update_autoloader_chain() { |
|
| 171 | spl_autoload_register( __NAMESPACE__ . '\autoloader' ); |
|
| 172 | ||
| 173 | $autoload_chain = spl_autoload_functions(); |
|
| 174 | ||
| 175 | foreach ( $autoload_chain as $autoloader ) { |
|
| 176 | if ( ! is_string( $autoloader ) ) { |
|
| 177 | /* |
|
| 178 | * The Jetpack Autoloader functions are registered as strings, so |
|
| 179 | * just continue if $autoloader isn't a string. |
|
| 180 | */ |
|
| 181 | continue; |
|
| 182 | } |
|
| 183 | ||
| 184 | if ( self::V1_AUTOLOADER_NAME === $autoloader ) { |
|
| 185 | // Move the v1.* autoloader function to the end of the spl autoloader chain. |
|
| 186 | spl_autoload_unregister( $autoloader ); |
|
| 187 | spl_autoload_register( $autoloader ); |
|
| 188 | ||
| 189 | } elseif ( |
|
| 190 | self::V2_AUTOLOADER_BASE === substr( $autoloader, 0, strlen( self::V2_AUTOLOADER_BASE ) ) |
|
| 191 | && __NAMESPACE__ !== substr( $autoloader, 0, strlen( __NAMESPACE__ ) ) |
|
| 192 | ) { |
|
| 193 | // Unregister any other v2.* autoloader functions if they're in the chain. |
|
| 194 | spl_autoload_unregister( $autoloader ); |
|
| 195 | } |
|
| 196 | } |
|
| 197 | } |
|
| 198 | } |
|
| 199 | ||