| Conditions | 8 |
| Paths | 14 |
| Total Lines | 94 |
| Code Lines | 74 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 29 | public function render() { |
||
| 30 | $taxs = get_taxonomies( array(), 'objects' |
||
| 31 | ); |
||
| 32 | |||
| 33 | $terms_array = array(); |
||
| 34 | if ( count( $taxs ) > 0 ) { |
||
| 35 | foreach ( $taxs as $tax ) { |
||
| 36 | $terms = get_terms( $tax->name ); |
||
| 37 | if ( count( $terms ) > 0 ) { |
||
|
|
|||
| 38 | $terms_array[ $tax->name ] = $terms; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | if ( count( $terms_array ) > 0 ) { |
||
| 44 | ?> |
||
| 45 | <h4><?php _e( 'Select the post type from which you want to delete posts by taxonomy', 'bulk-delete' ); ?></h4> |
||
| 46 | |||
| 47 | <fieldset class="options"> |
||
| 48 | <table class="optiontable"> |
||
| 49 | <?php $this->render_post_type_dropdown(); ?> |
||
| 50 | </table> |
||
| 51 | |||
| 52 | <h4> |
||
| 53 | <?php _e( 'Select the taxonomies from which you want to delete posts', 'bulk-delete' ); ?> |
||
| 54 | </h4> |
||
| 55 | |||
| 56 | <table class="optiontable"> |
||
| 57 | <?php |
||
| 58 | foreach ( $terms_array as $tax => $terms ) { |
||
| 59 | ?> |
||
| 60 | <tr> |
||
| 61 | <td scope="row"> |
||
| 62 | <input name="smbd_taxs" value="<?php echo esc_attr( $tax ); ?>" type="radio" class="custom-tax"> |
||
| 63 | </td> |
||
| 64 | <td> |
||
| 65 | <label for="smbd_taxs"><?php echo esc_attr( $taxs[ $tax ]->labels->name ); ?></label> |
||
| 66 | </td> |
||
| 67 | </tr> |
||
| 68 | <?php |
||
| 69 | } |
||
| 70 | ?> |
||
| 71 | </table> |
||
| 72 | |||
| 73 | <h4> |
||
| 74 | <?php _e( 'The selected taxonomy has the following terms. Select the terms from which you want to delete posts', 'bulk-delete' ); ?> |
||
| 75 | </h4> |
||
| 76 | |||
| 77 | <p> |
||
| 78 | <?php _e( 'Note: The post count below for each term is the total number of posts in that term, irrespective of post type', 'bulk-delete' ); ?>. |
||
| 79 | </p> |
||
| 80 | |||
| 81 | <?php |
||
| 82 | foreach ( $terms_array as $tax => $terms ) { |
||
| 83 | ?> |
||
| 84 | <table class="optiontable terms_<?php echo $tax; ?> terms"> |
||
| 85 | <?php |
||
| 86 | foreach ( $terms as $term ) { |
||
| 87 | ?> |
||
| 88 | <tr> |
||
| 89 | <td scope="row"> |
||
| 90 | <input name="smbd_taxs_terms[]" value="<?php echo $term->slug; ?>" type="checkbox" |
||
| 91 | class="terms"> |
||
| 92 | </td> |
||
| 93 | <td> |
||
| 94 | <label for="smbd_taxs_terms"><?php echo $term->name; ?> |
||
| 95 | (<?php echo $term->count . ' '; |
||
| 96 | _e( 'Posts', 'bulk-delete' ); ?>)</label> |
||
| 97 | </td> |
||
| 98 | </tr> |
||
| 99 | <?php |
||
| 100 | } |
||
| 101 | ?> |
||
| 102 | </table> |
||
| 103 | <?php |
||
| 104 | } |
||
| 105 | ?> |
||
| 106 | <table class="optiontable"> |
||
| 107 | <?php |
||
| 108 | $this->render_filtering_table_header(); |
||
| 109 | $this->render_restrict_settings(); |
||
| 110 | $this->render_exclude_sticky_settings(); |
||
| 111 | $this->render_delete_settings(); |
||
| 112 | $this->render_limit_settings(); |
||
| 113 | $this->render_cron_settings(); |
||
| 114 | ?> |
||
| 115 | </table> |
||
| 116 | |||
| 117 | </fieldset> |
||
| 118 | <?php |
||
| 119 | $this->render_submit_button(); |
||
| 120 | } else { |
||
| 121 | ?> |
||
| 122 | <h4><?php _e( "This WordPress installation doesn't have any non-empty taxonomies defined", 'bulk-delete' ) ?></h4> |
||
| 123 | <?php |
||
| 162 |