PHP Class Jetpack_Custom_CSS_Enhancements, vip-mu-plugins-public

Exibir arquivo Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Public Methods

Method Description
_wp_post_revision_fields ( array $fields, array $post ) : array Shows Preprocessor code in the Revisions screen, and ensures that post_content_filtered is maintained on revisions
add_hooks ( ) Set up the actions and filters needed for our compatability layer on top of core's Custom CSS implementation.
admin_menu ( ) Handle our admin menu item and legacy page declaration.
admin_page ( ) Admin page!
are_there_css_revisions ( string $stylesheet = '' ) : boolean | null | WP_Post Check whether there are CSS Revisions for a given theme.
customize_controls_enqueue_scripts ( ) Handle the enqueueing and localizing for scripts to be used in the Customizer.
customize_preview_init ( ) Things that we do on init when the Customize Preview is loading.
customize_preview_wp_get_custom_css ( string $css ) : mixed Output the custom css for customize preview.
customize_register ( WP_Customize_Manager $wp_customize ) Add Custom CSS section and controls.
customize_update_custom_css_post_content_args ( array $args, string $css, WP_Customize_Custom_CSS_Setting $setting ) : mixed Store the original pre-processed CSS in post_content_filtered and then store processed CSS in post_content.
customize_value_custom_css ( mixed $css, WP_Customize_Setting $setting ) : string Add CSS preprocessing to our CSS if it is supported.
customizer_link ( array $args = [] ) : string Build the URL to deep link to the Customizer.
customizer_redirect ( ) Handle the redirect for the customizer. This is necessary because we can't directly add customizer links to the admin menu.
echo_custom_css_partial ( ) Partial for use in the Customizer.
editor_max_image_size ( array $dims, string $size = 'medium', null $context = null ) : array When on the edit screen, make sure the custom content width setting is applied to the large image size.
get_all_themes_with_custom_css ( ) : array When we need to get all themes that have Custom CSS saved.
get_css_post ( string $stylesheet = '' ) : WP_Post | null Get the published custom CSS post.
get_revisions_url ( string $stylesheet = '' ) : null | string | void Core doesn't have a function to get the revisions url for a given post ID.
get_themes ( ) : array Get a map of all theme names and theme stylesheets for mapping stuff.
init ( ) Things that we do on init.
intval_base10 ( mixed $value ) : integer Get the base10 intval.
is_freetrial ( ) : boolean Flesh out for wpcom.
is_preview ( ) : boolean Flesh out for wpcom.
jetpack_content_width ( integer $content_width ) : integer Override the content_width with a custom value if one is set.
load_revision_php ( ) Add a footer action on revision.php to print some customizations for the theme switcher.
map_meta_cap ( array $caps, string $cap ) : array Re-map the Edit CSS capability.
post_id ( string $stylesheet = '' ) : integer Get the ID of a Custom CSS post tying to a given stylesheet.
preview_content_width ( ) Override $content_width in customizer previews.
preview_skip_stylesheet ( boolean $skip_value ) : null | boolean Override $content_width in customizer previews.
revision_admin_footer ( ) Print the theme switcher on revision.php and move it into place.
revisions_switcher_box ( string $stylesheet = '' ) The HTML for the theme revision switcher box.
sanitize_css ( string $css, array $args = [] ) : mixed | string Sanitize the CSS for users without unfiltered_html.
sanitize_css_callback ( mixed $css, WP_Customize_Setting $setting ) : mixed | string The callback to handle sanitizing the CSS. Takes different arguments, hence the proxy function.
sanitize_preprocessor ( string $preprocessor ) : null | string Make sure the preprocessor we're saving is one we know about.
set_content_width ( ) Currently this filter function gets called on 'template_redirect' action and 'admin_init' action
skip_stylesheet ( ) : mixed Determine whether or not we should have the theme skip its main stylesheet.
style_filter ( string $current ) : mixed | void Filter the current theme's stylesheet for potentially nullifying it.
update_custom_css_data ( array $args, string $stylesheet ) : mixed Filter to handle the processing of preprocessed css on save.
wp_enqueue_scripts ( ) Handle the enqueueing of scripts for customize previews.

