| Conditions | 1 |
| Paths | 1 |
| Total Lines | 97 |
| Code Lines | 77 |
| 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 |
||
| 50 | function add_template( $gallery_templates ) { |
||
| 51 | |||
| 52 | $gallery_templates[] = array( |
||
| 53 | 'slug' => 'image-viewer', |
||
| 54 | 'name' => __( 'Image Viewer', 'foogallery' ), |
||
| 55 | 'lazyload_support' => true, |
||
| 56 | 'fields' => array( |
||
| 57 | array( |
||
| 58 | 'id' => 'thumbnail_size', |
||
| 59 | 'title' => __( 'Thumb Size', 'foogallery' ), |
||
| 60 | 'section' => __( 'General', 'foogallery' ), |
||
| 61 | 'desc' => __( 'Choose the size of your thumbnails', 'foogallery' ), |
||
| 62 | 'type' => 'thumb_size', |
||
| 63 | 'default' => array( |
||
| 64 | 'width' => 640, |
||
| 65 | 'height' => 360, |
||
| 66 | 'crop' => true |
||
| 67 | ), |
||
| 68 | 'row_data'=> array( |
||
| 69 | 'data-foogallery-preview' => 'shortcode' |
||
| 70 | ) |
||
| 71 | ), |
||
| 72 | array( |
||
| 73 | 'id' => 'thumbnail_link', |
||
| 74 | 'title' => __( 'Thumb Link', 'foogallery' ), |
||
| 75 | 'section' => __( 'General', 'foogallery' ), |
||
| 76 | 'default' => 'image' , |
||
| 77 | 'type' => 'thumb_link', |
||
| 78 | 'desc' => __( 'You can choose to either link each thumbnail to the full size image or to the image\'s attachment page', 'foogallery') |
||
| 79 | ), |
||
| 80 | array( |
||
| 81 | 'id' => 'lightbox', |
||
| 82 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 83 | 'section' => __( 'General', 'foogallery' ), |
||
| 84 | 'desc' => __( 'Choose which lightbox you want to use in the gallery', 'foogallery' ), |
||
| 85 | 'type' => 'lightbox' |
||
| 86 | ), |
||
| 87 | array( |
||
| 88 | 'id' => 'alignment', |
||
| 89 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 90 | 'section' => __( 'General', 'foogallery' ), |
||
| 91 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery', 'foogallery' ), |
||
| 92 | 'default' => 'fg-center', |
||
| 93 | 'type' => 'radio', |
||
| 94 | 'spacer' => '<span class="spacer"></span>', |
||
| 95 | 'choices' => array( |
||
| 96 | 'fg-left' => __( 'Left', 'foogallery' ), |
||
| 97 | 'fg-center' => __( 'Center', 'foogallery' ), |
||
| 98 | 'fg-right' => __( 'Right', 'foogallery' ), |
||
| 99 | ), |
||
| 100 | 'row_data'=> array( |
||
| 101 | 'data-foogallery-change-selector' => 'input:radio', |
||
| 102 | 'data-foogallery-preview' => 'class' |
||
| 103 | ) |
||
| 104 | ), |
||
| 105 | array( |
||
| 106 | 'id' => 'language-help', |
||
| 107 | 'title' => __( 'Language Help', 'foogallery' ), |
||
| 108 | 'desc' => __( 'This gallery template shows the below items of text. Change them to suit your preference or language.', 'foogallery' ), |
||
| 109 | 'section' => __( 'General', 'foogallery' ), |
||
| 110 | 'type' => 'help' |
||
| 111 | ), |
||
| 112 | array( |
||
| 113 | 'id' => 'text-prev', |
||
| 114 | 'title' => __( '"Prev" Text', 'foogallery' ), |
||
| 115 | 'section' => __( 'General', 'foogallery' ), |
||
| 116 | 'type' => 'text', |
||
| 117 | 'default' => __('Prev', 'foogallery'), |
||
| 118 | 'row_data'=> array( |
||
| 119 | 'data-foogallery-preview' => 'shortcode' |
||
| 120 | ) |
||
| 121 | ), |
||
| 122 | array( |
||
| 123 | 'id' => 'text-of', |
||
| 124 | 'title' => __( '"of" Text', 'foogallery' ), |
||
| 125 | 'section' => __( 'General', 'foogallery' ), |
||
| 126 | 'type' => 'text', |
||
| 127 | 'default' => __('of', 'foogallery'), |
||
| 128 | 'row_data'=> array( |
||
| 129 | 'data-foogallery-preview' => 'shortcode' |
||
| 130 | ) |
||
| 131 | ), |
||
| 132 | array( |
||
| 133 | 'id' => 'text-next', |
||
| 134 | 'title' => __( '"Next" Text', 'foogallery' ), |
||
| 135 | 'section' => __( 'General', 'foogallery' ), |
||
| 136 | 'type' => 'text', |
||
| 137 | 'default' => __('Next', 'foogallery'), |
||
| 138 | 'row_data'=> array( |
||
| 139 | 'data-foogallery-preview' => 'shortcode' |
||
| 140 | ) |
||
| 141 | ) |
||
| 142 | ) |
||
| 143 | ); |
||
| 144 | |||
| 145 | return $gallery_templates; |
||
| 146 | } |
||
| 147 | |||
| 245 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.