function handle_exception($e) { $template = App\Config::get('debug') ? 'debug' : '5xx'; $view = new App\Template($template, compact('e')); $response = new Symfony\Component\HttpFoundation\Response($view->fetch(), Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR); $response->send(); }
// Move jQuery to the footer, include it by default, remove the "jquery-migrate" dependency. // NB: jQuery will be automatically moved in the header if a plugin requires it. add_action('wp_enqueue_scripts', function () { wp_deregister_script('jquery'); wp_enqueue_script('jquery', '/wp-includes/js/jquery/jquery.js', array(), false, true); }); // Add a stylesheet to the admin add_action('admin_enqueue_scripts', function () use($assetsDir) { wp_enqueue_style('wp-boilerplate-admin', $assetsDir . '/admin.css'); }); // Add a stylesheet for TinyMCE add_action('after_setup_theme', function () use($assetsDir) { add_editor_style($assetsDir . '/editor.css'); }); // Register an "asset" filter to easily manage asset versions (see the "theme.php" file). add_action('twig_apply_filters', function ($twig) use($assetsDir) { $assetsVersions = App\Config::get('assets'); // Register the filter $twig->addFilter('asset', new Twig_Filter_Function(function ($filepath, $assetName) use($assetsDir, $assetsVersions) { if (strtolower(substr($filepath, 0, 4)) != 'http') { $filepath = $assetsDir . '/' . $filepath; } $hasQueryParams = strstr($filepath, '?') !== false; return $filepath . (!$hasQueryParams ? '?ver=' : '&ver=') . $assetsVersions[$assetName]; })); return $twig; }); // Avoid emojis errors, see: https://core.trac.wordpress.org/ticket/32305 remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); });
<?php session_start(); define('ROOT', dirname(dirname(__DIR__))); define('SRC', ROOT . '/src'); define('PHP', SRC . '/php'); define('VIEWS', SRC . '/views'); define('CONFIG', SRC . '/config'); spl_autoload_register(function ($class) { $file = PHP . '/classes/' . str_replace('\\', '/', $class) . '.php'; if (is_file($file)) { include $file; } else { throw new \Exception("Класс {$class} не найден"); } }); define('DOCS', ROOT . '/' . App\Config::get('docsDir')); if (App\Config::get('debug')) { ini_set('display_errors', 1); error_reporting(E_ALL); } else { ini_set('display_errors', 0); error_reporting(0); } ini_set('xdebug.max_nesting_level', 200);