| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | class Jetpack_Custom_CSS { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 	static function init() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 		add_action( 'switch_theme', array( __CLASS__, 'reset' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 		add_action( 'wp_restore_post_revision', array( __CLASS__, 'restore_revision' ), 10, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 		// Save revisions for posts of type safecss. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 		add_action( 'load-revision.php', array( __CLASS__, 'add_revision_redirect' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		// Override the edit link, the default link causes a redirect loop | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 		add_filter( 'get_edit_post_link', array( __CLASS__, 'revision_post_link' ), 10, 3 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		// Overwrite the content width global variable if one is set in the custom css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 		add_action( 'template_redirect', array( __CLASS__, 'set_content_width' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		add_action( 'admin_init', array( __CLASS__, 'set_content_width' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		if ( ! is_admin() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 			add_filter( 'stylesheet_uri', array( __CLASS__, 'style_filter' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		define( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 			'SAFECSS_USE_ACE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 			! jetpack_is_mobile() && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 			! Jetpack_User_Agent_Info::is_ipad() && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 			 * Should the Custom CSS module use ACE to process CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 			 * @see http://ace.c9.io/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 			 * @param bool true Use ACE to process the Custom CSS. Default to true. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 			apply_filters( 'safecss_use_ace', true ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		// Register safecss as a custom post_type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		// Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		register_post_type( 'safecss', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	//		These are the defaults | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	//		'exclude_from_search' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	//		'public' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	//		'publicly_queryable' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	//		'show_ui' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			'supports' => array( 'revisions' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			'label' => 'Custom CSS', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			'can_export' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			'rewrite' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			'capabilities' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 				'edit_post' => 'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 				'read_post' => 'read', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 				'delete_post' => 'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 				'edit_posts' => 'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 				'edit_others_posts' => 'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 				'publish_posts' => 'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 				'read_private_posts' => 'read' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		// Short-circuit WP if this is a CSS stylesheet request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		if ( isset( $_GET['custom-css'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			header( 'Content-Type: text/css', true, 200 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 31536000) . ' GMT' ); // 1 year | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			Jetpack_Custom_CSS::print_css(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		add_action( 'admin_enqueue_scripts', array( 'Jetpack_Custom_CSS', 'enqueue_scripts' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		if ( isset( $_GET['page'] ) && 'editcss' == $_GET['page'] && is_admin() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 			// Do migration routine if necessary | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			Jetpack_Custom_CSS::upgrade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			 * Allows additional work when migrating safecss from wp_options to wp_post. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			do_action( 'safecss_migrate_post' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		 * Never embed the style in the head on wpcom. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		 * Yes, this filter should be added to an unsynced file on wpcom, but | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		 * there is no good syntactically-correct location to put it yet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		 * @link https://github.com/Automattic/jetpack/commit/a1be114e9179f64d147124727a58e2cf76c7e5a1#commitcomment-7763921 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			add_filter( 'safecss_embed_style', '__return_false' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 			add_filter( 'safecss_embed_style', array( 'Jetpack_Custom_CSS', 'should_we_inline_custom_css' ), 10, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		add_action( 'wp_head', array( 'Jetpack_Custom_CSS', 'link_tag' ), 101 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		add_filter( 'jetpack_content_width', array( 'Jetpack_Custom_CSS', 'jetpack_content_width' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		add_filter( 'editor_max_image_size', array( 'Jetpack_Custom_CSS', 'editor_max_image_size' ), 10, 3 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		if ( !current_user_can( 'switch_themes' ) && !is_super_admin() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		add_action( 'admin_menu', array( 'Jetpack_Custom_CSS', 'menu' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		if ( isset( $_POST['safecss'] ) && false == strstr( $_SERVER[ 'REQUEST_URI' ], 'options.php' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			check_admin_referer( 'safecss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			$save_result = self::save( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 				'css' => $_POST['safecss'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				'is_preview' => isset( $_POST['action'] ) && $_POST['action'] == 'preview', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				'preprocessor' => isset( $_POST['custom_css_preprocessor'] ) ? $_POST['custom_css_preprocessor'] : '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				'add_to_existing' => isset( $_POST['add_to_existing'] ) ? $_POST['add_to_existing'] == 'true' : true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 				'content_width' => isset( $_POST['custom_content_width'] ) ? $_POST['custom_content_width'] : false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 			if ( $_POST['action'] == 'preview' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				wp_safe_redirect( add_query_arg( 'csspreview', 'true', get_option( 'home' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 				exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			if ( $save_result ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 				add_action( 'admin_notices', array( 'Jetpack_Custom_CSS', 'saved_message' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		// Prevent content filters running on CSS when restoring revisions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		if ( isset( $_REQUEST[ 'action' ] ) && 'restore' === $_REQUEST[ 'action' ] && false !== strstr( $_SERVER[ 'REQUEST_URI' ], 'revision.php' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			$parent_post = get_post( wp_get_post_parent_id( intval( $_REQUEST[ 'revision' ] ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			if ( $parent_post && ! is_wp_error( $parent_post ) && 'safecss' === $parent_post->post_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 				// Remove wp_filter_post_kses, this causes CSS escaping issues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 				remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 				remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 				remove_all_filters( 'content_save_pre' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 		// Modify all internal links so that preview state persists | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 		if ( Jetpack_Custom_CSS::is_preview() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 			ob_start( array( 'Jetpack_Custom_CSS', 'buffer' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * Save new custom CSS. This should be the entry point for any third-party code using Jetpack_Custom_CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 * to save CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	 * @param array $args Array of arguments: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	 *        string $css The CSS (or LESS or Sass) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	 *        bool $is_preview Whether this CSS is preview or published | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	 *        string preprocessor Which CSS preprocessor to use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	 *        bool $add_to_existing Whether this CSS replaces the theme's CSS or supplements it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	 *        int $content_width A custom $content_width to go along with this CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	 * @return int The post ID of the saved Custom CSS post. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	public static function save( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 			'css' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 			'is_preview' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 			'preprocessor' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 			'add_to_existing' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 			'content_width' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		if ( $args['content_width'] && intval( $args['content_width']) > 0 && ( ! isset( $GLOBALS['content_width'] ) || $args['content_width'] != $GLOBALS['content_width'] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 			$args['content_width'] = intval( $args['content_width'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			$args['content_width'] = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 		// Remove wp_filter_post_kses, this causes CSS escaping issues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 		remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 		remove_all_filters( 'content_save_pre' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		 * Fires prior to saving custom css values. Necessitated because the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 		 * core WordPress save_pre filters were removed: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		 * - content_save_pre | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		 * - content_filtered_save_pre | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		 * @param array $args { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		 * Array of custom CSS arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		 * 	@type string $css The CSS (or LESS or Sass). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 		 * 	@type bool $is_preview Whether this CSS is preview or published. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		 * 	@type string preprocessor Which CSS preprocessor to use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 		 * 	@type bool $add_to_existing Whether this CSS replaces the theme's CSS or supplements it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 		 * 	@type int $content_width A custom $content_width to go along with this CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 		 * } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		do_action( 'safecss_save_pre', $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 		$warnings = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		safecss_class(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		$csstidy = new csstidy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 		$csstidy->optimise = new safecss( $csstidy ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 		$csstidy->set_cfg( 'remove_bslash',              false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 		$csstidy->set_cfg( 'compress_colors',            false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 		$csstidy->set_cfg( 'compress_font-weight',       false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		$csstidy->set_cfg( 'optimise_shorthands',        0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 		$csstidy->set_cfg( 'remove_last_;',              false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 		$csstidy->set_cfg( 'case_properties',            false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		$csstidy->set_cfg( 'discard_invalid_properties', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 		$csstidy->set_cfg( 'css_level',                  'CSS3.0' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		$csstidy->set_cfg( 'preserve_css',               true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 		$csstidy->set_cfg( 'template',                   dirname( __FILE__ ) . '/csstidy/wordpress-standard.tpl' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		$css = $orig = $args['css']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		$css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		if ( $css != $prev ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 			$warnings[] = 'preg_replace found stuff'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		// Some people put weird stuff in their CSS, KSES tends to be greedy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		$css = str_replace( '<=', '<=', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		// Why KSES instead of strip_tags?  Who knows? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 		$css = wp_kses_split( $prev = $css, array(), array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		$css = str_replace( '>', '>', $css ); // kses replaces lone '>' with > | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 		// Why both KSES and strip_tags?  Because we just added some '>'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 		$css = strip_tags( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 		if ( $css != $prev ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 			$warnings[] = 'kses found stuff'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		// if we're not using a preprocessor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 		if ( ! $args['preprocessor'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 			 * Fires before parsing the css with CSSTidy, but only if | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 			 * the preprocessor is not configured for use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 			 * @param obj $csstidy The csstidy object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 			 * @param string $css Custom CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 			 * @param array $args Array of custom CSS arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 			do_action( 'safecss_parse_pre', $csstidy, $css, $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 			$csstidy->parse( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 			 * Fires after parsing the css with CSSTidy, but only if | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 			 * the preprocessor is not cinfigured for use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 			 * @param obj $csstidy The csstidy object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 			 * @param array $warnings Array of warnings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 			 * @param array $args Array of custom CSS arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 			do_action( 'safecss_parse_post', $csstidy, $warnings, $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			$css = $csstidy->print->plain(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		if ( $args['add_to_existing'] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 			$add_to_existing = 'yes'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 			$add_to_existing = 'no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		if ( $args['is_preview'] || Jetpack_Custom_CSS::is_freetrial() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 			// Save the CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 			$safecss_revision_id = Jetpack_Custom_CSS::save_revision( $css, true, $args['preprocessor'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 			// Cache Buster | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 			update_option( 'safecss_preview_rev', intval( get_option( 'safecss_preview_rev' ) ) + 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 			update_metadata( 'post', $safecss_revision_id, 'custom_css_add', $add_to_existing ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 			update_metadata( 'post', $safecss_revision_id, 'content_width', $args['content_width'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 			update_metadata( 'post', $safecss_revision_id, 'custom_css_preprocessor', $args['preprocessor'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 			delete_option( 'safecss_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 			delete_option( 'safecss_content_width' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 			if ( $args['is_preview'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 				return $safecss_revision_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 			 * Fires after saving Custom CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 			do_action( 'safecss_save_preview_post' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 		// Save the CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 		$safecss_post_id = Jetpack_Custom_CSS::save_revision( $css, false, $args['preprocessor'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		$safecss_post_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 		update_option( 'safecss_rev', intval( get_option( 'safecss_rev' ) ) + 1 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 		update_post_meta( $safecss_post_id, 'custom_css_add', $add_to_existing ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		update_post_meta( $safecss_post_id, 'content_width', $args['content_width'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		update_post_meta( $safecss_post_id, 'custom_css_preprocessor', $args['preprocessor'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 		delete_option( 'safecss_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 		delete_option( 'safecss_content_width' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 		update_metadata( 'post', $safecss_post_revision['ID'], 'custom_css_add', $add_to_existing ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		update_metadata( 'post', $safecss_post_revision['ID'], 'content_width', $args['content_width'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 		update_metadata( 'post', $safecss_post_revision['ID'], 'custom_css_preprocessor', $args['preprocessor'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 		delete_option( 'safecss_preview_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 		return $safecss_post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 	 * Get the published custom CSS post. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 	static function get_post() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 		$custom_css_post_id = Jetpack_Custom_CSS::post_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		if ( $custom_css_post_id ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 			return get_post( $custom_css_post_id, ARRAY_A ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 	 * Get the post ID of the published custom CSS post. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	 * @return int|bool The post ID if it exists; false otherwise. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 	static function post_id() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		 * Filter the ID of the post where Custom CSS is stored, before the ID is retrieved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 		 * If the callback function returns a non-null value, then post_id() will immediately | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		 * return that value, instead of retrieving the normal post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 		 * @since 3.8.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 		 * @param null null The ID to return instead of the normal ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 		$custom_css_post_id = apply_filters( 'jetpack_custom_css_pre_post_id', null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 		if ( ! is_null( $custom_css_post_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 			return $custom_css_post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 		$custom_css_post_id = wp_cache_get( 'custom_css_post_id' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 		if ( false === $custom_css_post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 			$custom_css_posts = get_posts( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 				'posts_per_page' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 				'post_type' => 'safecss', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 				'post_status' => 'publish', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 				'orderby' => 'date', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 				'order' => 'DESC' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 			) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 			if ( count( $custom_css_posts ) > 0 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 				$custom_css_post_id = $custom_css_posts[0]->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 				$custom_css_post_id = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 			// Save post_id=0 to note that no safecss post exists. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 			wp_cache_set( 'custom_css_post_id', $custom_css_post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 		if ( ! $custom_css_post_id ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		return $custom_css_post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 	 * Get the current revision of the original safecss record | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 	 * @return object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 	static function get_current_revision() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 		$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		if ( empty( $safecss_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		$revisions = wp_get_post_revisions( $safecss_post['ID'], array( 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		// Empty array if no revisions exist | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		if ( empty( $revisions ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 			// Return original post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 			return $safecss_post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 			// Return the first entry in $revisions, this will be the current revision | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 			$current_revision = get_object_vars( array_shift( $revisions ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 			return $current_revision; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 	 * Save new revision of CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 	 * Checks to see if content was modified before really saving | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 	 * @param string $css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 	 * @param bool $is_preview | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 	 * @return bool|int If nothing was saved, returns false. If a post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 	 *                  or revision was saved, returns the post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	static function save_revision( $css, $is_preview = false, $preprocessor = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 		$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 		$compressed_css = Jetpack_Custom_CSS::minify( $css, $preprocessor ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		// If null, there was no original safecss record, so create one | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		if ( null == $safecss_post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 			if ( ! $css ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 			$post = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 			$post['post_content'] = $css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 			$post['post_title'] = 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 			$post['post_status'] = 'publish'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 			$post['post_type'] = 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 			$post['post_content_filtered'] = $compressed_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			// Set excerpt to current theme, for display in revisions list | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 439 |  | View Code Duplication | 			if ( function_exists( 'wp_get_theme' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 				$current_theme = wp_get_theme(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 				$post['post_excerpt'] = $current_theme->Name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 			else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 				$post['post_excerpt'] = get_current_theme(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 			// Insert the CSS into wp_posts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 			$post_id = wp_insert_post( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 			wp_cache_set( 'custom_css_post_id', $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 			return $post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		// Update CSS in post array with new value passed to this function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 		$safecss_post['post_content'] = $css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 		$safecss_post['post_content_filtered'] = $compressed_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 		// Set excerpt to current theme, for display in revisions list | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 458 |  | View Code Duplication | 		if ( function_exists( 'wp_get_theme' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			$current_theme = wp_get_theme(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			$safecss_post['post_excerpt'] = $current_theme->Name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			$safecss_post['post_excerpt'] = get_current_theme(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 		// Don't carry over last revision's timestamps, otherwise revisions all have matching timestamps | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 		unset( $safecss_post['post_date'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		unset( $safecss_post['post_date_gmt'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 		unset( $safecss_post['post_modified'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		unset( $safecss_post['post_modified_gmt'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 		// Do not update post if we are only saving a preview | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 		if ( false === $is_preview ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 			$post_id = wp_update_post( $safecss_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 			wp_cache_set( 'custom_css_post_id', $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 			return $post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 		else if ( ! defined( 'DOING_MIGRATE' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 			return _wp_put_post_revision( $safecss_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 	static function skip_stylesheet() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 		 * Prevent the Custom CSS stylesheet from being enqueued. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 		 * @since 2.2.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 		 * @param null Should the stylesheet be skipped. Default to null. Anything else will force the stylesheet to be skipped. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 		$skip_stylesheet = apply_filters( 'safecss_skip_stylesheet', null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 		if ( null !== $skip_stylesheet ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 			return $skip_stylesheet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 		} elseif ( Jetpack_Custom_CSS::is_customizer_preview() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 			if ( Jetpack_Custom_CSS::is_preview() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 				$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 				if ( $safecss_post ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 					return (bool) ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) == 'no' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 					return (bool) ( get_option( 'safecss_preview_add' ) == 'no' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 			else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 				$custom_css_post_id = Jetpack_Custom_CSS::post_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 				if ( $custom_css_post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 					$custom_css_add = get_post_meta( $custom_css_post_id, 'custom_css_add', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 					// It is possible for the CSS to be stored in a post but for the safecss_add option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 					// to have not been upgraded yet if the user hasn't opened their Custom CSS editor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 					// since October 2012. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 					if ( ! empty( $custom_css_add ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 						return (bool) ( $custom_css_add === 'no' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 				return (bool) ( get_option( 'safecss_add' ) == 'no' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 	static function is_preview() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 		return isset( $_GET['csspreview'] ) && $_GET['csspreview'] === 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 	 * Currently this filter function gets called on | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 	 * 'template_redirect' action and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 	 * 'admin_init' action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 	static function set_content_width(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		// Don't apply this filter on the Edit CSS page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		if ( isset( $_GET ) && isset( $_GET['page'] ) &&  'editcss' == $_GET['page'] && is_admin() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 		$GLOBALS['content_width'] = Jetpack::get_content_width(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 	 * False when the site has the Custom Design upgrade. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 	 * Used only on WordPress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 	static function is_freetrial() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		 * Determine if a WordPress.com site uses a Free trial of the Custom Design Upgrade. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 		 * Used only on WordPress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 		 * @param bool false Does the site use a Free trial of the Custom Design Upgrade. Default to false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 		return apply_filters( 'safecss_is_freetrial', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 	static function get_preprocessor_key() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 		$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 		return get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 	static function get_preprocessor() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 		/** This filter is documented in modules/custom-css/custom-css.php */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		$selected_preprocessor_key = self::get_preprocessor_key(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		$selected_preprocessor = isset( $preprocessors[ $selected_preprocessor_key ] ) ? $preprocessors[ $selected_preprocessor_key ] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 		return $selected_preprocessor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 	static function get_css( $compressed = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 		 * Filter the Custom CSS returned. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 		 * Can be used to return an error, or no CSS at all. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 		 * @param bool false Should we return an error instead of the Custom CSS. Default to false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 		$default_css = apply_filters( 'safecss_get_css_error', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 		if ( $default_css !== false ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 			return $default_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 		$option = ( Jetpack_Custom_CSS::is_preview() || Jetpack_Custom_CSS::is_freetrial() ) ? 'safecss_preview' : 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 		$css = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		if ( 'safecss' == $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 			// Don't bother checking for a migrated 'safecss' option if it never existed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 			if ( false === get_option( 'safecss' ) || get_option( 'safecss_revision_migrated' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 				$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 				if ( ! empty( $safecss_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 					$css = ( $compressed && $safecss_post['post_content_filtered'] ) ? $safecss_post['post_content_filtered'] : $safecss_post['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 				$current_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 				if ( false === $current_revision ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 					$css = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 					$css = ( $compressed && $current_revision['post_content_filtered'] ) ? $current_revision['post_content_filtered'] : $current_revision['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 			// Fix for un-migrated Custom CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 			if ( empty( $safecss_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 				$_css = get_option( 'safecss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 				if ( !empty( $_css ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 					$css = $_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 		else if ( 'safecss_preview' == $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 			$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 			$css = $safecss_post['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 			$css = Jetpack_Custom_CSS::minify( $css, get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 		$css = str_replace( array( '\\\00BB \\\0020', '\0BB \020', '0BB 020' ), '\00BB \0020', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		if ( empty( $css ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 			$css = "/*\n" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 				. wordwrap( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 					 * Filter the default message displayed in the Custom CSS editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 					 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 					 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 					 * @param string $str Default Custom CSS editor content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 					apply_filters( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 						'safecss_default_css', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 						__( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 							"Welcome to Custom CSS!\n\nTo learn how this works, see http://wp.me/PEmnE-Bt", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 							'jetpack' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 						) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 					) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 				. "\n*/"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 		 * Filter the Custom CSS returned from the editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 		 * @param string $css Custom CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 		$css = apply_filters( 'safecss_css', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 		return $css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 	static function replace_insecure_urls( $css ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 		if ( ! function_exists( '_sa_get_frontend_https_url_replacement_map' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 			return $css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 		list( $http_urls, $secure_urls ) = _sa_get_frontend_https_url_replacement_map(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 		return str_replace( $http_urls, $secure_urls, $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 	static function print_css() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 		 * Fires right before printing the custom CSS inside the <head> element. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 		do_action( 'safecss_print_pre' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 		$css = Jetpack_Custom_CSS::get_css( true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 		echo self::replace_insecure_urls( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 	static function should_we_inline_custom_css( $should_we, $css ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 		// If the CSS is less than 2,000 characters, inline it! otherwise return what was passed in. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 		return ( strlen( $css ) < 2000 ) ? true : $should_we; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 	static function link_tag() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 		global $blog_id, $current_blog; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 		if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 			 * Do not include any CSS on the page if the CSS includes an error. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 			 * Setting this filter to true stops any Custom CSS from being enqueued. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 			 * @param bool false Does the CSS include an error. Default to false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 			apply_filters( 'safecss_style_error', false ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 		) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 		if ( ! is_super_admin() && isset( $current_blog ) && ( 1 == $current_blog->spam || 1 == $current_blog->deleted ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 		if ( Jetpack_Custom_CSS::is_customizer_preview() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 		$css    = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 		$option = Jetpack_Custom_CSS::is_preview() ? 'safecss_preview' : 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 		if ( 'safecss' == $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 			if ( get_option( 'safecss_revision_migrated' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 				$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 				if ( ! empty( $safecss_post['post_content'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 					$css = $safecss_post['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 				} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 726 |  | View Code Duplication | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 				$current_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 				if ( ! empty( $current_revision['post_content'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 					$css = $current_revision['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 			// Fix for un-migrated Custom CSS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 			if ( empty( $safecss_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 				$_css = get_option( 'safecss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 				if ( !empty( $_css ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 					$css = $_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 743 |  | View Code Duplication | 		if ( 'safecss_preview' == $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 			$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 			if ( !empty( $safecss_post['post_content'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 				$css = $safecss_post['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 		$css = str_replace( array( '\\\00BB \\\0020', '\0BB \020', '0BB 020' ), '\00BB \0020', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 		if ( $css == '' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 		if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 			 * Allow inserting CSS inline instead of through a separate file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 			 * @since 3.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 			 * @param bool false Should the CSS be added inline instead of through a separate file. Default to false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 			 * @param string $css Custom CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 			apply_filters( 'safecss_embed_style', false, $css ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 		) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 			echo "\r\n" . '<style id="custom-css-css">' . Jetpack_Custom_CSS::get_css( true ) . "</style>\r\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 			$href = home_url( '/' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 			$href = add_query_arg( 'custom-css', 1, $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 			$href = add_query_arg( 'csblog', $blog_id, $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 			$href = add_query_arg( 'cscache', 6, $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  | 			$href = add_query_arg( 'csrev', (int) get_option( $option . '_rev' ), $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 			 * Filter the Custom CSS link enqueued in the head. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 			 * @param string $href Custom CSS link enqueued in the head. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  | 			 * @param string $blog_id Blog ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 			$href = apply_filters( 'safecss_href', $href, $blog_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 			if ( Jetpack_Custom_CSS::is_preview() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 				$href = add_query_arg( 'csspreview', 'true', $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  | 			<link rel="stylesheet" id="custom-css-css" type="text/css" href="<?php echo esc_url( $href ); ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 		 * Fires after creating the <link> in the <head> element for the custom css stylesheet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 		 * @since 2.2.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 		do_action( 'safecss_link_tag_post' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  | 	static function style_filter( $current ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  | 		if ( Jetpack_Custom_CSS::is_freetrial() && ( ! Jetpack_Custom_CSS::is_preview() || ! current_user_can( 'switch_themes' ) ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 			return $current; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 		else if ( Jetpack_Custom_CSS::skip_stylesheet() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 			 * Filter the default blank Custom CSS URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 			 * @since 2.2.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 			 * @param string $url Default blank Custom CSS URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  | 			return apply_filters( 'safecss_style_filter_url', plugins_url( 'custom-css/css/blank.css', __FILE__ ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		return $current; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  | 	static function buffer( $html ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  | 		$html = str_replace( '</body>', Jetpack_Custom_CSS::preview_flag(), $html ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  | 		return preg_replace_callback( '!href=([\'"])(.*?)\\1!', array( 'Jetpack_Custom_CSS', 'preview_links' ), $html ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 	static function preview_links( $matches ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  | 		if ( 0 !== strpos( $matches[2], get_option( 'home' ) ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  | 			return $matches[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  | 		$link = wp_specialchars_decode( $matches[2] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 		$link = add_query_arg( 'csspreview', 'true', $link ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 		$link = esc_url( $link ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | 		return "href={$matches[1]}$link{$matches[1]}"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 	 * Places a black bar above every preview page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 	static function preview_flag() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 		if ( is_admin() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 		$message = esc_html__( 'Preview: changes must be saved or they will be lost', 'jetpack' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 		 * Filter the Preview message displayed on the site when previewing custom CSS, before to save it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 		 * @param string $message Custom CSS preview message. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 		$message = apply_filters( 'safecss_preview_message', $message ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 		$preview_flag_js = "var flag = document.createElement('div'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  | 		flag.innerHTML = " . json_encode( $message ) . "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 		flag.style.background = '#FF6600'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 		flag.style.color = 'white'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 		flag.style.textAlign = 'center'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 		flag.style.fontSize = '15px'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 		flag.style.padding = '2px'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  | 		flag.style.fontFamily = 'sans-serif'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 		document.body.style.paddingTop = '0px'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 		document.body.insertBefore(flag, document.body.childNodes[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 		"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  | 		 * Filter the Custom CSS preview message JS styling. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  | 		 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 		 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  | 		 * @param string $preview_flag_js Custom CSS preview message JS styling. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 		$preview_flag_js = apply_filters( 'safecss_preview_flag_js', $preview_flag_js ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 		if ( $preview_flag_js ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 			$preview_flag_js = '<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 	// <![CDATA[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  | 	' . $preview_flag_js . ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 	// ]]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  | 	</script>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 		return $preview_flag_js; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 	static function menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  | 		$parent = 'themes.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 		$title = __( 'Edit CSS', 'jetpack' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 		$hook = add_theme_page( $title, $title, 'edit_theme_options', 'editcss', array( 'Jetpack_Custom_CSS', 'admin' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 		add_action( "load-revision.php", array( 'Jetpack_Custom_CSS', 'prettify_post_revisions' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 		add_action( "load-$hook", array( 'Jetpack_Custom_CSS', 'update_title' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 	 * Adds a menu item in the appearance section for this plugin's administration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 	 * page. Also adds hooks to enqueue the CSS and JS for the admin page. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 	static function update_title() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 		global $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 		$title = __( 'CSS', 'jetpack' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  | 	static function prettify_post_revisions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  | 		add_filter( 'the_title', array( 'Jetpack_Custom_CSS', 'post_title' ), 10, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  | 	static function post_title( $title, $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | 		if ( !$post_id = (int) $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  | 			return $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 		if ( !$post = get_post( $post_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  | 			return $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 		if ( 'safecss' != $post->post_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  | 			return $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 		return __( 'Custom CSS Stylesheet', 'jetpack' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 	static function enqueue_scripts( $hook ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 		if ( 'appearance_page_editcss' != $hook ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 		wp_enqueue_script( 'postbox' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  | 		wp_enqueue_script( 'custom-css-editor', plugins_url( 'custom-css/js/css-editor.js', __FILE__ ), 'jquery', '20130325', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 		wp_enqueue_style( 'custom-css-editor', plugins_url( 'custom-css/css/css-editor.css', __FILE__ ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  | 		if ( defined( 'SAFECSS_USE_ACE' ) && SAFECSS_USE_ACE ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  | 			wp_register_style( 'jetpack-css-codemirror', plugins_url( 'custom-css/css/codemirror.css', __FILE__ ), array(), '20120905' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  | 			wp_enqueue_style( 'jetpack-css-use-codemirror', plugins_url( 'custom-css/css/use-codemirror.css', __FILE__ ), array( 'jetpack-css-codemirror' ), '20120905' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  | 			wp_register_script( 'jetpack-css-codemirror', plugins_url( 'custom-css/js/codemirror.min.js', __FILE__ ), array(), '3.16', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  | 			wp_enqueue_script( 'jetpack-css-use-codemirror', plugins_url( 'custom-css/js/use-codemirror.js', __FILE__ ), array( 'jquery', 'underscore', 'jetpack-css-codemirror' ), '20131009', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 	static function saved_message() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  | 		echo '<div id="message" class="updated fade"><p><strong>' . __( 'Stylesheet saved.', 'jetpack' ) . '</strong></p></div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 	static function admin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 		add_meta_box( 'submitdiv', __( 'Publish', 'jetpack' ), array( __CLASS__, 'publish_box' ), 'editcss', 'side' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 		add_action( 'custom_css_submitbox_misc_actions', array( __CLASS__, 'content_width_settings' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  | 		$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  | 		if ( ! empty( $safecss_post ) && 0 < $safecss_post['ID'] && wp_get_post_revisions( $safecss_post['ID'] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  | 			add_meta_box( 'revisionsdiv', __( 'CSS Revisions', 'jetpack' ), array( __CLASS__, 'revisions_meta_box' ), 'editcss', 'side' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 		<div class="wrap"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  | 			 * Fires right before the custom css page begins. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | 			 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  | 			do_action( 'custom_design_header' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 			<h1><?php _e( 'CSS Stylesheet Editor', 'jetpack' ); ?></h1> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 			<form id="safecssform" action="" method="post"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 				<?php wp_nonce_field( 'safecss' ) ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 				<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  | 				<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 				<input type="hidden" name="action" value="save" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  | 				<div id="poststuff"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 					<p class="css-support"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 						/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  | 						 * Filter the intro text appearing above the Custom CSS Editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 						 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  | 						 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  | 						 * @param string $str Intro text appearing above the Custom CSS editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  | 						 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  | 						echo apply_filters( 'safecss_intro_text', __( 'New to CSS? Start with a <a href="http://www.htmldog.com/guides/cssbeginner/" target="_blank">beginner tutorial</a>. Questions? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 		Ask in the <a href="http://wordpress.org/support/forum/themes-and-templates" target="_blank">Themes and Templates forum</a>.', 'jetpack' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 					?></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 					<p class="css-support"><?php echo __( 'Note: Custom CSS will be reset when changing themes.', 'jetpack' ); ?></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 					<div id="post-body" class="metabox-holder columns-2"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 						<div id="post-body-content"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  | 							<div class="postarea"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  | 								<textarea id="safecss" name="safecss"<?php if ( SAFECSS_USE_ACE ) echo ' class="hide-if-js"'; ?>><?php echo esc_textarea( Jetpack_Custom_CSS::get_css() ); ?></textarea> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 								<div class="clear"></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 							</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  | 						</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 						<div id="postbox-container-1" class="postbox-container"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  | 						<?php do_meta_boxes( 'editcss', 'side', $safecss_post ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 					</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  | 					</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 					<br class="clear" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 				</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  | 			</form> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  | 		</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  | 	 * Content width setting callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  | 	static function content_width_settings() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  | 		$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 		$custom_content_width = get_post_meta( $safecss_post['ID'], 'content_width', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  | 		// If custom content width hasn't been overridden and the theme has a content_width value, use that as a default. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  | 		if ( $custom_content_width <= 0 && ! empty( $GLOBALS['content_width'] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  | 			$custom_content_width = $GLOBALS['content_width']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 		if ( ! $custom_content_width || ( isset( $GLOBALS['content_width'] ) && $custom_content_width == $GLOBALS['content_width'] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  | 			$custom_content_width = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  | 		<div class="misc-pub-section"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  | 			<label><?php esc_html_e( 'Media Width:', 'jetpack' ); ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 			<span id="content-width-display" data-default-text="<?php esc_attr_e( 'Default', 'jetpack' ); ?>" data-custom-text="<?php esc_attr_e( '%s px', 'jetpack' ); ?>"><?php echo $custom_content_width ? sprintf( esc_html__( '%s px', 'jetpack' ), $custom_content_width ) : esc_html_e( 'Default', 'jetpack' ); ?></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  | 			<a class="edit-content-width hide-if-no-js" href="#content-width"><?php echo esc_html_e( 'Edit', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  | 			<div id="content-width-select" class="hide-if-js"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  | 				<input type="hidden" name="custom_content_width" id="custom_content_width" value="<?php echo esc_attr( $custom_content_width ); ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  | 					printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  | 						__( 'Limit width to %1$s pixels for full size images. (<a href="%2$s" target="_blank">More info</a>.)', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 						'<input type="text" id="custom_content_width_visible" value="' . esc_attr( $custom_content_width ) . '" size="4" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  | 						/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  | 						 * Filter the Custom CSS limited width's support doc URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  | 						 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  | 						 * @since 2.2.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  | 						 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  | 						 * @param string $url Custom CSS limited width's support doc URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  | 						 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  | 						apply_filters( 'safecss_limit_width_link', 'http://jetpack.com/support/custom-css/#limited-width' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  | 					?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  | 				</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 				if ( !empty( $GLOBALS['content_width'] ) && $custom_content_width != $GLOBALS['content_width'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  | 					if ( function_exists( 'wp_get_theme' ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  | 						$current_theme = wp_get_theme()->Name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  | 					else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  | 						$current_theme = get_current_theme(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 					?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  | 					<p><?php printf( __( 'The default content width for the %s theme is %d pixels.', 'jetpack' ), $current_theme, intval( $GLOBALS['content_width'] ) ); ?></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 				<a class="save-content-width hide-if-no-js button" href="#content-width"><?php esc_html_e( 'OK', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 				<a class="cancel-content-width hide-if-no-js" href="#content-width"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 			</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 			<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 				jQuery( function ( $ ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  | 					var defaultContentWidth = <?php echo isset( $GLOBALS['content_width'] ) ? json_encode( intval( $GLOBALS['content_width'] ) ) : 0; ?>; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  | 					$( '.edit-content-width' ).bind( 'click', function ( e ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  | 						e.preventDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  | 						$( '#content-width-select' ).slideDown(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  | 						$( this ).hide(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  | 					} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  | 					$( '.cancel-content-width' ).bind( 'click', function ( e ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  | 						e.preventDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  | 						$( '#content-width-select' ).slideUp( function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  | 							$( '.edit-content-width' ).show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  | 							$( '#custom_content_width_visible' ).val( $( '#custom_content_width' ).val() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  | 						} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  | 					} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  | 					$( '.save-content-width' ).bind( 'click', function ( e ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  | 						e.preventDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  | 						$( '#content-width-select' ).slideUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  | 						var newContentWidth = parseInt( $( '#custom_content_width_visible' ).val(), 10 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  | 						if ( newContentWidth && newContentWidth != defaultContentWidth ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  | 							$( '#content-width-display' ).text( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  | 								$( '#content-width-display' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  | 									.data( 'custom-text' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  | 										.replace( '%s', $( '#custom_content_width_visible' ).val() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  | 							); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  | 						else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  | 							$( '#content-width-display' ).text( $( '#content-width-display' ).data( 'default-text' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  | 						$( '#custom_content_width' ).val( $( '#custom_content_width_visible' ).val() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  | 						$( '.edit-content-width' ).show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  | 					} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  | 				} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  | 		</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  | 	static function publish_box() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  | 		<div id="minor-publishing"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  | 			<div id="misc-publishing-actions"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  | 				 * Filter the array of available Custom CSS preprocessors. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  | 				 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  | 				 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  | 				 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  | 				 * @since 2.0.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  | 				 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  | 				 * @param array array() Empty by default. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  | 				$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  | 				if ( ! empty( $preprocessors ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  | 					$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  | 					$selected_preprocessor_key = get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  | 					$selected_preprocessor = isset( $preprocessors[$selected_preprocessor_key] ) ? $preprocessors[$selected_preprocessor_key] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  | 					?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  | 					<div class="misc-pub-section"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  | 						<label><?php esc_html_e( 'Preprocessor:', 'jetpack' ); ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  | 						<span id="preprocessor-display"><?php echo esc_html( $selected_preprocessor ? $selected_preprocessor['name'] : __( 'None', 'jetpack' ) ); ?></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  | 						<a class="edit-preprocessor hide-if-no-js" href="#preprocessor"><?php echo esc_html_e( 'Edit', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  | 						<div id="preprocessor-select" class="hide-if-js"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  | 							<input type="hidden" name="custom_css_preprocessor" id="custom_css_preprocessor" value="<?php echo esc_attr( $selected_preprocessor_key ); ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  | 							<select id="preprocessor_choices"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  | 								<option value=""><?php esc_html_e( 'None', 'jetpack' ); ?></option> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  | 								<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  | 								foreach ( $preprocessors as $preprocessor_key => $preprocessor ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 								?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  | 									<option value="<?php echo esc_attr( $preprocessor_key ); ?>" <?php selected( $selected_preprocessor_key, $preprocessor_key ); ?>><?php echo esc_html( $preprocessor['name'] ); ?></option> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 									<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 								?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 							</select> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 							<a class="save-preprocessor hide-if-no-js button" href="#preprocessor"><?php esc_html_e( 'OK', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 							<a class="cancel-preprocessor hide-if-no-js" href="#preprocessor"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  | 						</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  | 					</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 				$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 				$add_css = ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) != 'no' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 				<div class="misc-pub-section"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  | 					<label><?php esc_html_e( 'Mode:', 'jetpack' ); ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 					<span id="css-mode-display"><?php echo esc_html( $add_css ? __( 'Add-on', 'jetpack' ) : __( 'Replacement', 'jetpack' ) ); ?></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 					<a class="edit-css-mode hide-if-no-js" href="#css-mode"><?php echo esc_html_e( 'Edit', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 					<div id="css-mode-select" class="hide-if-js"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 						<input type="hidden" name="add_to_existing" id="add_to_existing" value="<?php echo $add_css ? 'true' : 'false'; ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  | 						<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  | 							<label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  | 								<input type="radio" name="add_to_existing_display" value="true" <?php checked( $add_css ); ?>/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 								<?php _e( 'Add-on CSS <b>(Recommended)</b>', 'jetpack' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  | 							</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 							<br /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 							<label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 								<input type="radio" name="add_to_existing_display" value="false" <?php checked( ! $add_css ); ?>/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  | 								<?php printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 									__( 'Replace <a href="%s">theme\'s CSS</a> <b>(Advanced)</b>', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 									/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 									 * Filter the theme's stylesheet URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  | 									 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  | 									 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  | 									 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  | 									 * @since 1.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  | 									 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  | 									 * @param string $url Active theme's stylesheet URL. Default to get_stylesheet_uri(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  | 									 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  | 									apply_filters( 'safecss_theme_stylesheet_url', get_stylesheet_uri() ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  | 								); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  | 							</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  | 						</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  | 						<a class="save-css-mode hide-if-no-js button" href="#css-mode"><?php esc_html_e( 'OK', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  | 						<a class="cancel-css-mode hide-if-no-js" href="#css-mode"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  | 					</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  | 				</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  | 				 * Allows addition of elements to the submit box for custom css on the wp-admin side. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  | 				 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  | 				 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  | 				 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  | 				 * @since 2.0.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  | 				do_action( 'custom_css_submitbox_misc_actions' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  | 			</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  | 		</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  | 		<div id="major-publishing-actions"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  | 			<input type="button" class="button" id="preview" name="preview" value="<?php esc_attr_e( 'Preview', 'jetpack' ) ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  | 			<div id="publishing-action"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  | 				<input type="submit" class="button-primary" id="save" name="save" value="<?php ( Jetpack_Custom_CSS::is_freetrial() ) ? esc_attr_e( 'Save & Buy Upgrade', 'jetpack' ) : esc_attr_e( 'Save Stylesheet', 'jetpack' ); ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  | 			</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  | 		</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  | 	 * Render metabox listing CSS revisions and the themes that correspond to the revisions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  | 	 * Called by safecss_admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  | 	 * @global $post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  | 	 * @param array $safecss_post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  | 	 * @uses wp_revisions_to_keep | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  | 	 * @uses WP_Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  | 	 * @uses wp_post_revision_title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  | 	 * @uses esc_html | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  | 	 * @uses add_query_arg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  | 	 * @uses menu_page_url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  | 	 * @uses wp_reset_query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  | 	static function revisions_meta_box( $safecss_post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  | 		$show_all_revisions = isset( $_GET['show_all_rev'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  | 		if ( function_exists( 'wp_revisions_to_keep' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | 			$max_revisions = wp_revisions_to_keep( (object) $safecss_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 			$max_revisions = defined( 'WP_POST_REVISIONS' ) && is_numeric( WP_POST_REVISIONS ) ? (int) WP_POST_REVISIONS : 25; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  | 		$posts_per_page = $show_all_revisions ? $max_revisions : 6; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  | 		$revisions = new WP_Query( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  | 			'posts_per_page' => $posts_per_page, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  | 			'post_type' => 'revision', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  | 			'post_status' => 'inherit', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  | 			'post_parent' => $safecss_post['ID'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  | 			'orderby' => 'date', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  | 			'order' => 'DESC' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  | 		if ( $revisions->have_posts() ) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  | 			<ul class="post-revisions"><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  | 			global $post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 			while ( $revisions->have_posts() ) : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  | 				$revisions->the_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  | 				?><li> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 						echo wp_post_revision_title( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  | 						if ( ! empty( $post->post_excerpt ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  | 							echo ' (' . esc_html( $post->post_excerpt ) . ')'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  | 					?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  | 				</li><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  | 			endwhile; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  | 			?></ul><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 			if ( $revisions->found_posts > 6 && !$show_all_revisions ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 				<br> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 				<a href="<?php echo add_query_arg( 'show_all_rev', 'true', menu_page_url( 'editcss', false ) ); ?>"><?php esc_html_e( 'Show all', 'jetpack' ); ?></a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 		wp_reset_query(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 	 * Hook in init at priority 11 to disable custom CSS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 	static function disable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  | 		remove_action( 'wp_head', array( 'Jetpack_Custom_CSS', 'link_tag' ), 101 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 	    remove_filter( 'stylesheet_uri', array( 'Jetpack_Custom_CSS', 'style_filter' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  | 	 * Reset all aspects of Custom CSS on a theme switch so that changing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 	 * themes is a sure-fire way to get a clean start. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 	static function reset() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 		$safecss_post_id = Jetpack_Custom_CSS::save_revision( '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 		$safecss_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 		update_option( 'safecss_rev', intval( get_option( 'safecss_rev' ) ) + 1 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 		update_post_meta( $safecss_post_id, 'custom_css_add', 'yes' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  | 		update_post_meta( $safecss_post_id, 'content_width', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  | 		update_post_meta( $safecss_post_id, 'custom_css_preprocessor', '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 		delete_option( 'safecss_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  | 		delete_option( 'safecss_content_width' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'custom_css_add', 'yes' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'content_width', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'custom_css_preprocessor', '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 		delete_option( 'safecss_preview_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 	static function is_customizer_preview() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 		if ( isset ( $GLOBALS['wp_customize'] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  | 			return ! $GLOBALS['wp_customize']->is_theme_active(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 	static function minify( $css, $preprocessor = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 		if ( ! $css ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  | 		if ( $preprocessor ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  | 			/** This filter is documented in modules/custom-css/custom-css.php */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  | 			$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  | 			if ( isset( $preprocessors[$preprocessor] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  | 				$css = call_user_func( $preprocessors[$preprocessor]['callback'], $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 		safecss_class(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 		$csstidy = new csstidy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  | 		$csstidy->optimise = new safecss( $csstidy ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 		$csstidy->set_cfg( 'remove_bslash',              false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 		$csstidy->set_cfg( 'compress_colors',            true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 		$csstidy->set_cfg( 'compress_font-weight',       true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 		$csstidy->set_cfg( 'remove_last_;',              true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  | 		$csstidy->set_cfg( 'case_properties',            true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  | 		$csstidy->set_cfg( 'discard_invalid_properties', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 		$csstidy->set_cfg( 'css_level',                  'CSS3.0' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  | 		$csstidy->set_cfg( 'template', 'highest'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 		$csstidy->parse( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 		return $csstidy->print->plain(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  | 	 * When restoring a SafeCSS post revision, also copy over the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  | 	 * content_width and custom_css_add post metadata. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  | 	static function restore_revision( $_post_id, $_revision_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 		$_post = get_post( $_post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 		if ( 'safecss' != $_post->post_type ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 		$safecss_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  | 		$content_width = get_post_meta( $_revision_id, 'content_width', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 		$custom_css_add = get_post_meta( $_revision_id, 'custom_css_add', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  | 		$preprocessor = get_post_meta( $_revision_id, 'custom_css_preprocessor', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'content_width', $content_width ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'custom_css_add', $custom_css_add ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  | 		update_metadata( 'post', $safecss_revision['ID'], 'custom_css_preprocessor', $preprocessor ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  | 		delete_option( 'safecss_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 		delete_option( 'safecss_content_width' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 		update_post_meta( $_post->ID, 'content_width', $content_width ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 		update_post_meta( $_post->ID, 'custom_css_add', $custom_css_add ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 		update_post_meta( $_post->ID, 'custom_css_preprocessor', $preprocessor ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 		delete_option( 'safecss_preview_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 	 * Migration routine for moving safecss from wp_options to wp_posts to support revisions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 	static function upgrade() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  | 		$css = get_option( 'safecss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  | 		if ( get_option( 'safecss_revision_migrated' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 		// Check if CSS is stored in wp_options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 		if ( $css ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  | 			// Remove the async actions from publish_post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  | 			remove_action( 'publish_post', 'queue_publish_post' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 			$post = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 			$post['post_content'] = $css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 			$post['post_title'] = 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 			$post['post_status'] = 'publish'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  | 			$post['post_type'] = 'safecss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 			// Insert the CSS into wp_posts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 			$post_id = wp_insert_post( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  | 			// Check for errors | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  | 			if ( !$post_id or is_wp_error( $post_id ) ) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 				die( $post_id->get_error_message() ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  | 			// Delete safecss option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  | 			delete_option( 'safecss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  | 		unset( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 		// Check if we have already done this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 		if ( !get_option( 'safecss_revision_migrated' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 			define( 'DOING_MIGRATE', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 			// Get hashes of safecss post and current revision | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 			$safecss_post = Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  | 			if ( empty( $safecss_post ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  | 				return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 			$safecss_post_hash = md5( $safecss_post['post_content'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  | 			$current_revision = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 			if ( null == $current_revision ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  | 				return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 			$current_revision_hash = md5( $current_revision['post_content'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  | 			// If hashes are not equal, set safecss post with content from current revision | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  | 			if ( $safecss_post_hash !== $current_revision_hash ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 				Jetpack_Custom_CSS::save_revision( $current_revision['post_content'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  | 				// Reset post_content to display the migrated revsion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 				$safecss_post['post_content'] = $current_revision['post_content']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | 			// Set option so that we dont keep doing this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  | 			update_option( 'safecss_revision_migrated', time() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 		$newest_safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 		if ( $newest_safecss_post ) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1467 |  | View Code Duplication | 			if ( get_option( 'safecss_content_width' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  | 				// Add the meta to the post and the latest revision. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 				update_post_meta( $newest_safecss_post['ID'], 'content_width', get_option( 'safecss_content_width' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 				update_metadata( 'post', $newest_safecss_post['ID'], 'content_width', get_option( 'safecss_content_width' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 				delete_option( 'safecss_content_width' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1475 |  | View Code Duplication | 			if ( get_option( 'safecss_add' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 				update_post_meta( $newest_safecss_post['ID'], 'custom_css_add', get_option( 'safecss_add' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  | 				update_metadata( 'post', $newest_safecss_post['ID'], 'custom_css_add', get_option( 'safecss_add' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  | 				delete_option( 'safecss_add' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  | 	 * Adds a filter to the redirect location in `wp-admin/revisions.php`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  | 	static function add_revision_redirect() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  | 		add_filter( 'wp_redirect', array( __CLASS__, 'revision_redirect' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  | 	 * Filters the redirect location in `wp-admin/revisions.php`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  | 	 * @param string $location The path to redirect to. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 	static function revision_redirect( $location ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 		$post = get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  | 		if ( ! empty( $post->post_type ) && 'safecss' == $post->post_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  | 			$location = 'themes.php?page=editcss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  | 			if ( 'edit.php' == $location ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  | 				$location = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 |  |  | 		return $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  | 	static function revision_post_link( $post_link, $post_id, $context ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  | 		if ( !$post_id = (int) $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  | 			return $post_link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  | 		if ( !$post = get_post( $post_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  | 			return $post_link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  | 		if ( 'safecss' != $post->post_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  | 			return $post_link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  | 		$post_link = admin_url( 'themes.php?page=editcss' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  | 		if ( 'display' == $context ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  | 			return esc_url( $post_link ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  | 		return esc_url_raw( $post_link ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 	 * When on the edit screen, make sure the custom content width | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 	 * setting is applied to the large image size. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 	static function editor_max_image_size( $dims, $size = 'medium', $context = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 		list( $width, $height ) = $dims; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 		if ( 'large' == $size && 'edit' == $context ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | 			$width = Jetpack::get_content_width(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 		return array( $width, $height ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 	 * Override the content_width with a custom value if one is set. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1548 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 1549 |  |  | 	static function jetpack_content_width( $content_width ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1550 |  |  | 		$custom_content_width = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 1551 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1552 |  |  | 		if ( Jetpack_Custom_CSS::is_preview() ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1553 |  |  | 			$safecss_post = Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                        
                            
            
                                    
            
            
                | 1554 |  |  | 			$custom_content_width = intval( get_post_meta( $safecss_post['ID'], 'content_width', true ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1555 |  |  | 		} else if ( ! Jetpack_Custom_CSS::is_freetrial() ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1556 |  |  | 			$custom_css_post_id = Jetpack_Custom_CSS::post_id(); | 
            
                                                                        
                            
            
                                    
            
            
                | 1557 |  |  | 			if ( $custom_css_post_id ) | 
            
                                                                        
                            
            
                                    
            
            
                | 1558 |  |  | 				$custom_content_width = intval( get_post_meta( $custom_css_post_id, 'content_width', true ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1559 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1560 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1561 |  |  | 		if ( $custom_content_width > 0 ) | 
            
                                                                        
                            
            
                                    
            
            
                | 1562 |  |  | 			$content_width = $custom_content_width; | 
            
                                                                        
                            
            
                                    
            
            
                | 1563 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1564 |  |  | 		return $content_width; | 
            
                                                                        
                            
            
                                    
            
            
                | 1565 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | class Jetpack_Safe_CSS { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  | 	static function filter_attr( $css, $element = 'div' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  | 		safecss_class(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  | 		$css = $element . ' {' . $css . '}'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  | 		$csstidy = new csstidy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  | 		$csstidy->optimise = new safecss( $csstidy ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 		$csstidy->set_cfg( 'remove_bslash', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  | 		$csstidy->set_cfg( 'compress_colors', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  | 		$csstidy->set_cfg( 'compress_font-weight', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  | 		$csstidy->set_cfg( 'discard_invalid_properties', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  | 		$csstidy->set_cfg( 'merge_selectors', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  | 		$csstidy->set_cfg( 'remove_last_;', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  | 		$csstidy->set_cfg( 'css_level', 'CSS3.0' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  | 		$css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  | 		$css = wp_kses_split( $css, array(), array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  | 		$csstidy->parse( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  | 		$css = $csstidy->print->plain(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  | 		$css = str_replace( array( "\n","\r","\t" ), '', $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  | 		preg_match( "/^{$element}\s*{(.*)}\s*$/", $css, $matches ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  | 		if ( empty( $matches[1] ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  | 		return $matches[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  | function migrate() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::upgrade()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  | 	return Jetpack_Custom_CSS::upgrade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | function safecss_revision_redirect( $redirect ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::revision_redirect()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  | 	return Jetpack_Custom_CSS::revision_redirect( $redirect ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  | function safecss_revision_post_link( $post_link, $post_id, $context ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::revision_post_link()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  | 	return Jetpack_Custom_CSS::revision_post_link( $post_link, $post_id, $context ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  | function get_safecss_post() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1620 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::get_post()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  | 	return Jetpack_Custom_CSS::get_post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  | function custom_css_post_id() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::post_id()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  | 	return Jetpack_Custom_CSS::post_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  | function get_current_revision() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::get_current_revision()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  | 	return Jetpack_Custom_CSS::get_current_revision(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  | function save_revision( $css, $is_preview = false, $preprocessor = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::save_revision()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  | 	return Jetpack_Custom_CSS::save_revision( $css, $is_preview, $preprocessor ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  | function safecss_skip_stylesheet() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::skip_stylesheet()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  | 	return Jetpack_Custom_CSS::skip_stylesheet(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  | function safecss_init() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::init()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  | 	return Jetpack_Custom_CSS::init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  | function safecss_is_preview() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::is_preview()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  | 	return Jetpack_Custom_CSS::is_preview(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  | function safecss_is_freetrial() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::is_freetrial()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 |  |  | 	return Jetpack_Custom_CSS::is_freetrial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1665 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1666 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1667 |  |  | function safecss( $compressed = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1668 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::get_css()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1669 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1670 |  |  | 	return Jetpack_Custom_CSS::get_css( $compressed ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1671 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1672 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1673 |  |  | function safecss_print() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1674 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::print_css()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1675 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1676 |  |  | 	return Jetpack_Custom_CSS::print_css(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1677 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1678 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1679 |  |  | function safecss_style() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1680 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::link_tag()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1681 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1682 |  |  | 	return Jetpack_Custom_CSS::link_tag(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1683 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1685 |  |  | function safecss_style_filter( $current ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1686 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::style_filter()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1687 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1688 |  |  | 	return Jetpack_Custom_CSS::style_filter( $current ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1689 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1691 |  |  | function safecss_buffer( $html ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1692 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::buffer()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1693 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1694 |  |  | 	return Jetpack_Custom_CSS::buffer( $html ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1695 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1696 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1697 |  |  | function safecss_preview_links( $matches ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1698 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::preview_links()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1699 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1700 |  |  | 	return Jetpack_Custom_CSS::preview_links( $matches ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1701 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1702 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1703 |  |  | function safecss_preview_flag() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1704 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::preview_flag()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1705 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1706 |  |  | 	return Jetpack_Custom_CSS::preview_flag(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1707 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1708 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1709 |  |  | function safecss_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1710 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::menu()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1711 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1712 |  |  | 	return Jetpack_Custom_CSS::menu(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1713 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1714 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1715 |  |  | function update_title() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1716 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::update_title()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1717 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1718 |  |  | 	return Jetpack_Custom_CSS::update_title(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1719 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1720 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1721 |  |  | function safecss_prettify_post_revisions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1722 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::prettify_post_revisions()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1723 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1724 |  |  | 	return Jetpack_Custom_CSS::prettify_post_revisions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1725 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1726 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1727 |  |  | function safecss_remove_title_excerpt_from_revisions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1728 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::remove_title_excerpt_from_revisions()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1729 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1730 |  |  | 	return Jetpack_Custom_CSS::remove_title_excerpt_from_revisions(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1731 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1732 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1733 |  |  | function safecss_post_title( $title, $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1734 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::post_title()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1735 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1736 |  |  | 	return Jetpack_Custom_CSS::post_title( $title, $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1737 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1738 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1739 |  |  | function safe_css_enqueue_scripts() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1740 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::enqueue_scripts()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1741 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1742 |  |  | 	return Jetpack_Custom_CSS::enqueue_scripts(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1743 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1744 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1745 |  |  | function safecss_admin_head() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1746 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::admin_head()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1747 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1748 |  |  | 	return Jetpack_Custom_CSS::admin_head(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1749 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1750 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1751 |  |  | function safecss_saved() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1752 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::saved_message()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1753 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1754 |  |  | 	return Jetpack_Custom_CSS::saved_message(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1755 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1756 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1757 |  |  | function safecss_admin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1758 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::admin()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1759 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1760 |  |  | 	return Jetpack_Custom_CSS::admin(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1761 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1762 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1763 |  |  | function custom_css_meta_box() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1764 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'add_meta_box( $id, $title, $callback, \'editcss\', \'side\' )' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1765 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1766 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1767 |  |  | function custom_css_post_revisions_meta_box( $safecss_post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1768 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::revisions_meta_box()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1769 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1770 |  |  | 	return Jetpack_Custom_CSS::revisions_meta_box( $safecss_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1771 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1773 |  |  | function disable_safecss_style() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1774 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::disable()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1775 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1776 |  |  | 	return Jetpack_Custom_CSS::disable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1777 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1778 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1779 |  |  | function custom_css_reset() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1780 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::reset()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1781 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1782 |  |  | 	return Jetpack_Custom_CSS::reset(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1783 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1784 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1785 |  |  | function custom_css_is_customizer_preview() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1786 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::is_customizer_preview()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1787 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1788 |  |  | 	return Jetpack_Custom_CSS::is_customizer_preview(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1789 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1790 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1791 |  |  | function custom_css_minify( $css, $preprocessor = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1792 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::minify()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1793 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1794 |  |  | 	return Jetpack_Custom_CSS::minify( $css, $preprocessor ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1795 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1796 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1797 |  |  | function custom_css_restore_revision( $_post_id, $_revision_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1798 |  |  | 	_deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::restore_revision()' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1799 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1800 |  |  | 	return Jetpack_Custom_CSS::restore_revision( $_post_id, $_revision_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1801 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1803 |  |  | function safecss_class() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1804 |  |  | 	// Wrapped so we don't need the parent class just to load the plugin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1805 |  |  | 	if ( class_exists('safecss') ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1806 |  |  | 		return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1807 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1808 |  |  | 	require_once( dirname( __FILE__ ) . '/csstidy/class.csstidy.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1809 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1810 |  |  | 	class safecss extends csstidy_optimise { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1811 |  |  | 		function __construct( &$css ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1812 |  |  | 			return $this->csstidy_optimise( $css ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1813 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1814 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1815 |  |  | 		function postparse() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1816 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1817 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1818 |  |  | 			 * Fires after parsing the css. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1819 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1820 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1821 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1822 |  |  | 			 * @since 1.8.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1823 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1824 |  |  | 			 * @param obj $this CSSTidy object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1825 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1826 |  |  | 			do_action( 'csstidy_optimize_postparse', $this ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1828 |  |  | 			return parent::postparse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1829 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1830 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1831 |  |  | 		function subvalue() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1832 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1833 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1834 |  |  | 			 * Fires before optimizing the Custom CSS subvalue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1835 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1836 |  |  | 			 * @module custom-css | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1837 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1838 |  |  | 			 * @since 1.8.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1839 |  |  | 			 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1840 |  |  | 			 * @param obj $this CSSTidy object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1841 |  |  | 			 **/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1842 |  |  | 			do_action( 'csstidy_optimize_subvalue', $this ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1843 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1844 |  |  | 			return parent::subvalue(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1845 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1846 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1847 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1848 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1849 |  |  | if ( ! function_exists( 'safecss_filter_attr' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1850 |  |  | 	function safecss_filter_attr( $css, $element = 'div' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1851 |  |  | 		return Jetpack_Safe_CSS::filter_attr( $css, $element ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1852 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1853 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1854 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1855 |  |  | add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1856 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1857 |  |  | include dirname( __FILE__ ) . '/custom-css/preprocessors.php'; | 
            
                                                        
            
                                    
            
            
                | 1858 |  |  |  | 
            
                        
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exitexpression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.