예제 #1
0
 function wm_generate_all_css()
 {
     if (wm_generate_main_css()) {
         wm_generate_rtl_css();
         wm_generate_ve_css();
     }
 }
예제 #2
0
파일: setup.php 프로젝트: pab44/pab44
 function wm_install()
 {
     //Helper variables
     global $content_width, $wp_customize;
     $coeficient = apply_filters('wmhook_wm_install_image_sizes_coeficient', 1);
     //Mobile image width is half the content width, but max $mobile_width_max
     $mobile_width_max = absint(apply_filters('wmhook_wm_install_image_sizes_mobile_width_max', 520));
     $mobile_width = apply_filters('wmhook_wm_install_image_sizes_mobile_width', min(absint($content_width / 2), $mobile_width_max));
     //Image ratios
     $image_sizes = array('content-width' => array('ratio-11' => array($content_width * $coeficient, $content_width * $coeficient), 'ratio-43' => array($content_width * $coeficient, floor(3 * $content_width * $coeficient / 4)), 'ratio-32' => array($content_width * $coeficient, floor(2 * $content_width * $coeficient / 3)), 'ratio-169' => array($content_width * $coeficient, floor(9 * $content_width * $coeficient / 16)), 'ratio-21' => array($content_width * $coeficient, floor($content_width * $coeficient / 2)), 'ratio-31' => array($content_width * $coeficient, floor($content_width * $coeficient / 3)), 'ratio-34' => array($content_width * $coeficient, floor(4 * $content_width * $coeficient / 3)), 'ratio-23' => array($content_width * $coeficient, floor(3 * $content_width * $coeficient / 2))), 'mobile' => array('ratio-11' => array($mobile_width * $coeficient, $mobile_width * $coeficient), 'ratio-43' => array($mobile_width * $coeficient, intval(3 * $mobile_width * $coeficient / 4)), 'ratio-32' => array($mobile_width * $coeficient, intval(2 * $mobile_width * $coeficient / 3)), 'ratio-169' => array($mobile_width * $coeficient, intval(9 * $mobile_width * $coeficient / 16)), 'ratio-21' => array($mobile_width * $coeficient, intval($mobile_width * $coeficient / 2)), 'ratio-31' => array($mobile_width * $coeficient, intval($mobile_width * $coeficient / 3)), 'ratio-34' => array($mobile_width * $coeficient, intval(4 * $mobile_width * $coeficient / 3)), 'ratio-23' => array($mobile_width * $coeficient, intval(3 * $mobile_width * $coeficient / 2))));
     $image_sizes = apply_filters('wmhook_wm_install_image_sizes', $image_sizes);
     //WordPress visual editor CSS stylesheets
     $visual_editor_css = array();
     if (wm_google_fonts()) {
         $visual_editor_css[] = esc_url_raw(str_replace(',', '%2C', '//fonts.googleapis.com/css' . wm_google_fonts()));
     }
     $visual_editor_css[] = get_option(WM_THEME_SETTINGS_PREFIX . WM_THEME_SHORTNAME . '-ve-css');
     $visual_editor_css = apply_filters('wmhook_wm_install_visual_editor_css', array_filter($visual_editor_css));
     /**
      * Localization
      *
      * Note: the first-loaded translation file overrides any following ones if the same translation is present.
      */
     //wp-content/languages/theme-name/it_IT.mo
     load_theme_textdomain('mustang', trailingslashit(WP_LANG_DIR) . 'themes/' . WM_THEME_SHORTNAME);
     //wp-content/themes/child-theme-name/languages/it_IT.mo
     load_theme_textdomain('mustang', get_stylesheet_directory() . '/languages');
     //wp-content/themes/theme-name/languages/it_IT.mo
     load_theme_textdomain('mustang', get_template_directory() . '/languages');
     // Declare support for child theme stylesheet automatic enqueuing
     add_theme_support('child-theme-stylesheet');
     // Title tag
     /**
      * @link  https://codex.wordpress.org/Function_Reference/add_theme_support#Title_Tag
      */
     add_theme_support('title-tag');
     //Visual editor styles
     add_editor_style($visual_editor_css);
     //Feed links
     add_theme_support('automatic-feed-links');
     //Enable HTML5 markup
     add_theme_support('html5', array('comment-list', 'comment-form', 'search-form', 'gallery', 'caption'));
     //Post formats
     add_theme_support('post-formats', apply_filters('wmhook_wm_install_post_formats', array('audio', 'gallery', 'link', 'quote', 'status', 'video')));
     //Custom menus
     add_theme_support('menus');
     register_nav_menus(apply_filters('wmhook_wm_install_menus', array('main' => __('Main navigation', 'mustang'))));
     //Custom WP Adminbar styles
     add_theme_support('admin-bar', array('callback' => 'wm_adminbar_css'));
     //Custom header and background (do not integrate yet...)
     // add_theme_support( 'custom-header' );
     // add_theme_support( 'custom-background' );
     //Thumbnails support
     add_theme_support('post-thumbnails');
     //Get image ratios from theme options
     $create_images = array_filter(array(wm_option('skin-image-posts'), wm_option('skin-image-blog'), wm_option('skin-image-gallery')));
     if (empty($create_images)) {
         $create_images = array(WM_DEFAULT_IMAGE_SIZE);
     }
     $create_images = array_unique($create_images);
     $create_images = apply_filters('wmhook_wm_install_image_sizes', $create_images);
     //Add image sizes (x, y, crop)
     add_image_size('full-hd', 1920, 9999, false);
     add_image_size('admin-thumbnail', 100, 100, true);
     add_image_size('content-width', $content_width * $coeficient, 9999, false);
     add_image_size('mobile', $mobile_width * $coeficient, 9999, false);
     foreach ($create_images as $ratio) {
         add_image_size($ratio, $image_sizes['content-width'][$ratio][0], $image_sizes['content-width'][$ratio][1], true);
         add_image_size('mobile-' . $ratio, $image_sizes['mobile'][$ratio][0], $image_sizes['mobile'][$ratio][1], true);
     }
     //Run theme installation
     if (!get_option(WM_THEME_SETTINGS_INSTALL)) {
         /**
          * Theme installation: Step 1
          */
         update_option(WM_THEME_SETTINGS_INSTALL, 1);
         do_action('wmhook_wm_install_step_1');
         //When installation done, redirect to "About" page (when not Lite theme version)
         if (!(defined('WM_LITE_THEME') && WM_LITE_THEME) && !isset($wp_customize)) {
             wp_safe_redirect(admin_url('themes.php?page=' . WM_THEME_SHORTNAME . '-about'));
             die;
         }
     }
     /**
      * Theme installation: Step 2
      *
      * This step is hooked onto WebMan Amplifier plugin activation.
      */
     /**
      * Theme installation: Step 3
      */
     if (2 === absint(get_option(WM_THEME_SETTINGS_INSTALL)) && get_option(WM_THEME_SETTINGS_SKIN)) {
         //Generate global CSS file
         if (wm_generate_main_css()) {
             update_option(WM_THEME_SETTINGS_INSTALL, 3);
             wm_generate_rtl_css();
             wm_generate_ve_css();
             //Save default skin path
             update_option(WM_THEME_SETTINGS_PREFIX . WM_THEME_SHORTNAME . '-skins', array_unique(array(WM_SKINS, WM_SKINS_CHILD)));
         }
         //Save theme version number in DB
         update_option(WM_THEME_SETTINGS_VERSION, WM_THEME_VERSION);
         do_action('wmhook_wm_install_step_3');
     }
 }