Skip to content

Commit bfdbe14

Browse files
Copilotswissspidy
andcommitted
Remove redundant version checks from command methods
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 83b0161 commit bfdbe14

3 files changed

Lines changed: 0 additions & 48 deletions

File tree

‎src/Font_Collection_Command.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ class Font_Collection_Command extends WP_CLI_Command {
8686
* @subcommand list
8787
*/
8888
public function list_( $args, $assoc_args ) {
89-
if ( ! class_exists( 'WP_Font_Library' ) ) {
90-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
91-
}
92-
9389
$font_library = WP_Font_Library::get_instance();
9490
$collections = $font_library->get_font_collections();
9591

@@ -156,10 +152,6 @@ public function list_( $args, $assoc_args ) {
156152
* Google Fonts
157153
*/
158154
public function get( $args, $assoc_args ) {
159-
if ( ! class_exists( 'WP_Font_Library' ) ) {
160-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
161-
}
162-
163155
$slug = $args[0];
164156
$font_library = WP_Font_Library::get_instance();
165157
$collection = $font_library->get_font_collection( $slug );

‎src/Font_Face_Command.php‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ class Font_Face_Command extends WP_CLI_Command {
109109
* @subcommand list
110110
*/
111111
public function list_( $args, $assoc_args ) {
112-
if ( ! post_type_exists( 'wp_font_face' ) ) {
113-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
114-
}
115-
116112
$formatter = $this->get_formatter( $assoc_args );
117113

118114
$query_args = array(
@@ -176,10 +172,6 @@ public function list_( $args, $assoc_args ) {
176172
* +------------+-------------+
177173
*/
178174
public function get( $args, $assoc_args ) {
179-
if ( ! post_type_exists( 'wp_font_face' ) ) {
180-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
181-
}
182-
183175
$font_face_id = $args[0];
184176
$post = get_post( $font_face_id );
185177

@@ -231,10 +223,6 @@ public function get( $args, $assoc_args ) {
231223
* 17
232224
*/
233225
public function create( $args, $assoc_args ) {
234-
if ( ! post_type_exists( 'wp_font_face' ) ) {
235-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
236-
}
237-
238226
if ( ! isset( $assoc_args['post_parent'] ) ) {
239227
WP_CLI::error( 'The --post_parent parameter is required.' );
240228
}
@@ -307,10 +295,6 @@ public function create( $args, $assoc_args ) {
307295
* Success: Updated font face 15.
308296
*/
309297
public function update( $args, $assoc_args ) {
310-
if ( ! post_type_exists( 'wp_font_face' ) ) {
311-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
312-
}
313-
314298
$font_face_id = $args[0];
315299
$post = get_post( $font_face_id );
316300

@@ -370,10 +354,6 @@ public function update( $args, $assoc_args ) {
370354
* Success: Deleted font face 17.
371355
*/
372356
public function delete( $args, $assoc_args ) {
373-
if ( ! post_type_exists( 'wp_font_face' ) ) {
374-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
375-
}
376-
377357
$force = Utils\get_flag_value( $assoc_args, 'force' );
378358

379359
$count = 0;

‎src/Font_Family_Command.php‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ class Font_Family_Command extends WP_CLI_Command {
102102
* @subcommand list
103103
*/
104104
public function list_( $args, $assoc_args ) {
105-
if ( ! post_type_exists( 'wp_font_family' ) ) {
106-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
107-
}
108-
109105
$formatter = $this->get_formatter( $assoc_args );
110106

111107
$query_args = array(
@@ -169,10 +165,6 @@ public function list_( $args, $assoc_args ) {
169165
* +------------+-------------+
170166
*/
171167
public function get( $args, $assoc_args ) {
172-
if ( ! post_type_exists( 'wp_font_family' ) ) {
173-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
174-
}
175-
176168
$font_family_id = $args[0];
177169
$post = get_post( $font_family_id );
178170

@@ -221,10 +213,6 @@ public function get( $args, $assoc_args ) {
221213
* 12
222214
*/
223215
public function create( $args, $assoc_args ) {
224-
if ( ! post_type_exists( 'wp_font_family' ) ) {
225-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
226-
}
227-
228216
if ( ! isset( $assoc_args['post_title'] ) ) {
229217
WP_CLI::error( 'The --post_title parameter is required.' );
230218
}
@@ -283,10 +271,6 @@ public function create( $args, $assoc_args ) {
283271
* Success: Updated font family 10.
284272
*/
285273
public function update( $args, $assoc_args ) {
286-
if ( ! post_type_exists( 'wp_font_family' ) ) {
287-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
288-
}
289-
290274
$font_family_id = $args[0];
291275
$post = get_post( $font_family_id );
292276

@@ -338,10 +322,6 @@ public function update( $args, $assoc_args ) {
338322
* Success: Deleted font family 12.
339323
*/
340324
public function delete( $args, $assoc_args ) {
341-
if ( ! post_type_exists( 'wp_font_family' ) ) {
342-
WP_CLI::error( 'Font Library is not available. Requires WordPress 6.5 or greater.' );
343-
}
344-
345325
$force = Utils\get_flag_value( $assoc_args, 'force' );
346326

347327
$count = 0;

0 commit comments

Comments
 (0)