Merge pull request #699 from mailpoet/php53-fix

Fixes various errors on PHP 5.3.x
This commit is contained in:
Jonathan Labreuille
2016-11-07 16:48:18 +01:00
committed by GitHub
6 changed files with 23 additions and 19 deletions

View File

@ -52,8 +52,9 @@ class Migrator {
function down() {
global $wpdb;
$drop_table = function($model) use($wpdb) {
$table = $this->prefix . $model;
$_this = $this;
$drop_table = function($model) use($wpdb, $_this) {
$table = $_this->prefix . $model;
$wpdb->query("DROP TABLE {$table}");
};

View File

@ -38,10 +38,11 @@ class Renderer {
function render($data, $column_count) {
$block_content = '';
array_map(function($block) use (&$block_content, &$column_content, $column_count) {
$rendered_block_element = $this->createElementFromBlockType($block, $column_count);
$_this = $this;
array_map(function($block) use (&$block_content, &$column_content, $column_count, $_this) {
$rendered_block_element = $_this->createElementFromBlockType($block, $column_count);
if(isset($block['blocks'])) {
$rendered_block_element = $this->render($block, $column_count);
$rendered_block_element = $_this->render($block, $column_count);
}
// vertical orientation denotes column container
if($block['type'] === 'container' && $block['orientation'] === 'vertical') {

View File

@ -11,7 +11,7 @@ class Renderer {
$this->getOneColumnTemplate($styles, $class) :
$this->getMultipleColumnsTemplate($styles, $width, $alignment, $class);
$result = array_map(function($content) use ($template) {
$content = self::removePaddingFromLastElement($content);
$content = Renderer::removePaddingFromLastElement($content);
return $template['content_start'] . $content . $template['content_end'];
}, $columns_data);
$result = implode('', $result);

View File

@ -59,13 +59,14 @@ class Renderer {
? $content['blocks']
: array();
$rendered_content = array_map(function($content_block) {
$_this = $this;
$rendered_content = array_map(function($content_block) use($_this) {
$column_count = count($content_block['blocks']);
$column_data = $this->blocks_renderer->render(
$column_data = $_this->blocks_renderer->render(
$content_block,
$column_count
);
return $this->columns_renderer->render(
return $_this->columns_renderer->render(
$content_block['styles'],
$column_count,
$column_data

View File

@ -41,7 +41,7 @@ class StylesHelper {
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)) {
return self::translateCSSAttribute($attribute) . ': ' . $style . ' !important;';
return StylesHelper::translateCSSAttribute($attribute) . ': ' . $style . ' !important;';
}
}, array_keys($data[$type]), $data[$type]);
return implode('', $styles);

View File

@ -42,9 +42,10 @@ class Shortcodes {
}
function process($shortcodes, $content = false) {
$_this = $this;
$processed_shortcodes = array_map(
function($shortcode) use ($content) {
$shortcode_details = $this->match($shortcode);
function($shortcode) use ($content, $_this) {
$shortcode_details = $_this->match($shortcode);
$shortcode_category = !empty($shortcode_details['category']) ?
ucfirst($shortcode_details['category']) :
false;
@ -52,7 +53,7 @@ class Shortcodes {
$shortcode_details['action'] :
false;
$shortcode_class =
self::SHORTCODE_CATEGORY_NAMESPACE . $shortcode_category;
Shortcodes::SHORTCODE_CATEGORY_NAMESPACE . $shortcode_category;
$shortcode_default_value = !empty($shortcode_details['default']) ?
$shortcode_details['default'] :
false;
@ -60,9 +61,9 @@ class Shortcodes {
$custom_shortcode = apply_filters(
'mailpoet_newsletter_shortcode',
$shortcode,
$this->newsletter,
$this->subscriber,
$this->queue,
$_this->newsletter,
$_this->subscriber,
$_this->queue,
$content
);
return ($custom_shortcode === $shortcode) ?
@ -72,9 +73,9 @@ class Shortcodes {
return $shortcode_class::process(
$shortcode_action,
$shortcode_default_value,
$this->newsletter,
$this->subscriber,
$this->queue,
$_this->newsletter,
$_this->subscriber,
$_this->queue,
$content
);
}, $shortcodes);