st-admin-outgoing-req-page.php
1 month ago
st-admin-system-page.php
1 year ago
st-admin-troubleshooting-page.php
3 months ago
st-admin-system-page.php
79 lines
| 1 | <?php |
| 2 | /** |
| 3 | * SureTriggers System Page. |
| 4 | * php version 5.6 |
| 5 | * |
| 6 | * @package SureTriggers |
| 7 | * @author BSF <username@example.com> |
| 8 | */ |
| 9 | |
| 10 | use SureTriggers\Controllers\OptionController; |
| 11 | ?> |
| 12 | <table class="widefat suretriggers-system-table suretriggers-system-table-trigger" cellspacing="0"> |
| 13 | <thead> |
| 14 | <tr> |
| 15 | <th colspan="3"><h2><?php esc_html_e( 'Registered Events', 'suretriggers' ); ?></h2></th> |
| 16 | </tr> |
| 17 | </thead> |
| 18 | <tbody> |
| 19 | <?php |
| 20 | $saved_triggers = OptionController::get_option( 'triggers' ); |
| 21 | if ( ! empty( $saved_triggers ) ) { |
| 22 | $grouped_data = []; |
| 23 | foreach ( (array) $saved_triggers as $row ) { |
| 24 | if ( ! is_array( $row ) || ! isset( $row['trigger'], $row['integration'] ) ) { |
| 25 | continue; |
| 26 | } |
| 27 | $grouped_data[ $row['integration'] ][] = $row['trigger']; |
| 28 | } |
| 29 | $output = []; |
| 30 | foreach ( $grouped_data as $integration => $triggers ) { |
| 31 | $output[] = [ |
| 32 | 'integration' => $integration, |
| 33 | 'triggers' => array_unique( $triggers ), |
| 34 | ]; |
| 35 | } |
| 36 | foreach ( (array) $output as $key => $trigger ) { |
| 37 | $count = count( $trigger['triggers'] ); |
| 38 | ?> |
| 39 | <tr> |
| 40 | <th rowspan="<?php echo esc_attr( (string) $count ); ?>"><?php echo esc_html( (string) $trigger['integration'] ); ?></th> |
| 41 | <td><?php echo esc_html( $trigger['triggers'][0] ); ?></td> |
| 42 | </tr> |
| 43 | <?php |
| 44 | for ( $i = 1; $i < $count; $i++ ) { |
| 45 | ?> |
| 46 | <tr> |
| 47 | <td><?php echo esc_html( $trigger['triggers'][ $i ] ); ?></td> |
| 48 | </tr> |
| 49 | <?php |
| 50 | } |
| 51 | } |
| 52 | } else { |
| 53 | ?> |
| 54 | <tr> |
| 55 | <td> |
| 56 | <?php |
| 57 | echo esc_html__( 'No Trigger registered yet.', 'suretriggers' ); |
| 58 | ?> |
| 59 | </td> |
| 60 | <?php |
| 61 | } |
| 62 | ?> |
| 63 | </tbody> |
| 64 | </table> |
| 65 | <script> |
| 66 | document.addEventListener("DOMContentLoaded", function () { |
| 67 | const tableRows = document.querySelectorAll(".suretriggers-system-table tbody tr"); |
| 68 | let isOdd = true; |
| 69 | tableRows.forEach(row => { |
| 70 | if (row.querySelector("th")) { |
| 71 | isOdd = !isOdd; |
| 72 | } |
| 73 | if (isOdd) { |
| 74 | row.classList.add("odd-row"); |
| 75 | } |
| 76 | }); |
| 77 | }); |
| 78 | </script> |
| 79 |