support-tools.php
118 lines
| 1 | <?php |
| 2 | |
| 3 | use CustomFacebookFeed\Admin\CFF_Support_Tool; |
| 4 | |
| 5 | if (!defined('ABSPATH')) { |
| 6 | return; |
| 7 | } |
| 8 | $role_id = CFF_Support_Tool::$plugin . CFF_Support_Tool::$role; |
| 9 | $cap = $role_id; |
| 10 | if (!current_user_can($cap)) { |
| 11 | return; |
| 12 | } |
| 13 | |
| 14 | $all_sources = CustomFacebookFeed\Builder\CFF_Feed_Builder::get_source_list(); |
| 15 | |
| 16 | if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'cff-api-check')) { |
| 17 | $results = $this->validate_and_sanitize_support_settings($_POST); |
| 18 | } |
| 19 | |
| 20 | |
| 21 | |
| 22 | ?> |
| 23 | <div class="cff_support_tools_wrap"> |
| 24 | <form method="post" action=""> |
| 25 | <?php wp_nonce_field('cff-api-check'); ?> |
| 26 | |
| 27 | <div class="cff_support_tools_field_group"> |
| 28 | <label for="sb_facebook_support_source"> |
| 29 | <?php esc_html_e('Connected Sources', 'custom-facebook-feed'); ?> |
| 30 | </label> |
| 31 | <select id="sb_facebook_support_source" name="sb_facebook_support_source"> |
| 32 | <option value="">Please Select</option> |
| 33 | <?php foreach ($all_sources as $source) : ?> |
| 34 | <option value="<?php echo esc_attr($source['id']); ?>"> |
| 35 | <?php echo esc_html($source['username']); ?> |
| 36 | ( |
| 37 | <?php echo esc_html($source['account_type']); ?> |
| 38 | <?php echo (!empty($source['privilege']) ? (' + ' . esc_html($source['privilege'])) : '') ?>) |
| 39 | </option> |
| 40 | <?php endforeach; ?> |
| 41 | </select> |
| 42 | </div> |
| 43 | <div class="cff_support_tools_field_group"> |
| 44 | <label for="sb_facebook_support_endpoint"> |
| 45 | <?php esc_html_e('Endpoint', 'custom-facebook-feed'); ?> |
| 46 | </label> |
| 47 | <select id="sb_facebook_support_endpoint" name="sb_facebook_support_endpoint"> |
| 48 | <?php foreach ($this->available_endpoints() as $key => $endpoint) : ?> |
| 49 | <option value="<?php echo esc_attr($key); ?>"> |
| 50 | <?php echo esc_html($endpoint); ?> |
| 51 | </option> |
| 52 | <?php endforeach; ?> |
| 53 | </select> |
| 54 | </div> |
| 55 | |
| 56 | <div class="cff_support_tools_field_group cff_support_tools_field_group_hide_show" |
| 57 | data-show="timeline,photos,videos,albums"> |
| 58 | <label for="sb_facebook_support_showby"> |
| 59 | <?php esc_html_e('Show Posts By', 'custom-facebook-feed'); ?> |
| 60 | </label> |
| 61 | <select id="sb_facebook_support_showby" name="sb_facebook_support_showby"> |
| 62 | <?php foreach ($this->available_timeline_showby() as $key => $showby) : ?> |
| 63 | <option value="<?php echo esc_attr($key); ?>"> |
| 64 | <?php echo esc_html($showby); ?> |
| 65 | </option> |
| 66 | <?php endforeach; ?> |
| 67 | </select> |
| 68 | </div> |
| 69 | |
| 70 | |
| 71 | <div class="cff_support_tools_field_group"> |
| 72 | <label for="sb_facebook_support_limit"> |
| 73 | <?php esc_html_e('Limit', 'custom-facebook-feed'); ?> |
| 74 | </label> |
| 75 | <input id="sb_facebook_support_limit" name="sb_facebook_support_limit" type="number"> |
| 76 | </div> |
| 77 | |
| 78 | <button class="button button-primary" type="submit">Submit</button> |
| 79 | |
| 80 | </form> |
| 81 | </div> |
| 82 | |
| 83 | |
| 84 | <style> |
| 85 | .cff_support_tools_wrap { |
| 86 | padding: 20px; |
| 87 | } |
| 88 | |
| 89 | .cff_support_tools_field_group { |
| 90 | margin-bottom: 20px; |
| 91 | width: 50%; |
| 92 | } |
| 93 | |
| 94 | .cff_support_tools_field_group label { |
| 95 | display: block; |
| 96 | font-weight: bold; |
| 97 | } |
| 98 | |
| 99 | .cff_support_tools_field_group>* { |
| 100 | width: 100%; |
| 101 | } |
| 102 | |
| 103 | .cff_support_tools_field_group_hide_show { |
| 104 | display: block; |
| 105 | } |
| 106 | </style> |
| 107 | |
| 108 | <script> |
| 109 | jQuery(function ($) { |
| 110 | $('#sb_facebook_support_endpoint').on('change', function () { |
| 111 | let endpoint = $(this).val(); |
| 112 | $('.cff_support_tools_field_group_hide_show').hide(); |
| 113 | $('.cff_support_tools_field_group_hide_show[data-show*="' + endpoint + '"]').show(); |
| 114 | }) |
| 115 | |
| 116 | }); |
| 117 | |
| 118 | </script> |