Merged in feature/MAW-855-import-code-into-aws (pull request #2)

code import from pantheon

* code import from pantheon
This commit is contained in:
Tony Volpe
2023-12-04 23:08:14 +00:00
parent 8c9b1312bc
commit 8f4b5efda6
4766 changed files with 185592 additions and 239967 deletions

View File

@@ -95,18 +95,24 @@ class Area {
// Display notice instructing the user to complete plugin setup.
add_action( 'admin_init', [ $this, 'display_setup_notice' ] );
// Display notice explaining removal of "Email Test" tab.
add_action( 'admin_init', [ $this, 'display_email_test_tab_removal_notice' ] );
// Outputs the plugin admin header.
add_action( 'in_admin_header', [ $this, 'display_admin_header' ], 100 );
// Outputs the plugin promotional admin footer.
add_action( 'in_admin_footer', [ $this, 'display_admin_footer' ] );
// Outputs the plugin version in the admin footer.
add_filter( 'update_footer', [ $this, 'display_update_footer' ], PHP_INT_MAX );
// Hide all unrelated to the plugin notices on the plugin admin pages.
add_action( 'admin_print_scripts', [ $this, 'hide_unrelated_notices' ] );
// Process all AJAX requests.
add_action( 'wp_ajax_wp_mail_smtp_ajax', [ $this, 'process_ajax' ] );
// Maybe redirect to "Tools -> Email Test" page if old direct URL to "Settings -> Email Test" is accessed.
add_action( 'admin_init', [ $this, 'maybe_redirect_test_tab' ] );
// Init parent admin pages.
if ( WP::in_wp_admin() || WP::is_doing_self_ajax() ) {
add_action( 'init', [ $this, 'get_parent_pages' ] );
@@ -221,6 +227,36 @@ class Area {
);
}
/**
* Display notice explaining removal of "Email Test" tab.
*
* @since 3.9.0
*/
public function display_email_test_tab_removal_notice() {
// Bail if we aren't on a "Settings" page.
if ( ! $this->is_admin_page( self::SLUG ) ) {
return;
}
// Bail if the notice has been dismissed.
if ( metadata_exists( 'user', get_current_user_id(), 'wp_mail_smtp_email_test_tab_removal_notice_dismissed' ) ) {
return;
}
WP::add_admin_notice(
sprintf(
wp_kses(
/* translators: %s: Tools page URL. */
__( 'The Email Test tab was moved to <a href="%s">WP Mail SMTP > Tools</a>.', 'wp-mail-smtp' ),
[ 'a' => [ 'href' => [] ] ]
),
$this->get_admin_page_url( self::SLUG . '-tools' )
),
implode( ' ', [ WP::ADMIN_NOTICE_INFO, 'email_test_tab_removal_notice' ] )
);
}
/**
* Get menu item position.
*
@@ -526,13 +562,13 @@ class Area {
*/
wp_enqueue_style(
'wp-mail-smtp-admin-jconfirm',
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.css',
wp_mail_smtp()->assets_url . '/css/vendor/jquery-confirm.min.css',
[ 'wp-mail-smtp-admin' ],
'3.3.4'
);
wp_enqueue_script(
'wp-mail-smtp-admin-jconfirm',
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.js',
wp_mail_smtp()->assets_url . '/js/vendor/jquery-confirm.min.js',
[ 'wp-mail-smtp-admin' ],
'3.3.4',
false
@@ -920,7 +956,6 @@ class Area {
if ( empty( $this->pages ) ) {
$this->pages = [
'settings' => new Pages\SettingsTab(),
'test' => new Pages\TestTab( new Pages\Tools() ),
'logs' => new Pages\LogsTab(),
'alerts' => new Pages\AlertsTab(),
'connections' => new Pages\AdditionalConnectionsTab(),
@@ -1131,6 +1166,14 @@ class Area {
$data['message'] = $dismissal_response;
break;
case 'email_test_tab_removal_notice_dismiss':
if ( ! check_ajax_referer( 'wp-mail-smtp-admin', 'nonce', false ) ) {
break;
}
update_user_meta( get_current_user_id(), 'wp_mail_smtp_email_test_tab_removal_notice_dismissed', true );
break;
default:
// Allow custom tasks data processing being added here.
$data = apply_filters( 'wp_mail_smtp_admin_process_ajax_' . $task . '_data', $data );
@@ -1189,7 +1232,7 @@ class Area {
return $links;
}
$custom['pro'] = sprintf(
$custom['wp-mail-smtp-pro'] = sprintf(
'<a href="%1$s" aria-label="%2$s" target="_blank" rel="noopener noreferrer"
style="color: #00a32a; font-weight: 700;"
onmouseover="this.style.color=\'#008a20\';"
@@ -1201,14 +1244,14 @@ class Area {
esc_html__( 'Get WP Mail SMTP Pro', 'wp-mail-smtp' )
);
$custom['settings'] = sprintf(
$custom['wp-mail-smtp-settings'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
esc_url( $this->get_admin_page_url() ),
esc_attr__( 'Go to WP Mail SMTP Settings page', 'wp-mail-smtp' ),
esc_html__( 'Settings', 'wp-mail-smtp' )
);
$custom['docs'] = sprintf(
$custom['wp-mail-smtp-docs'] = sprintf(
'<a href="%1$s" target="_blank" aria-label="%2$s" rel="noopener noreferrer">%3$s</a>',
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/', [ 'medium' => 'all-plugins', 'content' => 'Documentation' ] ) ),
@@ -1300,10 +1343,14 @@ class Area {
/**
* Maybe redirect to "Tools -> Email Test" page if old direct URL to "Settings -> Email Test" is accessed.
*
* @deprecated 3.9.0
*
* @since 2.8.0
*/
public function maybe_redirect_test_tab() {
_deprecated_function( __METHOD__, '3.9.0' );
if ( $this->is_admin_page( 'general' ) && $this->get_current_tab() === 'test' ) {
wp_safe_redirect( add_query_arg( 'tab', 'test', $this->get_admin_page_url( self::SLUG . '-tools' ) ) );
}
@@ -1349,4 +1396,127 @@ class Area {
// Output inline styles.
echo '<style>a.wp-mail-smtp-sidebar-upgrade-pro { background-color: #00a32a !important; color: #fff !important; font-weight: 600 !important; }</style>';
}
/**
* Display the promotional footer in our plugin pages.
*
* @since 3.10.0
*/
public function display_admin_footer() { //phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
// Bail early on non-plugin pages.
if ( ! $this->is_admin_page() ) {
return;
}
$title = esc_html__( 'Made with ♥ by the WP Mail SMTP team', 'wp-mail-smtp' );
$links = [
[
'url' => wp_mail_smtp()->is_pro() ?
wp_mail_smtp()->get_utm_url(
'https://wpmailsmtp.com/account/support/',
[
'medium' => 'Plugin Footer',
'content' => 'Contact Support',
]
) : 'https://wordpress.org/support/plugin/wp-mail-smtp/',
'text' => esc_html__( 'Support', 'wp-mail-smtp' ),
'target' => '_blank',
],
[
'url' => wp_mail_smtp()->get_utm_url(
'https://wpmailsmtp.com/docs/',
[
'medium' => 'Plugin Footer',
'content' => 'Plugin Documentation',
]
),
'text' => esc_html__( 'Docs', 'wp-mail-smtp' ),
'target' => '_blank',
],
];
if ( ! wp_mail_smtp()->is_white_labeled() ) {
$links[] = [
'url' => $this->get_admin_page_url( self::SLUG . '-about' ),
'text' => esc_html__( 'Free Plugins', 'wp-mail-smtp' ),
];
}
$links_count = count( $links );
?>
<div class="wp-mail-smtp-footer-promotion">
<p><?php echo esc_html( $title ); ?></p>
<ul class="wp-mail-smtp-footer-promotion-links">
<?php foreach ( $links as $key => $item ) : ?>
<li>
<?php
$attrs = 'href="' . esc_url( $item['url'] ) . '"';
if ( isset( $item['target'] ) ) {
$attrs .= ' target="' . esc_attr( $item['target'] ) . '"';
$attrs .= ' rel="noopener noreferrer"';
}
$text = esc_html( $item['text'] );
$divider = $links_count !== $key + 1 ? '<span>/</span>' : '';
printf(
'<a %1$s>%2$s</a>%3$s',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$attrs,
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$text,
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$divider
);
?>
</li>
<?php endforeach; ?>
</ul>
<ul class="wp-mail-smtp-footer-promotion-social">
<li>
<a href="https://www.facebook.com/wpmailsmtp" target="_blank" rel="noopener noreferrer">
<svg width="16" height="16" aria-hidden="true">
<path fill="#A7AAAD" d="M16 8.05A8.02 8.02 0 0 0 8 0C3.58 0 0 3.6 0 8.05A8 8 0 0 0 6.74 16v-5.61H4.71V8.05h2.03V6.3c0-2.02 1.2-3.15 3-3.15.9 0 1.8.16 1.8.16v1.98h-1c-1 0-1.31.62-1.31 1.27v1.49h2.22l-.35 2.34H9.23V16A8.02 8.02 0 0 0 16 8.05Z"/>
</svg>
<span class="screen-reader-text"><?php echo esc_html( 'Facebook' ); ?></span>
</a>
</li>
<li>
<a href="https://twitter.com/wpmailsmtp" target="_blank" rel="noopener noreferrer">
<svg width="17" height="16" aria-hidden="true">
<path fill="#A7AAAD" d="M15.27 4.43A7.4 7.4 0 0 0 17 2.63c-.6.27-1.3.47-2 .53a3.41 3.41 0 0 0 1.53-1.93c-.66.4-1.43.7-2.2.87a3.5 3.5 0 0 0-5.96 3.2 10.14 10.14 0 0 1-7.2-3.67C.86 2.13.7 2.73.7 3.4c0 1.2.6 2.26 1.56 2.89a3.68 3.68 0 0 1-1.6-.43v.03c0 1.7 1.2 3.1 2.8 3.43-.27.06-.6.13-.9.13a3.7 3.7 0 0 1-.66-.07 3.48 3.48 0 0 0 3.26 2.43A7.05 7.05 0 0 1 0 13.24a9.73 9.73 0 0 0 5.36 1.57c6.42 0 9.91-5.3 9.91-9.92v-.46Z"/>
</svg>
<span class="screen-reader-text"><?php echo esc_html( 'Twitter' ); ?></span>
</a>
</li>
<li>
<a href="https://youtube.com/playlist?list=PLt2XcSO7dFmCUMO0ky46Od6U2oSaiNodP" target="_blank" rel="noopener noreferrer">
<svg width="17" height="16" aria-hidden="true">
<path fill="#A7AAAD" d="M16.63 3.9a2.12 2.12 0 0 0-1.5-1.52C13.8 2 8.53 2 8.53 2s-5.32 0-6.66.38c-.71.18-1.3.78-1.49 1.53C0 5.2 0 8.03 0 8.03s0 2.78.37 4.13c.19.75.78 1.3 1.5 1.5C3.2 14 8.51 14 8.51 14s5.28 0 6.62-.34c.71-.2 1.3-.75 1.49-1.5.37-1.35.37-4.13.37-4.13s0-2.81-.37-4.12Zm-9.85 6.66V5.5l4.4 2.53-4.4 2.53Z"/>
</svg>
<span class="screen-reader-text"><?php echo esc_html( 'YouTube' ); ?></span>
</a>
</li>
</ul>
</div>
<?php
}
/**
* Display the plugin version in the footer of our plugin pages.
*
* @since 3.10.0
*
* @param string $text Text of the footer.
*/
public function display_update_footer( $text ) {
if ( $this->is_admin_page() ) {
return 'WP Mail SMTP ' . WPMS_PLUGIN_VER;
}
return $text;
}
}