Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwhte committed Apr 27, 2023
2 parents 775502b + 3d5eacf commit bc28872
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/dist/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-blocks', 'wp-element'), 'version' => 'd021e6349edf2e477821');
<?php return array('dependencies' => array('wp-blocks', 'wp-element'), 'version' => 'd63fc65fe960951d026b');
2 changes: 1 addition & 1 deletion assets/dist/index.css

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

2 changes: 1 addition & 1 deletion assets/dist/index.js

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

4 changes: 3 additions & 1 deletion assets/src/html-snippet/editor/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ $component-class-name: ".wp-block-wsuwp-html-snippet";
gap: 1ch;
}

&__preview-toggle {
&__controls,
&__control {
display: flex;
gap: 0.5em;
}

Expand Down
23 changes: 22 additions & 1 deletion assets/src/html-snippet/editor/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ const Edit = (props) => {
}
}

function getEditLink(post) {
if (!post) return;

const params = new URLSearchParams(location.search);
params.set("post", post.id);

return location.origin + location.pathname + "?" + params.toString();
}

if (isLoading && !data) {
return <p>loading...</p>;
}
Expand All @@ -57,6 +66,8 @@ const Edit = (props) => {
(o) => o.id.toString() === attributes.snippet_id
);

const editLink = getEditLink(selectedOption);

return (
<>
<div className={className}>
Expand All @@ -68,8 +79,18 @@ const Edit = (props) => {
HTML Snippet
</div>
<div className={`${className}__controls`}>
{editLink && (
<Button
className={`${className}__control is-tertiary`}
icon="edit"
href={editLink}
target="_blank"
>
Edit Snippet
</Button>
)}
<Button
className={`${className}__preview-toggle is-tertiary`}
className={`${className}__control is-tertiary`}
icon={attributes.show_preview ? "hidden" : "visibility"}
onClick={() => {
reset();
Expand Down
10 changes: 10 additions & 0 deletions includes/html-snippet-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public static function register_block()
)
);

add_filter(
'wsu_allowed_blocks_filter', function ( $blocks ) {
if (!in_array(self::$block_name, $blocks, true)) {
array_push($blocks, self::$block_name);
}

return $blocks;
}
);

}


Expand Down
2 changes: 1 addition & 1 deletion wsuwp-html-snippets.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: WSU HTML Snippets
Version: 1.1.0
Version: 1.2.0
Description: Embed common HTML content throughout a WordPress site.
Author: washingtonstateuniversity, jeremyfelt
Author URI: https://web.wsu.edu/
Expand Down

0 comments on commit bc28872

Please sign in to comment.