Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@7eefe58 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 9, 2024
1 parent bc0dd64 commit f437180
Show file tree
Hide file tree
Showing 55 changed files with 19,130 additions and 136 deletions.
41 changes: 28 additions & 13 deletions blocks/.template/plugin-templates/$slug.php.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@ namespace PRC\Platform\Blocks;
*/

class {{slugSnakeCase}} {
public static $block_library_version;
public static $active_theme;
public static $block_json;
public static $block_json = null;
public static $version;
public static $block_name;
{{^isCoreBlockVariant}}
public static $dir = __DIR__;

public function __construct( $block_library_version, $active_theme ) {
self::$block_library_version = $block_library_version ? $block_library_version : null;
self::$active_theme = $active_theme ? $active_theme : null;
public function __construct($loader) {
$block_json_file = PRC_BLOCK_LIBRARY_DIR . '/blocks/{{slug}}/build/block.json';
self::$block_json = wp_json_file_decode( $block_json_file, array( 'associative' => true ) );
self::$block_json = \wp_json_file_decode( $block_json_file, array( 'associative' => true ) );
self::$block_json['file'] = wp_normalize_path( realpath( $block_json_file ) );
self::$version = self::$block_json['version'];
self::$block_name = self::$block_json['name'];
$this->init($loader);
}

public function init($loader = null) {
if ( null !== $loader ) {
$loader->add_action('init', $this, 'block_init');
}
}

{{#isDynamicVariant}}
/**
* Render the block
Expand Down Expand Up @@ -78,17 +83,27 @@ class {{slugSnakeCase}} {
/**
* @TODO Search and replace {coreBlockChangeMyName} for your block name, e.g. "core/group".
*/
public static $block_name = {coreBlockChangeMyName};
public static $view_style_handle = null;
public static $editor_script_handle = null;

public function __construct( $block_library_version, $active_theme ) {
self::$block_library_version = $block_library_version ? $block_library_version : null;
self::$active_theme = $active_theme ? $active_theme : null;
public function __construct($loader) {
$block_json_file = PRC_BLOCK_LIBRARY_DIR . '/blocks/{{slug}}/build/block.json';
self::$block_json = wp_json_file_decode( $block_json_file, array( 'associative' => true ) );
self::$block_json = \wp_json_file_decode( $block_json_file, array( 'associative' => true ) );
self::$block_json['file'] = wp_normalize_path( realpath( $block_json_file ) );
self::$version = self::$block_json['version'];
self::$block_name = self::$block_json['name'];
$this->init($loader);
}

public function init($loader = null) {
if ( null !== $loader ) {
$loader->add_action('init', $this, 'init');
$loader->add_action('enqueue_block_editor_assets', $this, 'register_editor_assets');
$loader->add_action('enqueue_block_assets', $this, 'register_style_assets');
$loader->add_filter('block_type_metadata', $this, 'add_attributes');
$loader->add_filter('block_type_metadata_settings', $this, 'add_settings', 10, 2);
$loader->add_filter('render_block', $this, 'render', 10, 2);
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions blocks/core-social-links/core-social-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ public function add_attributes( $metadata ) {
);
}

if ( ! array_key_exists( 'imageId', $metadata['attributes'] ) ) {
$metadata['attributes']['imageId'] = array(
'type' => 'number',
);
}

if ( ! array_key_exists( 'hashtags', $metadata['attributes'] ) ) {
$metadata['attributes']['hashtags'] = array(
'type' => 'array',
'items' => array(
'type' => 'string',
),
);
}

return $metadata;
}

Expand All @@ -115,6 +130,8 @@ public function add_settings(array $settings, array $metadata) {
'core/social-links/title' => 'title',
'core/social-links/description' => 'description',
'core/social-links/url' => 'url',
'core/social-links/imageId' => 'imageId',
'core/social-links/hashtags' => 'hashtags',
)
);
}
Expand Down
47 changes: 47 additions & 0 deletions blocks/interactive-island-trigger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Interactive Island Trigger
Contributors: Seth Rubenstein
Tags: block
Tested up to: 6.4
Stable tag: 0.1.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Trigger an island's active status by click or by in viewport.

## Description

This is the long description. No limit, and you can use Markdown (as well as in the following sections).

For backwards compatibility, if this section is missing, the full length of the short description will be used, and
Markdown parsed.

## Instructions

This section describes how to use the block.

## Frequently Asked Questions

= A question that someone might have =

An answer to that question.

### What about foo bar?

Answer to foo bar dilemma.

## Screenshots

1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif).
2. This is the second screen shot
3. You can store screenshots in a .docs folder in this block directory...

## Changelog

= 0.1.0 =
* Release

## Developer Notes

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
blocks where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "prc-block/social-native-share",
"name": "prc-block/interactive-island-trigger",
"version": "0.1.0",
"title": "Social Native Share",
"category": "widgets",
"description": "A share button to invoke the native share sheet in a visitors browser. When a browser does not support navigator.share this will fallback to a row of core/social-links.",
"title": "Interactive Island Trigger",
"category": "theme",
"description": "Trigger an island's active status by click or by in viewport.",
"attributes": {
"allowedBlocks": {
"type": "array"
Expand Down Expand Up @@ -38,7 +38,7 @@
}
}
},
"textdomain": "social-native-share",
"textdomain": "interactive-island-trigger",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '5aa34ad7dfdcf6f7d977');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'd0c43635b099b048360a');
1 change: 1 addition & 0 deletions blocks/interactive-island-trigger/build/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wp-block-prc-block-interactive-island-trigger.wp-block{background:inherit;color:inherit}
2 changes: 2 additions & 0 deletions blocks/interactive-island-trigger/build/index.js

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

1 change: 1 addition & 0 deletions blocks/interactive-island-trigger/build/index.js.map

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions blocks/interactive-island-trigger/build/style-index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wp-block-prc-block-interactive-island-trigger{background:inherit;color:inherit}
48 changes: 48 additions & 0 deletions blocks/interactive-island-trigger/interactive-island-trigger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
namespace PRC\Platform\Blocks;

/**
* Block Name: Interactive Island Trigger
* Description: Trigger an island&#39;s active status by click or by in viewport.
* Requires at least: 6.4
* Requires PHP: 8.1
* Author: Seth Rubenstein
*
* @package prc-block
*/

class interactive_island_trigger {
public static $block_json = null;
public static $version;
public static $block_name;
public static $dir = __DIR__;

public function __construct($loader) {
$block_json_file = PRC_BLOCK_LIBRARY_DIR . '/blocks/interactive-island-trigger/build/block.json';
self::$block_json = \wp_json_file_decode( $block_json_file, array( 'associative' => true ) );
self::$block_json['file'] = wp_normalize_path( realpath( $block_json_file ) );
self::$version = self::$block_json['version'];
self::$block_name = self::$block_json['name'];
$this->init($loader);
}

public function init($loader = null) {
if ( null !== $loader ) {
$loader->add_action('init', $this, 'block_init');
}
}


/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
* @hook init
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
public function block_init() {
register_block_type( self::$dir . '/build' );
}

}
Loading

0 comments on commit f437180

Please sign in to comment.