PluginProbe
Embed Privacy / 0.1
Embed Privacy v0.1
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
← All changes | embed-privacy.php +26 -63 trunk0.1 View file →
@@ -1,20 +1,17 @@
1 1 <?php
2 2 namespace epiphyt\Embed_Privacy;
3 3
4 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
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: 0.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
17 14
18 15 Embed Privacy is free software: you can redistribute it and/or modify
19 16 it under the terms of the GNU General Public License as published by
20 17 the Free Software Foundation, either version 2 of the License, or
@@ -25,72 +22,38 @@
25 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 23 GNU General Public License for more details.
27 24
28 25 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.
26 +along with Fury. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
30 27 */
28 +
29 +// exit if ABSPATH is not defined
31 30 \defined( 'ABSPATH' ) || exit;
32 31
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 -}
32 +if ( ! \defined( 'EPI_EMBED_PRIVACY_BASE' ) ) \define( 'EPI_EMBED_PRIVACY_BASE', \plugin_dir_path( __FILE__ ) );
33 +if ( ! \defined( 'EPI_EMBED_PRIVACY_URL' ) ) \define( 'EPI_EMBED_PRIVACY_URL', \plugin_dir_url( __FILE__ ) );
44 34
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 35 /**
66 36 * Autoload all necessary classes.
67 37 *
68 - * @param string $class_name The class name of the auto-loaded class
38 + * @param string $class The class name of the autoloaded class
69 39 */
70 -\spl_autoload_register( static function( $class_name ) {
71 - $path = \explode( '\\', $class_name );
40 +\spl_autoload_register( function( string $class ) {
41 + $path = \explode( '\\', $class );
72 42 $filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) );
73 -
74 - if ( \strpos( $class_name, __NAMESPACE__ ) !== 0 ) {
75 - return;
76 - }
77 -
78 - $class_name = \str_replace(
43 + $class = \str_replace(
79 44 [ 'epiphyt\embed_privacy\\', '\\', '_' ],
80 45 [ '', '/', '-' ],
81 - \strtolower( $class_name )
46 + \strtolower( $class )
82 47 );
83 - $name_pos = \strrpos( $class_name, $filename );
48 + $class = \str_replace( $filename, 'class-' . $filename, $class );
49 + $maybe_file = __DIR__ . '/inc/' . $class . '.php';
84 50
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 51 if ( \file_exists( $maybe_file ) ) {
92 - require_once $maybe_file;
52 + require_once( __DIR__ . '/inc/' . $class . '.php' );
93 53 }
94 54 } );
95 55
96 -Embed_Privacy::get_instance()->init();
56 +$embed_privacy = new Embed_Privacy();
57 +
58 +\register_activation_hook( __FILE__, [ $embed_privacy, 'clear_embed_cache' ] );
59 +\register_deactivation_hook( __FILE__, [ $embed_privacy, 'clear_embed_cache' ] );