support-tools.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | use SmashBalloon\Reviews\Common\Admin\SBR_Support_Tool; |
| 4 | |
| 5 | if (!defined('ABSPATH')) { |
| 6 | return; |
| 7 | } |
| 8 | $role_id = SBR_Support_Tool::$plugin . SBR_Support_Tool::$role; |
| 9 | $cap = $role_id; |
| 10 | if (!current_user_can($cap)) { |
| 11 | return; |
| 12 | } |
| 13 | |
| 14 | |
| 15 | $all_sources = \SmashBalloon\Reviews\Common\Customizer\Db::get_facebook_sources(); |
| 16 | if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'sbr-api-check')) { |
| 17 | $results = $this->validate_and_sanitize_support_settings($_POST); |
| 18 | } |
| 19 | |
| 20 | |
| 21 | |
| 22 | ?> |
| 23 | <div class="sbr_support_tools_wrap"> |
| 24 | <form method="post" action=""> |
| 25 | <?php wp_nonce_field('sbr-api-check'); ?> |
| 26 | |
| 27 | <div class="sbr_support_tools_field_group"> |
| 28 | <label for="sb_reviews_support_source"> |
| 29 | <?php esc_html_e('Connected Sources', 'custom-reviews-feed'); ?> |
| 30 | </label> |
| 31 | <select id="sb_reviews_support_source" name="sb_reviews_support_source"> |
| 32 | <option value="">Please Select</option> |
| 33 | <?php foreach ($all_sources as $source): ?> |
| 34 | <option value="<?php echo esc_attr($source['account_id']); ?>"> |
| 35 | <?php echo esc_html($source['name']); ?> |
| 36 | </option> |
| 37 | <?php endforeach; ?> |
| 38 | </select> |
| 39 | </div> |
| 40 | <div class="sbr_support_tools_field_group"> |
| 41 | <label for="sb_reviews_support_endpoint"> |
| 42 | <?php esc_html_e('Endpoint', 'custom-reviews-feed'); ?> |
| 43 | </label> |
| 44 | <select id="sb_reviews_support_endpoint" name="sb_reviews_support_endpoint"> |
| 45 | <?php foreach ($this->available_endpoints() as $key => $endpoint): ?> |
| 46 | <option value="<?php echo esc_attr($key); ?>"> |
| 47 | <?php echo esc_html($endpoint); ?> |
| 48 | </option> |
| 49 | <?php endforeach; ?> |
| 50 | </select> |
| 51 | </div> |
| 52 | |
| 53 | <button class="button button-primary" type="submit">Submit</button> |
| 54 | |
| 55 | </form> |
| 56 | </div> |
| 57 | |
| 58 | |
| 59 | <style> |
| 60 | .sbr_support_tools_wrap { |
| 61 | padding: 20px; |
| 62 | padding-top: 50px; |
| 63 | } |
| 64 | |
| 65 | .sbr_support_tools_field_group { |
| 66 | margin-bottom: 20px; |
| 67 | width: 50%; |
| 68 | } |
| 69 | |
| 70 | .sbr_support_tools_field_group label { |
| 71 | display: block; |
| 72 | font-weight: bold; |
| 73 | } |
| 74 | |
| 75 | .sbr_support_tools_field_group>* { |
| 76 | width: 100%; |
| 77 | } |
| 78 | |
| 79 | .sbr_support_tools_field_group_hide_show { |
| 80 | display: block; |
| 81 | } |
| 82 | </style> |
| 83 | |
| 84 | <script> |
| 85 | jQuery(function ($) { |
| 86 | $('#sb_reviews_support_endpoint').on('change', function () { |
| 87 | let endpoint = $(this).val(); |
| 88 | $('.sbr_support_tools_field_group_hide_show').hide(); |
| 89 | $('.sbr_support_tools_field_group_hide_show[data-show*="' + endpoint + '"]').show(); |
| 90 | }) |
| 91 | |
| 92 | }); |
| 93 | |
| 94 | </script> |