<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[4578] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css: WordCamp Remote CSS: Refactor for compatibility with Jetpack 4.2.2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/4578">4578</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/4578","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iandunn</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-12-23 17:27:43 +0000 (Fri, 23 Dec 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp Remote CSS: Refactor for compatibility with Jetpack 4.2.2
WordPress 4.7 added a Customizer feature that allows editing CSS. Jetpack 4.2.2 replaced the Custom CSS module with an entirely new one that is compatible with the Customizer feature, but broke backwards-compatibility with the Site Cloner and Remote CSS plugins.
This commit refactors Remote CSS to restore compatibility with Jetpack.
https://make.wordpress.org/core/2016/10/11/feature-proposal-better-theme-customizations-via-custom-css-with-live-previews/
https://make.wordpress.org/core/2016/11/26/extending-the-custom-css-editor/
https://github.com/Automattic/jetpack/issues/5539
https://github.com/Automattic/jetpack/pull/5804</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappcommonphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/common.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappoutputcachedcssphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/output-cached-css.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappsynchronizeremotecssphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/synchronize-remote-css.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappuserinterfacephp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/user-interface.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappwebhookhandlerphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/webhook-handler.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssteststestsynchronizeremotecssphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/tests/test-synchronize-remote-css.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewshelpoverviewphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-overview.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewshelptipsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-tips.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewspageremotecssphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/page-remote-css.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/images/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssimagesgithubmarksvg">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/images/github-mark.svg</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewstemplatediscoverynoticephp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/template-discovery-notice.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappcommonphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/common.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/common.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/common.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,9 +1,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use WP_Post;
+use WP_Customize_Manager;
+use Exception;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const POST_TYPE = 'wc_remote_css';
</ins><span class="cx" style="display: block; padding: 0 10px"> const SAFE_CSS_POST_SLUG = 'wcrcss_safe_cached_version';
</span><span class="cx" style="display: block; padding: 0 10px"> const OPTION_LAST_UPDATE = 'wcrcss_last_update';
</span><span class="cx" style="display: block; padding: 0 10px"> const AJAX_ACTION = 'wcrcss_webhook';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,24 +17,101 @@
</span><span class="cx" style="display: block; padding: 0 10px"> const CSS_HANDLE = 'wordcamp_remote_css';
</span><span class="cx" style="display: block; padding: 0 10px"> const GITHUB_API_HOSTNAME = 'api.github.com';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'init', __NAMESPACE__ . '\register_post_types' );
+add_action( 'customize_register', __NAMESPACE__ . '\add_discovery_notice' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Find the ID of the post we use to store the safe CSS
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Register our custom post types
+ */
+function register_post_types() {
+ $labels = array(
+ 'name' => __( 'Remote CSS', 'wordcamporg' ),
+ 'singular_name' => __( 'Remote CSS', 'wordcamporg' ),
+ );
+
+ $capabilities = array(
+ 'delete_posts' => 'edit_theme_options',
+ 'delete_post' => 'edit_theme_options',
+ 'delete_published_posts' => 'edit_theme_options',
+ 'delete_private_posts' => 'edit_theme_options',
+ 'delete_others_posts' => 'edit_theme_options',
+ 'edit_post' => 'edit_css',
+ 'edit_posts' => 'edit_css',
+ 'edit_others_posts' => 'edit_css',
+ 'edit_published_posts' => 'edit_css',
+ 'read_post' => 'read',
+ 'read_private_posts' => 'read',
+ 'publish_posts' => 'edit_theme_options',
+ );
+
+ $params = array(
+ 'labels' => $labels,
+ 'public' => false,
+ 'hierarchical' => false,
+ 'rewrite' => false,
+ 'query_var' => false,
+ 'delete_with_user' => false,
+ 'can_export' => true,
+ 'supports' => array( 'title', 'revisions' ),
+ 'capabilities' => $capabilities,
+ );
+
+ register_post_type( POST_TYPE, $params );
+}
+
+/**
+ * Determines if the site's owner has configured the plugin
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|\WP_Error
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function get_safe_css_post_id() {
- $post = get_safe_css_post();
- $post_id = is_a( $post, 'WP_Post' ) ? $post->ID : $post;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function is_configured() {
+ return ! empty( get_option( OPTION_REMOTE_CSS_URL ) );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Get the WP_Post where the sanitized CSS is stored
+ *
+ * If it doesn't exist, it will be created.
+ *
+ * @todo All of the code related to the old Jetpack posts can be removed once all sites have migrated.
+ * That only happens once something triggers `admin_init`, though.
+ *
+ * @return WP_Post
+ */
+function get_safe_css_post() {
+ $posts = get_posts( array(
+ 'post_type' => POST_TYPE,
+ 'post_status' => 'private',
+ 'posts_per_page' => 1,
+ ) );
+
+ if ( isset( $posts[0] ) ) {
+ $post = $posts[0];
+ } else {
+ $jetpack_post = get_jetpack_post();
+
+ if ( $jetpack_post ) {
+ $post = migrate_jetpack_post( $jetpack_post );
+ } else {
+ $post = create_new_post();
+ }
+ }
+
+ return $post;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Find the post we use to store the safe CSS
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Find Jetpack's safe CSS post
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return \WP_Post|\WP_Error
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Before WordPress 4.7 and Jetpack 4.2.2, Jetpack stored it's Custom CSS in a `safecss` post type, and Remote CSS
+ * created it's own `safecss` post to store our sanitized CSS. Any site that hasn't been migrated to the
+ * `wc_remote_css` post type yet will still have their CSS stored in a `safecss` post.
+ *
+ * @return WP_Post|false
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function get_safe_css_post() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function get_jetpack_post() {
+ $post = false;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $safe_css_post = get_posts( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'posts_per_page' => 1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'safecss',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,18 +121,131 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $safe_css_post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = $safe_css_post[0];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- $post = wp_insert_post( array(
- 'post_type' => 'safecss',
- 'post_status' => 'private', // Jetpack_Custom_CSS::post_id() only searches for `public` posts, so this prevents Jetpack from fetching our post
- 'post_title' => SAFE_CSS_POST_SLUG,
- 'post_name' => SAFE_CSS_POST_SLUG,
- ), true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_wp_error( $post ) ) {
- $post = get_post( $post );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $post;
+}
+
+/**
+ * Migrate an old `safecss` post to the new `wc_remote_css` post type
+ *
+ * @see get_jetpack_post() for some background information
+ *
+ * We don't want to delete the old post, just in case something goes wrong and we need to restore it. It does need
+ * to be disabled, though, because otherwise it could cause problems. For instance, if it's migrated without being
+ * disabled, then the user deletes the Remote CSS URL in order to stop using the plugin. In that scenario, the old
+ * post would be restored, and there would be no way for the user to stop using the plugin.
+ *
+ * @param WP_Post $jetpack_post
+ *
+ * @return WP_Post
+ *
+ * @throws Exception
+ */
+function migrate_jetpack_post( $jetpack_post ) {
+ $new_post = create_new_post( $jetpack_post->post_content );
+
+ $jetpack_post->post_status = 'draft';
+ $jetpack_post->post_name = SAFE_CSS_POST_SLUG . '_migrated';
+
+ $result = wp_update_post( $jetpack_post, true );
+
+ if ( is_wp_error( $result ) ) {
+ throw new Exception( sprintf(
+ // translators: %s is an email address
+ __( "Could not migrate Jetpack post. Please notify us at %s.", 'wordcamporg' ),
+ EMAIL_CENTRAL_SUPPORT
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $new_post;
+}
+
+/**
+ * Create a new Remote CSS post
+ *
+ * @param string $content
+ *
+ * @return WP_Post
+ *
+ * @throws Exception
+ */
+function create_new_post( $content = '' ) {
+ $post = wp_insert_post( array(
+ 'post_type' => POST_TYPE,
+ 'post_name' => SAFE_CSS_POST_SLUG,
+ 'post_status' => 'private',
+ 'post_content' => $content
+ ), true );
+
+ if ( ! is_wp_error( $post ) ) {
+ $post = get_post( $post );
+ }
+
+ if ( ! is_a( $post, 'WP_Post' ) ) {
+ throw new Exception( sprintf(
+ // translators: %s is an email address
+ __( "Could not create CSS post. Please notify us at %s.", 'wordcamporg' ),
+ EMAIL_CENTRAL_SUPPORT
+ ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $post;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Get the mode for outputting the custom CSS.
+ *
+ * This just uses the same mode as Jetpack's CSS post, because it wouldn't make any sense to have them configured
+ * with opposite values.
+ *
+ * @return string
+ */
+function get_output_mode() {
+ $mode = 'add-on';
+ $jetpack_settings = (array) get_theme_mod( 'jetpack_custom_css' );
+
+ if ( isset( $jetpack_settings['replace'] ) && $jetpack_settings['replace'] ) {
+ $mode = 'replace';
+ }
+
+ return $mode;
+}
+
+/**
+ * Add a notice to Core's Custom CSS section to offer using Remote CSS
+ *
+ * The Core/Jetpack CSS editor is not designed to meet the needs of the typical WordCamp organizing team, but teams
+ * who aren't satisfied with it may not be aware of Remote CSS. This helps them discover it, so that they can
+ * choose which one they want to use.
+ *
+ * @param WP_Customize_Manager $wp_customize
+ */
+function add_discovery_notice( $wp_customize ) {
+ $plugin_url = plugins_url( '', __DIR__ );
+
+ $notice_text = sprintf(
+ __(
+ 'You can also build your CSS locally using your favorite tools, and collaborate on GitHub with <a href="%s">Remote CSS</a>.',
+ 'wordcamporg'
+ ),
+ admin_url( 'themes.php?page=remote-css' )
+ );
+
+ ob_start();
+ require_once( dirname( __DIR__ ) . '/views/template-discovery-notice.php' );
+ $description = ob_get_clean();
+
+ $wp_customize->add_control(
+ 'wcrss_discovery',
+ array(
+ 'priority' => 1,
+ 'section' => 'custom_css',
+ 'settings' => array(),
+ 'description' => $description,
+ 'input_attrs' => array(
+ 'style' => 'display: none;',
+ ),
+ )
+ );
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappoutputcachedcssphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/output-cached-css.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/output-cached-css.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/output-cached-css.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,13 +1,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use Jetpack;
+use Exception;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_cached_css', 11 ); // after the theme's stylesheet, but before Jetpack Custom CSS's stylesheet
-add_action( 'wp_ajax_' . CSS_HANDLE, __NAMESPACE__ . '\output_cached_css' );
-add_action( 'wp_ajax_nopriv_' . CSS_HANDLE, __NAMESPACE__ . '\output_cached_css' );
-add_filter( 'nocache_headers', __NAMESPACE__ . '\set_cache_headers' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( is_configured() ) {
+ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_cached_css', 11 ); // after the theme's stylesheet, but before Core's Custom CSS stylesheet
+ add_filter( 'stylesheet_uri', __NAMESPACE__ . '\skip_theme_stylesheet' );
+ add_action( 'wp_ajax_' . CSS_HANDLE, __NAMESPACE__ . '\output_cached_css' );
+ add_action( 'wp_ajax_nopriv_' . CSS_HANDLE, __NAMESPACE__ . '\output_cached_css' );
+ add_filter( 'nocache_headers', __NAMESPACE__ . '\set_cache_headers' );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Enqueue the cached CSS
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,16 +20,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * An AJAX endpoint is used because the CSS is stored in the database, rather than on the file system.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function enqueue_cached_css() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( false === get_option( OPTION_REMOTE_CSS_URL ) ) {
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ try {
+ $cachebuster = get_latest_revision_id();
+ } catch ( Exception $exception ) {
+ $cachebuster = date( 'Y-m-d-H' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cachebuster = get_latest_revision_id();
-
- if ( ! $cachebuster ) {
- $cachebuster = date( 'Y-m-d' ); // We should always have a revision ID, but this will work as a fallback if we don't for some reason
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style(
</span><span class="cx" style="display: block; padding: 0 10px"> CSS_HANDLE,
</span><span class="cx" style="display: block; padding: 0 10px"> add_query_arg( 'action', CSS_HANDLE, admin_url( 'admin-ajax.php' ) ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,24 +36,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Skip the theme's stylesheet when in `replace` mode
+ *
+ * Normally Jetpack handles this (via `Jetpack_Custom_CSS_Enhancements::style_filter`), but we still need to do it
+ * even if the `custom-css` module isn't active. We can't include `custom-css-4.7.php`, because it has
+ * side-effects. It doesn't seem worth it to require the module to be active just for this, so instead we're just
+ * duplicating the functionality.
+ *
+ * @param string $stylesheet_url
+ *
+ * @return string
+ */
+function skip_theme_stylesheet( $stylesheet_url ) {
+ if ( ! is_admin() && 'replace' === get_output_mode() && ! Jetpack::is_module_active( 'custom-css' ) ) {
+ $stylesheet_url = plugins_url( 'custom-css/custom-css/css/blank.css', Jetpack::get_module_path( 'custom-css' ) );
+ }
+
+ return $stylesheet_url;
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Get the ID of the latest revision of the safe CSS post
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return int
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_latest_revision_id() {
</span><span class="cx" style="display: block; padding: 0 10px"> $safe_css = get_safe_css_post();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( ! is_a( $safe_css, 'WP_Post' ) || empty( $safe_css->post_content_filtered ) ) {
- return false;
- }
</del><span class="cx" style="display: block; padding: 0 10px"> $latest_revision = wp_get_post_revisions( $safe_css->ID, array( 'posts_per_page' => 1 ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $latest_revision ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $latest_revision = $safe_css;
+ } else {
+ $latest_revision = array_shift( $latest_revision );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $latest_revision = array_shift( $latest_revision );
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $latest_revision->ID;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,9 +88,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $cache_headers;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $safe_css = get_safe_css_post();
-
- if ( ! is_a( $safe_css, 'WP_Post' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ try {
+ $safe_css = get_safe_css_post();
+ } catch ( Exception $exception ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $cache_headers;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,13 +111,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Handles the AJAX endpoint to output the local copy of the CSS
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function output_cached_css() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Explicitly tell the browser that this is CSS, to avoid MIME sniffing vulnerabilities
</ins><span class="cx" style="display: block; padding: 0 10px"> header( 'Content-Type: text/css; charset=' . get_option( 'blog_charset' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $safe_css = get_safe_css_post();
-
- if ( is_a( $safe_css, 'WP_Post' ) ) {
- echo $safe_css->post_content_filtered;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ try {
+ $safe_css_post = get_safe_css_post();
+ $safe_css = $safe_css_post->post_content;
+ } catch ( Exception $exception ) {
+ $safe_css = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo $safe_css;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappsynchronizeremotecssphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/synchronize-remote-css.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/synchronize-remote-css.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/synchronize-remote-css.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,16 +1,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use Jetpack_Custom_CSS_Enhancements;
+use Exception;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Synchronizes the local safe/cached copy of the CSS with the canonical, remote source.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @todo Minification was removed from Jetpack 4.2.2, but will probably be added back in the future. Once it is,
+ * make sure that it's being run here.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $remote_css_url
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function synchronize_remote_css( $remote_css_url ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- sanitize_and_save_unsafe_css( fetch_unsafe_remote_css( $remote_css_url ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $unsafe_css = fetch_unsafe_remote_css( $remote_css_url );
+ $safe_css = sanitize_unsafe_css( $unsafe_css );
+
+ save_safe_css( $safe_css );
</ins><span class="cx" style="display: block; padding: 0 10px"> update_option( OPTION_LAST_UPDATE, time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,45 +57,55 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Sanitize unsafe CSS and save the safe version
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sanitize unsafe CSS
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Note: If we ever need to decouple from Jetpack Custom CSS, then https://github.com/google/caja might be
- * a viable alternative. It'd be nice to have a modular solution, but we'd also have to keep it up to date,
- * and we'd still need to mirror the Output Mode setting.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Jetpack/CSSTidy will validate and normalize the CSS, but they do _NOT_ perform comprehensive sanitization from
+ * a security perspective. So, we still need to add our custom sanitization to the process. That's done in
+ * `mu-plugins/jetpack-tweaks/css-sanitization.php`, but we need to confirm that it actually ran, to protect against
+ * a situation where there was a change in Jetpack/CSSTidy, or in our sanitization, and this function wasn't updated
+ * to reflect them.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $unsafe_css
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @throws \Exception if Jetpack's Custom CSS module isn't available
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string
+ *
+ * @throws Exception
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function sanitize_and_save_unsafe_css( $unsafe_css ) {
- if ( ! is_callable( array( '\Jetpack_Custom_CSS', 'save' ) ) ) {
- throw new \Exception(
- __( "<code>Jetpack_Custom_CSS::save()</code> is not available.
- Please make sure Jetpack's Custom CSS module has been activated.", 'wordcamporg' )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function sanitize_unsafe_css( $unsafe_css ) {
+ require_once( JETPACK__PLUGIN_DIR . '/modules/custom-css/custom-css-4.7.php' );
+
+ $parser_rules_setup = has_filter( 'csstidy_optimize_postparse', 'WordCamp\Jetpack_Tweaks\sanitize_csstidy_parsed_rules' );
+ $subvalue_sanitization_setup = has_filter( 'csstidy_optimize_subvalue', 'WordCamp\Jetpack_Tweaks\sanitize_csstidy_subvalues' );
+
+ if ( ! $parser_rules_setup || ! $subvalue_sanitization_setup ) {
+ throw new Exception( sprintf(
+ // translators: %s is an email address
+ __( "Could not update CSS because sanitization was not available. Please notify us at %s.", 'wordcamporg' ),
+ EMAIL_CENTRAL_SUPPORT
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Note: In addition to the sanitization that Jetpack_Custom_CSS::save() does, there's additional sanitization
- * done by the callbacks in mu-plugins/jetpack-tweaks.php.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $safe_css = Jetpack_Custom_CSS_Enhancements::sanitize_css( $unsafe_css, array( 'force' => true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'jetpack_custom_css_pre_post_id', __NAMESPACE__ . '\get_safe_css_post_id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( did_action( 'csstidy_optimize_postparse' ) < 1 || did_action( 'csstidy_optimize_subvalue' ) < 1 ) {
+ throw new Exception( sprintf(
+ // translators: %s is an email address
+ __( "Could not update CSS because sanitization did not run. Please notify us at %s.", 'wordcamporg' ),
+ EMAIL_CENTRAL_SUPPORT
+ ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- \Jetpack_Custom_CSS::save( array(
- 'css' => $unsafe_css,
- 'is_preview' => false,
- 'preprocessor' => '', // This should never be changed to allow pre-processing. See note in validate_remote_css_url()
- 'add_to_existing' => false, // This isn't actually used, see get_output_mode()
- 'content_width' => false,
- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $safe_css;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'jetpack_custom_css_pre_post_id', __NAMESPACE__ . '\get_safe_css_post_id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Save the safe CSS
+ *
+ * @param string $safe_css
+ */
+function save_safe_css( $safe_css ) {
+ $post = get_safe_css_post();
+ $post->post_content = $safe_css;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Jetpack_Custom_CSS::save_revision() caches our post ID because it retrieves the post ID from
- * Jetpack_Custom_CSS::post_id() while the get_safe_css_post_id() callback is active. We need to clear that
- * to avoid unintended side-effects.
- */
- wp_cache_delete( 'custom_css_post_id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( $post );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappuserinterfacephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/user-interface.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/user-interface.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/user-interface.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,7 +1,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_menu', __NAMESPACE__ . '\add_admin_pages' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,37 +41,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $output_mode = get_output_mode();
</span><span class="cx" style="display: block; padding: 0 10px"> $remote_css_url = get_option( OPTION_REMOTE_CSS_URL , '' );
</span><span class="cx" style="display: block; padding: 0 10px"> $fonts_tool_url = admin_url( 'themes.php?page=wc-fonts-options' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $jetpack_modules_url = admin_url( 'admin.php?page=jetpack_modules' );
- $jetpack_custom_css_active = method_exists( '\Jetpack_Custom_CSS', 'init' );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> require_once( dirname( __DIR__ ) . '/views/page-remote-css.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the mode for outputting the custom CSS.
- *
- * This just uses the same mode as Jetpack's CSS post, because it wouldn't make any sense to have them configured
- * with opposite values.
- *
- * @return string
- */
-function get_output_mode() {
- $mode = 'add-on';
-
- try {
- $jetpack_css_post_id = get_jetpack_css_post_id();
-
- if ( 'no' === get_post_meta( $jetpack_css_post_id, 'custom_css_add', true ) ) {
- $mode = 'replace';
- }
- } catch( \Exception $exception ) {
- // Just fall back to the default $mode
- }
-
- return $mode;
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Get or set the mode for outputting the custom CSS.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * See get_output_mode() for notes.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,77 +53,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $mode
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function set_output_mode( $mode ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mode = 'replace' === $mode ? 'no' : 'yes';
- $revision_id = get_jetpack_css_latest_revision_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $jetpack_settings = (array) get_theme_mod( 'jetpack_custom_css' );
+ $jetpack_settings['replace'] = 'replace' === $mode;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_post_meta( get_jetpack_css_post_id(), 'custom_css_add', $mode );
-
- if ( $revision_id ) {
- update_metadata( 'post', $revision_id, 'custom_css_add', $mode ); // update_post_meta doesn't allow modifying revisions
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_theme_mod( 'jetpack_custom_css', $jetpack_settings );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the ID of Jetpack's safecss post
- *
- * If it doesn't exist yet, create it, because we'll need it for the Output Mode setting.
- *
- * @throws \Exception if Jetpack's Custom CSS module isn't available
- *
- * @return int
- */
-function get_jetpack_css_post_id() {
- if ( ! is_callable( array( '\Jetpack_Custom_CSS', 'post_id' ) ) ) {
- throw new \Exception(
- __( "<code>Jetpack_Custom_CSS::post_id()</code> is not available.
- Please make sure Jetpack's Custom CSS module has been activated.",
- 'wordcamporg' )
- );
- }
-
- $post_id = \Jetpack_Custom_CSS::post_id();
-
- if ( ! is_int( $post_id ) || 0 === $post_id ) {
- $post_values = array(
- 'post_content' => '',
- 'post_title' => 'safecss',
- 'post_status' => 'publish',
- 'post_type' => 'safecss',
- 'post_content_filtered' => '',
- );
-
- $post_id = wp_insert_post( $post_values, true );
-
- if ( is_wp_error( $post_id ) ) {
- throw new \Exception( $post_id->get_error_message() );
- }
- }
-
- return $post_id;
-}
-
-/**
- * Get the ID of the current Jetpack's safecss revision post
- *
- * @throws \Exception if Jetpack's Custom CSS module isn't available
- *
- * @return int|bool
- */
-function get_jetpack_css_latest_revision_id() {
- if ( ! is_callable( array( '\Jetpack_Custom_CSS', 'get_current_revision' ) ) ) {
- throw new \Exception(
- __( "<code>Jetpack_Custom_CSS::get_current_revision()</code> is not available.
- Please make sure Jetpack's Custom CSS module has been activated.",
- 'wordcamporg' )
- );
- }
-
- $revision = \Jetpack_Custom_CSS::get_current_revision();
-
- return empty( $revision['ID'] ) ? false : $revision['ID'];
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Process submissions of the form on the options page
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws \Exception if the user isn't authorized
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,15 +77,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' === $remote_css_url ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $notice = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_post( get_safe_css_post_id() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_safe_css_post();
+
+ wp_delete_post( $post->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $notice = __( 'The remote CSS file was successfully synchronized.', 'wordcamporg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $remote_css_url = validate_remote_css_url( $remote_css_url );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> synchronize_remote_css( $remote_css_url );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- set_output_mode( $_POST['wcrcss-output-mode'] );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_output_mode( $_POST['wcrcss-output-mode'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> update_option( OPTION_REMOTE_CSS_URL, $remote_css_url );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $notice;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,7 +143,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Vanilla CSS only
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * We need to force the user to do their own pre-processing, because Jetpack_Custom_CSS::save() doesn't
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * We need to force the user to do their own pre-processing, because Jetpack_Custom_CSS_Enhancements::sanitize() doesn't
</ins><span class="cx" style="display: block; padding: 0 10px"> * sanitize the unsafe CSS when a preprocessor is present. We'd have to add more logic to make sure it gets
</span><span class="cx" style="display: block; padding: 0 10px"> * sanitized, which would further couple the plugin to Jetpack.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -296,7 +207,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $view_slug ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'overview':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $jetpack_editor_url = admin_url( 'themes.php?page=editcss' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $custom_css_url = admin_url( 'customize.php?autofocus[section]=custom_css' );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'automated-synchronization':
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssappwebhookhandlerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/webhook-handler.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/webhook-handler.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/app/webhook-handler.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,9 +4,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'wp_ajax_' . AJAX_ACTION, __NAMESPACE__ . '\webhook_handler' ); // This is useless in production, but useful for manual testing
-add_action( 'wp_ajax_nopriv_' . AJAX_ACTION, __NAMESPACE__ . '\webhook_handler' );
-add_action( SYNCHRONIZE_ACTION, __NAMESPACE__ . '\synchronize_remote_css' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( is_configured() ) {
+ add_action( 'wp_ajax_' . AJAX_ACTION, __NAMESPACE__ . '\webhook_handler' ); // This is useless in production, but useful for manual testing
+ add_action( 'wp_ajax_nopriv_' . AJAX_ACTION, __NAMESPACE__ . '\webhook_handler' );
+ add_action( SYNCHRONIZE_ACTION, __NAMESPACE__ . '\synchronize_remote_css' );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * todo nginx on production fails with a 502 bad gateway if OPTION_REMOTE_CSS_URL is empty, even though dev handles it with an exception
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssimagesgithubmarksvg"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/images/github-mark.svg</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/images/github-mark.svg (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/images/github-mark.svg 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 120.8 117.8"><style>.a{fill:#191717;}</style><path d="M60.4 0C27 0 0 27 0 60.4c0 26.7 17.3 49.3 41.3 57.3 3 0.6 4.1-1.3 4.1-2.9 0-1.4-0.1-6.2-0.1-11.2C28.5 107.2 25 96.4 25 96.4c-2.7-7-6.7-8.8-6.7-8.8 -5.5-3.7 0.4-3.7 0.4-3.7 6.1 0.4 9.3 6.2 9.3 6.2 5.4 9.2 14.1 6.6 17.6 5 0.5-3.9 2.1-6.6 3.8-8.1C36 85.6 21.9 80.4 21.9 57.2c0-6.6 2.4-12 6.2-16.2 -0.6-1.5-2.7-7.7 0.6-16 0 0 5.1-1.6 16.6 6.2 4.8-1.3 10-2 15.1-2 5.1 0 10.3 0.7 15.1 2C87 23.4 92.1 25 92.1 25c3.3 8.3 1.2 14.5 0.6 16 3.9 4.2 6.2 9.6 6.2 16.2 0 23.2-14.1 28.3-27.6 29.8 2.2 1.9 4.1 5.5 4.1 11.2 0 8.1-0.1 14.6-0.1 16.6 0 1.6 1.1 3.5 4.1 2.9 24-8 41.3-30.6 41.3-57.3C120.8 27 93.7 0 60.4 0z" class="a"/><path d="M22.9 86.7c-0.1 0.3-0.6 0.4-1 0.2 -0.4-0.2-0.7-0.6-0.5-0.9 0.1-0.3 0.6-0.4 1
-0.2C22.8 86 23 86.4 22.9 86.7L22.9 86.7zM22.1 86.2" class="a"/><path d="M25.3 89.4c-0.3 0.3-0.9 0.1-1.2-0.3 -0.4-0.4-0.5-1-0.2-1.3 0.3-0.3 0.8-0.1 1.2 0.3C25.5 88.6 25.6 89.2 25.3 89.4L25.3 89.4zM24.7 88.8" class="a"/><path d="M27.7 92.9c-0.4 0.3-1 0-1.3-0.5 -0.4-0.5-0.4-1.2 0-1.4 0.4-0.3 1 0 1.3 0.5C28.1 92 28.1 92.6 27.7 92.9L27.7 92.9zM27.7 92.9" class="a"/><path d="M31 96.3c-0.3 0.4-1 0.3-1.6-0.2 -0.5-0.5-0.7-1.2-0.3-1.5 0.3-0.4 1-0.3 1.6 0.2C31.2 95.2 31.3 95.9 31 96.3L31 96.3zM31 96.3" class="a"/><path d="M35.5 98.2c-0.1 0.5-0.8 0.7-1.5 0.5 -0.7-0.2-1.1-0.8-1-1.2 0.1-0.5 0.8-0.7 1.5-0.5C35.2 97.2 35.6 97.7 35.5 98.2L35.5 98.2zM35.5 98.2" class="a"/><path d="M40.4 98.6c0 0.5-0.6 0.9-1.3 0.9 -0.7 0-1.3-0.4-1.3-0.9 0-0.5 0.6-0.9 1.3-0.9C39.8 97.7 40.4 98.1 40.4 98.6L40.4 98.6zM40.4 98.6" class="a"/><path d="M45 97.8c0.1 0.5-0
.4 1-1.1 1.1 -0.7 0.1-1.3-0.2-1.4-0.7 -0.1-0.5 0.4-1 1.1-1.1C44.3 97 44.9 97.3 45 97.8L45 97.8zM45 97.8" class="a"/></svg>
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssteststestsynchronizeremotecssphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/tests/test-synchronize-remote-css.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/tests/test-synchronize-remote-css.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/tests/test-synchronize-remote-css.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,11 +12,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_css_was_sanitized() {
</span><span class="cx" style="display: block; padding: 0 10px"> $unsanitized_css = file_get_contents( __DIR__ . '/unsanitized.css' );
</span><span class="cx" style="display: block; padding: 0 10px"> $known_good_sanitized_css = file_get_contents( __DIR__ . '/sanitized.css' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $maybe_sanitized_css = sanitize_unsafe_css( $unsanitized_css );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- sanitize_and_save_unsafe_css( $unsanitized_css );
-
- $maybe_sanitized_css = get_safe_css_post();
-
- $this->assertEquals( $maybe_sanitized_css->post_content, $known_good_sanitized_css );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $maybe_sanitized_css, $known_good_sanitized_css );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewshelpoverviewphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-overview.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-overview.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-overview.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,10 +3,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @var string $custom_css_url
+ */
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'Remote CSS gives you a lot more flexibility in how you develop your site than the Jetpack Custom CSS module.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'Remote CSS gives you a lot more flexibility in how you develop your site than the Core/Jetpack editor.
</ins><span class="cx" style="display: block; padding: 0 10px"> For instance, you can:', 'wordcamporg' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,7 +37,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <p>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php printf(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- __( 'If you\'re looking for something simpler, <a href="%s">Jetpack\'s CSS Editor</a> is a great option.', 'wordcamporg' ),
- esc_url( $jetpack_editor_url )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ __( 'If you\'re looking for something simpler, <a href="%s">the Core/Jetpack editor</a> is a great option.', 'wordcamporg' ),
+ esc_url( $custom_css_url )
</ins><span class="cx" style="display: block; padding: 0 10px"> ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewshelptipsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-tips.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-tips.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/help-tips.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,6 +3,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @var string $fonts_tool_url
+ * @var string $media_library_url
+ */
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <ul>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,7 +41,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </li>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <li>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( "This tool plays nicely with Jetpack's CSS editor, and it's possible to use both.
- If you do, the rules in the Jetpack editor will take precedence.", 'wordcamporg' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( "This tool plays nicely with the Core/Jetpack editor, and it's possible to use both.
+ If you do, the rules in the Core/Jetpack editor will take precedence.", 'wordcamporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </li>
</span><span class="cx" style="display: block; padding: 0 10px"> </ul>
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewspageremotecssphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/page-remote-css.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/page-remote-css.php 2016-12-23 17:27:38 UTC (rev 4577)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/page-remote-css.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,33 +3,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordCamp\RemoteCSS;
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @var string $notice
+ * @var string $notice_class
+ * @var string $remote_css_url
+ * @var string $output_mode
+ */
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wrap">
</span><span class="cx" style="display: block; padding: 0 10px"> <h1><?php _e( 'Remote CSS', 'wordcamporg' ); ?></h1>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php if ( ! $jetpack_custom_css_active ) : ?>
- <div id="message" class="notice notice-error inline">
- <?php
- /*
- * Jetpack_Custom_CSS is used to sanitize the unsafe CSS, and for removing the theme's stylesheet
- * in `replace` mode. Methods from Jetpack_Custom_CSS are called throughout this plugin, so we
- * need it to be active.
- */
- ?>
-
- <p>
- <?php printf(
- __( 'This tool uses some functionality from Jetpack\'s Custom CSS module,
- but it doesn\'t look like it\'s available.
- Please <a href="%s">activate it</a>.',
- 'wordcamporg' ),
- esc_url( $jetpack_modules_url )
- ); ?>
- </p>
- </div>
- <?php endif; ?>
-
</del><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_callable( '\WordCamp\Jetpack_Tweaks\notify_import_rules_stripped' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // This has to be called manually because process_options_page() is called after `admin_notices` fires
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,32 +24,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php if ( $notice ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="message" class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- /*
- * Typically KSES is discouraged when displaying text because it's expensive, but in this case
- * it's appropriate because the underlying layers need to pass HTML-formatted error messages, and
- * this only only runs when the options are updated.
- */
- ?>
-
</del><span class="cx" style="display: block; padding: 0 10px"> <p><?php echo wp_kses( $notice, wp_kses_allowed_html( 'data' ) ); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'This tool allows you to develop your CSS in any environment that you choose, and with the tools that you prefer,
- rather than with Jetpack\'s CSS Editor.
- <button type="button" id="wcrcss-open-help-tab" class="button-link">Open the Help tab</button> for detailed instructions.',
- 'wordcamporg' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e(
+ 'Remote CSS allows you to develop your CSS in any environment that you choose, and with whatever tools that you prefer.
+ <button type="button" id="wcrcss-open-help-tab" class="button-link">Open the Help tab</button> for detailed instructions.',
+ 'wordcamporg'
+ ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <form action="" method="POST">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php wp_nonce_field( 'wcrcss-options-submit', 'wcrcss-options-nonce' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <fieldset <?php disabled( $jetpack_custom_css_active, false ); ?>>
</del><span class="cx" style="display: block; padding: 0 10px"> <p>
</span><span class="cx" style="display: block; padding: 0 10px"> <label>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'Remote CSS File:', 'wordcamporg' ); ?><br />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'Remote CSS URL:', 'wordcamporg' ); ?><br />
</ins><span class="cx" style="display: block; padding: 0 10px"> <input type="text" name="wcrcss-remote-css-url" class="large-text" value="<?php echo esc_url( $remote_css_url ); ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> </label>
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,7 +67,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php submit_button( __( 'Update', 'wordcamporg' ) ); ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- </fieldset>
</del><span class="cx" style="display: block; padding: 0 10px"> </form>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampremotecssviewstemplatediscoverynoticephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/template-discovery-notice.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/template-discovery-notice.php (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-remote-css/views/template-discovery-notice.php 2016-12-23 17:27:43 UTC (rev 4578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,19 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordCamp\RemoteCSS;
+defined( 'WPINC' ) or die();
+
+/**
+ * @var string $plugin_url
+ * @var string $notice_text
+ */
+
+?>
+
+<img
+ src="<?php echo esc_url( $plugin_url ); ?>/images/github-mark.svg"
+ alt="GitHub logo"
+ style="position: relative; top: 3px; float: left; height: 2em; margin-right: 5px;"
+/>
+
+<?php echo wp_kses( $notice_text, wp_kses_allowed_html( 'data' ) ); ?>
</ins></span></pre>
</div>
</div>
</body>
</html>