$suffix );
}
/**
* Get content html.
*
* @since 4.7.2
*
* @return string The email content.
*/
private function getContentHtml() { // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$dateRange = $this->getDateRange();
$content = new Content( $dateRange );
$upsell = [
'search-statistics' => []
];
$preHeader = sprintf(
// Translators: 1 - The plugin short name ("AIOSEO").
esc_html__( 'Dive into your top-performing pages with %1$s and uncover growth opportunities.', 'all-in-one-seo-pack' ),
AIOSEO_PLUGIN_SHORT_NAME
);
$iconCalendar = 'weekly' === $this->frequency
? 'icon-calendar-weekly'
: 'icon-calendar-monthly';
$heading = 'weekly' === $this->frequency
? esc_html__( 'Your Weekly SEO Email Summary', 'all-in-one-seo-pack' )
: esc_html__( 'Your Monthly SEO Email Summary', 'all-in-one-seo-pack' );
$subheading = 'weekly' === $this->frequency
? esc_html__( 'Let\'s take a look at your SEO updates and content progress this week.', 'all-in-one-seo-pack' )
: esc_html__( 'Let\'s take a look at your SEO updates and content progress this month.', 'all-in-one-seo-pack' );
$statisticsReport = [
'posts' => [],
'keywords' => [],
'milestones' => [],
'cta' => [
'text' => esc_html__( 'See All SEO Statistics', 'all-in-one-seo-pack' ),
'url' => $content->searchStatisticsUrl
],
];
if ( ! $content->allowSearchStatistics() ) {
$upsell['search-statistics'] = [
'cta' => [
'text' => esc_html__( 'Unlock Search Statistics', 'all-in-one-seo-pack' ),
'url' => $content->searchStatisticsUrl,
],
];
}
if ( ! $upsell['search-statistics'] ) {
$subheading = 'weekly' === $this->frequency
? esc_html__( 'Let\'s take a look at how your site has performed in search results this week.', 'all-in-one-seo-pack' )
: esc_html__( 'Let\'s take a look at how your site has performed in search results this month.', 'all-in-one-seo-pack' );
$statisticsReport['posts'] = $content->getPostsStatistics();
$statisticsReport['keywords'] = $content->getKeywords();
$statisticsReport['milestones'] = $content->getMilestones();
}
$mktUrl = trailingslashit( AIOSEO_MARKETING_URL );
$medium = 'email-report-summary';
$posts = $content->getAioPosts();
$resources = [
'posts' => array_map( function ( $item ) use ( $medium, $content ) {
return array_merge( $item, [
'url' => aioseo()->helpers->utmUrl( $item['url'], $medium ),
'image' => [
'url' => ! empty( $item['image']['sizes']['medium']['source_url'] )
? $item['image']['sizes']['medium']['source_url']
: $content->featuredImagePlaceholder
]
] );
}, $content->getResources() ),
'cta' => [
'text' => esc_html__( 'See All Resources', 'all-in-one-seo-pack' ),
'url' => aioseo()->helpers->utmUrl( 'https://aioseo.com/blog/', $medium ),
],
];
$links = [
'disable' => admin_url( 'admin.php?page=aioseo-settings&aioseo-scroll=aioseo-email-summary-row&aioseo-highlight=aioseo-email-summary-row&aioseo-tab=advanced' ),
'update' => admin_url( 'update-core.php' ),
'marketing-site' => aioseo()->helpers->utmUrl( $mktUrl, $medium ),
'facebook' => aioseo()->helpers->utmUrl( $mktUrl . 'plugin/facebook', $medium ),
'linkedin' => aioseo()->helpers->utmUrl( $mktUrl . 'plugin/linkedin', $medium ),
'youtube' => aioseo()->helpers->utmUrl( $mktUrl . 'plugin/youtube', $medium ),
'twitter' => aioseo()->helpers->utmUrl( $mktUrl . 'plugin/twitter', $medium ),
];
ob_start();
require AIOSEO_DIR . '/app/Common/Views/report/summary.php';
return ob_get_clean();
}
/**
* Get email headers.
*
* @since 4.7.2
*
* @return array The email headers.
*/
private function getHeaders() {
return [ 'Content-Type: text/html; charset=UTF-8' ];
}
/**
* Get all allowed frequencies.
*
* @since 4.7.2
*
* @return array The email allowed frequencies.
*/
private function getAllowedFrequencies() {
$time = time();
$secondsTillNow = $time - strtotime( 'today' );
return [
'weekly' => [
'interval' => WEEK_IN_SECONDS,
'start' => strtotime( 'next Monday' ) - $time
],
'monthly' => [
'interval' => MONTH_IN_SECONDS,
'start' => ( strtotime( 'first day of next month' ) + ( DAY_IN_SECONDS * 2 ) - $secondsTillNow ) - $time
]
];
}
/**
* Retrieves the date range data based on the frequency.
*
* @since 4.7.3
*
* @return array The date range data.
*/
private function getDateRange() {
$dateFormat = get_option( 'date_format' );
// If frequency is 'monthly'.
$endDateRaw = strtotime( 'last day of last month' );
$startDateRaw = strtotime( 'first day of last month' );
// If frequency is 'weekly'.
if ( 'weekly' === $this->frequency ) {
$endDateRaw = strtotime( 'last Saturday' );
$startDateRaw = strtotime( 'last Sunday', $endDateRaw );
}
$endDate = date_i18n( $dateFormat, $endDateRaw );
$startDate = date_i18n( $dateFormat, $startDateRaw );
return [
'endDate' => $endDate,
'endDateRaw' => $endDateRaw,
'startDate' => $startDate,
'startDateRaw' => $startDateRaw,
'range' => "$startDate - $endDate",
];
}
}