Method Details

_wp_post_revision_fields() public static method

Shows Preprocessor code in the Revisions screen, and ensures that post_content_filtered is maintained on revisions
public static _wp_post_revision_fields ( array $fields, array $post ) : array
$fields array Post fields pertinent to revisions.
$post array A post array being processed for insertion as a post revision.
return array $fields Modified array to include post_content_filtered.

add_hooks() public static method

Set up the actions and filters needed for our compatability layer on top of core's Custom CSS implementation.
public static add_hooks ( )

admin_menu() public static method

Handle our admin menu item and legacy page declaration.
public static admin_menu ( )

admin_page() public static method

This currently has two main uses -- firstly to display the css for an inactive theme if there are no revisions attached it to a legacy bug, and secondly to handle folks that have bookmarkes in their browser going to the old page for managing Custom CSS in Jetpack. If we ever add back in a non-Customizer CSS editor, this would be the place.
public static admin_page ( )

are_there_css_revisions() public static method

Going forward, there should always be, but this was necessitated early on by https://core.trac.wordpress.org/ticket/30854
public static are_there_css_revisions ( string $stylesheet = '' ) : boolean | null | WP_Post
$stylesheet string Stylesheet name.
return boolean | null | WP_Post

customize_controls_enqueue_scripts() public static method

Handle the enqueueing and localizing for scripts to be used in the Customizer.

customize_preview_init() public static method

Things that we do on init when the Customize Preview is loading.
public static customize_preview_init ( )

customize_preview_wp_get_custom_css() public static method

Output the custom css for customize preview.
public static customize_preview_wp_get_custom_css ( string $css ) : mixed
$css string Custom CSS content.
return mixed

customize_register() public static method

Add Custom CSS section and controls.
public static customize_register ( WP_Customize_Manager $wp_customize )
$wp_customize WP_Customize_Manager WP_Customize_Manager instance.

customize_update_custom_css_post_content_args() public static method

Store the original pre-processed CSS in post_content_filtered and then store processed CSS in post_content.
public static customize_update_custom_css_post_content_args ( array $args, string $css, WP_Customize_Custom_CSS_Setting $setting ) : mixed
$args array Content post args.
$css string Original CSS being updated.
$setting WP_Customize_Custom_CSS_Setting Custom CSS Setting.
return mixed

customize_value_custom_css() public static method

Add CSS preprocessing to our CSS if it is supported.
public static customize_value_custom_css ( mixed $css, WP_Customize_Setting $setting ) : string
$css mixed Value of the setting.
$setting WP_Customize_Setting WP_Customize_Setting instance.
return string

customizer_redirect() public static method

There is a core patch in trac that would make this unnecessary.
public static customizer_redirect ( )

echo_custom_css_partial() public static method

Partial for use in the Customizer.
public static echo_custom_css_partial ( )

editor_max_image_size() static public method

When on the edit screen, make sure the custom content width setting is applied to the large image size.
static public editor_max_image_size ( array $dims, string $size = 'medium', null $context = null ) : array
$dims array Array of image dimensions (width and height).
$size string Size of the resulting image.
$context null Context the image is being resized for. `edit` or `display`.
return array

get_all_themes_with_custom_css() public static method

When we need to get all themes that have Custom CSS saved.
public static get_all_themes_with_custom_css ( ) : array
return array

get_css_post() public static method

Get the published custom CSS post.
public static get_css_post ( string $stylesheet = '' ) : WP_Post | null
$stylesheet string Optional. A theme object stylesheet name. Defaults to the current theme.
return WP_Post | null

get_revisions_url() public static method

Core doesn't have a function to get the revisions url for a given post ID.
public static get_revisions_url ( string $stylesheet = '' ) : null | string | void
$stylesheet string Stylesheet name.
return null | string | void

