コード例 #1
0
ファイル: backup_settings.php プロジェクト: ntnvu/tcb_online
function mmpm_options_backup()
{
    if (isset($_FILES[MMPM_OPTIONS_DB_NAME . '_backup']) && $_FILES[MMPM_OPTIONS_DB_NAME . '_backup']['error'] == 0) {
        $backup_file_content = mmpm_get_uri_content($_FILES[MMPM_OPTIONS_DB_NAME . '_backup']['tmp_name']);
        if ($backup_file_content !== false && ($options_backup = json_decode($backup_file_content, true))) {
            if (isset($options_backup['last_modified'])) {
                $options_backup['last_modified'] = time() + 30;
                update_option(MMPM_OPTIONS_DB_NAME, $options_backup);
            }
        }
    }
}
コード例 #2
0
function mmpm_enqueue_styles()
{
    // remove later
    include_once MMPM_EXTENSIONS_DIR . '/common_tools/init.php';
    if (function_exists('is_multisite') && is_multisite()) {
        $cache_file_name = 'cache.skin.b' . get_current_blog_id();
    } else {
        $cache_file_name = 'cache.skin';
    }
    /* check cache or dynamic file enqueue */
    $options_last_modified = mmpm_get_option('last_modified');
    if (file_exists(MMPM_CSS_DIR . '/' . $cache_file_name . '.css')) {
        $cache_status[] = 'exist';
        if ($options_last_modified > filemtime(MMPM_CSS_DIR . '/' . $cache_file_name . '.css')) {
            $cache_status[] = 'old';
        } else {
            $cache_status[] = 'actual';
        }
    } else {
        $cache_status[] = 'no-exist';
    }
    if (in_array('actual', $cache_status)) {
        $skin_css[] = array('name' => MMPM_PREFIX . '_mega_main_menu', 'path' => MMPM_CSS_URI . '/' . $cache_file_name . '.css');
    } else {
        if (mmpm_get_uri_content(MMPM_CSS_DIR . '/frontend/mega_main_menu.css') && ($cache_file = @fopen(MMPM_CSS_DIR . '/' . $cache_file_name . '.css', 'w'))) {
            include 'skin.php';
            $static_css = mmpm_get_uri_content(MMPM_CSS_DIR . '/frontend/mega_main_menu.css');
            $out = $static_css . $out;
            if (in_array('true', mmpm_get_option('coercive_styles', array()))) {
                $out = str_replace(array(";\r\n", ";\n", " !important !important"), array(" !important;", " !important;", " !important"), $out);
            }
            $out = str_replace(array("\t", "\r\n"), array("", " "), $out) . ' /*' . date("Y-m-d H:i") . '*/';
            if (@fwrite($cache_file, $out)) {
                $skin_css = array(array('name' => MMPM_PREFIX . '_' . $cache_file_name, 'path' => MMPM_CSS_URI . '/' . $cache_file_name . '.css'));
                @touch(MMPM_CSS_DIR . '/' . $cache_file_name . '.css', time(), time());
            }
        } else {
            $skin_css[] = array('name' => MMPM_PREFIX . '_common_styles', 'path' => MMPM_CSS_URI . '/frontend/mega_main_menu.css');
            $skin_css[] = array('name' => MMPM_PREFIX . '_dynamic.skin', 'path' => '/?mega_main_menu_style=skin');
        }
    }
    /* check and enqueue google fonts */
    /* register and enqueue styles */
    foreach ($skin_css as $single_css) {
        wp_register_style($single_css['name'], $single_css['path'], false, $options_last_modified);
        wp_enqueue_style($single_css['name']);
    }
    if (isset($_GET['mega_main_menu_style']) && !empty($_GET['mega_main_menu_style'])) {
        header("Content-type: text/css", true);
        //echo '/* CSS Generator  */';
        $generated = microtime(true);
        $style = $_GET['mega_main_menu_style'];
        if (file_exists(dirname(__FILE__) . '/' . $style . '.php')) {
            include $style . '.php';
            if (in_array('true', mmpm_get_option('coercive_styles', array()))) {
                $out = str_replace(array(";\r\n", ";\n", " !important !important"), array(" !important;", " !important;", " !important"), $out);
            }
            echo $out;
        } else {
            echo '/* Not have called CSS */';
        }
        die('/* CSS Generator Execution Time: ' . floatval(microtime(true) - $generated) . ' seconds */');
    }
}