Git Product home page Git Product logo

block-development-examples's Introduction

<!DOCTYPE html>
<html lang="en">
<head>
	<meta name="viewport" content="width=device-width" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>WordPress &#8250; ReadMe</title>
	<link rel="stylesheet" href="wp-admin/css/install.css?ver=20100228" type="text/css" />
</head>
<body>
<h1 id="logo">
	<a href="https://wordpress.org/"><img alt="WordPress" src="wp-admin/images/wordpress-logo.png" /></a>
</h1>
<p style="text-align: center">Semantic Personal Publishing Platform</p>

<h2>First Things First</h2>
<p>Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I am proud to be a part of. Thousands of hours have gone into WordPress, and we are dedicated to making it better every day. Thank you for making it part of your world.</p>
<p style="text-align: right">&#8212; Matt Mullenweg</p>

<h2>Installation: Famous 5-minute install</h2>
<ol>
	<li>Unzip the package in an empty directory and upload everything.</li>
	<li>Open <span class="file"><a href="wp-admin/install.php">wp-admin/install.php</a></span> in your browser. It will take you through the process to set up a <code>wp-config.php</code> file with your database connection details.
		<ol>
			<li>If for some reason this does not work, do not worry. It may not work on all web hosts. Open up <code>wp-config-sample.php</code> with a text editor like WordPad or similar and fill in your database connection details.</li>
			<li>Save the file as <code>wp-config.php</code> and upload it.</li>
			<li>Open <span class="file"><a href="wp-admin/install.php">wp-admin/install.php</a></span> in your browser.</li>
		</ol>
	</li>
	<li>Once the configuration file is set up, the installer will set up the tables needed for your site. If there is an error, double check your <code>wp-config.php</code> file, and try again. If it fails again, please go to the <a href="https://wordpress.org/support/forums/">WordPress support forums</a> with as much data as you can gather.</li>
	<li><strong>If you did not enter a password, note the password given to you.</strong> If you did not provide a username, it will be <code>admin</code>.</li>
	<li>The installer should then send you to the <a href="wp-login.php">login page</a>. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on &#8220;Profile&#8221; to change the password.</li>
</ol>

<h2>Updating</h2>
<h3>Using the Automatic Updater</h3>
<ol>
	<li>Open <span class="file"><a href="wp-admin/update-core.php">wp-admin/update-core.php</a></span> in your browser and follow the instructions.</li>
	<li>You wanted more, perhaps? That&#8217;s it!</li>
</ol>

<h3>Updating Manually</h3>
<ol>
	<li>Before you update anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</li>
	<li>Delete your old WordPress files, saving ones you&#8217;ve modified.</li>
	<li>Upload the new files.</li>
	<li>Point your browser to <span class="file"><a href="wp-admin/upgrade.php">/wp-admin/upgrade.php</a>.</span></li>
</ol>

<h2>Migrating from other systems</h2>
<p>WordPress can <a href="https://developer.wordpress.org/advanced-administration/wordpress/import/">import from a number of systems</a>. First you need to get WordPress installed and working as described above, before using <a href="wp-admin/import.php">our import tools</a>.</p>

<h2>System Requirements</h2>
<ul>
	<li><a href="https://www.php.net/">PHP</a> version <strong>7.2.24</strong> or greater.</li>
	<li><a href="https://www.mysql.com/">MySQL</a> version <strong>5.5.5</strong> or greater.</li>
</ul>

<h3>Recommendations</h3>
<ul>
	<li><a href="https://www.php.net/">PHP</a> version <strong>7.4</strong> or greater.</li>
	<li><a href="https://www.mysql.com/">MySQL</a> version <strong>8.0</strong> or greater OR <a href="https://mariadb.org/">MariaDB</a> version <strong>10.5</strong> or greater.</li>
	<li>The <a href="https://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a> Apache module.</li>
	<li><a href="https://wordpress.org/news/2016/12/moving-toward-ssl/">HTTPS</a> support.</li>
	<li>A link to <a href="https://wordpress.org/">wordpress.org</a> on your site.</li>
</ul>

