Giter Site home page Giter Site logo

sb-parent-block's Introduction

SB Parent block

banner

  • Contributors: bobbingwide
  • Tags: block, parent, link
  • Requires at least: 5.4.2
  • Tested up to: 6.4.2
  • Stable tag: 0.5.3
  • Requires PHP: 7.2.0
  • License: GPL-2.0-or-later
  • License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show parent of the current content as a link.

Description

Use the Parent block ( sb/parent-block ) to display a link to the parent of the current content. Works for any hierarchical post type such as pages, where the post type supports page-attributes.

Installation

  1. Upload the plugin files to the /wp-content/plugins/sb-parent-block directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the 'Plugins' screen in WordPress

Frequently Asked Questions

Is this a Single Block plugin?

A. I hope so.

What post types does it support?

Any which are hierarchical. The post type must support 'page-attributes' in order to create a post hieraarchy.

What if there is no parent?

The result will be "No parent". You can change this text using block settings.

Screenshots

  1. Parent block

Upgrade Notice

0.5.3

Update for support for PHP 8.3

0.5.2

Once again delivered as a production build.

0.5.1

Allows user defined value for 'No parent', when the content does not have a parent.

  • Note: The plugin is delivered with the Development build.

0.5.0

Now internationalized?

0.4.0

Use the Parent block (sb/parent-block) from the SB Parent block plugin to replace the Parent block previously delivered by Children block ( oik/parent-block ).

0.3.2

Upgrade for some improved usage notes.

0.3.1

Upgrade for some usage notes.

0.3.0

Use the Parent block in child pages to link back to the parent page.

0.2.0

Now implements the child list using server side rendering and supports the depth parameter

0.1.0

Initial version generated by npm wp-create-block

Changelog

0.5.3

  • Changed: Update build files #5
  • Changed: Update wp-scripts to 26.18.0. Remove out of date webpack.config.js #5
  • Changed: Add PHPUnit tests for PHP 8.3 #5
  • Tested: With WordPress 6.4.2
  • Tested: With PHP 8.1, PHP 8.2 and PHP 8.3
  • Tested: With PHPUnit 9.6

0.5.2

  • Changed: Enable peaceful coexistence with other single block plugins,#3
  • Tested: With WordPress 5.5-RC1

0.5.1

  • Changed: Allow user to set text to display when there's 'No parent'

0.5.0

  • Changed: Add internationalisation and localisation logic

0.4.0

  • Changed: Relevant code copied and cobbled from sb-children-block in preparation for delivery from wordpress.org as a Single Block ( SB ) plugin.
  • Rename block from oik/parent-block to sb/parent-block #1

Build process

Only necessary if you want to build the block yourself.

  • To build the block during development.

npm start or npm run dev

Press Ctrl-C to stop the process.

  • To build the block for runtime.

npm run build

The routine should terminate when the build is complete.

  • To build the main file for translation

npm run makepot

  • To create the block editor language files after translation

npm run makejson

Pre-requisite:

You need to have npm - Node Package Manager - installed.

For some basic instructions see the oik-blocks summary of blocks README

Most people run the npm command from the command line.

sb-parent-block's People

Contributors

bobbingwide avatar

Stargazers

Huub avatar

Watchers

 avatar

sb-parent-block's Issues

Improve styling of theParent block

When displayed by the Twenty Twenty theme the parent block is displayed over to the left.
I believe it needs to be wrapped in a div with its block's class.

Create the Single Block plugin delivering Parent block ( sb/parent-block )

Requirement

A Parent block exactly like the one developed in children-block, which was renamed to sb-children-block, to be delivered as a Single Block plugin from the wordpress.org plugin repository.

Proposed solution

  • Copy/cobble the relevant source code from sb-children-block ( after issue 4's been addressed )
  • Edit to build sb/parent-block from src/parent-block
  • Remove any references to children-block
  • Update package.json to add makepot and makejson
  • Add logic to set script translations for translation of JavaScript strings
  • Add logic to load plugin textdomain for translation of PHP strings
  • Internationalize strings in the source files
  • Localised in UK English ( en_GB ) and bbboing ( bb_BB ) locales
  • Test in bb_BB language / locale

Enable peaceful coexistence with other single block plugins when built with 'npm run build'

A few days ago I discovered a problem with multiple single block plugins built using the wp-scripts package's npm run build command. Basically, if each plugin's block doesn't have a unique name in the generated build file(s), then things can go terribly wrong.

I raised an issue against Gutenberg ( @wordpress/scripts: React.createElement type is invalid when two single block plugins are built using npm run build - issue number 24321 ).

The response was to use my own webpack.config.js file to supply the unique name.
IMO the problem is _a limitation with the wp-scripts packag_e.
But there's a fairly simple workaround.
... Add a webpack.config.js file and rebuild.

For sb-parent-block plugin the file is:

const config = require( '@wordpress/scripts/config/webpack.config' );

/**
 * Provide a unique name for the global scope (which is used to lazy-load chunks),
 * otherwise it throws a JS error when loading blocks compiled with `npm run build`.
 *
 * @see https://webpack.js.org/configuration/output/#outputjsonpfunction
 * @see https://github.com/WordPress/gutenberg/issues/24321
 */
// ------------------------------------------------------
config.output.jsonpFunction = 'sb-parent-block';
// ------------------------------------------------------

module.exports = config;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.