Beispiel #1
0
 function mmm_options_backup()
 {
     global $mega_main_menu;
     if (isset($_FILES[$mega_main_menu->constant['MM_OPTIONS_NAME'] . '_backup']) && $_FILES[$mega_main_menu->constant['MM_OPTIONS_NAME'] . '_backup']['error'] == 0) {
         $backup_file_content = mm_common::get_url_content($_FILES[$mega_main_menu->constant['MM_OPTIONS_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($mega_main_menu->constant['MM_OPTIONS_NAME'], $options_backup);
             }
         }
     }
 }
Beispiel #2
0
        /** 
         * register and call dynamic styles.
         * @return void
         */
        public function enqueue_skin()
        {
            $ware_skin_array = $this->constant['MM_WARE_SLUG'] . '__array_skin';
            if (function_exists('is_multisite') && is_multisite()) {
                $cache_file_name = 'cache.skin.b' . get_current_blog_id();
            } else {
                $cache_file_name = 'cache.skin';
            }
            $cache_file_dir = $this->constant['MM_WARE_DIR'] . '/src/css/' . $cache_file_name . '.css';
            $cache_file_url = $this->constant['MM_WARE_URL'] . 'src/css/' . $cache_file_name . '.css';
            $primary_styles_dir = $this->constant['MM_WARE_DIR'] . '/src/css/frontend.css';
            $primary_styles_url = $this->constant['MM_WARE_URL'] . 'src/css/frontend.css';
            /* check cache or dynamic file enqueue */
            $options_last_modified = $this->get_option('last_modified');
            if (file_exists($cache_file_dir)) {
                $cache_status[] = 'exist';
                if ($options_last_modified > filemtime($cache_file_dir)) {
                    $cache_status[] = 'old';
                } else {
                    $cache_status[] = 'actual';
                }
            } else {
                $cache_status[] = 'no-exist';
            }
            /*
            		$cache_status[] = 'no-exist';
            */
            if (in_array('actual', $cache_status)) {
                $skin_css[] = array('name' => $this->constant['MM_WARE_PREFIX'] . '_' . $this->constant['MM_WARE_SLUG'], 'path' => $cache_file_url);
            } else {
                $static_css = mm_common::get_url_content($primary_styles_url);
                if ($static_css !== false && ($cache_file = @fopen($cache_file_dir, 'w'))) {
                    $out = '';
                    /* google fonts */
                    if ($set_of_google_fonts = $this->get_option('set_of_google_fonts')) {
                        if (count($set_of_google_fonts) > 0) {
                            $out .= '/* google fonts */';
                            foreach ($set_of_google_fonts as $key => $value) {
                                $additional_font = '@import url(https://fonts.googleapis.com/css?family=' . str_replace(' ', '+', $value['family']) . ':400italic,600italic,300,400,600,700,800&subset=latin,latin-ext,cyrillic,cyrillic-ext);';
                                $out .= $additional_font;
                            }
                        }
                    }
                    $out .= $static_css . $ware_skin_array($this);
                    if ($this->get_option('responsive_resolution', '768') != '768') {
                        $out = str_replace(array('@media (max-width: 767px) { /* DO NOT CHANGE THIS LINE (See = Specific Options -> Responsive Resolution) */', '@media (min-width: 768px) { /* DO NOT CHANGE THIS LINE (See = Specific Options -> Responsive Resolution) */'), array('@media (max-width: ' . ($this->get_option('responsive_resolution', '768') - 1) . 'px) { /* Responsive Resolution is changed */', '@media (min-width: ' . $this->get_option('responsive_resolution', '768') . 'px) { /* Responsive Resolution is changed */'), $out);
                    }
                    if (in_array('true', $this->get_option('coercive_styles', array()))) {
                        $out = str_replace(array(";" . PHP_EOL, ";\n", ";\n", " !important !important;"), " !important;", $out);
                    }
                    $out = str_replace(array(PHP_EOL, "\n", '
', "\t", "  ", "  "), ' ', $out);
                    if (@fwrite($cache_file, $out)) {
                        $skin_css = array(array('name' => $this->constant['MM_WARE_PREFIX'] . '_' . $cache_file_name, 'path' => $cache_file_url));
                        @touch($cache_file_dir, time(), time());
                    }
                } else {
                    $skin_css[] = array('name' => $this->constant['MM_WARE_PREFIX'] . '_common_styles', 'path' => $primary_styles_url);
                    $skin_css[] = array('name' => $this->constant['MM_WARE_PREFIX'] . '_dynamic.skin', 'path' => '/?' . $this->constant['MM_WARE_PREFIX'] . '_page=skin');
                }
            }
            /* 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[$this->constant['MM_WARE_PREFIX'] . '_page']) && $_GET[$this->constant['MM_WARE_PREFIX'] . '_page'] == 'skin') {
                header("Content-type: text/css", true);
                $generated = microtime(true);
                $out = $ware_skin_array($this);
                if (in_array('true', $this->get_option('coercive_styles', array()))) {
                    $out = str_replace(array(";\n", ";\n", " !important !important"), array(" !important;", " !important;", " !important"), $out);
                }
                echo $out;
                die('/* CSS Generator Execution Time: ' . floatval(microtime(true) - $generated) . ' seconds */');
            }
        }
Beispiel #3
0
function mmm_enqueue_styles()
{
    // remove later
    global $mega_main_menu;
    //		include_once( $mega_main_menu->constant[ 'MM_WARE_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 = $mega_main_menu->get_option('last_modified');
    if (file_exists($mega_main_menu->constant['MM_WARE_CSS_DIR'] . '/' . $cache_file_name . '.css')) {
        $cache_status[] = 'exist';
        if ($options_last_modified > filemtime($mega_main_menu->constant['MM_WARE_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' => $mega_main_menu->constant['MM_WARE_PREFIX'] . '_mega_main_menu', 'path' => $mega_main_menu->constant['MM_WARE_CSS_URL'] . '/' . $cache_file_name . '.css');
    } else {
        $static_css = mm_common::get_url_content($mega_main_menu->constant['MM_WARE_CSS_DIR'] . '/frontend/mega_main_menu.css');
        if ($static_css !== false && ($cache_file = @fopen($mega_main_menu->constant['MM_WARE_CSS_DIR'] . '/' . $cache_file_name . '.css', 'w'))) {
            $out = '';
            /* google fonts */
            if ($set_of_google_fonts = $mega_main_menu->get_option('set_of_google_fonts')) {
                if (count($set_of_google_fonts) > 0) {
                    $out .= '/* google fonts */';
                    foreach ($set_of_google_fonts as $key => $value) {
                        $additional_font = '@import url(https://fonts.googleapis.com/css?family=' . str_replace(' ', '+', $value['family']) . ':400italic,600italic,300,400,600,700,800&subset=latin,latin-ext,cyrillic,cyrillic-ext);';
                        $out .= $additional_font;
                    }
                }
            }
            $out .= $static_css . mmm_get_skin();
            if (in_array('true', $mega_main_menu->get_option('coercive_styles', array()))) {
                $out = str_replace(array(";\n", ";\n", " !important !important"), array(" !important;", " !important;", " !important"), $out);
            }
            if ($mega_main_menu->get_option('responsive_resolution', '768') != '768') {
                $out = str_replace(array('@media (max-width: 767px) { /* DO NOT CHANGE THIS LINE (See = Specific Options -> Responsive Resolution) */', '@media (min-width: 768px) { /* DO NOT CHANGE THIS LINE (See = Specific Options -> Responsive Resolution) */'), array('@media (max-width: ' . ($mega_main_menu->get_option('responsive_resolution', '768') - 1) . 'px) { /* Responsive Resolution is changed */', '@media (min-width: ' . $mega_main_menu->get_option('responsive_resolution', '768') . 'px) { /* Responsive Resolution is changed */'), $out);
            }
            $out = str_replace(array("\t", "\n", "\n", "  "), array("", "", " ", " "), $out);
            if (@fwrite($cache_file, $out)) {
                $skin_css = array(array('name' => $mega_main_menu->constant['MM_WARE_PREFIX'] . '_' . $cache_file_name, 'path' => $mega_main_menu->constant['MM_WARE_CSS_URL'] . '/' . $cache_file_name . '.css'));
                @touch($mega_main_menu->constant['MM_WARE_CSS_DIR'] . '/' . $cache_file_name . '.css', time(), time());
            }
        } else {
            $skin_css[] = array('name' => $mega_main_menu->constant['MM_WARE_PREFIX'] . '_common_styles', 'path' => $mega_main_menu->constant['MM_WARE_CSS_URL'] . '/frontend/mega_main_menu.css');
            $skin_css[] = array('name' => $mega_main_menu->constant['MM_WARE_PREFIX'] . '_dynamic.skin', 'path' => '/?' . $mega_main_menu->constant['MM_WARE_PREFIX'] . '_page=skin');
            /*
            				if ( $set_of_google_fonts = $mega_main_menu->get_option( 'set_of_google_fonts' ) ) {
            					unset( $set_of_google_fonts['0'] );
            					if ( count( $set_of_google_fonts ) > 0 ) {
            						foreach ( $set_of_google_fonts as $key => $value ) {
            							$font_family = str_replace(' ', '+', $value['family'] ) . ':400italic,600italic,300,400,600,700,800&subset=latin,latin-ext,cyrillic,cyrillic-ext';
            							$skin_css[] = array( 'name' => $mega_main_menu->constant[ 'MM_WARE_PREFIX' ] . '_' . $value['family'], 'path' => 'https://fonts.googleapis.com/css?family=' . $font_family );
            						}
            					}
            				}
            */
        }
    }
    /* 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->constant['MM_WARE_PREFIX'] . '_page']) && $_GET[$mega_main_menu->constant['MM_WARE_PREFIX'] . '_page'] == 'skin') {
        header("Content-type: text/css", true);
        //echo '/* CSS Generator  */';
        $generated = microtime(true);
        if (file_exists(dirname(__FILE__) . '/skin.php')) {
            $out = mmm_get_skin();
            if (in_array('true', $mega_main_menu->get_option('coercive_styles', array()))) {
                $out = str_replace(array(";\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 */');
    }
}