Skip to content

Commit a1b650c

Browse files
authored
Merge pull request #228 from bmlt-enabled/optimizations
optimization and logging
2 parents 2798af3 + 47b9e62 commit a1b650c

File tree

10 files changed

+320
-62
lines changed

10 files changed

+320
-62
lines changed

admin/class-bmltenabled-admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function admin_menu_link()
3737
$icon = apply_filters("BmltEnabled_IconSVG", 'dashicons-location-alt');
3838
$slug = $slugs[0];
3939
add_menu_page(
40-
'Meeting List',
41-
'Meeting List',
40+
'Meeting Lists',
41+
'Meeting Lists',
4242
$cap,
4343
$slug,
4444
'',

admin/class-bread-admin.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ function download_settings()
264264
$this->download_settings_inner();
265265
}
266266
}
267+
function download_mpdf_log()
268+
{
269+
if ($this->bread->exportingLogFile()) {
270+
$this->download_log_file();
271+
}
272+
}
267273
private function download_settings_inner()
268274
{
269275
$this->bread->getConfigurationForSettingId($this->bread->getRequestedSetting());
@@ -287,6 +293,33 @@ private function download_settings_inner()
287293
file_put_contents('php://output', $json_file);
288294
exit;
289295
}
296+
function download_log_file()
297+
{
298+
if (!isset($_REQUEST['export-mpdf-log'])) {
299+
exit;
300+
}
301+
foreach (Bread::get_log_files() as $log) {
302+
if ($log['name'] === $_REQUEST['export-mpdf-log']) {
303+
$this->exportLogFile($log['path']);
304+
}
305+
}
306+
exit;
307+
}
308+
function exportLogFile($file)
309+
{
310+
ignore_user_abort(true);
311+
header('Content-Description: File Transfer');
312+
header('Content-Type: text/html; charset=utf-8');
313+
header('Content-Disposition: attachment; filename="'.basename($file).'"');
314+
header('Expires: 0');
315+
header('Cache-Control: must-revalidate');
316+
header('Pragma: public');
317+
header('Content-Length: ' . filesize($file));
318+
ob_end_flush();
319+
readfile($file);// phpcs:ignore
320+
ob_end_flush();
321+
exit;
322+
}
290323
function current_user_can_modify()
291324
{
292325
if (! current_user_can('manage_bread')) {
@@ -416,8 +449,8 @@ function admin_submenu_link($parent_slug)
416449
global $my_admin_page;
417450
$my_admin_page = add_submenu_page(
418451
$parent_slug,
419-
'Printable Meeting List',
420-
'Printable Meeting List',
452+
'Printable Meeting Lists',
453+
'Printable Meeting Lists',
421454
'manage_bread',
422455
basename(__FILE__),
423456
array(&$this, 'admin_options_page'),
@@ -555,6 +588,9 @@ function process_customize_form()
555588
}
556589
$this->bread->getConfigurationForSettingId($this->bread->getRequestedSetting());
557590
$this->bread->setOption('bread_version', sanitize_text_field($_POST['bread_version']));
591+
$this->bread->setOption('logging', isset($_POST['logging']));
592+
$this->bread->setOption('simpleTables', isset($_POST['simpleTables']));
593+
$this->bread->setOption('packTabledata', isset($_POST['packTabledata']));
558594
$this->bread->setOption('front_page_content', wp_kses_post($_POST['front_page_content']));
559595
$this->bread->setOption('front_page_line_height', $_POST['front_page_line_height']);
560596
$this->bread->setOption('front_page_font_size', floatval($_POST['front_page_font_size']));
@@ -669,7 +705,7 @@ function process_customize_form()
669705
$this->bread->setOption('extra_meetings', array());
670706
if (isset($_POST['extra_meetings'])) {
671707
foreach ($_POST['extra_meetings'] as $extra) {
672-
$this->bread->setOption('extra_meetings', wp_kses_post($extra));
708+
$this->bread->appendOption('extra_meetings', wp_kses_post($extra));
673709
}
674710
}
675711
$authors = isset($_POST['authors_select']) ? $_POST['authors_select'] : [];

admin/partials/_bmlt_server_setup.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,32 @@
133133
</select>
134134
</div>
135135
</div>
136+
<div id="meetinglistloggingdiv" class="postbox">
137+
<h3 class="hndle">Optimize/Debug mPDF<span title='<p>If there are problens during meeting list generation, you may enable debugging to help locate the error.</p><p><i>Please disable if not actively involved in locating problems.</i></p>' class="my-tooltip"><span class="tooltipster-icon">(?)</span></span></h3>
138+
<div class="inside">
139+
<input type="checkbox" name="logging" id="logging" <?php echo $this->bread->emptyOption('logging') ? '' : 'checked'; ?>>
140+
<label for="logging">Enable Logging</label>
141+
<br/>
142+
<input type="checkbox" name="simpleTables" id="simpleTables" <?php echo $this->bread->emptyOption('simpleTables') ? '' : 'checked'; ?>>
143+
<label for="simpleTables">Enable SimpleTables</label>
144+
<br/>
145+
<input type="checkbox" name="packTabledata" id="packTabledata" <?php echo $this->bread->emptyOption('packTabledata') ? '' : 'checked'; ?>>
146+
<label for="packTabledata">Pack Table Data</label>
147+
<?php
148+
$logs = Bread::get_log_files();
149+
if (!empty($logs)) {?>
150+
<br/><h4>Download Log Files</h4>
151+
<?php
152+
foreach ($logs as $log) {
153+
?>
154+
<a href="<?php echo esc_url(home_url().'/?export-mpdf-log='.$log['name']);?>"><?php echo esc_html($log['name']);?></a>
155+
<?php
156+
}
157+
}
158+
?>
159+
<br/>
160+
</div>
161+
</div>
136162
<div id="meetinglistcachediv" class="postbox">
137163
<h3 class="hndle">Meeting List Cache<span title='<p>Meeting List data is cached (as database transient) to generate a Meeting List faster.</p><p><i>CACHE is DELETED when you Save Changes.</i></p><p><b>The meeting list will not reflect changes to BMLT until the cache expires or is deleted.</b></p>' class="my-tooltip"><span class="tooltipster-icon">(?)</span></span></h3>
138164
<div class="inside">

bmlt-meeting-list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Bread
1212
* Plugin URI: https://bmlt.app
1313
* Description: Maintains and generates PDF Meeting Lists from BMLT.
14-
* Version: 2.8.11
14+
* Version: 2.9.0
1515
* Author: bmlt-enabled
1616
* Author URI: https://bmlt.app/
1717
* License: GPL-2.0+

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
],
1111
"require": {
1212
"mpdf/mpdf": "8.2.3",
13+
"monolog/monolog": "3.8.1",
1314
"mpdf/qrcode": "^1.0",
1415
"myclabs/deep-copy": "1.11.1"
1516
},

0 commit comments

Comments
 (0)