<?php
/*
Plugin Name: BT mPDF
Plugin URI: https://www.bt-webdesign.de
Description: Autoload mPDF v8.2.6 für PHP v8.5
Version: 7.0.0
Author: BT Webdesign
Author URI: https://www.bt-webdesign.de
*/

/*
 * This file is part of BT-mPDF.
 * bt-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * bt-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with bt-mpdf. If not, see <http://www.gnu.org/licenses/>.
 */

define( 'BT_MPDF_VERSION', '7.0.0' );
define( 'BT_MPDF_PHP_VERSION', '8.5' );                                         // nur Major- und Minor-Version
define( 'BT_MPDF_COMARE_PHP_VERSION', str_replace('.', "", BT_MPDF_PHP_VERSION) );
define( 'BT_MPDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'BT_MPDF_PLUGIN_HANDBUCH', 'backend/bt-mpdf/' );
define( 'BT_MPDF_PLUGIN_WEBSITE', 'https://tennisturnier.info/docs/handbuch-wordpress-tennisturnier-plugin/'.BT_MPDF_PLUGIN_HANDBUCH );

function bt_mpdf_info(){
  echo '<div style="margin:30px; padding:30px; background:#fff;">';
  echo '<h1>Plugin BT mPDF '. getHandbuchAdresse(BT_MPDF_PLUGIN_HANDBUCH) .'</h1>';
  echo '<h2>Plugin-Version: '.BT_MPDF_VERSION.'</h2>';
  echo '<p>Require mPDF für PHP-Version: '.BT_MPDF_PHP_VERSION.'</p>';
  echo '<p>Installierte PHP-Version '.PHP_VERSION.'</p>';

  if ( PHP_MAJOR_VERSION.PHP_MINOR_VERSION == BT_MPDF_COMARE_PHP_VERSION )
      echo '<p style="color:green"><b>&#10004; Perfekt!</b> PHP-Version passt zur Plugin-Version von BT mPDF</p>';
  else
  if ( PHP_MAJOR_VERSION.PHP_MINOR_VERSION < BT_MPDF_COMARE_PHP_VERSION )
      echo '<p style="color:red"><b>&#10008; PHP-Version ('.PHP_VERSION.') ist zu niedrig! Sollte mindestens PHP Version '.BT_MPDF_PHP_VERSION.' sein. Alternativ andere Version von Plugin BT-MPDF installieren.</b></p>';
  else
      echo '<p style="color:red"><b>&#10008; BT-mPDF-Version ist eventuell zu niedrig! Empfehlung: aktuellere Version vom Plugin BT-mPDF installieren.</b></p>';

  echo '<h2>Plugin Website: <a href="'.BT_MPDF_PLUGIN_WEBSITE.'" target="_blank">Tennisturnier Software - BT mPDF</a>';
  echo '</div>';
}
/**
* Admin new Mpdf
* Aufruf aus Plugin BT Tennisturnier
*
* @since 1.0.0
*/
function newMpdf($mode, $format, $margin_left, $margin_right, $margin_top, $margin_bottom){
global $mpdf;
require_once BT_MPDF_PLUGIN_DIR. '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf(['mode' => $mode, 'format' => $format, 'margin_left' => $margin_left, 'margin_right' => $margin_right, 'margin_top' => $margin_top, 'margin_bottom' => $margin_bottom]);
return $mpdf;
}