Version Description
- Incorporate Global Styles plugin functionality.
- Side-load images on template insertion.
- Remove widgets menu from wp-admin.
Download this release
Release Info
Developer | nosolosw |
Plugin | Full Site Editing |
Version | 0.13 |
Comparing to | |
See all releases |
Code changes from version 0.11 to 0.13
- full-site-editing-plugin.php +20 -2
- full-site-editing/blocks/navigation-menu/edit.js +5 -3
- full-site-editing/blocks/navigation-menu/index.php +3 -3
- full-site-editing/blocks/post-content/edit.js +2 -1
- full-site-editing/blocks/post-content/save.js +1 -1
- full-site-editing/blocks/site-description/edit.js +7 -5
- full-site-editing/blocks/site-title/edit.js +6 -4
- full-site-editing/blocks/template/edit.js +2 -2
- full-site-editing/class-full-site-editing.php +28 -6
- full-site-editing/dist/full-site-editing.asset.php +1 -0
- full-site-editing/dist/full-site-editing.deps.json +0 -1
- full-site-editing/dist/full-site-editing.js +2 -8
- full-site-editing/editor/block-inserter/post-content-block-appender.js +3 -2
- full-site-editing/editor/template-validity-override/index.js +2 -2
- full-site-editing/templates/class-template-image-inserter.php +174 -0
- full-site-editing/templates/class-wp-template-inserter.php +28 -0
- global-styles/README-DATA.md +363 -0
- global-styles/README.md +230 -0
- global-styles/class-global-styles.php +511 -0
- global-styles/dist/global-styles.asset.php +1 -0
- global-styles/dist/global-styles.css +1 -0
- global-styles/dist/global-styles.js +6 -0
- global-styles/dist/global-styles.rtl.css +1 -0
- global-styles/editor.scss +2 -0
- global-styles/includes/class-data-point-literal.php +44 -0
- global-styles/includes/class-data-point-option.php +104 -0
- global-styles/includes/class-data-point-theme.php +92 -0
- global-styles/includes/class-data-set.php +167 -0
- global-styles/includes/class-json-endpoint.php +116 -0
- global-styles/includes/interface-data-point.php +17 -0
- global-styles/index.js +51 -0
- global-styles/src/constants.js +7 -0
- global-styles/src/dom-updater.js +36 -0
- global-styles/src/font-pairings-panel-previews.js +73 -0
- global-styles/src/font-pairings-panel.js +50 -0
- global-styles/src/font-pairings-panel.scss +48 -0
- global-styles/src/font-selection-panel.js +49 -0
- global-styles/src/global-styles-sidebar.js +144 -0
- global-styles/src/global-styles-sidebar.scss +22 -0
- global-styles/src/icon.js +12 -0
- global-styles/src/no-support.js +11 -0
- global-styles/src/store.js +122 -0
- global-styles/static/blank.css +6 -0
- global-styles/static/style.css +28 -0
- posts-list-block/blocks/posts-list/index.js +1 -1
- posts-list-block/class-posts-list-block.php +7 -11
- posts-list-block/dist/posts-list-block.asset.php +1 -0
- posts-list-block/dist/posts-list-block.deps.json +0 -1
- posts-list-block/dist/posts-list-block.js +1 -1
- readme.txt +11 -1
- starter-page-templates/dist/starter-page-templates.asset.php +1 -0
- starter-page-templates/dist/starter-page-templates.deps.json +0 -1
- starter-page-templates/dist/starter-page-templates.js +1 -7
full-site-editing-plugin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Full Site Editing
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
-
* Version: 0.
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
@@ -20,7 +20,7 @@ namespace A8C\FSE;
|
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
23 |
-
define( 'PLUGIN_VERSION', '0.
|
24 |
|
25 |
// Themes which are supported by Full Site Editing (not the same as the SPT themes).
|
26 |
const SUPPORTED_THEMES = [ 'maywood' ];
|
@@ -44,6 +44,7 @@ function load_full_site_editing() {
|
|
44 |
require_once __DIR__ . '/full-site-editing/templates/class-rest-templates-controller.php';
|
45 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template.php';
|
46 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template-inserter.php';
|
|
|
47 |
require_once __DIR__ . '/full-site-editing/serialize-block-fallback.php';
|
48 |
|
49 |
Full_Site_Editing::get_instance();
|
@@ -151,6 +152,12 @@ add_action( 'plugins_loaded', __NAMESPACE__ . '\load_posts_list_block' );
|
|
151 |
* Load Starter_Page_Templates.
|
152 |
*/
|
153 |
function load_starter_page_templates() {
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
/**
|
155 |
* Can be used to disable the Starter Page Templates.
|
156 |
*
|
@@ -168,6 +175,16 @@ function load_starter_page_templates() {
|
|
168 |
}
|
169 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_starter_page_templates' );
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
/**
|
172 |
* Inserts default full site editing data for current theme during plugin activation.
|
173 |
*
|
@@ -178,6 +195,7 @@ add_action( 'plugins_loaded', __NAMESPACE__ . '\load_starter_page_templates' );
|
|
178 |
*/
|
179 |
function populate_wp_template_data() {
|
180 |
require_once __DIR__ . '/full-site-editing/class-full-site-editing.php';
|
|
|
181 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template-inserter.php';
|
182 |
|
183 |
$fse = Full_Site_Editing::get_instance();
|
2 |
/**
|
3 |
* Plugin Name: Full Site Editing
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
+
* Version: 0.13
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
23 |
+
define( 'PLUGIN_VERSION', '0.13' );
|
24 |
|
25 |
// Themes which are supported by Full Site Editing (not the same as the SPT themes).
|
26 |
const SUPPORTED_THEMES = [ 'maywood' ];
|
44 |
require_once __DIR__ . '/full-site-editing/templates/class-rest-templates-controller.php';
|
45 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template.php';
|
46 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template-inserter.php';
|
47 |
+
require_once __DIR__ . '/full-site-editing/templates/class-template-image-inserter.php';
|
48 |
require_once __DIR__ . '/full-site-editing/serialize-block-fallback.php';
|
49 |
|
50 |
Full_Site_Editing::get_instance();
|
152 |
* Load Starter_Page_Templates.
|
153 |
*/
|
154 |
function load_starter_page_templates() {
|
155 |
+
// We don't want the user to choose a template when copying a post.
|
156 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
157 |
+
if ( isset( $_GET['jetpack-copy'] ) ) {
|
158 |
+
return;
|
159 |
+
}
|
160 |
+
|
161 |
/**
|
162 |
* Can be used to disable the Starter Page Templates.
|
163 |
*
|
175 |
}
|
176 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_starter_page_templates' );
|
177 |
|
178 |
+
/**
|
179 |
+
* Load Global Styles plugin.
|
180 |
+
*/
|
181 |
+
function load_global_styles() {
|
182 |
+
if ( is_site_eligible_for_full_site_editing() ) {
|
183 |
+
require_once __DIR__ . '/global-styles/class-global-styles.php';
|
184 |
+
}
|
185 |
+
}
|
186 |
+
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_global_styles' );
|
187 |
+
|
188 |
/**
|
189 |
* Inserts default full site editing data for current theme during plugin activation.
|
190 |
*
|
195 |
*/
|
196 |
function populate_wp_template_data() {
|
197 |
require_once __DIR__ . '/full-site-editing/class-full-site-editing.php';
|
198 |
+
require_once __DIR__ . '/full-site-editing/templates/class-template-image-inserter.php';
|
199 |
require_once __DIR__ . '/full-site-editing/templates/class-wp-template-inserter.php';
|
200 |
|
201 |
$fse = Full_Site_Editing::get_instance();
|
full-site-editing/blocks/navigation-menu/edit.js
CHANGED
@@ -33,7 +33,9 @@ const NavigationMenuEdit = ( {
|
|
33 |
setTextColor,
|
34 |
textColor,
|
35 |
} ) => {
|
36 |
-
const { textAlign } = attributes;
|
|
|
|
|
37 |
|
38 |
return (
|
39 |
<Fragment>
|
@@ -47,7 +49,7 @@ const NavigationMenuEdit = ( {
|
|
47 |
</BlockControls>
|
48 |
<InspectorControls>
|
49 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
50 |
-
<FontSizePicker onChange={ setFontSize } value={
|
51 |
</PanelBody>
|
52 |
<PanelColorSettings
|
53 |
title={ __( 'Color Settings' ) }
|
@@ -70,7 +72,7 @@ const NavigationMenuEdit = ( {
|
|
70 |
textColor: textColor.color,
|
71 |
backgroundColor: backgroundColor.color,
|
72 |
} }
|
73 |
-
fontSize={
|
74 |
/>
|
75 |
</PanelColorSettings>
|
76 |
</InspectorControls>
|
33 |
setTextColor,
|
34 |
textColor,
|
35 |
} ) => {
|
36 |
+
const { customFontSize, textAlign } = attributes;
|
37 |
+
|
38 |
+
const actualFontSize = customFontSize || fontSize.size;
|
39 |
|
40 |
return (
|
41 |
<Fragment>
|
49 |
</BlockControls>
|
50 |
<InspectorControls>
|
51 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
52 |
+
<FontSizePicker onChange={ setFontSize } value={ actualFontSize } />
|
53 |
</PanelBody>
|
54 |
<PanelColorSettings
|
55 |
title={ __( 'Color Settings' ) }
|
72 |
textColor: textColor.color,
|
73 |
backgroundColor: backgroundColor.color,
|
74 |
} }
|
75 |
+
fontSize={ actualFontSize }
|
76 |
/>
|
77 |
</PanelColorSettings>
|
78 |
</InspectorControls>
|
full-site-editing/blocks/navigation-menu/index.php
CHANGED
@@ -49,10 +49,10 @@ function render_navigation_menu_block( $attributes ) {
|
|
49 |
$styles .= ' background-color: ' . $attributes['customBackgroundColor'] . ';';
|
50 |
}
|
51 |
|
52 |
-
if ( isset( $attributes['
|
53 |
-
$class .= ' has-' . $attributes['fontSize'] . '-font-size';
|
54 |
-
} elseif ( isset( $attributes['customFontSize'] ) ) {
|
55 |
$styles .= ' font-size: ' . $attributes['customFontSize'] . 'px;';
|
|
|
|
|
56 |
} else {
|
57 |
$class .= ' has-small-font-size';
|
58 |
}
|
49 |
$styles .= ' background-color: ' . $attributes['customBackgroundColor'] . ';';
|
50 |
}
|
51 |
|
52 |
+
if ( isset( $attributes['customFontSize'] ) ) {
|
|
|
|
|
53 |
$styles .= ' font-size: ' . $attributes['customFontSize'] . 'px;';
|
54 |
+
} elseif ( isset( $attributes['fontSize'] ) ) {
|
55 |
+
$class .= ' has-' . $attributes['fontSize'] . '-font-size';
|
56 |
} else {
|
57 |
$class .= ' has-small-font-size';
|
58 |
}
|
full-site-editing/blocks/post-content/edit.js
CHANGED
@@ -10,7 +10,8 @@ import classNames from 'classnames';
|
|
10 |
*/
|
11 |
import { compose, withState } from '@wordpress/compose';
|
12 |
import { withSelect } from '@wordpress/data';
|
13 |
-
import {
|
|
|
14 |
import { Component, Fragment } from '@wordpress/element';
|
15 |
|
16 |
class PostContentEdit extends Component {
|
10 |
*/
|
11 |
import { compose, withState } from '@wordpress/compose';
|
12 |
import { withSelect } from '@wordpress/data';
|
13 |
+
import { PostTitle } from '@wordpress/editor';
|
14 |
+
import { InnerBlocks } from '@wordpress/block-editor';
|
15 |
import { Component, Fragment } from '@wordpress/element';
|
16 |
|
17 |
class PostContentEdit extends Component {
|
full-site-editing/blocks/post-content/save.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { InnerBlocks } from '@wordpress/editor';
|
5 |
|
6 |
export default () => <InnerBlocks.Content />;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { InnerBlocks } from '@wordpress/block-editor';
|
5 |
|
6 |
export default () => <InnerBlocks.Content />;
|
full-site-editing/blocks/site-description/edit.js
CHANGED
@@ -46,7 +46,9 @@ function SiteDescriptionEdit( {
|
|
46 |
shouldUpdateSiteOption,
|
47 |
textColor,
|
48 |
} ) {
|
49 |
-
const { textAlign } = attributes;
|
|
|
|
|
50 |
|
51 |
const inititalDescription = __( 'Site description loading…' );
|
52 |
|
@@ -73,7 +75,7 @@ function SiteDescriptionEdit( {
|
|
73 |
</BlockControls>
|
74 |
<InspectorControls>
|
75 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
76 |
-
<FontSizePicker onChange={ setFontSize } value={
|
77 |
</PanelBody>
|
78 |
<PanelColorSettings
|
79 |
title={ __( 'Color Settings' ) }
|
@@ -96,7 +98,7 @@ function SiteDescriptionEdit( {
|
|
96 |
textColor: textColor.color,
|
97 |
backgroundColor: backgroundColor.color,
|
98 |
} }
|
99 |
-
fontSize={
|
100 |
/>
|
101 |
</PanelColorSettings>
|
102 |
</InspectorControls>
|
@@ -109,7 +111,7 @@ function SiteDescriptionEdit( {
|
|
109 |
[ `has-text-align-${ textAlign }` ]: textAlign,
|
110 |
[ backgroundColor.class ]: backgroundColor.class,
|
111 |
[ textColor.class ]: textColor.class,
|
112 |
-
[ fontSize.class ]: fontSize.class,
|
113 |
} ) }
|
114 |
identifier="content"
|
115 |
onChange={ value => handleChange( value ) }
|
@@ -119,7 +121,7 @@ function SiteDescriptionEdit( {
|
|
119 |
style={ {
|
120 |
backgroundColor: backgroundColor.color,
|
121 |
color: textColor.color,
|
122 |
-
fontSize:
|
123 |
} }
|
124 |
tagName="p"
|
125 |
value={ option }
|
46 |
shouldUpdateSiteOption,
|
47 |
textColor,
|
48 |
} ) {
|
49 |
+
const { customFontSize, textAlign } = attributes;
|
50 |
+
|
51 |
+
const actualFontSize = customFontSize || fontSize.size;
|
52 |
|
53 |
const inititalDescription = __( 'Site description loading…' );
|
54 |
|
75 |
</BlockControls>
|
76 |
<InspectorControls>
|
77 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
78 |
+
<FontSizePicker onChange={ setFontSize } value={ actualFontSize } />
|
79 |
</PanelBody>
|
80 |
<PanelColorSettings
|
81 |
title={ __( 'Color Settings' ) }
|
98 |
textColor: textColor.color,
|
99 |
backgroundColor: backgroundColor.color,
|
100 |
} }
|
101 |
+
fontSize={ actualFontSize }
|
102 |
/>
|
103 |
</PanelColorSettings>
|
104 |
</InspectorControls>
|
111 |
[ `has-text-align-${ textAlign }` ]: textAlign,
|
112 |
[ backgroundColor.class ]: backgroundColor.class,
|
113 |
[ textColor.class ]: textColor.class,
|
114 |
+
[ fontSize.class ]: ! customFontSize && fontSize.class,
|
115 |
} ) }
|
116 |
identifier="content"
|
117 |
onChange={ value => handleChange( value ) }
|
121 |
style={ {
|
122 |
backgroundColor: backgroundColor.color,
|
123 |
color: textColor.color,
|
124 |
+
fontSize: actualFontSize ? actualFontSize + 'px' : undefined,
|
125 |
} }
|
126 |
tagName="p"
|
127 |
value={ option }
|
full-site-editing/blocks/site-title/edit.js
CHANGED
@@ -43,7 +43,9 @@ function SiteTitleEdit( {
|
|
43 |
shouldUpdateSiteOption,
|
44 |
textColor,
|
45 |
} ) {
|
46 |
-
const { textAlign } = attributes;
|
|
|
|
|
47 |
|
48 |
const inititalTitle = __( 'Site title loading…' );
|
49 |
|
@@ -70,7 +72,7 @@ function SiteTitleEdit( {
|
|
70 |
</BlockControls>
|
71 |
<InspectorControls>
|
72 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
73 |
-
<FontSizePicker onChange={ setFontSize } value={
|
74 |
</PanelBody>
|
75 |
<PanelColorSettings
|
76 |
title={ __( 'Color Settings' ) }
|
@@ -91,7 +93,7 @@ function SiteTitleEdit( {
|
|
91 |
'has-text-color': textColor.color,
|
92 |
[ `has-text-align-${ textAlign }` ]: textAlign,
|
93 |
[ textColor.class ]: textColor.class,
|
94 |
-
[ fontSize.class ]: fontSize.class,
|
95 |
} ) }
|
96 |
identifier="content"
|
97 |
onChange={ value => handleChange( value ) }
|
@@ -100,7 +102,7 @@ function SiteTitleEdit( {
|
|
100 |
placeholder={ __( 'Add a Site Title' ) }
|
101 |
style={ {
|
102 |
color: textColor.color,
|
103 |
-
fontSize:
|
104 |
} }
|
105 |
tagName="h1"
|
106 |
value={ option }
|
43 |
shouldUpdateSiteOption,
|
44 |
textColor,
|
45 |
} ) {
|
46 |
+
const { customFontSize, textAlign } = attributes;
|
47 |
+
|
48 |
+
const actualFontSize = customFontSize || fontSize.size;
|
49 |
|
50 |
const inititalTitle = __( 'Site title loading…' );
|
51 |
|
72 |
</BlockControls>
|
73 |
<InspectorControls>
|
74 |
<PanelBody className="blocks-font-size" title={ __( 'Text Settings' ) }>
|
75 |
+
<FontSizePicker onChange={ setFontSize } value={ actualFontSize } />
|
76 |
</PanelBody>
|
77 |
<PanelColorSettings
|
78 |
title={ __( 'Color Settings' ) }
|
93 |
'has-text-color': textColor.color,
|
94 |
[ `has-text-align-${ textAlign }` ]: textAlign,
|
95 |
[ textColor.class ]: textColor.class,
|
96 |
+
[ fontSize.class ]: ! customFontSize && fontSize.class,
|
97 |
} ) }
|
98 |
identifier="content"
|
99 |
onChange={ value => handleChange( value ) }
|
102 |
placeholder={ __( 'Add a Site Title' ) }
|
103 |
style={ {
|
104 |
color: textColor.color,
|
105 |
+
fontSize: actualFontSize ? actualFontSize + 'px' : undefined,
|
106 |
} }
|
107 |
tagName="h1"
|
108 |
value={ option }
|
full-site-editing/blocks/template/edit.js
CHANGED
@@ -11,7 +11,7 @@ import { get, noop } from 'lodash';
|
|
11 |
* WordPress dependencies
|
12 |
*/
|
13 |
import { parse, createBlock } from '@wordpress/blocks';
|
14 |
-
import { BlockEdit } from '@wordpress/editor';
|
15 |
import { Button, Placeholder, Spinner, Disabled } from '@wordpress/components';
|
16 |
import { compose, withState } from '@wordpress/compose';
|
17 |
import { withDispatch, withSelect } from '@wordpress/data';
|
@@ -172,7 +172,7 @@ const TemplateEdit = compose(
|
|
172 |
<Placeholder className="template-block__overlay">
|
173 |
{ navigateToTemplate && (
|
174 |
<div className="template-block__loading">
|
175 |
-
<Spinner /> { sprintf( __( 'Loading %s
|
176 |
</div>
|
177 |
) }
|
178 |
<Button
|
11 |
* WordPress dependencies
|
12 |
*/
|
13 |
import { parse, createBlock } from '@wordpress/blocks';
|
14 |
+
import { BlockEdit } from '@wordpress/block-editor';
|
15 |
import { Button, Placeholder, Spinner, Disabled } from '@wordpress/components';
|
16 |
import { compose, withState } from '@wordpress/compose';
|
17 |
import { withDispatch, withSelect } from '@wordpress/data';
|
172 |
<Placeholder className="template-block__overlay">
|
173 |
{ navigateToTemplate && (
|
174 |
<div className="template-block__loading">
|
175 |
+
<Spinner /> { sprintf( __( 'Loading editor for: %s' ), templateTitle ) }
|
176 |
</div>
|
177 |
) }
|
178 |
<Button
|
full-site-editing/class-full-site-editing.php
CHANGED
@@ -61,6 +61,7 @@ class Full_Site_Editing {
|
|
61 |
add_filter( 'bulk_actions-edit-wp_template_type', [ $this, 'remove_delete_bulk_action_for_template_taxonomy' ] );
|
62 |
add_action( 'pre_delete_term', [ $this, 'restrict_template_taxonomy_deletion' ], 10, 2 );
|
63 |
add_action( 'transition_post_status', [ $this, 'restrict_template_drafting' ], 10, 3 );
|
|
|
64 |
|
65 |
$this->theme_slug = $this->normalize_theme_slug( get_stylesheet() );
|
66 |
$this->wp_template_inserter = new WP_Template_Inserter( $this->theme_slug );
|
@@ -153,12 +154,8 @@ class Full_Site_Editing {
|
|
153 |
* Enqueue assets.
|
154 |
*/
|
155 |
public function enqueue_script_and_style() {
|
156 |
-
$
|
157 |
-
|
158 |
-
plugin_dir_path( __FILE__ ) . 'dist/full-site-editing.deps.json'
|
159 |
-
),
|
160 |
-
true
|
161 |
-
);
|
162 |
wp_enqueue_script(
|
163 |
'a8c-full-site-editing-script',
|
164 |
plugins_url( 'dist/full-site-editing.js', __FILE__ ),
|
@@ -611,4 +608,29 @@ class Full_Site_Editing {
|
|
611 |
wp_die( esc_html__( 'Template Types cannon be deleted.' ) );
|
612 |
}
|
613 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
}
|
61 |
add_filter( 'bulk_actions-edit-wp_template_type', [ $this, 'remove_delete_bulk_action_for_template_taxonomy' ] );
|
62 |
add_action( 'pre_delete_term', [ $this, 'restrict_template_taxonomy_deletion' ], 10, 2 );
|
63 |
add_action( 'transition_post_status', [ $this, 'restrict_template_drafting' ], 10, 3 );
|
64 |
+
add_action( 'admin_menu', [ $this, 'remove_wp_admin_menu_items' ] );
|
65 |
|
66 |
$this->theme_slug = $this->normalize_theme_slug( get_stylesheet() );
|
67 |
$this->wp_template_inserter = new WP_Template_Inserter( $this->theme_slug );
|
154 |
* Enqueue assets.
|
155 |
*/
|
156 |
public function enqueue_script_and_style() {
|
157 |
+
$asset_file = include plugin_dir_path( __FILE__ ) . 'dist/full-site-editing.asset.php';
|
158 |
+
$script_dependencies = $asset_file['dependencies'];
|
|
|
|
|
|
|
|
|
159 |
wp_enqueue_script(
|
160 |
'a8c-full-site-editing-script',
|
161 |
plugins_url( 'dist/full-site-editing.js', __FILE__ ),
|
608 |
wp_die( esc_html__( 'Template Types cannon be deleted.' ) );
|
609 |
}
|
610 |
}
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Removes wp admin menu items we don't want like Customize and Widgets.
|
614 |
+
*/
|
615 |
+
public function remove_wp_admin_menu_items() {
|
616 |
+
global $submenu;
|
617 |
+
|
618 |
+
// For safety.
|
619 |
+
if ( ! \A8C\FSE\is_full_site_editing_active() ) {
|
620 |
+
return;
|
621 |
+
}
|
622 |
+
|
623 |
+
// Remove widget submenu.
|
624 |
+
remove_submenu_page( 'themes.php', 'widgets.php' );
|
625 |
+
|
626 |
+
/*
|
627 |
+
* This position is hardcoded in `wp-admin/menu.php` and we can't use `remove_submenu_page`
|
628 |
+
* because the customize URL varies depending on the current screen.
|
629 |
+
*
|
630 |
+
* We also want to access the customizer through the URL, so we shouldn't deny URL access.
|
631 |
+
*/
|
632 |
+
if ( isset( $submenu['themes.php'][6] ) ) {
|
633 |
+
unset( $submenu['themes.php'][6] );
|
634 |
+
}
|
635 |
+
}
|
636 |
}
|
full-site-editing/dist/full-site-editing.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-server-side-render', 'wp-url'), 'version' => '1ecf08ae71136d4a3598c69840c29f72');
|
full-site-editing/dist/full-site-editing.deps.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
["lodash","wp-api-fetch","wp-block-editor","wp-blocks","wp-components","wp-compose","wp-data","wp-dom-ready","wp-editor","wp-element","wp-hooks","wp-html-entities","wp-i18n","wp-plugins","wp-polyfill","wp-server-side-render","wp-url"]
|
|
full-site-editing/dist/full-site-editing.js
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
-
!function(t,e){for(var n in e)t[n]=e[n]}(window,function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=42)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e){!function(){t.exports=this.wp.
|
2 |
/*!
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
-
*/
|
7 |
-
/*!
|
8 |
-
Copyright (c) 2017 Jed Watson.
|
9 |
-
Licensed under the MIT License (MIT), see
|
10 |
-
http://jedwatson.github.io/classnames
|
11 |
-
*/
|
12 |
-
!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var t=[],e=0;e<arguments.length;e++){var o=arguments[e];if(o){var i=typeof o;if("string"===i||"number"===i)t.push(o);else if(Array.isArray(o)&&o.length){var c=r.apply(null,o);c&&t.push(c)}else if("object"===i)for(var l in o)n.call(o,l)&&o[l]&&t.push(l)}}return t.join(" ")}t.exports?(r.default=r,t.exports=r):void 0===(o=function(){return r}.apply(e,[]))||(t.exports=o)}()},function(t,e){!function(){t.exports=this.wp.editor}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e,n){var o=n(33),r=n(34),i=n(35);t.exports=function(t,e){return o(t)||r(t,e)||i()}},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.htmlEntities}()},function(t,e,n){},function(t,e){!function(){t.exports=this.wp.serverSideRender}()},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}t.exports=function(t,e,o){return e&&n(t.prototype,e),o&&n(t,o),t}},function(t,e,n){var o=n(29),r=n(30);t.exports=function(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?r(t):e}},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var o=n(31);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}},function(t,e){!function(){t.exports=this.wp.url}()},function(t,e,n){var o=n(38),r=n(39),i=n(40);t.exports=function(t){return o(t)||r(t)||i()}},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e,n){},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=o=function(t){return n(t)}:t.exports=o=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},o(e)}t.exports=o},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function n(e,o){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,o)}t.exports=n},function(t,e,n){},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],o=!0,r=!1,i=void 0;try{for(var c,l=t[Symbol.iterator]();!(o=(c=l.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(a){r=!0,i=a}finally{try{o||null==l.return||l.return()}finally{if(r)throw i}}return n}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){},function(t,e,n){},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,n){},function(t,e,n){"use strict";n.r(e);var o=n(0),r=n(7),i=n(1),c=n(10),l=n.n(c),a=n(19),s=n.n(a),u=n(4),p=n(3),d=n(8),f=Object(u.compose)([Object(p.withColors)("backgroundColor",{textColor:"color"}),Object(p.withFontSizes)("fontSize")])(function(t){var e=t.attributes,n=t.backgroundColor,r=t.fontSize,c=t.setAttributes,a=t.setBackgroundColor,u=t.setFontSize,f=t.setTextColor,b=t.textColor,m=e.textAlign;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:m,onChange:function(t){c({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:u,value:r.size})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:n.color,onChange:a,label:Object(i.__)("Background Color")},{value:b.color,onChange:f,label:Object(i.__)("Text Color")}]},Object(o.createElement)(p.ContrastChecker,l()({textColor:b.color,backgroundColor:n.color},{fontSize:r.size})))),Object(o.createElement)(s.a,{block:"a8c/navigation-menu",attributes:e}))}),b=(n(28),Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M12 7.27l4.28 10.43-3.47-1.53-.81-.36-.81.36-3.47 1.53L12 7.27M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71L12 2z"})));Object(r.registerBlockType)("a8c/navigation-menu",{title:Object(i.__)("Navigation Menu"),description:Object(i.__)("Visual placeholder for site-wide navigation and menus."),icon:b,category:"layout",supports:{align:["wide","full"],html:!1,reusable:!1},edit:f,save:function(){return null}});var m=n(13),g=n(5),O=n.n(g),j=n(20),h=n.n(j),v=n(21),y=n.n(v),S=n(22),_=n.n(S),E=n(23),k=n.n(E),w=n(24),C=n.n(w),x=n(11),P=n.n(x),T=n(2),B=n(12),I=function(t){function e(){return h()(this,e),_()(this,k()(e).apply(this,arguments))}return C()(e,t),y()(e,[{key:"toggleEditing",value:function(){var t=this.props,e=t.isEditing;(0,t.setState)({isEditing:!e})}},{key:"onSelectPost",value:function(t){var e=t.id,n=t.type;this.props.setState({isEditing:!1,selectedPostId:e,selectedPostType:n})}},{key:"render",value:function(){var t=this.props.attributes.align;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("div",{className:P()("post-content-block",O()({},"align".concat(t),t))},Object(o.createElement)(B.PostTitle,null),Object(o.createElement)(B.InnerBlocks,{templateLock:!1})))}}]),e}(o.Component),z=Object(u.compose)([Object(u.withState)({isEditing:!1,selectedPostId:void 0,selectedPostType:void 0}),Object(T.withSelect)(function(t,e){var n=e.selectedPostId,o=e.selectedPostType;return{selectedPost:(0,t("core").getEntityRecord)("postType",o,n)}})])(I);n(32);Object(r.registerBlockType)("a8c/post-content",{title:Object(i.__)("Content"),description:Object(i.__)("The page content."),icon:"layout",category:"layout",supports:{align:["full"],anchor:!1,customClassName:!1,html:!1,inserter:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"full"}},edit:z,save:function(){return Object(o.createElement)(B.InnerBlocks.Content,null)}});var A=Object(u.createHigherOrderComponent)(function(t){return function(e){return"a8c/post-content"!==e.name?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"post-content__block"}))}},"addContentSlotClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/post-content",A,9);var N=n(6),D=n(9),F=n.n(D),L=n(15),R=n.n(L),M=n(16),U=n.n(M),H=n(17);function q(t){var e=Object(o.useRef)();return Object(o.useEffect)(function(){e.current=t},[t]),e.current}function V(t,e,n,r,c,l){var a=Object(o.useState)({option:e,previousOption:"",loaded:!1,error:!1}),s=R()(a,2),u=s[0],p=s[1],d=q(r),f=q(c);function b(){p(F()({},u,{option:u.previousOption,isSaving:!1}))}return Object(o.useEffect)(function(){u.loaded||u.error?function(){var e=u.option,o=u.previousOption,l=e&&e.trim()===o.trim(),a=!e||0===e.trim().length;!r&&d&&a&&b();if(!c||l)return;!f&&c&&function(e){p(F()({},u,{isSaving:!0})),U()({path:"/wp/v2/settings",method:"POST",data:O()({},t,e)}).then(function(){return function(t){p(F()({},u,{previousOption:t,isDirty:!1,isSaving:!1}))}(e)}).catch(function(){n(Object(i.sprintf)(Object(i.__)("Unable to save site %s"),t)),b()})}(e)}():U()({path:"/wp/v2/settings"}).then(function(e){return p(F()({},u,{option:Object(H.decodeEntities)(e[t]),previousOption:Object(H.decodeEntities)(e[t]),loaded:!0,error:!1}))}).catch(function(){n(Object(i.sprintf)(Object(i.__)("Unable to load site %s"),t)),p(F()({},u,{option:Object(i.sprintf)(Object(i.__)("Error loading site %s"),t),error:!0}))})}),{siteOptions:u,handleChange:function(t){l({updated:Date.now()}),p(F()({},u,{option:t}))}}}var G=Object(u.compose)([Object(p.withColors)("backgroundColor",{textColor:"color"}),Object(p.withFontSizes)("fontSize"),Object(T.withSelect)(function(t,e){var n=e.clientId,o=t("core/editor"),r=o.isSavingPost,i=o.isPublishingPost,c=o.isAutosavingPost,l=o.isCurrentPostPublished,a=t("core/block-editor"),s=a.getBlockIndex,u=a.getBlockRootClientId,p=a.getTemplateLock,d=u(n);return{blockIndex:s(n,d),isLocked:!!p(d),rootClientId:d,shouldUpdateSiteOption:(r()&&l()||i())&&!c()}}),Object(T.withDispatch)(function(t,e){var n=e.blockIndex,o=e.rootClientId;return{createErrorNotice:t("core/notices").createErrorNotice,insertDefaultBlock:function(){return t("core/block-editor").insertDefaultBlock({},o,n+1)}}})])(function(t){var e,n=t.attributes,r=t.backgroundColor,c=t.className,a=t.createErrorNotice,s=t.fontSize,u=t.insertDefaultBlock,f=t.isSelected,b=t.setAttributes,m=t.setBackgroundColor,g=t.setFontSize,j=t.setTextColor,h=t.shouldUpdateSiteOption,v=t.textColor,y=n.textAlign,S=V("description",Object(i.__)("Site description loading…"),a,f,h,b),_=S.siteOptions,E=S.handleChange,k=_.option;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:y,onChange:function(t){b({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:g,value:s.size})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:r.color,onChange:m,label:Object(i.__)("Background Color")},{value:v.color,onChange:j,label:Object(i.__)("Text Color")}]},Object(o.createElement)(p.ContrastChecker,l()({textColor:v.color,backgroundColor:r.color},{fontSize:s.size})))),Object(o.createElement)(p.RichText,{allowedFormats:[],"aria-label":Object(i.__)("Site Description"),className:P()("site-description",c,(e={"has-text-color":v.color,"has-background":r.color},O()(e,"has-text-align-".concat(y),y),O()(e,r.class,r.class),O()(e,v.class,v.class),O()(e,s.class,s.class),e)),identifier:"content",onChange:function(t){return E(t)},onReplace:u,onSplit:N.noop,placeholder:Object(i.__)("Add a Site Description"),style:{backgroundColor:r.color,color:v.color,fontSize:s.size?s.size+"px":void 0},tagName:"p",value:k}))});n(36);Object(r.registerBlockType)("a8c/site-description",{title:Object(i.__)("Site Description"),description:Object(i.__)("Site description, also known as the tagline."),icon:Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(o.createElement)("path",{d:"M4 9h16v2H4V9zm0 4h10v2H4v-2z"})),category:"layout",supports:{align:["wide","full"],html:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"wide"},textAlign:{type:"string",default:"center"},textColor:{type:"string"},customTextColor:{type:"string"},backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},fontSize:{type:"string",default:"small"},customFontSize:{type:"number"}},edit:G,save:function(){return null}});var W=Object(u.compose)([Object(p.withColors)({textColor:"color"}),Object(p.withFontSizes)("fontSize"),Object(T.withSelect)(function(t,e){var n=e.clientId,o=t("core/editor"),r=o.isSavingPost,i=o.isPublishingPost,c=o.isAutosavingPost,l=o.isCurrentPostPublished,a=t("core/block-editor"),s=a.getBlockIndex,u=a.getBlockRootClientId,p=a.getTemplateLock,d=u(n);return{blockIndex:s(n,d),isLocked:!!p(d),rootClientId:d,shouldUpdateSiteOption:(r()&&l()||i())&&!c()}}),Object(T.withDispatch)(function(t,e){var n=e.blockIndex,o=e.rootClientId;return{createErrorNotice:t("core/notices").createErrorNotice,insertDefaultBlock:function(){return t("core/block-editor").insertDefaultBlock({},o,n+1)}}})])(function(t){var e,n=t.attributes,r=t.className,c=t.createErrorNotice,l=t.fontSize,a=t.insertDefaultBlock,s=t.isSelected,u=t.setAttributes,f=t.setFontSize,b=t.setTextColor,m=t.shouldUpdateSiteOption,g=t.textColor,j=n.textAlign,h=V("title",Object(i.__)("Site title loading…"),c,s,m,u),v=h.siteOptions,y=h.handleChange,S=v.option;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:j,onChange:function(t){u({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:f,value:l.size})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:g.color,onChange:b,label:Object(i.__)("Text Color")}]})),Object(o.createElement)(p.RichText,{allowedFormats:[],"aria-label":Object(i.__)("Site Title"),className:P()("site-title",r,(e={"has-text-color":g.color},O()(e,"has-text-align-".concat(j),j),O()(e,g.class,g.class),O()(e,l.class,l.class),e)),identifier:"content",onChange:function(t){return y(t)},onReplace:a,onSplit:N.noop,placeholder:Object(i.__)("Add a Site Title"),style:{color:g.color,fontSize:l.size?l.size+"px":void 0},tagName:"h1",value:S}))});n(37);Object(r.registerBlockType)("a8c/site-title",{title:Object(i.__)("Site Title"),description:Object(i.__)("Your site title."),icon:"layout",category:"layout",supports:{align:["wide","full"],html:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"wide"},textAlign:{type:"string",default:"center"},textColor:{type:"string"},customTextColor:{type:"string"},fontSize:{type:"string",default:"normal"},customFontSize:{type:"number"}},edit:W,save:function(){return null}});var Q=n(25),Y=(n(18),Object(u.compose)(Object(u.withState)({templateClientId:null}),Object(T.withSelect)(function(t,e){var n=e.attributes,o=e.templateClientId,r=t("core").getEntityRecord,i=t("core/editor"),c=i.getCurrentPostId,l=i.isEditedPostDirty,a=t("core/block-editor"),s=a.getBlock,u=a.getSelectedBlock,p=t("core/edit-post").isEditorSidebarOpened,d=n.templateId,f=c(),b=d&&r("postType","wp_template_part",d),m=Object(Q.addQueryArgs)(fullSiteEditing.editTemplateBaseUrl,{post:d,fse_parent_post:f}),g=u();return{currentPostId:f,editTemplateUrl:m,template:b,templateBlock:s(o),templateTitle:Object(N.get)(b,["title","rendered"],""),isDirty:l(),isEditorSidebarOpened:!!p(),isAnyTemplateBlockSelected:g&&"a8c/template"===g.name}}),Object(T.withDispatch)(function(t,e){var n=t("core/block-editor").receiveBlocks,o=t("core/edit-post").openGeneralSidebar,i=e.template,c=e.templateClientId,l=e.setState;return{savePost:t("core/editor").savePost,receiveTemplateBlocks:function(){if(i&&!c){var t=Object(r.parse)(Object(N.get)(i,["content","raw"],"")),e=Object(r.createBlock)("core/group",{},t);n([e]),l({templateClientId:e.clientId})}},openGeneralSidebar:o}}))(function(t){var e,n=t.attributes,r=t.editTemplateUrl,c=t.receiveTemplateBlocks,l=t.template,a=t.templateBlock,s=t.templateTitle,u=t.isDirty,p=t.savePost,f=t.isEditorSidebarOpened,b=t.openGeneralSidebar,m=t.isAnyTemplateBlockSelected;if(!l)return Object(o.createElement)(d.Placeholder,null,Object(o.createElement)(d.Spinner,null));var g=Object(o.createRef)(),j=Object(o.useState)(!1),h=R()(j,2),v=h[0],y=h[1];Object(o.useEffect)(function(){v&&!u&&g.current.click(),c()}),Object(o.useEffect)(function(){var t=document.querySelector(".edit-post-sidebar__panel-tabs ul li:last-child");if(f&&t){if(m)return b("edit-post/document"),void t.classList.add("hidden");t.classList.remove("hidden")}},[m,f,b]);var S=n.align,_=n.className;return Object(o.createElement)("div",{className:P()("template-block",(e={},O()(e,"align".concat(S),S),O()(e,"is-navigating-to-template",v),e))},a&&Object(o.createElement)(o.Fragment,null,Object(o.createElement)(d.Disabled,null,Object(o.createElement)("div",{className:_},Object(o.createElement)(B.BlockEdit,{attributes:a.attributes,block:a,clientId:a.clientId,isSelected:!1,name:a.name,setAttributes:N.noop}))),Object(o.createElement)(d.Placeholder,{className:"template-block__overlay"},v&&Object(o.createElement)("div",{className:"template-block__loading"},Object(o.createElement)(d.Spinner,null)," ",Object(i.sprintf)(Object(i.__)("Loading %s Editor"),s)),Object(o.createElement)(d.Button,{className:v?"hidden":null,href:r,onClick:function(t){y(!0),u&&(t.preventDefault(),p())},isDefault:!0,isLarge:!0,ref:g},Object(i.sprintf)(Object(i.__)("Edit %s"),s)))))})),J=Object(u.createHigherOrderComponent)(function(t){return function(e){return"fse-site-logo"!==e.attributes.className?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"template__site-logo"}))}},"addFSESiteLogoClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/template",J),"wp_template_part"!==fullSiteEditing.editorPostType&&Object(r.registerBlockType)("a8c/template",{title:Object(i.__)("Template Part"),description:Object(i.__)("Display a Template Part."),icon:"layout",category:"layout",attributes:{templateId:{type:"number"},className:{type:"string"}},supports:{anchor:!1,customClassName:!1,html:!1,inserter:!1,reusable:!1},edit:Y,save:function(){return null},getEditWrapperProps:function(){return{"data-align":"full"}}});var K=Object(u.createHigherOrderComponent)(function(t){return function(e){return"a8c/template"!==e.name?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"template__block-container"}))}},"addFSETemplateClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/template",K,9);var X=n(14),Z=n.n(X);Z()(function(){var t=fullSiteEditing,e=t.closeButtonLabel,n=t.closeButtonUrl,o=t.editorPostType,r=setInterval(function(){var t=document.querySelector(".edit-post-fullscreen-mode-close__toolbar a");if(t&&(clearInterval(r),"wp_template_part"===o&&n)){var i=document.createElement("a");i.href=n,i.innerHTML=e,i.className="components-button components-icon-button is-button is-default",i.setAttribute("aria-label",e),document.querySelector(".edit-post-fullscreen-mode-close__toolbar").replaceChild(i,t)}})});var $=n(26),tt=n.n($),et=n(27),nt=Object(T.withSelect)(function(t){var e=t("core").getEntityRecord,n=t("core/editor").getEditedPostAttribute;return{templateClasses:Object(N.map)(n("template_part_types"),function(t){var n=Object(N.get)(e("taxonomy","wp_template_part_type",t),"name","");return Object(N.endsWith)(n,"-header")?"site-header site-branding":Object(N.endsWith)(n,"-footer")?"site-footer":void 0})}})(function(t){var e=t.templateClasses,n=setInterval(function(){var t=document.querySelector(".block-editor-writing-flow.editor-writing-flow > div");t&&(clearInterval(n),t.className=P.a.apply(void 0,["a8c-template-editor"].concat(tt()(e))))});return null});"wp_template_part"===fullSiteEditing.editorPostType&&Object(et.registerPlugin)("fse-editor-template-classes",{render:nt}),Z()(function(){"wp_template_part"===fullSiteEditing.editorPostType&&Object(T.dispatch)("core/notices").createNotice("info",Object(i.__)("Updates to this template will affect all pages on your site."),{isDismissible:!1})});var ot=Object(u.compose)(Object(T.withSelect)(function(t){var e=t("core/editor"),n=e.getBlocks,o=e.getEditorSettings,r=t("core/edit-post").getEditorMode,i=n().find(function(t){return"a8c/post-content"===t.name});return{rootClientId:i?i.clientId:"",showInserter:"visual"===r()&&o().richEditingEnabled}}))(function(t){var e=t.rootClientId,n=t.showInserter;return Object(o.createElement)(B.Inserter,{rootClientId:e,disabled:!n,position:"bottom right"})});Z()(function(){return function(){if("page"===fullSiteEditing.editorPostType)var t=setInterval(function(){var e=document.querySelector(".edit-post-header-toolbar");if(e){clearInterval(t);var n=document.createElement("div");n.classList.add("fse-post-content-block-inserter"),e.insertBefore(n,e.firstChild),Object(o.render)(Object(o.createElement)(ot,null),n)}})}()});var rt=Object(T.subscribe)(function(){if("page"!==fullSiteEditing.editorPostType)return rt();!1===Object(T.select)("core/editor").isValidTemplate()&&Object(T.dispatch)("core/editor").setTemplateValidity(!0)}),it=["logo","brand","emblem","hallmark"];Object(m.addFilter)("blocks.registerBlockType","full-site-editing/editor/image-block-keywords",function(t,e){return"core/image"!==e?t:t=Object(N.assign)({},t,{keywords:t.keywords.concat(it)})});n(41);Object(T.use)(function(t){return{dispatch:function(e){var n=F()({},t.dispatch(e)),o=fullSiteEditing.editorPostType;return"core/editor"===e&&n.trashPost&&"wp_template_part"===o&&(n.trashPost=function(){}),n}}}),Object(T.use)(function(t){return{dispatch:function(e){var n=F()({},t.dispatch(e)),o=fullSiteEditing.editorPostType;if("core/editor"===e&&n.editPost&&"wp_template_part"===o){var r=n.editPost;n.editPost=function(t){"draft"!==t.status&&r(t)}}return n}}});var ct=Object(T.subscribe)(function(){var t=Object(T.dispatch)("core/edit-post").removeEditorPanel;return"page"===fullSiteEditing.editorPostType&&t("featured-image"),"wp_template_part"===fullSiteEditing.editorPostType&&t("post-status"),ct()})}]));
|
1 |
+
!function(t,e){for(var n in e)t[n]=e[n]}(window,function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=42)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e){!function(){t.exports=this.wp.blockEditor}()},function(t,e){!function(){t.exports=this.wp.data}()},function(t,e){!function(){t.exports=this.wp.compose}()},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){!function(){t.exports=this.lodash}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e,n){var o=n(5);function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}t.exports=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(n,!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},n.apply(this,arguments)}t.exports=n},function(t,e,n){var o;
|
2 |
/*!
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var t=[],e=0;e<arguments.length;e++){var o=arguments[e];if(o){var i=typeof o;if("string"===i||"number"===i)t.push(o);else if(Array.isArray(o)&&o.length){var c=r.apply(null,o);c&&t.push(c)}else if("object"===i)for(var l in o)n.call(o,l)&&o[l]&&t.push(l)}}return t.join(" ")}t.exports?(r.default=r,t.exports=r):void 0===(o=function(){return r}.apply(e,[]))||(t.exports=o)}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e,n){var o=n(33),r=n(34),i=n(35);t.exports=function(t,e){return o(t)||r(t,e)||i()}},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.htmlEntities}()},function(t,e,n){},function(t,e){!function(){t.exports=this.wp.serverSideRender}()},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}t.exports=function(t,e,o){return e&&n(t.prototype,e),o&&n(t,o),t}},function(t,e,n){var o=n(29),r=n(30);t.exports=function(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?r(t):e}},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var o=n(31);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}},function(t,e){!function(){t.exports=this.wp.editor}()},function(t,e){!function(){t.exports=this.wp.url}()},function(t,e,n){var o=n(38),r=n(39),i=n(40);t.exports=function(t){return o(t)||r(t)||i()}},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e,n){},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=o=function(t){return n(t)}:t.exports=o=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},o(e)}t.exports=o},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function n(e,o){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,o)}t.exports=n},function(t,e,n){},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],o=!0,r=!1,i=void 0;try{for(var c,l=t[Symbol.iterator]();!(o=(c=l.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(a){r=!0,i=a}finally{try{o||null==l.return||l.return()}finally{if(r)throw i}}return n}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){},function(t,e,n){},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,n){},function(t,e,n){"use strict";n.r(e);var o=n(0),r=n(7),i=n(1),c=n(10),l=n.n(c),a=n(18),s=n.n(a),u=n(4),p=n(2),d=n(8),f=Object(u.compose)([Object(p.withColors)("backgroundColor",{textColor:"color"}),Object(p.withFontSizes)("fontSize")])((function(t){var e=t.attributes,n=t.backgroundColor,r=t.fontSize,c=t.setAttributes,a=t.setBackgroundColor,u=t.setFontSize,f=t.setTextColor,b=t.textColor,m=e.customFontSize,g=e.textAlign,O=m||r.size;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:g,onChange:function(t){c({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:u,value:O})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:n.color,onChange:a,label:Object(i.__)("Background Color")},{value:b.color,onChange:f,label:Object(i.__)("Text Color")}]},Object(o.createElement)(p.ContrastChecker,l()({textColor:b.color,backgroundColor:n.color},{fontSize:O})))),Object(o.createElement)(s.a,{block:"a8c/navigation-menu",attributes:e}))})),b=(n(28),Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M12 7.27l4.28 10.43-3.47-1.53-.81-.36-.81.36-3.47 1.53L12 7.27M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71L12 2z"})));Object(r.registerBlockType)("a8c/navigation-menu",{title:Object(i.__)("Navigation Menu"),description:Object(i.__)("Visual placeholder for site-wide navigation and menus."),icon:b,category:"layout",supports:{align:["wide","full"],html:!1,reusable:!1},edit:f,save:function(){return null}});var m=n(12),g=n(5),O=n.n(g),j=n(19),h=n.n(j),v=n(20),y=n.n(v),S=n(21),_=n.n(S),E=n(22),k=n.n(E),w=n(23),C=n.n(w),x=n(11),P=n.n(x),T=n(3),B=n(24),I=function(t){function e(){return h()(this,e),_()(this,k()(e).apply(this,arguments))}return C()(e,t),y()(e,[{key:"toggleEditing",value:function(){var t=this.props,e=t.isEditing;(0,t.setState)({isEditing:!e})}},{key:"onSelectPost",value:function(t){var e=t.id,n=t.type;this.props.setState({isEditing:!1,selectedPostId:e,selectedPostType:n})}},{key:"render",value:function(){var t=this.props.attributes.align;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("div",{className:P()("post-content-block",O()({},"align".concat(t),t))},Object(o.createElement)(B.PostTitle,null),Object(o.createElement)(p.InnerBlocks,{templateLock:!1})))}}]),e}(o.Component),z=Object(u.compose)([Object(u.withState)({isEditing:!1,selectedPostId:void 0,selectedPostType:void 0}),Object(T.withSelect)((function(t,e){var n=e.selectedPostId,o=e.selectedPostType;return{selectedPost:(0,t("core").getEntityRecord)("postType",o,n)}}))])(I);n(32);Object(r.registerBlockType)("a8c/post-content",{title:Object(i.__)("Content"),description:Object(i.__)("The page content."),icon:"layout",category:"layout",supports:{align:["full"],anchor:!1,customClassName:!1,html:!1,inserter:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"full"}},edit:z,save:function(){return Object(o.createElement)(p.InnerBlocks.Content,null)}});var A=Object(u.createHigherOrderComponent)((function(t){return function(e){return"a8c/post-content"!==e.name?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"post-content__block"}))}}),"addContentSlotClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/post-content",A,9);var N=n(6),F=n(9),D=n.n(F),L=n(14),R=n.n(L),M=n(15),U=n.n(M),H=n(16);function q(t){var e=Object(o.useRef)();return Object(o.useEffect)((function(){e.current=t}),[t]),e.current}function V(t,e,n,r,c,l){var a=Object(o.useState)({option:e,previousOption:"",loaded:!1,error:!1}),s=R()(a,2),u=s[0],p=s[1],d=q(r),f=q(c);function b(){p(D()({},u,{option:u.previousOption,isSaving:!1}))}return Object(o.useEffect)((function(){u.loaded||u.error?function(){var e=u.option,o=u.previousOption,l=e&&e.trim()===o.trim(),a=!e||0===e.trim().length;!r&&d&&a&&b();if(!c||l)return;!f&&c&&function(e){p(D()({},u,{isSaving:!0})),U()({path:"/wp/v2/settings",method:"POST",data:O()({},t,e)}).then((function(){return function(t){p(D()({},u,{previousOption:t,isDirty:!1,isSaving:!1}))}(e)})).catch((function(){n(Object(i.sprintf)(Object(i.__)("Unable to save site %s"),t)),b()}))}(e)}():U()({path:"/wp/v2/settings"}).then((function(e){return p(D()({},u,{option:Object(H.decodeEntities)(e[t]),previousOption:Object(H.decodeEntities)(e[t]),loaded:!0,error:!1}))})).catch((function(){n(Object(i.sprintf)(Object(i.__)("Unable to load site %s"),t)),p(D()({},u,{option:Object(i.sprintf)(Object(i.__)("Error loading site %s"),t),error:!0}))}))})),{siteOptions:u,handleChange:function(t){l({updated:Date.now()}),p(D()({},u,{option:t}))}}}var G=Object(u.compose)([Object(p.withColors)("backgroundColor",{textColor:"color"}),Object(p.withFontSizes)("fontSize"),Object(T.withSelect)((function(t,e){var n=e.clientId,o=t("core/editor"),r=o.isSavingPost,i=o.isPublishingPost,c=o.isAutosavingPost,l=o.isCurrentPostPublished,a=t("core/block-editor"),s=a.getBlockIndex,u=a.getBlockRootClientId,p=a.getTemplateLock,d=u(n);return{blockIndex:s(n,d),isLocked:!!p(d),rootClientId:d,shouldUpdateSiteOption:(r()&&l()||i())&&!c()}})),Object(T.withDispatch)((function(t,e){var n=e.blockIndex,o=e.rootClientId;return{createErrorNotice:t("core/notices").createErrorNotice,insertDefaultBlock:function(){return t("core/block-editor").insertDefaultBlock({},o,n+1)}}}))])((function(t){var e,n=t.attributes,r=t.backgroundColor,c=t.className,a=t.createErrorNotice,s=t.fontSize,u=t.insertDefaultBlock,f=t.isSelected,b=t.setAttributes,m=t.setBackgroundColor,g=t.setFontSize,j=t.setTextColor,h=t.shouldUpdateSiteOption,v=t.textColor,y=n.customFontSize,S=n.textAlign,_=y||s.size,E=V("description",Object(i.__)("Site description loading…"),a,f,h,b),k=E.siteOptions,w=E.handleChange,C=k.option;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:S,onChange:function(t){b({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:g,value:_})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:r.color,onChange:m,label:Object(i.__)("Background Color")},{value:v.color,onChange:j,label:Object(i.__)("Text Color")}]},Object(o.createElement)(p.ContrastChecker,l()({textColor:v.color,backgroundColor:r.color},{fontSize:_})))),Object(o.createElement)(p.RichText,{allowedFormats:[],"aria-label":Object(i.__)("Site Description"),className:P()("site-description",c,(e={"has-text-color":v.color,"has-background":r.color},O()(e,"has-text-align-".concat(S),S),O()(e,r.class,r.class),O()(e,v.class,v.class),O()(e,s.class,!y&&s.class),e)),identifier:"content",onChange:function(t){return w(t)},onReplace:u,onSplit:N.noop,placeholder:Object(i.__)("Add a Site Description"),style:{backgroundColor:r.color,color:v.color,fontSize:_?_+"px":void 0},tagName:"p",value:C}))}));n(36);Object(r.registerBlockType)("a8c/site-description",{title:Object(i.__)("Site Description"),description:Object(i.__)("Site description, also known as the tagline."),icon:Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(o.createElement)("path",{d:"M4 9h16v2H4V9zm0 4h10v2H4v-2z"})),category:"layout",supports:{align:["wide","full"],html:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"wide"},textAlign:{type:"string",default:"center"},textColor:{type:"string"},customTextColor:{type:"string"},backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},fontSize:{type:"string",default:"small"},customFontSize:{type:"number"}},edit:G,save:function(){return null}});var W=Object(u.compose)([Object(p.withColors)({textColor:"color"}),Object(p.withFontSizes)("fontSize"),Object(T.withSelect)((function(t,e){var n=e.clientId,o=t("core/editor"),r=o.isSavingPost,i=o.isPublishingPost,c=o.isAutosavingPost,l=o.isCurrentPostPublished,a=t("core/block-editor"),s=a.getBlockIndex,u=a.getBlockRootClientId,p=a.getTemplateLock,d=u(n);return{blockIndex:s(n,d),isLocked:!!p(d),rootClientId:d,shouldUpdateSiteOption:(r()&&l()||i())&&!c()}})),Object(T.withDispatch)((function(t,e){var n=e.blockIndex,o=e.rootClientId;return{createErrorNotice:t("core/notices").createErrorNotice,insertDefaultBlock:function(){return t("core/block-editor").insertDefaultBlock({},o,n+1)}}}))])((function(t){var e,n=t.attributes,r=t.className,c=t.createErrorNotice,l=t.fontSize,a=t.insertDefaultBlock,s=t.isSelected,u=t.setAttributes,f=t.setFontSize,b=t.setTextColor,m=t.shouldUpdateSiteOption,g=t.textColor,j=n.customFontSize,h=n.textAlign,v=j||l.size,y=V("title",Object(i.__)("Site title loading…"),c,s,m,u),S=y.siteOptions,_=y.handleChange,E=S.option;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(p.BlockControls,null,Object(o.createElement)(p.AlignmentToolbar,{value:h,onChange:function(t){u({textAlign:t})}})),Object(o.createElement)(p.InspectorControls,null,Object(o.createElement)(d.PanelBody,{className:"blocks-font-size",title:Object(i.__)("Text Settings")},Object(o.createElement)(p.FontSizePicker,{onChange:f,value:v})),Object(o.createElement)(p.PanelColorSettings,{title:Object(i.__)("Color Settings"),initialOpen:!1,colorSettings:[{value:g.color,onChange:b,label:Object(i.__)("Text Color")}]})),Object(o.createElement)(p.RichText,{allowedFormats:[],"aria-label":Object(i.__)("Site Title"),className:P()("site-title",r,(e={"has-text-color":g.color},O()(e,"has-text-align-".concat(h),h),O()(e,g.class,g.class),O()(e,l.class,!j&&l.class),e)),identifier:"content",onChange:function(t){return _(t)},onReplace:a,onSplit:N.noop,placeholder:Object(i.__)("Add a Site Title"),style:{color:g.color,fontSize:v?v+"px":void 0},tagName:"h1",value:E}))}));n(37);Object(r.registerBlockType)("a8c/site-title",{title:Object(i.__)("Site Title"),description:Object(i.__)("Your site title."),icon:"layout",category:"layout",supports:{align:["wide","full"],html:!1,multiple:!1,reusable:!1},attributes:{align:{type:"string",default:"wide"},textAlign:{type:"string",default:"center"},textColor:{type:"string"},customTextColor:{type:"string"},fontSize:{type:"string",default:"normal"},customFontSize:{type:"number"}},edit:W,save:function(){return null}});var Q=n(25),Y=(n(17),Object(u.compose)(Object(u.withState)({templateClientId:null}),Object(T.withSelect)((function(t,e){var n=e.attributes,o=e.templateClientId,r=t("core").getEntityRecord,i=t("core/editor"),c=i.getCurrentPostId,l=i.isEditedPostDirty,a=t("core/block-editor"),s=a.getBlock,u=a.getSelectedBlock,p=t("core/edit-post").isEditorSidebarOpened,d=n.templateId,f=c(),b=d&&r("postType","wp_template_part",d),m=Object(Q.addQueryArgs)(fullSiteEditing.editTemplateBaseUrl,{post:d,fse_parent_post:f}),g=u();return{currentPostId:f,editTemplateUrl:m,template:b,templateBlock:s(o),templateTitle:Object(N.get)(b,["title","rendered"],""),isDirty:l(),isEditorSidebarOpened:!!p(),isAnyTemplateBlockSelected:g&&"a8c/template"===g.name}})),Object(T.withDispatch)((function(t,e){var n=t("core/block-editor").receiveBlocks,o=t("core/edit-post").openGeneralSidebar,i=e.template,c=e.templateClientId,l=e.setState;return{savePost:t("core/editor").savePost,receiveTemplateBlocks:function(){if(i&&!c){var t=Object(r.parse)(Object(N.get)(i,["content","raw"],"")),e=Object(r.createBlock)("core/group",{},t);n([e]),l({templateClientId:e.clientId})}},openGeneralSidebar:o}})))((function(t){var e,n=t.attributes,r=t.editTemplateUrl,c=t.receiveTemplateBlocks,l=t.template,a=t.templateBlock,s=t.templateTitle,u=t.isDirty,f=t.savePost,b=t.isEditorSidebarOpened,m=t.openGeneralSidebar,g=t.isAnyTemplateBlockSelected;if(!l)return Object(o.createElement)(d.Placeholder,null,Object(o.createElement)(d.Spinner,null));var j=Object(o.createRef)(),h=Object(o.useState)(!1),v=R()(h,2),y=v[0],S=v[1];Object(o.useEffect)((function(){y&&!u&&j.current.click(),c()})),Object(o.useEffect)((function(){var t=document.querySelector(".edit-post-sidebar__panel-tabs ul li:last-child");if(b&&t){if(g)return m("edit-post/document"),void t.classList.add("hidden");t.classList.remove("hidden")}}),[g,b,m]);var _=n.align,E=n.className;return Object(o.createElement)("div",{className:P()("template-block",(e={},O()(e,"align".concat(_),_),O()(e,"is-navigating-to-template",y),e))},a&&Object(o.createElement)(o.Fragment,null,Object(o.createElement)(d.Disabled,null,Object(o.createElement)("div",{className:E},Object(o.createElement)(p.BlockEdit,{attributes:a.attributes,block:a,clientId:a.clientId,isSelected:!1,name:a.name,setAttributes:N.noop}))),Object(o.createElement)(d.Placeholder,{className:"template-block__overlay"},y&&Object(o.createElement)("div",{className:"template-block__loading"},Object(o.createElement)(d.Spinner,null)," ",Object(i.sprintf)(Object(i.__)("Loading editor for: %s"),s)),Object(o.createElement)(d.Button,{className:y?"hidden":null,href:r,onClick:function(t){S(!0),u&&(t.preventDefault(),f())},isDefault:!0,isLarge:!0,ref:j},Object(i.sprintf)(Object(i.__)("Edit %s"),s)))))}))),J=Object(u.createHigherOrderComponent)((function(t){return function(e){return"fse-site-logo"!==e.attributes.className?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"template__site-logo"}))}}),"addFSESiteLogoClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/template",J),"wp_template_part"!==fullSiteEditing.editorPostType&&Object(r.registerBlockType)("a8c/template",{title:Object(i.__)("Template Part"),description:Object(i.__)("Display a Template Part."),icon:"layout",category:"layout",attributes:{templateId:{type:"number"},className:{type:"string"}},supports:{anchor:!1,customClassName:!1,html:!1,inserter:!1,reusable:!1},edit:Y,save:function(){return null},getEditWrapperProps:function(){return{"data-align":"full"}}});var K=Object(u.createHigherOrderComponent)((function(t){return function(e){return"a8c/template"!==e.name?Object(o.createElement)(t,e):Object(o.createElement)(t,l()({},e,{className:"template__block-container"}))}}),"addFSETemplateClassname");Object(m.addFilter)("editor.BlockListBlock","full-site-editing/blocks/template",K,9);var X=n(13),Z=n.n(X);Z()((function(){var t=fullSiteEditing,e=t.closeButtonLabel,n=t.closeButtonUrl,o=t.editorPostType,r=setInterval((function(){var t=document.querySelector(".edit-post-fullscreen-mode-close__toolbar a");if(t&&(clearInterval(r),"wp_template_part"===o&&n)){var i=document.createElement("a");i.href=n,i.innerHTML=e,i.className="components-button components-icon-button is-button is-default",i.setAttribute("aria-label",e),document.querySelector(".edit-post-fullscreen-mode-close__toolbar").replaceChild(i,t)}}))}));var $=n(26),tt=n.n($),et=n(27),nt=Object(T.withSelect)((function(t){var e=t("core").getEntityRecord,n=t("core/editor").getEditedPostAttribute;return{templateClasses:Object(N.map)(n("template_part_types"),(function(t){var n=Object(N.get)(e("taxonomy","wp_template_part_type",t),"name","");return Object(N.endsWith)(n,"-header")?"site-header site-branding":Object(N.endsWith)(n,"-footer")?"site-footer":void 0}))}}))((function(t){var e=t.templateClasses,n=setInterval((function(){var t=document.querySelector(".block-editor-writing-flow.editor-writing-flow > div");t&&(clearInterval(n),t.className=P.a.apply(void 0,["a8c-template-editor"].concat(tt()(e))))}));return null}));"wp_template_part"===fullSiteEditing.editorPostType&&Object(et.registerPlugin)("fse-editor-template-classes",{render:nt}),Z()((function(){"wp_template_part"===fullSiteEditing.editorPostType&&Object(T.dispatch)("core/notices").createNotice("info",Object(i.__)("Updates to this template will affect all pages on your site."),{isDismissible:!1})}));var ot=Object(u.compose)(Object(T.withSelect)((function(t){var e=t("core/editor").getEditorSettings,n=t("core/block-editor").getBlocks,o=t("core/edit-post").getEditorMode,r=n().find((function(t){return"a8c/post-content"===t.name}));return{rootClientId:r?r.clientId:"",showInserter:"visual"===o()&&e().richEditingEnabled}})))((function(t){var e=t.rootClientId,n=t.showInserter;return Object(o.createElement)(p.Inserter,{rootClientId:e,disabled:!n,position:"bottom right"})}));Z()((function(){return function(){if("page"===fullSiteEditing.editorPostType)var t=setInterval((function(){var e=document.querySelector(".edit-post-header-toolbar");if(e){clearInterval(t);var n=document.createElement("div");n.classList.add("fse-post-content-block-inserter"),e.insertBefore(n,e.firstChild),Object(o.render)(Object(o.createElement)(ot,null),n)}}))}()}));var rt=Object(T.subscribe)((function(){if("page"!==fullSiteEditing.editorPostType)return rt();!1===Object(T.select)("core/block-editor").isValidTemplate()&&Object(T.dispatch)("core/block-editor").setTemplateValidity(!0)})),it=["logo","brand","emblem","hallmark"];Object(m.addFilter)("blocks.registerBlockType","full-site-editing/editor/image-block-keywords",(function(t,e){return"core/image"!==e?t:t=Object(N.assign)({},t,{keywords:t.keywords.concat(it)})}));n(41);Object(T.use)((function(t){return{dispatch:function(e){var n=D()({},t.dispatch(e)),o=fullSiteEditing.editorPostType;return"core/editor"===e&&n.trashPost&&"wp_template_part"===o&&(n.trashPost=function(){}),n}}})),Object(T.use)((function(t){return{dispatch:function(e){var n=D()({},t.dispatch(e)),o=fullSiteEditing.editorPostType;if("core/editor"===e&&n.editPost&&"wp_template_part"===o){var r=n.editPost;n.editPost=function(t){"draft"!==t.status&&r(t)}}return n}}}));var ct=Object(T.subscribe)((function(){var t=Object(T.dispatch)("core/edit-post").removeEditorPanel;return"page"===fullSiteEditing.editorPostType&&t("featured-image"),"wp_template_part"===fullSiteEditing.editorPostType&&t("post-status"),ct()}))}]));
|
|
|
|
|
|
|
|
|
|
|
|
full-site-editing/editor/block-inserter/post-content-block-appender.js
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { Inserter } from '@wordpress/editor';
|
5 |
import { compose } from '@wordpress/compose';
|
6 |
import { withSelect } from '@wordpress/data';
|
7 |
|
8 |
const PostContentBlockAppender = compose(
|
9 |
withSelect( select => {
|
10 |
-
const {
|
|
|
11 |
const { getEditorMode } = select( 'core/edit-post' );
|
12 |
|
13 |
const postContentBlock = getBlocks().find( block => block.name === 'a8c/post-content' );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { Inserter } from '@wordpress/block-editor';
|
5 |
import { compose } from '@wordpress/compose';
|
6 |
import { withSelect } from '@wordpress/data';
|
7 |
|
8 |
const PostContentBlockAppender = compose(
|
9 |
withSelect( select => {
|
10 |
+
const { getEditorSettings } = select( 'core/editor' );
|
11 |
+
const { getBlocks } = select( 'core/block-editor' );
|
12 |
const { getEditorMode } = select( 'core/edit-post' );
|
13 |
|
14 |
const postContentBlock = getBlocks().find( block => block.name === 'a8c/post-content' );
|
full-site-editing/editor/template-validity-override/index.js
CHANGED
@@ -17,7 +17,7 @@ const unsubscribe = subscribe( () => {
|
|
17 |
if ( 'page' !== fullSiteEditing.editorPostType ) {
|
18 |
return unsubscribe();
|
19 |
}
|
20 |
-
if ( select( 'core/editor' ).isValidTemplate() === false ) {
|
21 |
-
dispatch( 'core/editor' ).setTemplateValidity( true );
|
22 |
}
|
23 |
} );
|
17 |
if ( 'page' !== fullSiteEditing.editorPostType ) {
|
18 |
return unsubscribe();
|
19 |
}
|
20 |
+
if ( select( 'core/block-editor' ).isValidTemplate() === false ) {
|
21 |
+
dispatch( 'core/block-editor' ).setTemplateValidity( true );
|
22 |
}
|
23 |
} );
|
full-site-editing/templates/class-template-image-inserter.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Full site editing file.
|
4 |
+
*
|
5 |
+
* @package A8C\FSE
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace A8C\FSE;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Template_Image_Inserter
|
12 |
+
*/
|
13 |
+
class Template_Image_Inserter {
|
14 |
+
/**
|
15 |
+
* Uploads specific images to the media libraray
|
16 |
+
*
|
17 |
+
* It then checks if any of the passed image URLs are also in the post content
|
18 |
+
* of any of the passed post IDs. If so, then the post content is updated to
|
19 |
+
* use the new local URL instead of the passed URL.
|
20 |
+
*
|
21 |
+
* @param array $img_urls URLs of images which should be uploaded.
|
22 |
+
* @param array $post_ids An array of posts IDs which should be updated with newly uploaded image URLs.
|
23 |
+
*/
|
24 |
+
public function copy_images_and_update_posts( $img_urls = [], $post_ids = [] ) {
|
25 |
+
do_action(
|
26 |
+
'a8c_fse_log',
|
27 |
+
'template_image_sideload_begin',
|
28 |
+
[
|
29 |
+
'context' => 'Template_Image_Inserter->copy_images_and_update_posts',
|
30 |
+
'image_urls' => $img_urls,
|
31 |
+
]
|
32 |
+
);
|
33 |
+
|
34 |
+
if ( empty( $img_urls ) || empty( $post_ids ) ) {
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
$images = $this->upload_images( $img_urls );
|
39 |
+
foreach ( $post_ids as $id ) {
|
40 |
+
$this->update_post_images( $id, $images );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Upload an array of images to the media library.
|
46 |
+
*
|
47 |
+
* If an file fails to upload, the error is logged to the FSE error handler.
|
48 |
+
*
|
49 |
+
* @param array $image_urls Images URLs to upload.
|
50 |
+
* @return array Each entry contains the old and new URL of an image if successfully uploaded.
|
51 |
+
*/
|
52 |
+
public function upload_images( $image_urls ) {
|
53 |
+
return array_reduce(
|
54 |
+
$image_urls,
|
55 |
+
function( $accumulator, $url ) {
|
56 |
+
// 1. Attempt to sideload the image and get the local URL.
|
57 |
+
$local_url = $this->upload_image( $url );
|
58 |
+
|
59 |
+
// 2. Check if anything went wrong during upload.
|
60 |
+
$error_msg = null;
|
61 |
+
if ( is_wp_error( $local_url ) ) {
|
62 |
+
$error_msg = $local_url->get_error_message();
|
63 |
+
} elseif ( ! is_string( $local_url ) ) {
|
64 |
+
$error_msg = 'Issue uploading the image.';
|
65 |
+
}
|
66 |
+
|
67 |
+
// 3. If there was an error, report it.
|
68 |
+
if ( is_string( $error_msg ) ) {
|
69 |
+
do_action(
|
70 |
+
'a8c_fse_log',
|
71 |
+
'image_sideload_failure',
|
72 |
+
[
|
73 |
+
'context' => 'Template_Image_Inserter->upload_images',
|
74 |
+
'error' => $error_msg,
|
75 |
+
'remote_image_url' => $url,
|
76 |
+
]
|
77 |
+
);
|
78 |
+
} else {
|
79 |
+
// 4. Otherwise, save the url.
|
80 |
+
$accumulator[] = [
|
81 |
+
'old_url' => $url,
|
82 |
+
'new_url' => $local_url,
|
83 |
+
];
|
84 |
+
}
|
85 |
+
return $accumulator;
|
86 |
+
},
|
87 |
+
[]
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Sideload a remote image URL and return the local attachment URL.
|
93 |
+
*
|
94 |
+
* @param string $image_url The URL to sideload to the local site.
|
95 |
+
* @return string The local URL of the newly uploaded image.
|
96 |
+
*/
|
97 |
+
public function upload_image( $image_url ) {
|
98 |
+
if ( ! function_exists( 'media_handle_sideload' ) ) {
|
99 |
+
require_once ABSPATH . '/wp-admin/includes/file.php';
|
100 |
+
require_once ABSPATH . '/wp-admin/includes/media.php';
|
101 |
+
require_once ABSPATH . '/wp-admin/includes/image.php';
|
102 |
+
}
|
103 |
+
|
104 |
+
// 1. Download the image.
|
105 |
+
$local_file = download_url( $image_url );
|
106 |
+
if ( is_wp_error( $local_file ) ) {
|
107 |
+
return $local_file;
|
108 |
+
}
|
109 |
+
|
110 |
+
// 2. Create a file object.
|
111 |
+
$file_name = basename( wp_parse_url( $image_url, PHP_URL_PATH ) );
|
112 |
+
$desc = 'Template Part Image';
|
113 |
+
$file_array = [
|
114 |
+
'name' => $file_name,
|
115 |
+
'tmp_name' => $local_file,
|
116 |
+
];
|
117 |
+
|
118 |
+
// 3. Sideload, remove tmp file, and return the local URL.
|
119 |
+
$id = media_handle_sideload( $file_array, 0, $desc );
|
120 |
+
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
121 |
+
@unlink( $local_file );
|
122 |
+
|
123 |
+
if ( is_wp_error( $id ) ) {
|
124 |
+
return $id;
|
125 |
+
}
|
126 |
+
|
127 |
+
return wp_get_attachment_url( $id );
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Upload an image URL.
|
132 |
+
*
|
133 |
+
* @param array $post_id The post ID which should be updated with the new URLs.
|
134 |
+
* @param array $images An array of old/new image URLs to replace.
|
135 |
+
*/
|
136 |
+
public function update_post_images( $post_id, $images ) {
|
137 |
+
$content = get_post_field( 'post_content', $post_id );
|
138 |
+
if ( empty( $content ) ) {
|
139 |
+
do_action(
|
140 |
+
'a8c_fse_log',
|
141 |
+
'update_post_with_new_images_get_post_failure',
|
142 |
+
[
|
143 |
+
'context' => 'Template_Image_Inserter->update_post_images',
|
144 |
+
'error' => 'Could not retrieve post content.',
|
145 |
+
'post_id' => $post_id,
|
146 |
+
]
|
147 |
+
);
|
148 |
+
return;
|
149 |
+
}
|
150 |
+
|
151 |
+
// Replace the matching images in the content and update the post.
|
152 |
+
foreach ( $images as $image ) {
|
153 |
+
$content = str_replace( $image['old_url'], $image['new_url'], $content );
|
154 |
+
}
|
155 |
+
$res = wp_update_post(
|
156 |
+
[
|
157 |
+
'ID' => $post_id,
|
158 |
+
'post_content' => $content,
|
159 |
+
]
|
160 |
+
);
|
161 |
+
|
162 |
+
if ( ! $res ) {
|
163 |
+
do_action(
|
164 |
+
'a8c_fse_log',
|
165 |
+
'update_post_with_new_images_update_post_failure',
|
166 |
+
[
|
167 |
+
'context' => 'Template_Image_Inserter->update_post_images',
|
168 |
+
'error' => 'Issue updating the post with the new image URLs.',
|
169 |
+
'image_urls' => $images,
|
170 |
+
]
|
171 |
+
);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
full-site-editing/templates/class-wp-template-inserter.php
CHANGED
@@ -32,6 +32,13 @@ class WP_Template_Inserter {
|
|
32 |
*/
|
33 |
private $theme_slug;
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
* This site option will be used to indicate that template data has already been
|
37 |
* inserted for this theme, in order to prevent this functionality from running
|
@@ -107,6 +114,11 @@ class WP_Template_Inserter {
|
|
107 |
if ( ! empty( $api_response['footers'] ) ) {
|
108 |
$this->footer_content = $api_response['footers'][0];
|
109 |
}
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -240,6 +252,20 @@ class WP_Template_Inserter {
|
|
240 |
|
241 |
add_option( $this->fse_template_data_option, true );
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
do_action(
|
244 |
'a8c_fse_log',
|
245 |
'template_population_success',
|
@@ -323,6 +349,7 @@ class WP_Template_Inserter {
|
|
323 |
'post_content' => $template_content_by_slug['about'],
|
324 |
'post_status' => 'publish',
|
325 |
'post_type' => 'page',
|
|
|
326 |
]
|
327 |
);
|
328 |
}
|
@@ -334,6 +361,7 @@ class WP_Template_Inserter {
|
|
334 |
'post_content' => $template_content_by_slug['contact'],
|
335 |
'post_status' => 'publish',
|
336 |
'post_type' => 'page',
|
|
|
337 |
]
|
338 |
);
|
339 |
}
|
32 |
*/
|
33 |
private $theme_slug;
|
34 |
|
35 |
+
/**
|
36 |
+
* Image URLs contained in the returned from the template API
|
37 |
+
*
|
38 |
+
* @var array $image_urls
|
39 |
+
*/
|
40 |
+
private $image_urls;
|
41 |
+
|
42 |
/**
|
43 |
* This site option will be used to indicate that template data has already been
|
44 |
* inserted for this theme, in order to prevent this functionality from running
|
114 |
if ( ! empty( $api_response['footers'] ) ) {
|
115 |
$this->footer_content = $api_response['footers'][0];
|
116 |
}
|
117 |
+
|
118 |
+
// This should contain all image URLs for images in any header or footer.
|
119 |
+
if ( ! empty( $api_response['image_urls'] ) ) {
|
120 |
+
$this->image_urls = $api_response['image_urls'];
|
121 |
+
}
|
122 |
}
|
123 |
|
124 |
/**
|
252 |
|
253 |
add_option( $this->fse_template_data_option, true );
|
254 |
|
255 |
+
// Note: we set the option before doing the image upload because the template
|
256 |
+
// parts can work with the remote URLs even if this fails.
|
257 |
+
$image_urls = $this->image_urls;
|
258 |
+
if ( ! empty( $image_urls ) ) {
|
259 |
+
// Uploading images locally does not work in the WordPress.com environment,
|
260 |
+
// so we use an action to handle it with Headstart there.
|
261 |
+
if ( has_action( 'a8c_fse_upload_template_part_images' ) ) {
|
262 |
+
do_action( 'a8c_fse_upload_template_part_images', $image_urls, [ $header_id, $footer_id ] );
|
263 |
+
} else {
|
264 |
+
$image_inserter = new Template_Image_Inserter();
|
265 |
+
$image_inserter->copy_images_and_update_posts( $image_urls, [ $header_id, $footer_id ] );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
do_action(
|
270 |
'a8c_fse_log',
|
271 |
'template_population_success',
|
349 |
'post_content' => $template_content_by_slug['about'],
|
350 |
'post_status' => 'publish',
|
351 |
'post_type' => 'page',
|
352 |
+
'menu_order' => 1,
|
353 |
]
|
354 |
);
|
355 |
}
|
361 |
'post_content' => $template_content_by_slug['contact'],
|
362 |
'post_status' => 'publish',
|
363 |
'post_type' => 'page',
|
364 |
+
'menu_order' => 1,
|
365 |
]
|
366 |
);
|
367 |
}
|
global-styles/README-DATA.md
ADDED
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Global Styles approach to Data <!-- omit in toc -->
|
2 |
+
|
3 |
+
Global Styles adds a new JSON REST API endpoint. It is a thin endpoint that outsources the data processing to the `\Automattic\Jetpack\Global_Styles\Data_Set` class, which implements a declarative approach to data retrieval and persistance.
|
4 |
+
|
5 |
+
In this document we'll go through the existing API:
|
6 |
+
|
7 |
+
- [Introduction](#introduction)
|
8 |
+
- [Literal Data Points](#literal-data-points)
|
9 |
+
- [Option Data Points](#option-data-points)
|
10 |
+
- [Fallback Values](#fallback-values)
|
11 |
+
- [Working with option's properties](#working-with-options-properties)
|
12 |
+
- [Updatable Options](#updatable-options)
|
13 |
+
- [Filters to prepare and sanitize data](#filters-to-prepare-and-sanitize-data)
|
14 |
+
- [Theme Data Points](#theme-data-points)
|
15 |
+
- [Fallback Values](#fallback-values-1)
|
16 |
+
- [Working with theme's properties](#working-with-themes-properties)
|
17 |
+
|
18 |
+
## Introduction
|
19 |
+
|
20 |
+
The `\Automattic\Jetpack\Global_Styles\Data_Set` takes as input a declarative data format and knows how to process three kinds of data:
|
21 |
+
|
22 |
+
```php
|
23 |
+
// Initialize
|
24 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
25 |
+
'font_list' => [
|
26 |
+
'type' => 'literal',
|
27 |
+
'default' => [
|
28 |
+
'Arvo',
|
29 |
+
'Libre Baskerville',
|
30 |
+
'Ubuntu',
|
31 |
+
],
|
32 |
+
],
|
33 |
+
'font_base_default' => [
|
34 |
+
'type' => 'theme',
|
35 |
+
'name' => [ 'jetpack-global-styles', 'font_base' ],
|
36 |
+
'default' => 'Ubuntu',
|
37 |
+
],
|
38 |
+
'site_name' => [
|
39 |
+
'type' => 'option',
|
40 |
+
'name' => 'blogname',
|
41 |
+
'default' => 'Your site name',
|
42 |
+
],
|
43 |
+
] );
|
44 |
+
|
45 |
+
$data_set->get_data(); // Outputs data.
|
46 |
+
$data_set->save_data( $new_data ); // Updates data.
|
47 |
+
```
|
48 |
+
|
49 |
+
- **literal data points** are literal PHP values. These don't change over time and aren't saved to the database.
|
50 |
+
- **options data points** are values that come from the WordPress Options API. These can also be updated.
|
51 |
+
- **theme support data points** are values that come from the theme via `add_theme_support`.
|
52 |
+
|
53 |
+
## Literal Data Points
|
54 |
+
|
55 |
+
Data points are considered to be of the *literal* kind if their `type` property value is `literal`. Their output is the literal PHP value in the `default` property, or `null` if none is provided.
|
56 |
+
|
57 |
+
For this **input**:
|
58 |
+
|
59 |
+
```php
|
60 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
61 |
+
'font_base_default' => [
|
62 |
+
'type' => 'literal',
|
63 |
+
'default' => 'Libre Baskerville',
|
64 |
+
],
|
65 |
+
'font_headings_default' => [
|
66 |
+
'type' => 'literal',
|
67 |
+
'default' => 'Lora',
|
68 |
+
],
|
69 |
+
] );
|
70 |
+
```
|
71 |
+
|
72 |
+
The **output** of `$data_set->get_data()` will be:
|
73 |
+
|
74 |
+
```php
|
75 |
+
[
|
76 |
+
'font_base_default' => 'Libre Baskerville',
|
77 |
+
'font_headings_default' => 'Lora',
|
78 |
+
]
|
79 |
+
```
|
80 |
+
|
81 |
+
Note that the `default` property can contain any valid PHP data.
|
82 |
+
|
83 |
+
For example, use an array as **input**:
|
84 |
+
|
85 |
+
```php
|
86 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
87 |
+
'font_options' => [
|
88 |
+
'type' => 'literal',
|
89 |
+
'default' => [
|
90 |
+
[
|
91 |
+
'label' => 'Ubuntu Font',
|
92 |
+
'value' => 'Ubuntu',
|
93 |
+
],
|
94 |
+
'Libre Baskerville',
|
95 |
+
'Lora',
|
96 |
+
],
|
97 |
+
],
|
98 |
+
] );
|
99 |
+
```
|
100 |
+
|
101 |
+
The **output** of `$data_set->get_data()` will be:
|
102 |
+
|
103 |
+
```php
|
104 |
+
[
|
105 |
+
'font_options' => [
|
106 |
+
0 => [
|
107 |
+
'label' => 'Ubuntu Font',
|
108 |
+
'value' => 'Ubuntu',
|
109 |
+
],
|
110 |
+
1 => 'Libre Baskerville'
|
111 |
+
2 => 'Lora',
|
112 |
+
]
|
113 |
+
]
|
114 |
+
```
|
115 |
+
|
116 |
+
## Option Data Points
|
117 |
+
|
118 |
+
Data points are considered to be of the *option* kind if the value of the `type` property is `option`. These are the only data points that can be updated.
|
119 |
+
|
120 |
+
The simplest use case is to operate with the contents of an option without further processing. This **input** can be expressed as:
|
121 |
+
|
122 |
+
```php
|
123 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
124 |
+
'site_name' => [
|
125 |
+
'type' => 'option',
|
126 |
+
'name' => 'blogname',
|
127 |
+
]
|
128 |
+
] );
|
129 |
+
```
|
130 |
+
|
131 |
+
The result of `$data_set->get_data()` will **output** the value of the `blogname` option in the database, or `false` if it doesn't exists or does not have a value:
|
132 |
+
|
133 |
+
```php
|
134 |
+
[
|
135 |
+
'site_name' => 'A WordPress Site'
|
136 |
+
]
|
137 |
+
```
|
138 |
+
|
139 |
+
### Fallback Values
|
140 |
+
|
141 |
+
If the option does not exist or does not have a value, then the return value will be `false`, which replicates the WordPress Options API default behavior. In case you want to provide a fallback value, you can do so by using the `default` property.
|
142 |
+
|
143 |
+
**Input**:
|
144 |
+
|
145 |
+
```php
|
146 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
147 |
+
'site_name' => [
|
148 |
+
'type' => 'option',
|
149 |
+
'name' => 'some_non_existing_option',
|
150 |
+
'default' => 'My cool site name',
|
151 |
+
]
|
152 |
+
] );
|
153 |
+
```
|
154 |
+
|
155 |
+
**Output** if option doesn't exist:
|
156 |
+
|
157 |
+
```php
|
158 |
+
[
|
159 |
+
'site_name' => 'My cool site name'
|
160 |
+
]
|
161 |
+
```
|
162 |
+
|
163 |
+
### Working with option's properties
|
164 |
+
|
165 |
+
So far, we've exposed the whole option value. However, sometimes we want to unwrap an option and work with one of its properties instead.
|
166 |
+
|
167 |
+
For example, let's say that there is an option called `jetpack_global_styles` whose value is an object such as:
|
168 |
+
|
169 |
+
```php
|
170 |
+
[
|
171 |
+
'font_base' => 'Roboto',
|
172 |
+
'font_headings' => 'Playfair Display',
|
173 |
+
]
|
174 |
+
```
|
175 |
+
|
176 |
+
For this **input**:
|
177 |
+
```php
|
178 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
179 |
+
'font_base' => [
|
180 |
+
'type' => 'option',
|
181 |
+
'name' => [ 'jetpack_global_styles', 'font_base' ],
|
182 |
+
]
|
183 |
+
] );
|
184 |
+
```
|
185 |
+
|
186 |
+
The **output** of `$data_set->get_data()` will be:
|
187 |
+
|
188 |
+
```php
|
189 |
+
[
|
190 |
+
'font_base' => 'Roboto',
|
191 |
+
]
|
192 |
+
```
|
193 |
+
|
194 |
+
### Updatable Options
|
195 |
+
|
196 |
+
By default, options can't be updated and they won't be processed during the `$data_set->save_data( $new_data )` execution. For example, for this **input**:
|
197 |
+
|
198 |
+
```php
|
199 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
200 |
+
'site_name' => [
|
201 |
+
'type' => 'option',
|
202 |
+
'name' => 'blogname',
|
203 |
+
],
|
204 |
+
] );
|
205 |
+
$data_set->save_data(
|
206 |
+
[
|
207 |
+
'site_name' => 'A new site name'
|
208 |
+
]
|
209 |
+
);
|
210 |
+
```
|
211 |
+
|
212 |
+
By default, the `blogname` option value **won't be processed** so the new value will be discarded.
|
213 |
+
|
214 |
+
Sometimes, though, we do want to update options. This can done by using the `updatable` key. Following the example above we set the option as updatable:
|
215 |
+
|
216 |
+
```php
|
217 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
218 |
+
'site_name' => [
|
219 |
+
'type' => 'option',
|
220 |
+
'name' => 'blogname',
|
221 |
+
'updatable' => true,
|
222 |
+
],
|
223 |
+
] );
|
224 |
+
$data_set->save_data(
|
225 |
+
[
|
226 |
+
'site_name' => 'A new site name.'
|
227 |
+
]
|
228 |
+
);
|
229 |
+
```
|
230 |
+
|
231 |
+
In this case, the `blogname` will be updated with the new value.
|
232 |
+
|
233 |
+
If we were working with specific properties of the option instead:
|
234 |
+
|
235 |
+
```php
|
236 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
237 |
+
'font_base' => [
|
238 |
+
'type' => 'option',
|
239 |
+
'name' => [ 'jetpack_global_styles', 'font_base' ],
|
240 |
+
'updatable' => true,
|
241 |
+
],
|
242 |
+
] );
|
243 |
+
$data_set->save_data(
|
244 |
+
[
|
245 |
+
'font_base' => 'Domine'
|
246 |
+
]
|
247 |
+
);
|
248 |
+
```
|
249 |
+
|
250 |
+
The result will be that the `jetpack_global_styles` option will have its `font_base` property updated, while the rest will keep the same values.
|
251 |
+
|
252 |
+
### Filters to prepare and sanitize data
|
253 |
+
|
254 |
+
**The `\Automattic\Jetpack\Global_Styles\Data_Set` doesn't do any validation or sanitization**, it's the consumer responsibility to do so. There are two filters that can be used to prepare, filter, validate and sanitize your data:
|
255 |
+
|
256 |
+
- `jetpack_global_styles_data_set_get_data`: it runs as the last step of `get_data()` and receives the result of processing the data points, so plugins have the opportunity to further processing it to their needs before it's used anywhere else.
|
257 |
+
- `jetpack_global_styles_data_set_save_data`: it runs as the first step of `save_data( $new_data )`, so plugins have the opportunity to validate and sanitize the incoming data to their needs before it's saved to the database.
|
258 |
+
|
259 |
+
## Theme Data Points
|
260 |
+
|
261 |
+
Data points are considered to be of the *theme* kind if the property `type`'s value is `theme`.
|
262 |
+
|
263 |
+
**Input** being:
|
264 |
+
|
265 |
+
```php
|
266 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
267 |
+
'jetpack_global_styles' => [
|
268 |
+
'type' => 'theme',
|
269 |
+
'name' => 'jetpack-global-styles',
|
270 |
+
],
|
271 |
+
] );
|
272 |
+
```
|
273 |
+
|
274 |
+
This will pull data added via `add_theme_support` as in:
|
275 |
+
|
276 |
+
```php
|
277 |
+
add_theme_support(
|
278 |
+
'jetpack-global-styles'
|
279 |
+
[
|
280 |
+
'font_headings' => 'Ubuntu',
|
281 |
+
]
|
282 |
+
);
|
283 |
+
```
|
284 |
+
|
285 |
+
The **output** of `$data_set->get_data()` will be the value taken from theme support, or `null` if none was provided or the feature and/or property don't exist:
|
286 |
+
|
287 |
+
```php
|
288 |
+
[
|
289 |
+
'jetpack_global_styles' => [
|
290 |
+
'font_headings' => 'Ubuntu',
|
291 |
+
],
|
292 |
+
]
|
293 |
+
```
|
294 |
+
|
295 |
+
### Fallback Values
|
296 |
+
|
297 |
+
If the theme has declared support for a feature but hasn't provided any value, the output for that data point be `null`. In case you want to provide a fallback value, you can do so by using the `default` property.
|
298 |
+
|
299 |
+
**Input**:
|
300 |
+
|
301 |
+
```php
|
302 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
303 |
+
'jetpack_global_styles' => [
|
304 |
+
'type' => 'theme',
|
305 |
+
'name' => 'jetpack-global-styles',
|
306 |
+
'default' => [
|
307 |
+
'font_headings' => 'Lora',
|
308 |
+
],
|
309 |
+
],
|
310 |
+
] );
|
311 |
+
```
|
312 |
+
|
313 |
+
Being the `add_theme_support` declaration:
|
314 |
+
|
315 |
+
```php
|
316 |
+
add_theme_support( 'jetpack-global-styles' );
|
317 |
+
```
|
318 |
+
|
319 |
+
The **output** of `$data_set->get_data()` will be:
|
320 |
+
|
321 |
+
```php
|
322 |
+
[
|
323 |
+
'jetpack_global_styles' =>[
|
324 |
+
'font_headings' => 'Lora',
|
325 |
+
]
|
326 |
+
]
|
327 |
+
```
|
328 |
+
|
329 |
+
## Working with theme's properties
|
330 |
+
|
331 |
+
It is also possible to work with specific properties, unwrapping the theme support data.
|
332 |
+
|
333 |
+
**Input**:
|
334 |
+
|
335 |
+
```php
|
336 |
+
$data_set = new \Automattic\Jetpack\Global_Styles\Data_Set( [
|
337 |
+
'font_headings' => [
|
338 |
+
'type' => 'theme',
|
339 |
+
'name' => [ 'jetpack-global-styles', 'font_headings' ],
|
340 |
+
],
|
341 |
+
] );
|
342 |
+
```
|
343 |
+
|
344 |
+
Being the `add_theme_support` declaration:
|
345 |
+
|
346 |
+
```php
|
347 |
+
add_theme_support(
|
348 |
+
'jetpack-global-styles',
|
349 |
+
[
|
350 |
+
'font_base' => 'Chivo',
|
351 |
+
'font_headings' => 'Ubuntu',
|
352 |
+
]
|
353 |
+
);
|
354 |
+
|
355 |
+
```
|
356 |
+
|
357 |
+
The **output** of `$data_set->get_data()` will be:
|
358 |
+
|
359 |
+
```php
|
360 |
+
[
|
361 |
+
'font_headings' => 'Ubuntu',
|
362 |
+
]
|
363 |
+
```
|
global-styles/README.md
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Global Styles plugin <!-- omit in toc -->
|
2 |
+
|
3 |
+
This plugin creates a new sidebar for the block editor through which the users can update the styles site-wide, if the active theme has declared support. At the moment, users can set the base and headings fonts.
|
4 |
+
|
5 |
+
- [How to develop and build the plugin](#how-to-develop-and-build-the-plugin)
|
6 |
+
- [How it works and how themes can use it](#how-it-works-and-how-themes-can-use-it)
|
7 |
+
- [Fallbacks for browsers without support for CSS custom properties](#fallbacks-for-browsers-without-support-for-css-custom-properties)
|
8 |
+
- [How to add a "Theme Default" option to the font list](#how-to-add-a-theme-default-option-to-the-font-list)
|
9 |
+
- [How to use a fallback stylesheet (experimental)](#how-to-use-a-fallback-stylesheet-experimental)
|
10 |
+
- [Existing hooks](#existing-hooks)
|
11 |
+
- [jetpack_global_styles_data_set_get_data filter](#jetpack_global_styles_data_set_get_data-filter)
|
12 |
+
- [jetpack_global_styles_data_set_save_data filter](#jetpack_global_styles_data_set_save_data-filter)
|
13 |
+
- [jetpack_global_styles_permission_check_additional filter](#jetpack_global_styles_permission_check_additional-filter)
|
14 |
+
- [jetpack_global_styles_settings](#jetpack_global_styles_settings)
|
15 |
+
- [FAQ](#faq)
|
16 |
+
- [Which fonts are available?](#which-fonts-are-available)
|
17 |
+
- [What will happen when the user changes to another theme that supports GlobalStyles?](#what-will-happen-when-the-user-changes-to-another-theme-that-supports-globalstyles)
|
18 |
+
- [What will happen when the user changes to a theme that doesn't support Global Styles or the plugin is deactivated?](#what-will-happen-when-the-user-changes-to-a-theme-that-doesnt-support-global-styles-or-the-plugin-is-deactivated)
|
19 |
+
|
20 |
+
## How to develop and build the plugin
|
21 |
+
|
22 |
+
Refer to instructions in the top-level [Full Site Editing](https://github.com/automattic/wp-calypso/tree/master/apps/full-site-editing) directory.
|
23 |
+
|
24 |
+
## How it works and how themes can use it
|
25 |
+
|
26 |
+
This plugin creates a new sidebar for the block editor through which the users can update the styles site-wide. At the moment, users can set the base and headings fonts. For the sidebar to be shown, the active theme needs to have declared support:
|
27 |
+
|
28 |
+
```php
|
29 |
+
add_theme_support( 'jetpack-global-styles' );
|
30 |
+
```
|
31 |
+
|
32 |
+
The user choices are stored using the Options API in the WordPress database, and exposed in the block editor and the front end as CSS custom properties. For example, the base and headings fonts are exposed as `--font-base` and `--font-headings`, respectively.
|
33 |
+
|
34 |
+
The theme can then use those variables to set its styles:
|
35 |
+
|
36 |
+
```css
|
37 |
+
body {
|
38 |
+
font-family: var( --font-base, serif );
|
39 |
+
}
|
40 |
+
|
41 |
+
h1 {
|
42 |
+
font-family: var( --font-headings, sans-serif );
|
43 |
+
}
|
44 |
+
```
|
45 |
+
|
46 |
+
In the above example, the `body`'s font-family will be what the user selected as the base font, or `serif` if `--font-base` is not set. Likewise, the `h1`'s font-family will be what the user selected as the headings font, or `sans-serif` if `--font-headings` is not set.
|
47 |
+
|
48 |
+
**Fallback values for CSS Custom Properties**
|
49 |
+
|
50 |
+
Note the font-family fallbacks provided for when `--font-base` or `--font-headings` are not set. There are a number of situations where these variables can have the value `unset` or even not being present (which the browsers also consider as being `unset`):
|
51 |
+
|
52 |
+
- If the Global Styles plugin is not installed, activated, or the theme didn't declared support.
|
53 |
+
- If the Global Styles plugin is activated and the theme has declared support but:
|
54 |
+
- the user hasn't selected and saved any choice yet.
|
55 |
+
- the user has selected _Theme Default_ as the font.
|
56 |
+
|
57 |
+
By adding fallbacks for these situations, themes can work with or without Global Styles using the same styles. They also provide a better experience to users with good defaults that are overwritten by user's choices when necessary. This is the recommended way to use the Global Styles plugin.
|
58 |
+
|
59 |
+
What would happen if no fallback is provided?
|
60 |
+
|
61 |
+
```css
|
62 |
+
body {
|
63 |
+
font-family: var( --font-base );
|
64 |
+
}
|
65 |
+
|
66 |
+
h1 {
|
67 |
+
font-family: var( --font-headings );
|
68 |
+
}
|
69 |
+
```
|
70 |
+
|
71 |
+
In the above example, the `body`'s font-family will be what the user selected as the base font, or `inherit` if `--font-base` is not set. Likewise, the `h1`'s font-family will be what the user selected as the headings font, or `inherit` if `--font-headings` is not set.
|
72 |
+
|
73 |
+
For more info on CSS Custom Properties, check out:
|
74 |
+
|
75 |
+
- [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/--*).
|
76 |
+
- [CSS Working Group specification](https://drafts.csswg.org/css-variables/#defining-variables).
|
77 |
+
- The [unset](https://drafts.csswg.org/css-cascade-4/#valdef-all-unset) keyword.
|
78 |
+
|
79 |
+
### Fallbacks for browsers without support for CSS custom properties
|
80 |
+
|
81 |
+
Browsers that don't support CSS custom properties don't know what to do with the `var` statement (neither the fallback within), so they ignore it. We can leverage this to provide fallbacks for them as well:
|
82 |
+
|
83 |
+
```css
|
84 |
+
body {
|
85 |
+
font-family: serif; // Fallback for browsers without support.
|
86 |
+
font-family: var( --font-base, serif ); // Variable and fallback for browsers with support.
|
87 |
+
}
|
88 |
+
|
89 |
+
h1 {
|
90 |
+
font-family: sans-serif; // Fallback for browsers without support.
|
91 |
+
font-family: var( --font-headings, sans-serif ); // Variable and fallback for browsers with support.
|
92 |
+
}
|
93 |
+
```
|
94 |
+
|
95 |
+
### How to add a "Theme Default" option to the font list
|
96 |
+
|
97 |
+
Themes can opt-in to add a _Theme Default_ option via the `enable_theme_default` parameter:
|
98 |
+
|
99 |
+
```php
|
100 |
+
add_theme_support(
|
101 |
+
'jetpack-global-styles',
|
102 |
+
[
|
103 |
+
'enable_theme_default' => true,
|
104 |
+
]
|
105 |
+
);
|
106 |
+
```
|
107 |
+
|
108 |
+
This will add a new option in the font picker called _Theme Default_. If the user hasn't selected any yet, it will be the active option by default (if the theme didn't add this option, the _System Font_ will be picked instead). When _Theme Default_ is active, the corresponding CSS custom property value will be `unset`.
|
109 |
+
|
110 |
+
For example, if the user selects:
|
111 |
+
|
112 |
+
- the base font to _Theme Default_, then `--font-base` value will be `unset`
|
113 |
+
- the headings font to _Lora_, then `--font-headings` value will be `Lora`
|
114 |
+
|
115 |
+
Essentially, the _Theme Default_ option is how an user would reset their choices and get back the theme default styles. We recommend adding this option and using fallbacks in the CSS custom properties declarations.
|
116 |
+
|
117 |
+
### How to use a fallback stylesheet (experimental)
|
118 |
+
|
119 |
+
As an experimental feature, the Global Styles plugin can provide a fallback stylesheet that uses the CSS custom properties. This is so themes can use Global Styles without introducing any changes to its own stylesheet.
|
120 |
+
|
121 |
+
```php
|
122 |
+
add_theme_support(
|
123 |
+
'jetpack-global-styles',
|
124 |
+
[
|
125 |
+
'enqueue_experimental_styles' => true,
|
126 |
+
]
|
127 |
+
);
|
128 |
+
```
|
129 |
+
|
130 |
+
If the `enqueue_experimental_styles` is present and it's `true`, the plugin will enqueue a fallback stylesheet that overrides the theme's. This feature is experimental. The overrides can't take into account all the ways that themes can present information (different tags, classes, etc.), so themes are responsible to check these are enough for its use case.
|
131 |
+
|
132 |
+
Note that if the theme requests enqueueing the experimental stylesheet, the experimental Global Styles styles will override the theme ones once the plugin is activated. By default, until the user makes a font choice, the _System Font_ will be used.
|
133 |
+
|
134 |
+
**_Theme Default_ option**
|
135 |
+
|
136 |
+
Themes that use this experimental feature can also add a _Theme Default_ option in the font picker by setting the `enable_theme_default` property to true. Note that when the user selects _Theme Default_ the font to be used is _System Font_. Per se, this isn't very useful, however, themes can also provide fallback fonts for when the font is `unset` (the user selected _Theme Default_ or hasn't made any choice yet):
|
137 |
+
|
138 |
+
```php
|
139 |
+
add_theme_support(
|
140 |
+
'jetpack-global-styles',
|
141 |
+
[
|
142 |
+
'enqueue_experimental_styles' => true,
|
143 |
+
'enable_theme_default' => true,
|
144 |
+
'font_base' => 'serif',
|
145 |
+
'font_headings' => 'sans-serif',
|
146 |
+
]
|
147 |
+
);
|
148 |
+
```
|
149 |
+
|
150 |
+
## Existing hooks
|
151 |
+
|
152 |
+
### jetpack_global_styles_data_set_get_data filter
|
153 |
+
|
154 |
+
See [README-DATA.md](./README-DATA.md).
|
155 |
+
|
156 |
+
### jetpack_global_styles_data_set_save_data filter
|
157 |
+
|
158 |
+
See [README-DATA.md](./README-DATA.md).
|
159 |
+
|
160 |
+
### jetpack_global_styles_permission_check_additional filter
|
161 |
+
|
162 |
+
This filter can be used to add _an additional check_ to decide whether 1) the global styles sidebar is enqueued and 2) the REST API endpoint should return the data. Note the existing checks in place:
|
163 |
+
|
164 |
+
- The user is logged in and has the `customize` capability.
|
165 |
+
- The site uses a theme that has declared support for `jetpack-global-styles`.
|
166 |
+
|
167 |
+
```php
|
168 |
+
function permission_check_callback( $has_permissions ) {
|
169 |
+
if ( $some_condition ) {
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
return $has_permissions;
|
173 |
+
}
|
174 |
+
add_filter( 'jetpack_global_styles_permission_check_additional', permission_check_callback );
|
175 |
+
```
|
176 |
+
|
177 |
+
### jetpack_global_styles_settings
|
178 |
+
|
179 |
+
This filter can be used to configure any of the Global Styles settings.
|
180 |
+
|
181 |
+
REST API related:
|
182 |
+
|
183 |
+
- `rest_namespace`: REST API namespace.
|
184 |
+
- `rest_route`: REST API route.
|
185 |
+
- `rest_path_client`: the path to be used by the client to query the endpoint.
|
186 |
+
|
187 |
+
To white-label Global Styles:
|
188 |
+
|
189 |
+
- `theme_support`: the name of the theme support feature.
|
190 |
+
- `option_name`: the name of the option to use in the database.
|
191 |
+
- `redux_store_name`: the name of the custom Redux store used by the client.
|
192 |
+
- `plugin_name`: the name of the registered plugin for the block editor.
|
193 |
+
|
194 |
+
## FAQ
|
195 |
+
|
196 |
+
### Which fonts are available?
|
197 |
+
|
198 |
+
These are the fonts available via the font selector in the sidebar and for the themes to set as defaults:
|
199 |
+
|
200 |
+
- Arvo
|
201 |
+
- Cabin
|
202 |
+
- Chivo
|
203 |
+
- Domine
|
204 |
+
- Fira Sans
|
205 |
+
- Libre Baskerville
|
206 |
+
- Libre Franklin
|
207 |
+
- Lora
|
208 |
+
- Merriweather
|
209 |
+
- Montserrat
|
210 |
+
- Open Sans
|
211 |
+
- Playfair Display
|
212 |
+
- Poppins
|
213 |
+
- Roboto
|
214 |
+
- Roboto Slab
|
215 |
+
- Rubik
|
216 |
+
- Source Sans Pro
|
217 |
+
- Source Serif Pro
|
218 |
+
- Space Mono
|
219 |
+
- Work Sans
|
220 |
+
|
221 |
+
### What will happen when the user changes to another theme that supports GlobalStyles?
|
222 |
+
|
223 |
+
Everything will continue to work as expected. If the user had selected:
|
224 |
+
|
225 |
+
- The _Theme Default_ option, the new theme's font will be used instead of the old one.
|
226 |
+
- A _custom font_, it'll still be used in the new theme. Note, however, that themes can make different choices as to what they consider base and font selections. For example: a theme can use the headings font for quotes and another theme can use the base font.
|
227 |
+
|
228 |
+
### What will happen when the user changes to a theme that doesn't support Global Styles or the plugin is deactivated?
|
229 |
+
|
230 |
+
The theme's font will be used.
|
global-styles/class-global-styles.php
ADDED
@@ -0,0 +1,511 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Global Styles file.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Global_Styles
|
12 |
+
*/
|
13 |
+
class Global_Styles {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Class instance.
|
17 |
+
*
|
18 |
+
* @var \Automattic\Jetpack\Global_Styles\Global_Styles
|
19 |
+
*/
|
20 |
+
private static $instance = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Holds the internal data description to be exposed through REST API.
|
24 |
+
*
|
25 |
+
* @var \Automattic\Jetpack\Global_Styles\Data_Set
|
26 |
+
*/
|
27 |
+
private $rest_api_data;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Namespace to use for the REST Endpoint.
|
31 |
+
* This can be overrided at initialization.
|
32 |
+
*
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
private $rest_namespace = 'jetpack-global-styles/v1';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Route to use for the REST Route.
|
39 |
+
* This can be overrided at initialization.
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
private $rest_route = 'options';
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Path the client will use to work with the options.
|
47 |
+
* This can be overrided at initialization.
|
48 |
+
*
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
private $rest_path_client = 'jetpack-global-styles/v1/options';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Undocumented variable
|
55 |
+
*
|
56 |
+
* @var string
|
57 |
+
*/
|
58 |
+
private $theme_support = 'jetpack-global-styles';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Undocumented variable
|
62 |
+
*
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
private $option_name = 'jetpack_global_styles';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Undocumented variable
|
69 |
+
*
|
70 |
+
* @var string
|
71 |
+
*/
|
72 |
+
private $redux_store_name = 'jetpack/global-styles';
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Undocumented variable
|
76 |
+
*
|
77 |
+
* @var string
|
78 |
+
*/
|
79 |
+
private $plugin_name = 'jetpack-global-styles';
|
80 |
+
|
81 |
+
const VERSION = '1909241817';
|
82 |
+
|
83 |
+
const SYSTEM_FONT = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif';
|
84 |
+
const AVAILABLE_FONTS = [
|
85 |
+
[
|
86 |
+
'label' => 'Theme Default',
|
87 |
+
'value' => 'unset',
|
88 |
+
],
|
89 |
+
[
|
90 |
+
'label' => 'System Font',
|
91 |
+
'value' => self::SYSTEM_FONT,
|
92 |
+
],
|
93 |
+
'Arvo',
|
94 |
+
'Cabin',
|
95 |
+
'Chivo',
|
96 |
+
'Domine',
|
97 |
+
'Fira Sans',
|
98 |
+
'Libre Baskerville',
|
99 |
+
'Libre Franklin',
|
100 |
+
'Lora',
|
101 |
+
'Merriweather',
|
102 |
+
'Montserrat',
|
103 |
+
'Open Sans',
|
104 |
+
'Playfair Display',
|
105 |
+
'Poppins',
|
106 |
+
'Roboto',
|
107 |
+
'Roboto Slab',
|
108 |
+
'Rubik',
|
109 |
+
'Source Sans Pro',
|
110 |
+
'Source Serif Pro',
|
111 |
+
'Space Mono',
|
112 |
+
'Work Sans',
|
113 |
+
];
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Creates instance.
|
117 |
+
*
|
118 |
+
* @return \Automattic\Jetpack\Global_Styles\Global_Styles
|
119 |
+
*/
|
120 |
+
public static function init() {
|
121 |
+
if ( is_null( self::$instance ) ) {
|
122 |
+
self::$instance = new self();
|
123 |
+
}
|
124 |
+
|
125 |
+
return self::$instance;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Global Styles setup.
|
130 |
+
*/
|
131 |
+
public function __construct() {
|
132 |
+
$this->update_plugin_settings();
|
133 |
+
|
134 |
+
// DATA TO EXPOSE THROUGH THE REST API.
|
135 |
+
require_once __DIR__ . '/includes/class-data-set.php';
|
136 |
+
$this->rest_api_data = new Data_Set(
|
137 |
+
[
|
138 |
+
'blogname' => [
|
139 |
+
'type' => 'option',
|
140 |
+
'name' => 'blogname',
|
141 |
+
'default' => 'Your site name',
|
142 |
+
],
|
143 |
+
'font_base' => [
|
144 |
+
'type' => 'option',
|
145 |
+
'name' => [ 'jetpack_global_styles', 'font_base' ],
|
146 |
+
'default' => 'unset',
|
147 |
+
'updatable' => true,
|
148 |
+
],
|
149 |
+
'font_headings' => [
|
150 |
+
'type' => 'option',
|
151 |
+
'name' => [ 'jetpack_global_styles', 'font_headings' ],
|
152 |
+
'default' => 'unset',
|
153 |
+
'updatable' => true,
|
154 |
+
],
|
155 |
+
'font_base_default' => [
|
156 |
+
'type' => 'theme',
|
157 |
+
'name' => [ 'jetpack-global-styles', 'font_base' ],
|
158 |
+
'default' => self::SYSTEM_FONT,
|
159 |
+
],
|
160 |
+
'font_headings_default' => [
|
161 |
+
'type' => 'theme',
|
162 |
+
'name' => [ 'jetpack-global-styles', 'font_headings' ],
|
163 |
+
'default' => self::SYSTEM_FONT,
|
164 |
+
],
|
165 |
+
'font_options' => [
|
166 |
+
'type' => 'literal',
|
167 |
+
'default' => self::AVAILABLE_FONTS,
|
168 |
+
],
|
169 |
+
'font_pairings' => [
|
170 |
+
'type' => 'literal',
|
171 |
+
'default' => [
|
172 |
+
[
|
173 |
+
'label' => 'Playfair Display & Roboto',
|
174 |
+
'headings' => 'Playfair Display',
|
175 |
+
'base' => 'Roboto',
|
176 |
+
'preview' => 'PLAY_ROBOTO', // See font-pairings-panel-previews.js.
|
177 |
+
],
|
178 |
+
[
|
179 |
+
'label' => 'Rubik & Work Sans',
|
180 |
+
'headings' => 'Rubik',
|
181 |
+
'base' => 'Work Sans',
|
182 |
+
'preview' => 'RUBIK_WORK', // See font-pairings-panel-previews.js.
|
183 |
+
],
|
184 |
+
[
|
185 |
+
'label' => 'System Font & Libre Baskerville',
|
186 |
+
'headings' => self::SYSTEM_FONT,
|
187 |
+
'base' => 'Libre Baskerville',
|
188 |
+
'preview' => 'SYSTEM_BASKER', // See font-pairings-panel-previews.js.
|
189 |
+
],
|
190 |
+
[
|
191 |
+
'label' => 'Space Mono & Lora',
|
192 |
+
'headings' => 'Space Mono',
|
193 |
+
'base' => 'Lora',
|
194 |
+
'preview' => 'SPACE_LORA', // See font-pairings-panel-previews.js.
|
195 |
+
],
|
196 |
+
],
|
197 |
+
],
|
198 |
+
]
|
199 |
+
);
|
200 |
+
|
201 |
+
// Setup REST API for the editor. Some environments (WordPress.com)
|
202 |
+
// may not load the theme functions for REST API calls,
|
203 |
+
// so we need to initialize it independently of theme support.
|
204 |
+
add_action( 'rest_api_init', [ $this, 'rest_api_init' ] );
|
205 |
+
|
206 |
+
add_filter( 'jetpack_global_styles_data_set_get_data', [ $this, 'maybe_filter_font_list' ] );
|
207 |
+
add_filter( 'jetpack_global_styles_data_set_save_data', [ $this, 'filter_and_validate_font_options' ] );
|
208 |
+
|
209 |
+
if ( $this->can_use_global_styles() ) {
|
210 |
+
// Setup editor.
|
211 |
+
add_action(
|
212 |
+
'enqueue_block_editor_assets',
|
213 |
+
[ $this, 'enqueue_block_editor_assets' ]
|
214 |
+
);
|
215 |
+
add_filter(
|
216 |
+
'block_editor_settings',
|
217 |
+
[ $this, 'block_editor_settings' ],
|
218 |
+
PHP_INT_MAX // So it runs last and overrides any style provided by the theme.
|
219 |
+
);
|
220 |
+
|
221 |
+
// Setup front-end.
|
222 |
+
add_action(
|
223 |
+
'wp_enqueue_scripts',
|
224 |
+
[ $this, 'wp_enqueue_scripts' ],
|
225 |
+
PHP_INT_MAX // So it runs last and overrides any style provided by the theme.
|
226 |
+
);
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Let 3rd parties configure plugin settings.
|
232 |
+
*/
|
233 |
+
private function update_plugin_settings() {
|
234 |
+
$settings = apply_filters(
|
235 |
+
'jetpack_global_styles_settings',
|
236 |
+
[
|
237 |
+
// Server-side settings.
|
238 |
+
'rest_namespace' => $this->rest_namespace,
|
239 |
+
'rest_route' => $this->rest_route,
|
240 |
+
'theme_support' => $this->theme_support,
|
241 |
+
'option_name' => $this->option_name,
|
242 |
+
// Client-side settings.
|
243 |
+
'rest_path_client' => $this->rest_path_client,
|
244 |
+
'redux_store_name' => $this->redux_store_name,
|
245 |
+
'plugin_name' => $this->plugin_name,
|
246 |
+
]
|
247 |
+
);
|
248 |
+
|
249 |
+
$this->rest_namespace = $settings['rest_namespace'];
|
250 |
+
$this->rest_route = $settings['rest_route'];
|
251 |
+
$this->theme_support = $settings['theme_support'];
|
252 |
+
$this->option_name = $settings['option_name'];
|
253 |
+
$this->rest_path_client = $settings['rest_path_client'];
|
254 |
+
$this->redux_store_name = $settings['redux_store_name'];
|
255 |
+
$this->plugin_name = $settings['plugin_name'];
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Initialize REST API endpoint.
|
260 |
+
*/
|
261 |
+
public function rest_api_init() {
|
262 |
+
require_once __DIR__ . '/includes/class-json-endpoint.php';
|
263 |
+
$rest_api = new JSON_Endpoint(
|
264 |
+
$this->rest_namespace,
|
265 |
+
$this->rest_route,
|
266 |
+
$this->rest_api_data,
|
267 |
+
[ $this, 'can_use_global_styles' ]
|
268 |
+
);
|
269 |
+
$rest_api->setup();
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Whether we should load Global Styles
|
274 |
+
* per this user and site.
|
275 |
+
*
|
276 |
+
* @return boolean
|
277 |
+
*/
|
278 |
+
public function can_use_global_styles() {
|
279 |
+
return is_user_logged_in() &&
|
280 |
+
current_user_can( 'customize' ) &&
|
281 |
+
current_theme_supports( $this->theme_support ) &&
|
282 |
+
apply_filters( 'jetpack_global_styles_permission_check_additional', true );
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* We want the front-end styles enqueued in the editor
|
287 |
+
* and wrapped by the .editor-styles-wrapper class,
|
288 |
+
* so they don't bleed into other parts of the editor.
|
289 |
+
*
|
290 |
+
* We also want the global styles to override the theme's stylesheet.
|
291 |
+
* We do so by hooking into the block_editor_settings
|
292 |
+
* and append this style the last.
|
293 |
+
*
|
294 |
+
* @param array $settings The editor settings.
|
295 |
+
*
|
296 |
+
* @return $settings array with the inline styles added.
|
297 |
+
*/
|
298 |
+
public function block_editor_settings( $settings ) {
|
299 |
+
if ( empty( $settings['styles'] ) || ! is_array( $settings['styles'] ) ) {
|
300 |
+
$settings['styles'] = array();
|
301 |
+
}
|
302 |
+
|
303 |
+
// Append them last, so it overrides any existing inline styles.
|
304 |
+
$settings['styles'][] = array(
|
305 |
+
'css' => $this->get_inline_css(),
|
306 |
+
);
|
307 |
+
|
308 |
+
return $settings;
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Enqueues the assets for the editor.
|
313 |
+
*
|
314 |
+
* @return void
|
315 |
+
*/
|
316 |
+
public function enqueue_block_editor_assets() {
|
317 |
+
$asset_file = plugin_dir_path( __FILE__ ) . 'dist/global-styles.asset.php';
|
318 |
+
$asset = file_exists( $asset_file )
|
319 |
+
? require_once $asset_file
|
320 |
+
: null;
|
321 |
+
$dependencies = isset( $asset['dependencies'] ) ?
|
322 |
+
$asset['dependencies'] :
|
323 |
+
[];
|
324 |
+
$version = isset( $asset['version'] ) ?
|
325 |
+
$asset['version'] :
|
326 |
+
filemtime( plugin_dir_path( __FILE__ ) . 'dist/global-styles.js' );
|
327 |
+
|
328 |
+
wp_enqueue_script(
|
329 |
+
'jetpack-global-styles-editor-script',
|
330 |
+
plugins_url( 'dist/global-styles.js', __FILE__ ),
|
331 |
+
$dependencies,
|
332 |
+
$version,
|
333 |
+
true
|
334 |
+
);
|
335 |
+
wp_localize_script(
|
336 |
+
'jetpack-global-styles-editor-script',
|
337 |
+
'JETPACK_GLOBAL_STYLES_EDITOR_CONSTANTS',
|
338 |
+
[
|
339 |
+
'PLUGIN_NAME' => $this->plugin_name,
|
340 |
+
'REST_PATH' => $this->rest_path_client,
|
341 |
+
'STORE_NAME' => $this->redux_store_name,
|
342 |
+
]
|
343 |
+
);
|
344 |
+
wp_enqueue_style(
|
345 |
+
'jetpack-global-styles-editor-style',
|
346 |
+
plugins_url( 'dist/global-styles.css', __FILE__ ),
|
347 |
+
[],
|
348 |
+
filemtime( plugin_dir_path( __FILE__ ) . 'dist/global-styles.css' )
|
349 |
+
);
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Enqueues the assets for front-end.
|
354 |
+
*
|
355 |
+
* We want the global styles to override the theme's stylesheet,
|
356 |
+
* that's why they are inlined.
|
357 |
+
*
|
358 |
+
* @return void
|
359 |
+
*/
|
360 |
+
public function wp_enqueue_scripts() {
|
361 |
+
wp_enqueue_style(
|
362 |
+
'jetpack-global-styles-frontend-style',
|
363 |
+
plugins_url( 'static/blank.css', __FILE__ ),
|
364 |
+
[],
|
365 |
+
self::VERSION // To bust cache when changes are done to font list, css custom vars, or style.css.
|
366 |
+
);
|
367 |
+
wp_add_inline_style( 'jetpack-global-styles-frontend-style', $this->get_inline_css( true ) );
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Prepare the inline CSS.
|
372 |
+
*
|
373 |
+
* @param boolean $only_selected_fonts Whether it should load all the fonts or only the selected. False by default.
|
374 |
+
* @return string
|
375 |
+
*/
|
376 |
+
private function get_inline_css( $only_selected_fonts = false ) {
|
377 |
+
$result = '';
|
378 |
+
|
379 |
+
$data = $this->rest_api_data->get_data();
|
380 |
+
|
381 |
+
/*
|
382 |
+
* Add the fonts we need:
|
383 |
+
*
|
384 |
+
* - all of them for the backend
|
385 |
+
* - only the selected ones for the frontend
|
386 |
+
*/
|
387 |
+
$font_list = [];
|
388 |
+
// We want $font_list to only contain valid Google Font values, not things like 'unset'.
|
389 |
+
$font_values = array_diff( $this->get_font_values( $data['font_options'] ), [ 'unset' ] );
|
390 |
+
if ( true === $only_selected_fonts ) {
|
391 |
+
foreach ( [ 'font_base', 'font_base_default', 'font_headings', 'font_headings_default' ] as $key ) {
|
392 |
+
if ( in_array( $data[ $key ], $font_values, true ) ) {
|
393 |
+
$font_list[] = $data[ $key ];
|
394 |
+
}
|
395 |
+
}
|
396 |
+
} else {
|
397 |
+
$font_list = $font_values;
|
398 |
+
}
|
399 |
+
$font_list_str = '';
|
400 |
+
foreach ( $font_list as $font ) {
|
401 |
+
// Some fonts lack italic variants,
|
402 |
+
// the API will return only the regular and bold CSS for those.
|
403 |
+
$font_list_str = $font_list_str . $font . ':regular,bold,italic,bolditalic|';
|
404 |
+
}
|
405 |
+
$result = $result . "@import url('https://fonts.googleapis.com/css?family=" . $font_list_str . "');";
|
406 |
+
|
407 |
+
/*
|
408 |
+
* Add the CSS custom properties.
|
409 |
+
*
|
410 |
+
* Note that we transform var_name into var-name,
|
411 |
+
* so the output is:
|
412 |
+
*
|
413 |
+
* :root{
|
414 |
+
* --var-name-1: value;
|
415 |
+
* --var-name-2: value;
|
416 |
+
* }
|
417 |
+
*
|
418 |
+
*/
|
419 |
+
$result = $result . ':root {';
|
420 |
+
$value = '';
|
421 |
+
$keys = [ 'font_headings', 'font_base', 'font_headings_default', 'font_base_default' ];
|
422 |
+
foreach ( $keys as $key ) {
|
423 |
+
$value = $data[ $key ];
|
424 |
+
$result = $result . ' --' . str_replace( '_', '-', $key ) . ': ' . $value . ';';
|
425 |
+
}
|
426 |
+
$result = $result . '}';
|
427 |
+
|
428 |
+
/*
|
429 |
+
* If the theme opts-in, also add a default stylesheet
|
430 |
+
* that uses the CSS custom properties.
|
431 |
+
*
|
432 |
+
* This is a fallback mechanism in case there are themes
|
433 |
+
* we don't want to / can't migrate to use CSS vars.
|
434 |
+
*/
|
435 |
+
$theme_support = get_theme_support( $this->theme_support )[0];
|
436 |
+
if (
|
437 |
+
is_array( $theme_support ) &&
|
438 |
+
array_key_exists( 'enqueue_experimental_styles', $theme_support ) &&
|
439 |
+
true === $theme_support['enqueue_experimental_styles']
|
440 |
+
) {
|
441 |
+
$result = $result . file_get_contents( plugin_dir_path( __FILE__ ) . 'static/style.css', true );
|
442 |
+
}
|
443 |
+
|
444 |
+
return $result;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Callback for get data filter.
|
449 |
+
*
|
450 |
+
* @param array $result Data to be sent through the REST API.
|
451 |
+
*
|
452 |
+
* @return array Filtered result.
|
453 |
+
*/
|
454 |
+
public function maybe_filter_font_list( $result ) {
|
455 |
+
$theme_defaults = get_theme_support( $this->theme_support )[0];
|
456 |
+
if (
|
457 |
+
array_key_exists( 'font_options', $result ) &&
|
458 |
+
(
|
459 |
+
! is_array( $theme_defaults ) ||
|
460 |
+
! array_key_exists( 'enable_theme_default', $theme_defaults ) ||
|
461 |
+
true !== $theme_defaults['enable_theme_default']
|
462 |
+
)
|
463 |
+
) {
|
464 |
+
$result['font_options'] = array_slice( $result['font_options'], 1 );
|
465 |
+
}
|
466 |
+
|
467 |
+
return $result;
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Return the list of available font values.
|
472 |
+
*
|
473 |
+
* @param array $font_list Array of fonts to process.
|
474 |
+
* @return array Font values.
|
475 |
+
*/
|
476 |
+
private function get_font_values( $font_list ) {
|
477 |
+
$font_values = [];
|
478 |
+
foreach ( $font_list as $font ) {
|
479 |
+
if ( is_array( $font ) ) {
|
480 |
+
$font_values[] = $font['value'];
|
481 |
+
} else {
|
482 |
+
$font_values[] = $font;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
return $font_values;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Callback for save data filter.
|
490 |
+
*
|
491 |
+
* @param array $incoming_data The data to validate.
|
492 |
+
* @return array Filtered result.
|
493 |
+
*/
|
494 |
+
public function filter_and_validate_font_options( $incoming_data ) {
|
495 |
+
$result = [];
|
496 |
+
|
497 |
+
$font_values = $this->get_font_values( self::AVAILABLE_FONTS );
|
498 |
+
foreach ( [ 'font_base', 'font_headings' ] as $key ) {
|
499 |
+
if (
|
500 |
+
array_key_exists( $key, $incoming_data ) &&
|
501 |
+
in_array( $incoming_data[ $key ], $font_values, true )
|
502 |
+
) {
|
503 |
+
$result[ $key ] = $incoming_data[ $key ];
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
return $result;
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
+
add_action( 'init', [ __NAMESPACE__ . '\Global_Styles', 'init' ] );
|
global-styles/dist/global-styles.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-polyfill'), 'version' => 'd671a04c2e31e2b03d104470194779c6');
|
global-styles/dist/global-styles.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.global-styles-sidebar .components-select-control__input{line-height:1;font-size:18px;height:36px}.global-styles-sidebar h3{margin:0 0 1em}.global-styles-sidebar__panel-action-buttons{display:flex;justify-content:flex-end;margin-bottom:96px}.global-styles-sidebar__publish-button{margin-left:1em}.font-pairings-panel{cursor:pointer;border-radius:4px;padding:4px;margin-bottom:.5em}.font-pairings-panel.is-selected{box-shadow:0 0 0 2px #555d66}.font-pairings-panel:focus{box-shadow:0 0 0 2px #00a0d2}.font-pairings-panel:hover{background-color:#f3f4f5;color:#191e23}.font-pairings-panel__preview{border:1px solid rgba(25,30,35,.2);border-radius:4px;background-color:#fff;padding:4px}.font-pairings-panel__preview h1,.font-pairings-panel__preview p{margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:10px 0}.font-pairings-panel__preview svg{display:block;width:100%;height:auto}.font-pairings-panel__label{text-align:center;margin-bottom:0}
|
global-styles/dist/global-styles.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(c){if(t[c])return t[c].exports;var a=t[c]={i:c,l:!1,exports:{}};return e[c].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,c){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(n.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(c,a,function(t){return e[t]}.bind(null,a));return c},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){!function(){e.exports=this.wp.editPost}()},function(e,t,n){var c=n(4);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,c)}return n}e.exports=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(n,!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},function(e,t){!function(){e.exports=this.wp.apiFetch}()},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t){!function(){e.exports=this.wp.domReady}()},function(e,t){!function(){e.exports=this.wp.keycodes}()},function(e,t,n){var c;
|
2 |
+
/*!
|
3 |
+
Copyright (c) 2017 Jed Watson.
|
4 |
+
Licensed under the MIT License (MIT), see
|
5 |
+
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var c=arguments[t];if(c){var r=typeof c;if("string"===r||"number"===r)e.push(c);else if(Array.isArray(c)&&c.length){var l=a.apply(null,c);l&&e.push(l)}else if("object"===r)for(var o in c)n.call(c,o)&&c[o]&&e.push(o)}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(c=function(){return a}.apply(t,[]))||(e.exports=c)}()},function(e,t,n){},function(e,t,n){"use strict";n.r(t);var c,a,r,l,o=n(8),s=n(3),i=n(9),u=n(6),h=n.n(u),f=n(7),p=n.n(f),v={},b=!1,m={publishOptions:regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,{type:"IO_PUBLISH_OPTIONS",options:t};case 2:return e.abrupt("return",{type:"PUBLISH_OPTIONS",options:t});case 3:case"end":return e.stop()}}),e)})),updateOptions:function(e){return{type:"UPDATE_OPTIONS",options:e}},fetchOptions:function(){return{type:"IO_FETCH_OPTIONS"}},resetLocalChanges:function(){return{type:"RESET_OPTIONS",options:v}}},O=n(10),d=n.n(O),g=n(4),j=n.n(g),_=n(0),E=n(5),z=n(1),y=n(2),P=n(11),w=n(12),V=n.n(w),S=function(e){var t=e.unsupportedFeature;return Object(_.createElement)("p",null,Object(y.sprintf)(Object(y.__)("Your active theme doesn't support %s."),t))},H=function(e,t,n){switch(e){case"SPACE_LORA":return Object(_.createElement)(z.SVG,{width:"232",height:"132",viewBox:"0 0 232 132",xmlns:"http://www.w3.org/2000/svg"},Object(_.createElement)(z.Path,{fill:"#fa4d4b",d:"M0 0h232v132H0z"}),Object(_.createElement)(z.Path,{d:"M24.1 62c-3.6-2.9-8.9-5-15.8-6.3-2.8-.5-5-1-6.9-1.6-.5-.2-1-.3-1.5-.5v12.5c1.4.3 2.9.6 4.4.9 2.5.4 4.6 1 6.2 1.6s2.9 1.3 3.9 2.2c.9.8 1.6 1.6 2 2.6.4.9.6 1.9.6 3 0 2.3-.9 4.2-2.7 5.8-1.8 1.6-4.6 2.4-8.4 2.4-2.2 0-4.2-.3-5.9-.8v12c1.8.3 3.7.4 5.7.4 3.7 0 7-.5 10-1.4 2.9-.9 5.5-2.3 7.5-4s3.6-3.9 4.7-6.3c1.1-2.5 1.7-5.3 1.7-8.4V75c0-5.7-1.8-10-5.5-13zM12.9 42.5c2.1 1.9 3.1 4.2 3.1 6.9v2.3h12.4v-3.4c0-2.7-.5-5.3-1.6-7.7-1-2.4-2.5-4.6-4.6-6.5-2-1.9-4.5-3.4-7.5-4.4-3-1.1-6.5-1.7-10.3-1.7-1.5 0-3 .1-4.4.3v11.9c1.3-.4 2.7-.5 4.4-.5 3.7-.2 6.5.8 8.5 2.8zm67.9 10.9c-1.8-2.1-4-3.6-6.5-4.7-2.4-1.1-5-1.6-7.8-1.6-3.7 0-6.7.7-9.1 2.2-2.4 1.4-4.2 3.4-5.5 5.9h-1.7v-6.8H38.4v65.4h11.8V88.2H52c.6 1.1 1.2 2.1 2 3.1.8.9 1.8 1.8 2.9 2.5 1.2.8 2.6 1.3 4.1 1.8 1.6.4 3.4.7 5.5.7 2.9 0 5.5-.5 8-1.5 2.5-1.1 4.7-2.6 6.5-4.6 1.8-2.1 3.3-4.6 4.3-7.5 1.1-2.9 1.6-6.3 1.6-10.2v-1.7c0-3.8-.6-7.1-1.7-10.1-1-2.9-2.5-5.3-4.4-7.3zm-5.7 18.9c0 3.9-1.2 7.1-3.5 9.4-2.3 2.3-5.2 3.4-8.9 3.4s-6.7-1.2-9-3.5c-2.3-2.4-3.4-5.5-3.4-9.3v-1.1c0-3.8 1.1-6.9 3.4-9.2 2.3-2.4 5.3-3.6 9-3.6s6.7 1.2 8.9 3.5c2.3 2.3 3.5 5.4 3.5 9.3v1.1zm66.2 8.6V48.4h-11.8V54h-1.7c-1.2-2.4-2.8-4.1-4.9-5.3-2-1.1-4.7-1.7-8-1.7-2.8 0-5.4.6-7.8 1.7-2.4 1.1-4.5 2.6-6.3 4.7-1.8 2.1-3.3 4.6-4.3 7.6-1.1 2.9-1.6 6.3-1.6 10v1.5c0 3.8.5 7.1 1.6 10.1 1.1 2.9 2.6 5.5 4.5 7.5 1.9 2.1 4 3.6 6.5 4.7s5.2 1.6 8 1.6c3 0 5.6-.6 7.9-1.8 2.3-1.3 4-3.4 5.3-6.3h1.7c0 2 .7 3.6 2 4.9 1.4 1.3 3.1 1.9 5.3 1.9h8.1V83.7H144c-1.8 0-2.7-.9-2.7-2.8zm-11.8-8.6c0 3.9-1 7.1-3.1 9.4-2.1 2.3-4.8 3.4-8.3 3.4-3.4 0-6.2-1.1-8.3-3.4-2.1-2.3-3.1-5.5-3.1-9.4v-1.1c0-3.9 1-7.1 3.1-9.3 2.1-2.3 4.8-3.5 8.3-3.5 3.4 0 6.2 1.2 8.3 3.5 2.1 2.3 3.1 5.4 3.1 9.3v1.1zm98.3-12.2c1.2-1 2.6-1.6 4.2-2V47.3c-2.1.3-4 .8-5.9 1.6-2.8 1.1-5.3 2.7-7.4 4.8-2.1 2.1-3.8 4.6-5.1 7.5-1.2 2.9-1.8 6.2-1.8 9.8v.6c0 3.9.6 7.4 1.7 10.4 1.2 3.1 2.8 5.7 4.9 7.8 2.1 2.1 4.6 3.8 7.5 4.9 1.9.7 4 1.2 6.1 1.5V84.7c-.4-.1-.7-.2-1.1-.3-1.3-.5-2.5-1.2-3.6-2-1-.9-1.8-1.9-2.4-3-.6-1.2-.9-2.5-.9-3.9h8V65.4h-7.8c.5-2 1.8-3.8 3.6-5.3zm-61.5 6.1c.7-1.7 1.6-3.1 2.7-4.2 1.1-1.2 2.4-2.1 3.9-2.7 1.5-.6 3.1-.9 4.8-.9 3.6 0 6.5 1 8.5 3s3.2 4.4 3.6 7.1l11.7-3c-1.1-5.5-3.6-10-7.7-13.3-4-3.4-9.3-5.1-15.8-5.1-3.4 0-6.6.6-9.6 1.7-2.9 1.1-5.5 2.8-7.8 4.9-2.2 2.1-3.9 4.7-5.2 7.7s-1.9 6.4-1.9 10.2v1.1c0 3.8.6 7.1 1.9 10.1 1.3 2.9 3 5.4 5.2 7.4s4.8 3.5 7.7 4.6c3 1.1 6.2 1.6 9.7 1.6 6.6 0 11.9-1.7 15.9-5.1 4-3.4 6.5-7.8 7.6-13.3l-11.7-3c-.6 3.1-1.8 5.5-3.8 7.3-1.9 1.8-4.6 2.7-8.3 2.7-1.7 0-3.3-.3-4.8-.8-1.5-.6-2.8-1.4-3.9-2.4-1.1-1.1-2-2.4-2.7-3.9-.6-1.6-.9-3.5-.9-5.5v-.6c0-2.1.3-3.9.9-5.6z",fill:"#270920"}),Object(_.createElement)(z.Path,{d:"M49.7 89.3c-1.1 1.3-2.6 2-4.5 2h-6.5c.1-1.1.2-2.5.2-4.3V68.5c0-1.3.1-2.2.4-2.8s.6-1 1.1-1.1c.5-.2 1.1-.3 2-.3v-3.2h-14v3.7l3.6-.1c-.1 1.1-.2 2.5-.2 4.4v18.5c0 1.3-.1 2.2-.4 2.8-.3.6-.6 1-1.1 1.2-.5.2-1.1.3-2 .3V95h25.8l.3-11.6h-3.2c.1 2.6-.5 4.5-1.5 5.9zM101.3 70c-2.5 0-4.8 1.5-7 4.5h-.1v-2.3c0-.8-.1-1.4-.1-1.9h-2.4c-.4.4-1.3.7-2.5 1-1.3.3-2.9.4-4.9.4v3.7l3.4-.1c-.1 1.3-.2 2.7-.2 4.1v8.1c0 1.5-.2 2.6-.5 3.3-.3.7-1.1 1-2.3 1V95h12.7v-3.7c-1.1 0-2.1 0-3.1.1.1-1.3.2-2.7.2-4.3v-7.9c.3-1 1-2.1 1.9-3.1 1-1.1 1.9-1.6 2.8-1.6.1 1 .5 1.8 1.1 2.2.6.4 1.4.6 2.2.6 1.1 0 1.9-.4 2.5-1.1.5-.7.8-1.5.8-2.3 0-1.3-.4-2.3-1.2-3-1-.5-2-.9-3.3-.9zm25.8 21.5c.1-1.3.2-2.7.2-4.3v-7.9c0-6.2-3-9.2-9-9.2-1.9 0-3.6.3-5.2.8-1.5.5-2.8 1.3-3.7 2.2-.9 1-1.4 2.1-1.4 3.3 0 .9.3 1.7.8 2.4.5.6 1.3.9 2.3.9 1 0 1.8-.3 2.3-.9.5-.6.8-1.3.8-2.1s-.2-1.4-.6-1.8c.9-.9 2.1-1.4 3.5-1.4 2.2 0 3.3 1.5 3.3 4.4v2.5c-3.7.2-6.9 1-9.5 2.5-2.6 1.5-4 3.6-4 6.4 0 1.9.6 3.4 1.7 4.6 1.2 1.2 2.8 1.8 4.8 1.8 2.8 0 5.2-1 7.2-3 .1 1.1.1 1.8.2 2.2h9.1v-3.7c-.7.1-1.8.2-2.8.3zm-6.6-2.2c-1.1 1.2-2.4 1.7-3.8 1.7-.8 0-1.4-.2-2-.6-.5-.4-.8-1.1-.8-1.9 0-1.3.6-2.4 1.8-3.1 1.3-.8 2.8-1.3 4.7-1.5v5.4zM75.1 71.5c-1.8-1-3.9-1.5-6.2-1.5-2.2 0-4.3.6-6.1 1.7-1.8 1.1-3.3 2.7-4.4 4.7-1.1 2-1.6 4.4-1.6 7 0 2.5.5 4.7 1.6 6.5 1.1 1.9 2.5 3.3 4.4 4.3 1.9 1 4 1.5 6.3 1.5 2.4 0 4.4-.5 6.2-1.6 1.8-1.1 3.3-2.6 4.3-4.6 1-2 1.5-4.3 1.5-7 0-2.5-.5-4.7-1.6-6.6-1.1-1.9-2.5-3.4-4.4-4.4zm-2.2 18.4c-.7 1.6-2 2.5-3.7 2.5-1.8 0-3.1-1-4-3-.9-2-1.3-4.4-1.3-7.2 0-2.5.4-4.5 1.2-6.2.8-1.7 2.1-2.5 3.9-2.5 1.7 0 3 1 3.8 3s1.2 4.4 1.2 7.2c-.1 2.5-.4 4.5-1.1 6.2z",fill:"#fff"}));case"SYSTEM_BASKER":return Object(_.createElement)(z.SVG,{width:"232",height:"132",viewBox:"0 0 232 132",xmlns:"http://www.w3.org/2000/svg"},Object(_.createElement)(z.Path,{fill:"#F18F1B",d:"M0 0h232v132H0z"}),Object(_.createElement)(z.Path,{d:"M10.016 50.563c.14 4.25 3.718 6.828 9.093 6.828 5.641 0 9.094-2.797 9.094-7.203 0-3.422-2.078-5.344-6.844-6.297l-2.39-.485c-2.657-.531-3.75-1.39-3.75-2.781 0-1.656 1.562-2.75 3.89-2.75 2.375 0 4.047 1.156 4.203 3.078h4.454c-.078-4.14-3.391-6.89-8.657-6.89-5.015 0-8.609 2.734-8.609 6.859 0 3.36 2.203 5.516 6.703 6.406l2.375.469c2.828.578 3.89 1.422 3.89 2.906 0 1.656-1.718 2.875-4.234 2.875-2.562 0-4.468-1.125-4.765-3.016h-4.453zM53 37v-8.422l7.86-14.125h-5.063l-5.063 9.625h-.109l-5.047-9.625h-5.14l7.843 14.125V37H53zM73.016 60.563c.14 4.25 3.718 6.828 9.093 6.828 5.641 0 9.094-2.797 9.094-7.204 0-3.421-2.078-5.343-6.844-6.296l-2.39-.485c-2.656-.531-3.75-1.39-3.75-2.781 0-1.656 1.562-2.75 3.89-2.75 2.375 0 4.047 1.156 4.204 3.078h4.453c-.079-4.14-3.391-6.89-8.657-6.89-5.015 0-8.609 2.734-8.609 6.859 0 3.36 2.203 5.516 6.703 6.406l2.375.469c2.828.578 3.89 1.422 3.89 2.906 0 1.656-1.718 2.875-4.234 2.875-2.562 0-4.468-1.125-4.765-3.016h-4.453zM114.984 47V28.344h6.532v-3.89H103.75v3.89h6.516V47h4.718zM149.812 43.094h-10.218v-5.688h9.64v-3.625h-9.64v-5.437h10.218v-3.89h-14.937V47h14.937v-3.906zM187.75 37V14.453h-5.469l-6.406 16.188h-.125l-6.406-16.188h-5.469V37h4.203V21.781h.125L174.328 37h2.969l6.125-15.219h.125V37h4.203z",fill:"#492B06"}),Object(_.createElement)(z.Path,{d:"M22.032 92H9.63v-.72c.396-.012.72-.048.972-.108s.444-.162.576-.306c.132-.144.222-.348.27-.612.048-.264.072-.606.072-1.026v-8.316c0-.42-.024-.756-.072-1.008-.036-.264-.114-.468-.234-.612a.852.852 0 0 0-.522-.306 4.454 4.454 0 0 0-.864-.126v-.72h6.21v.72a5.062 5.062 0 0 0-.99.108c-.24.06-.426.168-.558.324-.132.156-.222.372-.27.648a8.868 8.868 0 0 0-.054 1.098v7.542c0 .504.048.918.144 1.242.108.312.288.558.54.738.252.168.588.288 1.008.36.42.06.942.09 1.566.09.696 0 1.278-.042 1.746-.126.468-.084.858-.24 1.17-.468.324-.24.582-.558.774-.954.192-.396.354-.912.486-1.548h.72L22.032 92zm5.182-2.952c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V86.96c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v6.768zm-2.646-10.584c0-.396.132-.726.396-.99a1.35 1.35 0 0 1 .99-.414c.396 0 .726.138.99.414.276.264.414.594.414.99 0 .384-.138.714-.414.99a1.343 1.343 0 0 1-.99.396c-.384 0-.714-.132-.99-.396a1.382 1.382 0 0 1-.396-.99zm8.574 9.594c0 .444.06.858.18 1.242.132.372.306.696.522.972.216.276.474.492.774.648.3.156.63.234.99.234.72 0 1.266-.33 1.638-.99.372-.66.558-1.632.558-2.916 0-1.248-.186-2.196-.558-2.844-.36-.66-.906-.99-1.638-.99-.432 0-.834.12-1.206.36-.36.228-.642.552-.846.972-.276.576-.414 1.302-.414 2.178v1.134zm-.036-4.356h.072a3.07 3.07 0 0 1 1.206-1.044c.492-.252 1.05-.378 1.674-.378.636 0 1.224.132 1.764.396.552.252 1.026.6 1.422 1.044.408.444.726.966.954 1.566.228.6.342 1.242.342 1.926 0 .72-.126 1.386-.378 1.998-.24.6-.576 1.122-1.008 1.566-.42.444-.918.792-1.494 1.044a4.362 4.362 0 0 1-1.8.378c-.66 0-1.284-.126-1.872-.378-.576-.264-1.038-.606-1.386-1.026L31.234 92h-.612V81.29c0-1.128-.078-1.902-.234-2.322a.93.93 0 0 0-.126-.216.488.488 0 0 0-.216-.144 1.07 1.07 0 0 0-.36-.108 7.62 7.62 0 0 0-.612-.108v-.612l4.032-.72v6.642zm12.759 5.508c0 .468.018.84.054 1.116.048.264.138.468.27.612.132.144.324.24.576.288.252.036.588.054 1.008.054V92H41.76v-.72c.36-.024.648-.06.864-.108.216-.048.378-.144.486-.288.108-.144.174-.348.198-.612.036-.276.054-.642.054-1.098v-2.196c0-.744-.018-1.338-.054-1.782-.036-.444-.114-.786-.234-1.026a.867.867 0 0 0-.522-.468c-.216-.084-.504-.126-.864-.126v-.63l3.6-.666.288 2.07h.072c.324-.636.75-1.14 1.278-1.512.528-.372 1.086-.558 1.674-.558.456 0 .828.114 1.116.342.288.228.432.516.432.864 0 .384-.114.708-.342.972-.216.264-.516.396-.9.396-.18 0-.342-.036-.486-.108a3.131 3.131 0 0 1-.396-.234 2.28 2.28 0 0 0-.342-.252.549.549 0 0 0-.342-.126c-.228 0-.444.15-.648.45-.204.3-.372.702-.504 1.206a9.68 9.68 0 0 0-.234 1.224c-.06.444-.09.888-.09 1.332v.864zM59.8 90.326c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61zM65.985 92v-.72a4.75 4.75 0 0 0 .972-.108c.252-.06.444-.162.576-.306.144-.144.24-.348.288-.612.048-.264.072-.606.072-1.026v-8.316c0-.42-.018-.756-.054-1.008-.036-.264-.114-.468-.234-.612a.755.755 0 0 0-.468-.306 3.572 3.572 0 0 0-.774-.126v-.72h5.778c1.812 0 3.204.294 4.176.882.984.576 1.476 1.404 1.476 2.484 0 1.428-1.026 2.436-3.078 3.024v.072c.66 0 1.254.096 1.782.288.54.18.996.438 1.368.774a3.523 3.523 0 0 1 1.17 2.682c0 .612-.15 1.146-.45 1.602-.288.456-.708.84-1.26 1.152-1.068.6-2.538.9-4.41.9h-6.93zm7.056-1.098c1.932 0 2.898-.87 2.898-2.61 0-1.068-.348-1.848-1.044-2.34-.36-.252-.828-.432-1.404-.54-.564-.108-1.26-.162-2.088-.162h-.864v3.6c0 .744.192 1.272.576 1.584.384.312 1.026.468 1.926.468zM71.6 84.17c.54 0 1.008-.048 1.404-.144a3.249 3.249 0 0 0 1.008-.45c.576-.396.864-1.014.864-1.854 0-.876-.216-1.506-.648-1.89-.432-.396-1.128-.594-2.088-.594h-1.278c-.216 0-.324.102-.324.306v4.626H71.6zm14.325 2.7c-1.008.456-1.77.882-2.286 1.278-.504.384-.756.786-.756 1.206 0 .348.096.624.288.828a.948.948 0 0 0 .72.306c.288 0 .558-.048.81-.144.252-.108.468-.246.648-.414.18-.168.318-.366.414-.594.108-.24.162-.492.162-.756v-1.71zm0-.954v-.756c0-.696-.126-1.2-.378-1.512-.24-.324-.618-.486-1.134-.486-.348 0-.612.096-.792.288-.18.18-.348.486-.504.918-.108.3-.264.534-.468.702-.192.168-.462.252-.81.252-.336 0-.594-.102-.774-.306-.18-.204-.27-.492-.27-.864 0-.576.312-1.032.936-1.368.636-.336 1.59-.504 2.862-.504 1.344 0 2.304.246 2.88.738.576.48.864 1.29.864 2.43v3.942c0 1.02.204 1.53.612 1.53a.978.978 0 0 0 .63-.234l.27.522c-.168.3-.432.54-.792.72a2.7 2.7 0 0 1-1.188.252c-.552 0-.972-.168-1.26-.504-.288-.336-.432-.81-.432-1.422h-.09c-.348.624-.798 1.098-1.35 1.422-.552.324-1.182.486-1.89.486-.756 0-1.362-.21-1.818-.63-.456-.432-.684-.99-.684-1.674 0-.528.234-1.02.702-1.476.468-.468 1.248-.924 2.34-1.368l2.538-1.098zM91.6 92h-.558v-3.276h.756c.204.864.498 1.494.882 1.89.384.396.882.594 1.494.594.444 0 .786-.09 1.026-.27a.923.923 0 0 0 .378-.774c0-.336-.15-.66-.45-.972-.3-.324-.786-.666-1.458-1.026-.912-.492-1.566-.978-1.962-1.458a2.574 2.574 0 0 1-.594-1.656c0-.396.072-.762.216-1.098.156-.348.36-.648.612-.9.264-.252.576-.444.936-.576.36-.144.75-.216 1.17-.216.372 0 .738.054 1.098.162.372.108.696.258.972.45l.324-.432h.468v2.718h-.702c-.276-.684-.564-1.176-.864-1.476-.288-.3-.642-.45-1.062-.45-.336 0-.606.09-.81.27-.192.18-.288.42-.288.72 0 .336.144.654.432.954.3.3.792.63 1.476.99.48.264.894.522 1.242.774s.63.51.846.774c.216.252.372.522.468.81.108.276.162.576.162.9 0 .42-.078.798-.234 1.134a2.462 2.462 0 0 1-.666.864c-.288.24-.636.426-1.044.558-.396.132-.84.198-1.332.198-.516 0-.996-.066-1.44-.198-.444-.144-.81-.348-1.098-.612L91.6 92zm13.299-.72c.384 0 .654-.012.81-.036.156-.036.234-.102.234-.198 0-.072-.084-.246-.252-.522-.156-.288-.36-.618-.612-.99l-1.368-2.052-.9.864v.702c0 .468.018.846.054 1.134.036.288.096.516.18.684a.759.759 0 0 0 .378.324c.168.06.378.09.63.09V92h-5.31v-.72c.336-.012.606-.048.81-.108a.969.969 0 0 0 .486-.306c.12-.156.198-.366.234-.63a6.4 6.4 0 0 0 .072-1.062v-7.632c0-.732-.012-1.308-.036-1.728-.024-.42-.09-.732-.198-.936a.647.647 0 0 0-.468-.396 3.877 3.877 0 0 0-.846-.072v-.666l4.014-.684v10.008l1.728-1.638a28.697 28.697 0 0 0 1.332-1.314c.264-.3.396-.516.396-.648 0-.108-.114-.18-.342-.216-.216-.048-.624-.072-1.224-.072v-.72h4.914v.72c-.456 0-.858.078-1.206.234-.348.156-.726.426-1.134.81l-1.746 1.638 3.114 4.41c.276.384.546.648.81.792.264.144.612.216 1.044.216V92h-5.598v-.72zm14.737-.954c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61zm8.945 3.618c0 .468.018.84.054 1.116.048.264.138.468.27.612.132.144.324.24.576.288.252.036.588.054 1.008.054V92h-6.012v-.72c.36-.024.648-.06.864-.108.216-.048.378-.144.486-.288.108-.144.174-.348.198-.612.036-.276.054-.642.054-1.098v-2.196c0-.744-.018-1.338-.054-1.782-.036-.444-.114-.786-.234-1.026a.867.867 0 0 0-.522-.468c-.216-.084-.504-.126-.864-.126v-.63l3.6-.666.288 2.07h.072c.324-.636.75-1.14 1.278-1.512.528-.372 1.086-.558 1.674-.558.456 0 .828.114 1.116.342.288.228.432.516.432.864 0 .384-.114.708-.342.972-.216.264-.516.396-.9.396-.18 0-.342-.036-.486-.108a3.131 3.131 0 0 1-.396-.234 2.28 2.28 0 0 0-.342-.252.549.549 0 0 0-.342-.126c-.228 0-.444.15-.648.45-.204.3-.372.702-.504 1.206a9.68 9.68 0 0 0-.234 1.224c-.06.444-.09.888-.09 1.332v.864zm6.139-4.428a5.587 5.587 0 0 0-.378-.828 1.667 1.667 0 0 0-.378-.486.847.847 0 0 0-.414-.234 2.18 2.18 0 0 0-.522-.054v-.72h5.382v.72c-.3 0-.54.012-.72.036-.168.024-.3.06-.396.108a.328.328 0 0 0-.162.198.798.798 0 0 0-.036.252c0 .156.03.336.09.54.06.204.132.408.216.612l1.71 4.716h.072l1.926-4.698a6.35 6.35 0 0 0 .198-.54 1.66 1.66 0 0 0 .072-.45c0-.264-.09-.456-.27-.576-.18-.12-.498-.186-.954-.198v-.72h3.978v.72c-.324 0-.606.084-.846.252-.228.168-.468.54-.72 1.116l-3.366 7.632h-1.638l-2.844-7.398zm14.041 4.266c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V86.96c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v6.768zm-2.646-10.584c0-.396.132-.726.396-.99a1.35 1.35 0 0 1 .99-.414c.396 0 .726.138.99.414.276.264.414.594.414.99 0 .384-.138.714-.414.99a1.343 1.343 0 0 1-.99.396c-.384 0-.714-.132-.99-.396a1.382 1.382 0 0 1-.396-.99zm8.969 10.584c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V81.74c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v11.988zm6.399 0c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V81.74c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v11.988zm11.672 1.278c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61z",fill:"#FFF1E1"}));case"RUBIK_WORK":return Object(_.createElement)(z.SVG,{width:"232",height:"132",viewBox:"0 0 232 132",xmlns:"http://www.w3.org/2000/svg"},Object(_.createElement)(z.Path,{fill:"#000",d:"M0 0h232v132H0z"}),Object(_.createElement)(z.Path,{d:"M14.936 62c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.696c0-.352.128-.656.384-.912s.56-.384.912-.384h14.208c4.608 0 8.208 1.04 10.8 3.12 2.592 2.048 3.888 4.896 3.888 8.544 0 2.08-.464 3.92-1.392 5.52-.928 1.568-2.192 2.864-3.792 3.888l5.904 10.944c.096.192.144.368.144.528 0 .288-.112.544-.336.768a.977.977 0 0 1-.72.288H33.8c-.576 0-1.04-.128-1.392-.384-.32-.288-.544-.592-.672-.912l-4.128-9.168H25.64v9.168c0 .352-.128.656-.384.912s-.56.384-.912.384h-9.408zm14.208-19.584c.704 0 1.248-.224 1.632-.672.384-.48.576-1.072.576-1.776s-.192-1.312-.576-1.824c-.352-.544-.896-.816-1.632-.816H25.64v5.088h3.504zM56.873 62.48c-1.696 0-3.248-.384-4.656-1.152-1.408-.8-2.544-2.016-3.408-3.648-.832-1.632-1.248-3.664-1.248-6.096V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h9.168c.352 0 .656.128.912.384s.384.56.384.912v12.912c0 .864.208 1.52.624 1.968.416.448 1.008.672 1.776.672s1.36-.224 1.776-.672c.416-.448.624-1.104.624-1.968V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h9.12c.352 0 .656.128.912.384s.384.56.384.912v22.368c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.4c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V59.12c-.768 1.12-1.84 1.968-3.216 2.544-1.376.544-2.96.816-4.752.816zm41.127 0c-3.04 0-5.408-.96-7.104-2.88v1.104c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.16c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.216c0-.352.128-.656.384-.912s.56-.384.912-.384h8.88c.352 0 .656.128.912.384s.384.56.384.912v9.6C93.28 37.312 95.408 36.56 98 36.56c2.912 0 5.296.944 7.152 2.832 1.888 1.856 2.896 4.592 3.024 8.208.032.48.048 1.104.048 1.872 0 .8-.016 1.44-.048 1.92-.16 3.808-1.152 6.608-2.976 8.4-1.824 1.792-4.224 2.688-7.2 2.688zm-3.984-8.592c.832 0 1.408-.224 1.728-.672.352-.448.576-1.152.672-2.112.064-.64.096-1.168.096-1.584 0-.416-.032-.944-.096-1.584-.096-.96-.32-1.664-.672-2.112-.32-.448-.896-.672-1.728-.672-.8 0-1.392.208-1.776.624-.352.384-.56.976-.624 1.776-.032.48-.048 1.072-.048 1.776s.016 1.296.048 1.776c.064.928.272 1.632.624 2.112.352.448.944.672 1.776.672zM113.415 34.4c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912v-5.808c0-.352.128-.656.384-.912s.56-.384.912-.384h8.112c.352 0 .656.128.912.384s.384.56.384.912v5.808c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.112zm-.24 27.6c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h8.592c.352 0 .656.128.912.384s.384.56.384.912v22.368c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.592zm15.515 0c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.216c0-.352.128-.656.384-.912s.56-.384.912-.384h8.4c.352 0 .656.128.912.384s.384.56.384.912v15.552l4.224-6.912c.32-.544.784-.816 1.392-.816h9.696c.32 0 .592.112.816.336.224.224.336.496.336.816 0 .224-.08.464-.24.72l-6.576 9.36 7.776 11.952c.128.192.192.4.192.624 0 .32-.112.592-.336.816a1.11 1.11 0 0 1-.816.336h-10.08c-.64 0-1.136-.272-1.488-.816l-4.896-8.16v7.68c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.4zM25.4 105.48c-3.776 0-6.768-.88-8.976-2.64-2.208-1.76-3.312-4.16-3.312-7.2 0-1.952.56-3.664 1.68-5.136 1.12-1.472 2.72-2.8 4.8-3.984-1.216-1.312-2.096-2.528-2.64-3.648-.512-1.152-.768-2.32-.768-3.504 0-1.536.4-2.944 1.2-4.224.8-1.28 1.984-2.304 3.552-3.072 1.568-.768 3.456-1.152 5.664-1.152 2.048 0 3.824.384 5.328 1.152 1.536.736 2.688 1.744 3.456 3.024a7.494 7.494 0 0 1 1.2 4.128c0 1.856-.56 3.456-1.68 4.8-1.12 1.312-2.784 2.608-4.992 3.888l5.712 5.712c.512-.832.944-1.632 1.296-2.4.384-.8.768-1.84 1.152-3.12.128-.448.464-.672 1.008-.672h4.848c.256 0 .48.096.672.288.192.16.288.368.288.624-.032 1.12-.56 2.64-1.584 4.56-.992 1.92-2.096 3.616-3.312 5.088l5.376 5.424c.224.288.336.528.336.72a.774.774 0 0 1-.288.624.844.844 0 0 1-.624.24h-6.528c-.512 0-.928-.16-1.248-.48l-2.16-2.064c-2.464 2.016-5.616 3.024-9.456 3.024zm.432-21.984c1.28-.64 2.24-1.264 2.88-1.872.672-.608 1.008-1.328 1.008-2.16 0-.864-.304-1.552-.912-2.064-.576-.544-1.312-.816-2.208-.816a3.31 3.31 0 0 0-2.208.816c-.608.544-.912 1.248-.912 2.112 0 .576.176 1.184.528 1.824.384.608.992 1.328 1.824 2.16zM25.4 99.384c1.984 0 3.632-.592 4.944-1.776l-6.384-6.384c-2.112 1.12-3.168 2.48-3.168 4.08 0 1.216.464 2.208 1.392 2.976.928.736 2 1.104 3.216 1.104zM65.56 105h-3.168l-6.24-21.12h2.752l5.088 19.104 4.992-19.104h2.912l4.992 19.168 5.12-19.168H84.6L78.392 105h-3.168L71.48 91.304l-1.088-4.768h-.032l-1.088 4.768L65.56 105zm28.824-16.32c2.41 0 4.299.736 5.664 2.208 1.387 1.472 2.08 3.51 2.08 6.112 0 2.603-.693 4.64-2.08 6.112-1.365 1.472-3.253 2.208-5.664 2.208-2.41 0-4.31-.736-5.696-2.208-1.365-1.472-2.048-3.51-2.048-6.112 0-2.603.683-4.64 2.048-6.112 1.387-1.472 3.286-2.208 5.696-2.208zm0 2.208c-1.621 0-2.89.544-3.808 1.632C89.66 93.608 89.2 95.101 89.2 97c0 1.899.459 3.392 1.376 4.48.918 1.088 2.187 1.632 3.808 1.632 1.622 0 2.89-.544 3.808-1.632.918-1.088 1.376-2.581 1.376-4.48 0-1.899-.458-3.392-1.376-4.48-.917-1.088-2.186-1.632-3.808-1.632zm20.269-2.208c.768 0 1.355.107 1.76.32l-.512 2.496c-.512-.277-1.184-.416-2.016-.416-.683 0-1.355.203-2.016.608-.64.384-1.173.981-1.6 1.792-.405.79-.608 1.75-.608 2.88V105h-2.56V89h2.08l.352 2.624c.896-1.963 2.603-2.944 5.12-2.944zm11.463 8.416l-3.392 3.392V105h-2.56V81.64h2.56v15.648L131.012 89h3.2l-6.24 6.24 6.624 9.76h-3.104l-5.376-7.904zm29.655-13.536c3.776 0 6.496 1.493 8.16 4.48l-2.208 1.792c-.64-1.408-1.408-2.4-2.304-2.976-.874-.597-2.08-.896-3.616-.896-1.621 0-2.901.341-3.84 1.024-.917.661-1.376 1.515-1.376 2.56 0 .683.182 1.248.544 1.696.363.448.96.843 1.792 1.184.854.32 2.027.608 3.52.864 2.795.47 4.768 1.173 5.92 2.112 1.174.939 1.76 2.24 1.76 3.904 0 1.195-.341 2.251-1.024 3.168-.661.896-1.61 1.6-2.848 2.112-1.237.491-2.666.736-4.288.736-2.133 0-3.957-.416-5.472-1.248-1.493-.832-2.634-1.941-3.424-3.328l2.208-1.792c.576 1.259 1.419 2.24 2.528 2.944 1.131.683 2.539 1.024 4.224 1.024 1.664 0 2.987-.299 3.968-.896.982-.619 1.472-1.483 1.472-2.592 0-.939-.426-1.685-1.28-2.24-.853-.555-2.368-1.024-4.544-1.408-2.816-.49-4.81-1.195-5.984-2.112-1.173-.917-1.76-2.197-1.76-3.84 0-1.13.32-2.176.96-3.136.64-.96 1.558-1.717 2.752-2.272 1.195-.576 2.582-.864 4.16-.864zm26.044 19.584a5.25 5.25 0 0 0 1.28-.16l-.16 2.016a5.68 5.68 0 0 1-1.92.32c-.832 0-1.494-.181-1.984-.544-.47-.363-.768-.971-.896-1.824-.491.747-1.216 1.333-2.176 1.76a7.435 7.435 0 0 1-2.976.608c-1.579 0-2.88-.363-3.904-1.088-1.024-.747-1.536-1.813-1.536-3.2 0-1.216.533-2.261 1.6-3.136 1.066-.896 2.613-1.515 4.64-1.856l4.256-.704v-.896c0-1.067-.331-1.92-.992-2.56-.662-.64-1.579-.96-2.752-.96-1.067 0-1.995.256-2.784.768-.768.512-1.366 1.27-1.792 2.272l-1.888-1.376c.426-1.195 1.216-2.144 2.368-2.848 1.173-.704 2.538-1.056 4.096-1.056 1.898 0 3.424.459 4.576 1.376 1.152.917 1.728 2.272 1.728 4.064v7.872c0 .384.096.672.288.864.192.192.501.288.928.288zm-8.704-.064c1.344 0 2.496-.32 3.456-.96.981-.64 1.472-1.472 1.472-2.496v-2.208l-3.584.672c-1.43.256-2.496.63-3.2 1.12-.704.47-1.056 1.077-1.056 1.824 0 .661.256 1.173.768 1.536.512.341 1.226.512 2.144.512zm21.485-14.4c1.813 0 3.306.523 4.48 1.568 1.173 1.045 1.76 2.55 1.76 4.512V105h-2.56v-9.344c0-1.664-.363-2.87-1.088-3.616-.704-.747-1.654-1.12-2.848-1.12-.854 0-1.654.192-2.4.576-.747.363-1.366.97-1.856 1.824-.47.832-.704 1.888-.704 3.168V105h-2.56V89h2.24l.16 2.496c.533-.96 1.269-1.664 2.208-2.112.938-.47 1.994-.704 3.168-.704zm17.476 16.64c-1.536 0-2.922-.299-4.16-.896-1.237-.619-2.144-1.525-2.72-2.72l2.08-1.44a3.898 3.898 0 0 0 1.888 2.112c.896.469 1.952.704 3.168.704 1.259 0 2.219-.224 2.88-.672.662-.448.992-1.013.992-1.696 0-.619-.309-1.11-.928-1.472-.618-.384-1.706-.715-3.264-.992-1.536-.277-2.752-.608-3.648-.992-.896-.405-1.546-.907-1.952-1.504-.405-.619-.608-1.376-.608-2.272 0-.875.256-1.675.768-2.4.512-.725 1.248-1.301 2.208-1.728.96-.448 2.07-.672 3.328-.672 1.707 0 3.072.32 4.096.96 1.046.619 1.792 1.579 2.24 2.88l-2.176 1.28c-.341-1.024-.864-1.76-1.568-2.208-.682-.448-1.546-.672-2.592-.672-1.045 0-1.93.235-2.656.704-.725.47-1.088 1.013-1.088 1.632 0 .704.31 1.248.928 1.632.64.384 1.771.715 3.392.992 2.219.363 3.787.907 4.704 1.632.918.725 1.376 1.75 1.376 3.072a3.95 3.95 0 0 1-.832 2.464c-.533.704-1.312 1.259-2.336 1.664-1.002.405-2.176.608-3.52.608z",fill:"#fff"}));case"PLAY_ROBOTO":return Object(_.createElement)(z.SVG,{width:"232",height:"132",viewBox:"0 0 232 132",xmlns:"http://www.w3.org/2000/svg"},Object(_.createElement)(z.Path,{fill:"#B9B5B8",d:"M0 0h232v132H0z"}),Object(_.createElement)(z.Path,{d:"M149.438 101c-.75-2.125-1.23-5.27-1.438-9.438-2.625 3.417-5.979 6.063-10.062 7.938-4.042 1.833-8.334 2.75-12.876 2.75-6.5 0-11.77-1.812-15.812-5.438-4-3.624-6-8.208-6-13.75 0-6.583 2.729-11.791 8.188-15.624 5.5-3.834 13.145-5.75 22.937-5.75h13.563V54c0-4.833-1.5-8.625-4.5-11.375-2.959-2.792-7.292-4.188-13-4.188-5.209 0-9.521 1.334-12.938 4-3.417 2.667-5.125 5.876-5.125 9.626l-7.5-.063c0-5.375 2.5-10.02 7.5-13.938 5-3.958 11.146-5.937 18.437-5.937 7.542 0 13.48 1.896 17.813 5.688 4.375 3.75 6.625 9 6.75 15.75v32c0 6.541.687 11.437 2.063 14.687v.75h-8zm-23.5-5.375c5 0 9.458-1.208 13.374-3.625 3.959-2.417 6.834-5.646 8.626-9.688V67.439h-13.376c-7.458.083-13.291 1.458-17.5 4.124-4.208 2.626-6.312 6.25-6.312 10.876 0 3.791 1.396 6.937 4.188 9.437 2.833 2.5 6.5 3.75 11 3.75zM39.328 101.896c-5.461 0-9.6-1.451-12.416-4.352-2.73-2.987-4.096-6.699-4.096-11.136 0-3.84.981-6.997 2.944-9.472 2.048-2.56 4.437-4.523 7.168-5.888 2.73-1.365 6.272-2.773 10.624-4.224 4.608-1.536 7.979-2.944 10.112-4.224 2.133-1.28 3.2-3.072 3.2-5.376V45.832c0-2.73-.683-5.163-2.048-7.296s-3.712-3.2-7.04-3.2c-2.645 0-5.035.725-7.168 2.176 2.901 1.024 5.035 2.56 6.4 4.608 1.45 1.963 2.176 4.181 2.176 6.656 0 3.328-1.195 6.016-3.584 8.064-2.304 1.963-5.12 2.944-8.448 2.944-3.328 0-5.973-1.024-7.936-3.072-1.877-2.133-2.816-4.821-2.816-8.064 0-2.56.64-4.779 1.92-6.656 1.28-1.877 3.285-3.584 6.016-5.12 4.779-2.73 11.605-4.096 20.48-4.096 4.693 0 8.747.47 12.16 1.408 3.413.853 6.315 2.517 8.704 4.992 1.707 1.792 2.816 4.053 3.328 6.784.597 2.645.896 6.357.896 11.136V91.4c0 2.133.128 3.584.384 4.352.341.768.896 1.152 1.664 1.152.597 0 1.237-.17 1.92-.512a15.863 15.863 0 0 0 1.92-1.408l1.28 2.176c-3.67 3.157-8.917 4.736-15.744 4.736-5.12 0-8.704-.853-10.752-2.56-2.048-1.792-3.157-4.181-3.328-7.168-4.01 6.485-9.984 9.728-17.92 9.728zm12.8-10.24c1.792 0 3.37-.725 4.736-2.176V62.472c-.768 1.28-2.176 2.944-4.224 4.992-2.304 2.219-4.053 4.395-5.248 6.528-1.195 2.048-1.792 4.864-1.792 8.448 0 6.144 2.176 9.216 6.528 9.216z",fill:"#270920"}));default:return Object(_.createElement)("div",{className:"font-pairings-panel__preview"},Object(_.createElement)("h1",{style:{fontFamily:t}},"Lorem Ipsum"),Object(_.createElement)("p",{style:{fontFamily:n}},"Etiam tempor orci eu lobortis elementum nibh tellus molestie."))}},B=function(e){var t=e.fontPairings,n=e.fontBase,c=e.fontHeadings,a=e.update;return Object(_.createElement)(_.Fragment,null,Object(_.createElement)("h3",null,Object(y.__)("Font Pairings")),t&&c&&n?Object(_.createElement)("div",{role:"listbox"},t.map((function(e){var t=e.label,r=e.headings,l=e.base,o=e.preview,s=r===c&&l===n,i=V()("font-pairings-panel",{"is-selected":s});return Object(_.createElement)("div",{key:t,tabIndex:0,role:"option","aria-selected":s,className:i,onClick:function(){return a({headings:r,base:l})},onKeyDown:function(e){return e.keyCode===P.ENTER?a({headings:r,base:l}):null}},Object(_.createElement)("div",{className:"font-pairings-panel__preview"},H(o,r,l)),Object(_.createElement)("p",{className:"font-pairings-panel__label"},t))}))):Object(_.createElement)(S,{unsupportedFeature:Object(y.__)("font pairings")}))},M=function(e){var t=e.fontBase,n=e.fontBaseDefault,c=e.fontHeadings,a=e.fontHeadingsDefault,r=e.fontBaseOptions,l=e.fontHeadingsOptions,o=e.updateBaseFont,s=e.updateHeadingsFont;return r&&l?Object(_.createElement)(_.Fragment,null,Object(_.createElement)(z.SelectControl,{label:Object(y.__)("Heading Font"),value:c,options:l,onChange:function(e){return s(e)},style:{fontFamily:"unset"!==c?c:a}}),Object(_.createElement)(z.SelectControl,{label:Object(y.__)("Base Font"),value:t,options:r,onChange:function(e){return o(e)},style:{fontFamily:"unset"!==t?t:n}}),Object(_.createElement)("hr",null)):Object(_.createElement)(S,{unsupportedFeature:Object(y.__)("custom font selection")})},x=function(){return Object(_.createElement)(z.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(_.createElement)(z.Path,{d:"M9.93 13.5h4.14L12 7.98zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z"}))},T=function(e){if("object"==typeof e){var t=e.label,n=e.value,c=e.prop;return{label:t,value:n,prop:void 0===c?"ANY_PROPERTY":c}}return{label:e,value:e,prop:"ANY_PROPERTY"}},N=function(e){return null!==e.value&&null!==e.label},L=function(e,t){return e?e.map(T).filter(N).filter(function(e){return function(t){return"ANY_PROPERTY"===t.prop||t.prop===e}}(t)):[]},C=function(e){var t=e.hasLocalChanges,n=e.resetAction,c=e.publishAction,a=e.className,r=void 0===a?null:a;return Object(_.createElement)("div",{className:r},Object(_.createElement)(z.Button,{disabled:!t,isDefault:!0,onClick:n},Object(y.__)("Reset")),Object(_.createElement)(z.Button,{className:"global-styles-sidebar__publish-button",disabled:!t,isPrimary:!0,onClick:c},Object(y.__)("Publish")))},F=(n(13),JETPACK_GLOBAL_STYLES_EDITOR_CONSTANTS),A=F.PLUGIN_NAME,I=F.STORE_NAME,R=F.REST_PATH;c=I,a=R,Object(s.registerStore)(c,{reducer:function(e,t){switch(t.type){case"UPDATE_OPTIONS":case"RESET_OPTIONS":case"PUBLISH_OPTIONS":return h()({},e,{},t.options)}return e},actions:m,selectors:{getOption:function(e,t){return e?e[t]:void 0},hasLocalChanges:function(e){return!!e&&Object.keys(v).some((function(t){return v[t]!==e[t]}))}},resolvers:{getOption:regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!b){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,b=!0,e.next=6,m.fetchOptions();case 6:n=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),n={};case 12:return v=n,e.abrupt("return",{type:"UPDATE_OPTIONS",options:n});case 14:case"end":return e.stop()}}),e,null,[[2,9]])}))},controls:{IO_FETCH_OPTIONS:function(){return p()({path:a})},IO_PUBLISH_OPTIONS:function(e){var t=e.options;return v=t,p()({path:a,method:"POST",data:h()({},t)})}}}),r=["font_base","font_headings"],l=Object(s.select)(I).getOption,d()((function(){var e={},t={};r.forEach((function(n){e[n]=null,t[n]="--".concat(n.replace("_","-"))})),Object(s.subscribe)((function(){Object.keys(e).forEach((function(n){var c=l(n);if(e[n]!==c){e[n]=c;var a=document.getElementsByClassName("editor-styles-wrapper")[0];a&&a.style.setProperty(t[n],c)}}))}))})),Object(o.registerPlugin)(A,{render:Object(i.compose)(Object(s.withSelect)((function(e){return{siteName:e(I).getOption("blogname"),fontHeadings:e(I).getOption("font_headings"),fontHeadingsDefault:e(I).getOption("font_headings_default"),fontBase:e(I).getOption("font_base"),fontBaseDefault:e(I).getOption("font_base_default"),fontPairings:e(I).getOption("font_pairings"),fontOptions:e(I).getOption("font_options"),hasLocalChanges:e(I).hasLocalChanges()}})),Object(s.withDispatch)((function(e){return{updateOptions:e(I).updateOptions,publishOptions:e(I).publishOptions,resetLocalChanges:e(I).resetLocalChanges}})))((function(e){var t=e.fontHeadings,n=e.fontHeadingsDefault,c=e.fontBase,a=e.fontBaseDefault,r=e.fontPairings,l=e.fontOptions,o=e.siteName,s=e.publishOptions,i=e.updateOptions,u=e.hasLocalChanges,h=e.resetLocalChanges,f=function(){var e;return s((e={},j()(e,"font_base",c),j()(e,"font_headings",t),e))};return Object(_.createElement)(_.Fragment,null,Object(_.createElement)(E.PluginSidebarMoreMenuItem,{icon:Object(_.createElement)(x,null),target:"global-styles"},Object(y.__)("Global Styles")),Object(_.createElement)(E.PluginSidebar,{icon:Object(_.createElement)(x,null),name:"global-styles",title:Object(y.__)("Global Styles"),className:"global-styles-sidebar"},Object(_.createElement)(z.PanelBody,null,Object(_.createElement)("p",null,Object(y.sprintf)(Object(y.__)("You are customizing %s."),o)),Object(_.createElement)("p",null,Object(y.__)("Any change you make here will apply to the entire website.")),u?Object(_.createElement)("div",null,Object(_.createElement)("p",null,Object(_.createElement)("em",null,Object(y.__)("You have unsaved changes."))),Object(_.createElement)(C,{hasLocalChanges:u,publishAction:f,resetAction:h})):null),Object(_.createElement)(z.PanelBody,{title:Object(y.__)("Font Selection")},Object(_.createElement)(M,{fontBase:c,fontBaseDefault:a,fontHeadings:t,fontHeadingsDefault:n,fontBaseOptions:L(l,"font_base"),fontHeadingsOptions:L(l,"font_headings"),updateBaseFont:function(e){return i(j()({},"font_base",e))},updateHeadingsFont:function(e){return i(j()({},"font_headings",e))}}),Object(_.createElement)(B,{fontHeadings:t,fontBase:c,fontPairings:r,update:function(e){var t,n=e.headings,c=e.base;return i((t={},j()(t,"font_headings",n),j()(t,"font_base",c),t))}})),Object(_.createElement)(z.PanelBody,null,u?Object(_.createElement)("p",null,Object(_.createElement)("em",null,Object(y.__)("You have unsaved changes."))):null,Object(_.createElement)(C,{hasLocalChanges:u,publishAction:f,resetAction:h,className:"global-styles-sidebar__panel-action-buttons"}))))}))})}]));
|
global-styles/dist/global-styles.rtl.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.global-styles-sidebar .components-select-control__input{line-height:1;font-size:18px;height:36px}.global-styles-sidebar h3{margin:0 0 1em}.global-styles-sidebar__panel-action-buttons{display:flex;justify-content:flex-end;margin-bottom:96px}.global-styles-sidebar__publish-button{margin-right:1em}.font-pairings-panel{cursor:pointer;border-radius:4px;padding:4px;margin-bottom:.5em}.font-pairings-panel.is-selected{box-shadow:0 0 0 2px #555d66}.font-pairings-panel:focus{box-shadow:0 0 0 2px #00a0d2}.font-pairings-panel:hover{background-color:#f3f4f5;color:#191e23}.font-pairings-panel__preview{border:1px solid rgba(25,30,35,.2);border-radius:4px;background-color:#fff;padding:4px}.font-pairings-panel__preview h1,.font-pairings-panel__preview p{margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:10px 0}.font-pairings-panel__preview svg{display:block;width:100%;height:auto}.font-pairings-panel__label{text-align:center;margin-bottom:0}
|
global-styles/editor.scss
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
@import './src/global-styles-sidebar.scss';
|
2 |
+
@import './src/font-pairings-panel.scss';
|
global-styles/includes/class-data-point-literal.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Data Point Literal.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
require_once __DIR__ . '/interface-data-point.php';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Literal Data Point.
|
14 |
+
*/
|
15 |
+
class Data_Point_Literal implements Data_Point {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Holds the literal value.
|
19 |
+
*
|
20 |
+
* @var any
|
21 |
+
*/
|
22 |
+
private $value;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Constructor.
|
26 |
+
*
|
27 |
+
* @param any $meta Data point description.
|
28 |
+
*/
|
29 |
+
public function __construct( $meta ) {
|
30 |
+
if ( array_key_exists( 'default', $meta ) ) {
|
31 |
+
$this->value = $meta['default'];
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Implements \Automattic\Jetpack\Global_Styles\Data_Point interface.
|
37 |
+
*
|
38 |
+
* @return any The literal value.
|
39 |
+
*/
|
40 |
+
public function get_value() {
|
41 |
+
return $this->value;
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
global-styles/includes/class-data-point-option.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Data Point Option.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
require_once __DIR__ . '/interface-data-point.php';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Option Data Point.
|
14 |
+
*/
|
15 |
+
class Data_Point_Option implements Data_Point {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Option name.
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
private $option_name;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Option property to access, if exist.
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
private $option_property;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Default option value.
|
33 |
+
*
|
34 |
+
* @var any
|
35 |
+
*/
|
36 |
+
private $default_value;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Constructor.
|
40 |
+
*
|
41 |
+
* @param array $meta Data point description.
|
42 |
+
*/
|
43 |
+
public function __construct( $meta ) {
|
44 |
+
if ( is_array( $meta['name'] ) ) {
|
45 |
+
$this->option_name = $meta['name'][0];
|
46 |
+
$this->option_property = $meta['name'][1];
|
47 |
+
} else {
|
48 |
+
$this->option_name = $meta['name'];
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( array_key_exists( 'default', $meta ) ) {
|
52 |
+
$this->default_value = $meta['default'];
|
53 |
+
} else {
|
54 |
+
$this->default_value = false;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Implements \Automattic\Jetpack\Global_Styles\Data_Point interface.
|
60 |
+
*
|
61 |
+
* @return any The value to return.
|
62 |
+
*/
|
63 |
+
public function get_value() {
|
64 |
+
if ( ! isset( $this->option_property ) ) {
|
65 |
+
return get_option( $this->option_name, $this->default_value );
|
66 |
+
}
|
67 |
+
|
68 |
+
$value = get_option( $this->option_name, [] );
|
69 |
+
if ( is_array( $value ) && array_key_exists( $this->option_property, $value ) ) {
|
70 |
+
return $value[ $this->option_property ];
|
71 |
+
}
|
72 |
+
|
73 |
+
return $this->default_value;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Return the option name this data point belongs to.
|
78 |
+
*
|
79 |
+
* @return string Option name
|
80 |
+
*/
|
81 |
+
public function get_option_name() {
|
82 |
+
return $this->option_name;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Process new data.
|
87 |
+
*
|
88 |
+
* @param any $current_option_value Current option value.
|
89 |
+
* @param any $new_value Value to update.
|
90 |
+
* @return any The modified option value.
|
91 |
+
*/
|
92 |
+
public function process_data_point( $current_option_value, $new_value ) {
|
93 |
+
$result = $current_option_value;
|
94 |
+
|
95 |
+
if ( isset( $this->option_property ) ) {
|
96 |
+
$result[ $this->option_property ] = $new_value;
|
97 |
+
} else {
|
98 |
+
$result = $new_value;
|
99 |
+
}
|
100 |
+
|
101 |
+
return $result;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
global-styles/includes/class-data-point-theme.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Data Point Theme.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
require_once __DIR__ . '/interface-data-point.php';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Theme Data Point.
|
14 |
+
*/
|
15 |
+
class Data_Point_Theme implements Data_Point {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Feature name.
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
private $feature_name;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Option property to access, if exists.
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
private $feature_property;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Default value to return if no found.
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
private $default_value;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Constructor.
|
40 |
+
*
|
41 |
+
* @param array $meta Data point description.
|
42 |
+
*/
|
43 |
+
public function __construct( $meta ) {
|
44 |
+
if ( is_array( $meta['name'] ) ) {
|
45 |
+
$this->feature_name = $meta['name'][0];
|
46 |
+
$this->feature_property = $meta['name'][1];
|
47 |
+
} else {
|
48 |
+
$this->feature_name = $meta['name'];
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( array_key_exists( 'default', $meta ) ) {
|
52 |
+
$this->default_value = $meta['default'];
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Implements the \Automattic\Jetpack\Global_Styles\Data_Point interface.
|
58 |
+
*/
|
59 |
+
public function get_value() {
|
60 |
+
$theme_support = get_theme_support( $this->feature_name )[0];
|
61 |
+
|
62 |
+
if ( false === $theme_support || true === $theme_support ) {
|
63 |
+
return $this->default_value;
|
64 |
+
}
|
65 |
+
|
66 |
+
if (
|
67 |
+
is_array( $theme_support ) &&
|
68 |
+
! isset( $this->feature_property )
|
69 |
+
) {
|
70 |
+
return $theme_support;
|
71 |
+
}
|
72 |
+
|
73 |
+
if (
|
74 |
+
is_array( $theme_support ) &&
|
75 |
+
isset( $this->feature_property ) &&
|
76 |
+
array_key_exists( $this->feature_property, $theme_support )
|
77 |
+
) {
|
78 |
+
return $theme_support[ $this->feature_property ];
|
79 |
+
}
|
80 |
+
|
81 |
+
if (
|
82 |
+
is_array( $theme_support ) &&
|
83 |
+
isset( $this->feature_property ) &&
|
84 |
+
! array_key_exists( $this->feature_property, $theme_support )
|
85 |
+
) {
|
86 |
+
return $this->default_value;
|
87 |
+
}
|
88 |
+
|
89 |
+
return $this->default_value;
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
global-styles/includes/class-data-set.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Data Set.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Utility to retrieve data from a description.
|
12 |
+
*/
|
13 |
+
class Data_Set {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Description of the data points to work with.
|
17 |
+
*
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
private $data_meta = [];
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set of objects that implement the Data_Point interface.
|
24 |
+
*
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
private $data_set = [];
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Constructor
|
31 |
+
*
|
32 |
+
* @param array $data_meta Description of the data points to work with.
|
33 |
+
*/
|
34 |
+
public function __construct( $data_meta ) {
|
35 |
+
$this->data_meta = $data_meta;
|
36 |
+
$this->data_set = $this->build_data_set( $data_meta );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Build data set from the meta data provided.
|
41 |
+
*
|
42 |
+
* @param array $data_meta Meta data description.
|
43 |
+
* @return array The data set structure.
|
44 |
+
*/
|
45 |
+
private function build_data_set( $data_meta ) {
|
46 |
+
require_once __DIR__ . '/class-data-point-literal.php';
|
47 |
+
require_once __DIR__ . '/class-data-point-option.php';
|
48 |
+
require_once __DIR__ . '/class-data-point-theme.php';
|
49 |
+
|
50 |
+
$result = [];
|
51 |
+
foreach ( $data_meta as $key => $meta ) {
|
52 |
+
if ( $this->is_data_point_literal( $meta ) ) {
|
53 |
+
$result[ $key ] = new Data_Point_Literal( $meta );
|
54 |
+
} elseif ( $this->is_data_point_option( $meta ) ) {
|
55 |
+
$result[ $key ] = new Data_Point_Option( $meta );
|
56 |
+
} elseif ( $this->is_data_point_theme( $meta ) ) {
|
57 |
+
$result[ $key ] = new Data_Point_Theme( $meta );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return $result;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Whether the description provided is a data point
|
65 |
+
* whose value should be taken literally.
|
66 |
+
*
|
67 |
+
* @param array $meta Data point description.
|
68 |
+
* @return boolean
|
69 |
+
*/
|
70 |
+
private function is_data_point_literal( $meta ) {
|
71 |
+
return array_key_exists( 'type', $meta ) && 'literal' === $meta['type'];
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Whether the description provided is a data point
|
76 |
+
* whose value should be taken from an option.
|
77 |
+
*
|
78 |
+
* @param array $meta Data point description.
|
79 |
+
* @return boolean
|
80 |
+
*/
|
81 |
+
private function is_data_point_option( $meta ) {
|
82 |
+
return array_key_exists( 'type', $meta ) &&
|
83 |
+
'option' === $meta['type'] &&
|
84 |
+
array_key_exists( 'name', $meta );
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Whether the description provided is a data point
|
89 |
+
* that can be updated.
|
90 |
+
*
|
91 |
+
* @param array $meta Data point description.
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
private function is_data_point_updatable( $meta ) {
|
95 |
+
return $this->is_data_point_option( $meta ) &&
|
96 |
+
array_key_exists( 'updatable', $meta ) &&
|
97 |
+
$meta['updatable'];
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Whether the description provided is a data point
|
102 |
+
* whose value should be taken from theme support.
|
103 |
+
*
|
104 |
+
* @param array $meta Data point description.
|
105 |
+
* @return boolean
|
106 |
+
*/
|
107 |
+
private function is_data_point_theme( $meta ) {
|
108 |
+
return array_key_exists( 'name', $meta ) &&
|
109 |
+
array_key_exists( 'type', $meta ) &&
|
110 |
+
'theme' === $meta['type'];
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Process the data description given and return the values.
|
115 |
+
*
|
116 |
+
* @return array Values.
|
117 |
+
*/
|
118 |
+
public function get_data() {
|
119 |
+
$result = [];
|
120 |
+
foreach ( $this->data_set as $key => $data_point ) {
|
121 |
+
$result[ $key ] = $data_point->get_value();
|
122 |
+
}
|
123 |
+
|
124 |
+
$result = apply_filters( 'jetpack_global_styles_data_set_get_data', $result );
|
125 |
+
|
126 |
+
return $result;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Process incoming data.
|
131 |
+
*
|
132 |
+
* @param array $incoming_data Incoming data.
|
133 |
+
*/
|
134 |
+
public function save_data( $incoming_data ) {
|
135 |
+
$to_update = [];
|
136 |
+
|
137 |
+
$incoming_data = apply_filters( 'jetpack_global_styles_data_set_save_data', $incoming_data );
|
138 |
+
|
139 |
+
$options_updatable = array_filter(
|
140 |
+
$this->data_meta,
|
141 |
+
[ $this, 'is_data_point_updatable' ]
|
142 |
+
);
|
143 |
+
foreach ( $options_updatable as $key => $meta ) {
|
144 |
+
$option_name = $this->data_set[ $key ]->get_option_name();
|
145 |
+
|
146 |
+
// Get current value, if we haven't yet.
|
147 |
+
if ( ! array_key_exists( $option_name, $to_update ) ) {
|
148 |
+
$to_update[ $option_name ] = get_option( $option_name );
|
149 |
+
}
|
150 |
+
|
151 |
+
// Override with incoming value, if appropiate.
|
152 |
+
// At this point it should have been validated, sanitized, etc.
|
153 |
+
if ( array_key_exists( $key, $incoming_data ) ) {
|
154 |
+
$to_update[ $option_name ] = $this->data_set[ $key ]->process_data_point( $to_update[ $option_name ], $incoming_data[ $key ] );
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
$did_update = false;
|
159 |
+
foreach ( $to_update as $key => $value ) {
|
160 |
+
if ( update_option( $key, $value ) ) {
|
161 |
+
$did_update = true;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
return $did_update;
|
166 |
+
}
|
167 |
+
}
|
global-styles/includes/class-json-endpoint.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* JSON REST API endpoint for Global Styles plugin.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* REST API endpoint for Global Styles plugin.
|
12 |
+
*/
|
13 |
+
class JSON_Endpoint extends \WP_REST_Controller {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Namespace for the REST endpoint.
|
17 |
+
*
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
private $rest_namespace;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Route name for the REST endpoint.
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
private $rest_route;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Object holding the data description to work with.
|
31 |
+
*
|
32 |
+
* @var Automattic\Jetpack\Global_Styles\Data_Set
|
33 |
+
*/
|
34 |
+
private $data_set;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Permission check callback.
|
38 |
+
*
|
39 |
+
* @var callable
|
40 |
+
*/
|
41 |
+
private $permission_cb;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Constructor
|
45 |
+
*
|
46 |
+
* @param string $rest_namespace Namespace for the REST endpoint.
|
47 |
+
* @param string $rest_route Route name.
|
48 |
+
* @param array $data_set Description of the data to work with.
|
49 |
+
* @param callable $permission_cb Permission check callback.
|
50 |
+
*/
|
51 |
+
public function __construct( $rest_namespace, $rest_route, $data_set, $permission_cb ) {
|
52 |
+
$this->rest_namespace = $rest_namespace;
|
53 |
+
$this->rest_route = $rest_route;
|
54 |
+
$this->data_set = $data_set;
|
55 |
+
$this->permission_cb = $permission_cb;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Callback to determine whether the request can proceed.
|
60 |
+
*
|
61 |
+
* @return boolean
|
62 |
+
*/
|
63 |
+
public function permission_callback() {
|
64 |
+
return call_user_func( $this->permission_cb );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Initialize the routes. To be called on `rest_api_init'
|
69 |
+
*
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
public function setup() {
|
73 |
+
register_rest_route(
|
74 |
+
$this->rest_namespace,
|
75 |
+
$this->rest_route,
|
76 |
+
[
|
77 |
+
[
|
78 |
+
'methods' => \WP_REST_Server::READABLE,
|
79 |
+
'callback' => [ $this, 'get_data' ],
|
80 |
+
'permission_callback' => [ $this, 'permission_callback' ],
|
81 |
+
],
|
82 |
+
]
|
83 |
+
);
|
84 |
+
register_rest_route(
|
85 |
+
$this->rest_namespace,
|
86 |
+
$this->rest_route,
|
87 |
+
[
|
88 |
+
[
|
89 |
+
'methods' => \WP_REST_Server::CREATABLE,
|
90 |
+
'callback' => [ $this, 'update_data' ],
|
91 |
+
'permission_callback' => [ $this, 'permission_callback' ],
|
92 |
+
],
|
93 |
+
]
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Process the incoming request to get data.
|
99 |
+
*
|
100 |
+
* @return Array
|
101 |
+
*/
|
102 |
+
public function get_data() {
|
103 |
+
return $this->data_set->get_data();
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Process the incoming request to update data.
|
108 |
+
*
|
109 |
+
* @param \WP_REST_Request $request Incoming request.
|
110 |
+
* @return Boolean False if data hasn't changed or update failed, true otherwise.
|
111 |
+
*/
|
112 |
+
public function update_data( \WP_REST_Request $request ) {
|
113 |
+
$incoming_data = $request->get_json_params();
|
114 |
+
return $this->data_set->save_data( $incoming_data );
|
115 |
+
}
|
116 |
+
}
|
global-styles/includes/interface-data-point.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Interface Data Point.
|
4 |
+
*
|
5 |
+
* @package Automattic\Jetpack\Global_Styles
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Automattic\Jetpack\Global_Styles;
|
9 |
+
|
10 |
+
interface Data_Point {
|
11 |
+
/**
|
12 |
+
* Return value of the data point.
|
13 |
+
*
|
14 |
+
* @return any
|
15 |
+
*/
|
16 |
+
public function get_value();
|
17 |
+
}
|
global-styles/index.js
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { registerPlugin } from '@wordpress/plugins';
|
5 |
+
import { withDispatch, withSelect, select } from '@wordpress/data';
|
6 |
+
import { compose } from '@wordpress/compose';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Internal dependencies
|
10 |
+
*/
|
11 |
+
import registerStore from './src/store';
|
12 |
+
import registerDOMUpdater from './src/dom-updater';
|
13 |
+
import GlobalStylesSidebar from './src/global-styles-sidebar';
|
14 |
+
import {
|
15 |
+
FONT_BASE,
|
16 |
+
FONT_BASE_DEFAULT,
|
17 |
+
FONT_HEADINGS,
|
18 |
+
FONT_HEADINGS_DEFAULT,
|
19 |
+
FONT_PAIRINGS,
|
20 |
+
FONT_OPTIONS,
|
21 |
+
SITE_NAME,
|
22 |
+
} from './src/constants';
|
23 |
+
|
24 |
+
// Tell Webpack to compile this into CSS
|
25 |
+
import './editor.scss';
|
26 |
+
|
27 |
+
// Global variable.
|
28 |
+
const { PLUGIN_NAME, STORE_NAME, REST_PATH } = JETPACK_GLOBAL_STYLES_EDITOR_CONSTANTS; // eslint-disable-line no-undef
|
29 |
+
|
30 |
+
registerStore( STORE_NAME, REST_PATH );
|
31 |
+
registerDOMUpdater( [ FONT_BASE, FONT_HEADINGS ], select( STORE_NAME ).getOption );
|
32 |
+
|
33 |
+
registerPlugin( PLUGIN_NAME, {
|
34 |
+
render: compose(
|
35 |
+
withSelect( getSelectors => ( {
|
36 |
+
siteName: getSelectors( STORE_NAME ).getOption( SITE_NAME ),
|
37 |
+
fontHeadings: getSelectors( STORE_NAME ).getOption( FONT_HEADINGS ),
|
38 |
+
fontHeadingsDefault: getSelectors( STORE_NAME ).getOption( FONT_HEADINGS_DEFAULT ),
|
39 |
+
fontBase: getSelectors( STORE_NAME ).getOption( FONT_BASE ),
|
40 |
+
fontBaseDefault: getSelectors( STORE_NAME ).getOption( FONT_BASE_DEFAULT ),
|
41 |
+
fontPairings: getSelectors( STORE_NAME ).getOption( FONT_PAIRINGS ),
|
42 |
+
fontOptions: getSelectors( STORE_NAME ).getOption( FONT_OPTIONS ),
|
43 |
+
hasLocalChanges: getSelectors( STORE_NAME ).hasLocalChanges(),
|
44 |
+
} ) ),
|
45 |
+
withDispatch( dispatch => ( {
|
46 |
+
updateOptions: dispatch( STORE_NAME ).updateOptions,
|
47 |
+
publishOptions: dispatch( STORE_NAME ).publishOptions,
|
48 |
+
resetLocalChanges: dispatch( STORE_NAME ).resetLocalChanges,
|
49 |
+
} ) )
|
50 |
+
)( GlobalStylesSidebar ),
|
51 |
+
} );
|
global-styles/src/constants.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const FONT_BASE = 'font_base';
|
2 |
+
export const FONT_BASE_DEFAULT = 'font_base_default';
|
3 |
+
export const FONT_HEADINGS = 'font_headings';
|
4 |
+
export const FONT_HEADINGS_DEFAULT = 'font_headings_default';
|
5 |
+
export const FONT_PAIRINGS = 'font_pairings';
|
6 |
+
export const FONT_OPTIONS = 'font_options';
|
7 |
+
export const SITE_NAME = 'blogname';
|
global-styles/src/dom-updater.js
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { subscribe } from '@wordpress/data';
|
5 |
+
import domReady from '@wordpress/dom-ready';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* DOM updater
|
9 |
+
*
|
10 |
+
* @param {string[]} options A list of option names to keep track of.
|
11 |
+
* @param {Function} getOptionValue A function that given an option name as a string, returns the current option value.
|
12 |
+
*/
|
13 |
+
export default ( options, getOptionValue ) => {
|
14 |
+
domReady( () => {
|
15 |
+
const current = {};
|
16 |
+
const cssVariables = {};
|
17 |
+
options.forEach( option => {
|
18 |
+
current[ option ] = null;
|
19 |
+
cssVariables[ option ] = `--${ option.replace( '_', '-' ) }`;
|
20 |
+
} );
|
21 |
+
|
22 |
+
subscribe( () => {
|
23 |
+
Object.keys( current ).forEach( key => {
|
24 |
+
const value = getOptionValue( key );
|
25 |
+
if ( current[ key ] !== value ) {
|
26 |
+
current[ key ] = value;
|
27 |
+
// We want to scope this to the root node of the editor.
|
28 |
+
const node = document.getElementsByClassName( 'editor-styles-wrapper' )[ 0 ];
|
29 |
+
if ( node ) {
|
30 |
+
node.style.setProperty( cssVariables[ key ], value );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
} );
|
34 |
+
} );
|
35 |
+
} );
|
36 |
+
};
|
global-styles/src/font-pairings-panel-previews.js
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { Path, SVG } from '@wordpress/components';
|
5 |
+
|
6 |
+
const SpaceLora = () => (
|
7 |
+
<SVG width="232" height="132" viewBox="0 0 232 132" xmlns="http://www.w3.org/2000/svg">
|
8 |
+
<Path fill="#fa4d4b" d="M0 0h232v132H0z" />
|
9 |
+
<Path
|
10 |
+
d="M24.1 62c-3.6-2.9-8.9-5-15.8-6.3-2.8-.5-5-1-6.9-1.6-.5-.2-1-.3-1.5-.5v12.5c1.4.3 2.9.6 4.4.9 2.5.4 4.6 1 6.2 1.6s2.9 1.3 3.9 2.2c.9.8 1.6 1.6 2 2.6.4.9.6 1.9.6 3 0 2.3-.9 4.2-2.7 5.8-1.8 1.6-4.6 2.4-8.4 2.4-2.2 0-4.2-.3-5.9-.8v12c1.8.3 3.7.4 5.7.4 3.7 0 7-.5 10-1.4 2.9-.9 5.5-2.3 7.5-4s3.6-3.9 4.7-6.3c1.1-2.5 1.7-5.3 1.7-8.4V75c0-5.7-1.8-10-5.5-13zM12.9 42.5c2.1 1.9 3.1 4.2 3.1 6.9v2.3h12.4v-3.4c0-2.7-.5-5.3-1.6-7.7-1-2.4-2.5-4.6-4.6-6.5-2-1.9-4.5-3.4-7.5-4.4-3-1.1-6.5-1.7-10.3-1.7-1.5 0-3 .1-4.4.3v11.9c1.3-.4 2.7-.5 4.4-.5 3.7-.2 6.5.8 8.5 2.8zm67.9 10.9c-1.8-2.1-4-3.6-6.5-4.7-2.4-1.1-5-1.6-7.8-1.6-3.7 0-6.7.7-9.1 2.2-2.4 1.4-4.2 3.4-5.5 5.9h-1.7v-6.8H38.4v65.4h11.8V88.2H52c.6 1.1 1.2 2.1 2 3.1.8.9 1.8 1.8 2.9 2.5 1.2.8 2.6 1.3 4.1 1.8 1.6.4 3.4.7 5.5.7 2.9 0 5.5-.5 8-1.5 2.5-1.1 4.7-2.6 6.5-4.6 1.8-2.1 3.3-4.6 4.3-7.5 1.1-2.9 1.6-6.3 1.6-10.2v-1.7c0-3.8-.6-7.1-1.7-10.1-1-2.9-2.5-5.3-4.4-7.3zm-5.7 18.9c0 3.9-1.2 7.1-3.5 9.4-2.3 2.3-5.2 3.4-8.9 3.4s-6.7-1.2-9-3.5c-2.3-2.4-3.4-5.5-3.4-9.3v-1.1c0-3.8 1.1-6.9 3.4-9.2 2.3-2.4 5.3-3.6 9-3.6s6.7 1.2 8.9 3.5c2.3 2.3 3.5 5.4 3.5 9.3v1.1zm66.2 8.6V48.4h-11.8V54h-1.7c-1.2-2.4-2.8-4.1-4.9-5.3-2-1.1-4.7-1.7-8-1.7-2.8 0-5.4.6-7.8 1.7-2.4 1.1-4.5 2.6-6.3 4.7-1.8 2.1-3.3 4.6-4.3 7.6-1.1 2.9-1.6 6.3-1.6 10v1.5c0 3.8.5 7.1 1.6 10.1 1.1 2.9 2.6 5.5 4.5 7.5 1.9 2.1 4 3.6 6.5 4.7s5.2 1.6 8 1.6c3 0 5.6-.6 7.9-1.8 2.3-1.3 4-3.4 5.3-6.3h1.7c0 2 .7 3.6 2 4.9 1.4 1.3 3.1 1.9 5.3 1.9h8.1V83.7H144c-1.8 0-2.7-.9-2.7-2.8zm-11.8-8.6c0 3.9-1 7.1-3.1 9.4-2.1 2.3-4.8 3.4-8.3 3.4-3.4 0-6.2-1.1-8.3-3.4-2.1-2.3-3.1-5.5-3.1-9.4v-1.1c0-3.9 1-7.1 3.1-9.3 2.1-2.3 4.8-3.5 8.3-3.5 3.4 0 6.2 1.2 8.3 3.5 2.1 2.3 3.1 5.4 3.1 9.3v1.1zm98.3-12.2c1.2-1 2.6-1.6 4.2-2V47.3c-2.1.3-4 .8-5.9 1.6-2.8 1.1-5.3 2.7-7.4 4.8-2.1 2.1-3.8 4.6-5.1 7.5-1.2 2.9-1.8 6.2-1.8 9.8v.6c0 3.9.6 7.4 1.7 10.4 1.2 3.1 2.8 5.7 4.9 7.8 2.1 2.1 4.6 3.8 7.5 4.9 1.9.7 4 1.2 6.1 1.5V84.7c-.4-.1-.7-.2-1.1-.3-1.3-.5-2.5-1.2-3.6-2-1-.9-1.8-1.9-2.4-3-.6-1.2-.9-2.5-.9-3.9h8V65.4h-7.8c.5-2 1.8-3.8 3.6-5.3zm-61.5 6.1c.7-1.7 1.6-3.1 2.7-4.2 1.1-1.2 2.4-2.1 3.9-2.7 1.5-.6 3.1-.9 4.8-.9 3.6 0 6.5 1 8.5 3s3.2 4.4 3.6 7.1l11.7-3c-1.1-5.5-3.6-10-7.7-13.3-4-3.4-9.3-5.1-15.8-5.1-3.4 0-6.6.6-9.6 1.7-2.9 1.1-5.5 2.8-7.8 4.9-2.2 2.1-3.9 4.7-5.2 7.7s-1.9 6.4-1.9 10.2v1.1c0 3.8.6 7.1 1.9 10.1 1.3 2.9 3 5.4 5.2 7.4s4.8 3.5 7.7 4.6c3 1.1 6.2 1.6 9.7 1.6 6.6 0 11.9-1.7 15.9-5.1 4-3.4 6.5-7.8 7.6-13.3l-11.7-3c-.6 3.1-1.8 5.5-3.8 7.3-1.9 1.8-4.6 2.7-8.3 2.7-1.7 0-3.3-.3-4.8-.8-1.5-.6-2.8-1.4-3.9-2.4-1.1-1.1-2-2.4-2.7-3.9-.6-1.6-.9-3.5-.9-5.5v-.6c0-2.1.3-3.9.9-5.6z"
|
11 |
+
fill="#270920"
|
12 |
+
/>
|
13 |
+
<Path
|
14 |
+
d="M49.7 89.3c-1.1 1.3-2.6 2-4.5 2h-6.5c.1-1.1.2-2.5.2-4.3V68.5c0-1.3.1-2.2.4-2.8s.6-1 1.1-1.1c.5-.2 1.1-.3 2-.3v-3.2h-14v3.7l3.6-.1c-.1 1.1-.2 2.5-.2 4.4v18.5c0 1.3-.1 2.2-.4 2.8-.3.6-.6 1-1.1 1.2-.5.2-1.1.3-2 .3V95h25.8l.3-11.6h-3.2c.1 2.6-.5 4.5-1.5 5.9zM101.3 70c-2.5 0-4.8 1.5-7 4.5h-.1v-2.3c0-.8-.1-1.4-.1-1.9h-2.4c-.4.4-1.3.7-2.5 1-1.3.3-2.9.4-4.9.4v3.7l3.4-.1c-.1 1.3-.2 2.7-.2 4.1v8.1c0 1.5-.2 2.6-.5 3.3-.3.7-1.1 1-2.3 1V95h12.7v-3.7c-1.1 0-2.1 0-3.1.1.1-1.3.2-2.7.2-4.3v-7.9c.3-1 1-2.1 1.9-3.1 1-1.1 1.9-1.6 2.8-1.6.1 1 .5 1.8 1.1 2.2.6.4 1.4.6 2.2.6 1.1 0 1.9-.4 2.5-1.1.5-.7.8-1.5.8-2.3 0-1.3-.4-2.3-1.2-3-1-.5-2-.9-3.3-.9zm25.8 21.5c.1-1.3.2-2.7.2-4.3v-7.9c0-6.2-3-9.2-9-9.2-1.9 0-3.6.3-5.2.8-1.5.5-2.8 1.3-3.7 2.2-.9 1-1.4 2.1-1.4 3.3 0 .9.3 1.7.8 2.4.5.6 1.3.9 2.3.9 1 0 1.8-.3 2.3-.9.5-.6.8-1.3.8-2.1s-.2-1.4-.6-1.8c.9-.9 2.1-1.4 3.5-1.4 2.2 0 3.3 1.5 3.3 4.4v2.5c-3.7.2-6.9 1-9.5 2.5-2.6 1.5-4 3.6-4 6.4 0 1.9.6 3.4 1.7 4.6 1.2 1.2 2.8 1.8 4.8 1.8 2.8 0 5.2-1 7.2-3 .1 1.1.1 1.8.2 2.2h9.1v-3.7c-.7.1-1.8.2-2.8.3zm-6.6-2.2c-1.1 1.2-2.4 1.7-3.8 1.7-.8 0-1.4-.2-2-.6-.5-.4-.8-1.1-.8-1.9 0-1.3.6-2.4 1.8-3.1 1.3-.8 2.8-1.3 4.7-1.5v5.4zM75.1 71.5c-1.8-1-3.9-1.5-6.2-1.5-2.2 0-4.3.6-6.1 1.7-1.8 1.1-3.3 2.7-4.4 4.7-1.1 2-1.6 4.4-1.6 7 0 2.5.5 4.7 1.6 6.5 1.1 1.9 2.5 3.3 4.4 4.3 1.9 1 4 1.5 6.3 1.5 2.4 0 4.4-.5 6.2-1.6 1.8-1.1 3.3-2.6 4.3-4.6 1-2 1.5-4.3 1.5-7 0-2.5-.5-4.7-1.6-6.6-1.1-1.9-2.5-3.4-4.4-4.4zm-2.2 18.4c-.7 1.6-2 2.5-3.7 2.5-1.8 0-3.1-1-4-3-.9-2-1.3-4.4-1.3-7.2 0-2.5.4-4.5 1.2-6.2.8-1.7 2.1-2.5 3.9-2.5 1.7 0 3 1 3.8 3s1.2 4.4 1.2 7.2c-.1 2.5-.4 4.5-1.1 6.2z"
|
15 |
+
fill="#fff"
|
16 |
+
/>
|
17 |
+
</SVG>
|
18 |
+
);
|
19 |
+
|
20 |
+
const SystemBasker = () => (
|
21 |
+
<SVG width="232" height="132" viewBox="0 0 232 132" xmlns="http://www.w3.org/2000/svg">
|
22 |
+
<Path fill="#F18F1B" d="M0 0h232v132H0z" />
|
23 |
+
<Path
|
24 |
+
d="M10.016 50.563c.14 4.25 3.718 6.828 9.093 6.828 5.641 0 9.094-2.797 9.094-7.203 0-3.422-2.078-5.344-6.844-6.297l-2.39-.485c-2.657-.531-3.75-1.39-3.75-2.781 0-1.656 1.562-2.75 3.89-2.75 2.375 0 4.047 1.156 4.203 3.078h4.454c-.078-4.14-3.391-6.89-8.657-6.89-5.015 0-8.609 2.734-8.609 6.859 0 3.36 2.203 5.516 6.703 6.406l2.375.469c2.828.578 3.89 1.422 3.89 2.906 0 1.656-1.718 2.875-4.234 2.875-2.562 0-4.468-1.125-4.765-3.016h-4.453zM53 37v-8.422l7.86-14.125h-5.063l-5.063 9.625h-.109l-5.047-9.625h-5.14l7.843 14.125V37H53zM73.016 60.563c.14 4.25 3.718 6.828 9.093 6.828 5.641 0 9.094-2.797 9.094-7.204 0-3.421-2.078-5.343-6.844-6.296l-2.39-.485c-2.656-.531-3.75-1.39-3.75-2.781 0-1.656 1.562-2.75 3.89-2.75 2.375 0 4.047 1.156 4.204 3.078h4.453c-.079-4.14-3.391-6.89-8.657-6.89-5.015 0-8.609 2.734-8.609 6.859 0 3.36 2.203 5.516 6.703 6.406l2.375.469c2.828.578 3.89 1.422 3.89 2.906 0 1.656-1.718 2.875-4.234 2.875-2.562 0-4.468-1.125-4.765-3.016h-4.453zM114.984 47V28.344h6.532v-3.89H103.75v3.89h6.516V47h4.718zM149.812 43.094h-10.218v-5.688h9.64v-3.625h-9.64v-5.437h10.218v-3.89h-14.937V47h14.937v-3.906zM187.75 37V14.453h-5.469l-6.406 16.188h-.125l-6.406-16.188h-5.469V37h4.203V21.781h.125L174.328 37h2.969l6.125-15.219h.125V37h4.203z"
|
25 |
+
fill="#492B06"
|
26 |
+
/>
|
27 |
+
<Path
|
28 |
+
d="M22.032 92H9.63v-.72c.396-.012.72-.048.972-.108s.444-.162.576-.306c.132-.144.222-.348.27-.612.048-.264.072-.606.072-1.026v-8.316c0-.42-.024-.756-.072-1.008-.036-.264-.114-.468-.234-.612a.852.852 0 0 0-.522-.306 4.454 4.454 0 0 0-.864-.126v-.72h6.21v.72a5.062 5.062 0 0 0-.99.108c-.24.06-.426.168-.558.324-.132.156-.222.372-.27.648a8.868 8.868 0 0 0-.054 1.098v7.542c0 .504.048.918.144 1.242.108.312.288.558.54.738.252.168.588.288 1.008.36.42.06.942.09 1.566.09.696 0 1.278-.042 1.746-.126.468-.084.858-.24 1.17-.468.324-.24.582-.558.774-.954.192-.396.354-.912.486-1.548h.72L22.032 92zm5.182-2.952c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V86.96c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v6.768zm-2.646-10.584c0-.396.132-.726.396-.99a1.35 1.35 0 0 1 .99-.414c.396 0 .726.138.99.414.276.264.414.594.414.99 0 .384-.138.714-.414.99a1.343 1.343 0 0 1-.99.396c-.384 0-.714-.132-.99-.396a1.382 1.382 0 0 1-.396-.99zm8.574 9.594c0 .444.06.858.18 1.242.132.372.306.696.522.972.216.276.474.492.774.648.3.156.63.234.99.234.72 0 1.266-.33 1.638-.99.372-.66.558-1.632.558-2.916 0-1.248-.186-2.196-.558-2.844-.36-.66-.906-.99-1.638-.99-.432 0-.834.12-1.206.36-.36.228-.642.552-.846.972-.276.576-.414 1.302-.414 2.178v1.134zm-.036-4.356h.072a3.07 3.07 0 0 1 1.206-1.044c.492-.252 1.05-.378 1.674-.378.636 0 1.224.132 1.764.396.552.252 1.026.6 1.422 1.044.408.444.726.966.954 1.566.228.6.342 1.242.342 1.926 0 .72-.126 1.386-.378 1.998-.24.6-.576 1.122-1.008 1.566-.42.444-.918.792-1.494 1.044a4.362 4.362 0 0 1-1.8.378c-.66 0-1.284-.126-1.872-.378-.576-.264-1.038-.606-1.386-1.026L31.234 92h-.612V81.29c0-1.128-.078-1.902-.234-2.322a.93.93 0 0 0-.126-.216.488.488 0 0 0-.216-.144 1.07 1.07 0 0 0-.36-.108 7.62 7.62 0 0 0-.612-.108v-.612l4.032-.72v6.642zm12.759 5.508c0 .468.018.84.054 1.116.048.264.138.468.27.612.132.144.324.24.576.288.252.036.588.054 1.008.054V92H41.76v-.72c.36-.024.648-.06.864-.108.216-.048.378-.144.486-.288.108-.144.174-.348.198-.612.036-.276.054-.642.054-1.098v-2.196c0-.744-.018-1.338-.054-1.782-.036-.444-.114-.786-.234-1.026a.867.867 0 0 0-.522-.468c-.216-.084-.504-.126-.864-.126v-.63l3.6-.666.288 2.07h.072c.324-.636.75-1.14 1.278-1.512.528-.372 1.086-.558 1.674-.558.456 0 .828.114 1.116.342.288.228.432.516.432.864 0 .384-.114.708-.342.972-.216.264-.516.396-.9.396-.18 0-.342-.036-.486-.108a3.131 3.131 0 0 1-.396-.234 2.28 2.28 0 0 0-.342-.252.549.549 0 0 0-.342-.126c-.228 0-.444.15-.648.45-.204.3-.372.702-.504 1.206a9.68 9.68 0 0 0-.234 1.224c-.06.444-.09.888-.09 1.332v.864zM59.8 90.326c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61zM65.985 92v-.72a4.75 4.75 0 0 0 .972-.108c.252-.06.444-.162.576-.306.144-.144.24-.348.288-.612.048-.264.072-.606.072-1.026v-8.316c0-.42-.018-.756-.054-1.008-.036-.264-.114-.468-.234-.612a.755.755 0 0 0-.468-.306 3.572 3.572 0 0 0-.774-.126v-.72h5.778c1.812 0 3.204.294 4.176.882.984.576 1.476 1.404 1.476 2.484 0 1.428-1.026 2.436-3.078 3.024v.072c.66 0 1.254.096 1.782.288.54.18.996.438 1.368.774a3.523 3.523 0 0 1 1.17 2.682c0 .612-.15 1.146-.45 1.602-.288.456-.708.84-1.26 1.152-1.068.6-2.538.9-4.41.9h-6.93zm7.056-1.098c1.932 0 2.898-.87 2.898-2.61 0-1.068-.348-1.848-1.044-2.34-.36-.252-.828-.432-1.404-.54-.564-.108-1.26-.162-2.088-.162h-.864v3.6c0 .744.192 1.272.576 1.584.384.312 1.026.468 1.926.468zM71.6 84.17c.54 0 1.008-.048 1.404-.144a3.249 3.249 0 0 0 1.008-.45c.576-.396.864-1.014.864-1.854 0-.876-.216-1.506-.648-1.89-.432-.396-1.128-.594-2.088-.594h-1.278c-.216 0-.324.102-.324.306v4.626H71.6zm14.325 2.7c-1.008.456-1.77.882-2.286 1.278-.504.384-.756.786-.756 1.206 0 .348.096.624.288.828a.948.948 0 0 0 .72.306c.288 0 .558-.048.81-.144.252-.108.468-.246.648-.414.18-.168.318-.366.414-.594.108-.24.162-.492.162-.756v-1.71zm0-.954v-.756c0-.696-.126-1.2-.378-1.512-.24-.324-.618-.486-1.134-.486-.348 0-.612.096-.792.288-.18.18-.348.486-.504.918-.108.3-.264.534-.468.702-.192.168-.462.252-.81.252-.336 0-.594-.102-.774-.306-.18-.204-.27-.492-.27-.864 0-.576.312-1.032.936-1.368.636-.336 1.59-.504 2.862-.504 1.344 0 2.304.246 2.88.738.576.48.864 1.29.864 2.43v3.942c0 1.02.204 1.53.612 1.53a.978.978 0 0 0 .63-.234l.27.522c-.168.3-.432.54-.792.72a2.7 2.7 0 0 1-1.188.252c-.552 0-.972-.168-1.26-.504-.288-.336-.432-.81-.432-1.422h-.09c-.348.624-.798 1.098-1.35 1.422-.552.324-1.182.486-1.89.486-.756 0-1.362-.21-1.818-.63-.456-.432-.684-.99-.684-1.674 0-.528.234-1.02.702-1.476.468-.468 1.248-.924 2.34-1.368l2.538-1.098zM91.6 92h-.558v-3.276h.756c.204.864.498 1.494.882 1.89.384.396.882.594 1.494.594.444 0 .786-.09 1.026-.27a.923.923 0 0 0 .378-.774c0-.336-.15-.66-.45-.972-.3-.324-.786-.666-1.458-1.026-.912-.492-1.566-.978-1.962-1.458a2.574 2.574 0 0 1-.594-1.656c0-.396.072-.762.216-1.098.156-.348.36-.648.612-.9.264-.252.576-.444.936-.576.36-.144.75-.216 1.17-.216.372 0 .738.054 1.098.162.372.108.696.258.972.45l.324-.432h.468v2.718h-.702c-.276-.684-.564-1.176-.864-1.476-.288-.3-.642-.45-1.062-.45-.336 0-.606.09-.81.27-.192.18-.288.42-.288.72 0 .336.144.654.432.954.3.3.792.63 1.476.99.48.264.894.522 1.242.774s.63.51.846.774c.216.252.372.522.468.81.108.276.162.576.162.9 0 .42-.078.798-.234 1.134a2.462 2.462 0 0 1-.666.864c-.288.24-.636.426-1.044.558-.396.132-.84.198-1.332.198-.516 0-.996-.066-1.44-.198-.444-.144-.81-.348-1.098-.612L91.6 92zm13.299-.72c.384 0 .654-.012.81-.036.156-.036.234-.102.234-.198 0-.072-.084-.246-.252-.522-.156-.288-.36-.618-.612-.99l-1.368-2.052-.9.864v.702c0 .468.018.846.054 1.134.036.288.096.516.18.684a.759.759 0 0 0 .378.324c.168.06.378.09.63.09V92h-5.31v-.72c.336-.012.606-.048.81-.108a.969.969 0 0 0 .486-.306c.12-.156.198-.366.234-.63a6.4 6.4 0 0 0 .072-1.062v-7.632c0-.732-.012-1.308-.036-1.728-.024-.42-.09-.732-.198-.936a.647.647 0 0 0-.468-.396 3.877 3.877 0 0 0-.846-.072v-.666l4.014-.684v10.008l1.728-1.638a28.697 28.697 0 0 0 1.332-1.314c.264-.3.396-.516.396-.648 0-.108-.114-.18-.342-.216-.216-.048-.624-.072-1.224-.072v-.72h4.914v.72c-.456 0-.858.078-1.206.234-.348.156-.726.426-1.134.81l-1.746 1.638 3.114 4.41c.276.384.546.648.81.792.264.144.612.216 1.044.216V92h-5.598v-.72zm14.737-.954c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61zm8.945 3.618c0 .468.018.84.054 1.116.048.264.138.468.27.612.132.144.324.24.576.288.252.036.588.054 1.008.054V92h-6.012v-.72c.36-.024.648-.06.864-.108.216-.048.378-.144.486-.288.108-.144.174-.348.198-.612.036-.276.054-.642.054-1.098v-2.196c0-.744-.018-1.338-.054-1.782-.036-.444-.114-.786-.234-1.026a.867.867 0 0 0-.522-.468c-.216-.084-.504-.126-.864-.126v-.63l3.6-.666.288 2.07h.072c.324-.636.75-1.14 1.278-1.512.528-.372 1.086-.558 1.674-.558.456 0 .828.114 1.116.342.288.228.432.516.432.864 0 .384-.114.708-.342.972-.216.264-.516.396-.9.396-.18 0-.342-.036-.486-.108a3.131 3.131 0 0 1-.396-.234 2.28 2.28 0 0 0-.342-.252.549.549 0 0 0-.342-.126c-.228 0-.444.15-.648.45-.204.3-.372.702-.504 1.206a9.68 9.68 0 0 0-.234 1.224c-.06.444-.09.888-.09 1.332v.864zm6.139-4.428a5.587 5.587 0 0 0-.378-.828 1.667 1.667 0 0 0-.378-.486.847.847 0 0 0-.414-.234 2.18 2.18 0 0 0-.522-.054v-.72h5.382v.72c-.3 0-.54.012-.72.036-.168.024-.3.06-.396.108a.328.328 0 0 0-.162.198.798.798 0 0 0-.036.252c0 .156.03.336.09.54.06.204.132.408.216.612l1.71 4.716h.072l1.926-4.698a6.35 6.35 0 0 0 .198-.54 1.66 1.66 0 0 0 .072-.45c0-.264-.09-.456-.27-.576-.18-.12-.498-.186-.954-.198v-.72h3.978v.72c-.324 0-.606.084-.846.252-.228.168-.468.54-.72 1.116l-3.366 7.632h-1.638l-2.844-7.398zm14.041 4.266c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V86.96c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v6.768zm-2.646-10.584c0-.396.132-.726.396-.99a1.35 1.35 0 0 1 .99-.414c.396 0 .726.138.99.414.276.264.414.594.414.99 0 .384-.138.714-.414.99a1.343 1.343 0 0 1-.99.396c-.384 0-.714-.132-.99-.396a1.382 1.382 0 0 1-.396-.99zm8.969 10.584c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V81.74c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v11.988zm6.399 0c0 .48.018.864.054 1.152.036.288.108.51.216.666a.833.833 0 0 0 .468.324c.204.048.48.078.828.09V92h-5.67v-.72c.336-.012.606-.048.81-.108a.968.968 0 0 0 .486-.324c.12-.156.198-.366.234-.63.048-.276.072-.624.072-1.044V81.74c0-.696-.012-1.266-.036-1.71-.024-.456-.054-.768-.09-.936-.06-.3-.198-.498-.414-.594-.204-.096-.582-.144-1.134-.144v-.612l4.176-.684v11.988zm11.672 1.278c-1.092 1.236-2.454 1.854-4.086 1.854a5.787 5.787 0 0 1-2.034-.342c-.6-.24-1.116-.57-1.548-.99a4.592 4.592 0 0 1-1.008-1.53c-.24-.588-.36-1.242-.36-1.962 0-.744.126-1.422.378-2.034a4.619 4.619 0 0 1 1.062-1.602 5.01 5.01 0 0 1 1.638-1.062 5.62 5.62 0 0 1 2.088-.378c1.272 0 2.262.342 2.97 1.026.708.684 1.062 1.644 1.062 2.88 0 .192-.03.312-.09.36-.06.036-.228.054-.504.054h-5.796c-.048.108-.072.306-.072.594 0 1.176.252 2.106.756 2.79.516.684 1.212 1.026 2.088 1.026.504 0 1.002-.114 1.494-.342.504-.228.99-.552 1.458-.972l.504.63zm-3.492-4.734c.48 0 .786-.024.918-.072.144-.06.216-.192.216-.396 0-.528-.15-.96-.45-1.296a1.455 1.455 0 0 0-1.134-.504c-.516 0-.978.216-1.386.648-.396.42-.654.96-.774 1.62h2.61z"
|
29 |
+
fill="#FFF1E1"
|
30 |
+
/>
|
31 |
+
</SVG>
|
32 |
+
);
|
33 |
+
|
34 |
+
const RubikWork = () => (
|
35 |
+
<SVG width="232" height="132" viewBox="0 0 232 132" xmlns="http://www.w3.org/2000/svg">
|
36 |
+
<Path fill="#000" d="M0 0h232v132H0z" />
|
37 |
+
<Path
|
38 |
+
d="M14.936 62c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.696c0-.352.128-.656.384-.912s.56-.384.912-.384h14.208c4.608 0 8.208 1.04 10.8 3.12 2.592 2.048 3.888 4.896 3.888 8.544 0 2.08-.464 3.92-1.392 5.52-.928 1.568-2.192 2.864-3.792 3.888l5.904 10.944c.096.192.144.368.144.528 0 .288-.112.544-.336.768a.977.977 0 0 1-.72.288H33.8c-.576 0-1.04-.128-1.392-.384-.32-.288-.544-.592-.672-.912l-4.128-9.168H25.64v9.168c0 .352-.128.656-.384.912s-.56.384-.912.384h-9.408zm14.208-19.584c.704 0 1.248-.224 1.632-.672.384-.48.576-1.072.576-1.776s-.192-1.312-.576-1.824c-.352-.544-.896-.816-1.632-.816H25.64v5.088h3.504zM56.873 62.48c-1.696 0-3.248-.384-4.656-1.152-1.408-.8-2.544-2.016-3.408-3.648-.832-1.632-1.248-3.664-1.248-6.096V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h9.168c.352 0 .656.128.912.384s.384.56.384.912v12.912c0 .864.208 1.52.624 1.968.416.448 1.008.672 1.776.672s1.36-.224 1.776-.672c.416-.448.624-1.104.624-1.968V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h9.12c.352 0 .656.128.912.384s.384.56.384.912v22.368c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.4c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V59.12c-.768 1.12-1.84 1.968-3.216 2.544-1.376.544-2.96.816-4.752.816zm41.127 0c-3.04 0-5.408-.96-7.104-2.88v1.104c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.16c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.216c0-.352.128-.656.384-.912s.56-.384.912-.384h8.88c.352 0 .656.128.912.384s.384.56.384.912v9.6C93.28 37.312 95.408 36.56 98 36.56c2.912 0 5.296.944 7.152 2.832 1.888 1.856 2.896 4.592 3.024 8.208.032.48.048 1.104.048 1.872 0 .8-.016 1.44-.048 1.92-.16 3.808-1.152 6.608-2.976 8.4-1.824 1.792-4.224 2.688-7.2 2.688zm-3.984-8.592c.832 0 1.408-.224 1.728-.672.352-.448.576-1.152.672-2.112.064-.64.096-1.168.096-1.584 0-.416-.032-.944-.096-1.584-.096-.96-.32-1.664-.672-2.112-.32-.448-.896-.672-1.728-.672-.8 0-1.392.208-1.776.624-.352.384-.56.976-.624 1.776-.032.48-.048 1.072-.048 1.776s.016 1.296.048 1.776c.064.928.272 1.632.624 2.112.352.448.944.672 1.776.672zM113.415 34.4c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912v-5.808c0-.352.128-.656.384-.912s.56-.384.912-.384h8.112c.352 0 .656.128.912.384s.384.56.384.912v5.808c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.112zm-.24 27.6c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V38.336c0-.352.128-.656.384-.912s.56-.384.912-.384h8.592c.352 0 .656.128.912.384s.384.56.384.912v22.368c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.592zm15.515 0c-.352 0-.656-.128-.912-.384a1.246 1.246 0 0 1-.384-.912V29.216c0-.352.128-.656.384-.912s.56-.384.912-.384h8.4c.352 0 .656.128.912.384s.384.56.384.912v15.552l4.224-6.912c.32-.544.784-.816 1.392-.816h9.696c.32 0 .592.112.816.336.224.224.336.496.336.816 0 .224-.08.464-.24.72l-6.576 9.36 7.776 11.952c.128.192.192.4.192.624 0 .32-.112.592-.336.816a1.11 1.11 0 0 1-.816.336h-10.08c-.64 0-1.136-.272-1.488-.816l-4.896-8.16v7.68c0 .352-.128.656-.384.912s-.56.384-.912.384h-8.4zM25.4 105.48c-3.776 0-6.768-.88-8.976-2.64-2.208-1.76-3.312-4.16-3.312-7.2 0-1.952.56-3.664 1.68-5.136 1.12-1.472 2.72-2.8 4.8-3.984-1.216-1.312-2.096-2.528-2.64-3.648-.512-1.152-.768-2.32-.768-3.504 0-1.536.4-2.944 1.2-4.224.8-1.28 1.984-2.304 3.552-3.072 1.568-.768 3.456-1.152 5.664-1.152 2.048 0 3.824.384 5.328 1.152 1.536.736 2.688 1.744 3.456 3.024a7.494 7.494 0 0 1 1.2 4.128c0 1.856-.56 3.456-1.68 4.8-1.12 1.312-2.784 2.608-4.992 3.888l5.712 5.712c.512-.832.944-1.632 1.296-2.4.384-.8.768-1.84 1.152-3.12.128-.448.464-.672 1.008-.672h4.848c.256 0 .48.096.672.288.192.16.288.368.288.624-.032 1.12-.56 2.64-1.584 4.56-.992 1.92-2.096 3.616-3.312 5.088l5.376 5.424c.224.288.336.528.336.72a.774.774 0 0 1-.288.624.844.844 0 0 1-.624.24h-6.528c-.512 0-.928-.16-1.248-.48l-2.16-2.064c-2.464 2.016-5.616 3.024-9.456 3.024zm.432-21.984c1.28-.64 2.24-1.264 2.88-1.872.672-.608 1.008-1.328 1.008-2.16 0-.864-.304-1.552-.912-2.064-.576-.544-1.312-.816-2.208-.816a3.31 3.31 0 0 0-2.208.816c-.608.544-.912 1.248-.912 2.112 0 .576.176 1.184.528 1.824.384.608.992 1.328 1.824 2.16zM25.4 99.384c1.984 0 3.632-.592 4.944-1.776l-6.384-6.384c-2.112 1.12-3.168 2.48-3.168 4.08 0 1.216.464 2.208 1.392 2.976.928.736 2 1.104 3.216 1.104zM65.56 105h-3.168l-6.24-21.12h2.752l5.088 19.104 4.992-19.104h2.912l4.992 19.168 5.12-19.168H84.6L78.392 105h-3.168L71.48 91.304l-1.088-4.768h-.032l-1.088 4.768L65.56 105zm28.824-16.32c2.41 0 4.299.736 5.664 2.208 1.387 1.472 2.08 3.51 2.08 6.112 0 2.603-.693 4.64-2.08 6.112-1.365 1.472-3.253 2.208-5.664 2.208-2.41 0-4.31-.736-5.696-2.208-1.365-1.472-2.048-3.51-2.048-6.112 0-2.603.683-4.64 2.048-6.112 1.387-1.472 3.286-2.208 5.696-2.208zm0 2.208c-1.621 0-2.89.544-3.808 1.632C89.66 93.608 89.2 95.101 89.2 97c0 1.899.459 3.392 1.376 4.48.918 1.088 2.187 1.632 3.808 1.632 1.622 0 2.89-.544 3.808-1.632.918-1.088 1.376-2.581 1.376-4.48 0-1.899-.458-3.392-1.376-4.48-.917-1.088-2.186-1.632-3.808-1.632zm20.269-2.208c.768 0 1.355.107 1.76.32l-.512 2.496c-.512-.277-1.184-.416-2.016-.416-.683 0-1.355.203-2.016.608-.64.384-1.173.981-1.6 1.792-.405.79-.608 1.75-.608 2.88V105h-2.56V89h2.08l.352 2.624c.896-1.963 2.603-2.944 5.12-2.944zm11.463 8.416l-3.392 3.392V105h-2.56V81.64h2.56v15.648L131.012 89h3.2l-6.24 6.24 6.624 9.76h-3.104l-5.376-7.904zm29.655-13.536c3.776 0 6.496 1.493 8.16 4.48l-2.208 1.792c-.64-1.408-1.408-2.4-2.304-2.976-.874-.597-2.08-.896-3.616-.896-1.621 0-2.901.341-3.84 1.024-.917.661-1.376 1.515-1.376 2.56 0 .683.182 1.248.544 1.696.363.448.96.843 1.792 1.184.854.32 2.027.608 3.52.864 2.795.47 4.768 1.173 5.92 2.112 1.174.939 1.76 2.24 1.76 3.904 0 1.195-.341 2.251-1.024 3.168-.661.896-1.61 1.6-2.848 2.112-1.237.491-2.666.736-4.288.736-2.133 0-3.957-.416-5.472-1.248-1.493-.832-2.634-1.941-3.424-3.328l2.208-1.792c.576 1.259 1.419 2.24 2.528 2.944 1.131.683 2.539 1.024 4.224 1.024 1.664 0 2.987-.299 3.968-.896.982-.619 1.472-1.483 1.472-2.592 0-.939-.426-1.685-1.28-2.24-.853-.555-2.368-1.024-4.544-1.408-2.816-.49-4.81-1.195-5.984-2.112-1.173-.917-1.76-2.197-1.76-3.84 0-1.13.32-2.176.96-3.136.64-.96 1.558-1.717 2.752-2.272 1.195-.576 2.582-.864 4.16-.864zm26.044 19.584a5.25 5.25 0 0 0 1.28-.16l-.16 2.016a5.68 5.68 0 0 1-1.92.32c-.832 0-1.494-.181-1.984-.544-.47-.363-.768-.971-.896-1.824-.491.747-1.216 1.333-2.176 1.76a7.435 7.435 0 0 1-2.976.608c-1.579 0-2.88-.363-3.904-1.088-1.024-.747-1.536-1.813-1.536-3.2 0-1.216.533-2.261 1.6-3.136 1.066-.896 2.613-1.515 4.64-1.856l4.256-.704v-.896c0-1.067-.331-1.92-.992-2.56-.662-.64-1.579-.96-2.752-.96-1.067 0-1.995.256-2.784.768-.768.512-1.366 1.27-1.792 2.272l-1.888-1.376c.426-1.195 1.216-2.144 2.368-2.848 1.173-.704 2.538-1.056 4.096-1.056 1.898 0 3.424.459 4.576 1.376 1.152.917 1.728 2.272 1.728 4.064v7.872c0 .384.096.672.288.864.192.192.501.288.928.288zm-8.704-.064c1.344 0 2.496-.32 3.456-.96.981-.64 1.472-1.472 1.472-2.496v-2.208l-3.584.672c-1.43.256-2.496.63-3.2 1.12-.704.47-1.056 1.077-1.056 1.824 0 .661.256 1.173.768 1.536.512.341 1.226.512 2.144.512zm21.485-14.4c1.813 0 3.306.523 4.48 1.568 1.173 1.045 1.76 2.55 1.76 4.512V105h-2.56v-9.344c0-1.664-.363-2.87-1.088-3.616-.704-.747-1.654-1.12-2.848-1.12-.854 0-1.654.192-2.4.576-.747.363-1.366.97-1.856 1.824-.47.832-.704 1.888-.704 3.168V105h-2.56V89h2.24l.16 2.496c.533-.96 1.269-1.664 2.208-2.112.938-.47 1.994-.704 3.168-.704zm17.476 16.64c-1.536 0-2.922-.299-4.16-.896-1.237-.619-2.144-1.525-2.72-2.72l2.08-1.44a3.898 3.898 0 0 0 1.888 2.112c.896.469 1.952.704 3.168.704 1.259 0 2.219-.224 2.88-.672.662-.448.992-1.013.992-1.696 0-.619-.309-1.11-.928-1.472-.618-.384-1.706-.715-3.264-.992-1.536-.277-2.752-.608-3.648-.992-.896-.405-1.546-.907-1.952-1.504-.405-.619-.608-1.376-.608-2.272 0-.875.256-1.675.768-2.4.512-.725 1.248-1.301 2.208-1.728.96-.448 2.07-.672 3.328-.672 1.707 0 3.072.32 4.096.96 1.046.619 1.792 1.579 2.24 2.88l-2.176 1.28c-.341-1.024-.864-1.76-1.568-2.208-.682-.448-1.546-.672-2.592-.672-1.045 0-1.93.235-2.656.704-.725.47-1.088 1.013-1.088 1.632 0 .704.31 1.248.928 1.632.64.384 1.771.715 3.392.992 2.219.363 3.787.907 4.704 1.632.918.725 1.376 1.75 1.376 3.072a3.95 3.95 0 0 1-.832 2.464c-.533.704-1.312 1.259-2.336 1.664-1.002.405-2.176.608-3.52.608z"
|
39 |
+
fill="#fff"
|
40 |
+
/>
|
41 |
+
</SVG>
|
42 |
+
);
|
43 |
+
const PlayRoboto = () => (
|
44 |
+
<SVG width="232" height="132" viewBox="0 0 232 132" xmlns="http://www.w3.org/2000/svg">
|
45 |
+
<Path fill="#B9B5B8" d="M0 0h232v132H0z" />
|
46 |
+
<Path
|
47 |
+
d="M149.438 101c-.75-2.125-1.23-5.27-1.438-9.438-2.625 3.417-5.979 6.063-10.062 7.938-4.042 1.833-8.334 2.75-12.876 2.75-6.5 0-11.77-1.812-15.812-5.438-4-3.624-6-8.208-6-13.75 0-6.583 2.729-11.791 8.188-15.624 5.5-3.834 13.145-5.75 22.937-5.75h13.563V54c0-4.833-1.5-8.625-4.5-11.375-2.959-2.792-7.292-4.188-13-4.188-5.209 0-9.521 1.334-12.938 4-3.417 2.667-5.125 5.876-5.125 9.626l-7.5-.063c0-5.375 2.5-10.02 7.5-13.938 5-3.958 11.146-5.937 18.437-5.937 7.542 0 13.48 1.896 17.813 5.688 4.375 3.75 6.625 9 6.75 15.75v32c0 6.541.687 11.437 2.063 14.687v.75h-8zm-23.5-5.375c5 0 9.458-1.208 13.374-3.625 3.959-2.417 6.834-5.646 8.626-9.688V67.439h-13.376c-7.458.083-13.291 1.458-17.5 4.124-4.208 2.626-6.312 6.25-6.312 10.876 0 3.791 1.396 6.937 4.188 9.437 2.833 2.5 6.5 3.75 11 3.75zM39.328 101.896c-5.461 0-9.6-1.451-12.416-4.352-2.73-2.987-4.096-6.699-4.096-11.136 0-3.84.981-6.997 2.944-9.472 2.048-2.56 4.437-4.523 7.168-5.888 2.73-1.365 6.272-2.773 10.624-4.224 4.608-1.536 7.979-2.944 10.112-4.224 2.133-1.28 3.2-3.072 3.2-5.376V45.832c0-2.73-.683-5.163-2.048-7.296s-3.712-3.2-7.04-3.2c-2.645 0-5.035.725-7.168 2.176 2.901 1.024 5.035 2.56 6.4 4.608 1.45 1.963 2.176 4.181 2.176 6.656 0 3.328-1.195 6.016-3.584 8.064-2.304 1.963-5.12 2.944-8.448 2.944-3.328 0-5.973-1.024-7.936-3.072-1.877-2.133-2.816-4.821-2.816-8.064 0-2.56.64-4.779 1.92-6.656 1.28-1.877 3.285-3.584 6.016-5.12 4.779-2.73 11.605-4.096 20.48-4.096 4.693 0 8.747.47 12.16 1.408 3.413.853 6.315 2.517 8.704 4.992 1.707 1.792 2.816 4.053 3.328 6.784.597 2.645.896 6.357.896 11.136V91.4c0 2.133.128 3.584.384 4.352.341.768.896 1.152 1.664 1.152.597 0 1.237-.17 1.92-.512a15.863 15.863 0 0 0 1.92-1.408l1.28 2.176c-3.67 3.157-8.917 4.736-15.744 4.736-5.12 0-8.704-.853-10.752-2.56-2.048-1.792-3.157-4.181-3.328-7.168-4.01 6.485-9.984 9.728-17.92 9.728zm12.8-10.24c1.792 0 3.37-.725 4.736-2.176V62.472c-.768 1.28-2.176 2.944-4.224 4.992-2.304 2.219-4.053 4.395-5.248 6.528-1.195 2.048-1.792 4.864-1.792 8.448 0 6.144 2.176 9.216 6.528 9.216z"
|
48 |
+
fill="#270920"
|
49 |
+
/>
|
50 |
+
</SVG>
|
51 |
+
);
|
52 |
+
|
53 |
+
export default ( preview, headings, base ) => {
|
54 |
+
switch ( preview ) {
|
55 |
+
case 'SPACE_LORA':
|
56 |
+
return SpaceLora();
|
57 |
+
case 'SYSTEM_BASKER':
|
58 |
+
return SystemBasker();
|
59 |
+
case 'RUBIK_WORK':
|
60 |
+
return RubikWork();
|
61 |
+
case 'PLAY_ROBOTO':
|
62 |
+
return PlayRoboto();
|
63 |
+
default:
|
64 |
+
return (
|
65 |
+
<div className="font-pairings-panel__preview">
|
66 |
+
<h1 style={ { fontFamily: headings } }>Lorem Ipsum</h1>
|
67 |
+
<p style={ { fontFamily: base } }>
|
68 |
+
Etiam tempor orci eu lobortis elementum nibh tellus molestie.
|
69 |
+
</p>
|
70 |
+
</div>
|
71 |
+
);
|
72 |
+
}
|
73 |
+
};
|
global-styles/src/font-pairings-panel.js
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { ENTER } from '@wordpress/keycodes';
|
5 |
+
import classnames from 'classnames';
|
6 |
+
import { __ } from '@wordpress/i18n';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Internal dependencies
|
10 |
+
*/
|
11 |
+
import NoSupport from './no-support';
|
12 |
+
import loadFontPairingPreview from './font-pairings-panel-previews';
|
13 |
+
|
14 |
+
export default ( { fontPairings, fontBase, fontHeadings, update } ) => {
|
15 |
+
return (
|
16 |
+
<>
|
17 |
+
<h3>{ __( 'Font Pairings' ) }</h3>
|
18 |
+
{ fontPairings && fontHeadings && fontBase ? (
|
19 |
+
<div role="listbox">
|
20 |
+
{ fontPairings.map( ( { label, headings, base, preview } ) => {
|
21 |
+
const isSelected = headings === fontHeadings && base === fontBase;
|
22 |
+
const classes = classnames( 'font-pairings-panel', {
|
23 |
+
'is-selected': isSelected,
|
24 |
+
} );
|
25 |
+
return (
|
26 |
+
<div
|
27 |
+
key={ label }
|
28 |
+
tabIndex={ 0 }
|
29 |
+
role="option"
|
30 |
+
aria-selected={ isSelected }
|
31 |
+
className={ classes }
|
32 |
+
onClick={ () => update( { headings, base } ) }
|
33 |
+
onKeyDown={ event =>
|
34 |
+
event.keyCode === ENTER ? update( { headings, base } ) : null
|
35 |
+
}
|
36 |
+
>
|
37 |
+
<div className="font-pairings-panel__preview">
|
38 |
+
{ loadFontPairingPreview( preview, headings, base ) }
|
39 |
+
</div>
|
40 |
+
<p className="font-pairings-panel__label">{ label }</p>
|
41 |
+
</div>
|
42 |
+
);
|
43 |
+
} ) }
|
44 |
+
</div>
|
45 |
+
) : (
|
46 |
+
<NoSupport unsupportedFeature={ __( 'font pairings' ) } />
|
47 |
+
) }
|
48 |
+
</>
|
49 |
+
);
|
50 |
+
};
|
global-styles/src/font-pairings-panel.scss
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.font-pairings-panel {
|
2 |
+
cursor: pointer;
|
3 |
+
border-radius: 4px;
|
4 |
+
padding: 4px;
|
5 |
+
margin-bottom: 0.5em;
|
6 |
+
|
7 |
+
&.is-selected {
|
8 |
+
box-shadow: 0 0 0 2px #555d66;
|
9 |
+
}
|
10 |
+
|
11 |
+
&:focus {
|
12 |
+
box-shadow: 0 0 0 2px #00a0d2;
|
13 |
+
}
|
14 |
+
|
15 |
+
&:hover {
|
16 |
+
background-color: #f3f4f5;
|
17 |
+
color: #191e23;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
.font-pairings-panel__preview {
|
22 |
+
border: 1px solid rgba( 25, 30, 35, 0.2 );
|
23 |
+
border-radius: 4px;
|
24 |
+
background-color: #fff;
|
25 |
+
padding: 4px;
|
26 |
+
|
27 |
+
// For when no art directed preview is present.
|
28 |
+
h1,
|
29 |
+
p {
|
30 |
+
margin: 0;
|
31 |
+
white-space: nowrap;
|
32 |
+
overflow: hidden;
|
33 |
+
text-overflow: ellipsis;
|
34 |
+
padding: 10px 0;
|
35 |
+
}
|
36 |
+
|
37 |
+
// For the art directed preview.
|
38 |
+
svg {
|
39 |
+
display: block;
|
40 |
+
width: 100%;
|
41 |
+
height: auto;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
.font-pairings-panel__label {
|
46 |
+
text-align: center;
|
47 |
+
margin-bottom: 0;
|
48 |
+
}
|
global-styles/src/font-selection-panel.js
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __ } from '@wordpress/i18n';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* WordPress dependencies.
|
8 |
+
*/
|
9 |
+
import { SelectControl } from '@wordpress/components';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Internal dependencies
|
13 |
+
*/
|
14 |
+
import NoSupport from './no-support';
|
15 |
+
|
16 |
+
export default ( {
|
17 |
+
fontBase,
|
18 |
+
fontBaseDefault,
|
19 |
+
fontHeadings,
|
20 |
+
fontHeadingsDefault,
|
21 |
+
fontBaseOptions,
|
22 |
+
fontHeadingsOptions,
|
23 |
+
updateBaseFont,
|
24 |
+
updateHeadingsFont,
|
25 |
+
} ) => {
|
26 |
+
if ( ! fontBaseOptions || ! fontHeadingsOptions ) {
|
27 |
+
return <NoSupport unsupportedFeature={ __( 'custom font selection' ) } />;
|
28 |
+
}
|
29 |
+
|
30 |
+
return (
|
31 |
+
<>
|
32 |
+
<SelectControl
|
33 |
+
label={ __( 'Heading Font' ) }
|
34 |
+
value={ fontHeadings }
|
35 |
+
options={ fontHeadingsOptions }
|
36 |
+
onChange={ newValue => updateHeadingsFont( newValue ) }
|
37 |
+
style={ { fontFamily: fontHeadings !== 'unset' ? fontHeadings : fontHeadingsDefault } }
|
38 |
+
/>
|
39 |
+
<SelectControl
|
40 |
+
label={ __( 'Base Font' ) }
|
41 |
+
value={ fontBase }
|
42 |
+
options={ fontBaseOptions }
|
43 |
+
onChange={ newValue => updateBaseFont( newValue ) }
|
44 |
+
style={ { fontFamily: fontBase !== 'unset' ? fontBase : fontBaseDefault } }
|
45 |
+
/>
|
46 |
+
<hr />
|
47 |
+
</>
|
48 |
+
);
|
49 |
+
};
|
global-styles/src/global-styles-sidebar.js
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { PluginSidebar } from '@wordpress/edit-post';
|
5 |
+
import { Button, PanelBody } from '@wordpress/components';
|
6 |
+
import { __, sprintf } from '@wordpress/i18n';
|
7 |
+
import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Internal dependencies
|
11 |
+
*/
|
12 |
+
import FontPairingsPanel from './font-pairings-panel';
|
13 |
+
import FontSelectionPanel from './font-selection-panel';
|
14 |
+
import { GlobalStylesIcon } from './icon';
|
15 |
+
import { FONT_BASE, FONT_HEADINGS } from './constants';
|
16 |
+
|
17 |
+
const ANY_PROPERTY = 'ANY_PROPERTY';
|
18 |
+
|
19 |
+
const isFor = filterProperty => option =>
|
20 |
+
option.prop === ANY_PROPERTY || option.prop === filterProperty;
|
21 |
+
|
22 |
+
const toOption = font => {
|
23 |
+
if ( typeof font === 'object' ) {
|
24 |
+
const { label, value, prop = ANY_PROPERTY } = font;
|
25 |
+
return { label, value, prop };
|
26 |
+
}
|
27 |
+
return { label: font, value: font, prop: ANY_PROPERTY };
|
28 |
+
};
|
29 |
+
const isNotNull = option => option.value !== null && option.label !== null;
|
30 |
+
|
31 |
+
const toOptions = ( options, filterProperty ) =>
|
32 |
+
! options
|
33 |
+
? []
|
34 |
+
: options
|
35 |
+
.map( toOption )
|
36 |
+
.filter( isNotNull )
|
37 |
+
.filter( isFor( filterProperty ) );
|
38 |
+
|
39 |
+
const PanelActionButtons = ( {
|
40 |
+
hasLocalChanges,
|
41 |
+
resetAction,
|
42 |
+
publishAction,
|
43 |
+
className = null,
|
44 |
+
} ) => (
|
45 |
+
<div className={ className }>
|
46 |
+
<Button disabled={ ! hasLocalChanges } isDefault onClick={ resetAction }>
|
47 |
+
{ __( 'Reset' ) }
|
48 |
+
</Button>
|
49 |
+
<Button
|
50 |
+
className={ 'global-styles-sidebar__publish-button' }
|
51 |
+
disabled={ ! hasLocalChanges }
|
52 |
+
isPrimary
|
53 |
+
onClick={ publishAction }
|
54 |
+
>
|
55 |
+
{ __( 'Publish' ) }
|
56 |
+
</Button>
|
57 |
+
</div>
|
58 |
+
);
|
59 |
+
|
60 |
+
export default ( {
|
61 |
+
fontHeadings,
|
62 |
+
fontHeadingsDefault,
|
63 |
+
fontBase,
|
64 |
+
fontBaseDefault,
|
65 |
+
fontPairings,
|
66 |
+
fontOptions,
|
67 |
+
siteName,
|
68 |
+
publishOptions,
|
69 |
+
updateOptions,
|
70 |
+
hasLocalChanges,
|
71 |
+
resetLocalChanges,
|
72 |
+
} ) => {
|
73 |
+
const publish = () =>
|
74 |
+
publishOptions( {
|
75 |
+
[ FONT_BASE ]: fontBase,
|
76 |
+
[ FONT_HEADINGS ]: fontHeadings,
|
77 |
+
} );
|
78 |
+
return (
|
79 |
+
<>
|
80 |
+
<PluginSidebarMoreMenuItem icon={ <GlobalStylesIcon /> } target="global-styles">
|
81 |
+
{ __( 'Global Styles' ) }
|
82 |
+
</PluginSidebarMoreMenuItem>
|
83 |
+
<PluginSidebar
|
84 |
+
icon={ <GlobalStylesIcon /> }
|
85 |
+
name={ 'global-styles' }
|
86 |
+
title={ __( 'Global Styles' ) }
|
87 |
+
className="global-styles-sidebar"
|
88 |
+
>
|
89 |
+
<PanelBody>
|
90 |
+
<p>
|
91 |
+
{ /* translators: %s: Name of site. */
|
92 |
+
sprintf( __( 'You are customizing %s.' ), siteName ) }
|
93 |
+
</p>
|
94 |
+
<p>{ __( 'Any change you make here will apply to the entire website.' ) }</p>
|
95 |
+
{ hasLocalChanges ? (
|
96 |
+
<div>
|
97 |
+
<p>
|
98 |
+
<em>{ __( 'You have unsaved changes.' ) }</em>
|
99 |
+
</p>
|
100 |
+
<PanelActionButtons
|
101 |
+
hasLocalChanges={ hasLocalChanges }
|
102 |
+
publishAction={ publish }
|
103 |
+
resetAction={ resetLocalChanges }
|
104 |
+
/>
|
105 |
+
</div>
|
106 |
+
) : null }
|
107 |
+
</PanelBody>
|
108 |
+
<PanelBody title={ __( 'Font Selection' ) }>
|
109 |
+
<FontSelectionPanel
|
110 |
+
fontBase={ fontBase }
|
111 |
+
fontBaseDefault={ fontBaseDefault }
|
112 |
+
fontHeadings={ fontHeadings }
|
113 |
+
fontHeadingsDefault={ fontHeadingsDefault }
|
114 |
+
fontBaseOptions={ toOptions( fontOptions, FONT_BASE ) }
|
115 |
+
fontHeadingsOptions={ toOptions( fontOptions, FONT_HEADINGS ) }
|
116 |
+
updateBaseFont={ value => updateOptions( { [ FONT_BASE ]: value } ) }
|
117 |
+
updateHeadingsFont={ value => updateOptions( { [ FONT_HEADINGS ]: value } ) }
|
118 |
+
/>
|
119 |
+
<FontPairingsPanel
|
120 |
+
fontHeadings={ fontHeadings }
|
121 |
+
fontBase={ fontBase }
|
122 |
+
fontPairings={ fontPairings }
|
123 |
+
update={ ( { headings, base } ) =>
|
124 |
+
updateOptions( { [ FONT_HEADINGS ]: headings, [ FONT_BASE ]: base } )
|
125 |
+
}
|
126 |
+
/>
|
127 |
+
</PanelBody>
|
128 |
+
<PanelBody>
|
129 |
+
{ hasLocalChanges ? (
|
130 |
+
<p>
|
131 |
+
<em>{ __( 'You have unsaved changes.' ) }</em>
|
132 |
+
</p>
|
133 |
+
) : null }
|
134 |
+
<PanelActionButtons
|
135 |
+
hasLocalChanges={ hasLocalChanges }
|
136 |
+
publishAction={ publish }
|
137 |
+
resetAction={ resetLocalChanges }
|
138 |
+
className={ 'global-styles-sidebar__panel-action-buttons' }
|
139 |
+
/>
|
140 |
+
</PanelBody>
|
141 |
+
</PluginSidebar>
|
142 |
+
</>
|
143 |
+
);
|
144 |
+
};
|
global-styles/src/global-styles-sidebar.scss
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.global-styles-sidebar {
|
2 |
+
// Make the font dropdown a bit more spacy.
|
3 |
+
.components-select-control__input {
|
4 |
+
line-height: 1;
|
5 |
+
font-size: 18px;
|
6 |
+
height: 36px;
|
7 |
+
}
|
8 |
+
|
9 |
+
h3 {
|
10 |
+
margin: 0 0 1em;
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
.global-styles-sidebar__panel-action-buttons {
|
15 |
+
display: flex;
|
16 |
+
justify-content: flex-end;
|
17 |
+
margin-bottom: 96px;
|
18 |
+
}
|
19 |
+
|
20 |
+
.global-styles-sidebar__publish-button {
|
21 |
+
margin-left: 1em;
|
22 |
+
}
|
global-styles/src/icon.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { Path, SVG } from '@wordpress/components';
|
5 |
+
|
6 |
+
// For now, this icon shows a font style picker. Once we add colors, we'll want colors.
|
7 |
+
|
8 |
+
export const GlobalStylesIcon = () => (
|
9 |
+
<SVG xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
10 |
+
<Path d="M9.93 13.5h4.14L12 7.98zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z" />
|
11 |
+
</SVG>
|
12 |
+
);
|
global-styles/src/no-support.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __, sprintf } from '@wordpress/i18n';
|
5 |
+
|
6 |
+
export default ( { unsupportedFeature } ) => (
|
7 |
+
<p>
|
8 |
+
{ /* translators: %s: feature name (i.e. font pairings, etc) */
|
9 |
+
sprintf( __( "Your active theme doesn't support %s." ), unsupportedFeature ) }
|
10 |
+
</p>
|
11 |
+
);
|
global-styles/src/store.js
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import apiFetch from '@wordpress/api-fetch';
|
5 |
+
import { registerStore } from '@wordpress/data';
|
6 |
+
|
7 |
+
let cache = {};
|
8 |
+
let alreadyFetchedOptions = false;
|
9 |
+
|
10 |
+
const actions = {
|
11 |
+
*publishOptions( options ) {
|
12 |
+
yield {
|
13 |
+
type: 'IO_PUBLISH_OPTIONS',
|
14 |
+
options,
|
15 |
+
};
|
16 |
+
return {
|
17 |
+
type: 'PUBLISH_OPTIONS',
|
18 |
+
options,
|
19 |
+
};
|
20 |
+
},
|
21 |
+
updateOptions( options ) {
|
22 |
+
return {
|
23 |
+
type: 'UPDATE_OPTIONS',
|
24 |
+
options,
|
25 |
+
};
|
26 |
+
},
|
27 |
+
fetchOptions() {
|
28 |
+
return {
|
29 |
+
type: 'IO_FETCH_OPTIONS',
|
30 |
+
};
|
31 |
+
},
|
32 |
+
resetLocalChanges() {
|
33 |
+
return {
|
34 |
+
type: 'RESET_OPTIONS',
|
35 |
+
options: cache,
|
36 |
+
};
|
37 |
+
},
|
38 |
+
};
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Store API
|
42 |
+
*
|
43 |
+
* Selectors under `wp.data.select( STORE_NAME )`:
|
44 |
+
*
|
45 |
+
* - getOption( String optionName )
|
46 |
+
* - hasLocalChanges()
|
47 |
+
*
|
48 |
+
* Actions under `wp.data.dispatch( STORE_NAME )`:
|
49 |
+
*
|
50 |
+
* - updateOptions( Object optionsToUpdate )
|
51 |
+
* - publishOptions( Object optionsToUpdate )
|
52 |
+
* - resetLocalChanges()
|
53 |
+
*
|
54 |
+
* @param {string} storeName Name of the store.
|
55 |
+
* @param {string} optionsPath REST path used to interact with the options API.
|
56 |
+
*/
|
57 |
+
export default ( storeName, optionsPath ) => {
|
58 |
+
registerStore( storeName, {
|
59 |
+
reducer( state, action ) {
|
60 |
+
switch ( action.type ) {
|
61 |
+
case 'UPDATE_OPTIONS':
|
62 |
+
case 'RESET_OPTIONS':
|
63 |
+
case 'PUBLISH_OPTIONS':
|
64 |
+
return {
|
65 |
+
...state,
|
66 |
+
...action.options,
|
67 |
+
};
|
68 |
+
}
|
69 |
+
|
70 |
+
return state;
|
71 |
+
},
|
72 |
+
|
73 |
+
actions,
|
74 |
+
|
75 |
+
selectors: {
|
76 |
+
getOption( state, key ) {
|
77 |
+
return state ? state[ key ] : undefined;
|
78 |
+
},
|
79 |
+
hasLocalChanges( state ) {
|
80 |
+
return !! state && Object.keys( cache ).some( key => cache[ key ] !== state[ key ] );
|
81 |
+
},
|
82 |
+
},
|
83 |
+
|
84 |
+
resolvers: {
|
85 |
+
*getOption( key ) {
|
86 |
+
// eslint-disable-line no-unused-vars
|
87 |
+
if ( alreadyFetchedOptions ) {
|
88 |
+
return; // do nothing
|
89 |
+
}
|
90 |
+
|
91 |
+
let options;
|
92 |
+
try {
|
93 |
+
alreadyFetchedOptions = true;
|
94 |
+
options = yield actions.fetchOptions();
|
95 |
+
} catch ( error ) {
|
96 |
+
options = {};
|
97 |
+
}
|
98 |
+
cache = options;
|
99 |
+
return {
|
100 |
+
type: 'UPDATE_OPTIONS',
|
101 |
+
options,
|
102 |
+
};
|
103 |
+
},
|
104 |
+
},
|
105 |
+
|
106 |
+
controls: {
|
107 |
+
IO_FETCH_OPTIONS() {
|
108 |
+
return apiFetch( { path: optionsPath } );
|
109 |
+
},
|
110 |
+
IO_PUBLISH_OPTIONS( { options } ) {
|
111 |
+
cache = options; // optimistically update the cache
|
112 |
+
return apiFetch( {
|
113 |
+
path: optionsPath,
|
114 |
+
method: 'POST',
|
115 |
+
data: {
|
116 |
+
...options,
|
117 |
+
},
|
118 |
+
} );
|
119 |
+
},
|
120 |
+
},
|
121 |
+
} );
|
122 |
+
};
|
global-styles/static/blank.css
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* DO NOT DELETE.
|
3 |
+
*
|
4 |
+
* Placeholder file so we can use wp_add_inline_styles
|
5 |
+
* to dynamically add fonts, custom properties, etc.
|
6 |
+
*/
|
global-styles/static/style.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
h1,
|
2 |
+
h2,
|
3 |
+
h3,
|
4 |
+
h4,
|
5 |
+
h5,
|
6 |
+
h6,
|
7 |
+
.editor-post-title .editor-post-title__block .editor-post-title__input,
|
8 |
+
h1.entry-title.entry-title,
|
9 |
+
.entry-title.entry-title {
|
10 |
+
font-family: var(--font-headings, var(--font-headings-default));
|
11 |
+
}
|
12 |
+
|
13 |
+
body,
|
14 |
+
p,
|
15 |
+
li {
|
16 |
+
font-family: var(--font-base, var(--font-base-default));
|
17 |
+
}
|
18 |
+
|
19 |
+
/*
|
20 |
+
* Despite best efforts, some fonts bleed into placeholders.
|
21 |
+
* Unstyle these after the fact.
|
22 |
+
*/
|
23 |
+
.components-placeholder p,
|
24 |
+
.components-placeholder li,
|
25 |
+
.a8c-media-placeholder p,
|
26 |
+
.a8c-media-placeholder li {
|
27 |
+
font-family: inherit;
|
28 |
+
}
|
posts-list-block/blocks/posts-list/index.js
CHANGED
@@ -6,7 +6,7 @@ import { registerBlockType, createBlock } from '@wordpress/blocks';
|
|
6 |
import { __ } from '@wordpress/i18n';
|
7 |
import { Placeholder, RangeControl, PanelBody } from '@wordpress/components';
|
8 |
import { Fragment } from '@wordpress/element';
|
9 |
-
import { InspectorControls } from '@wordpress/editor';
|
10 |
/* eslint-enable import/no-extraneous-dependencies */
|
11 |
|
12 |
/**
|
6 |
import { __ } from '@wordpress/i18n';
|
7 |
import { Placeholder, RangeControl, PanelBody } from '@wordpress/components';
|
8 |
import { Fragment } from '@wordpress/element';
|
9 |
+
import { InspectorControls } from '@wordpress/block-editor';
|
10 |
/* eslint-enable import/no-extraneous-dependencies */
|
11 |
|
12 |
/**
|
posts-list-block/class-posts-list-block.php
CHANGED
@@ -20,10 +20,10 @@ class Posts_List_Block {
|
|
20 |
private static $instance = null;
|
21 |
|
22 |
/**
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
private $rendering_block = false;
|
28 |
|
29 |
/**
|
@@ -52,13 +52,8 @@ class Posts_List_Block {
|
|
52 |
* Enqueue block editor scripts.
|
53 |
*/
|
54 |
public function enqueue_scripts() {
|
55 |
-
|
56 |
-
$script_dependencies =
|
57 |
-
file_get_contents(
|
58 |
-
plugin_dir_path( __FILE__ ) . 'dist/posts-list-block.deps.json'
|
59 |
-
),
|
60 |
-
true
|
61 |
-
);
|
62 |
wp_enqueue_script(
|
63 |
'a8c-posts-list-script',
|
64 |
plugins_url( 'dist/posts-list-block.js', __FILE__ ),
|
@@ -66,6 +61,7 @@ class Posts_List_Block {
|
|
66 |
filemtime( plugin_dir_path( __FILE__ ) . 'dist/posts-list-block.js' ),
|
67 |
true
|
68 |
);
|
|
|
69 |
wp_set_script_translations( 'a8c-posts-list-script', 'full-site-editing' );
|
70 |
}
|
71 |
|
20 |
private static $instance = null;
|
21 |
|
22 |
/**
|
23 |
+
* Whether we are in the process of rendering the block.
|
24 |
+
*
|
25 |
+
* @var bool
|
26 |
+
*/
|
27 |
private $rendering_block = false;
|
28 |
|
29 |
/**
|
52 |
* Enqueue block editor scripts.
|
53 |
*/
|
54 |
public function enqueue_scripts() {
|
55 |
+
$asset_file = include plugin_dir_path( __FILE__ ) . 'dist/posts-list-block.asset.php';
|
56 |
+
$script_dependencies = $asset_file['dependencies'];
|
|
|
|
|
|
|
|
|
|
|
57 |
wp_enqueue_script(
|
58 |
'a8c-posts-list-script',
|
59 |
plugins_url( 'dist/posts-list-block.js', __FILE__ ),
|
61 |
filemtime( plugin_dir_path( __FILE__ ) . 'dist/posts-list-block.js' ),
|
62 |
true
|
63 |
);
|
64 |
+
|
65 |
wp_set_script_translations( 'a8c-posts-list-script', 'full-site-editing' );
|
66 |
}
|
67 |
|
posts-list-block/dist/posts-list-block.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'ff6291ee209d4db3d086c9529d41c3e6');
|
posts-list-block/dist/posts-list-block.deps.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
["wp-blocks","wp-components","wp-editor","wp-element","wp-i18n","wp-polyfill"]
|
|
posts-list-block/dist/posts-list-block.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e){e.exports={b:"a8c/posts-list",a:{postsPerPage:{type:"number",default:10}}}},function(e,t){!function(){e.exports=this.wp.
|
1 |
+
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e){e.exports=JSON.parse('{"b":"a8c/posts-list","a":{"postsPerPage":{"type":"number","default":10}}}')},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t,n){},function(e,t,n){"use strict";n.r(t);var o=n(0),r=n(3),l=n(1),i=n(2),s=n(5),c=n(4),u=(n(6),Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(o.createElement)("path",{opacity:".87",fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M3 5v14h17V5H3zm4 2v2H5V7h2zm-2 6v-2h2v2H5zm0 2h2v2H5v-2zm13 2H9v-2h9v2zm0-4H9v-2h9v2zm0-4H9V7h9v2z"})));Object(r.registerBlockType)(c.b,{title:Object(l.__)("Blog Posts Listing","full-site-editing"),description:Object(l.__)("Displays your latest Blog Posts.","full-site-editing"),icon:u,category:"layout",supports:{html:!1,multiple:!1,reusable:!1},attributes:c.a,edit:function(e){var t=e.attributes,n=e.setAttributes,r=e.isSelected;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(i.Placeholder,{icon:u,label:Object(l.__)("Your recent blog posts will be displayed here.","full-site-editing")},r?Object(o.createElement)(i.RangeControl,{label:Object(l.__)("Number of posts to show","full-site-editing"),value:t.postsPerPage,onChange:function(e){return n({postsPerPage:e})},min:1,max:50}):null),Object(o.createElement)(s.InspectorControls,null,Object(o.createElement)(i.PanelBody,null,Object(o.createElement)(i.RangeControl,{label:Object(l.__)("Number of posts","full-site-editing"),value:t.postsPerPage,onChange:function(e){return n({postsPerPage:e})},min:1,max:50}))))},save:function(){return null},transforms:{to:[{type:"block",blocks:["newspack-blocks/homepage-articles"],transform:function(e){var t=e.postsPerPage;return Object(r.createBlock)("newspack-blocks/homepage-articles",{postsToShow:t,showAvatar:!1,displayPostDate:!0,displayPostContent:!0})}}]}})}]));
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: alexislloyd, allancole, automattic, codebykat, copons, dmsnell, ge
|
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.0
|
5 |
Tested up to: 5.3
|
6 |
-
Stable tag: 0.
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -42,6 +42,16 @@ This plugin is experimental, so we don't provide any support for it outside of w
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
= 0.11 =
|
46 |
* Add color, background color, font size, and text alignment support to the Site Title, Site Description, and Navigation Menu blocks.
|
47 |
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.0
|
5 |
Tested up to: 5.3
|
6 |
+
Stable tag: 0.13
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 0.13 =
|
46 |
+
|
47 |
+
* Incorporate Global Styles plugin functionality.
|
48 |
+
* Side-load images on template insertion.
|
49 |
+
* Remove widgets menu from wp-admin.
|
50 |
+
|
51 |
+
= 0.12 =
|
52 |
+
|
53 |
+
* Change menu order of default pages that FSE creates to 1.
|
54 |
+
|
55 |
= 0.11 =
|
56 |
* Add color, background color, font size, and text alignment support to the Site Title, Site Description, and Navigation Menu blocks.
|
57 |
|
starter-page-templates/dist/starter-page-templates.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-nux', 'wp-plugins', 'wp-polyfill', 'wp-url'), 'version' => '54acb85af799b986eccd355fe8f982ee');
|
starter-page-templates/dist/starter-page-templates.deps.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
["lodash","wp-api-fetch","wp-block-editor","wp-blocks","wp-components","wp-compose","wp-data","wp-element","wp-i18n","wp-nux","wp-plugins","wp-polyfill","wp-url"]
|
|
starter-page-templates/dist/starter-page-templates.js
CHANGED
@@ -3,10 +3,4 @@
|
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
-
*/
|
7 |
-
/*!
|
8 |
-
Copyright (c) 2017 Jed Watson.
|
9 |
-
Licensed under the MIT License (MIT), see
|
10 |
-
http://jedwatson.github.io/classnames
|
11 |
-
*/
|
12 |
-
!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=i.apply(null,r);a&&e.push(a)}else if("object"===o)for(var c in r)n.call(r,c)&&r[c]&&e.push(c)}}return e.join(" ")}e.exports?(i.default=i,e.exports=i):void 0===(r=function(){return i}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,n){var r=n(4);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}e.exports=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(n,!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t,n){var r=n(27),i=n(28),o=n(29);e.exports=function(e,t){return r(e)||i(e,t)||o()}},function(e,t){function n(e,t,n,r,i,o,a){try{var c=e[o](a),l=c.value}catch(s){return void n(s)}c.done?t(l):Promise.resolve(l).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise(function(i,o){var a=e.apply(t,r);function c(e){n(a,i,o,c,l,"next",e)}function l(e){n(a,i,o,c,l,"throw",e)}c(void 0)})}}},function(e,t,n){var r=n(30),i=n(31),o=n(32);e.exports=function(e){return r(e)||i(e)||o()}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(23),i=n(6);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var r=n(24);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t){!function(){e.exports=this.wp.apiFetch}()},function(e,t){!function(){e.exports=this.wp.url}()},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(e){return n(e)}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},r(t)}e.exports=r},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t){!function(){e.exports=this.wp.nux}()},function(e,t,n){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(l){i=!0,o=l}finally{try{r||null==c.return||c.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var r=n(7),i=n.n(r),o=n(14),a=n.n(o),c=n(15),l=n.n(c),s=n(16),u=n.n(s),p=n(17),m=n.n(p),f=n(6),d=n.n(f),b=n(18),v=n.n(b),y=n(4),g=n.n(y),O=n(0),h=n(1),j=n(5),w=n.n(j),_=(n(25),n(2)),E=n(8),k=n(3),x=n(19),S=n(10),T=n(20),P=(n(26),n(9)),N=function(e){var t=e.blocks,n=void 0===t?[]:t,r=e.viewportWidth;return n&&n.length?Object(O.createElement)("div",{className:"edit-post-visual-editor"},Object(O.createElement)("div",{className:"editor-styles-wrapper"},Object(O.createElement)("div",{className:"editor-writing-flow"},Object(O.createElement)(P.BlockPreview,{blocks:n,viewportWidth:r})))):null},B=function(e){var t=e.id,n=e.value,r=e.onSelect,i=e.label,o=e.useDynamicPreview,a=void 0!==o&&o,c=e.staticPreviewImg,l=e.staticPreviewImgAlt,s=void 0===l?"":l,u=e.blocks,p=void 0===u?[]:u,m=e.isSelected,f=e.handleTemplateConfirmation;if(Object(h.isNil)(t)||Object(h.isNil)(i)||Object(h.isNil)(n))return null;if(a&&(Object(h.isNil)(p)||Object(h.isEmpty)(p)))return null;var d=a?Object(O.createElement)(k.Disabled,null,Object(O.createElement)(N,{blocks:p,viewportWidth:960})):Object(O.createElement)("img",{className:"template-selector-item__media",src:c,alt:s}),b="label-".concat(t,"-").concat(n);return Object(O.createElement)("button",{type:"button",className:w()("template-selector-item__label",{"is-selected":m}),value:n,onClick:function(){var e=window.matchMedia("(min-width: 660px)").matches;r(n),e||f(n)},"aria-labelledby":"".concat(t," ").concat(b)},Object(O.createElement)("div",{className:"template-selector-item__preview-wrap"},d),Object(O.createElement)("span",{className:"template-selector-item__template-title",id:b},i))},C={Address:Object(_._x)("123 Main St","default address","full-site-editing"),Phone:Object(_._x)("555-555-5555","default phone number","full-site-editing"),CompanyName:Object(_._x)("Your Company Name","default company name","full-site-editing"),Vertical:Object(_._x)("Business","default vertical name","full-site-editing")},I={CompanyName:"title",Address:"address",Phone:"phone",Vertical:"vertical"},A=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?e.replace(/{{(\w+)}}/g,function(e,n){var r=C[n];return t[I[n]]||r||n}):""},D=Object(E.compose)(O.memo,E.withInstanceId)(function(e){var t=e.label,n=e.className,r=e.help,i=e.instanceId,o=e.templates,a=void 0===o?[]:o,c=e.blocksByTemplates,l=void 0===c?{}:c,s=e.useDynamicPreview,u=void 0!==s&&s,p=e.onTemplateSelect,m=void 0===p?h.noop:p,f=e.siteInformation,d=void 0===f?{}:f,b=e.selectedTemplate,v=e.handleTemplateConfirmation,y=void 0===v?h.noop:v;if(Object(h.isEmpty)(a)||!Object(h.isArray)(a))return null;if(!0===u&&Object(h.isEmpty)(l))return null;var g="template-selector-control-".concat(i);return Object(O.createElement)(k.BaseControl,{label:t,id:g,help:r,className:w()(n,"template-selector-control")},Object(O.createElement)("ul",{className:"template-selector-control__options","data-testid":"template-selector-control-options"},Object(h.map)(a,function(e){var t=e.slug,n=e.title,i=e.preview,o=e.previewAlt;return Object(O.createElement)("li",{key:"".concat(g,"-").concat(t),className:"template-selector-control__template"},Object(O.createElement)(B,{id:g,value:t,label:A(n,d),help:r,onSelect:m,staticPreviewImg:i,staticPreviewImgAlt:o,blocks:l.hasOwnProperty(t)?l[t]:[],useDynamicPreview:u,isSelected:t===b,handleTemplateConfirmation:y}))})))}),M=n(11),q=n.n(M),L=function(e){var t=e.title,n=e.transform;return Object(O.createElement)("div",{className:"editor-post-title",style:{transform:n}},Object(O.createElement)("div",{className:"wp-block editor-post-title__block"},Object(O.createElement)("textarea",{className:"editor-post-title__input",value:t,onChange:function(){}})))},R=function(e){return Object(O.createElement)(P.BlockPreview,e)},U=function(e){var t=e.blocks,n=e.viewportWidth,r=e.title,i=w()("template-selector-preview","editor-styles-wrapper"),o=Object(O.useState)("hidden"),a=q()(o,2),c=a[0],l=a[1],s=Object(O.useRef)(null),u=Object(O.useReducer)(function(e){return e+1},0),p=q()(u,2),m=p[0],f=p[1],d=function(){setTimeout(function(){if(s&&s.current){var e=s.current.querySelector(".block-editor-block-preview__content");if(e){var t=window.getComputedStyle(e);if(t&&t.transform){var n=s.current.querySelector(".editor-post-title");n&&(n.style.transform=t.transform);var r=t.transform.replace(/matrix\((.+)\)$/i,"$1").split(",");r=r&&r.length?Number(r[0]):null,r=isNaN(r)?null:r;var i=e.closest(".template-selector-preview__offset-correction");if(i&&r){var o=n?n.offsetHeight:null;i.style.top="".concat(o*r,"px")}}l("visible")}}},300)};return Object(O.useLayoutEffect)(function(){l("hidden"),d()},[t]),Object(O.useEffect)(function(){if(t&&t.length){var e=Object(h.debounce)(function(){d(),f()},300);return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}},[t]),Object(h.isEmpty)(t)||!Object(h.isArray)(t)?Object(O.createElement)("div",{className:i},Object(O.createElement)("div",{className:"template-selector-preview__placeholder"},Object(_.__)("Select a page template to preview.","full-site-editing"))):Object(O.createElement)("div",{className:i},Object(O.createElement)(k.Disabled,null,Object(O.createElement)("div",{ref:s,className:"edit-post-visual-editor"},Object(O.createElement)("div",{className:"editor-styles-wrapper",style:{visibility:c}},Object(O.createElement)("div",{className:"editor-writing-flow"},Object(O.createElement)(L,{title:r}),Object(O.createElement)("div",{className:"template-selector-preview__offset-correction"},Object(O.createElement)(R,{key:m,blocks:t,viewportWidth:n})))))))};window._tkq=window._tkq||[];var W,V=null,z=function(e,t){V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_dismiss",{blog_id:V.blogid,segment_id:e,vertical_id:t}])},F=function(e,t,n){V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_template_selected",{blog_id:V.blogid,segment_id:e,vertical_id:t,template:n}])},G=n(12),$=n.n(G),H=n(13),Q=n.n(H),Y=n(21),J=n.n(Y),K=n(22),X=function(e,t,n){var r=e[t=Object(K.removeQueryArgs)(t,"w","s")]||{url:t,usages:[]};return i()({},e,g()({},t,i()({},r,{usages:[].concat(Q()(r.usages),Q()(n))})))},Z=function e(t,n){switch(t.blocksByClientId[n.clientId]=n,n.name){case"core/cover":case"core/image":var r=n.attributes.url;r&&(t.assets=X(t.assets,r,[{prop:"url",path:[n.clientId,"attributes","url"]},{prop:"id",path:[n.clientId,"attributes","id"]}]));case"core/media-text":var i=n.attributes.mediaUrl;i&&"image"===n.attributes.mediaType&&(t.assets=X(t.assets,i,[{prop:"url",path:[n.clientId,"attributes","mediaUrl"]},{prop:"id",path:[n.clientId,"attributes","mediaId"]}]));case"core/gallery":Object(h.forEach)(n.attributes.images,function(e,r){t.assets=X(t.assets,e.url,[{prop:"url",path:[n.clientId,"attributes","images",r,"url"]},{prop:"url",path:[n.clientId,"attributes","images",r,"link"]},{prop:"id",path:[n.clientId,"attributes","images",r,"id"]},{prop:"id",path:[n.clientId,"attributes","ids",r]}])})}return Object(h.isEmpty)(n.innerBlocks)?t:Object(h.reduce)(n.innerBlocks,e,t)},ee=function(){var e=$()(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J()({method:"POST",path:"/fse/v1/sideload/image/batch",data:{resources:Object(h.map)(t)}}).then(function(e){return Object(h.reduce)(t,function(t,n){var r=e.shift(),o=r.id,a=r.source_url;return i()({},t,g()({},n.url,{id:o,url:a}))},{})});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),te=function(e,t){return Object(h.forEach)(e.assets,function(n){var r=t[n.url];r&&Object(h.forEach)(n.usages,function(t){Object(h.set)(e.blocksByClientId,t.path,r[t.prop])})}),e.blocks},ne=function(){var e=$()(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Object(h.reduce)(t,Z,{assets:{},blocksByClientId:{},blocks:t}),!Object(h.isEmpty)(n.assets)){e.next=3;break}return e.abrupt("return",t);case 3:return e.abrupt("return",ee(n.assets).then(function(e){return te(n,e)}));case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),re=window.starterPageTemplatesConfig,ie=re.templates,oe=void 0===ie?[]:ie,ae=re.vertical,ce=re.segment,le=re.tracksUserData,se=re.siteInformation,ue=void 0===se?{}:se,pe=function(e){function t(e){var n;a()(this,t),n=u()(this,m()(t).call(this)),g()(d()(n),"state",{isLoading:!1,previewedTemplate:null,blocksByTemplateSlug:{},titlesByTemplateSlug:{},error:null,isOpen:!1}),g()(d()(n),"setTemplate",function(e){F(n.props.segment.id,n.props.vertical.id,e),n.props.saveTemplateChoice(e);var t=n.getBlocksByTemplateSlug(e),r=n.getTitleByTemplateSlug(e);t&&t.length?(n.setState({error:null,isLoading:!0}),n.maybePrefetchAssets(t).then(function(e){n.state.isOpen&&(n.props.insertTemplate(r,e),n.setState({isOpen:!1}))}).catch(function(e){n.setState({isLoading:!1,error:e})})):n.setState({isOpen:!1})}),g()(d()(n),"maybePrefetchAssets",function(e){return n.props.shouldPrefetchAssets?ne(e):Promise.resolve(e)}),g()(d()(n),"handleConfirmation",function(e){"string"!=typeof e&&(e=n.state.previewedTemplate),n.setTemplate(e)}),g()(d()(n),"previewTemplate",function(e){return n.setState({previewedTemplate:e})}),g()(d()(n),"closeModal",function(e){if(e.target.matches("button.template-selector-item__label"))return!1;z(n.props.segment.id,n.props.vertical.id);var t=Object(h.get)(window,["calypsoifyGutenberg","closeUrl"]);window.top.location=t||"edit.php?post_type=page"});var r=!Object(h.isEmpty)(e.templates);return n.state.isOpen=r,r&&(n.state.previewedTemplate=Object(h.get)(e.templates,[0,"slug"]),n.state.titlesByTemplateSlug=Object(h.mapValues)(Object(h.keyBy)(e.templates,"slug"),"title")),n}return v()(t,e),l()(t,[{key:"componentDidMount",value:function(){var e,t;this.state.isOpen&&(e=this.props.segment.id,t=this.props.vertical.id,V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_view",{blog_id:V.blogid,segment_id:e,vertical_id:t}]));var n=Object(h.reduce)(oe,function(e,t){var n=t.slug,r=t.content;return e[n]=r?Object(T.parse)(A(r,ue)):[],e},{});this.setState({blocksByTemplateSlug:n})}},{key:"getBlocksByTemplateSlug",value:function(e){return Object(h.get)(this.state.blocksByTemplateSlug,[e],[])}},{key:"getTitleByTemplateSlug",value:function(e){return Object(h.get)(this.state.titlesByTemplateSlug,[e],"")}},{key:"render",value:function(){var e=this.state,t=e.previewedTemplate,n=e.isOpen,r=e.isLoading,i=e.blocksByTemplateSlug,o=this.props.templates;return n?Object(O.createElement)(k.Modal,{title:Object(_.__)("Select Page Template","full-site-editing"),className:"page-template-modal",overlayClassName:"page-template-modal-screen-overlay",shouldCloseOnClickOutside:!1,isDismissable:!1,isDismissible:!1},Object(O.createElement)(k.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:this.closeModal,icon:"arrow-left-alt2",label:Object(_.__)("Go back")}),Object(O.createElement)("div",{className:"page-template-modal__inner"},r?Object(O.createElement)("div",{className:"page-template-modal__loading"},Object(O.createElement)(k.Spinner,null),Object(_.__)("Inserting template…","full-site-editing")):Object(O.createElement)(O.Fragment,null,Object(O.createElement)("form",{className:"page-template-modal__form"},Object(O.createElement)("fieldset",{className:"page-template-modal__list"},Object(O.createElement)("legend",{className:"page-template-modal__form-title"},Object(_.__)("Choose a template…","full-site-editing")),Object(O.createElement)(D,{label:Object(_.__)("Template","full-site-editing"),templates:o,blocksByTemplates:i,onTemplateSelect:this.previewTemplate,useDynamicPreview:!1,siteInformation:ue,selectedTemplate:t,handleTemplateConfirmation:this.handleConfirmation}))),Object(O.createElement)(U,{blocks:this.getBlocksByTemplateSlug(t),viewportWidth:960,title:this.getTitleByTemplateSlug(t)}))),Object(O.createElement)("div",{className:w()("page-template-modal__buttons",{"is-visually-hidden":Object(h.isEmpty)(t)||r})},Object(O.createElement)(k.Button,{isPrimary:!0,isLarge:!0,disabled:Object(h.isEmpty)(t)||r,onClick:this.handleConfirmation},Object(_.sprintf)(Object(_.__)("Use %s template","full-site-editing"),this.getTitleByTemplateSlug(t))))):null}}]),t}(O.Component),me=Object(E.compose)(Object(S.withSelect)(function(e){return{getMeta:function(){return e("core/editor").getEditedPostAttribute("meta")},postContentBlock:e("core/editor").getBlocks().find(function(e){return"a8c/post-content"===e.name})}}),Object(S.withDispatch)(function(e,t){e("core/nux").disableTips();var n=e("core/editor");return{saveTemplateChoice:function(e){var r=t.getMeta();n.editPost({meta:i()({},r,{_starter_page_template:e})})},insertTemplate:function(r,i){n.editPost({title:r});var o=t.postContentBlock;e("core/block-editor").insertBlocks(i,0,o?o.clientId:"",!1)}}}))(pe);le&&(V=W=le,window._tkq.push(["identifyUser",W.userid,W.username])),Object(x.registerPlugin)("page-templates",{render:function(){return Object(O.createElement)(me,{shouldPrefetchAssets:!1,templates:oe,vertical:ae,segment:ce})}})}]));
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=i.apply(null,r);a&&e.push(a)}else if("object"===o)for(var c in r)n.call(r,c)&&r[c]&&e.push(c)}}return e.join(" ")}e.exports?(i.default=i,e.exports=i):void 0===(r=function(){return i}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,n){var r=n(4);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}e.exports=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(n,!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t,n){var r=n(27),i=n(28),o=n(29);e.exports=function(e,t){return r(e)||i(e,t)||o()}},function(e,t){function n(e,t,n,r,i,o,a){try{var c=e[o](a),l=c.value}catch(s){return void n(s)}c.done?t(l):Promise.resolve(l).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function c(e){n(a,i,o,c,l,"next",e)}function l(e){n(a,i,o,c,l,"throw",e)}c(void 0)}))}}},function(e,t,n){var r=n(30),i=n(31),o=n(32);e.exports=function(e){return r(e)||i(e)||o()}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(23),i=n(6);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var r=n(24);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t){!function(){e.exports=this.wp.apiFetch}()},function(e,t){!function(){e.exports=this.wp.url}()},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(e){return n(e)}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},r(t)}e.exports=r},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t){!function(){e.exports=this.wp.nux}()},function(e,t,n){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(l){i=!0,o=l}finally{try{r||null==c.return||c.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var r=n(7),i=n.n(r),o=n(14),a=n.n(o),c=n(15),l=n.n(c),s=n(16),u=n.n(s),p=n(17),m=n.n(p),f=n(6),d=n.n(f),b=n(18),v=n.n(b),y=n(4),g=n.n(y),O=n(0),h=n(1),j=n(5),w=n.n(j),_=(n(25),n(2)),E=n(8),k=n(3),x=n(19),S=n(10),T=n(20),P=(n(26),n(9)),N=function(e){var t=e.blocks,n=void 0===t?[]:t,r=e.viewportWidth;return n&&n.length?Object(O.createElement)("div",{className:"edit-post-visual-editor"},Object(O.createElement)("div",{className:"editor-styles-wrapper"},Object(O.createElement)("div",{className:"editor-writing-flow"},Object(O.createElement)(P.BlockPreview,{blocks:n,viewportWidth:r})))):null},B=function(e){var t=e.id,n=e.value,r=e.onSelect,i=e.label,o=e.useDynamicPreview,a=void 0!==o&&o,c=e.staticPreviewImg,l=e.staticPreviewImgAlt,s=void 0===l?"":l,u=e.blocks,p=void 0===u?[]:u,m=e.isSelected,f=e.handleTemplateConfirmation;if(Object(h.isNil)(t)||Object(h.isNil)(i)||Object(h.isNil)(n))return null;if(a&&(Object(h.isNil)(p)||Object(h.isEmpty)(p)))return null;var d=a?Object(O.createElement)(k.Disabled,null,Object(O.createElement)(N,{blocks:p,viewportWidth:960})):Object(O.createElement)("img",{className:"template-selector-item__media",src:c,alt:s}),b="label-".concat(t,"-").concat(n);return Object(O.createElement)("button",{type:"button",className:w()("template-selector-item__label",{"is-selected":m}),value:n,onClick:function(){var e=window.matchMedia("(min-width: 660px)").matches;r(n),e||f(n)},"aria-labelledby":"".concat(t," ").concat(b)},Object(O.createElement)("div",{className:"template-selector-item__preview-wrap"},d),Object(O.createElement)("span",{className:"template-selector-item__template-title",id:b},i))},C={Address:Object(_._x)("123 Main St","default address","full-site-editing"),Phone:Object(_._x)("555-555-5555","default phone number","full-site-editing"),CompanyName:Object(_._x)("Your Company Name","default company name","full-site-editing"),Vertical:Object(_._x)("Business","default vertical name","full-site-editing")},I={CompanyName:"title",Address:"address",Phone:"phone",Vertical:"vertical"},A=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?e.replace(/{{(\w+)}}/g,(function(e,n){var r=C[n];return t[I[n]]||r||n})):""},D=Object(E.compose)(O.memo,E.withInstanceId)((function(e){var t=e.label,n=e.className,r=e.help,i=e.instanceId,o=e.templates,a=void 0===o?[]:o,c=e.blocksByTemplates,l=void 0===c?{}:c,s=e.useDynamicPreview,u=void 0!==s&&s,p=e.onTemplateSelect,m=void 0===p?h.noop:p,f=e.siteInformation,d=void 0===f?{}:f,b=e.selectedTemplate,v=e.handleTemplateConfirmation,y=void 0===v?h.noop:v;if(Object(h.isEmpty)(a)||!Object(h.isArray)(a))return null;if(!0===u&&Object(h.isEmpty)(l))return null;var g="template-selector-control-".concat(i);return Object(O.createElement)(k.BaseControl,{label:t,id:g,help:r,className:w()(n,"template-selector-control")},Object(O.createElement)("ul",{className:"template-selector-control__options","data-testid":"template-selector-control-options"},Object(h.map)(a,(function(e){var t=e.slug,n=e.title,i=e.preview,o=e.previewAlt;return Object(O.createElement)("li",{key:"".concat(g,"-").concat(t),className:"template-selector-control__template"},Object(O.createElement)(B,{id:g,value:t,label:A(n,d),help:r,onSelect:m,staticPreviewImg:i,staticPreviewImgAlt:o,blocks:l.hasOwnProperty(t)?l[t]:[],useDynamicPreview:u,isSelected:t===b,handleTemplateConfirmation:y}))}))))})),M=n(11),q=n.n(M),L=function(e){var t=e.title,n=e.transform;return(Object(O.createElement)("div",{className:"editor-post-title",style:{transform:n}},Object(O.createElement)("div",{className:"wp-block editor-post-title__block"},Object(O.createElement)("textarea",{className:"editor-post-title__input",value:t,onChange:function(){}}))))},R=function(e){return Object(O.createElement)(P.BlockPreview,e)},U=function(e){var t=e.blocks,n=e.viewportWidth,r=e.title,i=w()("template-selector-preview","editor-styles-wrapper"),o=Object(O.useState)("hidden"),a=q()(o,2),c=a[0],l=a[1],s=Object(O.useRef)(null),u=Object(O.useReducer)((function(e){return e+1}),0),p=q()(u,2),m=p[0],f=p[1],d=function(){setTimeout((function(){if(s&&s.current){var e=s.current.querySelector(".block-editor-block-preview__content");if(e){var t=window.getComputedStyle(e);if(t&&t.transform){var n=s.current.querySelector(".editor-post-title");n&&(n.style.transform=t.transform);var r=t.transform.replace(/matrix\((.+)\)$/i,"$1").split(",");r=r&&r.length?Number(r[0]):null,r=isNaN(r)?null:r;var i=e.closest(".template-selector-preview__offset-correction");if(i&&r){var o=n?n.offsetHeight:null;i.style.top="".concat(o*r,"px")}}l("visible")}}}),300)};return Object(O.useLayoutEffect)((function(){l("hidden"),d()}),[t]),Object(O.useEffect)((function(){if(t&&t.length){var e=Object(h.debounce)((function(){d(),f()}),300);return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}}),[t]),Object(h.isEmpty)(t)||!Object(h.isArray)(t)?Object(O.createElement)("div",{className:i},Object(O.createElement)("div",{className:"template-selector-preview__placeholder"},Object(_.__)("Select a page template to preview.","full-site-editing"))):Object(O.createElement)("div",{className:i},Object(O.createElement)(k.Disabled,null,Object(O.createElement)("div",{ref:s,className:"edit-post-visual-editor"},Object(O.createElement)("div",{className:"editor-styles-wrapper",style:{visibility:c}},Object(O.createElement)("div",{className:"editor-writing-flow"},Object(O.createElement)(L,{title:r}),Object(O.createElement)("div",{className:"template-selector-preview__offset-correction"},Object(O.createElement)(R,{key:m,blocks:t,viewportWidth:n})))))))};window._tkq=window._tkq||[];var W,V=null,z=function(e,t){V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_dismiss",{blog_id:V.blogid,segment_id:e,vertical_id:t}])},F=function(e,t,n){V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_template_selected",{blog_id:V.blogid,segment_id:e,vertical_id:t,template:n}])},G=n(12),$=n.n(G),H=n(13),Q=n.n(H),Y=n(21),J=n.n(Y),K=n(22),X=function(e,t,n){var r=e[t=Object(K.removeQueryArgs)(t,"w","s")]||{url:t,usages:[]};return i()({},e,g()({},t,i()({},r,{usages:[].concat(Q()(r.usages),Q()(n))})))},Z=function e(t,n){switch(t.blocksByClientId[n.clientId]=n,n.name){case"core/cover":case"core/image":var r=n.attributes.url;r&&(t.assets=X(t.assets,r,[{prop:"url",path:[n.clientId,"attributes","url"]},{prop:"id",path:[n.clientId,"attributes","id"]}]));case"core/media-text":var i=n.attributes.mediaUrl;i&&"image"===n.attributes.mediaType&&(t.assets=X(t.assets,i,[{prop:"url",path:[n.clientId,"attributes","mediaUrl"]},{prop:"id",path:[n.clientId,"attributes","mediaId"]}]));case"core/gallery":Object(h.forEach)(n.attributes.images,(function(e,r){t.assets=X(t.assets,e.url,[{prop:"url",path:[n.clientId,"attributes","images",r,"url"]},{prop:"url",path:[n.clientId,"attributes","images",r,"link"]},{prop:"id",path:[n.clientId,"attributes","images",r,"id"]},{prop:"id",path:[n.clientId,"attributes","ids",r]}])}))}return Object(h.isEmpty)(n.innerBlocks)?t:Object(h.reduce)(n.innerBlocks,e,t)},ee=function(){var e=$()(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J()({method:"POST",path:"/fse/v1/sideload/image/batch",data:{resources:Object(h.map)(t)}}).then((function(e){return Object(h.reduce)(t,(function(t,n){var r=e.shift(),o=r.id,a=r.source_url;return i()({},t,g()({},n.url,{id:o,url:a}))}),{})}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),te=function(e,t){return Object(h.forEach)(e.assets,(function(n){var r=t[n.url];r&&Object(h.forEach)(n.usages,(function(t){Object(h.set)(e.blocksByClientId,t.path,r[t.prop])}))})),e.blocks},ne=function(){var e=$()(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Object(h.reduce)(t,Z,{assets:{},blocksByClientId:{},blocks:t}),!Object(h.isEmpty)(n.assets)){e.next=3;break}return e.abrupt("return",t);case 3:return e.abrupt("return",ee(n.assets).then((function(e){return te(n,e)})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),re=window.starterPageTemplatesConfig,ie=re.templates,oe=void 0===ie?[]:ie,ae=re.vertical,ce=re.segment,le=re.tracksUserData,se=re.siteInformation,ue=void 0===se?{}:se,pe=function(e){function t(e){var n;a()(this,t),n=u()(this,m()(t).call(this)),g()(d()(n),"state",{isLoading:!1,previewedTemplate:null,blocksByTemplateSlug:{},titlesByTemplateSlug:{},error:null,isOpen:!1}),g()(d()(n),"setTemplate",(function(e){F(n.props.segment.id,n.props.vertical.id,e),n.props.saveTemplateChoice(e);var t=n.getBlocksByTemplateSlug(e),r=n.getTitleByTemplateSlug(e);t&&t.length?(n.setState({error:null,isLoading:!0}),n.maybePrefetchAssets(t).then((function(e){n.state.isOpen&&(n.props.insertTemplate(r,e),n.setState({isOpen:!1}))})).catch((function(e){n.setState({isLoading:!1,error:e})}))):n.setState({isOpen:!1})})),g()(d()(n),"maybePrefetchAssets",(function(e){return n.props.shouldPrefetchAssets?ne(e):Promise.resolve(e)})),g()(d()(n),"handleConfirmation",(function(e){"string"!=typeof e&&(e=n.state.previewedTemplate),n.setTemplate(e)})),g()(d()(n),"previewTemplate",(function(e){return n.setState({previewedTemplate:e})})),g()(d()(n),"closeModal",(function(e){if(e.target.matches("button.template-selector-item__label"))return!1;z(n.props.segment.id,n.props.vertical.id);var t=Object(h.get)(window,["calypsoifyGutenberg","closeUrl"]);window.top.location=t||"edit.php?post_type=page"}));var r=!Object(h.isEmpty)(e.templates);return n.state.isOpen=r,r&&(n.state.previewedTemplate=Object(h.get)(e.templates,[0,"slug"]),n.state.titlesByTemplateSlug=Object(h.mapValues)(Object(h.keyBy)(e.templates,"slug"),"title")),n}return v()(t,e),l()(t,[{key:"componentDidMount",value:function(){var e,t;this.state.isOpen&&(e=this.props.segment.id,t=this.props.vertical.id,V&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_view",{blog_id:V.blogid,segment_id:e,vertical_id:t}]));var n=Object(h.reduce)(oe,(function(e,t){var n=t.slug,r=t.content;return e[n]=r?Object(T.parse)(A(r,ue)):[],e}),{});this.setState({blocksByTemplateSlug:n})}},{key:"getBlocksByTemplateSlug",value:function(e){return Object(h.get)(this.state.blocksByTemplateSlug,[e],[])}},{key:"getTitleByTemplateSlug",value:function(e){return Object(h.get)(this.state.titlesByTemplateSlug,[e],"")}},{key:"render",value:function(){var e=this.state,t=e.previewedTemplate,n=e.isOpen,r=e.isLoading,i=e.blocksByTemplateSlug,o=this.props.templates;return n?Object(O.createElement)(k.Modal,{title:Object(_.__)("Select Page Template","full-site-editing"),className:"page-template-modal",overlayClassName:"page-template-modal-screen-overlay",shouldCloseOnClickOutside:!1,isDismissable:!1,isDismissible:!1},Object(O.createElement)(k.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:this.closeModal,icon:"arrow-left-alt2",label:Object(_.__)("Go back")}),Object(O.createElement)("div",{className:"page-template-modal__inner"},r?Object(O.createElement)("div",{className:"page-template-modal__loading"},Object(O.createElement)(k.Spinner,null),Object(_.__)("Inserting template…","full-site-editing")):Object(O.createElement)(O.Fragment,null,Object(O.createElement)("form",{className:"page-template-modal__form"},Object(O.createElement)("fieldset",{className:"page-template-modal__list"},Object(O.createElement)("legend",{className:"page-template-modal__form-title"},Object(_.__)("Choose a template…","full-site-editing")),Object(O.createElement)(D,{label:Object(_.__)("Template","full-site-editing"),templates:o,blocksByTemplates:i,onTemplateSelect:this.previewTemplate,useDynamicPreview:!1,siteInformation:ue,selectedTemplate:t,handleTemplateConfirmation:this.handleConfirmation}))),Object(O.createElement)(U,{blocks:this.getBlocksByTemplateSlug(t),viewportWidth:960,title:this.getTitleByTemplateSlug(t)}))),Object(O.createElement)("div",{className:w()("page-template-modal__buttons",{"is-visually-hidden":Object(h.isEmpty)(t)||r})},Object(O.createElement)(k.Button,{isPrimary:!0,isLarge:!0,disabled:Object(h.isEmpty)(t)||r,onClick:this.handleConfirmation},Object(_.sprintf)(Object(_.__)("Use %s template","full-site-editing"),this.getTitleByTemplateSlug(t))))):null}}]),t}(O.Component),me=Object(E.compose)(Object(S.withSelect)((function(e){return{getMeta:function(){return e("core/editor").getEditedPostAttribute("meta")},postContentBlock:e("core/editor").getBlocks().find((function(e){return"a8c/post-content"===e.name}))}})),Object(S.withDispatch)((function(e,t){e("core/nux").disableTips();var n=e("core/editor");return{saveTemplateChoice:function(e){var r=t.getMeta();n.editPost({meta:i()({},r,{_starter_page_template:e})})},insertTemplate:function(r,i){n.editPost({title:r});var o=t.postContentBlock;e("core/block-editor").insertBlocks(i,0,o?o.clientId:"",!1)}}})))(pe);le&&(V=W=le,window._tkq.push(["identifyUser",W.userid,W.username])),Object(x.registerPlugin)("page-templates",{render:function(){return Object(O.createElement)(me,{shouldPrefetchAssets:!1,templates:oe,vertical:ae,segment:ce})}})}]));
|
|
|
|
|
|
|
|
|
|
|
|