Skip to content

Commit

Permalink
remove open in new tab, back out link to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed May 5, 2021
1 parent 2b13132 commit 4c9ae36
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 62 deletions.
1 change: 0 additions & 1 deletion packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@import "./more/editor.scss";
@import "./navigation/editor.scss";
@import "./navigation-link/editor.scss";
@import "./home-link/editor.scss";
@import "./nextpage/editor.scss";
@import "./page-list/editor.scss";
@import "./paragraph/editor.scss";
Expand Down
5 changes: 1 addition & 4 deletions packages/block-library/src/home-link/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
"category": "design",
"parent": [ "core/navigation" ],
"title": "Home Link",
"description": "Create a link that always points to the homepage of the site. Usually not necessary if there is already a site title link present in the header.",
"textdomain": "default",
"attributes": {
"label": {
"type": "string"
},
"opensInNewTab": {
"type": "boolean",
"default": false
}
},
"usesContext": [
Expand Down
25 changes: 3 additions & 22 deletions packages/block-library/src/home-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import {
RichText,
useBlockProps,
InspectorControls,
} from '@wordpress/block-editor';
import { __, _x } from '@wordpress/i18n';
import { RichText, useBlockProps } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { useEffect } from '@wordpress/element';
import { ToggleControl } from '@wordpress/components';

const preventDefault = ( event ) => event.preventDefault();

Expand Down Expand Up @@ -51,7 +46,7 @@ export default function HomeEdit( {
},
} );

const { label, opensInNewTab } = attributes;
const { label } = attributes;

useEffect( () => {
if ( label === undefined ) {
Expand All @@ -61,20 +56,6 @@ export default function HomeEdit( {

return (
<>
<InspectorControls>
<div className="wp-block-home-link__settings">
<h2 className="wp-block-home-link__settings_label">
{ _x( 'Settings', 'Home link settings' ) }
</h2>
<ToggleControl
label={ __( 'Open in new tab' ) }
checked={ opensInNewTab }
onChange={ () => {
setAttributes( { opensInNewTab: ! opensInNewTab } );
} }
/>
</div>
</InspectorControls>
<li { ...blockProps }>
<a
className="wp-block-home-link__content"
Expand Down
9 changes: 0 additions & 9 deletions packages/block-library/src/home-link/editor.scss

This file was deleted.

8 changes: 0 additions & 8 deletions packages/block-library/src/home-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { _x } from '@wordpress/i18n';
import { home } from '@wordpress/icons';
import { createInterpolateElement } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -19,13 +18,6 @@ export { metadata, name };
export const settings = {
icon: home,

description: createInterpolateElement(
_x( 'Link to <a>your homepage</a>.', 'block description' ),
//TODO: slot/fill to override link
// eslint-disable-next-line jsx-a11y/anchor-has-content
{ a: <a href="options-reading.php" /> }
),

edit,

save,
Expand Down
12 changes: 0 additions & 12 deletions packages/block-library/src/home-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@ function render_block_core_home( $attributes, $content, $block ) {
// Start appending HTML attributes to anchor tag.
$html .= ' href="' . esc_url( home_url() ) . '"';

if ( isset( $attributes['opensInNewTab'] ) && true === $attributes['opensInNewTab'] ) {
$html .= ' target="_blank" ';
}

if ( isset( $attributes['rel'] ) ) {
$html .= ' rel="' . esc_attr( $attributes['rel'] ) . '"';
}

if ( isset( $attributes['title'] ) ) {
$html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
}

// End appending HTML attributes to anchor tag.
$html .= '>';

Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/fixtures/blocks/core__home-link.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:home-link {"label":"Home","opensInNewTab":false} /-->
<!-- wp:home-link {"label":"Home"} /-->
3 changes: 1 addition & 2 deletions packages/e2e-tests/fixtures/blocks/core__home-link.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"name": "core/home-link",
"isValid": true,
"attributes": {
"label": "Home",
"opensInNewTab": false
"label": "Home"
},
"innerBlocks": [],
"originalContent": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
{
"blockName": "core/home-link",
"attrs": {
"label": "Home",
"opensInNewTab": false
"label": "Home"
},
"innerBlocks": [],
"innerHTML": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:home-link {"label":"Home","opensInNewTab":false} /-->
<!-- wp:home-link {"label":"Home"} /-->

0 comments on commit 4c9ae36

Please sign in to comment.