Migrate email editor cdn-asset-url class to WP Coding Standard
[MAILPOET-6240]
This commit is contained in:
@@ -40,13 +40,13 @@ class Default_Content_Full extends Abstract_Pattern {
|
|||||||
<div class="wp-block-columns has-white-background-color has-background" style="margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20);padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:column -->
|
<div class="wp-block-columns has-white-background-color has-background" style="margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20);padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:column -->
|
||||||
<div class="wp-block-column">
|
<div class="wp-block-column">
|
||||||
<!-- wp:image {"width":"130px","sizeSlug":"large"} -->
|
<!-- wp:image {"width":"130px","sizeSlug":"large"} -->
|
||||||
<figure class="wp-block-image size-large is-resized"><img src="' . esc_url( $this->cdn_asset_url->generateCdnUrl( 'email-editor/your-logo-placeholder.png' ) ) . '" alt="Your Logo" style="width:130px"/></figure>
|
<figure class="wp-block-image size-large is-resized"><img src="' . esc_url( $this->cdn_asset_url->generate_cdn_url( 'email-editor/your-logo-placeholder.png' ) ) . '" alt="Your Logo" style="width:130px"/></figure>
|
||||||
<!-- /wp:image -->
|
<!-- /wp:image -->
|
||||||
<!-- wp:heading {"fontSize":"medium","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} -->
|
<!-- wp:heading {"fontSize":"medium","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} -->
|
||||||
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)">' . __( 'One column layout', 'mailpoet' ) . '</h2>
|
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)">' . __( 'One column layout', 'mailpoet' ) . '</h2>
|
||||||
<!-- /wp:heading -->
|
<!-- /wp:heading -->
|
||||||
<!-- wp:image {"width":"620px","sizeSlug":"large"} -->
|
<!-- wp:image {"width":"620px","sizeSlug":"large"} -->
|
||||||
<figure class="wp-block-image"><img src="' . esc_url( $this->cdn_asset_url->generateCdnUrl( 'newsletter/congratulation-page-illustration-transparent-LQ.20181121-1440.png' ) ) . '" alt="Banner Image"/></figure>
|
<figure class="wp-block-image"><img src="' . esc_url( $this->cdn_asset_url->generate_cdn_url( 'newsletter/congratulation-page-illustration-transparent-LQ.20181121-1440.png' ) ) . '" alt="Banner Image"/></figure>
|
||||||
<!-- /wp:image -->
|
<!-- /wp:image -->
|
||||||
<!-- wp:paragraph -->
|
<!-- wp:paragraph -->
|
||||||
<p>' . esc_html__( 'A one-column layout is great for simplified and concise content, like announcements or newsletters with brief updates. Drag blocks to add content and customize your styles from the styles panel on the top right.', 'mailpoet' ) . '</p>
|
<p>' . esc_html__( 'A one-column layout is great for simplified and concise content, like announcements or newsletters with brief updates. Drag blocks to add content and customize your styles from the styles panel on the top right.', 'mailpoet' ) . '</p>
|
||||||
|
@@ -44,7 +44,7 @@ class Default_Content extends Abstract_Pattern {
|
|||||||
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)">' . __( 'One column layout', 'mailpoet' ) . '</h2>
|
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)">' . __( 'One column layout', 'mailpoet' ) . '</h2>
|
||||||
<!-- /wp:heading -->
|
<!-- /wp:heading -->
|
||||||
<!-- wp:image {"width":"620px","sizeSlug":"large"} -->
|
<!-- wp:image {"width":"620px","sizeSlug":"large"} -->
|
||||||
<figure class="wp-block-image"><img src="' . esc_url( $this->cdn_asset_url->generateCdnUrl( 'newsletter/congratulation-page-illustration-transparent-LQ.20181121-1440.png' ) ) . '" alt="Banner Image"/></figure>
|
<figure class="wp-block-image"><img src="' . esc_url( $this->cdn_asset_url->generate_cdn_url( 'newsletter/congratulation-page-illustration-transparent-LQ.20181121-1440.png' ) ) . '" alt="Banner Image"/></figure>
|
||||||
<!-- /wp:image -->
|
<!-- /wp:image -->
|
||||||
<!-- wp:paragraph -->
|
<!-- wp:paragraph -->
|
||||||
<p>' . esc_html__( 'A one-column layout is great for simplified and concise content, like announcements or newsletters with brief updates. Drag blocks to add content and customize your styles from the styles panel on the top right.', 'mailpoet' ) . '</p>
|
<p>' . esc_html__( 'A one-column layout is great for simplified and concise content, like announcements or newsletters with brief updates. Drag blocks to add content and customize your styles from the styles panel on the top right.', 'mailpoet' ) . '</p>
|
||||||
|
@@ -1,20 +1,47 @@
|
|||||||
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the MailPoet plugin.
|
||||||
|
*
|
||||||
|
* @package MailPoet\EmailEditor
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
namespace MailPoet\EmailEditor\Utils;
|
namespace MailPoet\EmailEditor\Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for CDN asset URL.
|
||||||
|
*/
|
||||||
class Cdn_Asset_Url {
|
class Cdn_Asset_Url {
|
||||||
|
/**
|
||||||
|
* URL for CDN assets.
|
||||||
|
*/
|
||||||
const CDN_URL = 'https://ps.w.org/mailpoet/';
|
const CDN_URL = 'https://ps.w.org/mailpoet/';
|
||||||
/** @var string */
|
/**
|
||||||
private $baseUrl;
|
* Base URL for assets.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $base_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cdn_Asset_Url constructor.
|
||||||
|
*
|
||||||
|
* @param string $base_url - Base URL for assets.
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $baseUrl
|
string $base_url
|
||||||
) {
|
) {
|
||||||
$this->baseUrl = $baseUrl;
|
$this->base_url = $base_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateCdnUrl( $path ) {
|
/**
|
||||||
$useCdn = defined( 'MAILPOET_USE_CDN' ) ? MAILPOET_USE_CDN : true;
|
* Generate CDN URL for assets.
|
||||||
return ( $useCdn ? self::CDN_URL : $this->baseUrl . '/plugin_repository/' ) . "assets/$path";
|
*
|
||||||
|
* @param string $path - Path for assets.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate_cdn_url( $path ) {
|
||||||
|
$use_cdn = defined( 'MAILPOET_USE_CDN' ) ? MAILPOET_USE_CDN : true;
|
||||||
|
return ( $use_cdn ? self::CDN_URL : $this->base_url . '/plugin_repository/' ) . "assets/$path";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user