api-keys.php
156 lines
| 1 | <?php |
| 2 | /** |
| 3 | * API keys section under the "recaptcha" tab. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.0.4 |
| 7 | */ |
| 8 | |
| 9 | $types = array( |
| 10 | 'v2_checkbox' => array( |
| 11 | 'menu' => esc_html__( 'v2 Checkbox', 'hustle' ), |
| 12 | 'label' => esc_html__( 'reCAPTCHA v2 Checkbox', 'hustle' ), |
| 13 | ), |
| 14 | 'v2_invisible' => array( |
| 15 | 'menu' => esc_html__( 'v2 Invisible', 'hustle' ), |
| 16 | 'label' => esc_html__( 'reCAPTCHA v2 Invisible', 'hustle' ), |
| 17 | ), |
| 18 | 'v3_recaptcha' => array( |
| 19 | 'menu' => esc_html__( 'reCaptcha v3', 'hustle' ), |
| 20 | 'label' => esc_html__( 'reCAPTCHA v3', 'hustle' ), |
| 21 | ), |
| 22 | ); |
| 23 | ?> |
| 24 | |
| 25 | <div class="sui-form-field"> |
| 26 | |
| 27 | <label id="hustle-api-keys-label" class="sui-settings-label"><?php esc_html_e( 'API Keys', 'hustle' ); ?></label> |
| 28 | |
| 29 | <span id="hustle-api-keys-description" class="sui-description"> |
| 30 | <?php /* translators: 1. opening 'a' tag to recaptcha's list, 2. closing 'a' tag */ ?> |
| 31 | <?php printf( esc_html__( 'Enter the API keys for each reCAPTCHA type you want to use in your opt-ins. Note that each reCAPTCHA type requires a different set of API keys. %1$sGenerate API keys%2$s.', 'hustle' ), '<a href="https://www.google.com/recaptcha/admin#list" target="_blank">', '</a>' ); ?> |
| 32 | </span> |
| 33 | |
| 34 | <div class="sui-tabs sui-tabs-overflow" style="margin-top: 10px;"> |
| 35 | |
| 36 | <div role="tablist" class="sui-tabs-menu"> |
| 37 | |
| 38 | <?php |
| 39 | $i = 0; |
| 40 | foreach ( $types as $key => $text ) : |
| 41 | $i++; |
| 42 | ?> |
| 43 | |
| 44 | <button |
| 45 | type="button" |
| 46 | role="tab" |
| 47 | id="hustle-api-key-tab--<?php echo esc_attr( $key ); ?>" |
| 48 | class="sui-tab-item<?php echo ( 1 === $i ) ? ' active' : ''; ?>" |
| 49 | aria-controls="hustle-api-key-content--<?php echo esc_attr( $key ); ?>" |
| 50 | aria-selected="<?php echo ( 1 === $i ) ? 'true' : 'false'; ?>" |
| 51 | <?php echo ( 1 === $i ) ? '' : 'tabindex="-1"'; ?> |
| 52 | > |
| 53 | <?php echo esc_html( $text['menu'] ); ?> |
| 54 | </button> |
| 55 | |
| 56 | <?php |
| 57 | endforeach; |
| 58 | ?> |
| 59 | |
| 60 | </div> |
| 61 | |
| 62 | <div class="sui-tabs-content"> |
| 63 | |
| 64 | <?php |
| 65 | $i = 0; |
| 66 | foreach ( $types as $key => $text ) : |
| 67 | $i++; |
| 68 | ?> |
| 69 | |
| 70 | <div |
| 71 | role="tabpanel" |
| 72 | tabindex="0" |
| 73 | id="hustle-api-key-content--<?php echo esc_attr( $key ); ?>" |
| 74 | class="sui-tab-content<?php echo ( 1 === $i ) ? ' active' : ''; ?>" |
| 75 | aria-labelledby="hustle-api-key-tab--<?php echo esc_attr( $key ); ?>" |
| 76 | <?php echo ( 1 === $i ) ? '' : 'hidden'; ?> |
| 77 | > |
| 78 | |
| 79 | <?php /* translators: recaptcha key */ ?> |
| 80 | <span class="sui-description"><?php printf( esc_html__( 'Enter the API keys for %s type below:', 'hustle' ), esc_html( $text['label'] ) ); ?></span> |
| 81 | |
| 82 | <div class="sui-form-field"> |
| 83 | |
| 84 | <label for="hustle-<?php echo esc_attr( $key ); ?>-site-key" id="hustle-<?php echo esc_attr( $key ); ?>-site-key-label" class="sui-label"><?php esc_html_e( 'Site Key', 'hustle' ); ?></label> |
| 85 | |
| 86 | <input |
| 87 | type="text" |
| 88 | name="<?php echo esc_attr( $key . '_site_key' ); ?>" |
| 89 | value="<?php echo esc_attr( $settings[ $key . '_site_key' ] ); ?>" |
| 90 | placeholder="<?php esc_html_e( 'Enter your site key here', 'hustle' ); ?>" |
| 91 | id="hustle-<?php echo esc_attr( $key ); ?>-site-key" |
| 92 | class="sui-form-control" |
| 93 | aria-labelledby="hustle-<?php echo esc_attr( $key ); ?>-site-key-label" |
| 94 | /> |
| 95 | |
| 96 | </div> |
| 97 | |
| 98 | <div class="sui-form-field"> |
| 99 | |
| 100 | <label for="hustle-<?php echo esc_attr( $key ); ?>-secret-key" id="hustle-<?php echo esc_attr( $key ); ?>-site-secret-label" class="sui-label"><?php esc_html_e( 'Secret Key', 'hustle' ); ?></label> |
| 101 | |
| 102 | <input |
| 103 | type="text" |
| 104 | name="<?php echo esc_attr( $key . '_secret_key' ); ?>" |
| 105 | value="<?php echo esc_attr( $settings[ $key . '_secret_key' ] ); ?>" |
| 106 | placeholder="<?php esc_html_e( 'Enter your secret key here', 'hustle' ); ?>" |
| 107 | id="hustle-<?php echo esc_attr( $key ); ?>-secret-key" |
| 108 | class="sui-form-control" |
| 109 | aria-labelledby="hustle-<?php echo esc_attr( $key ); ?>-secret-key-label" |
| 110 | /> |
| 111 | |
| 112 | </div> |
| 113 | |
| 114 | <div class="sui-form-field" data-id="<?php echo esc_attr( $key ); ?>" data-render-id="0"> |
| 115 | |
| 116 | <label class="sui-label"><?php esc_html_e( 'reCAPTCHA Preview', 'hustle' ); ?></label> |
| 117 | |
| 118 | <div |
| 119 | id="hustle-modal-recaptcha-<?php echo esc_attr( $key ); ?>-0" |
| 120 | class="hustle-recaptcha-preview-container hustle-recaptcha" |
| 121 | style="display: none;" |
| 122 | data-sitekey="" |
| 123 | data-version="<?php echo esc_attr( $key ); ?>" |
| 124 | data-theme="light" |
| 125 | data-size="<?php echo 'v2_checkbox' === $key ? 'full' : 'invisible'; ?>" |
| 126 | data-badge="<?php echo 'v2_checkbox' === $key ? '' : 'inline'; ?>" |
| 127 | ></div> |
| 128 | |
| 129 | <?php |
| 130 | $this->get_html_for_options( |
| 131 | array( |
| 132 | array( |
| 133 | 'type' => 'inline_notice', |
| 134 | 'class' => 'hustle-recaptcha-' . esc_attr( $key ) . '-preview-notice', |
| 135 | 'icon' => 'info', |
| 136 | 'value' => esc_html__( 'Save your API keys to load the reCAPTCHA preview.', 'hustle' ), |
| 137 | 'attributes' => array( |
| 138 | 'style' => 'margin-top: 0;', |
| 139 | ), |
| 140 | ), |
| 141 | ) |
| 142 | ); |
| 143 | ?> |
| 144 | |
| 145 | </div> |
| 146 | |
| 147 | </div> |
| 148 | |
| 149 | <?php endforeach; ?> |
| 150 | |
| 151 | </div> |
| 152 | |
| 153 | </div> |
| 154 | |
| 155 | </div> |
| 156 |