1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89:
<?php
namespace WPGMZA\Integration;
if(!class_exists('WPGMZA\\Integration\\Gutenberg'))
return;
class ProGutenberg extends Gutenberg
{
public function __construct()
{
Gutenberg::__construct();
add_filter('wpgmza_plugin_get_localized_data', array(
$this,
'onPluginGetLocalizedData'
));
}
public function onPluginGetLocalizedData($data)
{
global $wpdb;
global $WPGMZA_TABLE_NAME_MAPS;
$maps = $wpdb->get_results("SELECT id, map_title FROM $WPGMZA_TABLE_NAME_MAPS WHERE active = 0");
$data['gutenbergData'] = array(
'maps' => $maps
);
return $data;
}
public function onRender($attr)
{
global $wpdb;
global $WPGMZA_TABLE_NAME_MAPS;
extract($attr);
$mapID = '1';
if(isset($attr['id']))
$mapID = $attr['id'];
else
$mapID = $wpdb->get_var("SELECT id FROM $WPGMZA_TABLE_NAME_MAPS LIMIT 1");
$output_attributes = array(
'id' => $mapID
);
if(!empty($attr['mashup_ids']))
{
$mashup_ids = $attr['mashup_ids'];
if(array_search($mapID, $mashup_ids) === false)
$mashup_ids[] = $mapID;
$output_attributes['mashup'] = 'true';
$output_attributes['mashup_ids'] = implode(',', $mashup_ids);
$output_attributes['parent_id'] = $mapID;
}
if(!empty($attr['className']))
{
$output_attributes['classname'] = $attr['className'];
}
$attributes_string = '';
foreach($output_attributes as $key => $value)
{
$attributes_string .= " {$key}=\"" . addslashes($value) . "\"";
}
$string = "[wpgmza{$attributes_string}]";
return $string;
}
}
add_filter('wpgmza_create_WPGMZA\\Integration\\Gutenberg', function($input) {
return new ProGutenberg();
}, 10, 1);