fooplugins /
foogallery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | if ( ! class_exists( 'FooGallery_Admin_Gallery_MetaBox_Fields' ) ) { |
||
| 4 | |||
| 5 | class FooGallery_Admin_Gallery_MetaBox_Fields { |
||
| 6 | |||
| 7 | function __construct() { |
||
|
0 ignored issues
–
show
|
|||
| 8 | //render the different types of fields for our gallery settings |
||
| 9 | add_action( 'foogallery_render_gallery_template_field', array( $this, 'render_gallery_template_field' ), 10, 3 ); |
||
| 10 | } |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Renders a gallery template field into the gallery settings metabox for a FooGallery |
||
| 14 | * |
||
| 15 | * @param array $field |
||
| 16 | * @param $gallery FooGallery |
||
| 17 | * @param $template |
||
| 18 | */ |
||
| 19 | function render_gallery_template_field( $field = array(), $gallery, $template ) { |
||
| 20 | $template_slug = $template['slug']; |
||
| 21 | |||
| 22 | //only declare up front so no debug warnings are shown |
||
| 23 | $type = $id = $desc = $default = $placeholder = $choices = $class = $spacer = $opactiy = null; |
||
| 24 | |||
| 25 | extract( $field ); |
||
| 26 | |||
| 27 | $id = $template_slug . '_' . $id; |
||
| 28 | |||
| 29 | $field['value'] = apply_filters( 'foogallery_render_gallery_template_field_value', $gallery->get_meta( $id, $default ), $field, $gallery, $template ); |
||
| 30 | |||
| 31 | $field_class = empty($class) ? '' : ' class="' . $class . '"'; |
||
| 32 | |||
| 33 | $field['choices'] = apply_filters( 'foogallery_render_gallery_template_field_choices', $choices, $field, $gallery ); |
||
| 34 | |||
| 35 | //allow for UI customization |
||
| 36 | do_action( 'foogallery_render_gallery_template_field_before', $field, $gallery ); |
||
| 37 | |||
| 38 | echo '<div class="foogallery_metabox_field-' . $type . '">'; |
||
| 39 | |||
| 40 | switch ( $type ) { |
||
| 41 | |||
| 42 | case 'html': |
||
| 43 | echo $desc; |
||
| 44 | $desc = ''; |
||
|
0 ignored issues
–
show
$desc is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 45 | break; |
||
| 46 | |||
| 47 | case 'checkbox': |
||
| 48 | if ( isset($gallery->settings[$id]) && $gallery->settings[$id] == 'on' ) { |
||
| 49 | $field['value'] = 'on'; |
||
| 50 | } else if ( ! isset($gallery->settings) && $default == 'on' ) { |
||
| 51 | $field['value'] = 'on'; |
||
| 52 | } else { |
||
| 53 | $field['value'] = ''; |
||
| 54 | } |
||
| 55 | |||
| 56 | $checked = 'on' === $field['value'] ? ' checked="checked"' : ''; |
||
| 57 | echo '<input' . $field_class . ' type="checkbox" id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" value="on"' . $checked . ' />'; |
||
| 58 | break; |
||
| 59 | |||
| 60 | case 'select': |
||
| 61 | echo '<select' . $field_class . ' id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']">'; |
||
| 62 | foreach ( $choices as $value => $label ) { |
||
|
0 ignored issues
–
show
|
|||
| 63 | $selected = ''; |
||
| 64 | if ( $field['value'] == $value ) { |
||
| 65 | $selected = ' selected="selected"'; |
||
| 66 | } |
||
| 67 | echo '<option ' . $selected . ' value="' . $value . '">' . $label . '</option>'; |
||
| 68 | } |
||
| 69 | |||
| 70 | echo '</select>'; |
||
| 71 | break; |
||
| 72 | |||
| 73 | case 'radio': |
||
| 74 | $i = 0; |
||
| 75 | $spacer = isset($spacer) ? $spacer : '<br />'; |
||
| 76 | foreach ( $choices as $value => $label ) { |
||
|
0 ignored issues
–
show
|
|||
| 77 | $selected = ''; |
||
| 78 | if ( $field['value'] == $value ) { |
||
| 79 | $selected = ' checked="checked"'; |
||
| 80 | } |
||
| 81 | echo '<input' . $field_class . $selected . ' type="radio" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" id="FooGallerySettings_' . $id . $i . '" value="' . $value . '"> <label for="FooGallerySettings_' . $id . $i . '">' . $label . '</label>'; |
||
| 82 | if ( $i < count( $choices ) - 1 ) { |
||
| 83 | echo $spacer; |
||
| 84 | } |
||
| 85 | $i++; |
||
| 86 | } |
||
| 87 | break; |
||
| 88 | |||
| 89 | case 'textarea': |
||
| 90 | echo '<textarea' . $field_class . ' id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" placeholder="' . $placeholder . '">' . esc_attr( $field['value'] ) . '</textarea>'; |
||
| 91 | |||
| 92 | break; |
||
| 93 | |||
| 94 | case 'text': |
||
| 95 | echo '<input' . $field_class . ' type="text" id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" value="' . esc_attr( $field['value'] ) . '" />'; |
||
| 96 | |||
| 97 | break; |
||
| 98 | |||
| 99 | case 'colorpicker': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 100 | |||
| 101 | $opacity_attribute = empty($opacity) ? '' : ' data-show-alpha="true"'; |
||
| 102 | |||
| 103 | echo '<input ' . $opacity_attribute . ' class="colorpicker" type="text" id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" value="' . esc_attr( $field['value'] ) . '" />'; |
||
| 104 | |||
| 105 | break; |
||
| 106 | |||
| 107 | case 'number': |
||
| 108 | $min = isset($min) ? $min : 0; |
||
| 109 | $step = isset($step) ? $step : 1; |
||
| 110 | echo '<input class="regular-text ' . $class . '" type="number" step="' . $step . '" min="' . $min .'" id="FooGallerySettings_' . $id . '" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . ']" placeholder="' . $placeholder . '" value="' . esc_attr( $field['value'] ) . '" />'; |
||
| 111 | |||
| 112 | break; |
||
| 113 | |||
| 114 | case 'checkboxlist': |
||
| 115 | $i = 0; |
||
| 116 | foreach ( $choices as $value => $label ) { |
||
| 117 | |||
| 118 | $checked = ''; |
||
| 119 | if ( isset($field['value'][$value]) && $field['value'][$value] == $value ) { |
||
| 120 | $checked = 'checked="checked"'; |
||
| 121 | } |
||
| 122 | |||
| 123 | echo '<input' . $field_class . ' ' . $checked . ' type="checkbox" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][' . $value . ']" id="FooGallerySettings_' . $id . $i . '" value="' . $value . '" data-value="' . $value . '"> <label for="FooGallerySettings_' . $id . $i . '">' . $label . '</label>'; |
||
| 124 | if ( $i < count( $choices ) - 1 ) { |
||
| 125 | echo '<br />'; |
||
| 126 | } |
||
| 127 | $i++; |
||
| 128 | } |
||
| 129 | |||
| 130 | break; |
||
| 131 | case 'icon': |
||
| 132 | $i = 0; |
||
| 133 | $input_name = FOOGALLERY_META_SETTINGS . '[' . $id . ']'; |
||
| 134 | $icon_html = ''; |
||
| 135 | foreach ( $choices as $value => $icon ) { |
||
| 136 | $selected = ( $field['value'] == $value ) ? ' checked="checked"' : ''; |
||
| 137 | $icon_html .= '<input style="display:none" name="' . $input_name. '" id="FooGallerySettings_' . $id . $i . '" ' . $selected . ' type="radio" value="' . $value . '" tabindex="' . $i . '"/>'; |
||
| 138 | $title = $icon['label']; |
||
| 139 | $img = $icon['img']; |
||
| 140 | $icon_html .= '<label for="FooGallerySettings_' . $id . $i . '" data-balloon-length="small" data-balloon-pos="down" data-balloon="' . $title . '"><img src="' . $img . '" /></label>'; |
||
| 141 | $i++; |
||
| 142 | } |
||
| 143 | echo $icon_html; |
||
| 144 | break; |
||
| 145 | |||
| 146 | case 'htmlicon': |
||
| 147 | $i = 0; |
||
| 148 | $input_name = FOOGALLERY_META_SETTINGS . '[' . $id . ']'; |
||
| 149 | $icon_html = ''; |
||
| 150 | foreach ( $choices as $value => $icon ) { |
||
|
0 ignored issues
–
show
|
|||
| 151 | $selected = ( $field['value'] == $value ) ? ' checked="checked"' : ''; |
||
| 152 | $icon_html .= '<input style="display:none" name="' . $input_name. '" id="FooGallerySettings_' . $id . $i . '" ' . $selected . ' type="radio" value="' . $value . '" tabindex="' . $i . '"/>'; |
||
| 153 | $title = $icon['label']; |
||
| 154 | $html = $icon['html']; |
||
| 155 | $icon_html .= '<label for="FooGallerySettings_' . $id . $i . '" data-balloon-length="small" data-balloon-pos="down" data-balloon="' . $title . '">' . $html . '</label>'; |
||
| 156 | $i++; |
||
| 157 | } |
||
| 158 | echo $icon_html; |
||
| 159 | break; |
||
| 160 | |||
| 161 | case 'thumb_size': |
||
| 162 | $width = is_array( $field['value'] ) ? $field['value']['width'] : 150; |
||
| 163 | $height = is_array( $field['value'] ) ? $field['value']['height'] : 150; |
||
| 164 | $crop = is_array( $field['value'] ) && array_key_exists( 'crop', $field['value'] ) ? $field['value']['crop'] : 0; |
||
| 165 | $crop_checked = ( $crop == 1 ) ? ' checked="checked"' : ''; |
||
| 166 | echo '<label for="FooGallerySettings_' . $id . '_width">' . __( 'Width', 'foogallery' ) . '</label>'; |
||
| 167 | echo '<input class="small-text" type="number" step="1" min="0" id="FooGallerySettings_' . $id . '_width" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][width]" value="' . esc_attr( $width ) . '" />'; |
||
| 168 | echo '<label for="FooGallerySettings_' . $id . '_width">' . __( 'Height', 'foogallery' ) . '</label>'; |
||
| 169 | echo '<input class="small-text" type="number" step="1" min="0" id="FooGallerySettings_' . $id . '_height" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][height]" value="' . esc_attr( $height ) . '" />'; |
||
| 170 | echo '<div class="foogallery-thumbsize-crop"><input name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][crop]" type="hidden" id="FooGallerySettings_' . $id . '_nocrop" value="0" />'; |
||
| 171 | echo '<input name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][crop]" type="checkbox" id="FooGallerySettings_' . $id . '_crop" value="1"' . $crop_checked . '>'; |
||
| 172 | echo '<label for="FooGallerySettings_' . $id . '_crop">' . __( 'Crop thumbnail to exact dimensions', 'foogallery' ) . '</label></div>'; |
||
| 173 | break; |
||
| 174 | |||
| 175 | case 'thumb_size_no_crop': |
||
| 176 | $width = is_array( $field['value'] ) ? $field['value']['width'] : 150; |
||
| 177 | $height = is_array( $field['value'] ) ? $field['value']['height'] : 150; |
||
| 178 | echo '<label for="FooGallerySettings_' . $id . '_width">' . __( 'Width', 'foogallery' ) . '</label>'; |
||
| 179 | echo '<input class="small-text" type="number" step="1" min="0" id="FooGallerySettings_' . $id . '_width" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][width]" value="' . esc_attr( $width ) . '" />'; |
||
| 180 | echo '<label for="FooGallerySettings_' . $id . '_width">' . __( 'Height', 'foogallery' ) . '</label>'; |
||
| 181 | echo '<input class="small-text" type="number" step="1" min="0" id="FooGallerySettings_' . $id . '_height" name="' . FOOGALLERY_META_SETTINGS . '[' . $id . '][height]" value="' . esc_attr( $height ) . '" />'; |
||
| 182 | break; |
||
| 183 | |||
| 184 | default: |
||
| 185 | do_action( 'foogallery_render_gallery_template_field_custom', $field, $gallery, $template ); |
||
| 186 | break; |
||
| 187 | } |
||
| 188 | |||
| 189 | if (!empty($suffix)) { |
||
| 190 | echo $suffix; |
||
| 191 | } |
||
| 192 | |||
| 193 | echo '</div>'; |
||
| 194 | |||
| 195 | //allow for more customization |
||
| 196 | do_action( 'foogallery_render_gallery_template_field_after', $field, $gallery ); |
||
| 197 | } |
||
| 198 | } |
||
| 199 | } |
||
| 200 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.