-
Notifications
You must be signed in to change notification settings - Fork 23
/
dk-pdf.php
executable file
·128 lines (89 loc) · 3.17 KB
/
dk-pdf.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
* Plugin Name: DK PDF
* Version: 1.9.9
* Description: WordPress to PDF made easy.
* Author: Emili Castells
* Author URI: https://dinamiko.dev
* Requires at least: 3.9
* Requires PHP: 8.0
* Tested up to: 6.7
* License: MIT
* Text Domain: dkpdf
* Domain Path: /languages/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'DKPDF' ) ) {
#[AllowDynamicProperties]
final class DKPDF {
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof DKPDF ) ) {
self::$instance = new DKPDF;
self::$instance->setup_constants();
add_action( 'plugins_loaded', array( self::$instance, 'dkpdf_load_textdomain' ) );
self::$instance->includes();
}
return self::$instance;
}
public function dkpdf_load_textdomain() {
load_plugin_textdomain( 'dkpdf', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
private function setup_constants() {
if ( ! defined( 'DKPDF_VERSION' ) ) {
define( 'DKPDF_VERSION', '1.9.7' );
}
if ( ! defined( 'DKPDF_PLUGIN_DIR' ) ) {
define( 'DKPDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'DKPDF_PLUGIN_URL' ) ) {
define( 'DKPDFPLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'DKPDF_PLUGIN_FILE' ) ) {
define( 'DKPDF_PLUGIN_FILE', __FILE__ );
}
}
private function includes() {
// settings / metaboxes
if ( is_admin() ) {
require_once DKPDF_PLUGIN_DIR . 'includes/class-dkpdf-settings.php';
$settings = new DKPDF_Settings( $this );
require_once DKPDF_PLUGIN_DIR . 'includes/class-dkpdf-admin-api.php';
$this->admin = new DKPDF_Admin_API();
require_once DKPDF_PLUGIN_DIR . 'includes/dkpdf-metaboxes.php';
}
// load css / js
require_once DKPDF_PLUGIN_DIR . 'includes/dkpdf-load-js-css.php';
// functions
require_once DKPDF_PLUGIN_DIR . 'includes/dkpdf-functions.php';
// shortcodes
require_once DKPDF_PLUGIN_DIR . 'includes/class-dkpdf-template-loader.php';
require_once DKPDF_PLUGIN_DIR . 'includes/dkpdf-shortcodes.php';
}
public function __clone() {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'dkpdf' ), DKPDF_VERSION );
}
public function __wakeup() {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'dkpdf' ), DKPDF_VERSION );
}
}
}
function DKPDF() {
if ( version_compare( phpversion(), '5.6.0', '<' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
deactivate_plugins( '/dk-pdf/dk-pdf.php' );
wp_die(
'<p>' . 'DK PDF can not be activated because it requires at least PHP version 5.6.0. '
. 'In case you can not update PHP, here you can <a href="'. esc_url('https://github.com/Dinamiko/dk-pdf/releases/tag/v1.9.3') .'" target="_blank">download DK PDF 1.9.3</a> which works with PHP 5.3 and above.'
. '</p>'
. '<a href="' . esc_url(admin_url( 'plugins.php' )) . '">' . esc_attr__( 'Back', 'dkpdf' ) . '</a>'
);
} else {
return DKPDF::instance();
}
}
DKPDF();