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 — master ( 88f370...1732e9 )
by Brad
06:19
created

FooGallery_Autoptimize_Compatibility   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A set_to_show_admin_notice() 0 5 2
B admin_notice() 0 30 3
A admin_notice_dismiss() 0 5 2
1
<?php
2
/**
3
 * Class to help users who also use Autoptomize plugin
4
 * Date: 2017/11/12
5
 */
6
7
if ( !class_exists( 'FooGallery_Autoptimize_Compatibility' ) ) {
8
9
    class FooGallery_Autoptimize_Compatibility {
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...
10
11
        const transient_key = 'foogallery_autoptimize_notice';
12
13
        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...
14
            if ( is_admin() ) {
15
                add_action( 'admin_notices', array( $this, 'admin_notice' ) );
16
                add_action( 'foogallery_admin_new_version_detected', array( $this, 'set_to_show_admin_notice' ) );
17
18
                add_action( 'wp_ajax_foogallery_autoptimize_dismiss', array( $this, 'admin_notice_dismiss' ) );
19
            }
20
        }
21
22
        /**
23
         * Set the transient for 3 days to display the message to flush the cache
24
         */
25
        function set_to_show_admin_notice() {
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...
26
            if ( class_exists( 'autoptimizeCache' ) ) {
27
                set_transient(FooGallery_Autoptimize_Compatibility::transient_key, true, 3 * 24 * 60 * 60);
28
            }
29
        }
30
31
        /**
32
         * Display the admin notice
33
         */
34
        function admin_notice() {
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...
35
            if ( !class_exists( 'autoptimizeCache' ) ) return;
36
            $show_notice = get_transient( FooGallery_Autoptimize_Compatibility::transient_key );
37
            if ( false === $show_notice ) return;
38
            ?>
39
            <script type="text/javascript">
40
                ( function ( $ ) {
41
                    $( document ).ready( function () {
42
                        $( '.foogallery-autoptimize-notice.is-dismissible' )
43
                            .on( 'click', '.notice-dismiss', function ( e ) {
44
                                e.preventDefault();
45
                                $.post( ajaxurl, {
46
                                    action: 'foogallery_autoptimize_dismiss',
47
                                    url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
48
                                    _wpnonce: '<?php echo wp_create_nonce( 'foogallery_autoptimize_dismiss' ); ?>'
49
                                } );
50
                            } );
51
                    } );
52
                } )( jQuery );
53
            </script>
54
            <div class="foogallery-autoptimize-notice notice error is-dismissible">
55
                <p>
56
                    <strong><?php _e( 'FooGallery + Autoptimize : ', 'foobox-image-lightbox' ); ?></strong>
57
                    <?php _e( 'We noticed that you have the Autoptimize plugin installed. After updating FooGallery, please make sure you delete the Autoptimize cache from the admin bar above to make sure your galleries continue to display correctly.' ); ?>
58
                    <br />
59
                    <?php _e( 'If you continue to have issues using FooGallery and Autoptimize together, then please goto Autoptimize Plugin settings –> Java Script Options –> Exclude Scripts and add foogallery.min.js' ); ?>
60
                </p>
61
            </div>
62
            <?php
63
        }
64
65
        /**
66
         * Dismiss the admin notice
67
         */
68
        function admin_notice_dismiss() {
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...
69
            if ( check_admin_referer( 'foogallery_autoptimize_dismiss' ) ) {
70
                delete_transient( FooGallery_Autoptimize_Compatibility::transient_key );
71
            }
72
        }
73
    }
74
}