PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.2
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.2
6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 57 releases
taskbuilder / includes / admin / settings / wppm_get_category_settings.php

wppm_get_category_settings.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.2, at includes/admin/settings/wppm_get_category_settings.php

169 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $current_user, $wpdb,$wppmfunction;
7 if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {
8 exit;
9 }
10 $wppm_ap_settings = get_option("wppm-ap-settings");
11 $orderby_sql = sanitize_sql_orderby( "load_order ASC");
12 $categories = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_project_categories ORDER BY $orderby_sql");
13 $cat_arr = array();
14 $cat_arr = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}wppm_project_categories");
15 if(!empty($cat_arr)){
16 foreach($cat_arr as $key=>$val){
17 $categories_array= json_decode(wp_json_encode($val));
18 $cat_ids[] = $categories_array->id;
19 }
20 $cat_ids = $wppmfunction->sanitize_array($cat_ids);
21 }
22 ?>
23 <div id="wppm_category_container">
24 <div class="wppm-help-container">
25 <a href="https://taskbuilder.net/docs/project-categories/" target="_blank"><?php echo esc_attr__( 'Click here', 'taskbuilder' )?></a> <?php echo esc_attr__( 'to see the documentation!', 'taskbuilder' )?>
26 </div>
27 <span class="wppm-title">
28 <?php echo esc_html_e('Project Categories','taskbuilder');?>
29 </span>
30 <span class="wppm-add-new-btn wppm_btn btn-primary" onclick="wppm_get_add_category()" style="margin-left:10px;background-color:<?php echo esc_attr($wppm_ap_settings['add-new-button-bg-color'])?>;color:<?php echo esc_attr($wppm_ap_settings['add-new-button-text-color'])?>;"><?php echo esc_html_e('+Add New','taskbuilder');?></span>
31 <div class="wppm_padding_space"></div>
32 <ul class="wppm-sortable">
33 <?php if(!empty($categories)){
34 foreach ($categories as $key=>$value){ ?>
35 <li class="ui-state-default" data-id="<?php echo intval(esc_attr($value->id))?>">
36 <div class="wppm-flex-container" style="border:1px solid #ddd">
37 <div class="wppm-sortable-handle"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/filter.svg'); ?>" alt="filter"></div>
38 <div class="wppm-sortable-label"><?php echo esc_html($value->name) ?></div>
39 <div class="wppm-sortable-edit" onclick="wppm_get_edit_category(<?php echo esc_attr($value->id) ?>);"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/edit1.svg'); ?>" alt="edit"></div>
40 <div class="wppm-sortable-delete" onclick="wppm_delete_category(<?php echo esc_attr($value->id) ?>);"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/trash.svg'); ?>" alt="delete"></div>
41 </div>
42 </li>
43 <?php }
44 }
45 ?>
46 </ul>
47 <input type="hidden" name="wppm_cat_order_ajax_nonce" id="wppm_cat_order_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_set_category_order' ) ); ?>">
48 <input type="hidden" name="wppm_delete_cat_ajax_nonce" id="wppm_delete_cat_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_delete_category' ) ); ?>">
49 <div>
50 <style>
51 #wppm_category_container .wppm-add-new-btn:hover{
52 background-color: <?php echo esc_attr($wppm_ap_settings['add-new-button-hover-color'])?>!important;
53 }
54 </style>
55 <script>
56 jQuery(function(){
57 jQuery( ".wppm-sortable" ).sortable({ handle: '.wppm-sortable-handle' });
58 jQuery( ".wppm-sortable" ).on("sortupdate",function(event,ui){
59 var keys = jQuery(this).sortable( "toArray", {attribute: 'data-id'} );
60 var order = <?php echo (!empty($cat_ids)) ? wp_json_encode($cat_ids):"0" ?>;
61 var result = {};
62 for (var i = 0; i < keys.length; i++){
63 result[keys[i]] = order[i];
64 }
65 var data = {
66 action: 'wppm_set_category_order',
67 load_orders : result,
68 _ajax_nonce:jQuery('#wppm_cat_order_ajax_nonce').val()
69 };
70 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
71 var response = JSON.parse(response_str);
72 if (response.sucess_status==1) {
73 jQuery('#wppm_alert_success').show();
74 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
75 }
76 jQuery('#wppm_alert_success').slideDown('fast',function(){});
77 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 2000);
78 });
79 });
80 });
81
82 function wppm_get_add_category(){
83 wppm_modal_open('Add Category');
84 var data = {
85 action: 'wppm_get_add_category'
86 };
87 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
88 var response = JSON.parse(response_str);
89 jQuery('#wppm_popup_body').html(response.body);
90 jQuery('#wppm_popup_footer').html(response.footer);
91 jQuery('#wppm_cat_name').focus();
92 });
93 }
94
95 function wppm_set_add_category(){
96 var cat_name = jQuery('#wppm_cat_name').val().trim();
97 if (cat_name.length == 0) {
98 jQuery('#wppm_cat_name').val('').focus();
99 return;
100 }
101 jQuery('.wppm_popup_action').text('<?php esc_js(__('Please wait ...','taskbuilder'))?>');
102 jQuery('.wppm_popup_action, #wppm_popup_body input').attr("disabled", "disabled");
103 var data = {
104 action: 'wppm_set_add_category',
105 cat_name : cat_name,
106 _ajax_nonce:jQuery('[name="_ajax_nonce"]').val()
107 };
108 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
109 wppm_modal_close();
110 var response = JSON.parse(response_str);
111 wppm_get_category_settings();
112 if (response.sucess_status=='1') {
113 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
114 jQuery('#wppm_alert_success').slideDown('fast',function(){});
115 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
116 wppm_get_category_settings();
117 } else {
118 jQuery('#wppm_alert_error .wppm_alert_text').text(response.messege);
119 jQuery('#wppm_alert_error').slideDown('fast',function(){});
120 setTimeout(function(){ jQuery('#wppm_alert_error').slideUp('fast',function(){}); }, 3000);
121 }
122 });
123 }
124
125 function wppm_get_edit_category(cat_id){
126 wppm_modal_open(wppm_admin.edit_category);
127 var data = {
128 action : 'wppm_get_edit_category',
129 cat_id:cat_id
130 };
131 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
132 var response = JSON.parse(response_str);
133 jQuery('#wppm_popup_body').html(response.body);
134 jQuery('#wppm_popup_footer').html(response.footer);
135 jQuery('#wppm_cat_name').focus();
136 });
137 }
138
139 function wppm_set_edit_category(cat_id){
140 var cat_name = jQuery('#wppm_edit_cat_name').val().trim();
141 if (cat_name.length == 0) {
142 jQuery('#wppm_edit_cat_name').val('').focus();
143 return;
144 }
145 jQuery('.wppm_popup_action').text('<?php esc_js(__('Please wait ...','taskbuilder'))?>');
146 jQuery('.wppm_popup_action, #wppm_popup_body input').attr("disabled", "disabled");
147 var data = {
148 action : 'wppm_set_edit_category',
149 cat_id:cat_id,
150 cat_name:cat_name,
151 _ajax_nonce:jQuery('[name="_ajax_nonce"]').val()
152 };
153 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
154 wppm_modal_close();
155 var response = JSON.parse(response_str);
156 wppm_get_category_settings();
157 if (response.sucess_status=='1') {
158 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
159 jQuery('#wppm_alert_success').slideDown('fast',function(){});
160 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
161 wppm_get_category_settings();
162 } else {
163 jQuery('#wppm_alert_error .wppm_alert_text').text(response.messege);
164 jQuery('#wppm_alert_error').slideDown('fast',function(){});
165 setTimeout(function(){ jQuery('#wppm_alert_error').slideUp('fast',function(){}); }, 3000);
166 }
167 });
168 }
169 </script>