get_themes() public static method

Get a map of all theme names and theme stylesheets for mapping stuff.
public static get_themes ( ) : array
return array

init() public static method

Things that we do on init.
public static init ( )

intval_base10() public static method

This is used as a setting's sanitize_callback; we can't use just plain intval because the second argument is not what intval() expects.
public static intval_base10 ( mixed $value ) : integer
$value mixed Number to convert.
return integer Integer.

is_freetrial() public static method

Flesh out for wpcom.
public static is_freetrial ( ) : boolean
return boolean

is_preview() public static method

Flesh out for wpcom.
public static is_preview ( ) : boolean
return boolean

jetpack_content_width() static public method

Override the content_width with a custom value if one is set.
static public jetpack_content_width ( integer $content_width ) : integer
$content_width integer Content Width value to be updated.
return integer

load_revision_php() public static method

Add a footer action on revision.php to print some customizations for the theme switcher.
public static load_revision_php ( )

map_meta_cap() public static method

Core, by default, restricts this to users that have unfiltered_html which would make the feature unusable in multi-site by non-super-admins, due to Core not shipping any solid sanitization. We're expanding who can use it, and then conditionally applying CSSTidy sanitization to users that do not have the unfiltered_html capability.
public static map_meta_cap ( array $caps, string $cap ) : array
$caps array Returns the user's actual capabilities.
$cap string Capability name.
return array $caps

post_id() public static method

Get the ID of a Custom CSS post tying to a given stylesheet.
public static post_id ( string $stylesheet = '' ) : integer
$stylesheet string Stylesheet name.
return integer $post_id Post ID.

preview_content_width() public static method

Override $content_width in customizer previews.
public static preview_content_width ( )

preview_skip_stylesheet() public static method

Runs on safecss_skip_stylesheet filter.
public static preview_skip_stylesheet ( boolean $skip_value ) : null | boolean
$skip_value boolean Should the stylesheet be skipped.
return null | boolean

revisions_switcher_box() public static method

The HTML for the theme revision switcher box.
public static revisions_switcher_box ( string $stylesheet = '' )
$stylesheet string Stylesheet name.

sanitize_css() public static method

Sanitize the CSS for users without unfiltered_html.
public static sanitize_css ( string $css, array $args = [] ) : mixed | string
$css string Input CSS.
$args array Array of CSS options.
return mixed | string

sanitize_css_callback() public static method

The callback to handle sanitizing the CSS. Takes different arguments, hence the proxy function.
public static sanitize_css_callback ( mixed $css, WP_Customize_Setting $setting ) : mixed | string
$css mixed Value of the setting.
$setting WP_Customize_Setting WP_Customize_Setting instance.
return mixed | string

sanitize_preprocessor() public static method

Make sure the preprocessor we're saving is one we know about.
public static sanitize_preprocessor ( string $preprocessor ) : null | string
$preprocessor string The preprocessor to sanitize.
return null | string

set_content_width() static public method

Currently this filter function gets called on 'template_redirect' action and 'admin_init' action
static public set_content_width ( )

skip_stylesheet() static public method

Determine whether or not we should have the theme skip its main stylesheet.
static public skip_stylesheet ( ) : mixed
return mixed The truthiness of this value determines whether the stylesheet should be skipped.

style_filter() static public method

Filter the current theme's stylesheet for potentially nullifying it.
static public style_filter ( string $current ) : mixed | void
$current string Stylesheet URI for the current theme/child theme.
return mixed | void

update_custom_css_data() public static method

Filter to handle the processing of preprocessed css on save.
public static update_custom_css_data ( array $args, string $stylesheet ) : mixed
$args array Custom CSS options.
$stylesheet string Original CSS to be updated.
return mixed

wp_enqueue_scripts() public static method

Handle the enqueueing of scripts for customize previews.
public static wp_enqueue_scripts ( )