Esempio n. 1
0
/**
 * Get Domain Mapping URL based on origal URL.
 *
 * @since 2.2
 */
function rocket_replace_domain_mapping_siteurl($url)
{
    $original_siteurl_host = parse_url(get_original_url('siteurl'), PHP_URL_HOST);
    $domain_mapping_siteurl_host = parse_url(domain_mapping_siteurl(false), PHP_URL_HOST);
    $url = str_replace($original_siteurl_host, $domain_mapping_siteurl_host, $url);
    return $url;
}
 public function file($target = 'path')
 {
     /**
      * Get the blog ID
      */
     if (is_multisite()) {
         $current_site = get_blog_details();
         $blog_id = $current_site->blog_id;
     } else {
         $blog_id = 1;
     }
     /**
      * Get the upload directory for this site.
      */
     $upload_dir = wp_upload_dir();
     /**
      * If this is a multisite installation, append the blogid to the filename
      */
     $blog_id = is_multisite() && $blog_id > 1 ? '_blog-' . $blog_id : null;
     $page_id = $this->page_id() ? $this->page_id() : 'global';
     $file_name = 'avada' . $blog_id . '-' . $page_id . '.css';
     $folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'avada-styles';
     /**
      * The complete path to the file.
      */
     $file_path = $folder_path . DIRECTORY_SEPARATOR . $file_name;
     /**
      * Get the URL directory of the stylesheet
      */
     $css_uri_folder = $upload_dir['baseurl'];
     /**
      * Build the URL of the file
      */
     $css_uri = trailingslashit($css_uri_folder) . 'avada-styles/' . $file_name;
     /**
      * Take care of domain mapping.
      * When using domain mapping we have to make sure that the URL to the file
      * does not include the original domain but instead the mapped domain.
      */
     if (defined('DOMAIN_MAPPING') && DOMAIN_MAPPING) {
         if (function_exists('domain_mapping_siteurl') && function_exists('get_original_url')) {
             $mapped_domain = domain_mapping_siteurl(false);
             $original_domain = get_original_url('siteurl');
             $css_uri = str_replace($original_domain, $mapped_domain, $css_uri);
         }
     }
     /**
      * Strip protocols from the URL.
      * Make sure we don't have any issues with sites using HTTPS/SSL
      */
     $css_uri = str_replace('https://', '//', $css_uri);
     $css_uri = str_replace('http://', '//', $css_uri);
     /**
      * Return the path or the URL
      * depending on the $target we have defined when calling this method.
      */
     if ('path' == $target) {
         return $file_path;
     } elseif ('url' == $target || 'uri' == $target) {
         $timestamp = file_exists($file_path) ? '?timestamp=' . filemtime($file_path) : '';
         return $css_uri . $timestamp;
     }
 }
