| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.14 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <[email protected]> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) |
| 13 |
{ |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
$integrations = (array) $this->data->get('integrations', []); |
| 18 |
if (!$integrations) |
| 19 |
{ |
| 20 |
return; |
| 21 |
} |
| 22 |
?> |
| 23 |
<div class="fb-integrations-settings"> |
| 24 |
<div class="fb-integrations-settings-grid"> |
| 25 |
<?php foreach ($integrations as $integration): ?> |
| 26 |
<?php |
| 27 |
$integration = is_array($integration) ? $integration : (array) $integration; |
| 28 |
$label = isset($integration['label']) ? $integration['label'] : ''; |
| 29 |
$slug = isset($integration['slug']) ? $integration['slug'] : ''; |
| 30 |
$connected = !empty($integration['connected']); |
| 31 |
$credential_fields = isset($integration['credentials']) && is_array($integration['credentials']) ? $integration['credentials'] : []; |
| 32 |
$docs_url = isset($integration['docs_url']) ? $integration['docs_url'] : ''; |
| 33 |
$connection_type = isset($integration['connection_type']) ? (string) $integration['connection_type'] : 'api_key'; |
| 34 |
$is_api_key = $connection_type === 'api_key'; |
| 35 |
$is_locked = !empty($integration['locked']); |
| 36 |
$status_class = $is_locked ? 'is-locked' : ($connected ? 'is-connected' : 'is-disconnected'); |
| 37 |
$status_label = isset($integration['status_label']) ? (string) $integration['status_label'] : firebox()->_($connected ? 'FB_INTEGRATION_CONNECTED' : 'FB_INTEGRATION_DISCONNECTED'); |
| 38 |
$logo_url = isset($integration['logo_url']) ? $integration['logo_url'] : ''; |
| 39 |
$plugin_message = isset($integration['plugin_message']) ? (string) $integration['plugin_message'] : ''; |
| 40 |
$plugin_action_label = isset($integration['plugin_action_label']) ? (string) $integration['plugin_action_label'] : ''; |
| 41 |
$plugin_action_url = isset($integration['plugin_action_url']) ? (string) $integration['plugin_action_url'] : ''; |
| 42 |
$locked_message = isset($integration['locked_message']) ? (string) $integration['locked_message'] : ''; |
| 43 |
$upgrade_badge_label = isset($integration['upgrade_badge_label']) ? (string) $integration['upgrade_badge_label'] : ''; |
| 44 |
$upgrade_label = isset($integration['upgrade_label']) ? (string) $integration['upgrade_label'] : ''; |
| 45 |
$upgrade_plan = isset($integration['upgrade_plan']) ? (string) $integration['upgrade_plan'] : 'Pro'; |
| 46 |
$current_plan = isset($integration['current_plan']) ? (string) $integration['current_plan'] : 'free'; |
| 47 |
/* translators: %s: Integration label. */ |
| 48 |
$upgrade_feature = sprintf(__('%s Integration', 'firebox'), $label); |
| 49 |
$show_secret_label = __('Show value', 'firebox'); |
| 50 |
$hide_secret_label = __('Hide value', 'firebox'); |
| 51 |
$credentials_class = count($credential_fields) > 1 ? ' has-multiple-credentials' : ' has-single-credential'; |
| 52 |
?> |
| 53 |
<div class="fb-integration-card<?php echo $connected ? ' is-connected' : ''; ?>" data-integration="<?php echo esc_attr($slug); ?>" data-connected="<?php echo esc_attr($connected ? '1' : '0'); ?>"> |
| 54 |
<div class="fb-integration-card-top"> |
| 55 |
<div class="fb-integration-card-title-wrap"> |
| 56 |
<?php if (!empty($logo_url)): ?> |
| 57 |
<img class="fb-integration-logo" src="<?php echo esc_url($logo_url); ?>" alt="<?php echo esc_attr($label); ?>" /> |
| 58 |
<?php endif; ?> |
| 59 |
<div class="fb-integration-card-heading"> |
| 60 |
<h5 class="fb-integration-card-title"><?php echo esc_html($label); ?></h5> |
| 61 |
<?php if ($is_locked): ?> |
| 62 |
<a |
| 63 |
class="fb-integration-upgrade-badge fpf-modal-opener" |
| 64 |
href="#" |
| 65 |
data-fpf-modal="#fireboxUpgradeToPlan" |
| 66 |
data-fpf-modal-item="<?php echo esc_attr($upgrade_feature); ?>" |
| 67 |
data-current-plan="<?php echo esc_attr($current_plan); ?>" |
| 68 |
data-upgrade-plan="<?php echo esc_attr($upgrade_plan); ?>" |
| 69 |
aria-label="<?php echo esc_attr($upgrade_badge_label); ?>" |
| 70 |
> |
| 71 |
<?php echo esc_html($upgrade_badge_label); ?> |
| 72 |
</a> |
| 73 |
<?php else: ?> |
| 74 |
<span class="fb-integration-status <?php echo esc_attr($status_class); ?>"><?php echo esc_html($status_label); ?></span> |
| 75 |
<?php endif; ?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
<div class="fb-integration-card-actions"> |
| 79 |
<?php if (!empty($docs_url)): ?> |
| 80 |
<a class="fb-integration-help-link fb-integration-help-link-compact" href="<?php echo esc_url($docs_url); ?>" target="_blank" aria-label="<?php echo esc_attr(fpframework()->_('FPF_WHERE_TO_FIND_API_KEY')); ?>"> |
| 81 |
<span class="dashicons dashicons-editor-help" aria-hidden="true"></span> |
| 82 |
</a> |
| 83 |
<?php endif; ?> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
|
| 87 |
<div class="fb-integration-card-body"> |
| 88 |
<?php if ($is_locked): ?> |
| 89 |
<div class="fb-integration-locked-wrapper"> |
| 90 |
<?php if (!empty($locked_message)): ?> |
| 91 |
<div class="fb-integration-locked-message"><?php echo esc_html($locked_message); ?></div> |
| 92 |
<?php endif; ?> |
| 93 |
<?php if (!empty($upgrade_label)): ?> |
| 94 |
<a |
| 95 |
class="fpf-button upgrade fb-integration-locked-action fpf-modal-opener" |
| 96 |
href="#" |
| 97 |
data-fpf-modal="#fireboxUpgradeToPlan" |
| 98 |
data-fpf-modal-item="<?php echo esc_attr($upgrade_feature); ?>" |
| 99 |
data-current-plan="<?php echo esc_attr($current_plan); ?>" |
| 100 |
data-upgrade-plan="<?php echo esc_attr($upgrade_plan); ?>" |
| 101 |
> |
| 102 |
<?php echo esc_html($upgrade_label); ?> |
| 103 |
</a> |
| 104 |
<?php endif; ?> |
| 105 |
</div> |
| 106 |
<?php elseif ($is_api_key): ?> |
| 107 |
<div class="fb-integration-input-wrapper<?php echo esc_attr($credentials_class); ?>"> |
| 108 |
<div class="fb-integration-credentials"> |
| 109 |
<?php foreach ($credential_fields as $field): ?> |
| 110 |
<?php |
| 111 |
$field = is_array($field) ? $field : []; |
| 112 |
$field_key = isset($field['key']) ? (string) $field['key'] : ''; |
| 113 |
$field_label = isset($field['label']) ? (string) $field['label'] : ''; |
| 114 |
$field_placeholder = isset($field['placeholder']) ? (string) $field['placeholder'] : ''; |
| 115 |
$field_value = isset($field['value']) ? (string) $field['value'] : ''; |
| 116 |
$field_type = isset($field['type']) && $field['type'] === 'text' ? 'text' : 'password'; |
| 117 |
$field_required = !empty($field['required']); |
| 118 |
// translators: %s: Credential field label or "value" if label is not provided. |
| 119 |
$field_show_label = sprintf(__('Show %s', 'firebox'), $field_label ?: __('value', 'firebox')); |
| 120 |
// translators: %s: Credential field label or "value" if label is not provided. |
| 121 |
$field_hide_label = sprintf(__('Hide %s', 'firebox'), $field_label ?: __('value', 'firebox')); |
| 122 |
?> |
| 123 |
<div class="fb-integration-credential-field"> |
| 124 |
<?php if (count($credential_fields) > 1): ?> |
| 125 |
<label class="fb-integration-credential-label" for="fb-integration-<?php echo esc_attr($slug . '-' . $field_key); ?>"> |
| 126 |
<?php echo esc_html($field_label); ?> |
| 127 |
</label> |
| 128 |
<?php endif; ?> |
| 129 |
<div class="fb-integration-input-control"> |
| 130 |
<input |
| 131 |
id="fb-integration-<?php echo esc_attr($slug . '-' . $field_key); ?>" |
| 132 |
type="<?php echo esc_attr($field_type); ?>" |
| 133 |
class="fpf-field-item fpf-control-input-item text fb-integration-credential-input<?php echo $connected ? ' is-readonly' : ''; ?>" |
| 134 |
autocomplete="off" |
| 135 |
value="<?php echo esc_attr($field_value); ?>" |
| 136 |
placeholder="<?php echo esc_attr($field_placeholder); ?>" |
| 137 |
aria-label="<?php echo esc_attr($field_label ?: $field_placeholder); ?>" |
| 138 |
data-field-key="<?php echo esc_attr($field_key); ?>" |
| 139 |
data-initial-type="<?php echo esc_attr($field_type); ?>" |
| 140 |
data-required="<?php echo esc_attr($field_required ? '1' : '0'); ?>" |
| 141 |
<?php // translators: %s: Credential field label or "this value" if label is not provided. ?> |
| 142 |
data-empty-message="<?php echo esc_attr(sprintf(__('Please enter %s.', 'firebox'), $field_label ?: __('this value', 'firebox'))); ?>" |
| 143 |
<?php echo $connected ? 'readonly="readonly"' : ''; ?> |
| 144 |
/> |
| 145 |
<?php if ($field_type === 'password'): ?> |
| 146 |
<button |
| 147 |
type="button" |
| 148 |
class="fpf-button fb-integration-visibility-toggle" |
| 149 |
aria-label="<?php echo esc_attr($field_show_label); ?>" |
| 150 |
title="<?php echo esc_attr($field_show_label); ?>" |
| 151 |
aria-pressed="false" |
| 152 |
data-show-label="<?php echo esc_attr($field_show_label ?: $show_secret_label); ?>" |
| 153 |
data-hide-label="<?php echo esc_attr($field_hide_label ?: $hide_secret_label); ?>" |
| 154 |
> |
| 155 |
<span class="dashicons dashicons-visibility" aria-hidden="true"></span> |
| 156 |
</button> |
| 157 |
<?php endif; ?> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
<?php endforeach; ?> |
| 161 |
</div> |
| 162 |
<div class="fb-integration-input-actions"> |
| 163 |
<button type="button" class="fpf-button primary fb-integration-connect<?php echo $connected ? ' hidden' : ''; ?>"> |
| 164 |
<?php echo esc_html(firebox()->_('FB_INTEGRATION_CONNECT')); ?> |
| 165 |
</button> |
| 166 |
<button type="button" class="fpf-button fb-integration-disconnect<?php echo !$connected ? ' hidden' : ''; ?>"> |
| 167 |
<?php echo esc_html(firebox()->_('FB_INTEGRATION_DISCONNECT')); ?> |
| 168 |
</button> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
<?php else: ?> |
| 172 |
<div class="fb-integration-plugin-wrapper"> |
| 173 |
<?php if (!empty($plugin_message)): ?> |
| 174 |
<div class="fb-integration-plugin-message"><?php echo esc_html($plugin_message); ?></div> |
| 175 |
<?php endif; ?> |
| 176 |
<?php if (!empty($plugin_action_url) && !empty($plugin_action_label)): ?> |
| 177 |
<a class="fpf-button primary fb-integration-plugin-action" href="<?php echo esc_url($plugin_action_url); ?>"> |
| 178 |
<?php echo esc_html($plugin_action_label); ?> |
| 179 |
</a> |
| 180 |
<?php endif; ?> |
| 181 |
</div> |
| 182 |
<?php endif; ?> |
| 183 |
|
| 184 |
<div class="fb-integration-message hidden"></div> |
| 185 |
</div> |
| 186 |
</div> |
| 187 |
<?php endforeach; ?> |
| 188 |
</div> |
| 189 |
</div> |
| 190 |
|