PluginProbe
Embed Privacy / trunk
Embed Privacy vtrunk
1.14.0 1.13.0 trunk 0.1 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.10 1.10.2 1.10.3 1.10.4 1.10.5 1.10.6 1.10.7 1.10.8 1.10.9 1.11.0 1.11.1 1.11.2 All 68 releases
embed-privacy / embed-privacy.php

embed-privacy.php in Embed Privacy trunk, at embed-privacy.php

97 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace epiphyt\Embed_Privacy;
3
4 /*
5 Plugin Name: Embed Privacy
6 Plugin URL: https://epiph.yt/en/embed-privacy/
7 Description: Embed Privacy prevents from loading external embeds directly and lets the user control which one should be loaded.
8 Version: 1.14.0
9 Author: Epiphyt
10 Author URI: https://epiph.yt/en/
11 License: GPL2
12 License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 Requires at least: 5.9
14 Requires PHP: 5.6
15 Tested up to: 7.1
16 Text Domain: embed-privacy
17
18 Embed Privacy is free software: you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation, either version 2 of the License, or
21 any later version.
22
23 Embed Privacy is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27
28 You should have received a copy of the GNU General Public License
29 along with Embed Privacy. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
30 */
31 \defined( 'ABSPATH' ) || exit;
32
33 if ( ! \defined( 'EPI_EMBED_PRIVACY_BASE' ) ) {
34 if ( \file_exists( \WP_PLUGIN_DIR . '/embed-privacy/' ) ) {
35 \define( 'EPI_EMBED_PRIVACY_BASE', \WP_PLUGIN_DIR . '/embed-privacy/' );
36 }
37 else if ( \file_exists( \WPMU_PLUGIN_DIR . '/embed-privacy/' ) ) {
38 \define( 'EPI_EMBED_PRIVACY_BASE', \WPMU_PLUGIN_DIR . '/embed-privacy/' );
39 }
40 else {
41 \define( 'EPI_EMBED_PRIVACY_BASE', \plugin_dir_path( __FILE__ ) );
42 }
43 }
44
45 \define( 'EPI_EMBED_PRIVACY_FILE', \EPI_EMBED_PRIVACY_BASE . \basename( __FILE__ ) );
46 \define( 'EPI_EMBED_PRIVACY_URL', \plugin_dir_url( \EPI_EMBED_PRIVACY_FILE ) );
47 \define( 'EMBED_PRIVACY_VERSION', '1.14.0' );
48
49 if ( ! \class_exists( 'DOMDocument' ) ) {
50 /**
51 * Disable the plugin if the php-dom extension is missing.
52 */
53 function disable_plugin() {
54 ?>
55 <div class="notice notice-error">
56 <p><?php \esc_html_e( 'The PHP extension "Document Object Model" (php-dom) is missing. Embed Privacy requires this extension to be installed and enabled. Please ask your hosting provider to install and enable it. Embed Privacy disables itself now. Please re-enable it again if the extension is installed and enabled.', 'embed-privacy' ); ?></p>
57 </div>
58 <?php
59 \deactivate_plugins( \plugin_basename( __FILE__ ) );
60 }
61
62 \add_action( 'admin_notices', __NAMESPACE__ . '\disable_plugin' );
63 }
64
65 /**
66 * Autoload all necessary classes.
67 *
68 * @param string $class_name The class name of the auto-loaded class
69 */
70 \spl_autoload_register( static function( $class_name ) {
71 $path = \explode( '\\', $class_name );
72 $filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) );
73
74 if ( \strpos( $class_name, __NAMESPACE__ ) !== 0 ) {
75 return;
76 }
77
78 $class_name = \str_replace(
79 [ 'epiphyt\embed_privacy\\', '\\', '_' ],
80 [ '', '/', '-' ],
81 \strtolower( $class_name )
82 );
83 $name_pos = \strrpos( $class_name, $filename );
84
85 if ( $name_pos !== false ) {
86 $class_name = \substr_replace( $class_name, 'class-' . $filename, $name_pos, \strlen( $filename ) );
87 }
88
89 $maybe_file = __DIR__ . '/inc/' . $class_name . '.php';
90
91 if ( \file_exists( $maybe_file ) ) {
92 require_once $maybe_file;
93 }
94 } );
95
96 Embed_Privacy::get_instance()->init();
97