| 1 |
<?php |
| 2 |
namespace epiphyt\Embed_Privacy; |
| 3 |
|
| 4 |
/* |
| 5 |
Plugin Name: Embed Privacy |
| 6 |
Description: Embed Privacy prevents from loading external embeds directly and lets the user control which one should be loaded. |
| 7 |
Version: 1.9.1 |
| 8 |
Author: Epiphyt |
| 9 |
Author URI: https://epiph.yt |
| 10 |
License: GPL2 |
| 11 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 12 |
Text Domain: embed-privacy |
| 13 |
Domain Path: /languages |
| 14 |
|
| 15 |
Embed Privacy is free software: you can redistribute it and/or modify |
| 16 |
it under the terms of the GNU General Public License as published by |
| 17 |
the Free Software Foundation, either version 2 of the License, or |
| 18 |
any later version. |
| 19 |
|
| 20 |
Embed Privacy is distributed in the hope that it will be useful, |
| 21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
GNU General Public License for more details. |
| 24 |
|
| 25 |
You should have received a copy of the GNU General Public License |
| 26 |
along with Embed Privacy. If not, see https://www.gnu.org/licenses/gpl-2.0.html. |
| 27 |
*/ |
| 28 |
|
| 29 |
// exit if ABSPATH is not defined |
| 30 |
\defined( 'ABSPATH' ) || exit; |
| 31 |
|
| 32 |
\define( 'EMBED_PRIVACY_VERSION', '1.9.1' ); |
| 33 |
|
| 34 |
if ( ! \defined( 'EPI_EMBED_PRIVACY_BASE' ) ) { |
| 35 |
\define( 'EPI_EMBED_PRIVACY_BASE', \WP_PLUGIN_DIR . '/embed-privacy/' ); |
| 36 |
} |
| 37 |
|
| 38 |
if ( ! \defined( 'EPI_EMBED_PRIVACY_URL' ) ) { |
| 39 |
\define( 'EPI_EMBED_PRIVACY_URL', \plugin_dir_url( \EPI_EMBED_PRIVACY_BASE . 'embed-privacy.php' ) ); |
| 40 |
} |
| 41 |
|
| 42 |
if ( ! \class_exists( 'DOMDocument' ) ) { |
| 43 |
/** |
| 44 |
* Disable the plugin if the php-dom extension is missing. |
| 45 |
*/ |
| 46 |
function disable_plugin() { |
| 47 |
?> |
| 48 |
<div class="notice notice-error"> |
| 49 |
<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> |
| 50 |
</div> |
| 51 |
<?php |
| 52 |
\deactivate_plugins( \plugin_basename( __FILE__ ) ); |
| 53 |
} |
| 54 |
|
| 55 |
\add_action( 'admin_notices', __NAMESPACE__ . '\disable_plugin' ); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Autoload all necessary classes. |
| 60 |
* |
| 61 |
* @param string $class The class name of the autoloaded class |
| 62 |
*/ |
| 63 |
\spl_autoload_register( function( $class ) { |
| 64 |
$path = \explode( '\\', $class ); |
| 65 |
$filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) ); |
| 66 |
$class = \str_replace( |
| 67 |
[ 'epiphyt\embed_privacy\\', '\\', '_' ], |
| 68 |
[ '', '/', '-' ], |
| 69 |
\strtolower( $class ) |
| 70 |
); |
| 71 |
$name_pos = \strrpos( $class, $filename ); |
| 72 |
|
| 73 |
if ( $name_pos !== false ) { |
| 74 |
$class = \substr_replace( $class, 'class-' . $filename, $name_pos, \strlen( $filename ) ); |
| 75 |
} |
| 76 |
|
| 77 |
$maybe_file = __DIR__ . '/inc/' . $class . '.php'; |
| 78 |
|
| 79 |
if ( \file_exists( $maybe_file ) ) { |
| 80 |
require_once $maybe_file; |
| 81 |
} |
| 82 |
} ); |
| 83 |
|
| 84 |
Embed_Privacy_Widget_Output_Filter::get_instance(); |
| 85 |
$embed_privacy = Embed_Privacy::get_instance(); |
| 86 |
$embed_privacy->set_plugin_file( __FILE__ ); |
| 87 |
$embed_privacy->init(); |
| 88 |
|