| Conditions | 1 |
| Paths | 1 |
| Total Lines | 105 |
| Code Lines | 87 |
| 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 |
||
| 39 | function add_template( $gallery_templates ) { |
||
| 40 | $gallery_templates[] = array( |
||
| 41 | 'slug' => 'masonry', |
||
| 42 | 'name' => __( 'Masonry Image Gallery', 'foogallery' ), |
||
| 43 | 'lazyload_support' => true, |
||
| 44 | 'admin_js' => FOOGALLERY_MASONRY_GALLERY_TEMPLATE_URL . 'js/admin-gallery-masonry.js', |
||
| 45 | 'fields' => array( |
||
| 46 | array( |
||
| 47 | 'id' => 'thumbnail_width', |
||
| 48 | 'title' => __( 'Thumb Width', 'foogallery' ), |
||
| 49 | 'desc' => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated', 'foogallery' ), |
||
| 50 | 'section' => __( 'General', 'foogallery' ), |
||
| 51 | 'type' => 'number', |
||
| 52 | 'class' => 'small-text', |
||
| 53 | 'default' => 150, |
||
| 54 | 'step' => '1', |
||
| 55 | 'min' => '0', |
||
| 56 | ), |
||
| 57 | array( |
||
| 58 | 'id' => 'layout', |
||
| 59 | 'title' => __( 'Masonry Layout', 'foogallery' ), |
||
| 60 | 'desc' => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ), |
||
| 61 | 'section' => __( 'General', 'foogallery' ), |
||
| 62 | 'type' => 'radio', |
||
| 63 | 'choices' => array( |
||
| 64 | 'fixed' => __( 'Fixed Width', 'foogallery' ), |
||
| 65 | '2col' => __( '2 Columns', 'foogallery' ), |
||
| 66 | '3col' => __( '3 Columns', 'foogallery' ), |
||
| 67 | '4col' => __( '4 Columns', 'foogallery' ), |
||
| 68 | '5col' => __( '5 Columns', 'foogallery' ) |
||
| 69 | ), |
||
| 70 | 'default' => 'fixed', |
||
| 71 | 'row_data'=> array( |
||
| 72 | 'data-foogallery-change-selector' => 'input:radio', |
||
| 73 | 'data-foogallery-value-selector' s=> 'input:checked' |
||
| 74 | ) |
||
| 75 | ), |
||
| 76 | array( |
||
| 77 | 'id' => 'gutter_width', |
||
| 78 | 'title' => __( 'Gutter Width', 'foogallery' ), |
||
| 79 | 'desc' => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ), |
||
| 80 | 'section' => __( 'General', 'foogallery' ), |
||
| 81 | 'type' => 'number', |
||
| 82 | 'class' => 'small-text', |
||
| 83 | 'default' => 10, |
||
| 84 | 'step' => '1', |
||
| 85 | 'min' => '0', |
||
| 86 | 'row_data'=> array( |
||
| 87 | 'data-foogallery-hidden' => true, |
||
| 88 | 'data-foogallery-show-when-field' => 'layout', |
||
| 89 | 'data-foogallery-show-when-field-value' => 'fixed' |
||
| 90 | ) |
||
| 91 | ), |
||
| 92 | array( |
||
| 93 | 'id' => 'gutter_percent', |
||
| 94 | 'title' => __( 'Gutter Size', 'foogallery' ), |
||
| 95 | 'desc' => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ), |
||
| 96 | 'section' => __( 'General', 'foogallery' ), |
||
| 97 | 'type' => 'radio', |
||
| 98 | 'choices' => array( |
||
| 99 | 'no-gutter' => __( 'No Gutter', 'foogallery' ), |
||
| 100 | '' => __( 'Normal Size Gutter', 'foogallery' ), |
||
| 101 | 'large-gutter' => __( 'Larger Gutter', 'foogallery' ) |
||
| 102 | ), |
||
| 103 | 'default' => '', |
||
| 104 | 'row_data'=> array( |
||
| 105 | 'data-foogallery-hidden' => true, |
||
| 106 | 'data-foogallery-show-when-field' => 'layout', |
||
| 107 | 'data-foogallery-show-when-field-operator' => '!==', |
||
| 108 | 'data-foogallery-show-when-field-value' => 'fixed' |
||
| 109 | ) |
||
| 110 | ), |
||
| 111 | array( |
||
| 112 | 'id' => 'center_align', |
||
| 113 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 114 | 'desc' => __( 'You can choose to center align your images or leave them at the default (left). Only applicable when using a fixed layout!', 'foogallery' ), |
||
| 115 | 'section' => __( 'Look & Feel', 'foogallery' ), |
||
| 116 | 'type' => 'radio', |
||
| 117 | 'spacer' => '<span class="spacer"></span>', |
||
| 118 | 'choices' => array( |
||
| 119 | 'default' => __( 'Left', 'foogallery' ), |
||
| 120 | 'center' => __( 'Center', 'foogallery' ), |
||
| 121 | 'right' => __( 'Right', 'foogallery' ) |
||
| 122 | ), |
||
| 123 | 'default' => 'default' |
||
| 124 | ), |
||
| 125 | array( |
||
| 126 | 'id' => 'thumbnail_link', |
||
| 127 | 'title' => __( 'Thumb Link', 'foogallery' ), |
||
| 128 | 'default' => 'image' , |
||
| 129 | 'type' => 'thumb_link', |
||
| 130 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything', 'foogallery' ), |
||
| 131 | ), |
||
| 132 | array( |
||
| 133 | 'id' => 'lightbox', |
||
| 134 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 135 | 'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image"', 'foogallery' ), |
||
| 136 | 'type' => 'lightbox', |
||
| 137 | ), |
||
| 138 | ), |
||
| 139 | ); |
||
| 140 | |||
| 141 | |||
| 142 | return $gallery_templates; |
||
| 143 | } |
||
| 144 | |||
| 193 | } |
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.