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