Version Description
- Posts List Block - fixes Edit link to only display for users with appropriate permissions.
Download this release
Release Info
Developer | get_dave |
Plugin | Full Site Editing |
Version | 0.2.2 |
Comparing to | |
See all releases |
Code changes from version 0.2.1 to 0.2.2
- full-site-editing-plugin.php +2 -2
- full-site-editing/blocks/site-title/edit.js +93 -0
- full-site-editing/blocks/site-title/index.js +25 -0
- full-site-editing/blocks/site-title/index.php +30 -0
- full-site-editing/blocks/site-title/style.scss +12 -0
- lib/feature-flags/feature-flags.php +0 -116
- posts-list-block/templates/post-item.php +5 -3
- readme.txt +10 -2
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.2.
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
21 |
-
define( 'A8C_FSE_VERSION', '0.2.
|
22 |
|
23 |
/**
|
24 |
* Load Full Site Editing.
|
2 |
/**
|
3 |
* Plugin Name: Full Site Editing
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
+
* Version: 0.2.2
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
21 |
+
define( 'A8C_FSE_VERSION', '0.2.2' );
|
22 |
|
23 |
/**
|
24 |
* Load Full Site Editing.
|
full-site-editing/blocks/site-title/edit.js
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import classNames from 'classnames';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* WordPress dependencies
|
8 |
+
*/
|
9 |
+
import { __ } from '@wordpress/i18n';
|
10 |
+
import { withNotices } from '@wordpress/components';
|
11 |
+
import { PlainText } from '@wordpress/editor';
|
12 |
+
import apiFetch from '@wordpress/api-fetch';
|
13 |
+
import { withSelect } from '@wordpress/data';
|
14 |
+
import { compose } from '@wordpress/compose';
|
15 |
+
import { Component, Fragment } from '@wordpress/element';
|
16 |
+
|
17 |
+
class SiteTitleEdit extends Component {
|
18 |
+
state = {
|
19 |
+
title: __( 'Site title loading…' ),
|
20 |
+
initialTitle: '',
|
21 |
+
};
|
22 |
+
|
23 |
+
componentDidMount() {
|
24 |
+
const { noticeOperations } = this.props;
|
25 |
+
|
26 |
+
return apiFetch( { path: '/wp/v2/settings' } )
|
27 |
+
.then( ( { title } ) => this.setState( { initialTitle: title, title } ) )
|
28 |
+
.catch( ( { message } ) => noticeOperations.createErrorNotice( message ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
componentDidUpdate( prevProps ) {
|
32 |
+
const { title, initialTitle } = this.state;
|
33 |
+
const { shouldUpdateSiteOption, noticeOperations, isSelected } = this.props;
|
34 |
+
|
35 |
+
const titleUnchanged = title && title.trim() === initialTitle.trim();
|
36 |
+
const titleIsEmpty = ! title || title.trim().length === 0;
|
37 |
+
|
38 |
+
// Reset to initial value if user de-selects the block with an empty value.
|
39 |
+
if ( ! isSelected && prevProps.isSelected && titleIsEmpty ) {
|
40 |
+
this.revertTitle();
|
41 |
+
}
|
42 |
+
|
43 |
+
// Don't do anything further if we shouldn't update the site option or the value is unchanged.
|
44 |
+
if ( ! shouldUpdateSiteOption || titleUnchanged ) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( ! prevProps.shouldUpdateSiteOption && shouldUpdateSiteOption ) {
|
49 |
+
apiFetch( { path: '/wp/v2/settings', method: 'POST', data: { title } } )
|
50 |
+
.then( () => this.updateInitialTitle() )
|
51 |
+
.catch( ( { message } ) => {
|
52 |
+
noticeOperations.createErrorNotice( message );
|
53 |
+
this.revertTitle();
|
54 |
+
} );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
revertTitle = () => this.setState( { title: this.state.initialTitle } );
|
59 |
+
|
60 |
+
updateInitialTitle = () => this.setState( { initialTitle: this.state.title } );
|
61 |
+
|
62 |
+
render() {
|
63 |
+
const { title } = this.state;
|
64 |
+
const { className, noticeUI } = this.props;
|
65 |
+
|
66 |
+
return (
|
67 |
+
<Fragment>
|
68 |
+
{ noticeUI }
|
69 |
+
<PlainText
|
70 |
+
className={ classNames( 'site-title', className ) }
|
71 |
+
value={ title }
|
72 |
+
onChange={ value => this.setState( { title: value } ) }
|
73 |
+
placeholder={ __( 'Site Title' ) }
|
74 |
+
aria-label={ __( 'Site Title' ) }
|
75 |
+
/>
|
76 |
+
</Fragment>
|
77 |
+
);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
export default compose( [
|
82 |
+
withSelect( select => {
|
83 |
+
const { isSavingPost, isPublishingPost, isAutosavingPost, isCurrentPostPublished } = select(
|
84 |
+
'core/editor'
|
85 |
+
);
|
86 |
+
return {
|
87 |
+
shouldUpdateSiteOption:
|
88 |
+
( ( isSavingPost() && isCurrentPostPublished() ) || isPublishingPost() ) &&
|
89 |
+
! isAutosavingPost(),
|
90 |
+
};
|
91 |
+
} ),
|
92 |
+
withNotices,
|
93 |
+
] )( SiteTitleEdit );
|
full-site-editing/blocks/site-title/index.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WordPress dependencies
|
3 |
+
*/
|
4 |
+
import { registerBlockType } from '@wordpress/blocks';
|
5 |
+
import { __ } from '@wordpress/i18n';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Internal dependencies
|
9 |
+
*/
|
10 |
+
import edit from './edit';
|
11 |
+
import './style.scss';
|
12 |
+
|
13 |
+
registerBlockType( 'a8c/site-title', {
|
14 |
+
title: __( 'Site Title' ),
|
15 |
+
description: __( 'Your site title.' ),
|
16 |
+
icon: 'layout',
|
17 |
+
category: 'layout',
|
18 |
+
supports: {
|
19 |
+
html: false,
|
20 |
+
multiple: false,
|
21 |
+
reusable: false,
|
22 |
+
},
|
23 |
+
edit,
|
24 |
+
save: () => null,
|
25 |
+
} );
|
full-site-editing/blocks/site-title/index.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render site title block.
|
4 |
+
*
|
5 |
+
* @package full-site-editing
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Renders the site title and allows for editing in the full site editor.
|
9 |
+
*
|
10 |
+
* @param array $attributes Block attributes.
|
11 |
+
* @param string $content Block content.
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
function render_site_title_block( $attributes, $content ) {
|
15 |
+
ob_start();
|
16 |
+
|
17 |
+
$class = 'site-title wp-block-a8c-site-title';
|
18 |
+
if ( isset( $attributes['className'] ) ) {
|
19 |
+
$class .= ' ' . $attributes['className'];
|
20 |
+
}
|
21 |
+
|
22 |
+
?>
|
23 |
+
<h1 class="<?php echo esc_attr( $class ); ?>">
|
24 |
+
<a href=<?php echo get_home_url(); ?>><?php echo get_bloginfo( 'name' ); ?></a>
|
25 |
+
</h1>
|
26 |
+
<!-- a8c:site-title -->
|
27 |
+
<?php
|
28 |
+
return ob_get_clean();
|
29 |
+
}
|
30 |
+
|
full-site-editing/blocks/site-title/style.scss
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.block-editor .wp-block-a8c-site-title {
|
2 |
+
&, &:focus {
|
3 |
+
display: inline;
|
4 |
+
color: #111111;
|
5 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
6 |
+
font-size: 1.125em;
|
7 |
+
font-weight: normal;
|
8 |
+
letter-spacing: -0.02em;
|
9 |
+
line-height: 1.2;
|
10 |
+
margin: 0;
|
11 |
+
}
|
12 |
+
}
|
lib/feature-flags/feature-flags.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Feature flags file.
|
4 |
-
*
|
5 |
-
* @package full-site-editing
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class A8C_Full_Site_Editing_Feature_Flags
|
10 |
-
*/
|
11 |
-
class A8C_Full_Site_Editing_Feature_Flags {
|
12 |
-
/**
|
13 |
-
* Class instance.
|
14 |
-
*
|
15 |
-
* @var A8C_Full_Site_Editing_Feature_Flags
|
16 |
-
*/
|
17 |
-
private static $instance = null;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Feature flags.
|
21 |
-
*
|
22 |
-
* @var array
|
23 |
-
*/
|
24 |
-
private $flags = [];
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Parameter and cookie name for storing/retrieving the feature flags.
|
28 |
-
*
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
const FEATURE_FLAGS = 'fse_feature_flags';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* A8C_Full_Site_Editing_Feature_Flags constructor.
|
35 |
-
*/
|
36 |
-
private function __construct() {
|
37 |
-
$this->set_flags();
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Creates instance.
|
42 |
-
*
|
43 |
-
* @return A8C_Full_Site_Editing_Feature_Flags
|
44 |
-
*/
|
45 |
-
public static function get_instance() {
|
46 |
-
if ( is_null( self::$instance ) ) {
|
47 |
-
self::$instance = new self();
|
48 |
-
}
|
49 |
-
|
50 |
-
return self::$instance;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Get the feature flags.
|
55 |
-
*
|
56 |
-
* @return array
|
57 |
-
*/
|
58 |
-
public function get_flags() {
|
59 |
-
return $this->flags;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Check if a feature flag is enabled.
|
64 |
-
*
|
65 |
-
* @param string $flag_name Feature flag.
|
66 |
-
* @return boolean
|
67 |
-
*/
|
68 |
-
public function is_enabled( $flag_name ) {
|
69 |
-
if ( ! isset( $flag_name, $this->flags[ $flag_name ] ) ) {
|
70 |
-
return false;
|
71 |
-
}
|
72 |
-
|
73 |
-
return (boolean) $this->flags[ $flag_name ];
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Set the feature flags based on GET parameter or cookie value.
|
78 |
-
*/
|
79 |
-
private function set_flags() {
|
80 |
-
$flags = null;
|
81 |
-
|
82 |
-
$has_flags_param = isset( $_GET[ self::FEATURE_FLAGS ] );
|
83 |
-
$has_flags_cookie = isset( $_COOKIE[ self::FEATURE_FLAGS ] );
|
84 |
-
|
85 |
-
// Remove all of the flag values when empty parameter is passed.
|
86 |
-
if ( $has_flags_param && empty( $_GET[ self::FEATURE_FLAGS ] ) ) {
|
87 |
-
setcookie( self::FEATURE_FLAGS, '', time() - 3600 );
|
88 |
-
$this->flags = [];
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
|
92 |
-
if ( $has_flags_param ) {
|
93 |
-
setcookie( self::FEATURE_FLAGS, $_GET[ self::FEATURE_FLAGS ] );
|
94 |
-
$flags = $_GET[ self::FEATURE_FLAGS ];
|
95 |
-
} else if ( $has_flags_cookie ) {
|
96 |
-
$flags = $_COOKIE[ self::FEATURE_FLAGS ];
|
97 |
-
}
|
98 |
-
|
99 |
-
if ( empty( $flags ) ) {
|
100 |
-
$this->flags = [];
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
|
104 |
-
// Feature flags are represented as a string of comma-separated feature flag names.
|
105 |
-
// For example: "flag1,flag2,-flag3" (leading "-" denotes that the given flag is disabled).
|
106 |
-
foreach ( explode( ',', $flags ) as $flag ) {
|
107 |
-
$flag = trim( $flag );
|
108 |
-
$is_enabled = '-' !== $flag[0];
|
109 |
-
|
110 |
-
// Strip "-" for disabled flags to obtain the correct name
|
111 |
-
$name = $is_enabled ? $flag : substr( $flag, 1 );
|
112 |
-
|
113 |
-
$this->flags[ $name ] = $is_enabled;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
posts-list-block/templates/post-item.php
CHANGED
@@ -31,9 +31,11 @@
|
|
31 |
<span class="a8c-posts-list-item__author"><?php echo esc_html_x( 'by', 'designating the post author (eg: by John Doe', 'full-site-editing' ); ?>
|
32 |
<?php the_author_posts_link(); ?>
|
33 |
</span>
|
34 |
-
|
35 |
-
<
|
36 |
-
|
|
|
|
|
37 |
</div>
|
38 |
|
39 |
<div class="a8c-posts-list-item__excerpt">
|
31 |
<span class="a8c-posts-list-item__author"><?php echo esc_html_x( 'by', 'designating the post author (eg: by John Doe', 'full-site-editing' ); ?>
|
32 |
<?php the_author_posts_link(); ?>
|
33 |
</span>
|
34 |
+
<?php if ( current_user_can( 'edit_posts' ) ) : ?>
|
35 |
+
<span class="a8c-posts-list-item__edit-link">
|
36 |
+
<a href="<?php echo esc_attr( get_edit_post_link() ); ?>"><?php esc_html_e( 'Edit', 'full-site-editing' ); ?></a>
|
37 |
+
</span>
|
38 |
+
<?php endif ?>
|
39 |
</div>
|
40 |
|
41 |
<div class="a8c-posts-list-item__excerpt">
|
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.2
|
6 |
-
Stable tag: 0.2
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -40,8 +40,16 @@ This plugin is experimental, so we don't provide any support for it outside of w
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
43 |
= 0.2.1 =
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
|
46 |
= 0.2 =
|
47 |
* Bug fixes and performance improvements.
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.0
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 0.2.2
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 0.2.2 =
|
44 |
+
|
45 |
+
* Posts List Block - fixes Edit link to only display for users with appropriate permissions.
|
46 |
+
|
47 |
= 0.2.1 =
|
48 |
+
|
49 |
+
* Starter Page Templates - bug fix with sub-locales.
|
50 |
+
* Starter Page Templates - fix momentum scrolling on Modal on iOS.
|
51 |
+
* Starter Page Templates - improve comprehension of Templates listing by forcing 2col layout on small viewports.
|
52 |
+
* Starter Page Templates - introduced version constant for cache busting purposes.
|
53 |
|
54 |
= 0.2 =
|
55 |
* Bug fixes and performance improvements.
|