Skip to content

Commit

Permalink
Rename into Template Part
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons committed Apr 26, 2019
1 parent 5401f2c commit 5073d86
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const setSelectedPost = async ( attributes, setState ) => {
} );
};

const ContentRendererEdit = withState( {
const TemplatePartEdit = withState( {
isEditing: false,
selectedPost: null,
} )( ( { attributes, isEditing, selectedPost, setAttributes, setState } ) => {
Expand Down Expand Up @@ -62,25 +62,25 @@ const ContentRendererEdit = withState( {
className={ classNames( 'components-icon-button components-toolbar__control', {
'is-active': isEditing,
} ) }
label={ __( 'Change Content' ) }
label={ __( 'Change Template Part' ) }
onClick={ toggleEditing }
icon="edit"
/>
</Toolbar>
</BlockControls>
) }
<div
className={ classNames( 'a8c-content-renderer-block', {
className={ classNames( 'a8c-template-part-block', {
[ `align${ align }` ]: align,
} ) }
>
{ showPlaceholder && (
<Placeholder
icon="layout"
label={ __( 'Content Renderer' ) }
instructions={ __( 'Select something to render' ) }
label={ __( 'Template Part' ) }
instructions={ __( 'Select a template part to display' ) }
>
<div className="a8c-content-renderer-block__selector">
<div className="a8c-template-part-block__selector">
<PostAutocomplete
selectedPostTitle={ get( selectedPost, 'title.rendered' ) }
onSelectPost={ onSelectPost }
Expand All @@ -92,7 +92,7 @@ const ContentRendererEdit = withState( {
</Placeholder>
) }
{ showContent && (
<RawHTML className="a8c-content-renderer-block__content">
<RawHTML className="a8c-template-part-block__content">
{ get( selectedPost, 'content.rendered' ) }
</RawHTML>
) }
Expand All @@ -101,4 +101,4 @@ const ContentRendererEdit = withState( {
);
} );

export default ContentRendererEdit;
export default TemplatePartEdit;
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { __ } from '@wordpress/i18n';
import edit from './edit';
import './style.scss';

registerBlockType( 'a8c/content-renderer', {
title: __( 'Content Renderer' ),
description: __( 'Renders the content of a post or a page.' ),
registerBlockType( 'a8c/template-part', {
title: __( 'Template Part' ),
description: __( 'Display a template part.' ),
icon: 'layout',
category: 'layout',
attributes: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

function render_content_renderer_block( $attributes ) {
function render_template_part_block( $attributes ) {
if ( ! isset( $attributes['selectedPostId'] ) || ! is_int( $attributes['selectedPostId'] ) ) {
return;
}
$align = isset( $attributes['align'] ) ? ' align' . $attributes['align'] : '';
$post = get_post( $attributes['selectedPostId'] );
setup_postdata( $post );

$content = '<div class="a8c-content-renderer'. $align . '">'
$content = '<div class="a8c-template-part'. $align . '">'
. apply_filters( 'the_content', get_the_content() )
. '</div>';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.a8c-content-renderer-block.alignfull {
.a8c-template-part-block.alignfull {
padding: 0 12px;
}

.a8c-content-renderer-block__selector {
.a8c-template-part-block__selector {
width: 300px;
a {
font-family: sans-serif;
Expand All @@ -11,7 +11,7 @@
}
}

.a8c-content-renderer-block__content {
.a8c-template-part-block__content {
pointer-events: none;
&::after {
content: '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

require_once( 'blocks/content-slot/index.php' );
require_once( 'blocks/content-renderer/index.php' );
require_once( 'blocks/template-part/index.php' );

class A8C_Full_Site_Editing {
static $initialized = false;
Expand Down Expand Up @@ -50,8 +50,8 @@ function register_blocks() {
'render_callback' => 'render_content_slot_block',
) );

register_block_type( 'a8c/content-renderer', array(
'render_callback' => 'render_content_renderer_block',
register_block_type( 'a8c/template-part', array(
'render_callback' => 'render_template_part_block',
) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/full-site-editing/full-site-editing-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* Internal dependencies
*/
import './blocks/content-slot';
import './blocks/content-renderer';
import './blocks/template-part';

0 comments on commit 5073d86

Please sign in to comment.