Completed
Pull Request — master (#1039)
by
unknown
09:42
created
caffeinated/admin/new/pricing/Price_Types_List_Table.class.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -16,197 +16,197 @@
 block discarded – undo
16 16
 class Price_Types_List_Table extends EE_Admin_List_Table
17 17
 {
18 18
 
19
-    public function __construct($admin_page)
20
-    {
21
-        parent::__construct($admin_page);
22
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
23
-        $this->_PRT = EEM_Price_Type::instance();
24
-    }
25
-
26
-
27
-    protected function _setup_data()
28
-    {
29
-        $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
30
-        $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
31
-        $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
32
-        $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
33
-    }
34
-
35
-
36
-    protected function _set_properties()
37
-    {
38
-        $this->_wp_list_args = array(
39
-            'singular' => esc_html__('price type', 'event_espresso'),
40
-            'plural'   => esc_html__('price types', 'event_espresso'),
41
-            'ajax'     => true,
42
-            'screen'   => $this->_admin_page->get_current_screen()->id,
43
-        );
44
-
45
-        $this->_columns = array(
46
-            'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47
-            'name'      => esc_html__('Name', 'event_espresso'),
48
-            'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
49
-            'percent'   => '<div class="jst-cntr">'
50
-                           . sprintf(
51
-                               /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
52
-                               esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
53
-                               '<br/>',
54
-                               '<span class="big-text">',
55
-                               '</span>'
56
-                           )
57
-                           . '</div>',
58
-            'order'     => '<div class="jst-cntr">'
59
-                           . sprintf(
60
-                               /* translators: HTML new line */
61
-                               esc_html__('Order of %s Application', 'event_espresso'),
62
-                               '<br/>'
63
-                           )
64
-                           . '</div>',
65
-        );
66
-
67
-        $this->_sortable_columns = array(
68
-            // TRUE means its already sorted
69
-            'name' => array('name' => false),
70
-        );
71
-
72
-        $this->_hidden_columns = array();
73
-    }
74
-
75
-
76
-    protected function _get_table_filters()
77
-    {
78
-    }
79
-
80
-
81
-    protected function _add_view_counts()
82
-    {
83
-        $this->_views['all']['count'] = $this->_all_data_count;
84
-        if (EE_Registry::instance()->CAP->current_user_can(
85
-            'ee_delete_default_price_types',
86
-            'pricing_trash_price_type'
87
-        )) {
88
-            $this->_views['trashed']['count'] = $this->_trashed_count;
89
-        }
90
-    }
91
-
92
-
93
-    public function column_cb($item)
94
-    {
95
-        if ($item->base_type() !== 1) {
96
-            return sprintf(
97
-                '<input type="checkbox" name="checkbox[%1$s]" />',
98
-                $item->ID()
99
-            );
100
-        }
101
-        return '';
102
-    }
103
-
104
-
105
-    public function column_name($item)
106
-    {
107
-
108
-        // Build row actions
109
-        $actions = array();
110
-        // edit price link
111
-        if (EE_Registry::instance()->CAP->current_user_can(
112
-            'ee_edit_default_price_type',
113
-            'pricing_edit_price_type',
114
-            $item->ID()
115
-        )) {
116
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
117
-                'action' => 'edit_price_type',
118
-                'id'     => $item->ID(),
119
-            ), PRICING_ADMIN_URL);
120
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
121
-                               . esc_attr__('Edit Price Type', 'event_espresso') . '">'
122
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
123
-        }
124
-
125
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
126
-            'ee_edit_default_price_type',
127
-            'pricing_edit_price_type',
128
-            $item->ID()
129
-        )
130
-            ? '<a href="' . $edit_lnk_url . '" title="'
131
-              . esc_attr__('Edit Price Type', 'event_espresso') . '">'
132
-              . stripslashes($item->name()) . '</a>'
133
-            : $item->name();
134
-
135
-        if ($item->base_type() !== 1) {
136
-            if ($this->_view == 'all') {
137
-                // trash price link
138
-                if (EE_Registry::instance()->CAP->current_user_can(
139
-                    'ee_delete_default_price_type',
140
-                    'pricing_trash_price_type',
141
-                    $item->ID()
142
-                )) {
143
-                    $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
144
-                        'action'   => 'trash_price_type',
145
-                        'id'       => $item->ID(),
146
-                        'noheader' => true,
147
-                    ), PRICING_ADMIN_URL);
148
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
149
-                                        . esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
150
-                                        . esc_html__('Move to Trash', 'event_espresso') . '</a>';
151
-                }
152
-            } else {
153
-                // restore price link
154
-                if (EE_Registry::instance()->CAP->current_user_can(
155
-                    'ee_delete_default_price_type',
156
-                    'pricing_restore_price_type',
157
-                    $item->ID()
158
-                )) {
159
-                    $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
160
-                        'action'   => 'restore_price_type',
161
-                        'id'       => $item->ID(),
162
-                        'noheader' => true,
163
-                    ), PRICING_ADMIN_URL);
164
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
165
-                                          . esc_attr__('Restore Price Type', 'event_espresso') . '">'
166
-                                          . esc_html__('Restore', 'event_espresso') . '</a>';
167
-                }
168
-                // delete price link
169
-                if (EE_Registry::instance()->CAP->current_user_can(
170
-                    'ee_delete_default_price_type',
171
-                    'pricing_delete_price_type',
172
-                    $item->ID()
173
-                )) {
174
-                    $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
175
-                        'action'   => 'delete_price_type',
176
-                        'id'       => $item->ID(),
177
-                        'noheader' => true,
178
-                    ), PRICING_ADMIN_URL);
179
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
180
-                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
181
-                                         . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
182
-                }
183
-            }
184
-        }
185
-
186
-        // Return the name contents
187
-        return sprintf(
188
-            '%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
189
-            $name_link,
190
-            $item->ID(),
191
-            $this->row_actions($actions)
192
-        );
193
-    }
194
-
195
-
196
-    public function column_base_type($item)
197
-    {
198
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
199
-    }
200
-
201
-
202
-    public function column_percent($item)
203
-    {
204
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
205
-    }
206
-
207
-
208
-    public function column_order($item)
209
-    {
210
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
211
-    }
19
+	public function __construct($admin_page)
20
+	{
21
+		parent::__construct($admin_page);
22
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
23
+		$this->_PRT = EEM_Price_Type::instance();
24
+	}
25
+
26
+
27
+	protected function _setup_data()
28
+	{
29
+		$trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
30
+		$this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
31
+		$this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
32
+		$this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
33
+	}
34
+
35
+
36
+	protected function _set_properties()
37
+	{
38
+		$this->_wp_list_args = array(
39
+			'singular' => esc_html__('price type', 'event_espresso'),
40
+			'plural'   => esc_html__('price types', 'event_espresso'),
41
+			'ajax'     => true,
42
+			'screen'   => $this->_admin_page->get_current_screen()->id,
43
+		);
44
+
45
+		$this->_columns = array(
46
+			'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47
+			'name'      => esc_html__('Name', 'event_espresso'),
48
+			'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
49
+			'percent'   => '<div class="jst-cntr">'
50
+						   . sprintf(
51
+							   /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
52
+							   esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
53
+							   '<br/>',
54
+							   '<span class="big-text">',
55
+							   '</span>'
56
+						   )
57
+						   . '</div>',
58
+			'order'     => '<div class="jst-cntr">'
59
+						   . sprintf(
60
+							   /* translators: HTML new line */
61
+							   esc_html__('Order of %s Application', 'event_espresso'),
62
+							   '<br/>'
63
+						   )
64
+						   . '</div>',
65
+		);
66
+
67
+		$this->_sortable_columns = array(
68
+			// TRUE means its already sorted
69
+			'name' => array('name' => false),
70
+		);
71
+
72
+		$this->_hidden_columns = array();
73
+	}
74
+
75
+
76
+	protected function _get_table_filters()
77
+	{
78
+	}
79
+
80
+
81
+	protected function _add_view_counts()
82
+	{
83
+		$this->_views['all']['count'] = $this->_all_data_count;
84
+		if (EE_Registry::instance()->CAP->current_user_can(
85
+			'ee_delete_default_price_types',
86
+			'pricing_trash_price_type'
87
+		)) {
88
+			$this->_views['trashed']['count'] = $this->_trashed_count;
89
+		}
90
+	}
91
+
92
+
93
+	public function column_cb($item)
94
+	{
95
+		if ($item->base_type() !== 1) {
96
+			return sprintf(
97
+				'<input type="checkbox" name="checkbox[%1$s]" />',
98
+				$item->ID()
99
+			);
100
+		}
101
+		return '';
102
+	}
103
+
104
+
105
+	public function column_name($item)
106
+	{
107
+
108
+		// Build row actions
109
+		$actions = array();
110
+		// edit price link
111
+		if (EE_Registry::instance()->CAP->current_user_can(
112
+			'ee_edit_default_price_type',
113
+			'pricing_edit_price_type',
114
+			$item->ID()
115
+		)) {
116
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
117
+				'action' => 'edit_price_type',
118
+				'id'     => $item->ID(),
119
+			), PRICING_ADMIN_URL);
120
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
121
+							   . esc_attr__('Edit Price Type', 'event_espresso') . '">'
122
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
123
+		}
124
+
125
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
126
+			'ee_edit_default_price_type',
127
+			'pricing_edit_price_type',
128
+			$item->ID()
129
+		)
130
+			? '<a href="' . $edit_lnk_url . '" title="'
131
+			  . esc_attr__('Edit Price Type', 'event_espresso') . '">'
132
+			  . stripslashes($item->name()) . '</a>'
133
+			: $item->name();
134
+
135
+		if ($item->base_type() !== 1) {
136
+			if ($this->_view == 'all') {
137
+				// trash price link
138
+				if (EE_Registry::instance()->CAP->current_user_can(
139
+					'ee_delete_default_price_type',
140
+					'pricing_trash_price_type',
141
+					$item->ID()
142
+				)) {
143
+					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
144
+						'action'   => 'trash_price_type',
145
+						'id'       => $item->ID(),
146
+						'noheader' => true,
147
+					), PRICING_ADMIN_URL);
148
+					$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
149
+										. esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
150
+										. esc_html__('Move to Trash', 'event_espresso') . '</a>';
151
+				}
152
+			} else {
153
+				// restore price link
154
+				if (EE_Registry::instance()->CAP->current_user_can(
155
+					'ee_delete_default_price_type',
156
+					'pricing_restore_price_type',
157
+					$item->ID()
158
+				)) {
159
+					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
160
+						'action'   => 'restore_price_type',
161
+						'id'       => $item->ID(),
162
+						'noheader' => true,
163
+					), PRICING_ADMIN_URL);
164
+					$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
165
+										  . esc_attr__('Restore Price Type', 'event_espresso') . '">'
166
+										  . esc_html__('Restore', 'event_espresso') . '</a>';
167
+				}
168
+				// delete price link
169
+				if (EE_Registry::instance()->CAP->current_user_can(
170
+					'ee_delete_default_price_type',
171
+					'pricing_delete_price_type',
172
+					$item->ID()
173
+				)) {
174
+					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
175
+						'action'   => 'delete_price_type',
176
+						'id'       => $item->ID(),
177
+						'noheader' => true,
178
+					), PRICING_ADMIN_URL);
179
+					$actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
180
+										 . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
181
+										 . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
182
+				}
183
+			}
184
+		}
185
+
186
+		// Return the name contents
187
+		return sprintf(
188
+			'%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
189
+			$name_link,
190
+			$item->ID(),
191
+			$this->row_actions($actions)
192
+		);
193
+	}
194
+
195
+
196
+	public function column_base_type($item)
197
+	{
198
+		return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
199
+	}
200
+
201
+
202
+	public function column_percent($item)
203
+	{
204
+		return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
205
+	}
206
+
207
+
208
+	public function column_order($item)
209
+	{
210
+		return '<div class="jst-cntr">' . $item->order() . '</div>';
211
+	}
212 212
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($admin_page)
20 20
     {
21 21
         parent::__construct($admin_page);
22
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
22
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
23 23
         $this->_PRT = EEM_Price_Type::instance();
24 24
     }
