Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@409dc7e from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Mar 21, 2024
1 parent 8e50889 commit fdd9ff2
Show file tree
Hide file tree
Showing 22 changed files with 19,157 additions and 0 deletions.
File renamed without changes.
47 changes: 47 additions & 0 deletions blocks/footnotes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Footnotes
Contributors: Pew Research Center
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

A unique take on footnotes. Supports numoffset.

## 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.
46 changes: 46 additions & 0 deletions blocks/footnotes/build/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "prc-block/footnotes",
"version": "0.1.0",
"title": "Footnotes",
"category": "theme",
"description": "A unique take on footnotes. Supports numoffset.",
"attributes": {
"allowedBlocks": {
"type": "array"
},
"orientation": {
"type": "string",
"default": "vertical"
}
},
"supports": {
"anchor": true,
"html": false,
"spacing": {
"blockGap": true,
"margin": [
"top",
"bottom"
],
"padding": true,
"__experimentalDefaultControls": {
"padding": true
}
},
"typography": {
"fontSize": true,
"__experimentalFontFamily": true,
"__experimentalDefaultControls": {
"fontSize": true,
"__experimentalFontFamily": true
}
}
},
"textdomain": "footnotes",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"render": "file:./render.php"
}
1 change: 1 addition & 0 deletions blocks/footnotes/build/index.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '6f529b24430b20cc96d2');
1 change: 1 addition & 0 deletions blocks/footnotes/build/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wp-block-prc-block-footnotes.wp-block{background:inherit;color:inherit}
2 changes: 2 additions & 0 deletions blocks/footnotes/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/footnotes/build/index.js.map

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions blocks/footnotes/build/render.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace PRC\Platform\Blocks;
// PHP file to use when rendering the block type on the server to show on the front end.
// The following variables are exposed to this file:

// $attributes (array): The block attributes.
// $content (string): The block default content.
// $block (WP_Block): The block instance.

$block_wrapper_attrs = get_block_wrapper_attributes();

echo wp_sprintf(
'<div %1$s>%2$s</div>',
$block_wrapper_attrs,
$content,
);
1 change: 1 addition & 0 deletions blocks/footnotes/build/style-index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wp-block-prc-block-footnotes{background:inherit;color:inherit}
20 changes: 20 additions & 0 deletions blocks/footnotes/footnotes-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace PRC\Platform\Blocks;

class Footnotes_API {
public $post_id = null;
public $footnotes = [];

public function __construct($post_id) {
$this->post_id = $post_id;
$this->footnotes = $this->get_footnotes();
}

public function get_footnotes() {
// loop through the content and extract out the shortcode based text...
}

public function process_content() {
// return the content with the shortcodes converted to markup
}
}
47 changes: 47 additions & 0 deletions blocks/footnotes/footnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace PRC\Platform\Blocks;

/**
* Block Name: Footnotes
* Description: A unique take on footnotes. Supports numoffset.
* Requires at least: 6.4
* Requires PHP: 8.1
* Author: Pew Research Center
*
* @package prc-block
*/

class Footnotes {
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/footnotes/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 fdd9ff2

Please sign in to comment.