class-ad-groups-list.php
10 years ago
class-notices.php
10 years ago
class-overview-widgets.php
10 years ago
class-shortcode-creator.php
10 years ago
notices.php
10 years ago
shortcode-creator-l10n.php
10 years ago
class-overview-widgets.php
252 lines
| 1 | <?php |
| 2 | /** |
| 3 | * container class for callbacks for overview widgets |
| 4 | * |
| 5 | * @package WordPress |
| 6 | * @subpackage Advanced Ads Plugin |
| 7 | * @since 1.4.3 |
| 8 | */ |
| 9 | class Advanced_Ads_Overview_Widgets_Callbacks { |
| 10 | |
| 11 | /** |
| 12 | * set the overview page to one column layout so widgets can get ordered horizontally |
| 13 | * |
| 14 | * @since 1.4.3 |
| 15 | * @param arr $columns columns array |
| 16 | * @return int $columns |
| 17 | */ |
| 18 | static function one_column_overview_page( $columns ) { |
| 19 | // $columns['toplevel_page_advanced-ads'] = 1; |
| 20 | return $columns; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * set the overview page to one column layout so widgets can get ordered horizontally |
| 25 | * this overwrites user settings |
| 26 | * |
| 27 | * @since 1.4.3 |
| 28 | * @return int $columns |
| 29 | */ |
| 30 | function one_column_overview_page_user() { |
| 31 | // return 1; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * register the plugin overview widgets |
| 36 | * |
| 37 | * @since 1.4.3 |
| 38 | * @param obj $screen |
| 39 | */ |
| 40 | public static function setup_overview_widgets($screen){ |
| 41 | |
| 42 | // abort if not on the overview page |
| 43 | if ( ! isset($screen->id) || $screen->id !== 'toplevel_page_advanced-ads' ) { return; } |
| 44 | |
| 45 | add_meta_box('advads_overview_news', __( 'Tips and Tutorials', 'advanced-ads' ), |
| 46 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_subscribe'), $screen->id, 'normal', 'high'); |
| 47 | add_meta_box('advads_overview_addon_help', __( 'Setup and Optimization Help', 'advanced-ads' ), |
| 48 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_help'), $screen->id, 'normal', 'high'); |
| 49 | add_meta_box('advads_overview_support', __( 'Manual and Support', 'advanced-ads' ), |
| 50 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_support'), $screen->id, 'normal', 'high'); |
| 51 | |
| 52 | // add widgets for pro add ons |
| 53 | add_meta_box('advads_overview_addon_pro', __( 'Advanced Ads Pro', 'advanced-ads' ), |
| 54 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_pro'), $screen->id, 'side', 'high'); |
| 55 | add_meta_box('advads_overview_addon_tracking', __( 'Tracking and Stats', 'advanced-ads' ), |
| 56 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_tracking'), $screen->id, 'side', 'high'); |
| 57 | add_meta_box('advads_overview_addon_responsive', __( 'Responsive and Mobile ads', 'advanced-ads' ), |
| 58 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_responsive'), $screen->id, 'side', 'high'); |
| 59 | add_meta_box('advads_overview_addon_geotargeting', __( 'Geo Targeting', 'advanced-ads' ), |
| 60 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_geotargeting'), $screen->id, 'side', 'high'); |
| 61 | add_meta_box('advads_overview_addon_sticky', __( 'Sticky ads', 'advanced-ads' ), |
| 62 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_sticky'), $screen->id, 'side', 'high'); |
| 63 | add_meta_box('advads_overview_addon_layer', __( 'PopUps and Layers', 'advanced-ads' ), |
| 64 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_layer'), $screen->id, 'side', 'high'); |
| 65 | add_meta_box('advads_overview_addon_slider', __( 'Ad Slider', 'advanced-ads' ), |
| 66 | array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_slider'), $screen->id, 'side', 'high'); |
| 67 | |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * subscribe widget |
| 72 | * |
| 73 | * @since 1.5.4 |
| 74 | */ |
| 75 | public static function render_subscribe(){ |
| 76 | |
| 77 | $is_subscribed = Advanced_Ads_Admin_Notices::get_instance()->is_subscribed(); |
| 78 | $options = Advanced_Ads_Admin_Notices::get_instance()->options(); |
| 79 | |
| 80 | $_notice = 'nl_free_addons'; |
| 81 | if ( ! isset($options['closed'][ $_notice ] ) && ! $is_subscribed ) { |
| 82 | ?><div class="advads-admin-notice"> |
| 83 | <p><?php _e( 'Get 2 <strong>free add-ons</strong> for joining the newsletter.', 'advanced-ads' ); ?></p> |
| 84 | <button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php echo $_notice ?>"><?php _e('Join now', 'advanced-ads'); ?></button> |
| 85 | </div><?php |
| 86 | } |
| 87 | |
| 88 | $_notice = 'nl_adsense'; |
| 89 | if ( ! isset($options['closed'][ $_notice ] ) ) { |
| 90 | ?><div class="advads-admin-notice"> |
| 91 | <p><?php _e( 'Learn more about how and <strong>how much you can earn with AdSense</strong> and Advanced Ads from the dedicated newsletter group.', 'advanced-ads' ); ?></p> |
| 92 | <button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php echo $_notice ?>"><?php _e('Subscribe me now', 'advanced-ads'); ?></button> |
| 93 | </div><?php |
| 94 | } |
| 95 | |
| 96 | $_notice = 'nl_first_steps'; |
| 97 | if ( ! isset($options['closed'][ $_notice ] ) && ! $is_subscribed ) { |
| 98 | ?><div class="advads-admin-notice"> |
| 99 | <p><?php _e( 'Get the first steps and more tutorials to your inbox.', 'advanced-ads' ); ?></p> |
| 100 | <button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php echo $_notice ?>"><?php _e('Send it now', 'advanced-ads'); ?></button> |
| 101 | </div><?php |
| 102 | } |
| 103 | |
| 104 | $model = Advanced_Ads::get_instance()->get_model(); |
| 105 | $recent_ads = $model->get_ads(); |
| 106 | |
| 107 | // get next steps |
| 108 | self::render_next_steps( $recent_ads ); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * render next-steps |
| 113 | */ |
| 114 | private static function render_next_steps($recent_ads = array()){ |
| 115 | $model = Advanced_Ads::get_instance()->get_model(); |
| 116 | $groups = $model->get_ad_groups(); |
| 117 | $placements = $model->get_ad_placements_array(); |
| 118 | |
| 119 | $next_steps = array(); |
| 120 | |
| 121 | if ( count( $recent_ads ) == 0 ) : |
| 122 | $next_steps[] = '<p><a class="button button-primary" href="' . admin_url( 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG ) . |
| 123 | '">' . __( 'Create your first ad', 'advanced-ads' ) . '</a></p>'; |
| 124 | endif; |
| 125 | if ( count( $groups ) == 0 ) : |
| 126 | $next_steps[] = '<p class="description">' . __( 'Ad Groups contain ads and are currently used to rotate multiple ads on a single spot.', 'advanced-ads' ) . '</p>' . |
| 127 | '<p><a class="button button-primary" href="' . admin_url( 'admin.php?action=edit&page=advanced-ads-groups' ) . |
| 128 | '">' . __( 'Create your first group', 'advanced-ads' ) . '</a></p>'; |
| 129 | endif; |
| 130 | if ( count( $placements ) == 0 ) : |
| 131 | $next_steps[] = '<p class="description">' . __( 'Ad Placements are the best way to manage where to display ads and groups.', 'advanced-ads' ) . '</p>' |
| 132 | . '<p><a class="button button-primary" href="' . admin_url( 'admin.php?action=edit&page=advanced-ads-placements' ) . |
| 133 | '">' . __( 'Create your first placement', 'advanced-ads' ) . '</a></p>'; |
| 134 | endif; |
| 135 | |
| 136 | // display all options |
| 137 | if ( count( $next_steps ) > 0 ){ |
| 138 | ?><br/><h4><?php _e( 'Next steps', 'advanced-ads' ); ?></h4><?php |
| 139 | foreach ( $next_steps as $_step ){ |
| 140 | echo $_step; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * support widget |
| 147 | */ |
| 148 | public static function render_support(){ |
| 149 | ?><ul> |
| 150 | <li><?php printf( __( '<a href="%s" target="_blank">Manual</a>', 'advanced-ads' ), ADVADS_URL . 'manual/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-manual' ); ?></li> |
| 151 | <li><?php printf( __( '<a href="%s" target="_blank">FAQ and Support</a>', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-manual' ); ?></li> |
| 152 | <li><?php printf( __( 'Vote for a <a href="%s" target="_blank">feature</a>', 'advanced-ads' ), ADVADS_URL . 'feature-requests/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-manual' ); ?></li> |
| 153 | <li><?php printf( __( 'Thank the developer with a ★★★★★ review on <a href="%s" target="_blank">wordpress.org</a>', 'advanced-ads' ), 'https://wordpress.org/support/view/plugin-reviews/advanced-ads' ); ?></li> |
| 154 | </ul><?php |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * help widget |
| 159 | */ |
| 160 | public static function render_help(){ |
| 161 | |
| 162 | ?><p><?php _e( 'Need help to set up and optimize your ads? Need custom coding on your site? Ask me for a quote.', 'advanced-ads' ); ?></p> |
| 163 | <p><a class="button button-primary" href="mailto:support@wpadvancedads.com?subject=<?php printf( __( 'Help with ads on %s', 'advanced-ads' ), home_url()); ?>"><?php |
| 164 | _e( 'Get an offer', 'advanced-ads' ); ?></a></p><?php |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * pro add-on widget |
| 169 | */ |
| 170 | public static function render_add_on_pro(){ |
| 171 | |
| 172 | ?><p><?php _e( 'Ad management for advanced websites.', 'advanced-ads' ); ?></p><ul class='list'> |
| 173 | <li><?php _e( 'Cache-busting', 'advanced-ads' ); ?></li> |
| 174 | <li><?php _e( 'Advanced visitor conditions', 'advanced-ads' ); ?></li> |
| 175 | <li><?php _e( 'Flash ads with fallback', 'advanced-ads' ); ?></li> |
| 176 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 177 | _e( 'Get Pro', 'advanced-ads' ); ?></a></p><?php |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * tracking add-on widget |
| 182 | */ |
| 183 | public static function render_add_on_tracking(){ |
| 184 | |
| 185 | ?><p><?php _e( 'Track the impressions of and clicks on your ads.', 'advanced-ads' ); ?></p><ul class='list'> |
| 186 | <li><?php _e( '2 methods to count impressions', 'advanced-ads' ); ?></li> |
| 187 | <li><?php _e( 'beautiful stats for all or single ads', 'advanced-ads' ); ?></li> |
| 188 | <li><?php _e( 'group stats by day, week or month', 'advanced-ads' ); ?></li> |
| 189 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/tracking/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 190 | _e( 'Get the Tracking add-on', 'advanced-ads' ); ?></a></p><?php |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * responsive add-on widget |
| 195 | */ |
| 196 | public static function render_add_on_responsive(){ |
| 197 | |
| 198 | ?><p><?php _e( 'Display ads based on the size of your visitor’s browser or device.', 'advanced-ads' ); ?></p><ul class='list'> |
| 199 | <li><?php _e( 'set a range (from … to …) pixels for the browser size', 'advanced-ads' ); ?></li> |
| 200 | <li><?php _e( 'set custom sizes for AdSense responsive ads', 'advanced-ads' ); ?></li> |
| 201 | <li><?php _e( 'list all ads by their responsive settings', 'advanced-ads' ); ?></li> |
| 202 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/responsive-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 203 | _e( 'Get the Responsive add-on', 'advanced-ads' ); ?></a></p><?php |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * geo targeting add-on widget |
| 208 | */ |
| 209 | public static function render_add_on_geotargeting(){ |
| 210 | |
| 211 | ?><p><?php _e( 'Target visitors by their geo location.', 'advanced-ads' ); ?></p><ul class='list'> |
| 212 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/geo-targeting/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 213 | _e( 'Get the Geo Targeting add-on', 'advanced-ads' ); ?></a></p><?php |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * sticky add-on widget |
| 218 | */ |
| 219 | public static function render_add_on_sticky(){ |
| 220 | |
| 221 | ?><p><?php _e( 'Fix ads to the browser while users are scrolling and create best performing anchor ads.', 'advanced-ads' ); ?></p><ul class='list'> |
| 222 | <li><?php _e( 'position ads that don’t scroll with the screen', 'advanced-ads' ); ?></li> |
| 223 | <li><?php _e( 'build anchor ads not only on mobile devices', 'advanced-ads' ); ?></li> |
| 224 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/sticky-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 225 | _e( 'Get the Sticky add-on', 'advanced-ads' ); ?></a></p><?php |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * layer add-on widget |
| 230 | */ |
| 231 | public static function render_add_on_layer(){ |
| 232 | |
| 233 | ?><p><?php _e( 'Display content and ads in layers and popups on custom events.', 'advanced-ads' ); ?></p><ul class='list'> |
| 234 | <li><?php _e( 'display a popup after a user interaction like scrolling', 'advanced-ads' ); ?></li> |
| 235 | <li><?php _e( 'optional background overlay', 'advanced-ads' ); ?></li> |
| 236 | <li><?php _e( 'allow users to close the popup', 'advanced-ads' ); ?></li> |
| 237 | </ul><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/popup-and-layer-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 238 | _e( 'Get the PopUp and Layer add-on', 'advanced-ads' ); ?></a></p><?php |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * slider add-on widget |
| 243 | */ |
| 244 | public static function render_add_on_slider(){ |
| 245 | |
| 246 | ?><p><?php _e( 'Create a beautiful and simple slider from your ads.', 'advanced-ads' ); ?></p> |
| 247 | <p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/slider/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" target="_blank"><?php |
| 248 | _e( 'Get the Slider add-on', 'advanced-ads' ); ?></a></p><?php |
| 249 | } |
| 250 | |
| 251 | } |
| 252 |