Making WordPress.org

Ticket #1113: 1113.diff

File 1113.diff, 2.8 KB (added by coreymckrill, 7 years ago)
  • wordcamp.org/public_html/wp-content/plugins/wordcamp-site-cloner/includes/source-site-id-setting.php

    diff --git wordcamp.org/public_html/wp-content/plugins/wordcamp-site-cloner/includes/source-site-id-setting.php wordcamp.org/public_html/wp-content/plugins/wordcamp-site-cloner/includes/source-site-id-setting.php
    index fdc7825..809d6a9 100644
    class Source_Site_ID_Setting extends \WP_Customize_Setting { 
    4747                }
    4848
    4949                switch_to_blog( $this->preview_source_site_id );
    50                 printf( '<style id="wcsc-source-site-custom-css">%s</style>', \Jetpack_Custom_CSS::get_css( true ) );
     50
     51                printf(
     52                        '<style id="wcsc-source-site-custom-css">%s %s</style>',
     53                        $this->get_cached_remote_css(),
     54                        \Jetpack_Custom_CSS::get_css( true )
     55                );
     56
    5157                restore_current_blog();
    5258        }
    5359
    class Source_Site_ID_Setting extends \WP_Customize_Setting { 
    106112        }
    107113
    108114        /**
     115         * Get the cached remote CSS for the current blog.
     116         *
     117         * @return string
     118         */
     119        public function get_cached_remote_css() {
     120                $remote_css = '';
     121
     122                if ( function_exists( '\WordCamp\RemoteCSS\get_safe_css_post' ) ) {
     123                        $post = \WordCamp\RemoteCSS\get_safe_css_post();
     124
     125                        if ( $post instanceof \WP_Post ) {
     126                                // Copied from \Jetpack_Custom_CSS::get_css()
     127                                $remote_css = str_replace(
     128                                        array( '\\\00BB \\\0020', '\0BB \020', '0BB 020' ),
     129                                        '\00BB \0020',
     130                                        $post->post_content_filtered
     131                                );
     132                        }
     133                }
     134
     135                return $remote_css;
     136        }
     137
     138        /**
    109139         * Clone the source site into the current site
    110140         *
    111141         * If the theme needs to be switched, Core will do that for us because we added the `?theme=` parameter
    class Source_Site_ID_Setting extends \WP_Customize_Setting { 
    123153                        return;
    124154                }
    125155
    126                 $source_site_css           = \Jetpack_Custom_CSS::get_css( false );
     156                $source_site_css = '';
     157
     158                // Add Remote CSS first
     159                // This maintains the correct cascading order of stylesheet rules
     160                if ( $remote_css = $this->get_cached_remote_css() ) {
     161                        $source_site_css .= sprintf(
     162                                "/* %s */\n%s\n\n",
     163                                sprintf(
     164                                        esc_html__( 'Remote CSS from %s', 'wordcamporg' ),
     165                                        esc_url( get_option( 'wcrcss_remote_css_url' ) )
     166                                ),
     167                                $remote_css
     168                        );
     169                }
     170
     171                // Add Jetpack Custom CSS second
     172                if ( $custom_css = \Jetpack_Custom_CSS::get_css( false ) ) {
     173                        $source_site_css .= sprintf(
     174                                "/* %s */\n%s\n\n",
     175                                sprintf(
     176                                        esc_html__( 'Custom CSS from %s', 'wordcamporg' ),
     177                                        get_bloginfo( 'name' )
     178                                ),
     179                                $custom_css
     180                        );
     181                }
     182
    127183                $source_site_preprocessor  = get_post_meta( $source_cite_css_post['ID'], 'custom_css_preprocessor', true );
    128184                $source_site_mode          = get_post_meta( $source_cite_css_post['ID'], 'custom_css_add', true );
    129185                $source_site_content_width = get_post_meta( $source_cite_css_post['ID'], 'content_width', true );