| 1 |
<?php |
| 2 |
namespace MaxButtons; |
| 3 |
defined('ABSPATH') or die('No direct access permitted'); |
| 4 |
|
| 5 |
class MBTablePress |
| 6 |
{ |
| 7 |
|
| 8 |
protected $enabled = false; |
| 9 |
|
| 10 |
public function __construct() |
| 11 |
{ |
| 12 |
add_filter('tablepress_table_raw_render_data', array($this, 'render_on'), 10, 2); |
| 13 |
add_filter('tablepress_table_output', array($this, 'render_off')); |
| 14 |
add_filter('mb_shortcode_display_args', array($this, 'shortcode_args'), 5); |
| 15 |
} |
| 16 |
|
| 17 |
public function render_on($table, $options) |
| 18 |
{ |
| 19 |
$this->enabled = true; |
| 20 |
return $table; |
| 21 |
} |
| 22 |
|
| 23 |
public function render_off($output) |
| 24 |
{ |
| 25 |
$this->enabled = false; |
| 26 |
return $output; |
| 27 |
} |
| 28 |
|
| 29 |
public function shortcode_args($args) |
| 30 |
{ |
| 31 |
$auto_press = apply_filters('mb/integrations/auto_inline_tablepress', true); |
| 32 |
if ($this->enabled && $auto_press) |
| 33 |
{ |
| 34 |
$args['load_css'] = 'inline'; // force inline css, because tablepress caches |
| 35 |
} |
| 36 |
return $args; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
$table = new MBTablePress(); |
| 43 |
|