25 25
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $this->_columns = array(
46 46
             'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47 47
             'name'      => esc_html__('Name', 'event_espresso'),
48
-            'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
48
+            'base_type' => '<div class="jst-cntr">'.__('Base Type', 'event_espresso').'</div>',
49 49
             'percent'   => '<div class="jst-cntr">'
50 50
                            . sprintf(
51 51
                                /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                 'action' => 'edit_price_type',
118 118
                 'id'     => $item->ID(),
119 119
             ), PRICING_ADMIN_URL);
120
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
121
-                               . esc_attr__('Edit Price Type', 'event_espresso') . '">'
122
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
120
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
121
+                               . esc_attr__('Edit Price Type', 'event_espresso').'">'
122
+                               . esc_html__('Edit', 'event_espresso').'</a>';
123 123
         }
124 124
 
125 125
         $name_link = EE_Registry::instance()->CAP->current_user_can(
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
             'pricing_edit_price_type',
128 128
             $item->ID()
129 129
         )
130
-            ? '<a href="' . $edit_lnk_url . '" title="'
131
-              . esc_attr__('Edit Price Type', 'event_espresso') . '">'
132
-              . stripslashes($item->name()) . '</a>'
130
+            ? '<a href="'.$edit_lnk_url.'" title="'
131
+              . esc_attr__('Edit Price Type', 'event_espresso').'">'
132
+              . stripslashes($item->name()).'</a>'
133 133
             : $item->name();
