- 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() {
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

@@ -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

@@ -48,9 +48,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;
@@ -66,9 +67,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) ?
@@ -78,9 +79,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);