GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — feature/gallery-template-clien... ( a5e10a...a6b5cf )
by Brad
02:25
created

FooGallery_Admin_Gallery_MetaBox_Settings   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 178
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 178
rs 10
c 0
b 0
f 0
wmc 11
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A enqueue_assets() 0 13 4
B add_section_icons() 0 16 5
B add_gallery_template_common_thumbnail_fields() 0 117 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: bradvin
5
 * Date: 2017/04/19
6
 * Time: 1:19 PM
7
 */
8
9
10
if ( ! class_exists( 'FooGallery_Admin_Gallery_MetaBox_Settings' ) ) {
11
12
    class FooGallery_Admin_Gallery_MetaBox_Settings {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
14
        /**
15
         * FooGallery_Admin_Gallery_MetaBox_Settings constructor.
16
         */
17
        function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
            //enqueue assets for the new settings tabs
19
            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
20
21
            //set default settings tab icons
22
            add_filter( 'foogallery_gallery_settings_metabox_section_icon', array( $this, 'add_section_icons') );
23
24
            add_filter( 'foogallery_gallery_template_common_thumbnail_fields', array( $this, 'add_gallery_template_common_thumbnail_fields' ) );
25
        }
26
27
        /***
28
         * Enqueue the assets needed by the settings
29
         * @param $hook_suffix
30
         */
31
        function enqueue_assets( $hook_suffix ){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
            if( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) {
33
                $screen = get_current_screen();
34
35
                if ( is_object( $screen ) && FOOGALLERY_CPT_GALLERY == $screen->post_type ){
36
37
                    // Register, enqueue scripts and styles here
38
                    wp_enqueue_script( 'foogallery-admin-settings', FOOGALLERY_URL . '/js/foogallery.admin.min.js', FOOGALLERY_VERSION, 'jquery' );
39
40
                    wp_enqueue_style( 'foogallery-admin-settings', FOOGALLERY_URL . '/css/foogallery.admin.min.css', FOOGALLERY_VERSION );
41
                }
42
            }
43
        }
44
45
        /**
46
         * Returns the Dashicon that can be used in the settings tabs
47
         * @param $section_slug
48
         * @return string
49
         */
50
        function add_section_icons( $section_slug ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
            switch ( $section_slug ) {
52
                case 'general':
53
                    return 'dashicons-admin-tools';
54
                    break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
55
                case 'advanced':
56
                    return 'dashicons-admin-generic';
57
                    break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
58
                case 'look &amp; feel':
59
                    return 'dashicons-images-alt2';
60
                    break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
61
                case 'video':
62
                    return 'dashicons-format-video';
63
            }
64
            return 'dashicons-admin-tools';
65
        }
66
67
        /**
68
         * Add common thumbnail fields to a gallery template
69
         *
70
         * @return array
71
         */
72
        function add_gallery_template_common_thumbnail_fields( $fields ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
73
74
            $border_style_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_border_style_choices',  array(
75
                'border-style-square-white' => array( 'label' => __( 'Square white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-white.png' ),
76
                'border-style-circle-white' => array( 'label' => __( 'Circular white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-white.png' ),
77
                'border-style-square-black' => array( 'label' => __( 'Square Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-black.png' ),
78
                'border-style-circle-black' => array( 'label' => __( 'Circular Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-black.png' ),
79
                'border-style-inset' => array( 'label' => __( 'Square Inset' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-inset.png' ),
80
                'border-style-rounded' => array( 'label' => __( 'Plain Rounded' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-plain-rounded.png' ),
81
                '' => array( 'label' => __( 'Plain' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-none.png' ),
82
            ) );
83
            $fields[] = array(
84
                'id'      => 'border-style',
85
                'title'   => __( 'Border Style', 'foogallery' ),
86
                'desc'    => __( 'The border style applied to each thumbnail', 'foogallery' ),
87
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
88
                'type'    => 'icon',
89
                'default' => 'border-style-square-white',
90
                'choices' => $border_style_choices
91
            );
92
93
            $fields[] = array(
94
                'id'      => 'hover-effect-help',
95
                'title'   => __( 'Hover Effect Help', 'foogallery' ),
96
                'desc'    => __( 'Captions can be enabled by choosing the "Caption" hover effect below.', 'foogallery' ),
97
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
98
                'type'    => 'help'
99
            );
100
101
            $hover_effect_type_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_type_choices', array(
102
                ''  => __( 'Icon', 'foogallery' ),
103
                'hover-effect-tint'   => __( 'Dark Tint', 'foogallery' ),
104
                'hover-effect-color' => __( 'Colorize', 'foogallery' ),
105
                'hover-effect-caption' => __( 'Caption', 'foogallery' ),
106
                'hover-effect-scale' => __( 'Scale', 'foogallery' ),
107
                'hover-effect-none' => __( 'None', 'foogallery' )
108
            ) );
109
            $fields[] = array(
110
                'id'      => 'hover-effect-type',
111
                'title'   => __( 'Hover Effect', 'foogallery' ),
112
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
113
                'default' => '',
114
                'type'    => 'radio',
115
                'choices' => $hover_effect_type_choices,
116
                'desc'	  => __( 'Choose what will happen when you hover over a thumbnail', 'foogallery' ),
117
                'row_data'=> array(
118
                    'data-foogallery-value-selector' => 'input:checked'
119
                )
120
            );
121
122
            $hover_effect_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_choices', array(
123
                'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ),
124
                'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ),
125
                'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ),
126
                'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ),
127
                'hover-effect-circle-plus' => array( 'label' => __( 'Cirlce Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ),
128
                'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' )
129
            ) );
130
            $fields[] = array(
131
                'id'      => 'hover-effect',
132
                'title'   => __( 'Hover Icon', 'foogallery' ),
133
                'desc'    => __( 'Choose which icon is shown when you hover over a thumbnail', 'foogallery' ),
134
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
135
                'type'    => 'icon',
136
                'default' => 'hover-effect-zoom',
137
                'choices' => $hover_effect_choices,
138
                'row_data'=> array(
139
                    'data-foogallery-hidden' => true,
140
                    'data-foogallery-show-when-field' => 'hover-effect-type',
141
                    'data-foogallery-show-when-field-value' => ''
142
                )
143
            );
144
145
            $caption_hover_effect_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_hover_effect_choices', array(
146
                'hover-caption-simple'  => __( 'Simple', 'foogallery' ),
147
                'hover-caption-full-drop'   => __( 'Drop', 'foogallery' ),
148
                'hover-caption-full-fade' => __( 'Fade In', 'foogallery' ),
149
                'hover-caption-push' => __( 'Push', 'foogallery' ),
150
                'hover-caption-simple-always' => __( 'Always Visible', 'foogallery' )
151
            ) );
152
            $fields[] = array(
153
                'id'      => 'caption-hover-effect',
154
                'title'   => __( 'Caption Type', 'foogallery' ),
155
                'desc'    => __( 'Choose what the captions will look like and how they will work', 'foogallery' ),
156
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
157
                'default' => 'hover-caption-simple',
158
                'type'    => 'radio',
159
                'choices' => $caption_hover_effect_choices,
160
                'row_data'=> array(
161
                    'data-foogallery-hidden' => true,
162
                    'data-foogallery-show-when-field' => 'hover-effect-type',
163
                    'data-foogallery-show-when-field-value' => 'hover-effect-caption'
164
                )
165
            );
166
167
            $caption_content_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_content_choices', array(
168
                'title'  => __( 'Title Only', 'foogallery' ),
169
                'desc'   => __( 'Description Only', 'foogallery' ),
170
                'both' => __( 'Title and Description', 'foogallery' )
171
            ) );
172
            $fields[] = array(
173
                'id'      => 'caption-content',
174
                'title'   => __( 'Caption Content', 'foogallery' ),
175
                'desc'    => __( 'Choose what is used for your caption content', 'foogallery' ),
176
                'section' => __( 'Look &amp; Feel', 'foogallery' ),
177
                'default' => 'title',
178
                'type'    => 'radio',
179
                'choices' => $caption_content_choices,
180
                'row_data'=> array(
181
                    'data-foogallery-hidden' => true,
182
                    'data-foogallery-show-when-field' => 'hover-effect-type',
183
                    'data-foogallery-show-when-field-value' => 'hover-effect-caption'
184
                )
185
            );
186
187
            return $fields;
188
        }
189
    }
190
}