| Conditions | 3 |
| Paths | 4 |
| Total Lines | 140 |
| Code Lines | 90 |
| 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 |
||
| 30 | public function render() { |
||
| 31 | ?> |
||
| 32 | <!-- Post Meta box start--> |
||
| 33 | <fieldset class="options"> |
||
| 34 | <?php |
||
| 35 | $types = get_post_types( array( |
||
| 36 | 'public' => true, |
||
| 37 | '_builtin' => false, |
||
| 38 | ), 'names' |
||
| 39 | ); |
||
| 40 | |||
| 41 | array_unshift( $types, 'post' ); |
||
| 42 | ?> |
||
| 43 | <h4><?php _e( 'Select the post type whose post meta fields you want to delete', 'bulk-delete' ); ?></h4> |
||
| 44 | <table class="optiontable"> |
||
| 45 | <?php |
||
| 46 | foreach ( $types as $type ) { |
||
| 47 | ?> |
||
| 48 | <tr> |
||
| 49 | <td> |
||
| 50 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_type" value = "<?php echo $type; ?>" type = "radio" class = "smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_type" <?php checked( $type, 'post' ); ?>> |
||
| 51 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_type"><?php echo $type; ?> </label> |
||
| 52 | </td> |
||
| 53 | </tr> |
||
| 54 | <?php |
||
| 55 | } |
||
| 56 | ?> |
||
| 57 | </table> |
||
| 58 | |||
| 59 | <h4><?php _e( 'Choose your post meta field settings', 'bulk-delete' ); ?></h4> |
||
| 60 | <table class="optiontable"> |
||
| 61 | <tr> |
||
| 62 | <td> |
||
| 63 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value" value="use_key" type="radio" checked> |
||
| 64 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value"><?php echo __( 'Delete based on post meta key name only', 'bulk-delete' ); ?></label> |
||
| 65 | </td> |
||
| 66 | </tr> |
||
| 67 | |||
| 68 | <tr> |
||
| 69 | <td> |
||
| 70 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value" id="smdb_<?php echo esc_attr( $this->field_slug ); ?>_use_key_compare" value="use_key_compare" type="radio" disabled> |
||
| 71 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value"><?php echo __( 'Delete based on post meta key name prefix or postfix', 'bulk-delete' ); ?></label> |
||
| 72 | <span class="bd-pm-pro" style="color:red; vertical-align: middle;"> |
||
| 73 | <?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a href = "http://bulkwp.com/addons/bulk-delete-post-meta/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-m-p" target="_blank">Buy now</a> |
||
| 74 | </span> |
||
| 75 | </td> |
||
| 76 | </tr> |
||
| 77 | |||
| 78 | <tr> |
||
| 79 | <td> |
||
| 80 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value" value="use_value" type="radio" disabled> |
||
| 81 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_use_value"><?php echo __( 'Delete based on post meta key name and value', 'bulk-delete' ); ?></label> |
||
| 82 | <span class="bd-pm-pro" style="color:red; vertical-align: middle;"> |
||
| 83 | <?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a href = "http://bulkwp.com/addons/bulk-delete-post-meta/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-m-p" target="_blank">Buy now</a> |
||
| 84 | </span> |
||
| 85 | </td> |
||
| 86 | </tr> |
||
| 87 | |||
| 88 | <tr> |
||
| 89 | <td> |
||
| 90 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_key"><?php _e( 'Post Meta Key ', 'bulk-delete' ); ?></label> |
||
| 91 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_key_prefix_postfix" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_key_prefix_postfix" style="display: none;"> |
||
| 92 | <option value="starts_with">starts with</option> |
||
| 93 | <option value="contains">contains</option> |
||
| 94 | <option value="ends_with">ends with</option> |
||
| 95 | </select> |
||
| 96 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_key" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_key" placeholder="<?php _e( 'Meta Key', 'bulk-delete' ); ?>"> |
||
| 97 | </td> |
||
| 98 | </tr> |
||
| 99 | </table> |
||
| 100 | <?php |
||
| 101 | /** |
||
| 102 | * Add more fields to the delete post meta field form. |
||
| 103 | * This hook can be used to add more fields to the delete post meta field form. |
||
| 104 | * |
||
| 105 | * @since 5.4 |
||
| 106 | */ |
||
| 107 | do_action( 'bd_delete_post_meta_form' ); |
||
| 108 | ?> |
||
| 109 | <table class="optiontable"> |
||
| 110 | <tr> |
||
| 111 | <td> |
||
| 112 | <h4><?php _e( 'Choose your deletion options', 'bulk-delete' ); ?></h4> |
||
| 113 | </td> |
||
| 114 | </tr> |
||
| 115 | |||
| 116 | <tr> |
||
| 117 | <td> |
||
| 118 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_restrict" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_restrict" value = "true" type = "checkbox" > |
||
| 119 | <?php _e( 'Only restrict to posts which are ', 'bulk-delete' );?> |
||
| 120 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_op" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_op" disabled> |
||
| 121 | <option value ="before"><?php _e( 'older than', 'bulk-delete' );?></option> |
||
| 122 | <option value ="after"><?php _e( 'posted within last', 'bulk-delete' );?></option> |
||
| 123 | </select> |
||
| 124 | <input type ="textbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_days" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_days" disabled value ="0" maxlength="4" size="4"><?php _e( 'days', 'bulk-delete' );?> |
||
| 125 | </td> |
||
| 126 | </tr> |
||
| 127 | |||
| 128 | <tr> |
||
| 129 | <td> |
||
| 130 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_limit" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_limit" value = "true" type = "checkbox"> |
||
| 131 | <?php _e( 'Only delete post meta field from first ', 'bulk-delete' );?> |
||
| 132 | <input type ="textbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_limit_to" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_limit_to" disabled value ="0" maxlength="4" size="4"><?php _e( 'posts.', 'bulk-delete' );?> |
||
| 133 | <?php _e( 'Use this option if there are more than 1000 posts and the script times out.', 'bulk-delete' ) ?> |
||
| 134 | </td> |
||
| 135 | </tr> |
||
| 136 | |||
| 137 | <tr> |
||
| 138 | <td> |
||
| 139 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value = "false" type = "radio" checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?> |
||
| 140 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value = "true" type = "radio" id = "smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" disabled > <?php _e( 'Schedule', 'bulk-delete' ); ?> |
||
| 141 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" id = "smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value = "now" type = "text" disabled><?php _e( 'repeat ', 'bulk-delete' );?> |
||
| 142 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" id = "smbd_pm_cron_freq" disabled> |
||
| 143 | <option value = "-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option> |
||
| 144 | <?php |
||
| 145 | $schedules = wp_get_schedules(); |
||
| 146 | foreach ( $schedules as $key => $value ) { |
||
| 147 | ?> |
||
| 148 | <option value = "<?php echo $key; ?>"><?php echo $value['display']; ?></option> |
||
| 149 | <?php |
||
| 150 | } |
||
| 151 | ?> |
||
| 152 | </select> |
||
| 153 | <span class="bd-pm-pro" style="color:red"> |
||
| 154 | <?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a href = "http://bulkwp.com/addons/bulk-delete-post-meta/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-m-p">Buy now</a> |
||
| 155 | </span> |
||
| 156 | </td> |
||
| 157 | </tr> |
||
| 158 | |||
| 159 | <tr> |
||
| 160 | <td> |
||
| 161 | <?php _e( 'Enter time in Y-m-d H:i:s format or enter now to use current time', 'bulk-delete' );?> |
||
| 162 | </td> |
||
| 163 | </tr> |
||
| 164 | |||
| 165 | </table> |
||
| 166 | </fieldset> |
||
| 167 | |||
| 168 | <p> |
||
| 169 | <button type="submit" name="bd_action" value="delete_meta_post" class="button-primary"><?php _e( 'Bulk Delete ', 'bulk-delete' ) ?>»</button> |
||
| 170 | </p> |
||
| 250 |