@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | |
159 | 159 | function trailingslashit( $string ) |
160 | 160 | { |
161 | - return untrailingslashit( $string ) . '/'; |
|
161 | + return untrailingslashit( $string ) . '/'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | function untrailingslashit( $string ) |
165 | 165 | { |
166 | - return rtrim( $string, '/\\' ); |
|
166 | + return rtrim( $string, '/\\' ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | function site_url() |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | public $term_relationships = "term_relationship"; |
289 | 289 | public $term_taxonomy = "term_taxonomy"; |
290 | 290 | |
291 | - } |
|
291 | + } |
|
292 | 292 | |
293 | 293 | class WP_Widget |
294 | 294 | { |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * to keep hidden, and a list of columns that are sortable. Each of these |
315 | 315 | * can be defined in another method (as we've done here) before being |
316 | 316 | * used to build the value for our _column_headers property. |
317 | - */ |
|
317 | + */ |
|
318 | 318 | $columns = $this->get_columns(); |
319 | 319 | $hidden = array(); |
320 | 320 | $sortable = $this->get_sortable_columns(); |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | * headers. The $this->_column_headers property takes an array which contains |
325 | 325 | * 3 other arrays. One for all columns, one for hidden columns, and one |
326 | 326 | * for sortable columns. |
327 | - */ |
|
327 | + */ |
|
328 | 328 | $this->_column_headers = array($columns, $hidden, $sortable); |
329 | 329 | |
330 | 330 | /** |
331 | 331 | * Optional. You can handle your bulk actions however you see fit. In this |
332 | 332 | * case, we'll handle them within our package just to keep things clean. |
333 | - */ |
|
333 | + */ |
|
334 | 334 | $this->process_bulk_action(); |
335 | 335 | |
336 | 336 | /** |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | * our data. In a real-world implementation, you will probably want to |
342 | 342 | * use sort and pagination data to build a custom query instead, as you'll |
343 | 343 | * be able to use your precisely-queried data immediately. |
344 | - */ |
|
344 | + */ |
|
345 | 345 | $data = $this->datas; |
346 | 346 | |
347 | 347 | /** |
348 | 348 | * REQUIRED for pagination. Let's figure out what page the user is currently |
349 | 349 | * looking at. We'll need this later, so you should always include it in |
350 | 350 | * your own package classes. |
351 | - */ |
|
351 | + */ |
|
352 | 352 | $current_page = $this->get_pagenum(); |
353 | 353 | |
354 | 354 | /** |
@@ -356,20 +356,20 @@ discard block |
||
356 | 356 | * In real-world use, this would be the total number of items in your database, |
357 | 357 | * without filtering. We'll need this later, so you should always include it |
358 | 358 | * in your own package classes. |
359 | - */ |
|
359 | + */ |
|
360 | 360 | $total_items = count($data); |
361 | 361 | |
362 | 362 | /** |
363 | 363 | * The WP_List_Table class does not handle pagination for us, so we need |
364 | 364 | * to ensure that the data is trimmed to only the current page. We can use |
365 | 365 | * array_slice() to |
366 | - */ |
|
366 | + */ |
|
367 | 367 | $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
368 | 368 | |
369 | 369 | /** |
370 | 370 | * REQUIRED. Now we can add our *sorted* data to the items property, where |
371 | 371 | * it can be used by the rest of the class. |
372 | - */ |
|
372 | + */ |
|
373 | 373 | $this->items = $data; |
374 | 374 | |
375 | 375 | /* REQUIRED. We also have to register our pagination options & calculations. */ |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | var $datas; |
17 | 17 | |
18 | 18 | /** ************************************************************************ |
19 | - * REQUIRED. Set up a constructor that references the parent constructor. We |
|
20 | - * use the parent reference to set some default configs. |
|
21 | - ***************************************************************************/ |
|
19 | + * REQUIRED. Set up a constructor that references the parent constructor. We |
|
20 | + * use the parent reference to set some default configs. |
|
21 | + ***************************************************************************/ |
|
22 | 22 | function __construct(){ |
23 | 23 | global $status, $page; |
24 | 24 | |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** ************************************************************************ |
47 | - * REQUIRED! This method dictates the table's columns and titles. This should |
|
48 | - * return an array where the key is the column slug (and class) and the value |
|
49 | - * is the column's title text. If you need a checkbox for bulk actions, refer |
|
50 | - * to the $columns array below. |
|
51 | - * |
|
52 | - * The 'cb' column is treated differently than the rest. If including a checkbox |
|
53 | - * column in your table you must create a column_cb() method. If you don't need |
|
54 | - * bulk actions or checkboxes, simply leave the 'cb' entry out of your array. |
|
55 | - * |
|
56 | - * @see WP_List_Table::::single_row_columns() |
|
57 | - * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
|
58 | - **************************************************************************/ |
|
47 | + * REQUIRED! This method dictates the table's columns and titles. This should |
|
48 | + * return an array where the key is the column slug (and class) and the value |
|
49 | + * is the column's title text. If you need a checkbox for bulk actions, refer |
|
50 | + * to the $columns array below. |
|
51 | + * |
|
52 | + * The 'cb' column is treated differently than the rest. If including a checkbox |
|
53 | + * column in your table you must create a column_cb() method. If you don't need |
|
54 | + * bulk actions or checkboxes, simply leave the 'cb' entry out of your array. |
|
55 | + * |
|
56 | + * @see WP_List_Table::::single_row_columns() |
|
57 | + * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
|
58 | + **************************************************************************/ |
|
59 | 59 | function get_columns(){ |
60 | 60 | $columns = array( |
61 | 61 | 'cb' => '',//'<input type="checkbox" />', //Render a checkbox instead of text |
@@ -69,26 +69,26 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** ************************************************************************ |
72 | - * Recommended. This method is called when the parent class can't find a method |
|
73 | - * specifically build for a given column. Generally, it's recommended to include |
|
74 | - * one method for each column you want to render, keeping your package class |
|
75 | - * neat and organized. For example, if the class needs to process a column |
|
76 | - * named 'title', it would first see if a method named $this->column_title() |
|
77 | - * exists - if it does, that method will be used. If it doesn't, this one will |
|
78 | - * be used. Generally, you should try to use custom column methods as much as |
|
79 | - * possible. |
|
80 | - * |
|
81 | - * Since we have defined a column_title() method later on, this method doesn't |
|
82 | - * need to concern itself with any column with a name of 'title'. Instead, it |
|
83 | - * needs to handle everything else. |
|
84 | - * |
|
85 | - * For more detailed insight into how columns are handled, take a look at |
|
86 | - * WP_List_Table::single_row_columns() |
|
87 | - * |
|
88 | - * @param array $item A singular item (one full row's worth of data) |
|
89 | - * @param array $column_name The name/slug of the column to be processed |
|
90 | - * @return string Text or HTML to be placed inside the column <td> |
|
91 | - **************************************************************************/ |
|
72 | + * Recommended. This method is called when the parent class can't find a method |
|
73 | + * specifically build for a given column. Generally, it's recommended to include |
|
74 | + * one method for each column you want to render, keeping your package class |
|
75 | + * neat and organized. For example, if the class needs to process a column |
|
76 | + * named 'title', it would first see if a method named $this->column_title() |
|
77 | + * exists - if it does, that method will be used. If it doesn't, this one will |
|
78 | + * be used. Generally, you should try to use custom column methods as much as |
|
79 | + * possible. |
|
80 | + * |
|
81 | + * Since we have defined a column_title() method later on, this method doesn't |
|
82 | + * need to concern itself with any column with a name of 'title'. Instead, it |
|
83 | + * needs to handle everything else. |
|
84 | + * |
|
85 | + * For more detailed insight into how columns are handled, take a look at |
|
86 | + * WP_List_Table::single_row_columns() |
|
87 | + * |
|
88 | + * @param array $item A singular item (one full row's worth of data) |
|
89 | + * @param array $column_name The name/slug of the column to be processed |
|
90 | + * @return string Text or HTML to be placed inside the column <td> |
|
91 | + **************************************************************************/ |
|
92 | 92 | function column_default($item, $column_name){ |
93 | 93 | switch($column_name){ |
94 | 94 | default: |
@@ -97,97 +97,97 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** ************************************************************************ |
100 | - * Recommended. This is a custom column method and is responsible for what |
|
101 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
102 | - * needs to render a column, it first looks for a method named |
|
103 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
104 | - * exist, column_default() is called instead. |
|
105 | - * |
|
106 | - * This example also illustrates how to implement rollover actions. Actions |
|
107 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
108 | - * will need to generate the URLs yourself. You could even ensure the links |
|
109 | - * |
|
110 | - * |
|
111 | - * @see WP_List_Table::::single_row_columns() |
|
112 | - * @param array $item A singular item (one full row's worth of data) |
|
113 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
114 | - **************************************************************************/ |
|
100 | + * Recommended. This is a custom column method and is responsible for what |
|
101 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
102 | + * needs to render a column, it first looks for a method named |
|
103 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
104 | + * exist, column_default() is called instead. |
|
105 | + * |
|
106 | + * This example also illustrates how to implement rollover actions. Actions |
|
107 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
108 | + * will need to generate the URLs yourself. You could even ensure the links |
|
109 | + * |
|
110 | + * |
|
111 | + * @see WP_List_Table::::single_row_columns() |
|
112 | + * @param array $item A singular item (one full row's worth of data) |
|
113 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
114 | + **************************************************************************/ |
|
115 | 115 | function column_id($item){ |
116 | 116 | return $item['id']; |
117 | 117 | } |
118 | 118 | /** ************************************************************************ |
119 | - * Recommended. This is a custom column method and is responsible for what |
|
120 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
121 | - * needs to render a column, it first looks for a method named |
|
122 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
123 | - * exist, column_default() is called instead. |
|
124 | - * |
|
125 | - * This example also illustrates how to implement rollover actions. Actions |
|
126 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
127 | - * will need to generate the URLs yourself. You could even ensure the links |
|
128 | - * |
|
129 | - * |
|
130 | - * @see WP_List_Table::::single_row_columns() |
|
131 | - * @param array $item A singular item (one full row's worth of data) |
|
132 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
133 | - **************************************************************************/ |
|
119 | + * Recommended. This is a custom column method and is responsible for what |
|
120 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
121 | + * needs to render a column, it first looks for a method named |
|
122 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
123 | + * exist, column_default() is called instead. |
|
124 | + * |
|
125 | + * This example also illustrates how to implement rollover actions. Actions |
|
126 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
127 | + * will need to generate the URLs yourself. You could even ensure the links |
|
128 | + * |
|
129 | + * |
|
130 | + * @see WP_List_Table::::single_row_columns() |
|
131 | + * @param array $item A singular item (one full row's worth of data) |
|
132 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
133 | + **************************************************************************/ |
|
134 | 134 | function column_status($item){ |
135 | 135 | return __($item['status'], 'wpshop'); |
136 | 136 | } |
137 | 137 | /** ************************************************************************ |
138 | - * Recommended. This is a custom column method and is responsible for what |
|
139 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
140 | - * needs to render a column, it first looks for a method named |
|
141 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
142 | - * exist, column_default() is called instead. |
|
143 | - * |
|
144 | - * This example also illustrates how to implement rollover actions. Actions |
|
145 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
146 | - * will need to generate the URLs yourself. You could even ensure the links |
|
147 | - * |
|
148 | - * |
|
149 | - * @see WP_List_Table::::single_row_columns() |
|
150 | - * @param array $item A singular item (one full row's worth of data) |
|
151 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
152 | - **************************************************************************/ |
|
138 | + * Recommended. This is a custom column method and is responsible for what |
|
139 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
140 | + * needs to render a column, it first looks for a method named |
|
141 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
142 | + * exist, column_default() is called instead. |
|
143 | + * |
|
144 | + * This example also illustrates how to implement rollover actions. Actions |
|
145 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
146 | + * will need to generate the URLs yourself. You could even ensure the links |
|
147 | + * |
|
148 | + * |
|
149 | + * @see WP_List_Table::::single_row_columns() |
|
150 | + * @param array $item A singular item (one full row's worth of data) |
|
151 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
152 | + **************************************************************************/ |
|
153 | 153 | function column_content($item){ |
154 | 154 | return $item['content']; |
155 | 155 | } |
156 | 156 | /** ************************************************************************ |
157 | - * Recommended. This is a custom column method and is responsible for what |
|
158 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
159 | - * needs to render a column, it first looks for a method named |
|
160 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
161 | - * exist, column_default() is called instead. |
|
162 | - * |
|
163 | - * This example also illustrates how to implement rollover actions. Actions |
|
164 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
165 | - * will need to generate the URLs yourself. You could even ensure the links |
|
166 | - * |
|
167 | - * |
|
168 | - * @see WP_List_Table::::single_row_columns() |
|
169 | - * @param array $item A singular item (one full row's worth of data) |
|
170 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
171 | - **************************************************************************/ |
|
157 | + * Recommended. This is a custom column method and is responsible for what |
|
158 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
159 | + * needs to render a column, it first looks for a method named |
|
160 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
161 | + * exist, column_default() is called instead. |
|
162 | + * |
|
163 | + * This example also illustrates how to implement rollover actions. Actions |
|
164 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
165 | + * will need to generate the URLs yourself. You could even ensure the links |
|
166 | + * |
|
167 | + * |
|
168 | + * @see WP_List_Table::::single_row_columns() |
|
169 | + * @param array $item A singular item (one full row's worth of data) |
|
170 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
171 | + **************************************************************************/ |
|
172 | 172 | function column_entity($item){ |
173 | 173 | return __($item['entity'],'wpshop'); |
174 | 174 | } |
175 | 175 | /** ************************************************************************ |
176 | - * Recommended. This is a custom column method and is responsible for what |
|
177 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
178 | - * needs to render a column, it first looks for a method named |
|
179 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
180 | - * exist, column_default() is called instead. |
|
181 | - * |
|
182 | - * This example also illustrates how to implement rollover actions. Actions |
|
183 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
184 | - * will need to generate the URLs yourself. You could even ensure the links |
|
185 | - * |
|
186 | - * |
|
187 | - * @see WP_List_Table::::single_row_columns() |
|
188 | - * @param array $item A singular item (one full row's worth of data) |
|
189 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
190 | - **************************************************************************/ |
|
176 | + * Recommended. This is a custom column method and is responsible for what |
|
177 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
178 | + * needs to render a column, it first looks for a method named |
|
179 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
180 | + * exist, column_default() is called instead. |
|
181 | + * |
|
182 | + * This example also illustrates how to implement rollover actions. Actions |
|
183 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
184 | + * will need to generate the URLs yourself. You could even ensure the links |
|
185 | + * |
|
186 | + * |
|
187 | + * @see WP_List_Table::::single_row_columns() |
|
188 | + * @param array $item A singular item (one full row's worth of data) |
|
189 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
190 | + **************************************************************************/ |
|
191 | 191 | function column_name($item){ |
192 | 192 | //Build row actions |
193 | 193 | $default_action='edit'; |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ); |
209 | 209 | } |
210 | 210 | /** ************************************************************************ |
211 | - * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column |
|
212 | - * is given special treatment when columns are processed. It ALWAYS needs to |
|
213 | - * have it's own method. |
|
214 | - * |
|
215 | - * @see WP_List_Table::::single_row_columns() |
|
216 | - * @param array $item A singular item (one full row's worth of data) |
|
217 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
218 | - **************************************************************************/ |
|
211 | + * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column |
|
212 | + * is given special treatment when columns are processed. It ALWAYS needs to |
|
213 | + * have it's own method. |
|
214 | + * |
|
215 | + * @see WP_List_Table::::single_row_columns() |
|
216 | + * @param array $item A singular item (one full row's worth of data) |
|
217 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
218 | + **************************************************************************/ |
|
219 | 219 | function column_cb($item){ |
220 | 220 | return ''; |
221 | 221 | return sprintf( |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | /** ************************************************************************ |
229 | - * Optional. If you want one or more columns to be sortable (ASC/DESC toggle), |
|
230 | - * you will need to register it here. This should return an array where the |
|
231 | - * key is the column that needs to be sortable, and the value is db column to |
|
232 | - * sort by. Often, the key and value will be the same, but this is not always |
|
233 | - * the case (as the value is a column name from the database, not the list table). |
|
234 | - * |
|
235 | - * This method merely defines which columns should be sortable and makes them |
|
236 | - * clickable - it does not handle the actual sorting. You still need to detect |
|
237 | - * the ORDERBY and ORDER querystring variables within prepare_items() and sort |
|
238 | - * your data accordingly (usually by modifying your query). |
|
239 | - * |
|
240 | - * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool) |
|
241 | - **************************************************************************/ |
|
229 | + * Optional. If you want one or more columns to be sortable (ASC/DESC toggle), |
|
230 | + * you will need to register it here. This should return an array where the |
|
231 | + * key is the column that needs to be sortable, and the value is db column to |
|
232 | + * sort by. Often, the key and value will be the same, but this is not always |
|
233 | + * the case (as the value is a column name from the database, not the list table). |
|
234 | + * |
|
235 | + * This method merely defines which columns should be sortable and makes them |
|
236 | + * clickable - it does not handle the actual sorting. You still need to detect |
|
237 | + * the ORDERBY and ORDER querystring variables within prepare_items() and sort |
|
238 | + * your data accordingly (usually by modifying your query). |
|
239 | + * |
|
240 | + * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool) |
|
241 | + **************************************************************************/ |
|
242 | 242 | function get_sortable_columns() { |
243 | 243 | $sortable_columns = array( |
244 | 244 | //'name' => array('name',true) //true means its already sorted |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** ************************************************************************ |
250 | - * Optional. If you need to include bulk actions in your list table, this is |
|
251 | - * the place to define them. Bulk actions are an associative array in the format |
|
252 | - * 'slug'=>'Visible Title' |
|
253 | - * |
|
254 | - * If this method returns an empty value, no bulk action will be rendered. If |
|
255 | - * you specify any bulk actions, the bulk actions box will be rendered with |
|
256 | - * the table automatically on display(). |
|
257 | - * |
|
258 | - * Also note that list tables are not automatically wrapped in <form> elements, |
|
259 | - * so you will need to create those manually in order for bulk actions to function. |
|
260 | - * |
|
261 | - * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles' |
|
262 | - **************************************************************************/ |
|
250 | + * Optional. If you need to include bulk actions in your list table, this is |
|
251 | + * the place to define them. Bulk actions are an associative array in the format |
|
252 | + * 'slug'=>'Visible Title' |
|
253 | + * |
|
254 | + * If this method returns an empty value, no bulk action will be rendered. If |
|
255 | + * you specify any bulk actions, the bulk actions box will be rendered with |
|
256 | + * the table automatically on display(). |
|
257 | + * |
|
258 | + * Also note that list tables are not automatically wrapped in <form> elements, |
|
259 | + * so you will need to create those manually in order for bulk actions to function. |
|
260 | + * |
|
261 | + * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles' |
|
262 | + **************************************************************************/ |
|
263 | 263 | function get_bulk_actions() { |
264 | 264 | $actions = array( |
265 | 265 | // 'delete' => __('Delete','wpshop') |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** ************************************************************************ |
271 | - * Optional. You can handle your bulk actions anywhere or anyhow you prefer. |
|
272 | - * For this example package, we will handle it in the class to keep things |
|
273 | - * clean and organized. |
|
274 | - * |
|
275 | - * @see $this->prepare_items() |
|
276 | - **************************************************************************/ |
|
271 | + * Optional. You can handle your bulk actions anywhere or anyhow you prefer. |
|
272 | + * For this example package, we will handle it in the class to keep things |
|
273 | + * clean and organized. |
|
274 | + * |
|
275 | + * @see $this->prepare_items() |
|
276 | + **************************************************************************/ |
|
277 | 277 | function process_bulk_action() { |
278 | 278 | //Detect when a bulk action is being triggered... |
279 | 279 | if( 'delete'===$this->current_action() ) { |
@@ -282,90 +282,90 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | /** ************************************************************************ |
285 | - * REQUIRED! This is where you prepare your data for display. This method will |
|
286 | - * usually be used to query the database, sort and filter the data, and generally |
|
287 | - * get it ready to be displayed. At a minimum, we should set $this->items and |
|
288 | - * $this->set_pagination_args(), although the following properties and methods |
|
289 | - * are frequently interacted with here... |
|
290 | - * |
|
291 | - * @uses $this->_column_headers |
|
292 | - * @uses $this->items |
|
293 | - * @uses $this->get_columns() |
|
294 | - * @uses $this->get_sortable_columns() |
|
295 | - * @uses $this->get_pagenum() |
|
296 | - * @uses $this->set_pagination_args() |
|
297 | - **************************************************************************/ |
|
285 | + * REQUIRED! This is where you prepare your data for display. This method will |
|
286 | + * usually be used to query the database, sort and filter the data, and generally |
|
287 | + * get it ready to be displayed. At a minimum, we should set $this->items and |
|
288 | + * $this->set_pagination_args(), although the following properties and methods |
|
289 | + * are frequently interacted with here... |
|
290 | + * |
|
291 | + * @uses $this->_column_headers |
|
292 | + * @uses $this->items |
|
293 | + * @uses $this->get_columns() |
|
294 | + * @uses $this->get_sortable_columns() |
|
295 | + * @uses $this->get_pagenum() |
|
296 | + * @uses $this->set_pagination_args() |
|
297 | + **************************************************************************/ |
|
298 | 298 | function prepare_items() { |
299 | 299 | /* First, lets decide how many records per page to show */ |
300 | 300 | $per_page = 10; |
301 | 301 | |
302 | 302 | /** |
303 | - * REQUIRED. Now we need to define our column headers. This includes a complete |
|
304 | - * array of columns to be displayed (slugs & titles), a list of columns |
|
305 | - * to keep hidden, and a list of columns that are sortable. Each of these |
|
306 | - * can be defined in another method (as we've done here) before being |
|
307 | - * used to build the value for our _column_headers property. |
|
308 | - */ |
|
303 | + * REQUIRED. Now we need to define our column headers. This includes a complete |
|
304 | + * array of columns to be displayed (slugs & titles), a list of columns |
|
305 | + * to keep hidden, and a list of columns that are sortable. Each of these |
|
306 | + * can be defined in another method (as we've done here) before being |
|
307 | + * used to build the value for our _column_headers property. |
|
308 | + */ |
|
309 | 309 | $columns = $this->get_columns(); |
310 | 310 | $hidden = array(); |
311 | 311 | $sortable = $this->get_sortable_columns(); |
312 | 312 | |
313 | 313 | /** |
314 | - * REQUIRED. Finally, we build an array to be used by the class for column |
|
315 | - * headers. The $this->_column_headers property takes an array which contains |
|
316 | - * 3 other arrays. One for all columns, one for hidden columns, and one |
|
317 | - * for sortable columns. |
|
318 | - */ |
|
314 | + * REQUIRED. Finally, we build an array to be used by the class for column |
|
315 | + * headers. The $this->_column_headers property takes an array which contains |
|
316 | + * 3 other arrays. One for all columns, one for hidden columns, and one |
|
317 | + * for sortable columns. |
|
318 | + */ |
|
319 | 319 | $this->_column_headers = array($columns, $hidden, $sortable); |
320 | 320 | |
321 | 321 | /** |
322 | - * Optional. You can handle your bulk actions however you see fit. In this |
|
323 | - * case, we'll handle them within our package just to keep things clean. |
|
324 | - */ |
|
322 | + * Optional. You can handle your bulk actions however you see fit. In this |
|
323 | + * case, we'll handle them within our package just to keep things clean. |
|
324 | + */ |
|
325 | 325 | $this->process_bulk_action(); |
326 | 326 | |
327 | 327 | /** |
328 | - * Instead of querying a database, we're going to fetch the example data |
|
329 | - * property we created for use in this plugin. This makes this example |
|
330 | - * package slightly different than one you might build on your own. In |
|
331 | - * this example, we'll be using array manipulation to sort and paginate |
|
332 | - * our data. In a real-world implementation, you will probably want to |
|
333 | - * use sort and pagination data to build a custom query instead, as you'll |
|
334 | - * be able to use your precisely-queried data immediately. |
|
335 | - */ |
|
328 | + * Instead of querying a database, we're going to fetch the example data |
|
329 | + * property we created for use in this plugin. This makes this example |
|
330 | + * package slightly different than one you might build on your own. In |
|
331 | + * this example, we'll be using array manipulation to sort and paginate |
|
332 | + * our data. In a real-world implementation, you will probably want to |
|
333 | + * use sort and pagination data to build a custom query instead, as you'll |
|
334 | + * be able to use your precisely-queried data immediately. |
|
335 | + */ |
|
336 | 336 | $data = $this->datas; |
337 | 337 | |
338 | 338 | /** |
339 | - * REQUIRED for pagination. Let's figure out what page the user is currently |
|
340 | - * looking at. We'll need this later, so you should always include it in |
|
341 | - * your own package classes. |
|
342 | - */ |
|
339 | + * REQUIRED for pagination. Let's figure out what page the user is currently |
|
340 | + * looking at. We'll need this later, so you should always include it in |
|
341 | + * your own package classes. |
|
342 | + */ |
|
343 | 343 | $current_page = $this->get_pagenum(); |
344 | 344 | |
345 | 345 | /** |
346 | - * REQUIRED for pagination. Let's check how many items are in our data array. |
|
347 | - * In real-world use, this would be the total number of items in your database, |
|
348 | - * without filtering. We'll need this later, so you should always include it |
|
349 | - * in your own package classes. |
|
350 | - */ |
|
346 | + * REQUIRED for pagination. Let's check how many items are in our data array. |
|
347 | + * In real-world use, this would be the total number of items in your database, |
|
348 | + * without filtering. We'll need this later, so you should always include it |
|
349 | + * in your own package classes. |
|
350 | + */ |
|
351 | 351 | $total_items = count($data); |
352 | 352 | |
353 | 353 | /** |
354 | - * The WP_List_Table class does not handle pagination for us, so we need |
|
355 | - * to ensure that the data is trimmed to only the current page. We can use |
|
356 | - * array_slice() to |
|
357 | - */ |
|
354 | + * The WP_List_Table class does not handle pagination for us, so we need |
|
355 | + * to ensure that the data is trimmed to only the current page. We can use |
|
356 | + * array_slice() to |
|
357 | + */ |
|
358 | 358 | $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
359 | 359 | |
360 | 360 | /** |
361 | - * REQUIRED. Now we can add our *sorted* data to the items property, where |
|
362 | - * it can be used by the rest of the class. |
|
363 | - */ |
|
361 | + * REQUIRED. Now we can add our *sorted* data to the items property, where |
|
362 | + * it can be used by the rest of the class. |
|
363 | + */ |
|
364 | 364 | $this->items = $data; |
365 | 365 | |
366 | 366 | /** |
367 | - * REQUIRED. We also have to register our pagination options & calculations. |
|
368 | - */ |
|
367 | + * REQUIRED. We also have to register our pagination options & calculations. |
|
368 | + */ |
|
369 | 369 | $this->set_pagination_args( array( |
370 | 370 | 'total_items' => $total_items, //WE have to calculate the total number of items |
371 | 371 | 'per_page' => $per_page, //WE have to determine how many items to show on a page |
@@ -1423,7 +1423,7 @@ |
||
1423 | 1423 | * @param string $attributeType The extension of the database table to get the attribute value in |
1424 | 1424 | * @param integer $attributeId The attribute identifier we want to get the value for |
1425 | 1425 | * @param integer $entityTypeId The entity type identifier we want to get the attribute value for (example: product = 1) |
1426 | - * @param integer $entityId The entity id we want the attribute value for |
|
1426 | + * @param integer $entityId The entity id we want the attribute value for |
|
1427 | 1427 | * |
1428 | 1428 | * @return object $attributeValue A wordpress database object containing the value of the attribute for the selected entity |
1429 | 1429 | */ |
@@ -23,8 +23,8 @@ |
||
23 | 23 | var $creating_account = true; |
24 | 24 | |
25 | 25 | /** Constructor of the class |
26 | - * @return void |
|
27 | - */ |
|
26 | + * @return void |
|
27 | + */ |
|
28 | 28 | function __construct () { |
29 | 29 | } |
30 | 30 |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | class wpshop_form { |
24 | 24 | |
25 | 25 | /** |
26 | - * Create The complete form by defining the form open and close and call the different function that allows to create the different type of input |
|
27 | - * |
|
28 | - * @param string $name The name of the form |
|
29 | - * @param array $input_list The list build by the database class' function that get the type of a table |
|
30 | - * @param string $method The default method for the form Default is set to post |
|
31 | - * @param string $action The default action for the form Default is set to empty |
|
32 | - * |
|
33 | - * @return mixed $the_form The complete html output of the form |
|
34 | - */ |
|
26 | + * Create The complete form by defining the form open and close and call the different function that allows to create the different type of input |
|
27 | + * |
|
28 | + * @param string $name The name of the form |
|
29 | + * @param array $input_list The list build by the database class' function that get the type of a table |
|
30 | + * @param string $method The default method for the form Default is set to post |
|
31 | + * @param string $action The default action for the form Default is set to empty |
|
32 | + * |
|
33 | + * @return mixed $the_form The complete html output of the form |
|
34 | + */ |
|
35 | 35 | function form($name, $input_list, $method = 'post', $action = ''){ |
36 | 36 | $the_form_content_hidden = $the_form_content = ''; |
37 | 37 | foreach ($input_list as $input_key => $input_def) { |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Check the input type |
|
72 | - * |
|
73 | - * @param array $input_def The input definition |
|
74 | - * |
|
75 | - * @return string $the_input |
|
76 | - */ |
|
71 | + * Check the input type |
|
72 | + * |
|
73 | + * @param array $input_def The input definition |
|
74 | + * |
|
75 | + * @return string $the_input |
|
76 | + */ |
|
77 | 77 | public static function check_input_type($input_def, $input_domain = '') { |
78 | 78 | |
79 | 79 | $input_option = ''; |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * Create an input type text or hidden or password |
|
126 | - * |
|
127 | - * @param string $name The name of the field given by the database |
|
128 | - * @param mixed $value The default value for the field Default is empty |
|
129 | - * @param string $type The input type Could be: text or hidden or passowrd |
|
130 | - * @param string $option Allows to define options for the input Could be readonly or disabled or style |
|
131 | - * |
|
132 | - * @return mixed The output code to add to the form |
|
133 | - */ |
|
125 | + * Create an input type text or hidden or password |
|
126 | + * |
|
127 | + * @param string $name The name of the field given by the database |
|
128 | + * @param mixed $value The default value for the field Default is empty |
|
129 | + * @param string $type The input type Could be: text or hidden or passowrd |
|
130 | + * @param string $option Allows to define options for the input Could be readonly or disabled or style |
|
131 | + * |
|
132 | + * @return mixed The output code to add to the form |
|
133 | + */ |
|
134 | 134 | public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){ |
135 | 135 | $allowedType = array('text', 'hidden', 'password', 'file'); |
136 | 136 | if(in_array($type, $allowedType)) |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | - * Create an textarea |
|
150 | - * |
|
151 | - * @param string $name The name of the field given by the database |
|
152 | - * @param mixed $value The default value for the field Default is empty |
|
153 | - * @param string $option Allows to define options for the input Could be maxlength or style |
|
154 | - * |
|
155 | - * @return mixed The output code to add to the form |
|
156 | - */ |
|
149 | + * Create an textarea |
|
150 | + * |
|
151 | + * @param string $name The name of the field given by the database |
|
152 | + * @param mixed $value The default value for the field Default is empty |
|
153 | + * @param string $option Allows to define options for the input Could be maxlength or style |
|
154 | + * |
|
155 | + * @return mixed The output code to add to the form |
|
156 | + */ |
|
157 | 157 | public static function form_input_textarea($name, $id, $value = '', $option = '') |
158 | 158 | { |
159 | 159 | return '<textarea name="' . $name.'" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>'; |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
164 | - * |
|
165 | - * @param string $name The name of the field given by the database |
|
166 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
167 | - * @param mixed $value The selected value for the field Default is empty |
|
168 | - * @param string $option Allows to define options for the input Could be onchange |
|
169 | - * |
|
170 | - * @return mixed $output The output code to add to the form |
|
171 | - */ |
|
163 | + * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
164 | + * |
|
165 | + * @param string $name The name of the field given by the database |
|
166 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
167 | + * @param mixed $value The selected value for the field Default is empty |
|
168 | + * @param string $option Allows to define options for the input Could be onchange |
|
169 | + * |
|
170 | + * @return mixed $output The output code to add to the form |
|
171 | + */ |
|
172 | 172 | public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){ |
173 | 173 | global $comboxOptionToHide; |
174 | 174 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
211 | - * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
212 | - * |
|
213 | - * @param string $name The name of the field given by the database |
|
214 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
215 | - * @param mixed $value The selected value for the field Default is empty |
|
216 | - * @param string $option Allows to define options for the input Could be onchange |
|
217 | - * |
|
218 | - * @return mixed $output The output code to add to the form |
|
219 | - */ |
|
211 | + * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
212 | + * |
|
213 | + * @param string $name The name of the field given by the database |
|
214 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
215 | + * @param mixed $value The selected value for the field Default is empty |
|
216 | + * @param string $option Allows to define options for the input Could be onchange |
|
217 | + * |
|
218 | + * @return mixed $output The output code to add to the form |
|
219 | + */ |
|
220 | 220 | public static function form_input_multiple_select($name, $id, $content, $value = array(), $option = '', $optionValue = '') { |
221 | 221 | global $comboxOptionToHide; |
222 | 222 | $values = array(); |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * Create a checkbox input |
|
253 | - * |
|
254 | - * @param string $name The name of the field given by the database |
|
255 | - * @param string $id The identifier of the field |
|
256 | - * @param string $type The input type Could be checkbox or radio |
|
257 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
258 | - * @param mixed $value The selected value for the field Default is empty |
|
259 | - * @param string $option Allows to define options for the input Could be onchange |
|
260 | - * |
|
261 | - * @return mixed $output The output code to add to the form |
|
262 | - */ |
|
252 | + * Create a checkbox input |
|
253 | + * |
|
254 | + * @param string $name The name of the field given by the database |
|
255 | + * @param string $id The identifier of the field |
|
256 | + * @param string $type The input type Could be checkbox or radio |
|
257 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
258 | + * @param mixed $value The selected value for the field Default is empty |
|
259 | + * @param string $option Allows to define options for the input Could be onchange |
|
260 | + * |
|
261 | + * @return mixed $output The output code to add to the form |
|
262 | + */ |
|
263 | 263 | public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){ |
264 | 264 | $output = ''; |
265 | 265 | $allowedType = array('checkbox', 'radio'); |
@@ -17,39 +17,39 @@ |
||
17 | 17 | class wpshop_display { |
18 | 18 | |
19 | 19 | /** |
20 | - * Returns the header display of a classical HTML page. |
|
21 | - * |
|
22 | - * @see afficherFinPage |
|
23 | - * |
|
24 | - * @param string $pageTitle Title of the page. |
|
25 | - * @param string $pageIcon Path of the icon. |
|
26 | - * @param string $iconTitle Title attribute of the icon. |
|
27 | - * @param string $iconAlt Alt attribute of the icon. |
|
28 | - * @param boolean $hasAddButton Define if there must be a "add" button for this page |
|
29 | - * @param string $actionInformationMessage A message to display in case of action is send |
|
30 | - * |
|
31 | - * @return string Html code composing the page header |
|
32 | - */ |
|
20 | + * Returns the header display of a classical HTML page. |
|
21 | + * |
|
22 | + * @see afficherFinPage |
|
23 | + * |
|
24 | + * @param string $pageTitle Title of the page. |
|
25 | + * @param string $pageIcon Path of the icon. |
|
26 | + * @param string $iconTitle Title attribute of the icon. |
|
27 | + * @param string $iconAlt Alt attribute of the icon. |
|
28 | + * @param boolean $hasAddButton Define if there must be a "add" button for this page |
|
29 | + * @param string $actionInformationMessage A message to display in case of action is send |
|
30 | + * |
|
31 | + * @return string Html code composing the page header |
|
32 | + */ |
|
33 | 33 | public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){ |
34 | 34 | include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php'); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Returns the end of a classical page |
|
39 | - * |
|
40 | - * @see displayPageHeader |
|
41 | - * |
|
42 | - * @return string Html code composing the page footer |
|
43 | - */ |
|
38 | + * Returns the end of a classical page |
|
39 | + * |
|
40 | + * @see displayPageHeader |
|
41 | + * |
|
42 | + * @return string Html code composing the page footer |
|
43 | + */ |
|
44 | 44 | public static function displayPageFooter($formActionButton){ |
45 | 45 | include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php'); |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | - * Return The complete output page code |
|
50 | - * |
|
51 | - * @return string The complete html page output |
|
52 | - */ |
|
49 | + * Return The complete output page code |
|
50 | + * |
|
51 | + * @return string The complete html page output |
|
52 | + */ |
|
53 | 53 | public static function display_page(){ |
54 | 54 | |
55 | 55 | $pageAddButton = false; |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Define the content for the widget |
|
37 | - * |
|
38 | - * @param mixed $instance The current widget instance |
|
39 | - */ |
|
36 | + * Define the content for the widget |
|
37 | + * |
|
38 | + * @param mixed $instance The current widget instance |
|
39 | + */ |
|
40 | 40 | function form($instance){ |
41 | 41 | $instance = wp_parse_args((array) $instance, array( |
42 | 42 | 'title' => '', |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * Widget Output |
|
76 | - * |
|
77 | - * @param array $args |
|
78 | - * @param array $instance Widget values. |
|
79 | - */ |
|
75 | + * Widget Output |
|
76 | + * |
|
77 | + * @param array $args |
|
78 | + * @param array $instance Widget values. |
|
79 | + */ |
|
80 | 80 | function widget($args, $instance){ |
81 | 81 | $widget_content = ''; |
82 | 82 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Get the sub categories of a given category |
|
100 | - * |
|
101 | - * @param integer $parent_category The main category we want to have the sub categories for |
|
102 | - */ |
|
99 | + * Get the sub categories of a given category |
|
100 | + * |
|
101 | + * @param integer $parent_category The main category we want to have the sub categories for |
|
102 | + */ |
|
103 | 103 | function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){ |
104 | 104 | $category_tree_output = ''; |
105 | 105 |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | |
219 | 219 | |
220 | 220 | /** |
221 | - * Reduce the stock regarding the order |
|
222 | - */ |
|
221 | + * Reduce the stock regarding the order |
|
222 | + */ |
|
223 | 223 | function the_order_payment_is_completed($order_id, $txn_id = null) { |
224 | 224 | // Donnees commandes |
225 | 225 | $order = get_post_meta($order_id, '_order_postmeta', true); |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Get payment method |
|
297 | - */ |
|
296 | + * Get payment method |
|
297 | + */ |
|
298 | 298 | function get_payment_method($post_id){ |
299 | 299 | $pm = __('Nc','wpshop'); |
300 | 300 | $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
324 | - * Set payment transaction number |
|
325 | - */ |
|
324 | + * Set payment transaction number |
|
325 | + */ |
|
326 | 326 | function display_payment_receiver_interface($post_id) { |
327 | 327 | $payment_validation = ''; |
328 | 328 | $display_button = false; |