/** * Assign default styles to $styles object. * * Nothing is returned, because the $styles parameter is passed by reference. * Meaning that whatever object is passed will be updated without having to * reassign the variable that was passed back to the same value. This saves * memory. * * Adding default styles is not the only task, it also assigns the base_url * property, the default version, and text direction for the object. * * @since 0.0.1 * * @param HQ_Styles $styles */ function hq_default_styles(&$styles) { include ABSPATH . HQINC . '/version.php'; // include an unmodified $hq_version if (!defined('SCRIPT_DEBUG')) { define('SCRIPT_DEBUG', false !== strpos($hq_version, '-src')); } if (!($guessurl = site_url())) { $guessurl = hq_guess_url(); } $styles->base_url = $guessurl; $styles->content_url = defined('HQ_CONTENT_URL') ? HQ_CONTENT_URL : ''; $styles->default_version = get_bloginfo('version'); $styles->text_direction = function_exists('is_rtl') && is_rtl() ? 'rtl' : 'ltr'; $styles->default_dirs = array('/hq-admin/', '/hq-includes/css/'); $open_sans_font_url = ''; /* translators: If there are characters in your language that are not supported * by Open Sans, translate this to 'off'. Do not translate into your own language. */ if ('off' !== _x('on', 'Open Sans font: on or off')) { $subsets = 'latin,latin-ext'; /* translators: To add an additional Open Sans character subset specific to your language, * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ $subset = _x('no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)'); if ('cyrillic' == $subset) { $subsets .= ',cyrillic,cyrillic-ext'; } elseif ('greek' == $subset) { $subsets .= ',greek,greek-ext'; } elseif ('vietnamese' == $subset) { $subsets .= ',vietnamese'; } // Hotlink Open Sans, for now $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset={$subsets}"; } // Register a stylesheet for the selected admin color scheme. $styles->add('colors', true, array('hq-admin', 'buttons', 'open-sans', 'dashicons')); $suffix = SCRIPT_DEBUG ? '' : '.min'; // Admin CSS $styles->add('hq-admin', "/hq-admin/css/hq-admin{$suffix}.css", array('open-sans', 'dashicons')); $styles->add('login', "/hq-admin/css/login{$suffix}.css", array('buttons', 'open-sans', 'dashicons')); $styles->add('install', "/hq-admin/css/install{$suffix}.css", array('buttons', 'open-sans')); $styles->add('hq-color-picker', "/hq-admin/css/color-picker{$suffix}.css"); $styles->add('customize-controls', "/hq-admin/css/customize-controls{$suffix}.css", array('hq-admin', 'colors', 'ie', 'imgareaselect')); $styles->add('customize-widgets', "/hq-admin/css/customize-widgets{$suffix}.css", array('hq-admin', 'colors')); $styles->add('customize-nav-menus', "/hq-admin/css/customize-nav-menus{$suffix}.css", array('hq-admin', 'colors')); $styles->add('press-this', "/hq-admin/css/press-this{$suffix}.css", array('open-sans', 'buttons')); $styles->add('ie', "/hq-admin/css/ie{$suffix}.css"); $styles->add_data('ie', 'conditional', 'lte IE 7'); // Common dependencies $styles->add('buttons', "/hq-includes/css/buttons{$suffix}.css"); $styles->add('dashicons', "/hq-includes/css/dashicons{$suffix}.css"); $styles->add('open-sans', $open_sans_font_url); // Includes CSS $styles->add('admin-bar', "/hq-includes/css/admin-bar{$suffix}.css", array('open-sans', 'dashicons')); $styles->add('hq-auth-check', "/hq-includes/css/hq-auth-check{$suffix}.css", array('dashicons')); $styles->add('editor-buttons', "/hq-includes/css/editor{$suffix}.css", array('dashicons')); $styles->add('media-views', "/hq-includes/css/media-views{$suffix}.css", array('buttons', 'dashicons', 'hq-mediaelement')); $styles->add('hq-pointer', "/hq-includes/css/hq-pointer{$suffix}.css", array('dashicons')); $styles->add('customize-preview', "/hq-includes/css/customize-preview{$suffix}.css"); // External libraries and friends $styles->add('imgareaselect', '/hq-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8'); $styles->add('hq-jquery-ui-dialog', "/hq-includes/css/jquery-ui-dialog{$suffix}.css", array('dashicons')); $styles->add('mediaelement', "/hq-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.17.0'); $styles->add('hq-mediaelement', "/hq-includes/js/mediaelement/hq-mediaelement.css", array('mediaelement')); $styles->add('thickbox', '/hq-includes/js/thickbox/thickbox.css', array('dashicons')); // Deprecated CSS $styles->add('media', "/hq-admin/css/deprecated-media{$suffix}.css"); $styles->add('farbtastic', '/hq-admin/css/farbtastic.css', array(), '1.3u1'); $styles->add('jcrop', "/hq-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12'); $styles->add('colors-fresh', false, array('hq-admin', 'buttons')); // Old handle. // RTL CSS $rtl_styles = array('hq-admin', 'install', 'hq-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'ie', 'login', 'press-this', 'buttons', 'admin-bar', 'hq-auth-check', 'editor-buttons', 'media-views', 'hq-pointer', 'hq-jquery-ui-dialog', 'media', 'farbtastic'); foreach ($rtl_styles as $rtl_style) { $styles->add_data($rtl_style, 'rtl', 'replace'); if ($suffix) { $styles->add_data($rtl_style, 'suffix', $suffix); } } }
/** Installs the site. * * Runs the required functions to set up and populate the database, * including primary admin user and initial options. * * @since 0.0.1 * * @param string $blog_title Blog title. * @param string $user_name User's username. * @param string $user_email User's email. * @param bool $public Whether blog is public. * @param string $deprecated Optional. Not used. * @param string $user_password Optional. User's chosen password. Default empty (random password). * @param string $language Optional. Language chosen. Default empty. * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. */ function hq_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.6'); } hq_check_mysql_version(); //TODO: no cache //hq_cache_flush(); //TODO: Debug //make_db_current_silent(); make_db_current(); populate_options(); populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); if ($language) { update_option('HQLANG', $language); } $guessurl = hq_guess_url(); update_option('siteurl', $guessurl); // If not a public blog, don't ping. if (!$public) { update_option('default_pingback_flag', 0); } /* * Create default user. If the user already exists, the user tables are * being shared among blogs. Just set the role in that case. */ $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if (!$user_id && empty($user_password)) { $user_password = hq_generate_password(12, false); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = hq_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } elseif (!$user_id) { // Password has been provided $message = '<em>' . __('Your chosen password.') . '</em>'; $user_id = hq_create_user($user_name, $user_password, $user_email); } else { $message = __('User already exists. Password inherited.'); } $user = new HQ_User($user_id); $user->set_role('administrator'); hq_install_defaults($user_id); hq_install_maybe_enable_pretty_permalinks(); flush_rewrite_rules(); hq_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.')); hq_cache_flush(); /** * Fires after a site is fully installed. * * @since 0.0.1 * * @param HQ_User $user The site owner. */ do_action('hq_install', $user); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
* If neither set of conditions is true, initiate loading the setup process. */ if (file_exists(ABSPATH . 'hq-config.php')) { /** The config file resides in ABSPATH */ require_once ABSPATH . 'hq-config.php'; } elseif (file_exists(dirname(ABSPATH) . '/hq-config.php') && !file_exists(dirname(ABSPATH) . '/hq-settings.php')) { /** The config file resides one level above ABSPATH but is not part of another install */ require_once dirname(ABSPATH) . '/hq-config.php'; } else { // A config file doesn't exist define('HQINC', 'hq-includes'); require_once ABSPATH . HQINC . '/load.php'; // Standardize $_SERVER variables across setups. hq_fix_server_vars(); require_once ABSPATH . HQINC . '/functions.php'; $path = hq_guess_url() . '/hq-admin/setup-config.php'; /* * We're going to redirect to setup-config.php. While this shouldn't result * in an infinite loop, that's a silly thing to assume, don't you think? If * we're traveling in circles, our last-ditch effort is "Need more help?" */ if (false === strpos($_SERVER['REQUEST_URI'], 'setup-config')) { header('Location: ' . $path); exit; } define('HQ_CONTENT_DIR', ABSPATH . 'hq-content'); require_once ABSPATH . HQINC . '/version.php'; hq_check_php_mysql_versions(); hq_load_translations_early(); // Die with an error message $die = __("There doesn't seem to be a <code>hq-config.php</code> file. I need this before we can get started.") . '</p>';
/** * Create HiveQueen options and set the default values. * * @since 0.0.1 * * @global hqdb $hqdb HiveQueen database abstraction object. * @global int $hq_db_version * @global int $hq_current_db_version */ function populate_options() { global $hqdb, $hq_db_version, $hq_current_db_version; $guessurl = hq_guess_url(); /** * Fires before creating HiveQueen options and populating their default values. * * @since 0.0.1 */ do_action('populate_options'); if (ini_get('safe_mode')) { // Safe mode can break mkdir() so use a flat structure by default. $uploads_use_yearmonth_folders = 0; } else { $uploads_use_yearmonth_folders = 1; } $template = HQ_DEFAULT_THEME; // If default theme is a child theme, we need to get its template $theme = hq_get_theme($template); if (!$theme->errors()) { $template = $theme->get_template(); } $timezone_string = ''; $gmt_offset = 0; /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) or a valid timezone string (America/New_York). See http://us3.php.net/manual/en/timezones.php for all timezone strings supported by PHP. */ $offset_or_tz = _x('0', 'default GMT offset or timezone string'); if (is_numeric($offset_or_tz)) { $gmt_offset = $offset_or_tz; } elseif ($offset_or_tz && in_array($offset_or_tz, timezone_identifiers_list())) { $timezone_string = $offset_or_tz; } $options = array('siteurl' => $guessurl, 'home' => $guessurl, 'blogname' => __('My Site'), 'blogdescription' => __('Just another HiveQueen site'), 'users_can_register' => 0, 'admin_email' => '*****@*****.**', 'start_of_week' => _x('1', 'start of week'), 'use_balanceTags' => 0, 'use_smilies' => 1, 'require_name_email' => 1, 'comments_notify' => 1, 'posts_per_rss' => 10, 'rss_use_excerpt' => 0, 'mailserver_url' => 'mail.example.com', 'mailserver_login' => '*****@*****.**', 'mailserver_pass' => 'password', 'mailserver_port' => 110, 'default_category' => 1, 'default_comment_status' => 'open', 'default_ping_status' => 'open', 'default_pingback_flag' => 1, 'posts_per_page' => 10, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'links_updated_date_format' => __('F j, Y g:i a'), 'comment_moderation' => 0, 'moderation_notify' => 1, 'permalink_structure' => '', 'gzipcompression' => 0, 'hack_file' => 0, 'blog_charset' => 'UTF-8', 'moderation_keys' => '', 'active_plugins' => array(), 'category_base' => '', 'ping_sites' => 'http://rpc.pingomatic.com/', 'advanced_edit' => 0, 'comment_max_links' => 2, 'gmt_offset' => $gmt_offset, 'default_email_category' => 1, 'recently_edited' => '', 'template' => $template, 'stylesheet' => HQ_DEFAULT_THEME, 'comment_whitelist' => 1, 'blacklist_keys' => '', 'comment_registration' => 0, 'html_type' => 'text/html', 'use_trackback' => 0, 'default_role' => 'subscriber', 'db_version' => $hq_db_version, 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 'upload_path' => '', 'blog_public' => '1', 'default_link_category' => 2, 'show_on_front' => 'posts', 'tag_base' => '', 'show_avatars' => '1', 'avatar_rating' => 'G', 'upload_url_path' => '', 'thumbnail_size_w' => 150, 'thumbnail_size_h' => 150, 'thumbnail_crop' => 1, 'medium_size_w' => 300, 'medium_size_h' => 300, 'avatar_default' => 'mystery', 'large_size_w' => 1024, 'large_size_h' => 1024, 'image_default_link_type' => 'file', 'image_default_size' => '', 'image_default_align' => '', 'close_comments_for_old_posts' => 0, 'close_comments_days_old' => 14, 'thread_comments' => 1, 'thread_comments_depth' => 5, 'page_comments' => 0, 'comments_per_page' => 50, 'default_comments_page' => 'newest', 'comment_order' => 'asc', 'sticky_posts' => array(), 'widget_categories' => array(), 'widget_text' => array(), 'widget_rss' => array(), 'uninstall_plugins' => array(), 'timezone_string' => $timezone_string, 'page_for_posts' => 0, 'page_on_front' => 0, 'default_post_format' => 0, 'link_manager_enabled' => 0, 'finished_splitting_shared_terms' => 1); // 3.3 //TODO: no multisite //if ( ! is_multisite() ) { $options['initial_db_version'] = !empty($hq_current_db_version) && $hq_current_db_version < $hq_db_version ? $hq_current_db_version : $hq_db_version; //} //TODO: no multisite //if ( is_multisite() ) { // /* translators: blog tagline */ // $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_current_site()->site_name ); // $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; //} // Set autoload to no for these options $fat_options = array('moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins'); $keys = "'" . implode("', '", array_keys($options)) . "'"; $existing_options = $hqdb->get_col("SELECT option_name FROM {$hqdb->options} WHERE option_name in ( {$keys} )"); $insert = ''; foreach ($options as $option => $value) { if (in_array($option, $existing_options)) { continue; } if (in_array($option, $fat_options)) { $autoload = 'no'; } else { $autoload = 'yes'; } if (is_array($value)) { $value = serialize($value); } if (!empty($insert)) { $insert .= ', '; } $insert .= $hqdb->prepare("(%s, %s, %s)", $option, $value, $autoload); } if (!empty($insert)) { $hqdb->query("INSERT INTO {$hqdb->options} (option_name, option_value, autoload) VALUES " . $insert); } // In case it is set, but blank, update "home". if (!__get_option('home')) { update_option('home', $guessurl); } // Delete unused options. $unusedoptions = array('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_hqnonce', '_hq_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'hqorg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', 'embed_autourls', 'default_post_edit_rows'); foreach ($unusedoptions as $option) { delete_option($option); } // Delete obsolete magpie stuff. $hqdb->query("DELETE FROM {$hqdb->options} WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?\$'"); /* * Deletes all expired transients. The multi-table delete syntax is used * to delete the transient record from table a, and the corresponding * transient_timeout record from table b. */ $time = time(); $sql = "DELETE a, b FROM {$hqdb->options} a, {$hqdb->options} b\n\t\tWHERE a.option_name LIKE %s\n\t\tAND a.option_name NOT LIKE %s\n\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\tAND b.option_value < %d"; $hqdb->query($hqdb->prepare($sql, $hqdb->esc_like('_transient_') . '%', $hqdb->esc_like('_transient_timeout_') . '%', $time)); //TODO: Goyo no multisite //if ( is_main_site() && is_main_network() ) { if (true) { $sql = "DELETE a, b FROM {$hqdb->options} a, {$hqdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\tAND b.option_value < %d"; $hqdb->query($hqdb->prepare($sql, $hqdb->esc_like('_site_transient_') . '%', $hqdb->esc_like('_site_transient_timeout_') . '%', $time)); } }