Add public keyword to methods
[MAILPOET-2413]
This commit is contained in:
@ -6,7 +6,7 @@ use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
|
||||
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||
|
||||
class Button {
|
||||
static function render($element, $column_base_width) {
|
||||
public static function render($element, $column_base_width) {
|
||||
$element['styles']['block']['width'] = self::calculateWidth($element, $column_base_width);
|
||||
$styles = 'display:inline-block;-webkit-text-size-adjust:none;mso-hide:all;text-decoration:none !important;text-align:center;' . StylesHelper::getBlockStyles($element, $exclude = ['textAlign']);
|
||||
$styles = EHelper::escapeHtmlStyleAttr($styles);
|
||||
@ -43,7 +43,7 @@ class Button {
|
||||
return $template;
|
||||
}
|
||||
|
||||
static function calculateWidth($element, $column_base_width) {
|
||||
public static function calculateWidth($element, $column_base_width) {
|
||||
$column_width = $column_base_width - (StylesHelper::$padding_width * 2);
|
||||
$border_width = (int)$element['styles']['block']['borderWidth'];
|
||||
$button_width = (int)$element['styles']['block']['width'];
|
||||
|
@ -6,7 +6,7 @@ use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
|
||||
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||
|
||||
class Divider {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$background_color = $element['styles']['block']['backgroundColor'];
|
||||
$divider_cell_style = "border-top-width: {$element['styles']['block']['borderWidth']};";
|
||||
$divider_cell_style .= "border-top-style: {$element['styles']['block']['borderStyle']};";
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Util\pQuery\pQuery;
|
||||
use MailPoetVendor\CSS;
|
||||
|
||||
class Footer {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$element['text'] = preg_replace('/\n/', '<br />', $element['text']);
|
||||
$element['text'] = preg_replace('/(<\/?p.*?>)/i', '', $element['text']);
|
||||
$line_height = sprintf(
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Util\pQuery\pQuery;
|
||||
use MailPoetVendor\CSS;
|
||||
|
||||
class Header {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$element['text'] = preg_replace('/\n/', '<br />', $element['text']);
|
||||
$element['text'] = preg_replace('/(<\/?p.*?>)/i', '', $element['text']);
|
||||
$line_height = sprintf(
|
||||
|
@ -7,7 +7,7 @@ use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Image {
|
||||
static function render($element, $column_base_width) {
|
||||
public static function render($element, $column_base_width) {
|
||||
if (empty($element['src'])) {
|
||||
return '';
|
||||
}
|
||||
@ -51,7 +51,7 @@ class Image {
|
||||
return $template;
|
||||
}
|
||||
|
||||
static function adjustImageDimensions($element, $column_base_width) {
|
||||
public static function adjustImageDimensions($element, $column_base_width) {
|
||||
$padded_width = StylesHelper::$padding_width * 2;
|
||||
// scale image to fit column width
|
||||
if ($element['width'] > $column_base_width) {
|
||||
|
@ -12,7 +12,7 @@ class Renderer {
|
||||
public $posts;
|
||||
public $ALC;
|
||||
|
||||
function __construct(array $newsletter) {
|
||||
public function __construct(array $newsletter) {
|
||||
$this->newsletter = $newsletter;
|
||||
$this->posts = [];
|
||||
$newer_than_timestamp = false;
|
||||
@ -31,7 +31,7 @@ class Renderer {
|
||||
);
|
||||
}
|
||||
|
||||
function render($data) {
|
||||
public function render($data) {
|
||||
$column_count = count($data['blocks']);
|
||||
$columns_layout = isset($data['columnLayout']) ? $data['columnLayout'] : null;
|
||||
$column_widths = ColumnsHelper::columnWidth($column_count, $columns_layout);
|
||||
@ -63,7 +63,7 @@ class Renderer {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
function createElementFromBlockType($block, $column_base_width) {
|
||||
public function createElementFromBlockType($block, $column_base_width) {
|
||||
if ($block['type'] === 'automatedLatestContent') {
|
||||
$content = $this->processAutomatedLatestContent($block, $column_base_width);
|
||||
return $content;
|
||||
@ -76,7 +76,7 @@ class Renderer {
|
||||
return $block_class::render($block, $column_base_width);
|
||||
}
|
||||
|
||||
function automatedLatestContentTransformedPosts($args) {
|
||||
public function automatedLatestContentTransformedPosts($args) {
|
||||
$posts_to_exclude = $this->getPosts();
|
||||
$ALC_posts = $this->ALC->getPosts($args, $posts_to_exclude);
|
||||
foreach ($ALC_posts as $post) {
|
||||
@ -86,7 +86,7 @@ class Renderer {
|
||||
return $this->ALC->transformPosts($args, $ALC_posts);
|
||||
}
|
||||
|
||||
function processAutomatedLatestContent($args, $column_base_width) {
|
||||
public function processAutomatedLatestContent($args, $column_base_width) {
|
||||
$transformed_posts = [
|
||||
'blocks' => $this->automatedLatestContentTransformedPosts($args),
|
||||
];
|
||||
@ -95,11 +95,11 @@ class Renderer {
|
||||
return $rendered_posts;
|
||||
}
|
||||
|
||||
function getPosts() {
|
||||
public function getPosts() {
|
||||
return $this->posts;
|
||||
}
|
||||
|
||||
function setPosts($posts) {
|
||||
public function setPosts($posts) {
|
||||
return $this->posts = $posts;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||
use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
|
||||
|
||||
class Social {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$icons_block = '';
|
||||
if (is_array($element['icons'])) {
|
||||
foreach ($element['icons'] as $index => $icon) {
|
||||
@ -15,10 +15,10 @@ class Social {
|
||||
|
||||
$style = 'width:' . $icon['width'] . ';height:' . $icon['width'] . ';-ms-interpolation-mode:bicubic;border:0;display:inline;outline:none;';
|
||||
$icons_block .= '<a href="' . EHelper::escapeHtmlLinkAttr($icon['link']) . '" style="text-decoration:none!important;"
|
||||
><img
|
||||
><img
|
||||
src="' . EHelper::escapeHtmlLinkAttr($icon['image']) . '"
|
||||
width="' . (int)$icon['width'] . '"
|
||||
height="' . (int)$icon['height'] . '"
|
||||
width="' . (int)$icon['width'] . '"
|
||||
height="' . (int)$icon['height'] . '"
|
||||
style="' . EHelper::escapeHtmlStyleAttr($style) . '"
|
||||
alt="' . EHelper::escapeHtmlAttr($icon['iconType']) . '"
|
||||
></a> ';
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||
use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
|
||||
|
||||
class Spacer {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$height = (int)$element['styles']['block']['height'];
|
||||
$background_color = EHelper::escapeHtmlAttr($element['styles']['block']['backgroundColor']);
|
||||
$template = '
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||
use MailPoet\Util\pQuery\pQuery;
|
||||
|
||||
class Text {
|
||||
static function render($element) {
|
||||
public static function render($element) {
|
||||
$html = $element['text'];
|
||||
// replace with spaces
|
||||
$html = str_replace(' ', ' ', $html);
|
||||
@ -27,7 +27,7 @@ class Text {
|
||||
return $template;
|
||||
}
|
||||
|
||||
static function convertBlockquotesToTables($html) {
|
||||
public static function convertBlockquotesToTables($html) {
|
||||
$DOM_parser = new pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$blockquotes = $DOM->query('blockquote');
|
||||
@ -72,7 +72,7 @@ class Text {
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function convertParagraphsToTables($html) {
|
||||
public static function convertParagraphsToTables($html) {
|
||||
$DOM_parser = new pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$paragraphs = $DOM->query('p');
|
||||
@ -136,7 +136,7 @@ class Text {
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function styleLists($html) {
|
||||
public static function styleLists($html) {
|
||||
$DOM_parser = new pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$lists = $DOM->query('ol, ul, li');
|
||||
@ -156,7 +156,7 @@ class Text {
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function styleHeadings($html) {
|
||||
public static function styleHeadings($html) {
|
||||
$DOM_parser = new pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$headings = $DOM->query('h1, h2, h3, h4');
|
||||
@ -169,11 +169,11 @@ class Text {
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function removeLastLineBreak($html) {
|
||||
public static function removeLastLineBreak($html) {
|
||||
return preg_replace('/(^)?(<br[^>]*?\/?>)+$/i', '', $html);
|
||||
}
|
||||
|
||||
static function insertLineBreak($element) {
|
||||
public static function insertLineBreak($element) {
|
||||
$element->parent->insertChild(
|
||||
[
|
||||
'tag_name' => 'br',
|
||||
|
@ -24,22 +24,22 @@ class ColumnsHelper {
|
||||
];
|
||||
|
||||
/** @return int[] */
|
||||
static function columnWidth($columns_count, $columns_layout) {
|
||||
public static function columnWidth($columns_count, $columns_layout) {
|
||||
if (isset(self::$columns_width[$columns_layout])) {
|
||||
return self::$columns_width[$columns_layout];
|
||||
}
|
||||
return self::$columns_width[$columns_count];
|
||||
}
|
||||
|
||||
static function columnClass($columns_count) {
|
||||
public static function columnClass($columns_count) {
|
||||
return self::$columns_class[$columns_count];
|
||||
}
|
||||
|
||||
static function columnClasses() {
|
||||
public static function columnClasses() {
|
||||
return self::$columns_class;
|
||||
}
|
||||
|
||||
static function columnAlignment($columns_count) {
|
||||
public static function columnAlignment($columns_count) {
|
||||
return self::$columns_alignment[$columns_count];
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
|
||||
|
||||
class Renderer {
|
||||
|
||||
function render($content_block, $columns_data) {
|
||||
public function render($content_block, $columns_data) {
|
||||
|
||||
$columns_count = count($content_block['blocks']);
|
||||
|
||||
@ -24,7 +24,7 @@ class Renderer {
|
||||
return $template['content_start'] . $content . $template['content_end'];
|
||||
}
|
||||
|
||||
function getOneColumnTemplate($styles, $image) {
|
||||
public function getOneColumnTemplate($styles, $image) {
|
||||
$background_css = $this->getBackgroundCss($styles, $image);
|
||||
$template['content_start'] = '
|
||||
<tr>
|
||||
@ -99,7 +99,7 @@ class Renderer {
|
||||
</td>';
|
||||
}
|
||||
|
||||
function getMultipleColumnsContentStart($width, $alignment, $class) {
|
||||
public function getMultipleColumnsContentStart($width, $alignment, $class) {
|
||||
return '
|
||||
<td width="' . $width . '" valign="top">
|
||||
<![endif]--><div style="display:inline-block; max-width:' . $width . 'px; vertical-align:top; width:100%;">
|
||||
|
@ -7,7 +7,7 @@ class EscapeHelper {
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
static function escapeHtmlText($string) {
|
||||
public static function escapeHtmlText($string) {
|
||||
return htmlspecialchars((string)$string, ENT_NOQUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ class EscapeHelper {
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
static function escapeHtmlAttr($string) {
|
||||
public static function escapeHtmlAttr($string) {
|
||||
return htmlspecialchars((string)$string, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ class EscapeHelper {
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
static function escapeHtmlStyleAttr($string) {
|
||||
public static function escapeHtmlStyleAttr($string) {
|
||||
return htmlspecialchars((string)$string, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class EscapeHelper {
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
static function unescapeHtmlStyleAttr($string) {
|
||||
public static function unescapeHtmlStyleAttr($string) {
|
||||
return htmlspecialchars_decode((string)$string, ENT_COMPAT);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ class EscapeHelper {
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
static function escapeHtmlLinkAttr($string) {
|
||||
public static function escapeHtmlLinkAttr($string) {
|
||||
$string = self::escapeHtmlAttr($string);
|
||||
if (preg_match('/\s*(javascript:|data:text|data:application)/ui', $string) === 1) {
|
||||
return '';
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Util\pQuery\pQuery;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class OpenTracking {
|
||||
static function process($template) {
|
||||
public static function process($template) {
|
||||
$DOM = new pQuery();
|
||||
$DOM = $DOM->parseStr($template);
|
||||
$template = $DOM->query('body');
|
||||
@ -23,7 +23,7 @@ class OpenTracking {
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function addTrackingImage() {
|
||||
public static function addTrackingImage() {
|
||||
WPFunctions::get()->addFilter(Renderer::FILTER_POST_PROCESS, function ($template) {
|
||||
return OpenTracking::process($template);
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ class Renderer {
|
||||
/**
|
||||
* @param \MailPoet\Models\Newsletter|array $newsletter
|
||||
*/
|
||||
function __construct($newsletter, $preview = false) {
|
||||
public function __construct($newsletter, $preview = false) {
|
||||
$this->newsletter = ($newsletter instanceof Newsletter) ? $newsletter->asArray() : $newsletter;
|
||||
$this->preview = $preview;
|
||||
$this->blocks_renderer = new Blocks\Renderer($this->newsletter);
|
||||
@ -44,7 +44,7 @@ class Renderer {
|
||||
$this->mss_activated = $bridge->isMPSendingServiceEnabled();
|
||||
}
|
||||
|
||||
function render($type = false) {
|
||||
public function render($type = false) {
|
||||
$newsletter = $this->newsletter;
|
||||
$body = (is_array($newsletter['body']))
|
||||
? $newsletter['body']
|
||||
|
@ -62,14 +62,14 @@ class StylesHelper {
|
||||
static $heading_margin_multiplier = 0.3;
|
||||
static $padding_width = 20;
|
||||
|
||||
static function getBlockStyles($element, $ignore_specific_styles = false) {
|
||||
public static function getBlockStyles($element, $ignore_specific_styles = false) {
|
||||
if (!isset($element['styles']['block'])) {
|
||||
return;
|
||||
}
|
||||
return self::getStyles($element['styles'], 'block', $ignore_specific_styles);
|
||||
}
|
||||
|
||||
static function getStyles($data, $type, $ignore_specific_styles = false) {
|
||||
public static function getStyles($data, $type, $ignore_specific_styles = false) {
|
||||
$styles = array_map(function($attribute, $style) use ($ignore_specific_styles) {
|
||||
if (!$ignore_specific_styles || !in_array($attribute, $ignore_specific_styles)) {
|
||||
$style = StylesHelper::applyFontFamily($attribute, $style);
|
||||
@ -79,13 +79,13 @@ class StylesHelper {
|
||||
return implode('', $styles);
|
||||
}
|
||||
|
||||
static function translateCSSAttribute($attribute) {
|
||||
public static function translateCSSAttribute($attribute) {
|
||||
return (array_key_exists($attribute, self::$css_attributes)) ?
|
||||
self::$css_attributes[$attribute] :
|
||||
$attribute;
|
||||
}
|
||||
|
||||
static function setStyle($style, $selector) {
|
||||
public static function setStyle($style, $selector) {
|
||||
$css = $selector . '{' . PHP_EOL;
|
||||
$style = self::applyHeadingMargin($style, $selector);
|
||||
$style = self::applyLineHeight($style, $selector);
|
||||
@ -97,7 +97,7 @@ class StylesHelper {
|
||||
return $css;
|
||||
}
|
||||
|
||||
static function applyTextAlignment($block) {
|
||||
public static function applyTextAlignment($block) {
|
||||
if (is_array($block)) {
|
||||
$text_alignment = isset($block['styles']['block']['textAlign']) ?
|
||||
strtolower($block['styles']['block']['textAlign']) :
|
||||
@ -113,21 +113,21 @@ class StylesHelper {
|
||||
$block . 'text-align:left;';
|
||||
}
|
||||
|
||||
static function applyFontFamily($attribute, $style) {
|
||||
public static function applyFontFamily($attribute, $style) {
|
||||
if ($attribute !== 'fontFamily') return $style;
|
||||
return (isset(self::$font[$style])) ?
|
||||
self::$font[$style] :
|
||||
self::$font['Arial'];
|
||||
}
|
||||
|
||||
static function applyHeadingMargin($style, $selector) {
|
||||
public static function applyHeadingMargin($style, $selector) {
|
||||
if (!preg_match('/h[1-4]/i', $selector)) return $style;
|
||||
$font_size = (int)$style['fontSize'];
|
||||
$style['margin'] = sprintf('0 0 %spx 0', self::$heading_margin_multiplier * $font_size);
|
||||
return $style;
|
||||
}
|
||||
|
||||
static function applyLineHeight($style, $selector) {
|
||||
public static function applyLineHeight($style, $selector) {
|
||||
if (!preg_match('/mailpoet_paragraph|h[1-4]/i', $selector)) return $style;
|
||||
$line_height = isset($style['lineHeight']) ? (float)$style['lineHeight'] : self::$default_line_height;
|
||||
$font_size = (int)$style['fontSize'];
|
||||
@ -145,7 +145,7 @@ class StylesHelper {
|
||||
return array_keys($font_names);
|
||||
}
|
||||
|
||||
static function getCustomFontsLinks($styles) {
|
||||
public static function getCustomFontsLinks($styles) {
|
||||
$links = [];
|
||||
foreach (self::getCustomFontsNames($styles) as $name) {
|
||||
$links[] = urlencode($name) . ':400,400i,700,700i';
|
||||
|
Reference in New Issue
Block a user