<h2>Online Resources</h2>
<p>If you have any questions that are not addressed in this document, please take advantage of WordPress&#8217; numerous online resources:</p>
<dl>
	<dt><a href="https://wordpress.org/documentation/">HelpHub</a></dt>
		<dd>HelpHub is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.</dd>
	<dt><a href="https://wordpress.org/news/">The WordPress Blog</a></dt>
		<dd>This is where you&#8217;ll find the latest updates and news related to WordPress. Recent WordPress news appears in your administrative dashboard by default.</dd>
	<dt><a href="https://planet.wordpress.org/">WordPress Planet</a></dt>
		<dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.</dd>
	<dt><a href="https://wordpress.org/support/forums/">WordPress Support Forums</a></dt>
		<dd>If you&#8217;ve looked everywhere and still cannot find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.</dd>
	<dt><a href="https://make.wordpress.org/support/handbook/appendix/other-support-locations/introduction-to-irc/">WordPress <abbr>IRC</abbr> (Internet Relay Chat) Channel</a></dt>
		<dd>There is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (<a href="https://web.libera.chat/#wordpress">irc.libera.chat #wordpress</a>)</dd>
</dl>

<h2>Final Notes</h2>
<ul>
	<li>If you have any suggestions, ideas, or comments, or if you (gasp!) found a bug, join us in the <a href="https://wordpress.org/support/forums/">Support Forums</a>.</li>
	<li>WordPress has a robust plugin <abbr>API</abbr> (Application Programming Interface) that makes extending the code easy. If you are a developer interested in utilizing this, see the <a href="https://developer.wordpress.org/plugins/">Plugin Developer Handbook</a>. You shouldn&#8217;t modify any of the core code.</li>
</ul>

<h2>Share the Love</h2>
<p>WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better&#8212;you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgeable than yourself, or writing the author of a media article that overlooks us.</p>

<p>WordPress is the official continuation of <a href="https://cafelog.com/">b2/caf&#233;log</a>, which came from Michel V. The work has been continued by the <a href="https://wordpress.org/about/">WordPress developers</a>. If you would like to support WordPress, please consider <a href="https://wordpress.org/donate/">donating</a>.</p>

<h2>License</h2>
<p>WordPress is free software, and is released under the terms of the <abbr>GPL</abbr> (GNU General Public License) version 2 or (at your option) any later version. See <a href="license.txt">license.txt</a>.</p>

</body>
</html>

block-development-examples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

block-development-examples's Issues

Create "how-to-guides-block-tutorial-XXXXXX"

This should a multi-block plugin containing all the JSX gutenberg-examples referenced in the tutorial:

I would just migrate the JSX examples and would skip for now the NON-JSX examples

  • 01-basic-esnext#31
  • 02-stylesheets → there's no JSX example for this part but I think we should recreate 02-stylesheets in JSX version
  • 03-editable-esnext#33
  • 04-controls-esnext#34
  • 05-recipe-card-esnext#35
  • 06-inner-blocks-esnext#36
  • 08-block-supports-esnext#38
  • 10-dynamic-block#40
├── blocks-jsx
│   ├── 01-basic-esnext
│   ├── 03-editable-esnext
│   ├── 04-controls-esnext
│   ├── 05-recipe-card-esnext
│   ├── 06-inner-blocks-esnext
│   ├── 08-block-supports-esnext
│   ├── 10-dynamic-block
│   └── meta-block

composer run lint is failing

composer run lint is returning some errors and provoking the main workflow to fail

I'm removing "*.php": [ "composer run lint"], from lint-staged until this issue is solved

⬢  block-development-examples  trunk ⦾ composer run lint
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/vendor/symfony/console/Command/DumpCompletionCommand.php:48
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/vendor/symfony/console/Command/DumpCompletionCommand.php:56
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:875
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:880
> ./vendor/bin/phpcs --standard=phpcs.xml
sh: ./vendor/bin/phpcs: No such file or directory
Script ./vendor/bin/phpcs --standard=phpcs.xml handling the lint event returned with error code 127

remove package "php-actions_composer_block-development-examples"

There's a package available in the repo that may be confusing for newcomers of this repo

https://github.com/WordPress/block-development-examples/pkgs/container/block-development-examples%2Fphp-actions_composer_block-development-examples

Could we remove it?

Improve onboarding of this repo

  • Better order of columns of the table
    • ID - brief description - tags - zip - live view
  • Get rid of color column
  • Move that table to the very top
  • Why this ID? Explain this in a WIKI page
    • Question mark - link to the WIKI page
  • Include build folder in the repo for didactical purposes
    • Update getting started steps

format-api-f14b86: Document how and where the icon is being imported

I followed along the example of the Format API and but I was dumbfounded because I couldn't figure out how the icon was being imported and needed to import different one.

Action item:
Explicitly mention how the icon is being imported in the tutorial (or if the approach that I did more common, maybe include that )

Other buttons in the format bar were calling it in by importing WordPress' Icons package but that's not called in the format-api-f14b86 example.

I eventually figured out to import an existing WordPress icon by:

  1. installing the Icons package (npm install @wordpress/icons --save),
  2. in my js file, importing the package and then specifically importing the icon that i wanted to use import { commentReplyLink } from "@wordpress/icons"; List of icons is available at the storybook
  3. within my RichTextToolbarButton component, adding the icon as an object like icon={commentReplyLink} unlike the example which in format-api-f14b86 which brings in a text string.

(for anyone else finding this: if you wanted to import your own, you probably could do it through through https://wordpress.github.io/gutenberg/?path=/docs/components-icon--docs

Relatedly, the richtexttoolbarbutton component (which appears to be a wrapper or abstraction?) is could have its documentation improved by although that should go in the gutenberg repository; since all that exists is the example in the rich-text readme and a separate reference in https://github.com/WordPress/gutenberg/tree/1eb76440f7b86ca905ac875d4a2c6ed67fc48daf/packages/block-editor which says it's undocumented.

Add Experimental Tag

It would be great to be able to tag an example as experimental. For example, the Interactivity API

Request: Missing examples

Here are a few situations that examples would be useful for:

  • A plugin containing multiple blocks (showing file structure / build configuration etc.)
  • A custom data store
  • A plugin containing multiple blocks utilizing the custom data store (particularly the build configuration is important here I think so that the data store doesn't get compiled into each block separately)

Add E2E tests for blocks.

We need to add some E2E tests to ensure that blocks are inserted and displayed correctly.

This should be done only for examples that are not tagged as NON-BLOCK

Protect `trunk` from being pushed to directly.

For my work on #38, I thought I was working on a branch and instead pushed to trunk directly. This is bad. Can we protect the branch so we can't update trunk unless it's from a PR? I don't have access to do it myself.

[Tracking Issue] Update plugin Readme files to include more detailed information

What?

We need to update each plugin to explain the learning goal/objective, provide details on the code, and link to any relevant references as needed.

ReadMe Example to follow

Basic Block Translation 3df23d

The goal of this example is to showcase how to use translations in a block.

Folder Short description Tags ID () Download .zip Live Demo
📁 Basic Block with Translations STATIC RENDERING 3df23d 📦

Understanding the Example Code

Both the edit.js and save.js files import the __ function @wordpress/i18n to apply translations to the texts used in the code.

  • The __ function receives the text and a namespace as parameters
  • At index.php we tell WordPress our JavaScript contains translations, using the wp_set_script_translations() function.
  • At languages/ folder there are all the translations files (the source files and the .mo ones actually used to apply the translations)

Related resources


Note
Check the Start Guide for local development with the examples

Running `pnpm -- wp-env start` fails

I cloned the repo and followed the Quick start guide to install and build.

I then ran pnpm -- wp-env start and received the following error:

Success: WordPress installed successfully.
Success: Added the constant 'FS_METHOD' to the 'wp-config.php' file with the value 'direct'.
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'false'.
Success: Added the constant 'SCRIPT_DEBUG' to the 'wp-config.php' file with the raw value 'false'.
Success: Added the constant 'WP_ENVIRONMENT_TYPE' to the 'wp-config.php' file with the value 'local'.
Success: Added the constant 'WP_PHP_BINARY' to the 'wp-config.php' file with the value 'php'.
Success: Added the constant 'WP_TESTS_EMAIL' to the 'wp-config.php' file with the value '[email protected]'.
Success: Added the constant 'WP_TESTS_TITLE' to the 'wp-config.php' file with the value 'Test Blog'.
Success: Added the constant 'WP_TESTS_DOMAIN' to the 'wp-config.php' file with the value 'localhost:8889'.
Success: Added the constant 'WP_SITEURL' to the 'wp-config.php' file with the value 'http://localhost:8889'.
Success: Added the constant 'WP_HOME' to the 'wp-config.php' file with the value 'http://localhost:8889'.
Success: Added the constant 'JETPACK_AUTOLOAD_DEV' to the 'wp-config.php' file with the raw value 'true'.
Success: Added the constant 'WP_DEBUG_LOG' to the 'wp-config.php' file with the raw value 'true'.
Success: Added the constant 'WP_DEBUG_DISPLAY' to the 'wp-config.php' file with the raw value 'true'.
Plugin 'block-dynamic-rendering-64756b' activated.
Success: Activated 1 of 1 plugins.
 Container d07e259cdf8f3f7e35b966a1a019160c-tests-mysql-1  Running
 Container d07e259cdf8f3f7e35b966a1a019160c-tests-wordpress-1  Running
Warning: The 'basic-block-3df23d' plugin could not be found.
Error: No plugins activated.

This is due to the .wp-env.json having a references to folders that don't exist in the plugins entry

Interactivity API - Countdown Block - broken w/out Gutenberg plugin active

Explanation: Requires Gutenberg

Plugin requires header

How to use the header

Todo

  • Find how to require a plugin in the header
Requires Plugins: gutenberg

Background

The Interactivity API won't work without the Gutenberg Plugin active. There's a new header that will throw an error in the dashboard for this (as of 6.5). Trying to get word on this header so it can be documented.

How was it discovered?

The Playground demo worked, so the code wasn't broken.

raw blueprint file

{
        "step": "installPlugin",
        "pluginZipFile": {
          "resource": "wordpress.org/plugins",
          "slug": "gutenberg"
        }

Error track

from console

Uncaught TypeError: Cannot read properties of undefined (reading 'startCountdown')
    at interactivity.min.js?ver=6.5:2:25942
    at Array.forEach (<anonymous>)
    at interactivity.min.js?ver=6.5:2:25927
    at interactivity.min.js?ver=6.5:2:25951
    at interactivity.min.js?ver=6.5:2:29636
    at Object.__ (interactivity.min.js?ver=6.5:2:27702)
    at vt (interactivity.min.js?ver=6.5:2:13563)
    at Array.forEach (<anonymous>)
    at at (interactivity.min.js?ver=6.5:2:12275)

Steps to reproduce

  • Clone the repo
  • Move blocks from /plugins to /wp-content/plugins in your installation
  • Install packages
  • Run build
  • Insert interactive countdown block
  • No countdown

Possible culprits

  • 👋 Gutenberg not installed?
  • 🚫 interactivity API dependencies in package-lock.json?
  • 🚫 viewScript changes?
  • ⁇ No data from datastore?

Tutorial: Build your first block - confusion about instruction

create a folder” – I am not sure I understand the purpose - I did not do this step and the tutorial worked okay.
"Therefore, create a new directory (folder) on your computer called “Block Tutorial”

“line 9” — this is relative, after a few file edits, the code referenced was not on line 9 for me
"So open up the file and add the following section after the example in line 9."

Using one instance of wp-scripts to work with all blocks

Description

In order to take a look at blocks in this repo, there are a couple of steps needed:

  • Clone the repo
  • Move all files from the repo's /plugins folder to wp-content/plugins for your local installation
  • Build the NPM packages for each block (takes running/installing multiple times)

Proposal

Is there a way to save @wordpress/scripts in the wp-content/plugins directory, and build this one time?

Otherwise, if you had a local copy of wp-scripts at a source folder, let's say
~/users/username/dev/wp-scripts

To access all builds from one wp-scripts package?

Caveats

I realize you can do this by bootstrapping multiple plugins, but I'm thinking of never having to re-install the wp-scripts package again... just update it for one copy on your machine.

Also realize there can be some dependency issues here, and also some issues with needing extra packages such as useDebounce ..

Developer Experience

I went through the process of creating a new example by running npm run create-example and for the most part it was a easy and straightforward process.

The only feedback I would give is that the step of choosing the tags was a little confusing for me. This is mostly because I didn't fully read the instructions and pressed enter to select a tag which confirmed my choices 🤦 . I would say that perhaps we need to have the tags in alphabetical order as they seemed random to me during my second try.

This is great tool for copying existing plugins in the repo and this coupled with a create-block template cover all of options for creating new examples.

Basic Block Translation not working

The plugin Basic Block Translation 3df23d (basic-block-translations-3df23d) not translated.

I've extract this plugin folder from downloaded file > add to WordPress plugins folder > activated > changed settings to Espanol language.

Go to Appearance > widgets in WordPress admin dashboard.

Added Example: Basic block.

It's showing Hello World!!. instead of Hola Mundo!!

I'm following this document and try with this plugin but translation seems to be not working at all.

Add standards and linting tools to the repo.

I'd like to make sure we have the correct tools in place in the repo to ensure that all code that is submitted follows the WordPress coding standards. We already have eslint/prettier available from @wordpress/scripts but I propose we add PHP Code Sniffer with WPCS 3.0 as well. We can then leverage Husky to check the code before it's committed and also add an Action to run the linting tools

Broken links in Data Basics example

Simple editor button example (no build)

It'd be nice with an example (no build) that would add a simple button to this "editor toolbar", to more or less mimic the possibilities we had to add a TinyMCE button. I think there are a lot of plugins that do just that, to access short codes, insert macros, or whatever.

If you haven't worked with this level of JS before, I think many "PHP developers" are left out in the cold, so to speak, because of the steep learning curve introduced with block elements.

image

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.