-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba43d4b
commit eeff81f
Showing
12 changed files
with
400 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"apiVersion": 3, | ||
"name": "airblocks/content-image", | ||
"title": "Sisältö ja kuva", | ||
"category": "airdev", | ||
"description": "A Gutenberg block!", | ||
"icon": "block-default", | ||
"editorScript": "file:./editor.js", | ||
"render": "file:./render.php", | ||
"attributes": { | ||
"title": { | ||
"type": "string", | ||
"default": "", | ||
"air_label": "title", | ||
"air_location": "rich-text", | ||
"air_type": "string" | ||
}, | ||
"content": { | ||
"type": "string", | ||
"default": "", | ||
"air_label": "content", | ||
"air_location": "rich-text", | ||
"air_type": "string" | ||
}, | ||
"image": { | ||
"type": "string", | ||
"default": "", | ||
"air_label": "image", | ||
"air_location": "rich-text", | ||
"air_type": "string" | ||
} | ||
}, | ||
"supports": { | ||
"html": false, | ||
"customClassName": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Name: content-image | ||
* Title: Sisältö ja kuva | ||
* Category: airdev | ||
* Description: A Gutenberg block! | ||
* Icon: block-default | ||
* | ||
* @package air-light | ||
*/ | ||
|
||
// Register attributes | ||
register_rich_text( 'title' ); | ||
register_rich_text( 'content' ); | ||
register_rich_text( 'image' ); | ||
// register_attribute( 'attribute_name', 'Attribute Label', 'string', 'Default Value!' ); | ||
// register_rich_text( 'attribute_name', 'Default Value!' ); | ||
|
||
// Get fields | ||
$title = attr( 'title' ); | ||
$content = attr( 'content' ); | ||
$image = attr( 'image' ); | ||
?> | ||
|
||
<section class="block block-content-image"> | ||
<div class="container"> | ||
|
||
<div class="items"> | ||
<div class="item"> | ||
<h2 wp-rich="title"> | ||
<?php echo esc_html( $title ); ?> | ||
</h2> | ||
|
||
<?php echo wp_kses_post( $content ); ?> | ||
</div> | ||
|
||
<div class="item"> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array( 'dependencies' => array( 'react', 'wp-blocks', 'wp-i18n', 'wp-block-editor' ), 'version' => '10312243362054402459' ); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* WP Block Builder "framework" | ||
* @package air-blocks | ||
*/ | ||
|
||
// Workaround to access local variables inside functions | ||
global $get_attribute_local_scope; | ||
$get_attribute_local_scope = function ( $key ) use ( $attributes ) { | ||
if ( ! isset( $attributes[ $key ] ) ) { | ||
return ''; | ||
} | ||
return $attributes[ $key ]; | ||
}; | ||
|
||
if ( ! function_exists( 'register_attribute' ) ) { | ||
function register_attribute( $key, $name, $type = "string", $default_value = "" ) {} | ||
} | ||
|
||
if ( ! function_exists( 'register_rich_text' ) ) { | ||
function register_rich_text( $key, $default_value = "" ) {} | ||
} | ||
|
||
if ( ! function_exists( 'attr' ) ) { | ||
function attr( $key ) { | ||
global $get_attribute_local_scope; | ||
return $get_attribute_local_scope( $key ); | ||
} | ||
} | ||
|
||
// End WP Block Builder "framework" | ||
|
||
ob_start(); | ||
require 'block.php'; | ||
$html = ob_get_clean(); | ||
|
||
$is_editor = defined( 'REST_REQUEST' ) && true === REST_REQUEST && 'edit' === filter_input( INPUT_GET, 'context', FILTER_SANITIZE_STRING ); | ||
|
||
if ( ! $is_editor ) { | ||
// Replace innerblocks | ||
$html = preg_replace( '(<InnerBlocks[^>]*\/{0,1}>)', $content, $html ); | ||
|
||
// Remove attributes | ||
$html = preg_replace( '( wp-[a-z\-]+="[^"]+")', '', $html ); | ||
} | ||
|
||
// We're just parsing content coming from blocks, so no escaping is necessary. | ||
echo $html; // phpcs:ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.block-content-image { | ||
// Your block styles here | ||
} |
Oops, something went wrong.