function gantry5_layout_manager() { static $output = null; if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } add_filter('admin_body_class', function () { return 'gantry5 gantry5-wordpress'; }); if ($output) { echo $output; return; } // Detect Gantry Framework or fail gracefully. if (!class_exists('Gantry5\\Loader')) { wp_die(__('Gantry 5 Framework not found.')); } // Initialize administrator or fail gracefully. try { Gantry5\Loader::setup(); $gantry = Gantry\Framework\Gantry::instance(); $gantry['router'] = function ($c) { return new \Gantry\Admin\Router($c); }; // Dispatch to the controller. $output = $gantry['router']->dispatch(); } catch (Exception $e) { throw $e; // wp_die( $e->getMessage() ); } }
protected function getInput() { $app = JFactory::getApplication(); // Detect Gantry Framework or fail gracefully. if (!class_exists('Gantry5\\Loader')) { $app->enqueueMessage(JText::sprintf('MOD_GANTRY5_PLUGIN_MISSING', JText::_('MOD_GANTRY5_PARTICLE')), 'error'); return ''; } if (!defined('GANTRYADMIN_PATH')) { define('GANTRYADMIN_PATH', JPATH_ADMINISTRATOR . '/components/com_gantry5'); } // Initialize administrator or fail gracefully. try { Gantry5\Loader::setup(); $this->container = Gantry\Framework\Gantry::instance(); $this->container['router'] = function ($c) { return new \Gantry\Admin\Router($c); }; } catch (Exception $e) { $app->enqueueMessage(JText::sprintf($e->getMessage()), 'error'); return ''; } // FIXME: Better style detection. $style = \Gantry\Joomla\StyleHelper::getStyle(['home' => 1, 'client_id' => 0]); $this->container['router']->setStyle($style->id)->load(); $field = ['default' => true, 'scope' => '', 'name' => $this->name, 'field' => ['type' => 'gantry.particle', 'label' => 'Particle', 'class' => 'input-small', 'picker_label' => 'Pick a Particle', 'overridable' => false], 'value' => json_decode($this->value, true)]; $params = ['content' => $this->container['admin.theme']->render('@gantry-admin/forms/fields/gantry/particle.html.twig', $field)]; return $this->container['admin.theme']->render('@gantry-admin/partials/layout.html.twig', $params); }
/** * Display Gantry 5 backend icon * * @param string $context * @return array|null */ public function onGetIcons($context) { $user = JFactory::getUser(); if ($context != $this->params->get('context', 'mod_quickicon') || !$user->authorise('core.manage', 'com_gantry5')) { return null; } try { $updates = null; if ($user->authorise('core.manage', 'com_installer')) { // Initialise Gantry. Gantry5\Loader::setup(); $gantry = Gantry\Framework\Gantry::instance(); $gantry['streams']; /** @var Gantry\Framework\Platform $platform */ $platform = $gantry['platform']; $updates = $platform->updates(); } } catch (Exception $e) { $app = JFactory::getApplication(); $app->enqueueMessage($e->getMessage(), 'warning'); $updates = false; } $quickicons = array(array('link' => JRoute::_('index.php?option=com_gantry5'), 'image' => 'eye', 'text' => JText::_('COM_GANTRY5'), 'group' => 'MOD_QUICKICON_EXTENSIONS', 'access' => array('core.manage', 'com_gantry5'))); if ($updates === false) { // Disabled $quickicons[] = array('link' => JRoute::_('index.php?option=com_gantry5'), 'image' => 'eye', 'text' => JText::_('PLG_QUICKICON_GANTRY5_UPDATES_DISABLED'), 'group' => 'MOD_QUICKICON_MAINTENANCE'); } elseif (!empty($updates)) { // Has updates $quickicons[] = array('link' => JRoute::_('index.php?option=com_installer&view=update'), 'image' => 'download', 'text' => JText::_('PLG_QUICKICON_GANTRY5_UPDATE_NOW'), 'group' => 'MOD_QUICKICON_MAINTENANCE'); } return $quickicons; }
function gantry_layout_manager() { static $output = null; if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if ($output) { echo $output; return; } // Define Gantry Admin services. $gantry = Gantry\Framework\Gantry::instance(); $gantry['admin.theme'] = function ($c) { return new \Gantry\Admin\Theme(GANTRYADMIN_PATH); }; // Boot the service. $theme = $gantry['admin.theme']; $gantry['base_url'] = \admin_url('themes.php?page=layout-manager'); $gantry['routes'] = ['overview' => '', 'settings' => '&view=settings', 'pages' => '&view=pages_index', 'pages/edit' => '&view=pages_edit', 'pages/create' => '&view=pages_create', 'assignments' => '&view=assignments', 'updates' => '&view=updates']; $view = isset($_GET['view']) ? sanitize_key($_GET['view']) : 'overview'; // Render the page. try { $output = $theme->render("{$view}.html.twig"); } catch (Exception $e) { wp_die($e->getMessage()); } }
/** * Load Gantry framework before dispatching to the component. */ private function onAfterRouteSite() { $template = $this->app->getTemplate(true); if (!file_exists(JPATH_THEMES . "/{$template->template}/gantry/theme.yaml")) { return; } $path = JPATH_THEMES . "/{$template->template}/includes/gantry.php"; if (is_file($path)) { // Manually setup Gantry 5 Framework from the template. include $path; return; } // Setup Gantry 5 Framework or throw exception. Gantry5\Loader::setup(); // Get Gantry instance. $gantry = Gantry\Framework\Gantry::instance(); // Initialize the template. $gantry['theme.path'] = JPATH_THEMES . "/{$template->template}"; $gantry['theme.name'] = $template->template; $themePath = $gantry['theme.path'] . '/includes/theme.php'; //if (is_file($themePath)) { include_once $themePath; }
public function preflight($type, $parent) { if ($type == 'uninstall') { return true; } $manifest = $parent->getManifest(); $name = JText::_($manifest->name); // Prevent installation if Gantry 5 isn't enabled. try { if (!class_exists('Gantry5\\Loader')) { throw new RuntimeException(sprintf('Please install Gantry 5 Framework before installing %s template!', $name)); } Gantry5\Loader::setup(); $gantry = Gantry\Framework\Gantry::instance(); if (!method_exists($gantry, 'isCompatible') || !$gantry->isCompatible($this->requiredGantryVersion)) { throw new \RuntimeException(sprintf('Please upgrade Gantry 5 Framework to v%s (or later) before installing %s template!', strtoupper($this->requiredGantryVersion), $name)); } } catch (Exception $e) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf($e->getMessage()), 'error'); return false; } return true; }
* @package Gantry 5 Theme * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC * @license GNU/GPLv2 and later * * http://www.gnu.org/licenses/gpl-2.0.html */ defined('ABSPATH') or die; /* * The template for displaying all pages. * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages * and that other 'pages' on your WordPress site will use a * different template. * * To generate specific templates for your pages you can use: * /mytheme/views/page-mypage.html.twig * (which will still route through this PHP file) * OR * /mytheme/page-mypage.php * (in which case you'll want to duplicate this file and save to the above path) */ $gantry = Gantry\Framework\Gantry::instance(); $theme = $gantry['theme']; // We need to render contents of <head> before plugin content gets added. $context = Timber::get_context(); $context['page_head'] = $gantry->isCompatible('5.1.5') ? $theme->render('partials/page_head.html.twig', $context) : null; $post = Timber::query_post(); $context['post'] = $post; Timber::render(['page-' . $post->post_name . '.html.twig', 'page.html.twig'], $context);
/** * Load Gantry framework before dispatching to the component. */ private function onAfterRouteSite() { $template = $this->app->getTemplate(true); if (!file_exists(JPATH_THEMES . "/{$template->template}/gantry/theme.yaml")) { return; } $gantryPath = JPATH_THEMES . "/{$template->template}/includes/gantry.php"; if (is_file($gantryPath)) { // Manually setup Gantry 5 Framework from the template. include_once $gantryPath; } else { // Setup Gantry 5 Framework or throw exception. Gantry5\Loader::setup(); // Get Gantry instance. $gantry = Gantry\Framework\Gantry::instance(); // Initialize the template. $gantry['theme.path'] = JPATH_THEMES . "/{$template->template}"; $gantry['theme.name'] = $template->template; $themePath = $gantry['theme.path'] . '/includes/theme.php'; include_once $themePath; } /** @var Gantry\Framework\Theme $theme */ $theme = $gantry['theme']; /** @var \Gantry\Framework\Outlines $configurations */ $configurations = $gantry['configurations']; $theme->setLayout($configurations->current()); if (!$this->params->get('production', 0) || $this->params->get('asset_timestamps', 1)) { $age = (int) ($this->params->get('asset_timestamps_period', 7) * 86400); Gantry\Framework\Document::$timestamp_age = $age > 0 ? $age : PHP_INT_MAX; } else { Gantry\Framework\Document::$timestamp_age = 0; } }