, Ruben Garcia * @since 1.0.0 */ // Exit if accessed directly if( !defined( 'ABSPATH' ) ) exit; /** * Badge Builder page * * @since 1.0.0 * * @return void */ function gamipress_badge_builder_page() { $icons = gamipress_badge_builder_get_icons(); $title = esc_html__( 'GamiPress Badge Builder', 'gamipress' ); $title = str_replace( 'GamiPress', 'GamiPress', $title ); /** * Badge Builder page title * * @since 7.0.0 * * @param string $title * * @return string $title */ $title = apply_filters( 'gamipress_badge_builder_page_title', $title ); ?>
array( 'name' => __( 'Upload Badge', 'gamipress' ), 'desc' => __( 'Upload a GPB file', 'gamipress' ), 'accept' => '.gpb', ), ); /** * Badge Builder import actions * * @since 7.0.0 * * @param array $import_actions * * @return array $import_actions */ $import_actions = apply_filters( 'gamipress_badge_builder_import_actions', $import_actions ); ?>
array( 'name' => __( 'Download Badge', 'gamipress' ), 'desc' => __( 'Download as GPB', 'gamipress' ), ), 'save-png' => array( 'name' => __( 'Download as PNG', 'gamipress' ), 'desc' => __( 'To upload to WordPress', 'gamipress' ), ), ); /** * Badge Builder export actions * * @since 7.0.0 * * @param array $export_actions * * @return array $export_actions */ $export_actions = apply_filters( 'gamipress_badge_builder_export_actions', $export_actions ); ?>
array( 'name' => __( 'Add Shape', 'gamipress' ), 'icon' => 'insert', ), 'open-generate-badge' => array( 'name' => __( 'Generate Badge', 'gamipress' ), 'icon' => 'awards', ), 'open-generate-multiple' => array( 'name' => __( 'Generate Multiple', 'gamipress' ), 'icon' => 'awards', ), ); /** * Badge Builder toolbar tools * * @since 7.0.0 * * @param array $tools * * @return array $tools */ $tools = apply_filters( 'gamipress_badge_builder_toolbar_tools', $tools ); ?> $tool ) : ?>
:
    $action ) : ?>
