PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.2.7
Advanced Ads – Ad Manager & AdSense v1.2.7
2.0.26 2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / admin / includes / class-ad-groups-list-table.php
advanced-ads / admin / includes Last commit date
class-ad-groups-list-table.php 11 years ago class-display-condition-callbacks.php 11 years ago class-list-table.php 12 years ago index.php 12 years ago
class-ad-groups-list-table.php
291 lines
1 <?php
2
3 /**
4 * Groups List Table class.
5 *
6 * derrived from WP_Terms_List_Table
7 *
8 * @package WordPress
9 * @subpackage List_Table
10 * @since 3.1.0
11 * @access private
12 */
13 class AdvAds_Groups_List_Table extends AdvAds_List_Table {
14
15 /**
16 * constructor
17 *
18 * @since 1.0.0
19 * @global type $status
20 * @global type $page
21 */
22 function __construct() {
23 global $status, $page;
24
25 parent::__construct(array(
26 'plural' => 'adgroups',
27 'singular' => 'adgroup',
28 ));
29
30 $this->post_type = Advanced_Ads::POST_TYPE_SLUG;
31 $this->taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
32 }
33
34 /**
35 * default column handling
36 *
37 * @since 1.0.0
38 * @param type $item
39 * @param type $column_name
40 * @return output for the column
41 */
42 function column_default($item, $column_name) {
43 return apply_filters("manage_{$this->taxonomy}_{$column_name}_column", '', $column_name, $item->term_id);
44 }
45
46 /**
47 * handle checkbox column
48 *
49 * @since 1.0.ß
50 * @see WP_List_Table::::single_row_columns()
51 * @param array $item A singular item (one full row's worth of data)
52 * @return string Text to be placed inside the column <td> (movie title only)
53 */
54 function column_cb($tag) {
55 $default_term = get_option('default_' . $this->screen->taxonomy);
56
57 return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf(__('Select %s', ADVADS_SLUG), $tag->name) . '</label>'
58 . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
59
60 return '&nbsp;';
61 }
62
63 /**
64 * column with the ad group id
65 * @since 1.0.0
66 * @param type $tag
67 * @return string
68 */
69 function column_id($tag) {
70 return $tag->term_id;
71 }
72
73 /**
74 * render the basic ad group information
75 *
76 * @since 1.0.0
77 * @param obj $tag
78 * @return string
79 */
80 function column_name($tag) {
81 $tax = get_taxonomy($this->taxonomy);
82
83 $default_term = get_option('default_' . $this->taxonomy);
84
85 $name = apply_filters('term_name', $tag->name, $tag);
86 $qe_data = get_term($tag->term_id, $this->taxonomy, OBJECT, 'edit');
87 // $edit_link = esc_url(get_edit_term_link($tag->term_id, $this->taxonomy, $this->screen->post_type));
88 $args = array(
89 'action' => 'edit',
90 'group_id' => $tag->term_id
91 );
92 $edit_link = Advanced_Ads_Admin::group_page_url($args);
93
94 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;', ADVADS_SLUG), $name)) . '">' . $name . '</a></strong><br />';
95 $out .= '<p class="description">' . $tag->description . '</p>';
96
97 $actions = array();
98 if (current_user_can($tax->cap->edit_terms)) {
99 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit', ADVADS_SLUG) . '</a>';
100 // $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
101 }
102 if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term){
103 $args = array(
104 'action' => 'delete',
105 'group_id' => $tag->term_id
106 );
107 $delete_link = Advanced_Ads_Admin::group_page_url($args);
108 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url($delete_link, 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
109 }
110
111 $actions = apply_filters("{$this->taxonomy}_row_actions", $actions, $tag);
112
113 $out .= $this->row_actions($actions);
114 $out .= '</div>';
115
116 return $out;
117 }
118
119 /**
120 * render the slug column
121 *
122 * @since 1.0.0
123 * @param obj $tag
124 * @return string
125 */
126 function column_slug($tag) {
127 return apply_filters('editable_slug', $tag->slug);
128 }
129
130 /**
131 * render the ads column (number of ads belonging to this group)
132 *
133 * @since 1.0.0
134 * @updated 1.1.0 only display published ads
135 * @param obj $tag
136 * @return string
137 */
138 function column_ads($tag) {
139 $count = number_format_i18n($tag->count);
140
141 $tax = get_taxonomy($this->taxonomy);
142 $args = array(
143 'post_type' => $this->post_type,
144 'post_status' => 'publish',
145 'taxonomy' => $this->taxonomy,
146 'term' => $tag->slug
147 );
148 $ads = new WP_Query($args);
149
150 $group = new Advads_Ad_Group($tag->term_id);
151 $weights = $group->get_ad_weights();
152
153 $out = '';
154 $actions = array();
155 // The Loop
156 if ( $ads->have_posts() ) {
157 $out .= '<table class="advads-groups-ads-list">';
158 while ( $ads->have_posts() ) {
159 $ads->the_post();
160 $out .= '<tr><td><a href="' . get_edit_post_link(get_the_ID()) . '">' . get_the_title() . '</a>';
161 $_weight = (isset($weights[get_the_ID()])) ? $weights[get_the_ID()] : Advads_Ad_Group::MAX_AD_GROUP_WEIGHT;
162 $out .= '<td class="ad-weight ad-weight-' . get_the_ID() . '" title="'.__('Ad weight', ADVADS_SLUG).'">' . $_weight . '</td></tr>';
163 $out .= '</tr>';
164 }
165 $out .= '</table>';
166 // include actions
167 $actions['edit'] = '<a href="#" class="edit-ad-group-ads">' . __('Edit', ADVADS_SLUG) . '</a>';
168 $out .= $this->row_actions($actions);
169 // row with the group id
170 $out .= '<input type="hidden" class="ad-group-id" value="'. $tag->term_id .'"/>';
171 }
172 // Restore original Post Data
173 wp_reset_postdata();
174
175 return $out;
176 }
177
178 /**
179 * load the column names
180 *
181 * @since 1.0.0
182 * @see WP_List_Table::::single_row_columns()
183 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
184 * ************************************************************************ */
185 function get_columns() {
186 $columns = array(
187 // 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
188 'id' => __('ID', $this->textdomain),
189 'name' => __('Ad Group', $this->textdomain),
190 'slug' => __('Slug', $this->textdomain),
191 'ads' => __('Ads', $this->textdomain),
192 );
193 return $columns;
194 }
195
196 /**
197 * contains sortable columns
198 *
199 * @since 1.0.0
200 * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
201 * ************************************************************************ */
202 function get_sortable_columns() {
203 $sortable_columns = array(
204 'id' => array('id', true), //true means it's already sorted
205 'name' => array('name', false),
206 'description' => array('description', false),
207 'slug' => array('slug', false)
208 );
209 return $sortable_columns;
210 }
211
212 /**
213 * define bulk actions
214 *
215 * @since 1.0.0
216 * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
217 * ************************************************************************ */
218 function get_bulk_actions() {
219 $actions = array(
220 // 'delete' => __('Delete', $this->textdomain)
221 );
222 return $actions;
223 }
224
225 /**
226 * handle bulk actions here
227 *
228 * @since 1.0.0
229 * @see $this->prepare_items()
230 * ************************************************************************ */
231 function process_bulk_action() {
232
233 //Detect when a bulk action is being triggered...
234 if ('delete' === $this->current_action()) {
235
236 }
237 }
238
239 /**
240 * load items for output
241 *
242 * @since 1.0.0
243 */
244 function prepare_items() {
245 // how many items per page
246 // get_items_per_page basically uses a filter
247 $per_page = $this->get_items_per_page('edit_' . $this->taxonomy . '_per_page');
248
249 // set columns
250 $columns = $this->get_columns();
251 $hidden = array();
252 $sortable = $this->get_sortable_columns();
253
254 // combined array with all kinds of columns
255 $this->_column_headers = array($columns, $hidden, $sortable);
256
257 // process bulk actions
258 $this->process_bulk_action();
259
260 // prepare items
261 $search = !empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : '';
262
263 $args = array(
264 'taxonomy' => $this->taxonomy,
265 'search' => $search,
266 'page' => $this->get_pagenum(),
267 'number' => $per_page,
268 'hide_empty' => 0,
269 'orderby' => 'id'
270 );
271
272 if (!empty($_REQUEST['orderby']))
273 $args['orderby'] = trim(wp_unslash($_REQUEST['orderby']));
274
275 if (!empty($_REQUEST['order']))
276 $args['order'] = trim(wp_unslash($_REQUEST['order']));
277
278 $this->callback_args = $args;
279
280 // get items
281 $this->items = get_categories($args);
282
283 $total_items = count($this->items);
284 $this->set_pagination_args(array(
285 'total_items' => $total_items,
286 'per_page' => $per_page,
287 'total_pages' => ceil($total_items / $per_page)
288 ));
289 }
290
291 }