PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
← All changes | includes/admin/pages/badge-builder.php +920 -0 7.9.2 → 8.0.5 View file →
@@ -1,0 +1,920 @@
1 +<?php
2 +/**
3 + * Badge Builder Page
4 + *
5 + * @package GamiPress\Admin\Badge_Builder
6 + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.0.0
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Badge Builder page
14 + *
15 + * @since 1.0.0
16 + *
17 + * @return void
18 + */
19 +function gamipress_badge_builder_page() {
20 +
21 + $icons = gamipress_badge_builder_get_icons();
22 +
23 + $title = esc_html__( 'GamiPress Badge Builder', 'gamipress' );
24 +
25 + $title = str_replace( 'GamiPress', '<span>GamiPress</span>', $title );
26 +
27 + /**
28 + * Badge Builder page title
29 + *
30 + * @since 7.0.0
31 + *
32 + * @param string $title
33 + *
34 + * @return string $title
35 + */
36 + $title = apply_filters( 'gamipress_badge_builder_page_title', $title );
37 +
38 + ?>
39 +
40 + <div class="wrap gamipress-badge-builder">
41 +
42 + <div class="gamipress-badge-builder-top">
43 + <?php // Logo ?>
44 + <div class="gamipress-logo">
45 + <h1 class="wp-heading-inline"><?php echo gamipress_dashicon( 'gamipress' ) . $title; ?></h1>
46 + </div>
47 +
48 + <div class="gamipress-badge-builder-top-filename">
49 + <input type="text" id="filename" value="" placeholder="<?php echo esc_attr( __( 'Enter badge name here...', 'gamipress' ) ); ?>">
50 + </div>
51 +
52 + <?php
53 +
54 + $import_actions = array(
55 + 'upload-gpb' => array(
56 + 'name' => __( 'Upload Badge', 'gamipress' ),
57 + 'desc' => __( 'Upload a GPB file', 'gamipress' ),
58 + 'accept' => '.gpb',
59 + ),
60 + );
61 +
62 + /**
63 + * Badge Builder import actions
64 + *
65 + * @since 7.0.0
66 + *
67 + * @param array $import_actions
68 + *
69 + * @return array $import_actions
70 + */
71 + $import_actions = apply_filters( 'gamipress_badge_builder_import_actions', $import_actions );
72 +
73 + ?>
74 +
75 + <div class="gamipress-badge-builder-top-actions">
76 + <button class="button gamipress-badge-builder-action gamipress-badge-builder-action-upload">
77 + <?php esc_html_e( 'Upload', 'gamipress' ); ?>
78 + <ul class="gamipress-badge-builder-action-dropdown gamipress-badge-builder-action-upload-dropdown">
79 + <?php foreach( $import_actions as $action_id => $action ) : ?>
80 + <li class="gamipress-badge-builder-<?php echo esc_attr( $action_id ); ?>">
81 + <strong><?php echo esc_html( $action['name'] ); ?></strong>
82 + <span><?php echo esc_html( $action['desc'] ); ?></span>
83 + <input type="file" accept="<?php echo esc_attr( $action['accept'] ); ?>" id="gamipress-badge-builder-<?php echo esc_attr( $action_id ); ?>-input">
84 + </li>
85 + <?php endforeach; ?>
86 + </ul>
87 + </button>
88 +
89 + <?php
90 +
91 + $export_actions = array(
92 + 'save-gpb' => array(
93 + 'name' => __( 'Download Badge', 'gamipress' ),
94 + 'desc' => __( 'Download as GPB', 'gamipress' ),
95 + ),
96 + 'save-png' => array(
97 + 'name' => __( 'Download as PNG', 'gamipress' ),
98 + 'desc' => __( 'To upload to WordPress', 'gamipress' ),
99 + ),
100 + );
101 +
102 + /**
103 + * Badge Builder export actions
104 + *
105 + * @since 7.0.0
106 + *
107 + * @param array $export_actions
108 + *
109 + * @return array $export_actions
110 + */
111 + $export_actions = apply_filters( 'gamipress_badge_builder_export_actions', $export_actions );
112 +
113 + ?>
114 +
115 + <button class="button button-primary gamipress-badge-builder-action gamipress-badge-builder-action-save">
116 + <?php esc_html_e( 'Download', 'gamipress' ); ?>
117 + <ul class="gamipress-badge-builder-action-dropdown gamipress-badge-builder-action-save-dropdown">
118 + <?php foreach( $export_actions as $action_id => $action ) : ?>
119 + <li class="gamipress-badge-builder-<?php echo esc_attr( $action_id ); ?>">
120 + <strong><?php echo esc_html( $action['name'] ); ?></strong>
121 + <span><?php echo esc_html( $action['desc'] ); ?></span>
122 + </li>
123 + <?php endforeach; ?>
124 + </ul>
125 + </button>
126 + </div>
127 + </div>
128 +
129 + <div class="gamipress-badge-builder-toolbar">
130 +
131 + <?php
132 +
133 + $tools = array(
134 + 'add-icon' => array(
135 + 'name' => __( 'Add Shape', 'gamipress' ),
136 + 'icon' => 'insert',
137 + ),
138 + 'open-generate-badge' => array(
139 + 'name' => __( 'Generate Badge', 'gamipress' ),
140 + 'icon' => 'awards',
141 + ),
142 + 'open-generate-multiple' => array(
143 + 'name' => __( 'Generate Multiple', 'gamipress' ),
144 + 'icon' => 'awards',
145 + ),
146 + );
147 +
148 + /**
149 + * Badge Builder toolbar tools
150 + *
151 + * @since 7.0.0
152 + *
153 + * @param array $tools
154 + *
155 + * @return array $tools
156 + */
157 + $tools = apply_filters( 'gamipress_badge_builder_toolbar_tools', $tools );
158 +
159 + ?>
160 +
161 + <?php foreach( $tools as $tool_id => $tool ) : ?>
162 + <span class="gamipress-badge-builder-toolbar-control" data-action="<?php echo esc_attr( $tool_id ); ?>">
163 + <?php echo gamipress_dashicon( $tool['icon'] ); ?> <?php echo esc_html( $tool['name'] ); ?>
164 + </span>
165 + <?php endforeach; ?>
166 +
167 + </div>
168 +
169 + <div class="gamipress-badge-builder-view">
170 + <canvas id="gamipress-badge-builder-canvas" width="600" height="600"></canvas>
171 + </div>
172 +
173 + <div class="gamipress-badge-builder-view-backup">
174 + <canvas id="gamipress-badge-builder-canvas-backup" width="600" height="600"></canvas>
175 + </div>
176 +
177 + <div class="gamipress-badge-builder-generate-multiple-view">
178 + <?php for( $i = 0; $i < 15; $i++ ) : ?>
179 + <div class="gamipress-badge-builder-preview" data-index="<?php echo esc_attr( $i ); ?>">
180 + <canvas id="gamipress-badge-builder-preview-canvas-<?php echo esc_attr( $i ); ?>" width="150" height="150"></canvas>
181 + <div class="gamipress-badge-builder-preview-actions">
182 + <span class="gamipress-badge-builder-preview-action cmb-tooltip">
183 + <?php echo gamipress_dashicon( 'info-outline' ); ?>
184 + <span class="cmb-tooltip-desc cmb-tooltip-top">
185 + <?php esc_html_e( 'Palette', 'gamipress' ); ?>: <span class="gamipress-badge-builder-preview-palette-name"></span>
186 + </span>
187 + </span>
188 + <span class="gamipress-badge-builder-preview-action cmb-tooltip" data-action="generate-multiple-edit">
189 + <?php echo gamipress_dashicon( 'edit' ); ?>
190 + <span class="cmb-tooltip-desc cmb-tooltip-top">
191 + <?php esc_html_e( 'Edit', 'gamipress' ); ?>
192 + </span>
193 + </span>
194 + <span class="gamipress-badge-builder-preview-action gamipress-badge-builder-preview-save-action cmb-tooltip">
195 + <?php echo gamipress_dashicon( 'download' ); ?>
196 + <span class="cmb-tooltip-desc cmb-tooltip-top">
197 + <?php esc_html_e( 'Download', 'gamipress' ); ?>
198 + </span>
199 + <ul class="gamipress-badge-builder-preview-action-dropdown gamipress-badge-builder-preview-action-download-dropdown">
200 + <?php foreach( $export_actions as $action_id => $action ) : ?>
201 + <li class="gamipress-badge-builder-preview-<?php echo esc_attr( $action_id ); ?>">
202 + <strong><?php echo esc_html( $action['name'] ); ?></strong>
203 + <span><?php echo esc_html( $action['desc'] ); ?></span>
204 + </li>
205 + <?php endforeach; ?>
206 + </ul>
207 + </span>
208 + </div>
209 +
210 + </div>
211 + <?php endfor; ?>
212 + </div>
213 +
214 + <div class="gamipress-badge-builder-sidebar">
215 +
216 + <div class="gamipress-badge-builder-generate-badge-options" style="display: none;">
217 + <?php
218 +
219 + $fields = array(
220 + 'badge_palette' => array(
221 + 'name' => __( 'Color Palette', 'gamipress' ),
222 + 'type' => 'radio',
223 + 'options' => array(
224 + '' => __( 'Random', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
225 + '#e3574d',
226 + '#88bdab',
227 + '#215E61',
228 + ) ),
229 + 'material' => __( 'Material', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
230 + '#e3574d',
231 + '#71b243',
232 + '#3ea5d0',
233 + ) ),
234 + 'pastel' => __( 'Pastel', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
235 + '#f7a3b2',
236 + '#88bdab',
237 + '#bd89c6',
238 + ) ),
239 + 'vintage' => __( 'Vintage', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
240 + '#FE7F2D',
241 + '#5C6F2B',
242 + '#215E61',
243 + ) ),
244 + ),
245 + ),
246 + 'generate' => array(
247 + 'name' => __( 'Generate', 'gamipress' ),
248 + 'type' => 'text',
249 + 'render_row_cb' => 'gamipress_badge_builder_generate_badge_field',
250 + ),
251 + );
252 +
253 + /**
254 + * Badge Builder generate fields
255 + *
256 + * @since 7.0.0
257 + *
258 + * @param array $fields
259 + *
260 + * @return array $fields
261 + */
262 + $fields = apply_filters( 'gamipress_badge_builder_generate_badge_fields', $fields );
263 +
264 + foreach ($fields as $field_id => $field) {
265 + $fields[$field_id]['id'] = $field_id;
266 + }
267 +
268 + $cmb2 = new CMB2(array(
269 + 'id' => 'gamipress_badge_builder',
270 + 'classes' => 'gamipress-form gamipress-box-form',
271 + 'hookup' => false,
272 + 'fields' => $fields
273 + ));
274 +
275 + $cmb2->object_id('gamipress_badge_builder');
276 +
277 + CMB2_Hookup::enqueue_cmb_css();
278 + CMB2_Hookup::enqueue_cmb_js();
279 +
280 + $cmb2->show_form();
281 +
282 + ?>
283 + </div>
284 +
285 + <div class="gamipress-badge-builder-generate-multiple-options" style="display: none;">
286 + <?php
287 +
288 + $fields = array(
289 + 'multiple_palette' => array(
290 + 'name' => __( 'Color Palette', 'gamipress' ),
291 + 'type' => 'radio',
292 + 'options' => array(
293 + '' => __( 'Random', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
294 + '#e3574d',
295 + '#88bdab',
296 + '#215E61',
297 + ) ),
298 + 'material' => __( 'Material', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
299 + '#e3574d',
300 + '#71b243',
301 + '#3ea5d0',
302 + ) ),
303 + 'pastel' => __( 'Pastel', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
304 + '#f7a3b2',
305 + '#88bdab',
306 + '#bd89c6',
307 + ) ),
308 + 'vintage' => __( 'Vintage', 'gamipress' ) . gamipress_badge_builder_colors_sample_html( array(
309 + '#FE7F2D',
310 + '#5C6F2B',
311 + '#215E61',
312 + ) ),
313 + ),
314 + ),
315 + 'generate' => array(
316 + 'name' => __( 'Generate', 'gamipress' ),
317 + 'type' => 'text',
318 + 'render_row_cb' => 'gamipress_badge_builder_generate_multiple_field',
319 + ),
320 + );
321 +
322 + /**
323 + * Badge Builder generate fields
324 + *
325 + * @since 7.0.0
326 + *
327 + * @param array $fields
328 + *
329 + * @return array $fields
330 + */
331 + $fields = apply_filters( 'gamipress_badge_builder_generate_multiple_fields', $fields );
332 +
333 + foreach ($fields as $field_id => $field) {
334 + $fields[$field_id]['id'] = $field_id;
335 + }
336 +
337 + $cmb2 = new CMB2(array(
338 + 'id' => 'gamipress_badge_builder',
339 + 'classes' => 'gamipress-form gamipress-box-form',
340 + 'hookup' => false,
341 + 'fields' => $fields
342 + ));
343 +
344 + $cmb2->object_id('gamipress_badge_builder');
345 +
346 + CMB2_Hookup::enqueue_cmb_css();
347 + CMB2_Hookup::enqueue_cmb_js();
348 +
349 + $cmb2->show_form();
350 +
351 + ?>
352 + </div>
353 +
354 + <div class="gamipress-badge-builder-selection-options">
355 + <?php
356 +
357 + $fields = array(
358 + 'icon' => array(
359 + 'name' => __( 'Shape', 'gamipress' ),
360 + 'type' => 'text',
361 + 'attributes' => array(
362 + 'type' => 'hidden'
363 + ),
364 + 'after_field' => 'gamipress_badge_builder_icon_field',
365 + ),
366 + // FILL
367 + 'fill_title' => array(
368 + 'name' => __( 'Color', 'gamipress' ),
369 + 'type' => 'title',
370 + ),
371 + 'fill_color_type' => array(
372 + 'name' => __( 'Color Type', 'gamipress' ),
373 + 'type' => 'select',
374 + 'options' => array(
375 + 'single' => __( 'Single', 'gamipress' ),
376 + 'gradient' => __( 'Gradient', 'gamipress' ),
377 + ),
378 + ),
379 + 'fill_color_type_notice' => array(
380 + 'name' => '&nbsp;',
381 + 'type' => 'text',
382 + 'desc' => gamipress_badge_builder_get_pro_notice(),
383 + 'attributes' => array( 'type' => 'hidden', ),
384 + 'classes_cb' => 'cmb_conditional_fields_classes_cb',
385 + 'show_if' => array( 'fill_color_type' => 'gradient' ),
386 + ),
387 + 'fill' => array(
388 + 'name' => __( 'Color', 'gamipress' ),
389 + 'type' => 'colorpicker',
390 + 'default' => '#000000ff',
391 + ),
392 + // BORDER
393 + 'stroke_title' => array(
394 + 'name' => __( 'Border', 'gamipress' ),
395 + 'type' => 'title',
396 + ),
397 + 'stroke_width' => array(
398 + 'name' => __( 'Width', 'gamipress' ),
399 + 'type' => 'text',
400 + 'attributes' => array(
401 + 'type' => 'number',
402 + 'min' => '0',
403 + 'step' => '1',
404 + ),
405 + 'default' => '0',
406 + ),
407 + 'stroke_color_type' => array(
408 + 'name' => __( 'Color Type', 'gamipress' ),
409 + 'type' => 'select',
410 + 'options' => array(
411 + 'single' => __( 'Single', 'gamipress' ),
412 + 'gradient' => __( 'Gradient', 'gamipress' ),
413 + ),
414 + 'classes_cb' => 'cmb_conditional_fields_classes_cb',
415 + 'hide_if' => array(
416 + 'stroke_width' => '0'
417 + ),
418 + ),
419 + 'stroke_color_type_notice' => array(
420 + 'name' => '&nbsp;',
421 + 'type' => 'text',
422 + 'desc' => gamipress_badge_builder_get_pro_notice(),
423 + 'attributes' => array( 'type' => 'hidden', ),
424 + 'classes_cb' => 'cmb_conditional_fields_classes_cb',
425 + 'show_if' => array( 'stroke_color_type' => 'gradient' ),
426 + ),
427 + 'stroke' => array(
428 + 'name' => __( 'Color', 'gamipress' ),
429 + 'type' => 'colorpicker',
430 + 'default' => '#ff0000',
431 + 'classes_cb' => 'cmb_conditional_fields_classes_cb',
432 + 'hide_if' => array(
433 + 'stroke_width' => '0'
434 + ),
435 + ),
436 + 'stroke_type' => array(
437 + 'name' => __( 'Corner Type', 'gamipress' ),
438 + 'type' => 'select',
439 + 'options' => array(
440 + 'round' => __( 'Round', 'gamipress' ),
441 + 'miter' => __( 'Square', 'gamipress' ),
442 + ),
443 + 'classes_cb' => 'cmb_conditional_fields_classes_cb',
444 + 'hide_if' => array(
445 + 'stroke_width' => '0'
446 + ),
447 + ),
448 + // TOOLS
449 + 'tools_title' => array(
450 + 'name' => __( 'Tools', 'gamipress' ),
451 + 'type' => 'title',
452 + ),
453 + 'tools' => array(
454 + 'name' => __( 'Tools', 'gamipress' ),
455 + 'type' => 'text',
456 + 'render_row_cb' => 'gamipress_badge_builder_tools_field',
457 + ),
458 + // SHORTCUTS
459 + 'shortcuts_title' => array(
460 + 'name' => __( 'Shortcuts', 'gamipress' ) . '<a href="#" class="gamipress-badge-builder-shortcuts-toggle">' . __( 'Show', 'gamipress' ) . '</a>',
461 + 'type' => 'title',
462 + ),
463 + 'shortcuts' => array(
464 + 'name' => __( 'Shortcuts', 'gamipress' ),
465 + 'type' => 'text',
466 + 'render_row_cb' => 'gamipress_badge_builder_shortcuts_field',
467 + ),
468 + );
469 +
470 + /**
471 + * Badge Builder selection fields
472 + *
473 + * @since 7.0.0
474 + *
475 + * @param array $fields
476 + *
477 + * @return array $fields
478 + */
479 + $fields = apply_filters( 'gamipress_badge_builder_selection_fields', $fields );
480 +
481 + foreach ($fields as $field_id => $field) {
482 + $fields[$field_id]['id'] = $field_id;
483 + }
484 +
485 + $cmb2 = new CMB2(array(
486 + 'id' => 'gamipress_badge_builder',
487 + 'classes' => 'gamipress-form gamipress-box-form',
488 + 'hookup' => false,
489 + 'fields' => $fields
490 + ));
491 +
492 + $cmb2->object_id('gamipress_badge_builder');
493 +
494 + CMB2_Hookup::enqueue_cmb_css();
495 + CMB2_Hookup::enqueue_cmb_js();
496 +
497 + $cmb2->show_form();
498 +
499 + ?>
500 + </div>
501 +
502 + <div class="gamipress-badge-builder-icon-selector">
503 + <div class="gamipress-badge-builder-icon-selector-filter">
504 + <input type="text" placeholder="<?php echo esc_attr( __( 'Type to filter...', 'gamipress' ) ); ?>">
505 + <?php echo gamipress_dashicon( 'no' ); ?>
506 + </div>
507 +
508 + <?php
509 + foreach( $icons as $group_id => $group ) :
510 + if( count( $group['icons'] ) === 0 ) continue; ?>
511 + <strong><?php echo $group['name'] ?></strong>
512 + <div class="gamipress-badge-builder-icons gamipress-badge-builder-icons-<?php echo esc_attr( $group_id ); ?>">
513 + <?php foreach( $group['icons'] as $icon_id => $icon ) : ?>
514 + <div class="gamipress-badge-builder-icon gamipress-badge-builder-icon-<?php echo esc_attr( $icon_id ); ?> cmb-tooltip" data-id="<?php echo esc_attr( $icon_id ); ?>">
515 + <span class="gamipress-badge-builder-icon-svg"><?php echo $icon['svg']; ?></span>
516 + <span class="cmb-tooltip-desc cmb-tooltip-top"><?php echo esc_html( $icon['name'] ); ?></span>
517 + </div>
518 + <?php endforeach; ?>
519 + </div>
520 + <?php endforeach;
521 +
522 + ?>
523 + </div>
524 +
525 + </div>
526 +
527 + </div>
528 +
529 + <?php
530 +}
531 +
532 +/**
533 + * Pro notice
534 + *
535 + * @since 1.0.0
536 + *
537 + * @return string
538 + */
539 +function gamipress_badge_builder_get_pro_notice() {
540 + return sprintf( __( 'Available in %s.', 'gamipress' ),
541 + '<a href="https://gamipress.com/add-ons/gamipress-badge-builder-pro/" target="_blank">'
542 + . __( 'Pro version', 'gamipress' )
543 + . '</a>'
544 + );
545 +}
546 +
547 +/**
548 + * Color Palettes
549 + *
550 + * @since 1.0.0
551 + *
552 + * @return string
553 + */
554 +function gamipress_badge_builder_get_color_palettes() {
555 +
556 + return apply_filters( 'gamipress_badge_builder_color_palettes', array(
557 + 'material' => array(
558 + 'name' => __( 'Material', 'gamipress' ),
559 + 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#e3574d', '#71b243', '#3ea5d0', ) ),
560 + ),
561 + 'pastel' => array(
562 + 'name' => __( 'Pastel', 'gamipress' ),
563 + 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#f7a3b2', '#88bdab', '#bd89c6', ) ),
564 + ),
565 + 'vintage' => array(
566 + 'name' => __( 'Vintage', 'gamipress' ),
567 + 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#FE7F2D', '#5C6F2B', '#215E61', ) ),
568 + ),
569 + ) );
570 +
571 +}
572 +
573 +/**
574 + * Colors sample HTML
575 + *
576 + * @since 1.0.0
577 + *
578 + * @param array $colors Hex colors
579 + */
580 +function gamipress_badge_builder_colors_sample_html( $colors ) {
581 + ob_start(); ?>
582 +
583 + <div class="gamipress-badge-builder-colors-sample">
584 +
585 + <?php foreach( $colors as $color ) : ?>
586 + <span class="gamipress-badge-builder-color-sample" style="background-color: <?php echo esc_attr( $color ); ?>"></span>
587 + <?php endforeach; ?>
588 +
589 + </div>
590 +
591 + <?php return ob_get_clean();
592 +}
593 +
594 +/**
595 + * Generate badge field buttons
596 + *
597 + * @since 1.0.0
598 + *
599 + * @param object $field_args Current field args
600 + * @param object $field Current field object
601 + */
602 +function gamipress_badge_builder_generate_badge_field( $field_args, $field ) {
603 + ?>
604 + <div class="gamipress-badge-builder-generate-badge-options-actions">
605 + <button class="button button-primary gamipress-badge-builder-sidebar-control" data-action="generate-badge"><?php esc_html_e( 'Generate', 'gamipress' ); ?></button>
606 + <button class="button gamipress-badge-builder-sidebar-control" data-action="close-generate-badge"><?php esc_html_e( 'Close', 'gamipress' ); ?></button>
607 + </div>
608 + <?php
609 +}
610 +
611 +/**
612 + * Generate multiple field buttons
613 + *
614 + * @since 1.0.0
615 + *
616 + * @param object $field_args Current field args
617 + * @param object $field Current field object
618 + */
619 +function gamipress_badge_builder_generate_multiple_field( $field_args, $field ) {
620 + ?>
621 + <div class="gamipress-badge-builder-generate-multiple-options-actions">
622 + <button class="button button-primary gamipress-badge-builder-sidebar-control" data-action="generate-multiple"><?php esc_html_e( 'Generate', 'gamipress' ); ?></button>
623 + <button class="button gamipress-badge-builder-sidebar-control" data-action="close-generate-multiple"><?php esc_html_e( 'Close', 'gamipress' ); ?></button>
624 + </div>
625 + <?php
626 +}
627 +
628 +/**
629 + * Icon field
630 + *
631 + * @since 1.0.0
632 + *
633 + * @param object $field_args Current field args
634 + * @param object $field Current field object
635 + */
636 +function gamipress_badge_builder_icon_field( $field_args, $field ) {
637 + ?>
638 + <div class="gamipress-badge-builder-icon cmb-tooltip" data-id="">
639 + <span class="gamipress-badge-builder-icon-svg"></span>
640 + <span class="cmb-tooltip-desc cmb-tooltip-left"></span>
641 + </div>
642 + <?php
643 +}
644 +
645 +/**
646 + * Font Style field
647 + *
648 + * @since 1.0.0
649 + *
650 + * @param object $field_args Current field args
651 + * @param object $field Current field object
652 + */
653 +function gamipress_badge_builder_text_align_field( $field_args, $field ) {
654 + $tools = array(
655 + 'text-align-left' => array(
656 + 'name' => __( 'Left', 'gamipress' ),
657 + 'icon' => 'editor-alignleft',
658 + ),
659 + 'text-align-center' => array(
660 + 'name' => __( 'Center', 'gamipress' ),
661 + 'icon' => 'editor-aligncenter',
662 + ),
663 + 'text-align-right' => array(
664 + 'name' => __( 'Right', 'gamipress' ),
665 + 'icon' => 'editor-alignright',
666 + ),
667 + 'text-align-justify' => array(
668 + 'name' => __( 'Justify', 'gamipress' ),
669 + 'icon' => 'editor-justify',
670 + ),
671 + );
672 +
673 + ?>
674 + <div class="cmb-row gamipress-badge-builder-tools cmb2-id-text-align">
675 + <div class="cmb-th"><?php esc_html_e( 'Alignment', 'gamipress' ); ?></div>
676 + <div class="cmb-td">
677 + <?php foreach( $tools as $tool_id => $tool ) : ?>
678 + <span class="gamipress-badge-builder-tool cmb-tooltip" data-tool="<?php echo esc_attr( $tool_id ); ?>">
679 + <?php echo gamipress_dashicon( $tool['icon'] ); ?>
680 + <span class="cmb-tooltip-desc cmb-tooltip-top"><?php echo esc_html( $tool['name'] ); ?></span>
681 + </span>
682 + <?php endforeach; ?>
683 + </div>
684 + </div>
685 + <?php
686 +}
687 +
688 +/**
689 + * Tools field
690 + *
691 + * @since 1.0.0
692 + *
693 + * @param object $field_args Current field args
694 + * @param object $field Current field object
695 + */
696 +function gamipress_badge_builder_tools_field( $field_args, $field ) {
697 +
698 + $tools = array(
699 + 'scale' => array(
700 + 'name' => __( 'Scale', 'gamipress' ),
701 + 'tools' => array(
702 + 'scale-up' => array(
703 + 'name' => __( 'Scale Up', 'gamipress' ),
704 + 'icon' => 'plus-alt2',
705 + ),
706 + 'scale-down' => array(
707 + 'name' => __( 'Scale Down', 'gamipress' ),
708 + 'icon' => 'minus',
709 + ),
710 + 'fit' => array(
711 + 'name' => __( 'Fit To Canvas', 'gamipress' ),
712 + 'icon' => 'fullscreen-alt',
713 + ),
714 + ),
715 + ),
716 + 'transform' => array(
717 + 'name' => __( 'Transform', 'gamipress' ),
718 + 'tools' => array(
719 + 'rotate-left' => array(
720 + 'name' => __( 'Rotate 5º Left', 'gamipress' ),
721 + 'icon' => 'image-rotate dashicons-image-rotate-left',
722 + ),
723 + 'rotate-right' => array(
724 + 'name' => __( 'Rotate 5º Right', 'gamipress' ),
725 + 'icon' => 'image-rotate dashicons-image-rotate-right',
726 + ),
727 + 'flip-horizontal' => array(
728 + 'name' => __( 'Flip Horizontal', 'gamipress' ),
729 + 'icon' => 'image-flip-horizontal',
730 + ),
731 + 'flip-vertical' => array(
732 + 'name' => __( 'Flip Vertical', 'gamipress' ),
733 + 'icon' => 'image-flip-vertical',
734 + ),
735 + )
736 + ),
737 + 'alignment' => array(
738 + 'name' => __( 'Alignment', 'gamipress' ),
739 + 'tools' => array(
740 + 'align-horizontal-left' => array(
741 + 'name' => __( 'Left', 'gamipress' ),
742 + 'icon' => 'gamipress-align-horizontal-left',
743 + ),
744 + 'align-horizontal-center' => array(
745 + 'name' => __( 'Center', 'gamipress' ),
746 + 'icon' => 'gamipress-align-horizontal-center',
747 + ),
748 + 'align-horizontal-right' => array(
749 + 'name' => __( 'Right', 'gamipress' ),
750 + 'icon' => 'gamipress-align-horizontal-right',
751 + ),
752 + 'align-vertical-top' => array(
753 + 'name' => __( 'Top', 'gamipress' ),
754 + 'icon' => 'gamipress-align-vertical-top',
755 + ),
756 + 'align-vertical-center' => array(
757 + 'name' => __( 'Middle', 'gamipress' ),
758 + 'icon' => 'gamipress-align-vertical-center',
759 + ),
760 + 'align-vertical-bottom' => array(
761 + 'name' => __( 'Bottom', 'gamipress' ),
762 + 'icon' => 'gamipress-align-vertical-bottom',
763 + ),
764 + )
765 + ),
766 + 'group' => array(
767 + 'name' => __( 'Group', 'gamipress' ),
768 + 'tools' => array(
769 + 'group' => array(
770 + 'name' => __( 'Group', 'gamipress' ),
771 + 'icon' => 'gamipress-group',
772 + ),
773 + 'ungroup' => array(
774 + 'name' => __( 'Ungroup', 'gamipress' ),
775 + 'icon' => 'gamipress-ungroup',
776 + ),
777 + )
778 + ),
779 + 'order' => array(
780 + 'name' => __( 'Order', 'gamipress' ),
781 + 'tools' => array(
782 + 'send-back' => array(
783 + 'name' => __( 'Send To Back', 'gamipress' ),
784 + 'icon' => 'gamipress-send-back',
785 + ),
786 + 'send-front' => array(
787 + 'name' => __( 'Send To Front', 'gamipress' ),
788 + 'icon' => 'gamipress-send-front',
789 + ),
790 + )
791 + ),
792 + 'actions' => array(
793 + 'name' => __( 'Actions', 'gamipress' ),
794 + 'tools' => array(
795 + 'undo' => array(
796 + 'name' => __( 'Undo', 'gamipress' ),
797 + 'icon' => 'undo',
798 + ),
799 + 'redo' => array(
800 + 'name' => __( 'Redo', 'gamipress' ),
801 + 'icon' => 'redo',
802 + ),
803 + 'duplicate' => array(
804 + 'name' => __( 'Duplicate', 'gamipress' ),
805 + 'icon' => 'admin-page',
806 + ),
807 + 'delete' => array(
808 + 'name' => __( 'Delete', 'gamipress' ),
809 + 'icon' => 'trash',
810 + ),
811 + )
812 + ),
813 + );
814 +
815 + ?>
816 +
817 + <?php foreach( $tools as $tools_group_id => $tools_group ) : ?>
818 + <div class="cmb-row gamipress-badge-builder-tools gamipress-badge-builder-tools-<?php echo esc_attr( $tools_group_id ); ?>">
819 + <div class="cmb-th"><?php echo esc_html( $tools_group['name'] ); ?></div>
820 + <div class="cmb-td">
821 + <?php foreach( $tools_group['tools'] as $tool_id => $tool ) : ?>
822 + <span class="gamipress-badge-builder-tool cmb-tooltip" data-tool="<?php echo esc_attr( $tool_id ); ?>">
823 + <?php echo gamipress_dashicon( $tool['icon'] ); ?>
824 + <span class="cmb-tooltip-desc cmb-tooltip-top"><?php echo esc_html( $tool['name'] ); ?></span>
825 + </span>
826 + <?php endforeach; ?>
827 + </div>
828 +
829 + </div>
830 + <?php endforeach; ?>
831 +
832 + <?php
833 +
834 +}
835 +
836 +/**
837 + * Shortcuts field
838 + *
839 + * @since 1.0.0
840 + *
841 + * @param object $field_args Current field args
842 + * @param object $field Current field object
843 + */
844 +function gamipress_badge_builder_shortcuts_field( $field_args, $field ) {
845 +
846 + $shortcuts = array(
847 + 'move' => array(
848 + 'keys' => '<kbd>&#8592;</kbd> <kbd>&#8593;</kbd> <kbd>&#8595;</kbd> <kbd>&#8594;</kbd>',
849 + 'name' => __( 'Move', 'gamipress' ),
850 + ),
851 + 'scale' => array(
852 + 'keys' => '<kbd>+</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>-</kbd>',
853 + 'name' => __( 'Scale', 'gamipress' ),
854 + ),
855 + 'fit' => array(
856 + 'keys' => '<kbd>Shift</kbd> + <kbd>F</kbd>',
857 + 'name' => __( 'Fit To Canvas', 'gamipress' ),
858 + ),
859 + 'rotate' => array(
860 + 'keys' => '<kbd>Ctrl</kbd> + <kbd>&#8592;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8594;</kbd>',
861 + 'name' => __( 'Rotate', 'gamipress' ),
862 + ),
863 + 'flip_horizontal' => array(
864 + 'keys' => '<kbd>Alt</kbd> + <kbd>&#8592;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8594;</kbd>',
865 + 'name' => __( 'Flip Horizontal', 'gamipress' ),
866 + ),
867 + 'flip_vertical' => array(
868 + 'keys' => '<kbd>Alt</kbd> + <kbd>&#8593;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8595;</kbd>',
869 + 'name' => __( 'Flip Vertical', 'gamipress' ),
870 + ),
871 + 'align_horizontal' => array(
872 + 'keys' => '<kbd>Shift</kbd> + <kbd>&#8592;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8594;</kbd>',
873 + 'name' => __( 'Align Horizontal', 'gamipress' ),
874 + ),
875 + 'align_vertical' => array(
876 + 'keys' => '<kbd>Shift</kbd> + <kbd>&#8593;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8595;</kbd>',
877 + 'name' => __( 'Align Vertical', 'gamipress' ),
878 + ),
879 + 'align_center' => array(
880 + 'keys' => '<kbd>Shift</kbd> + <kbd>C</kbd>',
881 + 'name' => __( 'Align Center', 'gamipress' ),
882 + ),
883 + 'send_front_back' => array(
884 + 'keys' => '<kbd>Ctrl</kbd> + <kbd>&#8593;</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>&#8595;</kbd>',
885 + 'name' => __( 'Send To Front/Back', 'gamipress' ),
886 + ),
887 + 'duplicate' => array(
888 + 'keys' => '<kbd>Shift</kbd> + <kbd>D</kbd>',
889 + 'name' => __( 'Duplicate', 'gamipress' ),
890 + ),
891 + 'delete' => array(
892 + 'keys' => '<kbd>supr</kbd> ' . __( 'or', 'gamipress' ) . ' <kbd>delete</kbd>',
893 + 'name' => __( 'Delete', 'gamipress' ),
894 + ),
895 + 'undo' => array(
896 + 'keys' => '<kbd>Ctrl</kbd> + <kbd>Z</kbd>',
897 + 'name' => __( 'Undo', 'gamipress' ),
898 + ),
899 + 'redo' => array(
900 + 'keys' => '<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Z</kbd>',
901 + 'name' => __( 'Redo', 'gamipress' ),
902 + ),
903 + 'multiple_selection' => array(
904 + 'keys' => '<kbd>Ctrl</kbd> + <kbd>' . __( 'Left Click', 'gamipress' ) . '</kbd>',
905 + 'name' => __( 'Multiple Selection', 'gamipress' ),
906 + ),
907 + ); ?>
908 + <div class="gamipress-badge-builder-shortcuts-wrapper" style="display: none;">
909 +
910 + <?php foreach( $shortcuts as $shortcut_id => $shortcut ) : ?>
911 + <div class="cmb-row gamipress-badge-builder-shortcuts gamipress-badge-builder-shortcuts-<?php echo esc_attr( $shortcut_id ); ?>">
912 + <div class="cmb-th"><?php echo esc_html( $shortcut['name'] ); ?></div>
913 + <div class="cmb-td"><?php echo $shortcut['keys']; ?></div>
914 + </div>
915 + <?php endforeach; ?>
916 +
917 + </div>
918 +
919 + <?php
920 +}