| @@ -162,12 +162,21 @@ | ||
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * Loads all registered commands. |
| 165 | 165 | * |
| 166 | + * Commands that opt in to conditional loading by implementing | |
| 167 | + * Loadable_Interface are skipped when their conditionals are not met. | |
| 168 | + * | |
| 166 | 169 | * @return void |
| 167 | 170 | */ |
| 168 | 171 | protected function load_commands() { |
| 169 | 172 | foreach ( $this->commands as $class ) { |
| 173 | + if ( \is_subclass_of( $class, Loadable_Interface::class ) | |
| 174 | + && ! $this->conditionals_are_met( $class ) | |
| 175 | + ) { | |
| 176 | + continue; | |
| 177 | + } | |
| 178 | + | |
| 170 | 179 | $command = $this->get_class( $class ); |
| 171 | 180 | |
| 172 | 181 | if ( $command === null ) { |
| 173 | 182 | continue; |