134 134
 
135 135
         if ($item->base_type() !== 1) {
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
                         'id'       => $item->ID(),
146 146
                         'noheader' => true,
147 147
                     ), PRICING_ADMIN_URL);
148
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
149
-                                        . esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
150
-                                        . esc_html__('Move to Trash', 'event_espresso') . '</a>';
148
+                    $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
149
+                                        . esc_attr__('Move Price Type to Trash', 'event_espresso').'">'
150
+                                        . esc_html__('Move to Trash', 'event_espresso').'</a>';
151 151
                 }
152 152
             } else {
153 153
                 // restore price link
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
                         'id'       => $item->ID(),
162 162
                         'noheader' => true,
163 163
                     ), PRICING_ADMIN_URL);
164
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
165
-                                          . esc_attr__('Restore Price Type', 'event_espresso') . '">'
166
-                                          . esc_html__('Restore', 'event_espresso') . '</a>';
164
+                    $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
165
+                                          . esc_attr__('Restore Price Type', 'event_espresso').'">'
166
+                                          . esc_html__('Restore', 'event_espresso').'</a>';
167 167
                 }
168 168
                 // delete price link
169 169
                 if (EE_Registry::instance()->CAP->current_user_can(
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
                         'id'       => $item->ID(),
177 177
                         'noheader' => true,
178 178
                     ), PRICING_ADMIN_URL);
179
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
180
-                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
181
-                                         . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
179
+                    $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'
180
+                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso').'">'
181
+                                         . esc_html__('Delete Permanently', 'event_espresso').'</a>';
182 182
                 }
183 183
             }
184 184
         }
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
 
196 196
     public function column_base_type($item)
197 197
     {
198
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
198
+        return '<div class="jst-cntr">'.$item->base_type_name().'</div>';
199 199
     }
200 200
 
201 201
 
202 202
     public function column_percent($item)
203 203
     {
204
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
204
+        return '<div class="jst-cntr">'.($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign).'</div>';
205 205
     }
206 206
 
207 207
 
208 208
     public function column_order($item)
209 209
     {
210
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
210
+        return '<div class="jst-cntr">'.$item->order().'</div>';
211 211
     }
212 212
 }
Please login to merge, or discard this patch.