kompass/buena/functions.php
2023-12-30 14:34:31 +01:00

90 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if ( ! defined( 'ABSPATH' ) ) {
die( 'Im a theme.' );
}
if ( ! function_exists( 'trigger_pfadfinden_plugin_error' ) ) {
/**
* Show an error message.
*
* @see http://www.squarepenguin.com/wordpress/?p=6 Inspiration
*
* @param string $message
* @param int $type optional
* @return bool
*/
function trigger_pfadfinden_plugin_error( $message, $type = 0 )
{
if ( isset( $_GET['action'] ) && 'error_scrape' === $_GET['action'] ) {
echo $message;
return true;
}
if ( ! $type ) {
$type = E_USER_WARNING;
}
return trigger_error( $message, $type );
}
}
// Check for suitable environment
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID >= 50400 ) {
// Register autoloader if updater plugin missing
if ( ! class_exists( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\Theme' ) ) {
if ( ! include_once __DIR__ . '/use/shy-wordpress/src/autoloader.php' ) {
trigger_pfadfinden_plugin_error(
__( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ),
E_USER_ERROR
);
return;
}
}
// Register our autoloader
if ( ! include_once __DIR__ . '/src/autoloader.php' ) {
trigger_pfadfinden_plugin_error(
__( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ),
E_USER_ERROR
);
return;
}
/**
* @return \plugins\buena\src\Pfadfinden\WordPress\BuenaTheme
*/
function buena_get_theme()
{
static $theme = null;
if (!$theme) {
$theme = new ReflectionClass( 'plugins\buena\src\Pfadfinden\WordPress\BuenaTheme' );
$theme = $theme->newInstance();
}
return $theme;
}
/**
* @param string $method
* @return callable
*/
function buena_get_callback( $method )
{
return array( buena_get_theme(), (string) $method );
}
return buena_get_theme();
}
// Display error message
trigger_pfadfinden_plugin_error(
sprintf(
__( 'You need at least PHP 5.4 to use the Buena theme. Your are using %s.', 'buena-theme' ),
PHP_VERSION
),
E_USER_ERROR
);