=' )
&& version_compare( get_bloginfo( 'version' ), YINGA_FOCUS_MIN_WP, '>=' );
}
if ( ! yinga_focus_requirements_met() ) {
add_action(
'admin_notices',
static function (): void {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
printf(
'
',
esc_html__( 'Yinga Focus is not active.', 'yinga-focus' ),
esc_html(
sprintf(
/* translators: 1: required PHP version, 2: required WordPress version, 3: current PHP version, 4: current WordPress version */
__( 'This plugin needs PHP %1$s and WordPress %2$s or newer. This site runs PHP %3$s and WordPress %4$s.', 'yinga-focus' ),
YINGA_FOCUS_MIN_PHP,
YINGA_FOCUS_MIN_WP,
PHP_VERSION,
get_bloginfo( 'version' )
)
)
);
}
);
return;
}
/**
* Autoloader.
*
* Composer is de bedoelde route (`composer install`), maar de plugin moet ook
* werken als iemand de map rechtstreeks uit git kopieert. Vandaar de terugval
* op een eigen PSR-4-loader.
*/
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
} else {
spl_autoload_register(
static function ( string $class ): void {
$prefix = 'Yinga\\Focus\\';
if ( ! str_starts_with( $class, $prefix ) ) {
return;
}
$file = __DIR__ . '/src/' . str_replace( '\\', '/', substr( $class, strlen( $prefix ) ) ) . '.php';
if ( is_readable( $file ) ) {
require_once $file;
}
}
);
}
require_once __DIR__ . '/src/Api/functions.php';
/**
* De plugin-instantie.
*
* @return \Yinga\Focus\Plugin
*/
function yinga_focus(): \Yinga\Focus\Plugin {
return \Yinga\Focus\Plugin::instance( YINGA_FOCUS_PLUGIN_FILE );
}
// `plugins_loaded` is vroeg genoeg voor `init`-registraties en laat genoeg
// dat andere plugins (Elementor, ACF) al bestaan wanneer we ze straks
// detecteren.
add_action( 'plugins_loaded', static fn() => yinga_focus()->boot(), 5 );
/*
* Er is bewust geen deactivation hook.
*
* Hier stond `wp_cache_flush()`. Dat leegt niet onze cache maar die van de
* hele site: alles wat WordPress en elke andere plugin erin hebben staan. Op
* een site met Redis of Memcached is dat een merkbare dreun, en bij multisite
* raakt het alle sites in het netwerk.
*
* Het loste bovendien niets op. De gratis plugin zet zelf niets in de
* objectcache — de focusdata is post meta, en die invalideert WordPress zelf
* bij elke wijziging. Wat Pro cachet (UrlResolver) heeft een eigen groep en
* een TTL en overleeft een deactivering prima.
*
* Deactiveren raakt dus geen gebruikersdata en geen cache van anderen.
*/