- Fixes 'Using $this when not in object context' error in PHP 5.3

This commit is contained in:
Vlad
2016-11-06 18:46:56 -05:00
parent 8df4da768a
commit 61c255564f
4 changed files with 20 additions and 16 deletions

View File

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

View File

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

View File

@@ -59,13 +59,14 @@ class Renderer {
? $content['blocks'] ? $content['blocks']
: array(); : 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_count = count($content_block['blocks']);
$column_data = $this->blocks_renderer->render( $column_data = $_this->blocks_renderer->render(
$content_block, $content_block,
$column_count $column_count
); );
return $this->columns_renderer->render( return $_this->columns_renderer->render(
$content_block['styles'], $content_block['styles'],
$column_count, $column_count,
$column_data $column_data

View File

@@ -48,9 +48,10 @@ class Shortcodes {
} }
function process($shortcodes, $content = false) { function process($shortcodes, $content = false) {
$_this = $this;
$processed_shortcodes = array_map( $processed_shortcodes = array_map(
function($shortcode) use ($content) { function($shortcode) use ($content, $_this) {
$shortcode_details = $this->match($shortcode); $shortcode_details = $_this->match($shortcode);
$shortcode_category = !empty($shortcode_details['category']) ? $shortcode_category = !empty($shortcode_details['category']) ?
ucfirst($shortcode_details['category']) : ucfirst($shortcode_details['category']) :
false; false;
@@ -66,9 +67,9 @@ class Shortcodes {
$custom_shortcode = apply_filters( $custom_shortcode = apply_filters(
'mailpoet_newsletter_shortcode', 'mailpoet_newsletter_shortcode',
$shortcode, $shortcode,
$this->newsletter, $_this->newsletter,
$this->subscriber, $_this->subscriber,
$this->queue, $_this->queue,
$content $content
); );
return ($custom_shortcode === $shortcode) ? return ($custom_shortcode === $shortcode) ?
@@ -78,9 +79,9 @@ class Shortcodes {
return $shortcode_class::process( return $shortcode_class::process(
$shortcode_action, $shortcode_action,
$shortcode_default_value, $shortcode_default_value,
$this->newsletter, $_this->newsletter,
$this->subscriber, $_this->subscriber,
$this->queue, $_this->queue,
$content $content
); );
}, $shortcodes); }, $shortcodes);