kompass/buena/functions.php

90 lines
2.0 KiB
PHP
Raw Normal View History

2023-12-30 14:28:21 +01:00
<?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
2023-12-30 14:34:31 +01:00
if ( ! class_exists( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\Theme' ) ) {
2023-12-30 14:28:21 +01:00
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;
}
/**
2023-12-30 14:34:31 +01:00
* @return \plugins\buena\src\Pfadfinden\WordPress\BuenaTheme
2023-12-30 14:28:21 +01:00
*/
function buena_get_theme()
{
static $theme = null;
if (!$theme) {
2023-12-30 14:34:31 +01:00
$theme = new ReflectionClass( 'plugins\buena\src\Pfadfinden\WordPress\BuenaTheme' );
2023-12-30 14:28:21 +01:00
$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
);