Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gutenberg support #1554

Merged
merged 36 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5039789
Create a style for Gutenberg block styles in Largo
benlk Sep 12, 2018
3539d71
Add WIP support for .alignwide and .alignfull classes
benlk Sep 12, 2018
73da4c6
remove some extraneous comments from css/editor-style.css by LESS (re…
benlk Sep 12, 2018
f9cdb86
Merge branch '1401-hero-margin-left' into gutenberg-css
benlk Sep 12, 2018
255bffa
inc/enqueue.php: largogutenberg_frontend_css_js needs to know suffix …
benlk Sep 12, 2018
533b869
Make #main's z-index 1
benlk Sep 12, 2018
b38e700
floating social buttons' z-index is now beneath #main
benlk Sep 12, 2018
e0633fb
tabs/spaces correction in less/inc/single.less
benlk Sep 12, 2018
962d567
Recompile LESS from previous three commits.
benlk Sep 12, 2018
e4da8d7
Add support for Gutenberg's use of <figure> and add support for align…
benlk Sep 13, 2018
c3e56a5
Complete .classic .alignfull styles; WIP .classic .alignwide styles: …
benlk Sep 18, 2018
60e7d66
note on what align-wide does
benlk Sep 18, 2018
b121912
Merge branch '0.5-dev' into gutenberg-css
benlk Nov 7, 2018
cfa64e4
Typofix in tests for gutenberg
benlk Nov 7, 2018
6ce7507
Split Gutenberg test functions off into separate test class in tests/…
benlk Nov 7, 2018
12f7660
Switch from using function 'the_gutenberg_project' to 'register_block…
benlk Nov 7, 2018
6cfd7f3
Download and activate Gutenberg in some cases.
benlk Nov 7, 2018
3bd24e9
Fix the path for gutenberg download
benlk Nov 7, 2018
694fa6b
Better bootstrapping of gutenberg
benlk Nov 7, 2018
cf014c2
Remove pre-5.0 Gutenberg tests, for now
benlk Nov 7, 2018
e9607e2
Remove unneeded foo from partials/nav-main.php
benlk Nov 7, 2018
8347b8c
Merge branch '0.5-dev' into gutenberg-css
benlk Nov 7, 2018
8ea5b6b
Improvements to Gutenberg display of ul, blockquote, buttons
benlk Nov 7, 2018
b802dd3
Better button support, alignwide on full template, blockquote alignment
benlk Nov 8, 2018
18f66fd
Fix undefined offset error in largo_top_term
benlk Nov 8, 2018
a8e8da2
Fix array-to-string conversion error in get_template_part
benlk Nov 8, 2018
68aa4f6
Update homepages/homepage.php to use the 'Homepage Top Story' term, n…
benlk Nov 8, 2018
d2dc11d
Fix countability error in options framework
benlk Nov 8, 2018
055166f
Fix undefined ID problems on series edit page, from custom term meta …
benlk Nov 8, 2018
0ba77d3
But Brain, what if a post has no attachment?
benlk Nov 8, 2018
ff3f26a
Undefined indexes in custom taxonomy landing edit form
benlk Nov 8, 2018
deefc30
An undefined variable in the byline class, for https://github.com/INN…
benlk Nov 8, 2018
1909242
Undefined instance['qty'] on largo-related-posts widget
benlk Nov 8, 2018
5cf3d79
reorg changelog, add note for gutenberg
benlk Nov 8, 2018
9cda2f0
has-drop-cap support
benlk Nov 8, 2018
6ecf7eb
Remove list items on gallery block if gutenberg is deactivated
benlk Nov 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,39 @@ language: php
# - WP_VERSION=4.7
# - WP_VERSION=4.6
# - WP_VERSION=4.5
#
# The GUTENBERG env var should be set in WordPress versions where we want to run Gutenberg tests, but Gutenberg has not yet been included in WordPress Core. For 5.0, there is no need to set the GUTENBERG variable.
#

# For a breakdown of why these versions were chosen, see https://github.com/INN/WP-DS-NPR-API/issues/12#issuecomment-374730094
# This list should be rechecked periodically.
matrix:
include:
# PHPunit 5
- php: 5.6
env: WP_VERSION=4.6 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.6
- php: 5.6
env: WP_VERSION=4.7 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.7
- php: 5.6
env: WP_VERSION=4.8 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.8
- php: 5.6
env: WP_VERSION=4.9 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.9
# - php: 5.6
# env: WP_VERSION=4.9 GUTENBERG=1
# PHPUnit 6
- php: 7.0
env: WP_VERSION=4.8 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.8
- php: 7.0
env: WP_VERSION=4.9 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.9
# - php: 7.0
# env: WP_VERSION=4.9 GUTENBERG=1
# PHPUnit 6
- php: 7.1
env: WP_VERSION=4.9 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=4.9
# - php: 7.1
# env: WP_VERSION=4.9 GUTENBERG=1
- php: 7.1
env: WP_VERSION=5.0 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
env: WP_VERSION=5.0
# PHPUnit 7 support will come with https://core.trac.wordpress.org/ticket/43218
# - php: 7.2
# env: WP_VERSION=4.9 WP_TESTS_DIR=/tmp/wordpress/tests/phpunit WP_CORE_DIR=/tmp/wordpress
Expand All @@ -67,6 +76,7 @@ before_script:
- export WP_TESTS_DIR=/tmp/wordpress/tests/phpunit
- export WP_CORE_DIR=/tmp/wordpress/
- git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_CORE_DIR
- if [ GUTENBERG ]; then git clone --depth=1 --branch="v4.2.0" https://github.com/WordPress/gutenberg.git $WP_CORE_DIR'src/wp-content/plugins/gutenberg'; fi
- cd ..
- mv $SLUG "$WP_CORE_DIR/src/wp-content/themes/$SLUG"
- cd $WP_CORE_DIR
Expand Down
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function(grunt) {
var path = process.cwd().replace(/^[\s\S]+\/wp-content/, "\/wp-content");

var cssLessFiles = {
'css/gutenberg.css': 'less/gutenberg.less',
'css/style.css': 'less/style.less',
'css/editor-style.css': 'less/editor-style.less',
'homepages/assets/css/single.css': 'homepages/assets/less/single.less',
Expand Down
11 changes: 10 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ though this project doesn't succeed in adhering to [Semantic Versioning](https:/

## [Unreleased](https://github.com/INN/largo/compare/0.5...0.5-dev)

- Adds Gutenberg support, with
- editor styles
- support for the `.alignwide` and `.alignfull` CSS classes and their use in blocks
- pullquote styles
- Removes the INN Member RSS widget, because the RSS feed it draws from is no longer supported or maintained by INN. Because the RSS feed was occasionally empty, the widget would result in 500 errors. [RP #1535](https://github.com/INN/largo/pulls/1535) for [issue #1511](https://github.com/INN/largo/issues/1511) and [#893](https://github.com/INN/largo/issues/893).
- Removes the default inclusion of Google Analytics with INN's Largo Project IDs. [PR #1502](https://github.com/INN/largo/pull/1502) as part of [issue #1495](https://github.com/INN/largo/issues/1495), and by request.
- Fixes numerous undefined variable errors.

### Removed
- Removes the default inclusion of Google Analytics with INN's Largo Project IDs. [PR #1502](https://github.com/INN/largo/pull/1502) as part of [issue #1495](https://github.com/INN/largo/issues/1495), and by request.

### Upgrade notices
- If your child theme has significant custom styling, or has custom post templates, your theme may need to provide additional styles to ensure Gutenberg compatibility.

## [Largo 0.5.5.4](https://github.com/INN/largo/releases/tag/v0.5.5.4)

This is a maintenance release containing bug fixes for v0.5.5.
Expand Down
121 changes: 29 additions & 92 deletions css/editor-style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/editor-style.min.css

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions css/gutenberg.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions css/gutenberg.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 118 additions & 4 deletions css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/style.min.css

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,10 @@ function largo_php_warning() {
* functions.php file.
*/
function largo_setup() {
$suffix = ( LARGO_DEBUG ) ? '' : '.min';

// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style('/css/editor-style.css');
add_editor_style('/css/editor-style' . $suffix . '.css');

// Add default posts and comments RSS feed links to <head>.
add_theme_support( 'automatic-feed-links' );
Expand All @@ -423,6 +424,12 @@ function largo_setup() {
//Add support for <title> tags
add_theme_support( 'title-tag' );

// Gutenberg alignment classes
add_theme_support( 'align-wide' );

// Gutenberg support for editor styles; @link https://github.com/WordPress/gutenberg/pull/9008
add_theme_support( 'editor-styles' );
add_editor_style('/css/gutenberg' . $suffix . '.css');
}
}
add_action( 'after_setup_theme', 'largo_setup' );
Expand Down
6 changes: 3 additions & 3 deletions homepages/homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ function largo_home_single_top() {

// Cache the terms
$homepage_feature_term = get_term_by( 'name', __('Homepage Featured', 'largo'), 'prominence' );
$top_story_term = get_term_by( 'name', __('Top Story', 'largo'), 'prominence' );
$top_story_term = get_term_by( 'name', __('Homepage Top Story', 'largo'), 'prominence' );

// Get the posts that are both in 'Homepage Featured' and 'Top Story'
// Get the posts that are both in 'Homepage Featured' and 'Homepage Top Story'
$top_story_posts = get_posts(array(
'tax_query' => array(
'relation' => 'AND',
Expand All @@ -114,7 +114,7 @@ function largo_home_single_top() {
return $top_story_posts[0];
}

// Fallback: get the posts that are in "Homepage Featured" but not "Top Story"
// Fallback: get the posts that are in "Homepage Featured" but not "Homepage Top Story"
$homepage_featured_posts = get_posts(array(
'tax_query' => array(
array(
Expand Down
6 changes: 3 additions & 3 deletions inc/byline_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public function __toString() {
* This supports both Largo_Byline and Largo_CoAuthors_Byline
*/
function avatar() {

// only do avatars if it's a single post
if ( ! is_single() ) {
$output = '';
$output = ' ';
} else {
$output = '';
$author_email = get_the_author_meta( 'email', $this->author_id );
if ( $this->author->type == 'guest-author' && get_the_post_thumbnail( $this->author->ID ) ) {
if ( isset( $this->author ) && $this->author->type == 'guest-author' && get_the_post_thumbnail( $this->author->ID ) ) {
$output = get_the_post_thumbnail( $this->author->ID, array( 60,60 ) );
$output = str_replace( 'attachment-32x32', 'avatar avatar-32 photo', $output );
$output = str_replace( 'wp-post-image', '', $output );
Expand Down
53 changes: 52 additions & 1 deletion inc/enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function largo_enqueue_js() {
/*
* Use minified assets if LARGO_DEBUG is false.
*/
$suffix = (LARGO_DEBUG)? '' : '.min';
$suffix = ( LARGO_DEBUG ) ? '' : '.min';
$version = largo_version();

// Our primary stylesheet. Often overridden by custom-less-variables version.
Expand Down Expand Up @@ -261,3 +261,54 @@ function largo_google_analytics() {
}
}
add_action( 'wp_head', 'largo_google_analytics' );


/**
* Enqueue Largo's Gutenberg-supporting stylesheets and scripts, for the frontend
*
* @since 0.6
*/
function largo_gutenberg_frontend_css_js() {
$suffix = ( LARGO_DEBUG ) ? '' : '.min';
$version = largo_version();

if (
function_exists( 'register_block_type' )
// @todo add a conditional that checks that we're on a Gutenberg post
) {
// Gutenberg support stylesheet
wp_enqueue_style(
'largo-stylesheet-gutenberg',
get_template_directory_uri() . '/css/gutenberg' . $suffix . '.css',
array(),
$version
);
}
}
add_action( 'wp_enqueue_scripts', 'largo_gutenberg_frontend_css_js' );

/**
* Enqueue Largo's Gutenberg-supporting stylesheets and scripts, for the admin editor
*
* @since 0.6
* @see https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/#enqueuing-block-scripts
*/
function largo_gutenberg_editor_css_js() {
$suffix = ( LARGO_DEBUG ) ? '' : '.min';
$version = largo_version();
if (
function_exists( 'register_block_type' )
// @todo add a conditional that checks that we're on a Gutenberg post
) {
// Gutenberg support stylesheet
wp_enqueue_style(
'largo-stylesheet-gutenberg',
get_template_directory_uri() . '/css/gutenberg' . $suffix . '.css',
array(),
$version
);
}
// wp_register_script()
// see what we do in pym shortcode
}
add_action( 'enqueue_block_editor_assets', 'largo_gutenberg_editor_css_js' );
2 changes: 1 addition & 1 deletion inc/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function largo_content_nav( $nav_id, $in_same_cat = false ) {
<?php } elseif ( $wp_query->max_num_pages > 1 ) {
$posts_term = of_get_option('posts_term_plural');

largo_render_template('partials/load-more-posts', array(
largo_render_template('partials/load-more-posts', null, array(
'nav_id' => $nav_id,
'the_query' => $wp_query,
'posts_term' => ($posts_term)? $posts_term : 'Posts'
Expand Down
4 changes: 3 additions & 1 deletion inc/related-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ function largo_top_term( $options = array() ) {
*/
if ( empty( $output ) ) {
$output = largo_categories_and_tags( 1, false, $args['link'], $args['use_icon'], '', $args['wrapper'], $args['exclude']);
$output = ( is_array( $output ) ) ? $output[0] : '';
if ( is_array( $output ) && ! empty( $output[0] ) ) {
$output = ( is_array( $output ) ) ? $output[0] : '';
}
}

/*
Expand Down
26 changes: 18 additions & 8 deletions inc/sidebars.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ function largo_register_sidebars() {
function largo_custom_sidebars_dropdown( $selected='', $skip_default=false, $post_id=NULL ) {
global $wp_registered_sidebars, $post;

$the_id = ( $post_id ) ? $post_id:$post->ID;
$custom = ( $selected ) ? $selected:get_post_meta( $the_id, 'custom_sidebar', true );
if ( ! empty( $post_id ) || ! empty( $post ) ) {
$the_id = ( $post_id ) ? $post_id : $post->ID;
$custom = ( $selected ) ? $selected:get_post_meta( $the_id, 'custom_sidebar', true );
} else {
$custom = null;
}

// for the ultimate in backwards compatibility, if nothing's set or using deprecated 'default'
$default = ( of_get_option( 'single_template' ) == 'classic' ) ? 'sidebar-single' : 'none';
$val = $default;

$admin_page = get_current_screen();

// for new posts
if ( $admin_page->action == 'add' )
$val = 'none';
Expand All @@ -154,7 +160,6 @@ function largo_custom_sidebars_dropdown( $selected='', $skip_default=false, $pos
if ( $custom && $custom !== 'default' )
$val = $custom;

$admin_page = get_current_screen();
$output = '';
if ( $admin_page->base == 'post' ) {

Expand Down Expand Up @@ -222,22 +227,27 @@ function largo_custom_sidebars_dropdown( $selected='', $skip_default=false, $pos
function largo_landing_page_custom_sidebars_dropdown( $left_or_right, $selected, $post_id=null ) {
global $wp_registered_sidebars, $post;

$the_id = ( $post_id )? $post_id : $post->ID;
$custom = ( $selected )? $selected : get_post_meta( $the_id, 'custom_sidebar', true );
if ( ! empty( $post_id ) || ! empty( $post ) ) {
$the_id = ( $post_id )? $post_id : $post->ID;
$custom = ( $selected )? $selected : get_post_meta( $the_id, 'custom_sidebar', true );
} else {
$custom = null;
}

// for the ultimate in backwards compatibility, if nothing's set or using deprecated 'default'
$default = ( of_get_option( 'single_template' ) == 'classic' ) ? 'sidebar-single' : 'none';
$val = $default;

$admin_page = get_current_screen();

// for new posts
if ( $admin_page->action == 'add' )
$val = 'none';

// for posts and taxonomies with values set
if ( $custom && $custom !== 'default' )
if ( isset( $custom ) && $custom !== 'default' )
$val = $custom;

$admin_page = get_current_screen();
$output = '';
if ( isset( $admin_page->post_type ) and $admin_page->post_type == 'cftl-tax-landing' ) {
$default = of_get_option(
Expand All @@ -247,7 +257,7 @@ function largo_landing_page_custom_sidebars_dropdown( $left_or_right, $selected,
$default_label = sprintf( __( 'Default (%s)', 'largo' ), $wp_registered_sidebars[$default]['name']);

$output .= '<option value="' . $default . '" ';
$output .= selected('none', $val, false);
$output .= selected( 'none', $val, false );
$output .= '>' . $default_label . '</option>';
}

Expand Down
2 changes: 1 addition & 1 deletion inc/term-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function largo_add_term_featured_media_button( $context = '' ) {
<p><a href="#" id="set-featured-media-button" class="button set-featured-media add_media" data-editor="content" title="<?php echo $language; ?> Featured Media"><span class="dashicons dashicons-admin-generic"></span> <?php echo $language; ?> Featured Media</a> <span class="spinner" style="display: none;"></span></p>
<p class="description">This image will be displayed on the top of the term's archive page.</p>
<input type="hidden" id="post_ID" value="<?php echo $post_id ?>" />
<input type="hidden" id="featured_image_id" value="<?php echo $featured['attachment'] ;?>" />
<input type="hidden" id="featured_image_id" value="<?php echo ( ! empty( $featured['attachment'] ) ) ? esc_attr( $featured['attachment'] ) : '' ; ;?>" />

<?php # echo get_the_post_thumbnail($post_id); ?>
</td>
Expand Down
Loading