Esempio n. 3
0
function autoptimize_end_buffering($content)
{
    if (stripos($content, "<html") === false || stripos($content, "<xsl:stylesheet") !== false) {
        return $content;
    }
    // load URL constants as late as possible to allow domain mapper to kick in
    if (function_exists("domain_mapping_siteurl")) {
        define('AUTOPTIMIZE_WP_SITE_URL', domain_mapping_siteurl(get_current_blog_id()));
        define('AUTOPTIMIZE_WP_CONTENT_URL', str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL), AUTOPTIMIZE_WP_SITE_URL, content_url()));
    } else {
        define('AUTOPTIMIZE_WP_SITE_URL', site_url());
        define('AUTOPTIMIZE_WP_CONTENT_URL', content_url());
    }
    if (is_multisite()) {
        $blog_id = get_current_blog_id();
        define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL . AUTOPTIMIZE_CACHE_CHILD_DIR . $blog_id . '/');
    } else {
        define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL . AUTOPTIMIZE_CACHE_CHILD_DIR);
    }
    define('AUTOPTIMIZE_WP_ROOT_URL', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', AUTOPTIMIZE_WP_CONTENT_URL));
    // Config element
    $conf = autoptimizeConfig::instance();
    // Choose the classes
    $classes = array();
    if ($conf->get('autoptimize_js')) {
        $classes[] = 'autoptimizeScripts';
    }
    if ($conf->get('autoptimize_css')) {
        $classes[] = 'autoptimizeStyles';
    }
    if ($conf->get('autoptimize_html')) {
        $classes[] = 'autoptimizeHTML';
    }
    // Set some options
    $classoptions = array('autoptimizeScripts' => array('justhead' => $conf->get('autoptimize_js_justhead'), 'forcehead' => $conf->get('autoptimize_js_forcehead'), 'trycatch' => $conf->get('autoptimize_js_trycatch'), 'js_exclude' => $conf->get('autoptimize_js_exclude'), 'cdn_url' => $conf->get('autoptimize_cdn_url')), 'autoptimizeStyles' => array('justhead' => $conf->get('autoptimize_css_justhead'), 'datauris' => $conf->get('autoptimize_css_datauris'), 'defer' => $conf->get('autoptimize_css_defer'), 'defer_inline' => $conf->get('autoptimize_css_defer_inline'), 'inline' => $conf->get('autoptimize_css_inline'), 'css_exclude' => $conf->get('autoptimize_css_exclude'), 'cdn_url' => $conf->get('autoptimize_cdn_url')), 'autoptimizeHTML' => array('keepcomments' => $conf->get('autoptimize_html_keepcomments')));
    $content = apply_filters('autoptimize_filter_html_before_minify', $content);
    // Run the classes
    foreach ($classes as $name) {
        $instance = new $name($content);
        if ($instance->read($classoptions[$name])) {
            $instance->minify();
            $instance->cache();
            $content = $instance->getcontent();
        }
        unset($instance);
    }
    $content = apply_filters('autoptimize_html_after_minify', $content);
    return $content;
}
Esempio n. 4
0
function domain_mapping_themes_uri($full_url)
{
    return str_replace(get_original_url('siteurl'), get_option('siteurl'), $full_url);
}
Esempio n. 5
0
/**
 *
 */
function miss_wpmu_image($src)
{
    if (is_multisite()) {
        global $blog_id;
        if (is_subdomain_install()) {
            if (defined('DOMAIN_MAPPING')) {
                if (function_exists('get_original_url')) {
                    //WordPress MU Domain Mapping
                    return site_url() . '/' . str_replace(str_replace(get_original_url('siteurl'), site_url(), get_blog_option($blog_id, 'fileupload_url')), get_blog_option($blog_id, 'upload_path'), $src);
                } else {
                    //VHOST and directory enabled Domain Mapping plugin
                    global $dm_map;
                    if (isset($dm_map)) {
                        static $orig_urls = array();
                        if (!isset($orig_urls[$blog_id])) {
                            remove_filter('pre_option_siteurl', array(&$dm_map, 'domain_mapping_siteurl'));
                            $orig_url = get_option('siteurl');
                            $orig_urls[$blog_id] = $orig_url;
                            add_filter('pre_option_siteurl', array(&$dm_map, 'domain_mapping_siteurl'));
                        }
                        return site_url() . '/' . str_replace(str_replace($orig_urls[$blog_id], site_url(), get_blog_option($blog_id, 'fileupload_url')), get_blog_option($blog_id, 'upload_path'), $src);
                    }
                }
            }
            return site_url() . '/' . str_replace(get_blog_option($blog_id, 'fileupload_url'), get_blog_option($blog_id, 'upload_path'), $src);
        } else {
            if (defined('DOMAIN_MAPPING')) {
                if (function_exists('get_original_url')) {
                    //WordPress MU Domain Mapping
                    return site_url() . '/' . str_replace(str_replace(get_original_url('siteurl'), site_url(), get_blog_option($blog_id, 'fileupload_url')), get_blog_option($blog_id, 'upload_path'), $src);
                }
            }
            $curSite = get_current_site(1);
            $fileupload_url = get_blog_option($blog_id, 'fileupload_url');
            if (strpos($src, $fileupload_url) !== false) {
                return $curSite->path . str_replace($fileupload_url, get_blog_option($blog_id, 'upload_path'), $src);
            } else {
                return str_replace(str_replace('files', '', $fileupload_url), '/', $src);
            }
        }
    } else {
        return $src;
    }
}
    ?>

<div id="edit-answer">
	<h2><?php 
    _e('Your Answer', QA_TEXTDOMAIN);
    ?>
