Example #1
0
 /**
  * @param     $file
  * @param int $order
  *
  * @return void
  */
 public function addStyle($file, $order = self::DEFAULT_ORDER)
 {
     global $wp_styles;
     $path_parts = pathinfo($file);
     //check if its a file or handle
     if (isset($path_parts['extension']) && $path_parts['extension'] == 'css') {
         //differentiate between the plugin files and the widget files
         if (strpos($file, 'widget') === false) {
             $handle = 'rok_' . str_replace('.', '_', basename($file));
         } else {
             $handle = 'rok_widget_' . str_replace('.', '_', basename($file));
         }
         //check if wordpress head has run
         if (!did_action('wp_head')) {
             // Gantry 5 special case
             if (class_exists('Gantry\\Framework\\Gantry')) {
                 Gantry\Framework\Document::addHeaderTag(['tag' => 'link', 'href' => $file, 'rel' => 'stylesheet']);
             } else {
                 wp_register_style($handle, $file);
                 wp_enqueue_style($handle);
             }
         } else {
             //wordpress head already ran so...
             if (!wp_style_is($handle)) {
                 $file_root = str_replace($wp_styles->base_url, ABSPATH, $file);
                 if (file_exists($file_root)) {
                     echo "<link rel='stylesheet' id='{$handle}' href='{$file}' type='text/css' media='all' />\n";
                 }
             }
         }
     } else {
         //might be a handle
         wp_enqueue_style($file);
     }
 }
Example #2
0
<?php

defined('ABSPATH') or die;
add_action('admin_init', 'gantry5_admin_start_buffer', -10000);
add_action('admin_init', 'gantry5_register_admin_settings');
add_filter('plugin_action_links', 'gantry5_modify_plugin_action_links', 10, 2);
add_filter('network_admin_plugin_action_links', 'gantry5_modify_plugin_action_links', 10, 2);
add_action('admin_enqueue_scripts', 'gantry5_admin_scripts');
add_action('wp_ajax_gantry5', 'gantry5_layout_manager');
// Check if Timber is active before displaying sidebar button
if (class_exists('Timber')) {
    // Load Gantry 5 icon styling for the admin sidebar
    add_action('admin_enqueue_scripts', function () {
        if (is_admin()) {
            wp_enqueue_style('wordpress-admin-icon', Gantry\Framework\Document::url('gantry-assets://css/wordpress-admin-icon.css'));
        }
    });
    // Adjust menu to contain Gantry stuff.
    add_action('admin_menu', function () {
        $gantry = Gantry\Framework\Gantry::instance();
        $theme = $gantry['theme']->details()['details.name'];
        remove_submenu_page('themes.php', 'theme-editor.php');
        add_menu_page($theme . ' Theme', $theme . ' Theme', 'manage_options', 'layout-manager', 'gantry5_layout_manager');
        add_submenu_page(null, 'Gantry 5 Settings', 'Gantry 5 Settings', 'manage_options', 'g5-settings', 'gantry5_plugin_settings');
    }, 100);
}
function gantry5_admin_start_buffer()
{
    ob_start();
    ob_implicit_flush(false);
}
Example #3
0
 /**
  * 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;
     }
 }