| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Remove Schema |
| 4 |
* Plugin URI: https://plugin.nl/remove-schema |
| 5 |
* Description: Remove all Schema Markup / Structured data (Microdata, RDFa and/or JSON-ld) that you don’t want on your site. |
| 6 |
* Version: 2.0.0 |
| 7 |
* Requires at least: 6.8 |
| 8 |
* Requires PHP: 8.2 |
| 9 |
* Author: Tim van Iersel |
| 10 |
* Author URI: https://plugin.nl |
| 11 |
* License: GPL-2.0-or-later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: remove-schema |
| 14 |
* Domain Path: /languages |
| 15 |
* |
| 16 |
* @package TimVanIersel\RemoveSchema |
| 17 |
*/ |
| 18 |
|
| 19 |
declare(strict_types=1); |
| 20 |
|
| 21 |
if ( ! defined( 'ABSPATH' ) ) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
define( 'REMOVE_SCHEMA_VERSION', '2.0.0' ); |
| 26 |
define( 'REMOVE_SCHEMA_FILE', __FILE__ ); |
| 27 |
define( 'REMOVE_SCHEMA_PATH', plugin_dir_path( __FILE__ ) ); |
| 28 |
define( 'REMOVE_SCHEMA_URL', plugin_dir_url( __FILE__ ) ); |
| 29 |
define( 'REMOVE_SCHEMA_BASENAME', plugin_basename( __FILE__ ) ); |
| 30 |
|
| 31 |
$remove_schema_autoload_loaded = false; |
| 32 |
|
| 33 |
foreach ( array( 'vendor/autoload.php', 'autoload.php' ) as $remove_schema_autoload ) { |
| 34 |
$remove_schema_autoload_path = REMOVE_SCHEMA_PATH . $remove_schema_autoload; |
| 35 |
|
| 36 |
if ( file_exists( $remove_schema_autoload_path ) ) { |
| 37 |
require $remove_schema_autoload_path; |
| 38 |
$remove_schema_autoload_loaded = true; |
| 39 |
break; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
if ( ! $remove_schema_autoload_loaded ) { |
| 44 |
add_action( 'admin_notices', 'remove_schema_render_missing_autoloader_notice' ); |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
register_activation_hook( __FILE__, array( TimVanIersel\RemoveSchema\Lifecycle\Activator::class, 'activate' ) ); |
| 49 |
register_deactivation_hook( __FILE__, array( TimVanIersel\RemoveSchema\Lifecycle\Deactivator::class, 'deactivate' ) ); |
| 50 |
|
| 51 |
TimVanIersel\RemoveSchema\Plugin::boot(); |
| 52 |
|
| 53 |
/** |
| 54 |
* Render an admin notice when no autoloader is available. |
| 55 |
*/ |
| 56 |
function remove_schema_render_missing_autoloader_notice(): void { |
| 57 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
?> |
| 61 |
<div class="notice notice-error"> |
| 62 |
<p> |
| 63 |
<?php |
| 64 |
echo esc_html__( |
| 65 |
'Remove Schema is missing its autoloader. Reinstall the plugin or run "composer install" before activating the source checkout.', |
| 66 |
'remove-schema' |
| 67 |
); |
| 68 |
?> |
| 69 |
</p> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
} |
| 73 |
|