</h2>
	
	
	<?php 
    if (is_user_logged_in()) {
        the_answer_form();
    } else {
        $current_url = get_original_url('siteurl');
        $current_url .= "/wp-login.php?redirect_to=";
        $current_url .= get_original_url('siteurl') . $_SERVER["REQUEST_URI"];
        echo "<p><strong>Please <a href='" . $current_url . "'>login using your gatorlink information</a> before submitting a question</strong></p>";
    }
    ?>
	
</div>
<p><?php 
    the_question_subscription();
    ?>
</p>

</div><!--#qa-page-wrapper-->

			</article>
		
		<?php 
Esempio n. 7
0
 function bulk_upload_to_dreamspeed()
 {
     $max_time = ini_get('max_execution_time');
     $time_start = microtime(true);
     // make sure this exists
     if (!function_exists('wp_generate_attachment_metadata')) {
         include ABSPATH . 'wp-admin/includes/image.php';
     }
     $attachments = $this->get_attachment_without_dreamspeed_info();
     if ($attachments && !empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (microtime(true) - $time_start >= $max_time - 5) {
                 if (!wp_next_scheduled('dreamspeed_media_sync')) {
                     wp_schedule_event(time(), 'hourly', 'dreamspeed_media_sync');
                 }
                 break;
             }
             $file = get_attached_file($attachment->ID);
             $data = wp_generate_attachment_metadata($attachment->ID, $file);
             $this->wp_generate_attachment_metadata(array(), $attachment->ID);
             if ($attachment->post_parent > 0) {
                 if ($parent_post = get_post($attachment->post_parent)) {
                     $upload_dir = wp_upload_dir();
                     $base_url = $upload_dir['baseurl'];
                     // Quick check to make sure Multisite old school isn't being Midvale School for the Gifted.
                     if (defined('DOMAIN_MAPPING')) {
                         $base_url_ms = str_replace(get_original_url('siteurl'), site_url(), $base_url);
                         $parent_post->post_content = str_replace($base_url_ms . '/', $this->get_base_url(), $parent_post->post_content);
                     }
                     $parent_post->post_content = str_replace($base_url . '/', $this->get_base_url(), $parent_post->post_content);
                     wp_update_post($parent_post);
                 }
             }
         }
     } else {
         wp_clear_scheduled_hook('dreamspeed_media_sync');
     }
 }
function redirect_login_to_orig()
{
    if (!get_site_option('dm_remote_login') || isset($_GET['action']) && $_GET['action'] == 'logout' || isset($_GET['loggedout'])) {
        return false;
    }
    $url = get_original_url('siteurl');
    if ($url != site_url()) {
        $url .= "/wp-login.php";
        echo "<script type='text/javascript'>\nwindow.location = '{$url}'</script>";
    }
}
        public static function makecss()
        {
            global $wp_filesystem, $ss_framework;
            $file = self::file();
            // Initialize the Wordpress filesystem.
            if (empty($wp_filesystem)) {
                require_once ABSPATH . '/wp-admin/includes/file.php';
                WP_Filesystem();
            }
            $content = '/********* Compiled - Do not edit *********/

			';
            $content .= $ss_framework->compiler();
            // Take care of domain mapping
            if (defined('DOMAIN_MAPPING') && 1 == DOMAIN_MAPPING) {
                if (function_exists('domain_mapping_siteurl') && function_exists('get_original_url')) {
                    $mapped_domain = domain_mapping_siteurl(false);
                    $mapped_domain = str_replace('https://', '//', $domain_mapping);
                    $mapped_domain = str_replace('http://', '//', $mapped_domain);
                    $original_domain = get_original_url('siteurl');
                    $original_domain = str_replace('https://', '//', $original_domain);
                    $original_domain = str_replace('http://', '//', $original_domain);
                    $content = str_replace($original_domain, $mapped_domain, $content);
                }
            }
            // Strip protocols
            $content = str_replace('https://', '//', $content);
            $content = str_replace('http://', '//', $content);
            if (is_writeable($file) || !file_exists($file) && is_writeable(dirname($file))) {
                if (!$wp_filesystem->put_contents($file, $content, FS_CHMOD_FILE)) {
                    return apply_filters('shoestrap_css_output', $content);
                }
            }
            // Force re-building the stylesheet version transient
            delete_transient('shoestrap_stylesheet_time');
            delete_transient('shoestrap_stylesheet_path');
            delete_transient('shoestrap_stylesheet_uri');
        }