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-bulk-copy ( e0532f )
by Brad
02:52
created

FooGallery_Pro_Bulk_Copy::ajax_bulk_copy_start()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * FooGallery Pro Bulk Copy Class
4
 */
5
if ( ! class_exists( 'FooGallery_Pro_Bulk_Copy' ) ) {
6
7
    class FooGallery_Pro_Bulk_Copy
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...
8
    {
9
        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...
10
        {
11
            //add the bulk copy metabox
12
            add_action( 'add_meta_boxes_' . FOOGALLERY_CPT_GALLERY, array( $this, 'add_bulk_copy_meta_box_to_gallery' ) );
13
14
            // Ajax call for starting the bulk copy
15
            add_action( 'wp_ajax_foogallery_bulk_copy_start', array( $this, 'ajax_bulk_copy_start' ) );
16
17
            // Ajax call for running the bulk copy
18
            add_action( 'wp_ajax_foogallery_bulk_copy_run', array( $this, 'ajax_bulk_copy_run' ) );
19
        }
20
21
        public function ajax_bulk_copy_run()
0 ignored issues
show
Coding Style introduced by
ajax_bulk_copy_run uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
22
        {
23
            if (check_admin_referer('foogallery_bulk_copy_run', 'foogallery_bulk_copy_run_nonce')) {
24
                $data = $_POST['foogallery_bulk_copy'];
25
                $foogallery_id = $data['foogallery'];
26
                $errors = $settings = $galleries = array();
27
                $destination = false;
28
                if ( !array_key_exists( 'settings', $data ) ) {
29
                    $errors['settings'] = __('You need to decide which settings you want to copy across.', 'foogallery');
30
                } else {
31
                    $settings = $data['settings'];
32
                }
33
34
                if ( !isset( $data['destination'] ) ) {
35
                    $errors['destination'] = __('You need to choose the destination you want to copy to.', 'foogallery');
36
                } else {
37
                    $destination = $data['destination'];
38
                }
39
40
                if ( 'custom' === $destination ) {
41
                    if (!isset($data['gallery'])) {
42
                        $errors['gallery'] = __('You need to select which galleries you want to copy to.', 'foogallery');
43
                    } else {
44
                        $galleries = $data['gallery'];
45
                    }
46
                }
47
48
                if ( count($errors) ) {
49
                    $this->output_bulk_copy_form( $foogallery_id, $settings, $destination, $galleries, $errors );
50
                } else {
51
                    //if we get here, then we can perform a bulk copy!
52
                    $result = $this->run_bulk_copy( $foogallery_id, $settings, $destination, $galleries );
53
                    ?>
54
                    <div class="foogallery_bulk_copy_result"><?php echo $result; ?></div>
55
                    <button class="button button-primary button-large" id="foogallery_bulk_copy_start"><?php _e( 'Start Another Bulk Copy', 'foogallery' ); ?></button>
56
                    <?php wp_nonce_field( 'foogallery_bulk_copy_start', 'foogallery_bulk_copy_start_nonce', false ); ?>
57
                    <span class="foogallery_bulk_copy_spinner spinner"></span><?php
58
                }
59
            }
60
61
            die();
62
        }
63
64
        private function run_bulk_copy($foogallery_id, $settings = false, $destination = false, $galleries = array()) {
0 ignored issues
show
Unused Code introduced by
The parameter $settings is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
66
            $args = array(
67
                'post_type'     => FOOGALLERY_CPT_GALLERY,
68
                'post_status'	=> array( 'publish', 'draft' ),
69
                'cache_results' => false,
70
                'nopaging'      => true,
71
            );
72
73
            if ( 'all' === $destination ) {
74
                $exclude[] = intval($foogallery_id);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$exclude was never initialized. Although not strictly required by PHP, it is generally a good practice to add $exclude = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
75
                $args['post__not_in'] = $exclude;
76
            } else {
77
                $args['post__in'] = $galleries;
78
            }
79
80
            $gallery_posts = get_posts( $args );
81
82
            $gallery_template = get_post_meta( $foogallery_id, FOOGALLERY_META_TEMPLATE, true );
0 ignored issues
show
Unused Code introduced by
$gallery_template 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
83
            $settings = get_post_meta( $foogallery_id, FOOGALLERY_META_SETTINGS, true );
0 ignored issues
show
Unused Code introduced by
$settings 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
84
            $custom_css = get_post_meta( $foogallery_id, FOOGALLERY_META_CUSTOM_CSS, true );
0 ignored issues
show
Unused Code introduced by
$custom_css 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
85
            $sorting = get_post_meta( $foogallery_id, FOOGALLERY_META_SORT, true );
0 ignored issues
show
Unused Code introduced by
$sorting 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
86
            $retina = get_post_meta( $foogallery_id, FOOGALLERY_META_RETINA, true );
0 ignored issues
show
Unused Code introduced by
$retina 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
87
88
            $count = 0;
89
            foreach ( $gallery_posts as $post ) {
90
                $count++;
91
                //override the post meta for the gallery
92
            }
93
94
            return sprintf( __( 'Successfully copied settings to %d galleries.', 'foogallery' ), $count );
95
        }
96
97
        public function output_bulk_copy_form($foogallery_id, $settings = false, $destination = false, $galleries = array(), $errors = array()) {
98
            //check if we need to set some defaults
99
            if ( false === $settings ) {
100
                $settings[FOOGALLERY_META_TEMPLATE] = FOOGALLERY_META_TEMPLATE;
101
                $settings[FOOGALLERY_META_SETTINGS] = FOOGALLERY_META_SETTINGS;
102
                $settings[FOOGALLERY_META_RETINA] = FOOGALLERY_META_RETINA;
103
                $settings[FOOGALLERY_META_SORT] = FOOGALLERY_META_SORT;
104
                $settings[FOOGALLERY_META_CUSTOM_CSS] = FOOGALLERY_META_CUSTOM_CSS;
105
            }
106
            $exclude[] = intval($foogallery_id);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$exclude was never initialized. Although not strictly required by PHP, it is generally a good practice to add $exclude = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
107
            ?>
108
            <div class="foogallery-bulk-copy-settings">
109
                <table class="foogallery-metabox-settings">
110
                    <tr class="foogallery_template_field">
111
                        <th>
112
                            <label for="FooGallerySettings_default_lightbox"><?php _e('Which Settings?', 'foogallery'); ?></label>
113
                            <span data-balloon-length="large" data-balloon-pos="right" data-balloon="Choose which settings you wish to bulk copy to other galleries."><i class="dashicons dashicons-editor-help"></i></span>
114
                        </th>
115
                        <td>
116
                            <?php if ( array_key_exists( 'settings', $errors ) ) {?>
117
                                <div class="foogallery_bulk_copy_error"><?php echo $errors['settings']; ?></div>
118
                            <?php } ?>
119
                            <div class="foogallery_metabox_field-radio">
120
                                <input <?php echo (array_key_exists(FOOGALLERY_META_TEMPLATE, $settings) ? 'checked="checked"' : ''); ?> type="checkbox" name="foogallery_bulk_copy[settings][<?php echo FOOGALLERY_META_TEMPLATE; ?>]" id="FooGalleryBulkCopy_Settings_Template" value="<?php echo FOOGALLERY_META_TEMPLATE; ?>">
121
                                <label for="FooGalleryBulkCopy_Settings_Template"><?php _e('Gallery Template', 'foogallery'); ?></label><br>
122
123
                                <input <?php echo (array_key_exists(FOOGALLERY_META_SETTINGS, $settings) ? 'checked="checked"' : ''); ?> type="checkbox" name="foogallery_bulk_copy[settings][<?php echo FOOGALLERY_META_SETTINGS; ?>]" id="FooGalleryBulkCopy_Settings_Template" value="<?php echo FOOGALLERY_META_SETTINGS; ?>">
124
                                <label for="FooGalleryBulkCopy_Settings_Template"><?php _e('Template Settings', 'foogallery'); ?></label><br>
125
126
                                <input <?php echo (array_key_exists(FOOGALLERY_META_RETINA, $settings) ? 'checked="checked"' : ''); ?> type="checkbox" name="foogallery_bulk_copy[settings][<?php echo FOOGALLERY_META_RETINA; ?>]" id="FooGalleryBulkCopy_Settings_Retina" value="<?php echo FOOGALLERY_META_RETINA; ?>">
127
                                <label for="FooGalleryBulkCopy_Settings_Retina"><?php _e('Retina Settings', 'foogallery'); ?></label><br>
128
129
                                <input <?php echo (array_key_exists(FOOGALLERY_META_SORT, $settings) ? 'checked="checked"' : ''); ?> type="checkbox" name="foogallery_bulk_copy[settings][<?php echo FOOGALLERY_META_SORT; ?>]" id="FooGalleryBulkCopy_Settings_Sorting" value="<?php echo FOOGALLERY_META_SORT; ?>">
130
                                <label for="FooGalleryBulkCopy_Settings_Sorting"><?php _e('Sorting Settings', 'foogallery'); ?></label><br>
131
132
                                <input <?php echo (array_key_exists(FOOGALLERY_META_CUSTOM_CSS, $settings) ? 'checked="checked"' : ''); ?> type="checkbox" name="foogallery_bulk_copy[settings][<?php echo FOOGALLERY_META_CUSTOM_CSS; ?>]" id="FooGalleryBulkCopy_Settings_CustomCSS" value="<?php echo FOOGALLERY_META_CUSTOM_CSS; ?>">
133
                                <label for="FooGalleryBulkCopy_Settings_CustomCSS"><?php _e('Custom CSS', 'foogallery'); ?></label>
134
                            </div>
135
                        </td>
136
                    </tr>
137
                    <tr class="foogallery_template_field">
138
                        <th>
139
                            <label for="FooGallerySettings_default_lightbox"><?php _e('Destination', 'foogallery'); ?></label>
140
                            <span data-balloon-length="large" data-balloon-pos="right" data-balloon="Choose which galleries you want to copy the settings to."><i class="dashicons dashicons-editor-help"></i></span>
141
                        </th>
142
                        <td>
143
                            <?php if ( array_key_exists( 'destination', $errors ) ) {?>
144
                                <div class="foogallery_bulk_copy_error"><?php echo $errors['destination']; ?></div>
145
                            <?php } ?>
146
                            <div class="foogallery_metabox_field-radio">
147
                                <input <?php echo ('all' === $destination ? 'checked="checked"' : ''); ?> type="radio" name="foogallery_bulk_copy[destination]" id="FooGalleryBulkCopy_Destination_All" value="all">
148
                                <label for="FooGalleryBulkCopy_Destination_All"><?php _e('All Galleries', 'foogallery'); ?></label><br>
149
150
                                <input <?php echo ('custom' === $destination ? 'checked="checked"' : ''); ?> type="radio" name="foogallery_bulk_copy[destination]" id="FooGalleryBulkCopy_Destination_Custom" value="custom">
151
                                <label for="FooGalleryBulkCopy_Destination_Custom"><?php _e('Custom Selection', 'foogallery'); ?></label><br>
152
                            </div>
153
                        </td>
154
                    </tr>
155
                    <tr class="foogallery_template_field">
156
                        <th>
157
                            <label for="FooGallerySettings_default_lightbox"><?php _e('Select the galleries', 'foogallery'); ?></label>
158
                        </th>
159
                        <td>
160
                            <?php if ( array_key_exists( 'gallery', $errors ) ) {?><div class="foogallery_bulk_copy_error"><?php echo $errors['gallery']; ?></div><?php } ?>
161
                            <div class="foogallery_metabox_field-radio bulk_copy_custom">
162
                                <?php foreach ( foogallery_get_all_galleries($exclude) as $foogallery ) {
0 ignored issues
show
Documentation introduced by
$exclude is of type array<integer,integer>, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
163
                                    $checked = array_key_exists( $foogallery->ID, $galleries ) ? 'checked="checked"' : '';
164
                                    ?><div class="foogallery_bulk_copy_custom_selection">
165
                                    <input <?php echo $checked; ?> type="checkbox" name="foogallery_bulk_copy[gallery][<?php echo $foogallery->ID; ?>]" id="FooGalleryBulkCopy_Custom_<?php echo $foogallery->ID; ?>" value="<?php echo $foogallery->ID; ?>">
166
                                    <label for="FooGalleryBulkCopy_Custom_<?php echo $foogallery->ID; ?>"><?php echo $foogallery->name . ' [' . $foogallery->ID . ']'; ?></label>
167
                                    </div>
168
                                <?php } ?>
169
                            </div>
170
                        </td>
171
                    </tr>
172
                </table>
173
                <p>
174
                    <input type="hidden" name="foogallery_bulk_copy[foogallery]" value="<?php echo $foogallery_id; ?>" />
175
                    <button class="button button-primary button-large" id="foogallery_bulk_copy_run"><?php _e( 'Run Bulk Copy', 'foogallery' ); ?></button>
176
                    <span class="foogallery_bulk_copy_spinner spinner"></span>
177
                    <?php if ( count ($errors) > 0 ) { ?>
178
                        <br />
179
                        <div class="foogallery_bulk_copy_error"><?php _e('The bulk copy could not be run, due to errors. Please see above and correct the errors before continuing.', 'foogallery'); ?></div>
180
                    <?php } ?>
181
                    <?php wp_nonce_field( 'foogallery_bulk_copy_run', 'foogallery_bulk_copy_run_nonce', false ); ?>
182
                </p>
183
            </div>
184
            <?php
185
        }
186
187
        public function ajax_bulk_copy_start()
0 ignored issues
show
Coding Style introduced by
ajax_bulk_copy_start uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
188
        {
189
            if (check_admin_referer('foogallery_bulk_copy_start', 'foogallery_bulk_copy_start_nonce')) {
190
                $foogallery_id = $_POST['foogallery'];
191
                $this->output_bulk_copy_form( $foogallery_id );
192
            }
193
194
            die();
195
        }
196
197
        /**
198
         * Add a metabox to the gallery for bulk copying
199
         * @param $post
200
         */
201
        function add_bulk_copy_meta_box_to_gallery($post) {
0 ignored issues
show
Unused Code introduced by
The parameter $post is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
202
            add_meta_box(
203
                'foogallery_bulk_copy',
204
                __( 'Bulk Copy', 'foogallery' ),
205
                array( $this, 'render_gallery_bulk_copy_metabox' ),
206
                FOOGALLERY_CPT_GALLERY,
207
                'normal',
208
                'low'
209
            );
210
        }
211
212
        /**
213
         * Render the bulk copy metabox on the gallery edit page
214
         * @param $post
215
         */
216
        function render_gallery_bulk_copy_metabox( $post ) {
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...
217
            ?>
218
            <style type="text/css">
219
                .foogallery_bulk_copy_custom_selection {
220
                    display: inline-block;
221
                    width: 40%;
222
                    margin-bottom:5px;
223
                }
224
225
                .foogallery_bulk_copy_custom_selection label {
226
                    vertical-align: top;
227
                }
228
229
                .foogallery_bulk_copy_error {
230
                    position: relative;
231
                    line-height: 16px;
232
                    padding: 6px 5px;
233
                    font-size: 14px;
234
                    text-align: left;
235
                    margin-bottom: 5px;
236
                    background-color: #FFe4e4;
237
                    border-left: 4px solid #be392f;
238
                    -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
239
                    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
240
                }
241
242
                .foogallery_bulk_copy_spinner {
243
                    float: none !important;
244
                }
245
246
                .foogallery_bulk_copy_result {
247
                    position: relative;
248
                    line-height: 16px;
249
                    padding: 6px 5px;
250
                    font-size: 14px;
251
                    text-align: left;
252
                    margin-top: 5px;
253
                    margin-bottom: 5px;
254
                    background-color: #e4ffe4;
255
                    border-left: 4px solid #1bbe33;
256
                    -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
257
                    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
258
                }
259
            </style>
260
            <script type="text/javascript">
261
                jQuery(function ($) {
262
                    $('#foogallery_bulk_copy_container').on('click', '#foogallery_bulk_copy_start', function(e) {
263
                        e.preventDefault();
264
265
                        $('.foogallery_bulk_copy_spinner').addClass('is-active');
266
                        var data = 'action=foogallery_bulk_copy_start' +
267
                            '&foogallery=<?php echo $post->ID; ?>' +
268
                            '&foogallery_bulk_copy_start_nonce=' + $('#foogallery_bulk_copy_start_nonce').val() +
269
                            '&_wp_http_referer=' + encodeURIComponent($('input[name="_wp_http_referer"]').val());
270
271
                        $.ajax({
272
                            type: "POST",
273
                            url: ajaxurl,
274
                            data: data,
275
                            success: function(data) {
276
                                $('#foogallery_bulk_copy_container').html(data);
277
                                $('.foogallery_bulk_copy_spinner').removeClass('is-active');
278
                            }
279
                        });
280
                    });
281
282
                    $('#foogallery_bulk_copy_container').on('click', '#foogallery_bulk_copy_run', function(e) {
283
                        e.preventDefault();
284
285
                        $('.foogallery_bulk_copy_spinner').addClass('is-active');
286
                        var data = $('.foogallery-bulk-copy-settings').find('select, textarea, input').serialize() +
287
                            '&action=foogallery_bulk_copy_run' +
288
                            '&foogallery_bulk_copy_run_nonce=' + $('#foogallery_bulk_copy_run_nonce').val() +
289
                            '&_wp_http_referer=' + encodeURIComponent($('input[name="_wp_http_referer"]').val());
290
291
                        $.ajax({
292
                            type: "POST",
293
                            url: ajaxurl,
294
                            data: data,
295
                            success: function(data) {
296
                                $('#foogallery_bulk_copy_container').html(data);
297
                                $('.foogallery_bulk_copy_spinner').removeClass('is-active');
298
                            }
299
                        });
300
                    });
301
                });
302
            </script>
303
            <div>
304
                <p class="foogallery-help"><?php _e('You can bulk copy the settings from this gallery to other galleries in a few easy steps. To get started, click the button below. Please be sure to save your gallery before you start the copy, as only the saved settings stored in the database will be copied across.', 'foogallery'); ?></p>
305
            </div>
306
            <br/>
307
            <div id="foogallery_bulk_copy_container">
308
                <button class="button button-primary button-large" id="foogallery_bulk_copy_start"><?php _e( 'Start Bulk Copy', 'foogallery' ); ?></button>
309
                <?php wp_nonce_field( 'foogallery_bulk_copy_start', 'foogallery_bulk_copy_start_nonce', false ); ?>
310
                <span class="foogallery_bulk_copy_spinner spinner"></span>
311
            </div>
312
            <?php
313
        }
314
    }
315
}