Exemple #1
0
 /**
  * Override the content_width with a custom value if one is set.
  */
 static function jetpack_content_width($content_width)
 {
     $custom_content_width = 0;
     if (Jetpack_Custom_CSS::is_preview()) {
         $safecss_post = Jetpack_Custom_CSS::get_current_revision();
         $custom_content_width = intval(get_post_meta($safecss_post['ID'], 'content_width', true));
     } else {
         if (!Jetpack_Custom_CSS::is_freetrial()) {
             $custom_css_post_id = Jetpack_Custom_CSS::post_id();
             if ($custom_css_post_id) {
                 $custom_content_width = intval(get_post_meta($custom_css_post_id, 'content_width', true));
             }
         }
     }
     if ($custom_content_width > 0) {
         $content_width = $custom_content_width;
     }
     return $content_width;
 }
Exemple #2
0
    static function publish_box()
    {
        ?>
		<div id="minor-publishing">
			<div id="misc-publishing-actions">
				<?php 
        $preprocessors = apply_filters('jetpack_custom_css_preprocessors', array());
        if (!empty($preprocessors)) {
            $safecss_post = Jetpack_Custom_CSS::get_current_revision();
            $selected_preprocessor_key = get_post_meta($safecss_post['ID'], 'custom_css_preprocessor', true);
            $selected_preprocessor = isset($preprocessors[$selected_preprocessor_key]) ? $preprocessors[$selected_preprocessor_key] : null;
            ?>
					<div class="misc-pub-section">
						<label><?php 
            esc_html_e('Preprocessor:', 'jetpack');
            ?>
</label>
						<span id="preprocessor-display"><?php 
            echo esc_html($selected_preprocessor ? $selected_preprocessor['name'] : __('None', 'jetpack'));
            ?>
</span>
						<a class="edit-preprocessor hide-if-no-js" href="#preprocessor"><?php 
            echo esc_html_e('Edit', 'jetpack');
            ?>
</a>
						<div id="preprocessor-select" class="hide-if-js">
							<input type="hidden" name="custom_css_preprocessor" id="custom_css_preprocessor" value="<?php 
            echo esc_attr($selected_preprocessor_key);
            ?>
" />
							<select id="preprocessor_choices">
								<option value=""><?php 
            esc_html_e('None', 'jetpack');
            ?>
</option>
								<?php 
            foreach ($preprocessors as $preprocessor_key => $preprocessor) {
                ?>
									<option value="<?php 
                echo esc_attr($preprocessor_key);
                ?>
" <?php 
                selected($selected_preprocessor_key, $preprocessor_key);
                ?>
><?php 
                echo esc_html($preprocessor['name']);
                ?>
</option>
									<?php 
            }
            ?>
							</select>
							<a class="save-preprocessor hide-if-no-js button" href="#preprocessor"><?php 
            esc_html_e('OK', 'jetpack');
            ?>
</a>
							<a class="cancel-preprocessor hide-if-no-js" href="#preprocessor"><?php 
            esc_html_e('Cancel', 'jetpack');
            ?>
</a>
						</div>
					</div>
					<?php 
        }
        $safecss_post = Jetpack_Custom_CSS::get_current_revision();
        $add_css = get_post_meta($safecss_post['ID'], 'custom_css_add', true) != 'no';
        ?>
				<div class="misc-pub-section">
					<label><?php 
        esc_html_e('Mode:', 'jetpack');
        ?>
</label>
					<span id="css-mode-display"><?php 
        echo esc_html($add_css ? __('Add-on', 'jetpack') : __('Replacement', 'jetpack'));
        ?>
</span>
					<a class="edit-css-mode hide-if-no-js" href="#css-mode"><?php 
        echo esc_html_e('Edit', 'jetpack');
        ?>
</a>
					<div id="css-mode-select" class="hide-if-js">
						<input type="hidden" name="add_to_existing" id="add_to_existing" value="<?php 
        echo $add_css ? 'true' : 'false';
        ?>
" />
						<p>
							<label>
								<input type="radio" name="add_to_existing_display" value="true" <?php 
        checked($add_css);
        ?>
/>
								<?php 
        _e('Add-on CSS <b>(Recommended)</b>', 'jetpack');
        ?>
							</label>
							<br />
							<label>
								<input type="radio" name="add_to_existing_display" value="false" <?php 
        checked(!$add_css);
        ?>
/>
								<?php 
        printf(__('Replace <a href="%s">theme\'s CSS</a> <b>(Advanced)</b>', 'jetpack'), apply_filters('safecss_theme_stylesheet_url', get_stylesheet_uri()));
        ?>
							</label>
						</p>
						<a class="save-css-mode hide-if-no-js button" href="#css-mode"><?php 
        esc_html_e('OK', 'jetpack');
        ?>
</a>
						<a class="cancel-css-mode hide-if-no-js" href="#css-mode"><?php 
        esc_html_e('Cancel', 'jetpack');
        ?>
</a>
					</div>
					<script type="text/javascript">
						jQuery( function ( $ ) {
							$( '.edit-css-mode' ).bind( 'click', function ( e ) {
								e.preventDefault();

								$( '#css-mode-select' ).slideDown();
								$( this ).hide();
							} );

							$( '.cancel-css-mode' ).bind( 'click', function ( e ) {
								e.preventDefault();

								$( '#css-mode-select' ).slideUp( function () {
									$( '.edit-css-mode' ).show();
									$( 'input[name=add_to_existing_display][value=' + $( '#add_to_existing' ).val() + ']' ).attr( 'checked', true );
								} );
							} );

							$( '.save-css-mode' ).bind( 'click', function ( e ) {
								e.preventDefault();

								$( '#css-mode-select' ).slideUp();
								$( '#css-mode-display' ).text( $( 'input[name=add_to_existing_display]:checked' ).val() == 'true' ? 'Add-on' : 'Replacement' );
								$( '#add_to_existing' ).val( $( 'input[name=add_to_existing_display]:checked' ).val() );
								$( '.edit-css-mode' ).show();
							} );
						} );
					</script>
				</div>
				<?php 
        do_action('custom_css_submitbox_misc_actions');
        ?>
			</div>
		</div>
		<div id="major-publishing-actions">
			<input type="button" class="button" id="preview" name="preview" value="<?php 
        esc_attr_e('Preview', 'jetpack');
        ?>
" />
			<div id="publishing-action">
				<input type="submit" class="button-primary" id="save" name="save" value="<?php 
        Jetpack_Custom_CSS::is_freetrial() ? esc_attr_e('Save &amp; Buy Upgrade', 'jetpack') : esc_attr_e('Save Stylesheet', 'jetpack');
        ?>
" />
			</div>
		</div>
		<?php 
    }