array( 'name' => __( 'Shape', 'gamipress' ), 'type' => 'text', 'attributes' => array( 'type' => 'hidden' ), 'after_field' => 'gamipress_badge_builder_icon_field', ), // FILL 'fill_title' => array( 'name' => __( 'Color', 'gamipress' ), 'type' => 'title', ), 'fill_color_type' => array( 'name' => __( 'Color Type', 'gamipress' ), 'type' => 'select', 'options' => array( 'single' => __( 'Single', 'gamipress' ), 'gradient' => __( 'Gradient', 'gamipress' ), ), ), 'fill_color_type_notice' => array( 'name' => ' ', 'type' => 'text', 'desc' => gamipress_badge_builder_get_pro_notice(), 'attributes' => array( 'type' => 'hidden', ), 'classes_cb' => 'cmb_conditional_fields_classes_cb', 'show_if' => array( 'fill_color_type' => 'gradient' ), ), 'fill' => array( 'name' => __( 'Color', 'gamipress' ), 'type' => 'colorpicker', 'default' => '#000000ff', ), // BORDER 'stroke_title' => array( 'name' => __( 'Border', 'gamipress' ), 'type' => 'title', ), 'stroke_width' => array( 'name' => __( 'Width', 'gamipress' ), 'type' => 'text', 'attributes' => array( 'type' => 'number', 'min' => '0', 'step' => '1', ), 'default' => '0', ), 'stroke_color_type' => array( 'name' => __( 'Color Type', 'gamipress' ), 'type' => 'select', 'options' => array( 'single' => __( 'Single', 'gamipress' ), 'gradient' => __( 'Gradient', 'gamipress' ), ), 'classes_cb' => 'cmb_conditional_fields_classes_cb', 'hide_if' => array( 'stroke_width' => '0' ), ), 'stroke_color_type_notice' => array( 'name' => ' ', 'type' => 'text', 'desc' => gamipress_badge_builder_get_pro_notice(), 'attributes' => array( 'type' => 'hidden', ), 'classes_cb' => 'cmb_conditional_fields_classes_cb', 'show_if' => array( 'stroke_color_type' => 'gradient' ), ), 'stroke' => array( 'name' => __( 'Color', 'gamipress' ), 'type' => 'colorpicker', 'default' => '#ff0000', 'classes_cb' => 'cmb_conditional_fields_classes_cb', 'hide_if' => array( 'stroke_width' => '0' ), ), 'stroke_type' => array( 'name' => __( 'Corner Type', 'gamipress' ), 'type' => 'select', 'options' => array( 'round' => __( 'Round', 'gamipress' ), 'miter' => __( 'Square', 'gamipress' ), ), 'classes_cb' => 'cmb_conditional_fields_classes_cb', 'hide_if' => array( 'stroke_width' => '0' ), ), // TOOLS 'tools_title' => array( 'name' => __( 'Tools', 'gamipress' ), 'type' => 'title', ), 'tools' => array( 'name' => __( 'Tools', 'gamipress' ), 'type' => 'text', 'render_row_cb' => 'gamipress_badge_builder_tools_field', ), // SHORTCUTS 'shortcuts_title' => array( 'name' => __( 'Shortcuts', 'gamipress' ) . '' . __( 'Show', 'gamipress' ) . '', 'type' => 'title', ), 'shortcuts' => array( 'name' => __( 'Shortcuts', 'gamipress' ), 'type' => 'text', 'render_row_cb' => 'gamipress_badge_builder_shortcuts_field', ), ); /** * Badge Builder selection fields * * @since 7.0.0 * * @param array $fields * * @return array $fields */ $fields = apply_filters( 'gamipress_badge_builder_selection_fields', $fields ); foreach ($fields as $field_id => $field) { $fields[$field_id]['id'] = $field_id; } $cmb2 = new CMB2(array( 'id' => 'gamipress_badge_builder', 'classes' => 'gamipress-form gamipress-box-form', 'hookup' => false, 'fields' => $fields )); $cmb2->object_id('gamipress_badge_builder'); CMB2_Hookup::enqueue_cmb_css(); CMB2_Hookup::enqueue_cmb_js(); $cmb2->show_form(); ?>
$group ) : if( count( $group['icons'] ) === 0 ) continue; ?>
$icon ) : ?>
' . __( 'Pro version', 'gamipress' ) . '' ); } /** * Color Palettes * * @since 1.0.0 * * @return string */ function gamipress_badge_builder_get_color_palettes() { return apply_filters( 'gamipress_badge_builder_color_palettes', array( 'material' => array( 'name' => __( 'Material', 'gamipress' ), 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#e3574d', '#71b243', '#3ea5d0', ) ), ), 'pastel' => array( 'name' => __( 'Pastel', 'gamipress' ), 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#f7a3b2', '#88bdab', '#bd89c6', ) ), ), 'vintage' => array( 'name' => __( 'Vintage', 'gamipress' ), 'colors_sample' => gamipress_badge_builder_colors_sample_html( array( '#FE7F2D', '#5C6F2B', '#215E61', ) ), ), ) ); } /** * Colors sample HTML * * @since 1.0.0 * * @param array $colors Hex colors */ function gamipress_badge_builder_colors_sample_html( $colors ) { ob_start(); ?>
array( 'name' => __( 'Left', 'gamipress' ), 'icon' => 'editor-alignleft', ), 'text-align-center' => array( 'name' => __( 'Center', 'gamipress' ), 'icon' => 'editor-aligncenter', ), 'text-align-right' => array( 'name' => __( 'Right', 'gamipress' ), 'icon' => 'editor-alignright', ), 'text-align-justify' => array( 'name' => __( 'Justify', 'gamipress' ), 'icon' => 'editor-justify', ), ); ?>
$tool ) : ?>
array( 'name' => __( 'Scale', 'gamipress' ), 'tools' => array( 'scale-up' => array( 'name' => __( 'Scale Up', 'gamipress' ), 'icon' => 'plus-alt2', ), 'scale-down' => array( 'name' => __( 'Scale Down', 'gamipress' ), 'icon' => 'minus', ), 'fit' => array( 'name' => __( 'Fit To Canvas', 'gamipress' ), 'icon' => 'fullscreen-alt', ), ), ), 'transform' => array( 'name' => __( 'Transform', 'gamipress' ), 'tools' => array( 'rotate-left' => array( 'name' => __( 'Rotate 5º Left', 'gamipress' ), 'icon' => 'image-rotate dashicons-image-rotate-left', ), 'rotate-right' => array( 'name' => __( 'Rotate 5º Right', 'gamipress' ), 'icon' => 'image-rotate dashicons-image-rotate-right', ), 'flip-horizontal' => array( 'name' => __( 'Flip Horizontal', 'gamipress' ), 'icon' => 'image-flip-horizontal', ), 'flip-vertical' => array( 'name' => __( 'Flip Vertical', 'gamipress' ), 'icon' => 'image-flip-vertical', ), ) ), 'alignment' => array( 'name' => __( 'Alignment', 'gamipress' ), 'tools' => array( 'align-horizontal-left' => array( 'name' => __( 'Left', 'gamipress' ), 'icon' => 'gamipress-align-horizontal-left', ), 'align-horizontal-center' => array( 'name' => __( 'Center', 'gamipress' ), 'icon' => 'gamipress-align-horizontal-center', ), 'align-horizontal-right' => array( 'name' => __( 'Right', 'gamipress' ), 'icon' => 'gamipress-align-horizontal-right', ), 'align-vertical-top' => array( 'name' => __( 'Top', 'gamipress' ), 'icon' => 'gamipress-align-vertical-top', ), 'align-vertical-center' => array( 'name' => __( 'Middle', 'gamipress' ), 'icon' => 'gamipress-align-vertical-center', ), 'align-vertical-bottom' => array( 'name' => __( 'Bottom', 'gamipress' ), 'icon' => 'gamipress-align-vertical-bottom', ), ) ), 'group' => array( 'name' => __( 'Group', 'gamipress' ), 'tools' => array( 'group' => array( 'name' => __( 'Group', 'gamipress' ), 'icon' => 'gamipress-group', ), 'ungroup' => array( 'name' => __( 'Ungroup', 'gamipress' ), 'icon' => 'gamipress-ungroup', ), ) ), 'order' => array( 'name' => __( 'Order', 'gamipress' ), 'tools' => array( 'send-back' => array( 'name' => __( 'Send To Back', 'gamipress' ), 'icon' => 'gamipress-send-back', ), 'send-front' => array( 'name' => __( 'Send To Front', 'gamipress' ), 'icon' => 'gamipress-send-front', ), ) ), 'actions' => array( 'name' => __( 'Actions', 'gamipress' ), 'tools' => array( 'undo' => array( 'name' => __( 'Undo', 'gamipress' ), 'icon' => 'undo', ), 'redo' => array( 'name' => __( 'Redo', 'gamipress' ), 'icon' => 'redo', ), 'duplicate' => array( 'name' => __( 'Duplicate', 'gamipress' ), 'icon' => 'admin-page', ), 'delete' => array( 'name' => __( 'Delete', 'gamipress' ), 'icon' => 'trash', ), ) ), ); ?> $tools_group ) : ?>
$tool ) : ?>
array( 'keys' => '← ↑ ↓ →', 'name' => __( 'Move', 'gamipress' ), ), 'scale' => array( 'keys' => '+ ' . __( 'or', 'gamipress' ) . ' -', 'name' => __( 'Scale', 'gamipress' ), ), 'fit' => array( 'keys' => 'Shift + F', 'name' => __( 'Fit To Canvas', 'gamipress' ), ), 'rotate' => array( 'keys' => 'Ctrl + ← ' . __( 'or', 'gamipress' ) . ' →', 'name' => __( 'Rotate', 'gamipress' ), ), 'flip_horizontal' => array( 'keys' => 'Alt + ← ' . __( 'or', 'gamipress' ) . ' →', 'name' => __( 'Flip Horizontal', 'gamipress' ), ), 'flip_vertical' => array( 'keys' => 'Alt + ↑ ' . __( 'or', 'gamipress' ) . ' ↓', 'name' => __( 'Flip Vertical', 'gamipress' ), ), 'align_horizontal' => array( 'keys' => 'Shift + ← ' . __( 'or', 'gamipress' ) . ' →', 'name' => __( 'Align Horizontal', 'gamipress' ), ), 'align_vertical' => array( 'keys' => 'Shift + ↑ ' . __( 'or', 'gamipress' ) . ' ↓', 'name' => __( 'Align Vertical', 'gamipress' ), ), 'align_center' => array( 'keys' => 'Shift + C', 'name' => __( 'Align Center', 'gamipress' ), ), 'send_front_back' => array( 'keys' => 'Ctrl + ↑ ' . __( 'or', 'gamipress' ) . ' ↓', 'name' => __( 'Send To Front/Back', 'gamipress' ), ), 'duplicate' => array( 'keys' => 'Shift + D', 'name' => __( 'Duplicate', 'gamipress' ), ), 'delete' => array( 'keys' => 'supr ' . __( 'or', 'gamipress' ) . ' delete', 'name' => __( 'Delete', 'gamipress' ), ), 'undo' => array( 'keys' => 'Ctrl + Z', 'name' => __( 'Undo', 'gamipress' ), ), 'redo' => array( 'keys' => 'Ctrl + Shift + Z', 'name' => __( 'Redo', 'gamipress' ), ), 'multiple_selection' => array( 'keys' => 'Ctrl + ' . __( 'Left Click', 'gamipress' ) . '', 'name' => __( 'Multiple Selection', 'gamipress' ), ), ); ?>