You've already forked wp-fedistream
All checks were successful
Create Release Package / build-release (push) Successful in 1m2s
- Added $loading_page_template flag in TemplateLoader - template-wrapper.php sets flag before loading theme header/footer - Shortcodes::render_template() returns early if flag is set - Prevents recursion from theme components, widgets, or other plugins Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
201 lines
5.1 KiB
PHP
201 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: WP FediStream
|
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-fedistream
|
|
* Description: Stream music over ActivityPub - Build your own music streaming platform for Musicians and Labels.
|
|
* Version: 0.4.6
|
|
* Requires at least: 6.4
|
|
* Requires PHP: 8.3
|
|
* Author: Marco Graetsch
|
|
* Author URI: https://src.bundespruefstelle.ch/magdev
|
|
* License: GPL v2 or later
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
* Text Domain: wp-fedistream
|
|
* Domain Path: /languages
|
|
*
|
|
* @package WP_FediStream
|
|
*/
|
|
|
|
// Prevent direct file access.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Plugin version.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_VERSION', '0.4.6' );
|
|
|
|
/**
|
|
* Plugin file path.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_FILE', __FILE__ );
|
|
|
|
/**
|
|
* Plugin directory path.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_PATH', plugin_dir_path( __FILE__ ) );
|
|
|
|
/**
|
|
* Plugin directory URL.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_URL', plugin_dir_url( __FILE__ ) );
|
|
|
|
/**
|
|
* Plugin basename.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_BASENAME', plugin_basename( __FILE__ ) );
|
|
|
|
/**
|
|
* Minimum WordPress version required.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_MIN_WP_VERSION', '6.4' );
|
|
|
|
/**
|
|
* Minimum PHP version required.
|
|
*
|
|
* @var string
|
|
*/
|
|
define( 'WP_FEDISTREAM_MIN_PHP_VERSION', '8.3' );
|
|
|
|
/**
|
|
* Check requirements and bootstrap the plugin.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_init(): void {
|
|
// Check PHP version.
|
|
if ( version_compare( PHP_VERSION, WP_FEDISTREAM_MIN_PHP_VERSION, '<' ) ) {
|
|
add_action( 'admin_notices', 'wp_fedistream_php_version_notice' );
|
|
return;
|
|
}
|
|
|
|
// Check WordPress version.
|
|
if ( version_compare( get_bloginfo( 'version' ), WP_FEDISTREAM_MIN_WP_VERSION, '<' ) ) {
|
|
add_action( 'admin_notices', 'wp_fedistream_wp_version_notice' );
|
|
return;
|
|
}
|
|
|
|
// Check if Composer autoloader exists.
|
|
$autoloader = WP_FEDISTREAM_PATH . 'vendor/autoload.php';
|
|
if ( ! file_exists( $autoloader ) ) {
|
|
add_action( 'admin_notices', 'wp_fedistream_autoloader_notice' );
|
|
return;
|
|
}
|
|
|
|
require_once $autoloader;
|
|
|
|
// Initialize the plugin.
|
|
\WP_FediStream\Plugin::get_instance();
|
|
}
|
|
|
|
/**
|
|
* Display PHP version notice.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_php_version_notice(): void {
|
|
$message = sprintf(
|
|
/* translators: 1: Required PHP version, 2: Current PHP version */
|
|
__( 'WP FediStream requires PHP version %1$s or higher. You are running PHP %2$s.', 'wp-fedistream' ),
|
|
WP_FEDISTREAM_MIN_PHP_VERSION,
|
|
PHP_VERSION
|
|
);
|
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( $message ) );
|
|
}
|
|
|
|
/**
|
|
* Display WordPress version notice.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_wp_version_notice(): void {
|
|
$message = sprintf(
|
|
/* translators: 1: Required WordPress version, 2: Current WordPress version */
|
|
__( 'WP FediStream requires WordPress version %1$s or higher. You are running WordPress %2$s.', 'wp-fedistream' ),
|
|
WP_FEDISTREAM_MIN_WP_VERSION,
|
|
get_bloginfo( 'version' )
|
|
);
|
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( $message ) );
|
|
}
|
|
|
|
/**
|
|
* Display autoloader notice.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_autoloader_notice(): void {
|
|
$message = __( 'WP FediStream requires Composer dependencies to be installed. Please run "composer install" in the plugin directory.', 'wp-fedistream' );
|
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( $message ) );
|
|
}
|
|
|
|
/**
|
|
* Plugin activation hook.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_activate(): void {
|
|
// Check requirements before activation.
|
|
if ( version_compare( PHP_VERSION, WP_FEDISTREAM_MIN_PHP_VERSION, '<' ) ) {
|
|
deactivate_plugins( WP_FEDISTREAM_BASENAME );
|
|
wp_die(
|
|
sprintf(
|
|
/* translators: %s: Required PHP version */
|
|
esc_html__( 'WP FediStream requires PHP version %s or higher.', 'wp-fedistream' ),
|
|
WP_FEDISTREAM_MIN_PHP_VERSION
|
|
)
|
|
);
|
|
}
|
|
|
|
$autoloader = WP_FEDISTREAM_PATH . 'vendor/autoload.php';
|
|
if ( file_exists( $autoloader ) ) {
|
|
require_once $autoloader;
|
|
\WP_FediStream\Installer::activate();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Plugin deactivation hook.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_deactivate(): void {
|
|
$autoloader = WP_FEDISTREAM_PATH . 'vendor/autoload.php';
|
|
if ( file_exists( $autoloader ) ) {
|
|
require_once $autoloader;
|
|
\WP_FediStream\Installer::deactivate();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Plugin uninstall hook.
|
|
*
|
|
* @return void
|
|
*/
|
|
function wp_fedistream_uninstall(): void {
|
|
$autoloader = WP_FEDISTREAM_PATH . 'vendor/autoload.php';
|
|
if ( file_exists( $autoloader ) ) {
|
|
require_once $autoloader;
|
|
\WP_FediStream\Installer::uninstall();
|
|
}
|
|
}
|
|
|
|
// Register activation/deactivation hooks.
|
|
register_activation_hook( __FILE__, 'wp_fedistream_activate' );
|
|
register_deactivation_hook( __FILE__, 'wp_fedistream_deactivate' );
|
|
|
|
// Initialize plugin after all plugins are loaded.
|
|
add_action( 'plugins_loaded', 'wp_fedistream_init' );
|