Пример #1
0
 function scripts_and_styles()
 {
     $debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG;
     $theme = get_template_directory_uri();
     $ver = get_package_version();
     $assets = file_get_contents(get_template_directory() . '/assets.json');
     $assets = json_decode($assets);
     $assets_js = $assets->js;
     $assets_css = $assets->css;
     $external = array('css' => array(), 'js' => array());
     $handle = 'global';
     // CSS from assets.json
     foreach ($assets_css as $bundle) {
         foreach ($bundle->files as $asset) {
             $asset = json_encode($asset);
             $asset = str_replace('$ver', $ver, $asset);
             $asset = json_decode($asset);
             $asset_defaults = array("handle" => "", "path" => "", "dependencies" => null, "version" => $ver);
             $asset = (object) array_merge((array) $asset_defaults, (array) $asset);
             if (isset($asset->external) && $asset->external) {
                 $asset->path = $asset->src;
                 $external['css'][] = $asset;
             } else {
                 $asset->path = $theme . '/' . $asset->src;
             }
             // Unminified Styles
             if ($debug) {
                 wp_enqueue_style($asset->handle, $asset->path, $asset->dependencies, $asset->version);
             }
         }
     }
     // JS from assets.json
     foreach ($assets_js as $bundle) {
         foreach ($bundle->files as $asset) {
             // Dont include assets marked for dist build only.
             if (isset($asset->dist_only) && $asset->dist_only) {
                 continue;
             }
             $asset = json_encode($asset);
             $asset = str_replace('$ver', $ver, $asset);
             $asset = json_decode($asset);
             $asset_defaults = array("handle" => "", "path" => "", "dependencies" => null, "version" => $ver, "in_footer" => true);
             $asset = (object) array_merge((array) $asset_defaults, (array) $asset);
             if (isset($asset->external) && $asset->external) {
                 $asset->path = $asset->src;
                 $external['js'][] = $asset;
             } else {
                 $asset->path = $theme . '/' . $asset->src;
             }
             // Unminified Scripts
             if ($debug) {
                 wp_enqueue_script($asset->handle, $asset->path, $asset->dependencies, $asset->version, $bundle->in_footer);
             }
         }
     }
     // Enqueue concatenated files
     if (!$debug) {
         foreach ($assets_css as $bundle) {
             if (!$bundle->include_globally) {
                 continue;
             }
             $name = $bundle->name;
             wp_enqueue_style($name . '-style-build', $theme . '/assets/dist/dist-' . $name . '-' . $ver . '.css', null, null);
         }
         foreach ($assets_js as $bundle) {
             if (!$bundle->include_globally) {
                 continue;
             }
             $name = $bundle->name;
             $in_footer = $bundle->in_footer;
             wp_enqueue_script($name . '-script-build', $theme . '/assets/dist/dist-' . $name . '-' . $ver . '.js', null, null, $in_footer);
         }
     }
     // External Assets
     if (!empty($external['css'])) {
         foreach ($external['css'] as $asset) {
             wp_enqueue_style($asset->handle, $asset->path, $asset->dependencies, $asset->version);
         }
     }
     if (!empty($external['js'])) {
         foreach ($external['js'] as $asset) {
             wp_enqueue_script($asset->handle, $asset->path, $asset->dependencies, $asset->version, $asset->in_footer);
         }
     }
     global $post;
     wp_localize_script('global-script-build', 'WP', array('themeDir' => get_template_directory_uri(), 'homeUrl' => get_bloginfo('url'), 'ajaxUrl' => admin_url('admin-ajax.php'), 'slug' => get_post($post)->post_name, 'env' => defined('ENV') ? ENV : 'production'));
 }
Пример #2
0
<?php

/*
 * Front Page
 */
