| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | /** |
| 11 | 16 | * Class MainWP_Notification_Settings |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -23,10 +28,38 @@ | ||
| 23 | 28 | * @var mixed Default null. |
| 24 | 29 | */ |
| 25 | 30 | private static $instance = null; |
| 26 | 31 | |
| 32 | + /** | |
| 33 | + * Private static variable to hold the single instance. | |
| 34 | + * | |
| 35 | + * @static | |
| 36 | + * | |
| 37 | + * @var mixed Default null. | |
| 38 | + */ | |
| 39 | + private static $boilerplate_tokens_loaded = null; | |
| 27 | 40 | |
| 41 | + | |
| 28 | 42 | /** |
| 43 | + * Private static variable to hold the single instance. | |
| 44 | + * | |
| 45 | + * @static | |
| 46 | + * | |
| 47 | + * @var mixed Default null. | |
| 48 | + */ | |
| 49 | + private static $report_tokens_loaded = null; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Private static variable to hold the single instance. | |
| 53 | + * | |
| 54 | + * @static | |
| 55 | + * | |
| 56 | + * @var mixed Default null. | |
| 57 | + */ | |
| 58 | + private static $client_report_tokens_loaded = null; | |
| 59 | + | |
| 60 | + | |
| 61 | + /** | |
| 29 | 62 | * Get class name. |
| 30 | 63 | * |
| 31 | 64 | * @return string Class name. |
| 32 | 65 | */ |
| @@ -112,10 +145,10 @@ | ||
| 112 | 145 | * @param bool $updated True if page loaded after update, false if not. |
| 113 | 146 | */ |
| 114 | 147 | public function render_all_settings( $updated ) { |
| 115 | 148 | |
| 116 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) { | |
| 117 | - mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); | |
| 149 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { | |
| 150 | + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); | |
| 118 | 151 | return; |
| 119 | 152 | } |
| 120 | 153 | |
| 121 | 154 | $email_description = ''; |
| @@ -125,14 +158,17 @@ | ||
| 125 | 158 | $emails_settings = array(); |
| 126 | 159 | } |
| 127 | 160 | |
| 128 | 161 | ?> |
| 129 | - <div id="mainwp-all-emails-settings" class="ui segment"> | |
| 162 | + <div id="mainwp-all-emails-settings" class="ui padded segment"> | |
| 130 | 163 | <?php if ( $updated ) : ?> |
| 131 | 164 | <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div> |
| 132 | 165 | <?php endif; ?> |
| 133 | 166 | <div class="ui info message"> |
| 134 | - <?php printf( esc_html__( 'Email notifications sent from MainWP Dashboard are listed below. Click on an email to configure it. For additional help, please see %1$sthis help document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/email-settings/">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?> | |
| 167 | + <?php | |
| 168 | + /* translators: 1: Opening anchor tag, 2: Closing anchor tag with external link icon */ | |
| 169 | + printf( esc_html__( 'Email notifications sent from MainWP Dashboard are listed below. Click on an email to configure it. For additional help, please see %1$sthis help document%2$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/management/mainwp-dashboard-settings#manage-email-settings">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 170 | + ?> | |
| 135 | 171 | </div> |
| 136 | 172 | <table class="ui unstackable table" id="mainwp-emails-settings-table"> |
| 137 | 173 | <thead> |
| 138 | 174 | <tr> |
| @@ -220,10 +256,10 @@ | ||
| 220 | 256 | * @uses \MainWP\Dashboard\MainWP_Notification_Template::is_overrided_template() |
| 221 | 257 | */ |
| 222 | 258 | public function render_edit_settings( $type, $updated_templ ) { |
| 223 | 259 | |
| 224 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) { | |
| 225 | - mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); | |
| 260 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { | |
| 261 | + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); | |
| 226 | 262 | return; |
| 227 | 263 | } |
| 228 | 264 | |
| 229 | 265 | $emails_settings = get_option( 'mainwp_settings_notification_emails' ); |
| @@ -249,9 +285,12 @@ | ||
| 249 | 285 | <input type="hidden" name="mainwp_setting_emails_type" value="<?php echo esc_html( $type ); ?>" /> |
| 250 | 286 | <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-email-tokens-info-message' ) ) : ?> |
| 251 | 287 | <div class="ui info message"> |
| 252 | 288 | <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i> |
| 253 | - <?php printf( esc_html__( '%1$sBoilerplate%2$s and %3$sReports%4$s extensions tokens are supported in the email settings and templates if Extensions are in use.', 'mainwp' ), '<a href="https://mainwp.com/extension/boilerplate/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://mainwp.com/extension/pro-reports/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?> | |
| 289 | + <?php | |
| 290 | + /* translators: 1: Opening anchor tag for Boilerplate, 2: Closing anchor tag, 3: Opening anchor tag for Reports, 4: Closing anchor tag */ | |
| 291 | + printf( esc_html__( '%1$sBoilerplate%2$s and %3$sReports%4$s extensions tokens are supported in the email settings and templates if Extensions are in use.', 'mainwp' ), '<a href="https://mainwp.com/extension/boilerplate/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://mainwp.com/extension/pro-reports/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 292 | + ?> | |
| 254 | 293 | </div> |
| 255 | 294 | <?php endif; ?> |
| 256 | 295 | <h3 class="ui header"> |
| 257 | 296 | <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-email-' . esc_attr( $type ) ); ?> |
| @@ -393,8 +432,10 @@ | ||
| 393 | 432 | } elseif ( 'http_check' === $type ) { |
| 394 | 433 | $email_description = esc_html__( 'Alert if any of your websites return unexpected HTTP status after running updates.', 'mainwp' ); |
| 395 | 434 | } elseif ( 'deactivated_license_alert' === $type ) { |
| 396 | 435 | $email_description = esc_html__( 'Receive a notification when an extension\'s license is deactivated.', 'mainwp' ); |
| 436 | + } elseif ( 'auto_updates' === $type ) { | |
| 437 | + $email_description = esc_html__( 'Receive a notification about auto-updates.', 'mainwp' ); | |
| 397 | 438 | } |
| 398 | 439 | |
| 399 | 440 | $addition_desc = apply_filters( 'mainwp_notification_type_desc', '', $type ); |
| 400 | 441 | if ( ! empty( $addition_desc ) ) { |
| @@ -409,19 +450,52 @@ | ||
| 409 | 450 | * |
| 410 | 451 | * @param int $updated Update code (copied, saved or deleted). |
| 411 | 452 | */ |
| 412 | 453 | public static function render_update_template_message( $updated ) { |
| 413 | - ?> | |
| 414 | - <?php if ( 1 === (int) $updated ) : ?> | |
| 415 | - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Custom email template deleted successfully.', 'mainwp' ); ?></div> | |
| 416 | - <?php endif; ?> | |
| 417 | - <?php if ( 2 === (int) $updated ) : ?> | |
| 418 | - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template copied successfully.', 'mainwp' ); ?></div> | |
| 419 | - <?php endif; ?> | |
| 420 | - <?php if ( 3 === (int) $updated ) : ?> | |
| 421 | - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template updated successfully.', 'mainwp' ); ?></div> | |
| 422 | - <?php endif; ?> | |
| 423 | - <?php | |
| 454 | + switch ( (int) $updated ) { | |
| 455 | + case 1: | |
| 456 | + ?> | |
| 457 | + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Custom email template deleted successfully.', 'mainwp' ); ?></div> | |
| 458 | + <?php | |
| 459 | + break; | |
| 460 | + case 2: | |
| 461 | + ?> | |
| 462 | + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template copied successfully.', 'mainwp' ); ?></div> | |
| 463 | + <?php | |
| 464 | + break; | |
| 465 | + case 3: | |
| 466 | + ?> | |
| 467 | + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template updated successfully.', 'mainwp' ); ?></div> | |
| 468 | + <?php | |
| 469 | + break; | |
| 470 | + case 31: | |
| 471 | + ?> | |
| 472 | + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template update failed. Please try again.', 'mainwp' ); ?></div> | |
| 473 | + <?php | |
| 474 | + break; | |
| 475 | + case 32: | |
| 476 | + ?> | |
| 477 | + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template failed to open. Please try again.', 'mainwp' ); ?></div> | |
| 478 | + <?php | |
| 479 | + break; | |
| 480 | + case 33: | |
| 481 | + ?> | |
| 482 | + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template is not writable. Please try again.', 'mainwp' ); ?></div> | |
| 483 | + <?php | |
| 484 | + break; | |
| 485 | + case 34: | |
| 486 | + ?> | |
| 487 | + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'The destination email template is invalid and could not be saved. Please try again.', 'mainwp' ); ?></div> | |
| 488 | + <?php | |
| 489 | + break; | |
| 490 | + case 35: | |
| 491 | + ?> | |
| 492 | + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template update failed. Please ensure you have theme editing permissions and try again.', 'mainwp' ); ?></div> | |
| 493 | + <?php | |
| 494 | + break; | |
| 495 | + default: | |
| 496 | + break; | |
| 497 | + } | |
| 424 | 498 | } |
| 425 | 499 | |
| 426 | 500 | /** |
| 427 | 501 | * Get email notification types. |
| @@ -432,9 +506,10 @@ | ||
| 432 | 506 | */ |
| 433 | 507 | public static function get_notification_types( $type = '' ) { |
| 434 | 508 | $types = array( |
| 435 | 509 | 'daily_digest' => esc_html__( 'Daily Digest Email', 'mainwp' ), |
| 436 | - 'uptime' => esc_html__( 'Basic Uptime Monitoring Email', 'mainwp' ), | |
| 510 | + 'auto_updates' => esc_html__( 'Auto Updates Email', 'mainwp' ), | |
| 511 | + 'uptime' => esc_html__( 'Uptime Monitoring Email', 'mainwp' ), | |
| 437 | 512 | 'site_health' => esc_html__( 'Site Health Monitoring Email', 'mainwp' ), |
| 438 | 513 | 'deactivated_license_alert' => esc_html__( 'Extension License Deactivation Notification Email', 'mainwp' ), |
| 439 | 514 | ); |
| 440 | 515 | |
| @@ -476,8 +551,32 @@ | ||
| 476 | 551 | return array_merge( $default, $options ); |
| 477 | 552 | } |
| 478 | 553 | |
| 479 | 554 | /** |
| 555 | + * Prepare general email notifications settings. | |
| 556 | + * | |
| 557 | + * @param array $options Email settings. | |
| 558 | + * @param object $website Site data. | |
| 559 | + * | |
| 560 | + * @return void. | |
| 561 | + */ | |
| 562 | + public static function prepare_general_email_settings_for_site( &$options, $website ) { | |
| 563 | + if ( is_array( $options ) && isset( $options['subject'] ) && isset( $options['heading'] ) && isset( $options['recipients'] ) ) { | |
| 564 | + if ( preg_match( '/\[[^\]]+\]/is', $options['subject'] . $options['heading'], $matches ) ) { | |
| 565 | + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true ); | |
| 566 | + $options['subject'] = MainWP_System_Utility::replace_tokens_values( $options['subject'], $tokens_values ); | |
| 567 | + $options['heading'] = MainWP_System_Utility::replace_tokens_values( $options['heading'], $tokens_values ); | |
| 568 | + } | |
| 569 | + | |
| 570 | + if ( preg_match( '/\[[^\]]+\]/is', $options['recipients'] . $options['subject'] . $options['heading'], $matches ) ) { | |
| 571 | + // support boilerplate and reports tokens. | |
| 572 | + $fields = array( 'recipients', 'subject', 'heading' ); | |
| 573 | + $options = static::replace_tokens_for_settings( $options, $fields, $website ); | |
| 574 | + } | |
| 575 | + } | |
| 576 | + } | |
| 577 | + | |
| 578 | + /** | |
| 480 | 579 | * Get general notification email. |
| 481 | 580 | * |
| 482 | 581 | * @return string|empty recipients. |
| 483 | 582 | */ |
| @@ -509,8 +608,9 @@ | ||
| 509 | 608 | * Get email settings for a single site. |
| 510 | 609 | * |
| 511 | 610 | * @param string $type Email type. |
| 512 | 611 | * @param object $website Object containing the child site information. |
| 612 | + * @param mixed $website_status Object containing the child site status. | |
| 513 | 613 | * |
| 514 | 614 | * @return array An array containing the email settings. |
| 515 | 615 | * |
| 516 | 616 | * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values() |
| @@ -515,9 +615,9 @@ | ||
| 515 | 615 | * |
| 516 | 616 | * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values() |
| 517 | 617 | * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values() |
| 518 | 618 | */ |
| 519 | - public static function get_site_email_settings( $type, $website ) { | |
| 619 | + public static function get_site_email_settings( $type, $website, $website_status = false ) { | |
| 520 | 620 | if ( empty( $website ) || ! property_exists( $website, 'settings_notification_emails' ) ) { |
| 521 | 621 | return array( 'disable' => 1 ); |
| 522 | 622 | } |
| 523 | 623 | $settings = array(); |
| @@ -533,9 +633,9 @@ | ||
| 533 | 633 | $default = static::get_default_emails_fields( $type ); |
| 534 | 634 | $options = array_merge( $default, $options ); |
| 535 | 635 | |
| 536 | 636 | if ( preg_match( '/\[[^\]]+\]/is', $options['subject'] . $options['heading'], $matches ) ) { |
| 537 | - $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website ); | |
| 637 | + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true, $website_status ); | |
| 538 | 638 | $options['subject'] = MainWP_System_Utility::replace_tokens_values( $options['subject'], $tokens_values ); |
| 539 | 639 | $options['heading'] = MainWP_System_Utility::replace_tokens_values( $options['heading'], $tokens_values ); |
| 540 | 640 | } |
| 541 | 641 | |
| @@ -567,21 +667,27 @@ | ||
| 567 | 667 | $default_fields = array( |
| 568 | 668 | 'daily_digest' => array( |
| 569 | 669 | 'disable' => $disable, |
| 570 | 670 | 'recipients' => $recipients, |
| 571 | - 'subject' => $general ? 'Daily Digest' : '[site.name] Daily Digest', | |
| 671 | + 'subject' => $general ? 'Daily Digest from Your MainWP Dashboard' : '[site.name] Daily Digest from Your MainWP Dashboard', | |
| 572 | 672 | 'heading' => $general ? 'Daily Digest' : '[site.name] Daily Digest', |
| 573 | 673 | ), |
| 674 | + 'auto_updates' => array( | |
| 675 | + 'disable' => $disable, | |
| 676 | + 'recipients' => $recipients, | |
| 677 | + 'subject' => $general ? 'Auto Updates Notification from Your MainWP Dashboard' : '[site.name] Auto Updates Notification from Your MainWP Dashboard', | |
| 678 | + 'heading' => $general ? 'Auto Updates Notification' : '[site.name] Auto Updates Notification', | |
| 679 | + ), | |
| 574 | 680 | 'uptime' => array( |
| 575 | 681 | 'disable' => $disable, |
| 576 | 682 | 'recipients' => $recipients, |
| 577 | - 'subject' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring', | |
| 683 | + 'subject' => $general ? 'Uptime Monitoring Alert from your MainWP Dashboard' : '[site.name] Uptime Monitoring Alert from your MainWP Dashboard', | |
| 578 | 684 | 'heading' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring', |
| 579 | 685 | ), |
| 580 | 686 | 'site_health' => array( |
| 581 | 687 | 'disable' => $disable, |
| 582 | 688 | 'recipients' => $recipients, |
| 583 | - 'subject' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring', | |
| 689 | + 'subject' => $general ? 'Site Health Monitoring Alert from Your MainWP Dashboard' : '[site.name] Site Health Monitoring Alert from Your MainWP Dashboard', | |
| 584 | 690 | 'heading' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring', |
| 585 | 691 | ), |
| 586 | 692 | 'http_check' => array( |
| 587 | 693 | 'disable' => $disable, |
| @@ -591,9 +697,9 @@ | ||
| 591 | 697 | ), |
| 592 | 698 | 'deactivated_license_alert' => array( |
| 593 | 699 | 'disable' => $disable, |
| 594 | 700 | 'recipients' => $recipients, |
| 595 | - 'subject' => 'Extension License Deactivation Notification', | |
| 701 | + 'subject' => 'Extension License Deactivation Notification from Your MainWP Dashboard', | |
| 596 | 702 | 'heading' => 'Extension License Deactivation Notification', |
| 597 | 703 | ), |
| 598 | 704 | ); |
| 599 | 705 | |
| @@ -625,19 +731,23 @@ | ||
| 625 | 731 | * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values() |
| 626 | 732 | */ |
| 627 | 733 | public static function replace_tokens_for_settings( $options, $fields, $website ) { // phpcs:ignore -- NOSONAR - complex. |
| 628 | 734 | |
| 629 | - /** | |
| 630 | - * Filter: mainwp_boilerplate_get_tokens | |
| 631 | - * | |
| 632 | - * Enables and filters the Boilerplate extension tokens. | |
| 633 | - * | |
| 634 | - * @param object $website Object containing the child site data. | |
| 635 | - * | |
| 636 | - * @since 4.1 | |
| 637 | - */ | |
| 638 | - $boilerplate_tokens = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website ); | |
| 735 | + if ( null === static::$boilerplate_tokens_loaded ) { | |
| 736 | + /** | |
| 737 | + * Filter: mainwp_boilerplate_get_tokens | |
| 738 | + * | |
| 739 | + * Enables and filters the Boilerplate extension tokens. | |
| 740 | + * | |
| 741 | + * @param object $website Object containing the child site data. | |
| 742 | + * | |
| 743 | + * @since 4.1 | |
| 744 | + */ | |
| 745 | + static::$boilerplate_tokens_loaded = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website ); | |
| 746 | + } | |
| 639 | 747 | |
| 748 | + $boilerplate_tokens = static::$boilerplate_tokens_loaded; | |
| 749 | + | |
| 640 | 750 | if ( is_array( $boilerplate_tokens ) ) { |
| 641 | 751 | foreach ( $fields as $field ) { |
| 642 | 752 | if ( isset( $options[ $field ] ) ) { |
| 643 | 753 | $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $boilerplate_tokens ); |
| @@ -644,19 +754,23 @@ | ||
| 644 | 754 | } |
| 645 | 755 | } |
| 646 | 756 | } |
| 647 | 757 | |
| 648 | - /** | |
| 649 | - * Filter: mainwp_pro_reports_get_site_tokens | |
| 650 | - * | |
| 651 | - * Enables and filters the Pro Reports extension tokens. | |
| 652 | - * | |
| 653 | - * @param object $website Object containing the child site data. | |
| 654 | - * | |
| 655 | - * @since 4.1 | |
| 656 | - */ | |
| 657 | - $report_tokens = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id ); | |
| 758 | + if ( null === static::$report_tokens_loaded ) { | |
| 759 | + /** | |
| 760 | + * Filter: mainwp_pro_reports_get_site_tokens | |
| 761 | + * | |
| 762 | + * Enables and filters the Pro Reports extension tokens. | |
| 763 | + * | |
| 764 | + * @param object $website Object containing the child site data. | |
| 765 | + * | |
| 766 | + * @since 4.1 | |
| 767 | + */ | |
| 768 | + static::$report_tokens_loaded = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id ); | |
| 769 | + } | |
| 658 | 770 | |
| 771 | + $report_tokens = static::$report_tokens_loaded; | |
| 772 | + | |
| 659 | 773 | if ( is_array( $report_tokens ) ) { |
| 660 | 774 | foreach ( $fields as $field ) { |
| 661 | 775 | if ( isset( $options[ $field ] ) ) { |
| 662 | 776 | $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $report_tokens ); |
| @@ -663,18 +777,23 @@ | ||
| 663 | 777 | } |
| 664 | 778 | } |
| 665 | 779 | } |
| 666 | 780 | |
| 667 | - /** | |
| 668 | - * Filter: mainwp_client_report_get_site_tokens | |
| 669 | - * | |
| 670 | - * Enables and filters the Client Reports extension tokens. | |
| 671 | - * | |
| 672 | - * @param object $website Object containing the child site data. | |
| 673 | - * | |
| 674 | - * @since 4.1 | |
| 675 | - */ | |
| 676 | - $client_report_tokens = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id ); | |
| 781 | + if ( null === static::$client_report_tokens_loaded ) { | |
| 782 | + /** | |
| 783 | + * Filter: mainwp_client_report_get_site_tokens | |
| 784 | + * | |
| 785 | + * Enables and filters the Client Reports extension tokens. | |
| 786 | + * | |
| 787 | + * @param object $website Object containing the child site data. | |
| 788 | + * | |
| 789 | + * @since 4.1 | |
| 790 | + */ | |
| 791 | + static::$client_report_tokens_loaded = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id ); | |
| 792 | + } | |
| 793 | + | |
| 794 | + $client_report_tokens = static::$client_report_tokens_loaded; | |
| 795 | + | |
| 677 | 796 | if ( is_array( $client_report_tokens ) ) { |
| 678 | 797 | foreach ( $fields as $field ) { |
| 679 | 798 | if ( isset( $options[ $field ] ) ) { |
| 680 | 799 | $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $client_report_tokens ); |
| @@ -697,9 +816,9 @@ | ||
| 697 | 816 | * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values() |
| 698 | 817 | */ |
| 699 | 818 | public static function replace_tokens_for_content( $content, $website ) { |
| 700 | 819 | |
| 701 | - $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website ); | |
| 820 | + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true ); | |
| 702 | 821 | |
| 703 | 822 | $content = MainWP_System_Utility::replace_tokens_values( $content, $tokens_values ); |
| 704 | 823 | |
| 705 | 824 | // if tokens existed. |