| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 53 |
| 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 |
||
| 43 | function setup_cpts() { |
||
| 44 | $order_capabilities = array( |
||
| 45 | 'edit_post' => 'edit_posts', |
||
| 46 | 'read_post' => 'read_private_posts', |
||
| 47 | 'delete_post' => 'delete_posts', |
||
| 48 | 'edit_posts' => 'edit_posts', |
||
| 49 | 'edit_others_posts' => 'edit_others_posts', |
||
| 50 | 'publish_posts' => 'publish_posts', |
||
| 51 | 'read_private_posts' => 'read_private_posts', |
||
| 52 | ); |
||
| 53 | $order_args = array( |
||
| 54 | 'label' => __( 'Order', 'jetpack' ), |
||
| 55 | 'description' => __( 'Simple Payments orders', 'jetpack' ), |
||
| 56 | 'supports' => array( 'custom-fields' ), |
||
| 57 | 'hierarchical' => false, |
||
| 58 | 'public' => false, |
||
| 59 | 'show_ui' => false, |
||
| 60 | 'show_in_menu' => false, |
||
| 61 | 'show_in_admin_bar' => false, |
||
| 62 | 'show_in_nav_menus' => false, |
||
| 63 | 'can_export' => true, |
||
| 64 | 'has_archive' => false, |
||
| 65 | 'exclude_from_search' => true, |
||
| 66 | 'publicly_queryable' => false, |
||
| 67 | 'rewrite' => false, |
||
| 68 | 'capabilities' => $order_capabilities, |
||
| 69 | 'show_in_rest' => true, |
||
| 70 | ); |
||
| 71 | register_post_type( self::$post_type_order, $order_args ); |
||
| 72 | |||
| 73 | $product_capabilities = array( |
||
| 74 | 'edit_post' => 'edit_posts', |
||
| 75 | 'read_post' => 'read_private_posts', |
||
| 76 | 'delete_post' => 'delete_posts', |
||
| 77 | 'edit_posts' => 'edit_posts', |
||
| 78 | 'edit_others_posts' => 'edit_others_posts', |
||
| 79 | 'publish_posts' => 'publish_posts', |
||
| 80 | 'read_private_posts' => 'read_private_posts', |
||
| 81 | ); |
||
| 82 | $product_args = array( |
||
| 83 | 'label' => __( 'Product', 'jetpack' ), |
||
| 84 | 'description' => __( 'Simple Payments products', 'jetpack' ), |
||
| 85 | 'supports' => array( 'custom-fields' ), |
||
| 86 | 'hierarchical' => false, |
||
| 87 | 'public' => false, |
||
| 88 | 'show_ui' => false, |
||
| 89 | 'show_in_menu' => false, |
||
| 90 | 'show_in_admin_bar' => false, |
||
| 91 | 'show_in_nav_menus' => false, |
||
| 92 | 'can_export' => true, |
||
| 93 | 'has_archive' => false, |
||
| 94 | 'exclude_from_search' => true, |
||
| 95 | 'publicly_queryable' => false, |
||
| 96 | 'rewrite' => false, |
||
| 97 | 'capabilities' => $product_capabilities, |
||
| 98 | 'show_in_rest' => true, |
||
| 99 | ); |
||
| 100 | register_post_type( self::$post_type_product, $product_args ); |
||
| 101 | } |
||
| 102 | |||
| 105 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.