-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpress-this-extended.php
More file actions
211 lines (184 loc) · 5.07 KB
/
press-this-extended.php
File metadata and controls
211 lines (184 loc) · 5.07 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
/**
* Press This Extended
*
* @package BJGK\Press_This_Extended
* @version 2.0.0
* @author Brandon Kraft <[email protected]>
* @copyright Copyright (c) 2015-2024, Brandon Kraft
* @link https://www.brandonkraft.com/press-this-extended/
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: Press This Extended
* Plugin URI: https://www.brandonkraft.com/press-this-extended/
* Description: Provides options for extending and modifying the Press This plugin filters. Supports both Press This 1.x and 2.x.
* Version: 2.0.0
* Author: Brandon Kraft
* Author URI: https://www.brandonkraft.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: press-this-extended
* Domain Path: /languages
* Requires at least: 6.9
* Requires PHP: 7.4
*/
/*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
* that you can use any other version of the GPL.
*
* This program 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.
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define plugin constants
define( 'PRESS_THIS_EXTENDED_VERSION', '2.0.0' );
define( 'PRESS_THIS_EXTENDED_FILE', __FILE__ );
define( 'PRESS_THIS_EXTENDED_DIR', plugin_dir_path( __FILE__ ) );
define( 'PRESS_THIS_EXTENDED_URL', plugin_dir_url( __FILE__ ) );
/**
* Main plugin class.
*
* @since 2.0.0
*/
final class Press_This_Extended {
/**
* Plugin instance.
*
* @var Press_This_Extended|null
*/
private static $instance = null;
/**
* Settings handler.
*
* @var PressThisExtended\Settings
*/
private $settings;
/**
* Filters handler.
*
* @var PressThisExtended\Filters
*/
private $filters;
/**
* Get plugin instance.
*
* @return Press_This_Extended
*/
public static function get_instance() {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
private function __construct() {
$this->load_dependencies();
$this->init();
}
/**
* Load required files.
*/
private function load_dependencies() {
require_once PRESS_THIS_EXTENDED_DIR . 'includes/class-version-detector.php';
require_once PRESS_THIS_EXTENDED_DIR . 'includes/class-settings.php';
require_once PRESS_THIS_EXTENDED_DIR . 'includes/class-filters.php';
require_once PRESS_THIS_EXTENDED_DIR . 'includes/class-legacy-compat.php';
}
/**
* Initialize the plugin.
*/
private function init() {
// Load translations
add_action( 'init', array( $this, 'load_translations' ) );
// Initialize legacy compatibility (runs early)
PressThisExtended\Legacy_Compat::init();
// Initialize settings
$this->settings = new PressThisExtended\Settings();
$this->settings->init();
// Initialize filters
$this->filters = new PressThisExtended\Filters( $this->settings );
$this->filters->init();
// Add plugin action links
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
// Add mobile web app meta tags (legacy feature)
add_action( 'admin_head-press-this.php', array( $this, 'mobile_app_meta' ) );
}
/**
* Load translations.
*/
public function load_translations() {
$domain = 'press-this-extended';
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
load_textdomain(
$domain,
trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo'
);
load_plugin_textdomain(
$domain,
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages'
);
}
/**
* Add settings link to plugins page.
*
* @param array $links Existing links.
* @return array Modified links.
*/
public function action_links( $links ) {
$settings_link = sprintf(
'<a href="%s">%s</a>',
admin_url( 'options-general.php?page=press-this-extended' ),
__( 'Settings', 'press-this-extended' )
);
array_unshift( $links, $settings_link );
return $links;
}
/**
* Add mobile web app meta tags for Press This.
*
* Makes Press This into a standalone web app on iOS and Chrome for Android.
*
* @since 1.1.0
*/
public function mobile_app_meta() {
?>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="mobile-web-app-capable" content="yes">
<?php
}
/**
* Get the settings handler.
*
* @return PressThisExtended\Settings
*/
public function get_settings() {
return $this->settings;
}
/**
* Get the filters handler.
*
* @return PressThisExtended\Filters
*/
public function get_filters() {
return $this->filters;
}
}
/**
* Get the plugin instance.
*
* @return Press_This_Extended
*/
function press_this_extended() {
return Press_This_Extended::get_instance();
}
// Initialize the plugin
add_action( 'plugins_loaded', 'press_this_extended' );