| Conditions | 1 |
| Paths | 1 |
| Total Lines | 116 |
| 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 |
||
| 48 | function add_template( $gallery_templates ) { |
||
| 49 | $gallery_templates[] = array( |
||
| 50 | 'slug' => 'justified', |
||
| 51 | 'name' => __( 'Justified Gallery', 'foogallery' ), |
||
| 52 | 'preview_support' => true, |
||
| 53 | 'common_fields_support' => true, |
||
| 54 | 'lazyload_support' => true, |
||
| 55 | 'paging_support' => true, |
||
| 56 | 'mandatory_classes' => 'fg-justified', |
||
| 57 | 'thumbnail_dimensions' => true, |
||
| 58 | 'filtering_support' => true, |
||
| 59 | 'fields' => array( |
||
| 60 | array( |
||
| 61 | 'id' => 'thumb_height', |
||
| 62 | 'title' => __( 'Thumb Height', 'foogallery' ), |
||
| 63 | 'desc' => __( 'Choose the height of your thumbnails. Thumbnails will be generated on the fly and cached once generated', 'foogallery' ), |
||
| 64 | 'section' => __( 'General', 'foogallery' ), |
||
| 65 | 'type' => 'number', |
||
| 66 | 'class' => 'small-text', |
||
| 67 | 'default' => 250, |
||
| 68 | 'step' => '10', |
||
| 69 | 'min' => '0', |
||
| 70 | 'row_data'=> array( |
||
| 71 | 'data-foogallery-preview' => 'shortcode', |
||
| 72 | 'data-foogallery-change-selector' => 'input', |
||
| 73 | ) |
||
| 74 | ), |
||
| 75 | array( |
||
| 76 | 'id' => 'row_height', |
||
| 77 | 'title' => __( 'Row Height', 'foogallery' ), |
||
| 78 | 'desc' => __( 'The preferred height of your gallery rows. This can be different from the thumbnail height', 'foogallery' ), |
||
| 79 | 'section' => __( 'General', 'foogallery' ), |
||
| 80 | 'type' => 'number', |
||
| 81 | 'class' => 'small-text', |
||
| 82 | 'default' => 150, |
||
| 83 | 'step' => '10', |
||
| 84 | 'min' => '0', |
||
| 85 | 'row_data'=> array( |
||
| 86 | 'data-foogallery-change-selector' => 'input', |
||
| 87 | 'data-foogallery-value-selector' => 'input', |
||
| 88 | 'data-foogallery-preview' => 'shortcode', |
||
| 89 | ) |
||
| 90 | ), |
||
| 91 | array( |
||
| 92 | 'id' => 'max_row_height', |
||
| 93 | 'title' => __( 'Max Row Height', 'foogallery' ), |
||
| 94 | 'desc' => __( 'A number (e.g 200) which specifies the maximum row height in pixels. A negative value for no limits. Alternatively, use a percentage (e.g. 200% which means that the row height cannot exceed 2 * rowHeight)', 'foogallery' ), |
||
| 95 | 'section' => __( 'General', 'foogallery' ), |
||
| 96 | 'type' => 'text', |
||
| 97 | 'class' => 'small-text', |
||
| 98 | 'default' => '200%', |
||
| 99 | 'row_data'=> array( |
||
| 100 | 'data-foogallery-change-selector' => 'input', |
||
| 101 | 'data-foogallery-value-selector' => 'input', |
||
| 102 | 'data-foogallery-preview' => 'shortcode', |
||
| 103 | ) |
||
| 104 | ), |
||
| 105 | array( |
||
| 106 | 'id' => 'margins', |
||
| 107 | 'title' => __( 'Margins', 'foogallery' ), |
||
| 108 | 'desc' => __( 'The spacing between your thumbnails.', 'foogallery' ), |
||
| 109 | 'section' => __( 'General', 'foogallery' ), |
||
| 110 | 'type' => 'number', |
||
| 111 | 'class' => 'small-text', |
||
| 112 | 'default' => 1, |
||
| 113 | 'step' => '1', |
||
| 114 | 'min' => '0', |
||
| 115 | 'row_data'=> array( |
||
| 116 | 'data-foogallery-change-selector' => 'input', |
||
| 117 | 'data-foogallery-value-selector' => 'input', |
||
| 118 | 'data-foogallery-preview' => 'shortcode', |
||
| 119 | ) |
||
| 120 | ), |
||
| 121 | array( |
||
| 122 | 'id' => 'thumbnail_link', |
||
| 123 | 'title' => __( 'Thumbnail Link', 'foogallery' ), |
||
| 124 | 'section' => __( 'General', 'foogallery' ), |
||
| 125 | 'default' => 'image' , |
||
| 126 | 'type' => 'thumb_link', |
||
| 127 | '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' ), |
||
| 128 | ), |
||
| 129 | array( |
||
| 130 | 'id' => 'lightbox', |
||
| 131 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 132 | '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' ), |
||
| 133 | 'section' => __( 'General', 'foogallery' ), |
||
| 134 | 'default' => 'none', |
||
| 135 | 'type' => 'lightbox', |
||
| 136 | ), |
||
| 137 | array( |
||
| 138 | 'id' => 'lastrow', |
||
| 139 | 'title' => __( 'Last Row', 'foogallery' ), |
||
| 140 | 'desc' => __( 'What should be done with the last row in the gallery?', 'foogallery' ), |
||
| 141 | 'section' => __( 'General', 'foogallery' ), |
||
| 142 | 'type' => 'radio', |
||
| 143 | 'spacer' => '<span class="spacer"></span>', |
||
| 144 | 'default' => 'center', |
||
| 145 | 'choices' => array( |
||
| 146 | 'hide' => __( 'Hide', 'foogallery' ), |
||
| 147 | 'justify' => __( 'Justify', 'foogallery' ), |
||
| 148 | 'nojustify' => __( 'No Justify', 'foogallery' ), |
||
| 149 | 'right' => __( 'Right', 'foogallery' ), |
||
| 150 | 'center' => __( 'Center', 'foogallery' ), |
||
| 151 | 'left' => __( 'Left', 'foogallery' ), |
||
| 152 | ), |
||
| 153 | 'row_data'=> array( |
||
| 154 | 'data-foogallery-change-selector' => 'input:radio', |
||
| 155 | 'data-foogallery-value-selector' => 'input:checked', |
||
| 156 | 'data-foogallery-preview' => 'shortcode', |
||
| 157 | ) |
||
| 158 | ), |
||
| 159 | ), |
||
| 160 | ); |
||
| 161 | |||
| 162 | return $gallery_templates; |
||
| 163 | } |
||
| 164 | |||
| 272 | } |
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.