| @@ -3,9 +3,15 @@ | ||
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | $wppm_default_task_list_view = get_option('wppm_default_task_list_view'); |
| 6 | 6 | $settings = get_option("wppm-ap-modal"); |
| 7 | -global $wpdb,$wppmfunction,$current_user; | |
| 7 | +$id = isset($_GET['task_id']) ? intval($_GET['task_id']) : 0; | |
| 8 | +$action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : 'view'; | |
| 9 | +$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; | |
| 10 | +$today_filter = isset( $_GET['wppm_task_filter'] ) | |
| 11 | + ? sanitize_key( wp_unslash( $_GET['wppm_task_filter'] ) ) | |
| 12 | + : ''; | |
| 13 | +global $wpdb,$wppmfunction,$current_user,$plugin_page; | |
| 8 | 14 | echo wp_kses_post(!empty($wppmfunction->wppm_load_setting_header_html()) ? $wppmfunction->wppm_load_setting_header_html() : ''); ?> |
| 9 | 15 | <div class="wppm_bootstrap"> |
| 10 | 16 | <div id="wppm_task_container"> |
| 11 | 17 | </div> |
| @@ -60,14 +66,28 @@ | ||
| 60 | 66 | color:<?php echo esc_attr( $settings['action-btn-text-color'])?>!important; |
| 61 | 67 | } |
| 62 | 68 | </style> |
| 63 | 69 | <script type="text/javascript"> |
| 64 | - jQuery( document ).ready( function( jQuery ) { | |
| 65 | - var task_list_view = <?php echo (int) ($wppm_default_task_list_view); ?>; | |
| 66 | - if(task_list_view == 1){ | |
| 67 | - wppm_get_task_list(); | |
| 70 | +var wppm_task_filter = <?php echo wp_json_encode( $today_filter ); ?>; | |
| 71 | +jQuery(document).ready(function($){ | |
| 72 | + var wppm_open_task_id = <?php echo intval($id); ?>; | |
| 73 | + var task_list_view = <?php echo (int) $wppm_default_task_list_view; ?>; | |
| 74 | + var wppm_action = <?php echo wp_json_encode($action); ?>; | |
| 75 | + if (wppm_open_task_id > 0) { | |
| 76 | + // Open specific task | |
| 77 | + wppm_open_task(wppm_open_task_id); | |
| 78 | + return; | |
| 68 | 79 | } |
| 69 | - if(task_list_view == 0){ | |
| 70 | - wppm_display_grid_view(); | |
| 80 | + if (wppm_action === 'add') { | |
| 81 | + // Open Add Task modal | |
| 82 | + wppm_add_new_task(); | |
| 83 | + return; | |
| 71 | 84 | } |
| 72 | - }) | |
| 85 | + // Default view | |
| 86 | + if (task_list_view == 1) { | |
| 87 | + wppm_get_task_list(); | |
| 88 | + } else { | |
| 89 | + wppm_display_grid_view(<?php echo wp_json_encode($page); ?>); | |
| 90 | + } | |
| 91 | + | |
| 92 | +}); | |
| 73 | 93 | </script> |