$data = Timber::get_context();
$post = new TimberPost();
$posts_per_page = 15;
$post_types = array('post', 'sa-news');
require 'templates/includes/latest-content.php';
require 'templates/includes/latest-issue.php';
require 'templates/includes/post-categories.php';
$ajax_settings = array('post_type' => join(',', $post_types), 'posts_per_page' => 15, 'template' => 'archive-post', 'append_to' => '.archive__posts');
$data['post'] = $post;
$data['ajax_settings'] = $ajax_settings;
wp_enqueue_style('flickity-css', get_template_directory_uri() . '/assets/vendor/flickity/dist/flickity.min.css', get_package_version());
wp_enqueue_script('flickity-js', get_template_directory_uri() . '/assets/vendor/flickity/dist/flickity.pkgd.min.js', array('jquery'), get_package_version(), true);
wp_enqueue_script('flickity-lazy-load', get_template_directory_uri() . '/assets/vendor/flickity-bg-lazyload/bg-lazyload.js', array('jquery', 'flickity-js'), get_package_version(), true);
Timber::render('front-page.twig', $data);
Пример #3
0
function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    log_cleanup("*** Executing Update (upcp) - BEGIN ***");
    debug_for_backend();
    $login = new Client(null, null, 'upgrade');
    $DoUpdate = false;
    $opt = parse_opt($argv);
    log_cleanup("Kloxo Install/Update");
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        log_cleanup("- Installing Kloxo packages at the first time");
        $DoUpdate = true;
    } else {
        log_cleanup("- Getting Version Info from the LxCenter download Server");
        $upversion = false;
        if (isset($opt['till-version']) && $opt['till-version'] || lxfile_exists("__path_slave_db")) {
            $sgbl->slave = true;
            $upversion = findNextVersion($opt['till-version']);
            $type = 'slave';
        } else {
            $sgbl->slave = false;
            $upversion = findNextVersion();
            $type = 'master';
        }
        if ($upversion) {
            log_cleanup("- Connecting LxCenter download server");
            do_upgrade($upversion);
            log_cleanup("- Upgrade Done. Cleanup....");
            flush();
        } else {
            $localversion = $sgbl->__ver_major_minor_release;
            log_cleanup("- Kloxo is the latest version ({$localversion})");
        }
        // Thirdparty/Webmail/AWstats checks
        $verWM = getVersionNumber(get_package_version("lxwebmail"));
        $verAW = getVersionNumber(get_package_version("lxawstats"));
        $ver = file_get_contents("http://download.lxcenter.org/download/thirdparty/kloxo-version.list");
        $verTP = getVersionNumber($ver);
        if (!lxfile_exists("/var/cache/kloxo/lxwebmail{$verWM}.tar.gz")) {
            $retWM = true;
        } else {
            $retWM = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/lxawstats{$verAW}.tar.gz")) {
            $retAW = true;
        } else {
            $retAW = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/kloxo-thirdparty.{$verTP}.zip")) {
            $retTP = true;
        } else {
            $retTP = false;
        }
        installThirdparty();
        installWebmail();
        installAwstats();
        // Run cleanups or not
        if ($retTP || $retWM || $retAW || $upversion) {
            $DoUpdate = true;
        } else {
            $DoUpdate = false;
        }
    }
    log_cleanup("*** Executing Update (upcp) - END ***");
    if ($DoUpdate == false) {
        log_cleanup("Run /script/cleanup if you want to fix/restore/(re)install non-working components.");
        exit;
    }
    if (is_running_secondary()) {
        log_cleanup("Not running Update cleanup, because this is running as secondary\n");
        exit;
    }
    //
    // Executing update/cleanup process
    //
    lxfile_cp("htmllib/filecore/php.ini", "/usr/local/lxlabs/ext/php/etc/php.ini");
    $res = pcntl_exec("/bin/sh", array("../bin/common/updatecleanup.sh", "--type={$type}"));
}
Пример #4
0
function installAwstats($ver = null)
{
    //	if (!is_numeric($ver)) { return; }
    $file = "lxawstats";
    log_cleanup("Awstats Checks");
    if (!$ver) {
        $ver = getVersionNumber(get_package_version($file));
        log_cleanup("- {$file} version is {$ver}");
    }
    lxfile_mkdir("/var/cache/kloxo");
    lxfile_mkdir("/home/kloxo/httpd/awstats/");
    $path = "/home/kloxo/httpd/awstats";
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        $locverpath = "/var/cache/kloxo/{$file}-version";
        $locver = getVersionNumber(file_get_contents($locverpath));
        log_cleanup("- local copy version is {$locver}");
        if (lxfile_exists("/var/cache/kloxo/{$file}{$locver}.tar.gz")) {
            log_cleanup("- Use version {$locver} local copy for installing");
            $ver = $locver;
        } else {
            log_cleanup("- Download and use version {$ver} for installing");
            system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz");
        }
        $DoUpdate = true;
    } else {
        if (!lxfile_exists("/var/cache/kloxo/{$file}{$ver}.tar.gz")) {
            log_cleanup("- Download and use version {$ver} for updating");
            system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz");
            $DoUpdate = true;
        } else {
            log_cleanup("- No update found.");
            $DoUpdate = false;
        }
    }
    $ret = null;
    if ($DoUpdate) {
        lxfile_rm_rec("{$path}/tools/");
        lxfile_rm_rec("{$path}/wwwroot/");
        //	system("cd $path ; tar -xzf /var/cache/kloxo/$file*.tar.gz tools wwwroot docs");
        $ret = lxshell_unzip("__system__", $path, "/var/cache/kloxo/{$file}{$ver}.tar.gz");
    }
    if (!$ret) {
        return true;
    }
}