PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.8.21
Advanced Ads – Ad Manager & AdSense v1.8.21
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-menu.php
advanced-ads / admin / includes Last commit date
class-ad-groups-list.php 8 years ago class-ad-type.php 8 years ago class-licenses.php 8 years ago class-menu.php 8 years ago class-meta-box.php 8 years ago class-notices.php 8 years ago class-options.php 9 years ago class-overview-widgets.php 8 years ago class-settings.php 8 years ago class-shortcode-creator.php 9 years ago notices.php 8 years ago shortcode-creator-l10n.php 10 years ago
class-menu.php
237 lines
1 <?php
2 defined( 'ABSPATH' ) || exit;
3
4 class Advanced_Ads_Admin_Menu {
5 /**
6 * Instance of this class.
7 *
8 * @var object
9 */
10 protected static $instance = null;
11
12 /**
13 * Slug of the ad group page
14 *
15 * @since 1.0.0
16 * @var string
17 */
18 protected $ad_group_hook_suffix = null;
19
20 private function __construct() {
21 // Add menu items
22 add_action( 'admin_menu', array($this, 'add_plugin_admin_menu') );
23 add_action( 'admin_head', array( $this, 'highlight_menu_item' ) );
24
25 $this->plugin_slug = Advanced_Ads::get_instance()->get_plugin_slug();
26 $this->post_type = constant( 'Advanced_Ads::POST_TYPE_SLUG' );
27 }
28
29 /**
30 * Return an instance of this class.
31 *
32 * @return object A single instance of this class.
33 */
34 public static function get_instance() {
35 // If the single instance hasn't been set, set it now.
36 if ( null == self::$instance ) {
37 self::$instance = new self;
38 }
39
40 return self::$instance;
41 }
42
43 /**
44 * Register the administration menu for this plugin into the WordPress Dashboard menu.
45 *
46 * @since 1.0.0
47 */
48 public function add_plugin_admin_menu() {
49
50 $has_ads = Advanced_Ads::get_number_of_ads();
51
52 // use the overview page only when there is an ad already
53 if( $has_ads ){
54 add_menu_page(
55 __( 'Overview', 'advanced-ads' ), 'Advanced Ads', Advanced_Ads_Plugin::user_cap( 'advanced_ads_see_interface'), $this->plugin_slug, array($this, 'display_overview_page'), 'dashicons-chart-line', '58.74'
56 );
57 }
58 // forward Ads link to new-ad page when there is no ad existing yet.
59 // the target to post-new.php needs the extra "new" or any other attribute, since the original add-ad link was removed by CSS using the exact href attribute as a selector
60 $target = ( ! $has_ads ) ? 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG . '&new=new' : 'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG;
61 add_submenu_page(
62 $this->plugin_slug, __( 'Ads', 'advanced-ads' ), __( 'Ads', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads'), $target
63 );
64
65 // display the main overview page as second item when we don’t have ads yet
66 if( ! $has_ads ){
67 add_menu_page(
68 __( 'Overview', 'advanced-ads' ), 'Advanced Ads', Advanced_Ads_Plugin::user_cap( 'advanced_ads_see_interface'), $this->plugin_slug, array($this, 'display_overview_page'), 'dashicons-chart-line', '58.74'
69 );
70
71 add_submenu_page(
72 $this->plugin_slug, __( 'Overview', 'advanced-ads' ), __( 'Overview', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_see_interface'), $this->plugin_slug, array($this, 'display_overview_page')
73 );
74 }
75
76 // hidden by css; not placed in 'options.php' in order to highlight the correct item, see the 'highlight_menu_item()'
77 if ( ! current_user_can( 'edit_posts' ) ) {
78 add_submenu_page(
79 $this->plugin_slug, __( 'Add New Ad', 'advanced-ads' ), __( 'New Ad', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads'), 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG
80 );
81 }
82
83 $this->ad_group_hook_suffix = add_submenu_page(
84 $this->plugin_slug, __( 'Ad Groups & Rotations', 'advanced-ads' ), __( 'Groups & Rotation', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads'), $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
85 );
86
87 // add placements page
88 add_submenu_page(
89 $this->plugin_slug, __( 'Ad Placements', 'advanced-ads' ), __( 'Placements', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_placements'), $this->plugin_slug . '-placements', array($this, 'display_placements_page')
90 );
91 // add settings page
92 Advanced_Ads_Admin::get_instance()->plugin_screen_hook_suffix = add_submenu_page(
93 $this->plugin_slug, __( 'Advanced Ads Settings', 'advanced-ads' ), __( 'Settings', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options'), $this->plugin_slug . '-settings', array($this, 'display_plugin_settings_page')
94 );
95 // add support page
96 add_submenu_page(
97 $this->plugin_slug, __( 'Support', 'advanced-ads' ), __( 'Support', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options'), $this->plugin_slug . '-support', array($this, 'display_support_page')
98 );
99
100 // allows extensions to insert sub menu pages
101 do_action( 'advanced-ads-submenu-pages', $this->plugin_slug );
102 }
103
104 /**
105 * Highlights the 'Advanced Ads->Ads' item in the menu when an ad edit page is open
106 * @see the 'parent_file' and the 'submenu_file' filters for reference
107 */
108 public function highlight_menu_item() {
109 global $parent_file, $submenu_file, $post_type;
110 if ( $post_type === $this->post_type ) {
111 $parent_file = $this->plugin_slug;
112 $submenu_file = 'edit.php?post_type=' . $this->post_type;
113 }
114 }
115
116 /**
117 * Render the overview page
118 *
119 * @since 1.2.2
120 */
121 public function display_overview_page() {
122
123 include ADVADS_BASE_PATH . 'admin/views/overview.php';
124 }
125
126 /**
127 * Render the settings page
128 *
129 * @since 1.0.0
130 */
131 public function display_plugin_settings_page() {
132 include ADVADS_BASE_PATH . 'admin/views/settings.php';
133 }
134
135 /**
136 * Render the placements page
137 *
138 * @since 1.1.0
139 */
140 public function display_placements_page() {
141 $placement_types = Advanced_Ads_Placements::get_placement_types();
142 $placements = Advanced_Ads::get_ad_placements_array(); // -TODO use model
143 $items = Advanced_Ads_Placements::items_for_select();
144 // load ads and groups for select field
145
146 // display view
147 include ADVADS_BASE_PATH . 'admin/views/placements.php';
148 }
149
150 /**
151 * Render the support page
152 *
153 * @since 1.6.8.1
154 */
155 public function display_support_page() {
156
157 include ADVADS_BASE_PATH . 'admin/views/support.php';
158 }
159
160 /**
161 * Render the ad group page
162 *
163 * @since 1.0.0
164 */
165 public function ad_group_admin_page() {
166
167 $taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
168 $post_type = Advanced_Ads::POST_TYPE_SLUG;
169 $tax = get_taxonomy( $taxonomy );
170
171 $action = Advanced_Ads_Admin::get_instance()->current_action();
172
173 // handle new and updated groups
174 if ( 'editedgroup' == $action ) {
175 $group_id = (int) $_POST['group_id'];
176 check_admin_referer( 'update-group_' . $group_id );
177
178 if ( ! current_user_can( $tax->cap->edit_terms ) ) {
179 wp_die( __( 'Sorry, you are not allowed to access this feature.', 'advanced-ads' ) ); }
180
181 // handle new groups
182 if ( 0 == $group_id ) {
183 $ret = wp_insert_term( $_POST['name'], $taxonomy, $_POST );
184 if ( $ret && ! is_wp_error( $ret ) ) {
185 $forced_message = 1; }
186 else {
187 $forced_message = 4; }
188 // handle group updates
189 } else {
190 $tag = get_term( $group_id, $taxonomy );
191 if ( ! $tag ) {
192 wp_die( __( 'You attempted to edit an ad group that doesn&#8217;t exist. Perhaps it was deleted?', 'advanced-ads' ) ); }
193
194 $ret = wp_update_term( $group_id, $taxonomy, $_POST );
195 if ( $ret && ! is_wp_error( $ret ) ) {
196 $forced_message = 3; }
197 else {
198 $forced_message = 5; }
199 }
200 // deleting items
201 } elseif ( $action == 'delete' ){
202 $group_id = (int) $_REQUEST['group_id'];
203 check_admin_referer( 'delete-tag_' . $group_id );
204
205 if ( ! current_user_can( $tax->cap->delete_terms ) ) {
206 wp_die( __( 'Sorry, you are not allowed to access this feature.', 'advanced-ads' ) ); }
207
208 wp_delete_term( $group_id, $taxonomy );
209
210 $forced_message = 2;
211 }
212
213 // handle views
214 switch ( $action ) {
215 case 'edit' :
216 $title = $tax->labels->edit_item;
217 if ( isset($_REQUEST['group_id']) ) {
218 $group_id = absint( $_REQUEST['group_id'] );
219 $tag = get_term( $group_id, $taxonomy, OBJECT, 'edit' );
220 } else {
221 $group_id = 0;
222 $tag = false;
223 }
224
225 include ADVADS_BASE_PATH . 'admin/views/ad-group-edit.php';
226 break;
227
228 default :
229 $title = $tax->labels->name;
230 $wp_list_table = _get_list_table( 'WP_Terms_List_Table' );
231
232 // load template
233 include ADVADS_BASE_PATH . 'admin/views/ad-group.php';
234 }
235 }
236
237 }