add-ons
4 years ago
donors
7 months ago
emails
4 days ago
forms
2 days ago
payments
1 year ago
reports
1 year ago
settings
1 month ago
shortcodes
1 year ago
tools
4 months ago
upgrades
5 months ago
views
1 year ago
abstract-admin-settings-page.php
2 years ago
admin-actions.php
1 month ago
admin-filters.php
9 months ago
admin-footer.php
2 years ago
admin-pages.php
5 months ago
class-addon-activation-banner.php
9 months ago
class-admin-settings.php
1 year ago
class-api-keys-table.php
4 years ago
class-blank-slate.php
1 year ago
class-give-admin.php
5 years ago
class-give-html-elements.php
1 year ago
class-i18n-module.php
4 years ago
dashboard-widgets.php
3 years ago
give-metabox-functions.php
3 years ago
import-functions.php
11 months ago
misc-functions.php
2 years ago
plugins.php
9 months ago
setting-page-functions.php
6 years ago
class-addon-activation-banner.php
811 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Give Activation Banner |
| 4 | * |
| 5 | * @author GiveWP |
| 6 | * @version 1.0 |
| 7 | */ |
| 8 | |
| 9 | // Exit if accessed directly. |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | global $give_addons; |
| 15 | |
| 16 | /** |
| 17 | * Class Give_Addon_Activation_Banner |
| 18 | * |
| 19 | * @since 3.17.2 added $user_id property to class |
| 20 | * @since 2.1.0 Added pleasing interface when multiple add-ons are activated. |
| 21 | */ |
| 22 | class Give_Addon_Activation_Banner { |
| 23 | /** |
| 24 | * @since 3.17.2 |
| 25 | * @var int |
| 26 | */ |
| 27 | protected $user_id; |
| 28 | |
| 29 | /** |
| 30 | * Class constructor. |
| 31 | * |
| 32 | * @since 1.0 |
| 33 | * @access public |
| 34 | * |
| 35 | * @param array $_banner_details { |
| 36 | * 'file' => __FILE__, // (required) Directory path to the main plugin file |
| 37 | * 'name' => __( 'Authorize.net Gateway', 'give-authorize' ), // (required) Name of the Add-on |
| 38 | * 'version' => GIVE_AUTHORIZE_VERSION, // (required)The most current version |
| 39 | * 'documentation_url' => 'http://docs.givewp.com/addon-authorize',// (required) |
| 40 | * 'support_url' => 'https://givewp.com/support/', // (required)Location of Add-on settings page, leave blank to hide |
| 41 | * 'testing' => false, // (required) Never leave as "true" in production!!! |
| 42 | * } |
| 43 | */ |
| 44 | function __construct( $_banner_details ) { |
| 45 | global $give_addons, $pagenow; |
| 46 | |
| 47 | // Append add-on information to the global variable. |
| 48 | $give_addons[] = $_banner_details; |
| 49 | |
| 50 | if ( 'plugins.php' === $pagenow ) { |
| 51 | |
| 52 | // Get the current user. |
| 53 | $current_user = wp_get_current_user(); |
| 54 | $this->user_id = $current_user->ID; |
| 55 | |
| 56 | // Set up hooks. |
| 57 | $this->init(); |
| 58 | |
| 59 | // Store user id who activated plugin. |
| 60 | $this->add_addon_activate_meta(); |
| 61 | |
| 62 | // Check if notice callback is already hooked. |
| 63 | if ( ! $this->is_banner_notice_hooked() ) { |
| 64 | // If multiple add-on are activated then show activation banner in tab view. |
| 65 | add_action( 'admin_notices', array( $this, 'addon_activation_banner_notices' ), 10 ); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get the meta key name. |
| 72 | * |
| 73 | * @since 2.1 |
| 74 | * @param string $addon_banner_key |
| 75 | * |
| 76 | * @return string |
| 77 | */ |
| 78 | public static function get_banner_user_meta_key( $addon_banner_key ) { |
| 79 | $addon_slug = sanitize_text_field( $addon_banner_key ); |
| 80 | |
| 81 | return "give_addon_{$addon_slug}_active_by_user"; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Set up WordPress filters to hook into WP's update process. |
| 86 | * |
| 87 | * @since 1.0 |
| 88 | * @access public |
| 89 | * |
| 90 | * @return void |
| 91 | */ |
| 92 | public function init() { |
| 93 | // Get the current page to add the notice to |
| 94 | add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
| 95 | |
| 96 | // Get the Give add-ons. |
| 97 | $give_addons = $this->get_plugin_file_names(); |
| 98 | |
| 99 | if ( ! empty( $give_addons ) ) { |
| 100 | |
| 101 | // Go through each of the add-on and hook deactivate action. |
| 102 | foreach ( $give_addons as $addon_name => $give_addon ) { |
| 103 | |
| 104 | // Testing? |
| 105 | if ( true === $give_addon['testing'] ) { |
| 106 | $nag_meta_key = 'give_addon_activation_ignore_' . $addon_name; |
| 107 | delete_user_meta( $this->user_id, $nag_meta_key ); |
| 108 | } |
| 109 | |
| 110 | // Add deactivate hook. |
| 111 | add_action( 'deactivate_' . $give_addon['plugin_main_file'], array( $this, 'remove_addon_activate_meta' ) ); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Get plugin file name. |
| 118 | * |
| 119 | * @since 1.8 |
| 120 | * @access private |
| 121 | * @return mixed |
| 122 | */ |
| 123 | private function get_plugin_file_names() { |
| 124 | global $give_addons; |
| 125 | |
| 126 | // Get recently activated plugins. |
| 127 | $active_plugins = get_option( 'active_plugins' ); |
| 128 | |
| 129 | $file_names = array(); |
| 130 | |
| 131 | if ( empty( $give_addons ) ) { |
| 132 | return $file_names; |
| 133 | } |
| 134 | |
| 135 | // Go through each addon and get the plugin file url. |
| 136 | foreach ( $give_addons as $give_addon ) { |
| 137 | $file_name = ''; |
| 138 | $file_path = explode( '/plugins/', $give_addon['file'] ); |
| 139 | if ( $file_path ) { |
| 140 | $file_path = array_pop( $file_path ); |
| 141 | $file_name = current( explode( '/', $file_path ) ); |
| 142 | } |
| 143 | |
| 144 | if ( ! empty( $file_name ) ) { |
| 145 | foreach ( $active_plugins as $plugin ) { |
| 146 | if ( false !== strpos( $plugin, $file_name ) ) { |
| 147 | $add_on_key = sanitize_title( $give_addon['name'] ); |
| 148 | $give_addon['plugin_main_file'] = $plugin; // Include plugin file. |
| 149 | $file_names[ $add_on_key ] = $give_addon; |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return $file_names; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Setup user id to option |
| 161 | * |
| 162 | * @since 1.8 |
| 163 | * @access private |
| 164 | */ |
| 165 | private function add_addon_activate_meta() { |
| 166 | // Get all activated add-ons. |
| 167 | $give_addons = $this->get_plugin_file_names(); |
| 168 | |
| 169 | if ( ! empty( $give_addons ) ) { |
| 170 | |
| 171 | // Go through each add-ons and add meta data. |
| 172 | foreach ( $give_addons as $banner_addon_name => $addon ) { |
| 173 | |
| 174 | // User meta key. |
| 175 | $user_id = give_get_active_by_user_meta( $banner_addon_name ); |
| 176 | |
| 177 | if ( ! $user_id ) { |
| 178 | $option_key = self::get_banner_user_meta_key( $banner_addon_name ); |
| 179 | |
| 180 | // store user id who activated add-on. |
| 181 | update_option( $option_key, $this->user_id, false ); |
| 182 | |
| 183 | // Update global cache. |
| 184 | $GLOBALS['give_addon_activated_by_user'][ $option_key ] = $this->user_id; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Check if the addon_activation_banner_notices function has already been hooked to admin_notice. |
| 192 | * |
| 193 | * @since 2.1.0 |
| 194 | * |
| 195 | * @return bool |
| 196 | */ |
| 197 | public function is_banner_notice_hooked() { |
| 198 | global $wp_filter; |
| 199 | $notice_already_hooked = false; |
| 200 | |
| 201 | if ( isset( $wp_filter['admin_notices']->callbacks[10] ) ) { |
| 202 | // Get all of the hooks. |
| 203 | $admin_notice_callbacks = array_keys( $wp_filter['admin_notices']->callbacks[10] ); |
| 204 | |
| 205 | if ( ! empty( $admin_notice_callbacks ) ) { |
| 206 | foreach ( $admin_notice_callbacks as $key ) { |
| 207 | // If the key is found in your string, set $found to true |
| 208 | if ( false !== strpos( $key, 'addon_activation_banner_notices' ) ) { |
| 209 | $notice_already_hooked = true; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | return $notice_already_hooked; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Get the add-on banner notices. |
| 220 | * |
| 221 | * @since 2.1.0 |
| 222 | */ |
| 223 | public function addon_activation_banner_notices() { |
| 224 | global $pagenow, $give_addons; |
| 225 | |
| 226 | // Bailout. |
| 227 | if ( 'plugins.php' !== $pagenow ) { |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | // Store the add-ons of which activation banner should be shown. |
| 232 | $addon_to_display = array(); |
| 233 | |
| 234 | // Get recently activated add-ons. |
| 235 | $recent_activated = $this->get_recently_activated_addons(); |
| 236 | $latest_addon = array(); |
| 237 | |
| 238 | // Get the plugin folder name, because many give-addon not sending proper plugin_file. |
| 239 | if ( ! empty( $recent_activated ) ) { |
| 240 | foreach ( $recent_activated as $recent_addon ) { |
| 241 | // Get the add-on folder name. |
| 242 | $latest_addon[] = substr( $recent_addon, 0, strpos( $recent_addon, '/' ) ); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // Go through each of the give add-on. |
| 247 | foreach ( $give_addons as $addon ) { |
| 248 | $addon_sanitized_name = sanitize_title( $addon['name'] ); |
| 249 | |
| 250 | // Get the add-on dismiss status. |
| 251 | $add_on_state = get_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon_sanitized_name}", true ); |
| 252 | |
| 253 | // Get the option key. |
| 254 | $activate_by_user = (int) give_get_active_by_user_meta( $addon_sanitized_name ); |
| 255 | |
| 256 | // Remove plugin file and get the Add-on's folder name only. |
| 257 | $file_path = $this->get_plugin_folder_name( $addon['file'] ); |
| 258 | |
| 259 | // If add-on were never dismissed. |
| 260 | if ( 'true' !== $add_on_state && $this->user_id === $activate_by_user ) { |
| 261 | if ( ! empty( $latest_addon ) && ( in_array( $file_path, $latest_addon, true ) || empty( $latest_addon ) ) ) { |
| 262 | $addon_to_display[] = $addon; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if ( ! empty( $addon_to_display ) ) { |
| 268 | ob_start(); |
| 269 | |
| 270 | // Output inline styles here because there's no reason |
| 271 | // to enqueued them after the alert is dismissed. |
| 272 | $this->print_css_js(); |
| 273 | ?> |
| 274 | <div class="<?php echo ( 1 !== count( $addon_to_display ) ) ? 'give-alert-tab-wrapper' : ''; ?> updated give-addon-alert give-notice"> |
| 275 | <?php |
| 276 | // If multiple add-on are activated. |
| 277 | if ( 1 !== count( $addon_to_display ) ) { |
| 278 | ?> |
| 279 | <div class="give-vertical-tab"> |
| 280 | <div class="give-addon-tab-list"> |
| 281 | <ul class="give-alert-addon-list"> |
| 282 | <?php |
| 283 | $is_first = true; |
| 284 | foreach ( $addon_to_display as $banner ) { |
| 285 | ?> |
| 286 | <li class="give-tab-list<?php echo ( true === $is_first ) ? ' active' : ''; ?>" id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>"> |
| 287 | <a href="#"><?php echo esc_html( $banner['name'] ); ?></a> |
| 288 | </li> |
| 289 | <?php |
| 290 | $is_first = false; |
| 291 | } |
| 292 | $is_first = true; |
| 293 | ?> |
| 294 | </ul> |
| 295 | </div> |
| 296 | <div class="give-right-side-block"> |
| 297 | <?php foreach ( $addon_to_display as $banner ) : ?> |
| 298 | <div class="give-tab-details <?php echo ( true === $is_first ) ? ' active' : ''; ?> " id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>"> |
| 299 | <?php |
| 300 | // Render single add banner. |
| 301 | $this->render_single_addon_banner( $banner, false ); |
| 302 | $is_first = false; |
| 303 | ?> |
| 304 | </div> |
| 305 | <?php endforeach; ?> |
| 306 | </div> |
| 307 | </div> |
| 308 | <?php |
| 309 | } else { |
| 310 | $this->render_single_addon_banner( $addon_to_display[0], true ); |
| 311 | } |
| 312 | ?> |
| 313 | </div> |
| 314 | <?php |
| 315 | $notice_html = ob_get_clean(); |
| 316 | |
| 317 | // Register notice. |
| 318 | Give()->notices->register_notice( |
| 319 | array( |
| 320 | 'id' => 'give_add_on_activation_notice', |
| 321 | 'type' => 'updated', |
| 322 | 'description_html' => $notice_html, |
| 323 | 'show' => true, |
| 324 | ) |
| 325 | ); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Render single banner activation |
| 331 | * |
| 332 | * @since 2.1.0 |
| 333 | * |
| 334 | * @param array $banner_arr Banner options. |
| 335 | * @param bool $is_single Is single. |
| 336 | */ |
| 337 | private function render_single_addon_banner( $banner_arr, $is_single ) { |
| 338 | // Get all give add-on. |
| 339 | $give_addons = give_get_plugins(); |
| 340 | |
| 341 | // Plugin main file. |
| 342 | $plugin_file = $banner_arr['file']; |
| 343 | |
| 344 | // Get the plugin main file. |
| 345 | foreach ( $give_addons as $main_file => $addon ) { |
| 346 | // Plugin should be activated. |
| 347 | if ( ! is_plugin_active( $main_file ) ) { |
| 348 | continue; |
| 349 | } |
| 350 | |
| 351 | if ( |
| 352 | isset( $banner_arr['name'] ) |
| 353 | && 'add-on' === $addon['Type'] |
| 354 | && $this->get_plugin_folder_name( $main_file ) === $this->get_plugin_folder_name( $plugin_file ) |
| 355 | ) { |
| 356 | $plugin_file = WP_PLUGIN_DIR . '/' . $main_file; |
| 357 | break; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | // Create dismiss URL. |
| 362 | $dismiss_url = $is_single |
| 363 | ? admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=' . sanitize_title( $banner_arr['name'] ) ) |
| 364 | : admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=all' ); |
| 365 | |
| 366 | // Get the add-on details. |
| 367 | $plugin_data = get_plugin_data( $plugin_file ); |
| 368 | ?> |
| 369 | <img src="<?php echo esc_url( GIVE_PLUGIN_URL . 'build/assets/dist/images/give-icon-full-circle.svg' ); ?>" class="give-logo" /> |
| 370 | <div class="give-alert-message"> |
| 371 | <h3> |
| 372 | <?php |
| 373 | printf( |
| 374 | /* translators: %s: Add-on name */ |
| 375 | '%s<span>%s</span>', |
| 376 | __( 'New GiveWP Add-on Activated: ', 'give' ), |
| 377 | esc_html( $banner_arr['name'] ) |
| 378 | ); |
| 379 | ?> |
| 380 | </h3> |
| 381 | <a href="<?php echo esc_url( $dismiss_url ); ?>" class="dismiss"> |
| 382 | <span class="dashicons dashicons-dismiss"></span> |
| 383 | </a> |
| 384 | <div class="alert-actions"> |
| 385 | <?php |
| 386 | // Point them to your settings page. |
| 387 | if ( ! empty( $plugin_data['Description'] ) ) { |
| 388 | ?> |
| 389 | <span class="give-addon-description"> |
| 390 | <em><?php echo esc_html( strip_tags( $plugin_data['Description'] ) ); ?></em></span><br /> |
| 391 | <?php |
| 392 | } |
| 393 | if ( isset( $banner_arr['settings_url'] ) ) { |
| 394 | printf( |
| 395 | '<a href="%s"><span class="dashicons dashicons-admin-settings"></span>%s</a>', |
| 396 | esc_url( $banner_arr['settings_url'] ), |
| 397 | esc_html__( 'Go to Settings', 'give' ) |
| 398 | ); |
| 399 | } |
| 400 | // Show them how to configure the Addon. |
| 401 | if ( isset( $banner_arr['documentation_url'] ) ) { |
| 402 | printf( |
| 403 | '<a href="%s" target="_blank"><span class="dashicons dashicons-media-text"></span>%s</a>', |
| 404 | esc_url( $banner_arr['documentation_url'] ), |
| 405 | sprintf( |
| 406 | /* translators: %s: Add-on name */ |
| 407 | esc_html__( 'Documentation: %s Add-on', 'give' ), |
| 408 | esc_html( $banner_arr['name'] ) |
| 409 | ) |
| 410 | ); |
| 411 | } |
| 412 | |
| 413 | // Let them signup for plugin updates |
| 414 | if ( isset( $banner_arr['support_url'] ) ) { |
| 415 | printf( |
| 416 | '<a href="%s" target="_blank"><span class="dashicons dashicons-sos"></span>%s</a>', |
| 417 | esc_url( $banner_arr['support_url'] ), |
| 418 | esc_html__( 'Get Support', 'give' ) |
| 419 | ); |
| 420 | } |
| 421 | ?> |
| 422 | </div> |
| 423 | </div> |
| 424 | <?php |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Ignore Nag. |
| 429 | * |
| 430 | * This is the action that allows the user to dismiss the banner it basically sets a tag to their user meta data |
| 431 | * |
| 432 | * @since 1.0 |
| 433 | * @access public |
| 434 | */ |
| 435 | public function give_addon_notice_ignore() { |
| 436 | /** |
| 437 | * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
| 438 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
| 439 | */ |
| 440 | if ( |
| 441 | isset( $_GET['give_addon'], $_GET['give_addon_activation_ignore'] ) |
| 442 | && '1' === $_GET['give_addon_activation_ignore'] |
| 443 | ) { |
| 444 | // Get the value of the 'give_addon' query string. |
| 445 | $addon_query_arg = sanitize_text_field( wp_unslash( $_GET['give_addon'] ) ); |
| 446 | $deactivated_addons = array(); |
| 447 | |
| 448 | // If All add-on requested to dismiss. |
| 449 | if ( 'all' === $addon_query_arg ) { |
| 450 | // Get all activated add-ons. |
| 451 | $give_addons = $this->get_plugin_file_names(); |
| 452 | |
| 453 | if ( ! empty( $give_addons ) ) { |
| 454 | $deactivated_addons = array_keys( $give_addons ); |
| 455 | } |
| 456 | } else { |
| 457 | // Store the addon to deactivate. |
| 458 | $deactivated_addons[] = $addon_query_arg; |
| 459 | } |
| 460 | |
| 461 | if ( ! empty( $deactivated_addons ) ) { |
| 462 | foreach ( $deactivated_addons as $addon ) { |
| 463 | // Record it user meta. |
| 464 | add_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon}", 'true', true ); |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | /** |
| 471 | * Delete user id from option if plugin deactivated. |
| 472 | * |
| 473 | * @since 1.8 |
| 474 | * @since 2.1.0 Added support for multiple addons. |
| 475 | * @access public |
| 476 | */ |
| 477 | public function remove_addon_activate_meta() { |
| 478 | // Get the hook name and then grab the plugin file from it. |
| 479 | $plugin_file = str_replace( 'deactivate_', '', current_action() ); |
| 480 | |
| 481 | // Get all activated add-ons. |
| 482 | $give_addons = $this->get_plugin_file_names(); |
| 483 | |
| 484 | if ( ! empty( $give_addons ) ) { |
| 485 | foreach ( $give_addons as $banner_addon_name => $addon ) { |
| 486 | if ( $plugin_file === $addon['plugin_main_file'] ) { |
| 487 | |
| 488 | // Get the user meta key. |
| 489 | $user_id = (int) give_get_active_by_user_meta( $banner_addon_name ); |
| 490 | |
| 491 | if ( $user_id ) { |
| 492 | // Get user meta for this add-on. |
| 493 | $nag_meta_key = "give_addon_activation_ignore_{$banner_addon_name}"; |
| 494 | |
| 495 | // Delete plugin activation option key. |
| 496 | delete_option( self::get_banner_user_meta_key( $banner_addon_name ) ); |
| 497 | // Delete user meta of plugin activation. |
| 498 | delete_user_meta( $user_id, $nag_meta_key ); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Get list of add-on last activated. |
| 507 | * |
| 508 | * @since 2.1.0 |
| 509 | * |
| 510 | * @return mixed|array |
| 511 | */ |
| 512 | public function get_recently_activated_addons() { |
| 513 | return give_get_recently_activated_addons(); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * Get the addon's folder name. |
| 518 | * |
| 519 | * @since 2.1.0 |
| 520 | * |
| 521 | * @param string $main_file Plugin Main File. |
| 522 | * |
| 523 | * @return bool|mixed|string |
| 524 | */ |
| 525 | public function get_plugin_folder_name( $main_file ) { |
| 526 | // Remove plugin file and get the Add-on's folder name only. |
| 527 | $file_path = explode( '/plugins/', $main_file ); |
| 528 | $addon_file_path = array_pop( $file_path ); |
| 529 | $addon_file_path = substr( $addon_file_path, 0, strpos( $addon_file_path, '/' ) ); |
| 530 | |
| 531 | return $addon_file_path; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Add activation banner css and js . |
| 536 | * |
| 537 | * @since 1.8.16 |
| 538 | * @since 2.1.0 Added JS code for multiple add-on. |
| 539 | * @access private |
| 540 | */ |
| 541 | private function print_css_js() { |
| 542 | ?> |
| 543 | <style> |
| 544 | div.give-addon-alert.updated { |
| 545 | padding: 20px; |
| 546 | position: relative; |
| 547 | border-color: #69B868; |
| 548 | min-height: 85px; |
| 549 | } |
| 550 | |
| 551 | div.give-alert-message { |
| 552 | margin-left: 108px; |
| 553 | } |
| 554 | |
| 555 | div.give-addon-alert img.give-logo { |
| 556 | max-width: 85px; |
| 557 | float: left; |
| 558 | } |
| 559 | |
| 560 | div.give-addon-alert h3 { |
| 561 | margin: -5px 0 10px; |
| 562 | font-size: 22px; |
| 563 | font-weight: 400; |
| 564 | line-height: 30px; |
| 565 | } |
| 566 | |
| 567 | div.give-addon-alert h3 span { |
| 568 | font-weight: 700; |
| 569 | color: #69B868; |
| 570 | } |
| 571 | |
| 572 | div.give-addon-alert a { |
| 573 | color: #69B868; |
| 574 | } |
| 575 | |
| 576 | div.give-addon-alert .alert-actions a { |
| 577 | margin-right: 2em; |
| 578 | } |
| 579 | |
| 580 | div.give-addon-alert .alert-actions a { |
| 581 | text-decoration: underline; |
| 582 | } |
| 583 | |
| 584 | div.give-addon-alert .alert-actions a:hover { |
| 585 | color: #555555; |
| 586 | } |
| 587 | |
| 588 | div.give-addon-alert .alert-actions a span { |
| 589 | text-decoration: none; |
| 590 | margin-right: 5px; |
| 591 | } |
| 592 | |
| 593 | div.give-addon-alert .dismiss { |
| 594 | position: absolute; |
| 595 | right: 0px; |
| 596 | height: 99%; |
| 597 | top: 23%; |
| 598 | margin-top: -10px; |
| 599 | outline: none; |
| 600 | box-shadow: none; |
| 601 | text-decoration: none; |
| 602 | color: #AAA; |
| 603 | } |
| 604 | |
| 605 | div.give-addon-alert .dismiss { |
| 606 | position: absolute; |
| 607 | right: 20px; |
| 608 | height: 100%; |
| 609 | top: 50%; |
| 610 | margin-top: -10px; |
| 611 | outline: none; |
| 612 | box-shadow: none; |
| 613 | text-decoration: none; |
| 614 | color: #AAA; |
| 615 | } |
| 616 | |
| 617 | div.give-alert-tab-wrapper .dismiss { |
| 618 | right: 0px !important; |
| 619 | height: 99% !important; |
| 620 | top: 23% !important; |
| 621 | } |
| 622 | |
| 623 | div.give-addon-alert .dismiss:hover { |
| 624 | color: #333; |
| 625 | } |
| 626 | |
| 627 | ul.give-alert-addon-list { |
| 628 | min-width: 220px; |
| 629 | display: inline-block; |
| 630 | float: left; |
| 631 | max-width: 250px; |
| 632 | padding: 0; |
| 633 | margin: 0; |
| 634 | max-height: 146px; |
| 635 | overflow: hidden; |
| 636 | } |
| 637 | |
| 638 | div.give-addon-alert .give-addon-description { |
| 639 | padding: 1px; |
| 640 | display: inline-block; |
| 641 | color: #777; |
| 642 | margin-bottom: 12px; |
| 643 | } |
| 644 | |
| 645 | div.give-alert-tab-wrapper .give-right-side-block { |
| 646 | width: calc(100% - 250px); |
| 647 | display: inline-block; |
| 648 | float: left; |
| 649 | background: #fff; |
| 650 | position: relative; |
| 651 | } |
| 652 | |
| 653 | div.give-vertical-tab { |
| 654 | width: 100%; |
| 655 | } |
| 656 | |
| 657 | ul.give-alert-addon-list li { |
| 658 | display: block; |
| 659 | border: 1px solid #d1d1d18f; |
| 660 | border-width: 1px 0px 0px 0px; |
| 661 | margin: 0; |
| 662 | } |
| 663 | |
| 664 | ul.give-alert-addon-list li a.inactivate { |
| 665 | cursor: default; |
| 666 | } |
| 667 | |
| 668 | ul.give-alert-addon-list li a { |
| 669 | display: block; |
| 670 | font-weight: bold; |
| 671 | color: #a3a3a3; |
| 672 | text-decoration: none; |
| 673 | padding: 15px 10px 15px; |
| 674 | box-shadow: inset -6px 0px 18px 0px rgba(204, 204, 204, 0.36); |
| 675 | -moz-box-shadow: inset -6px 0px 18px 0px rgba(204, 204, 204, 0.36); |
| 676 | -webkit-box-shadow: inset -6px 0px 18px 0px rgba(204, 204, 204, 0.36); |
| 677 | -ms-box-shadow: inset -6px 0px 18px 0px rgba(204, 204, 204, 0.36); |
| 678 | -o-box-shadow: inset -6px 0px 18px 0px rgba(204, 204, 204, 0.36); |
| 679 | } |
| 680 | |
| 681 | ul.give-alert-addon-list li.give-tab-list.active a { |
| 682 | color: #5f6c74; |
| 683 | box-shadow: none; |
| 684 | } |
| 685 | |
| 686 | div.updated.give-addon-alert.give-notice.give-alert-tab-wrapper { |
| 687 | display: inline-block; |
| 688 | width: 100%; |
| 689 | } |
| 690 | |
| 691 | .give-alert-tab-wrapper .give-tab-details { |
| 692 | display: none; |
| 693 | min-height: 100px; |
| 694 | position: absolute; |
| 695 | top: 0; |
| 696 | left: 0; |
| 697 | padding: 20px 20px 20px 40px; |
| 698 | } |
| 699 | |
| 700 | .give-alert-tab-wrapper .give-tab-details.active { |
| 701 | display: block; |
| 702 | z-index: 1; |
| 703 | position: relative; |
| 704 | } |
| 705 | |
| 706 | .give-alert-tab-wrapper.give-addon-alert img.give-logo { |
| 707 | max-width: 80px; |
| 708 | } |
| 709 | |
| 710 | .give-alert-tab-wrapper .give-alert-message { |
| 711 | margin-left: 100px; |
| 712 | padding-top: 10px; |
| 713 | } |
| 714 | |
| 715 | ul.give-alert-addon-list li.give-tab-list.active { |
| 716 | background: #fff; |
| 717 | } |
| 718 | |
| 719 | ul.give-alert-addon-list li.give-tab-list:last-child { |
| 720 | border-bottom: 0px solid #ccc; |
| 721 | } |
| 722 | |
| 723 | ul.give-alert-addon-list li.give-tab-list:first-child { |
| 724 | border-top: 0 none; |
| 725 | } |
| 726 | |
| 727 | .give-alert-tab-wrapper { |
| 728 | padding: 0 !important; |
| 729 | } |
| 730 | |
| 731 | ul.give-alert-addon-list::-webkit-scrollbar { |
| 732 | height: 10px; |
| 733 | width: 10px; |
| 734 | border-radius: 4px; |
| 735 | transition: all 0.3s ease; |
| 736 | background: rgba(158, 158, 158, 0.15); |
| 737 | } |
| 738 | |
| 739 | ul.give-alert-addon-list::-webkit-scrollbar-thumb { |
| 740 | background: #939395; |
| 741 | border-radius: 4px; |
| 742 | } |
| 743 | |
| 744 | /** Responsiveness */ |
| 745 | @media screen and (max-width: 767px) { |
| 746 | .give-alert-tab-wrapper .give-tab-details { |
| 747 | padding: 20px 40px 20px 20px; |
| 748 | } |
| 749 | |
| 750 | .give-alert-tab-wrapper .give-right-side-block { |
| 751 | width: 100%; |
| 752 | } |
| 753 | |
| 754 | .give-alert-tab-wrapper ul.give-alert-addon-list { |
| 755 | min-width: 100%; |
| 756 | } |
| 757 | } |
| 758 | </style> |
| 759 | |
| 760 | <!-- Start of the Give Add-on tab JS --> |
| 761 | <script type="text/javascript"> |
| 762 | jQuery( document ).ready( function( $ ) { |
| 763 | $( '.give-alert-tab-wrapper' ).on( 'click', '.give-tab-list', function() { |
| 764 | if ( $( this ).find( 'a' ).hasClass( 'inactivate' ) ) { |
| 765 | return false; |
| 766 | } |
| 767 | |
| 768 | var |
| 769 | clicked_tab = $( this ).attr( 'id' ), |
| 770 | addon_tab_wrapper = $( this ).closest( '.give-alert-tab-wrapper' ); |
| 771 | |
| 772 | // Remove 'active' class from all tab list. |
| 773 | $( '.give-alert-addon-list li' ).removeClass( 'active' ); |
| 774 | // Add active class to the selected tab. |
| 775 | $( this ).addClass( 'active' ); |
| 776 | // Remove 'active' class from the details. |
| 777 | addon_tab_wrapper.find( '.give-tab-details' ).removeClass( 'active' ); |
| 778 | addon_tab_wrapper.find( '.give-right-side-block .give-tab-details#' + clicked_tab ).addClass( 'active' ); |
| 779 | |
| 780 | return false; |
| 781 | } ); |
| 782 | |
| 783 | var add_on_tabs = $( '.give-alert-addon-list' ); |
| 784 | |
| 785 | add_on_tabs |
| 786 | .mouseout( function() { |
| 787 | $( this ).css( 'overflow', 'hidden' ); |
| 788 | } ) |
| 789 | .mouseover( function() { |
| 790 | $( this ).css( 'overflow', 'auto' ); |
| 791 | } ); |
| 792 | |
| 793 | // Prevent default click event of the add-on. |
| 794 | add_on_tabs.find( 'li a' ).on( 'click', function( e ) { |
| 795 | e.preventDefault(); |
| 796 | } ); |
| 797 | |
| 798 | // If total length of the add-on is 2. |
| 799 | if ( 2 === add_on_tabs.find( 'li' ).length ) { |
| 800 | var li = $( 'li.give-tab-list' ); |
| 801 | li.last().clone().prependTo( 'ul.give-alert-addon-list' ); |
| 802 | li.last().removeAttr( 'id' ).find( 'a' ).addClass( 'inactivate' ).html( ' ' ); |
| 803 | $( '.give-tab-list:first' ).trigger( 'click' ); |
| 804 | } |
| 805 | } ); |
| 806 | </script> |
| 807 | <!-- End of the Give Add-on tab JS --> |
| 808 | <?php |
| 809 | } |
| 810 | } |
| 811 |