Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins: Try blocks for single plugin page #460

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "wporg/plugin-section",
"version": "0.1.0",
"title": "Plugin Section",
"category": "design",
"icon": "",
"description": "Display a section of a plugin.",
"textdomain": "wporg",
"attributes": {
"section": {
"type": "string",
"default": "description"
}
},
"supports": {
"html": false
},
"usesContext": [
"postId"
],
"editorScript": "file:./index.js",
"render": "file:./render.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-server-side-render'), 'version' => '61e703d9bae16dfbd20d');

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

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require_once( __DIR__ . '/src/blocks/search-page/index.php' );
require_once( __DIR__ . '/src/blocks/single-plugin/index.php' );
require_once( __DIR__ . '/src/blocks/plugin-card/index.php' );
require_once( __DIR__ . '/src/blocks/plugin-section/index.php' );

// Block Configs
require_once( __DIR__ . '/inc/block-bindings.php' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace WordPressdotorg\Plugin_Directory\Theme\Block_Bindings;

use WordPressdotorg\Plugin_Directory\Template;

// Actions and filters.
add_action( 'init', __NAMESPACE__ . '\register_block_bindings' );

Expand Down Expand Up @@ -39,6 +41,35 @@ function get_meta_block_value( $args, $block ) {
}

switch ( $args['key'] ) {
case 'plugin-banner-url':
$raw_banners = Template::get_plugin_banner( $post, 'raw_with_rtl' );
if ( is_rtl() ) {
if ( ! empty( $raw_banners['banner_2x_rtl'] ) ) {
return $raw_banners['banner_2x_rtl'];
}
if ( ! empty( $raw_banners['banner_rtl'] ) ) {
return $raw_banners['banner_rtl'];
}
}
if ( ! empty( $raw_banners['banner_2x'] ) ) {
return $raw_banners['banner_2x'];
}
if ( ! empty( $raw_banners['banner'] ) ) {
return $raw_banners['banner'];
}
return '';
case 'plugin-icon-url':
$raw_icons = Template::get_plugin_icon( $plugin_post, 'raw' );
if ( ! empty( $raw_icons['svg'] ) ) {
return $raw_icons['svg'];
}
if ( ! empty( $raw_icons['icon_2x'] ) ) {
return $raw_icons['icon_2x'];
}
if ( ! empty( $raw_icons['icon'] ) ) {
return $raw_icons['icon'];
}
return '';
case 'ratings-link':
return sprintf(
'<a href="%s">%s</a>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
// This pattern can be expanded as more widgets are converted to blocks and/or block bindings.
?>

<!-- wp:legacy-widget {"idBase":"plugin_categorization","instance":{}} /-->

<!-- wp:legacy-widget {"idBase":"plugin_adopt_me","instance":{}} /-->

<!-- wp:legacy-widget {"idBase":"plugin_meta","instance":{}} /-->

<!-- wp:group -->
<div class="wp-block-group">
<!-- wp:heading {"className":"widget-title"} -->
Expand All @@ -31,3 +37,9 @@
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:legacy-widget {"idBase":"plugin_contributors","instance":{}} /-->

<!-- wp:legacy-widget {"idBase":"plugin_support","instance":{}} /-->

<!-- wp:legacy-widget {"idBase":"plugin_donate","instance":{}} /-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Title: Plugin
* Slug: wporg-plugins-2024/single-plugin-closed
* Inserter: no
*/

use WordPressdotorg\Plugin_Directory\Plugin_Directory;

?>

<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide">
<!-- wp:image {"align":"wide","metadata":{"bindings":{"url":{"source":"wporg-plugins/meta","args":{"key":"plugin-banner-url"}}}}} -->
<figure class="wp-block-image alignwide"><img alt=""/></figure>
<!-- /wp:image -->

<!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group">
<!-- wp:image {"width":"96px","height":"96px","scale":"cover","metadata":{"bindings":{"url":{"source":"wporg-plugins/meta","args":{"key":"plugin-icon-url"}}}}} -->
<figure class="wp-block-image is-resized"><img alt="" style="object-fit:cover;width:96px;height:96px"/></figure>
<!-- /wp:image -->

<!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"layout":{"type":"flex","orientation":"vertical"}} -->
<div class="wp-block-group">
<!-- wp:post-title {"level":1,"style":{"typography":{"fontStyle":"normal","fontWeight":"400"}},"fontSize":"heading-3","fontFamily":"inter"} /-->

<!-- wp:post-author-name {"isLink":true} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:group {"align":"wide","layout":{"type":"default"}} -->
<div class="wp-block-group alignwide">
<!-- wp:paragraph -->
<p>[TABS]</p>
<!-- /wp:paragraph -->

<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%">
<!-- wp:wporg/notice {"type":"warning"} -->
<div class="wp-block-wporg-notice is-warning-notice"><div class="wp-block-wporg-notice__icon"></div><div class="wp-block-wporg-notice__content"><p>This plugin has been closed as of December 12, 2024 and is not available for download. This closure is permanent. Reason: Author Request.</p></div></div>
<!-- /wp:wporg/notice -->
</div>
<!-- /wp:column -->

<!-- wp:column {"width":"33.33%"} -->
<div class="wp-block-column" style="flex-basis:33.33%">
<!-- wp:pattern {"slug":"wporg-plugins-2024/sidebar-closed"} /-->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* Title: Plugin
* Slug: wporg-plugins-2024/single-plugin
* Inserter: no
*/

use WordPressdotorg\Plugin_Directory\Plugin_Directory;

?>

<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide">
<!-- wp:image {"align":"wide","metadata":{"bindings":{"url":{"source":"wporg-plugins/meta","args":{"key":"plugin-banner-url"}}}}} -->
<figure class="wp-block-image alignwide"><img alt=""/></figure>
<!-- /wp:image -->

<!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group">
<!-- wp:image {"width":"96px","height":"96px","scale":"cover","metadata":{"bindings":{"url":{"source":"wporg-plugins/meta","args":{"key":"plugin-icon-url"}}}}} -->
<figure class="wp-block-image is-resized"><img alt="" style="object-fit:cover;width:96px;height:96px"/></figure>
<!-- /wp:image -->

<!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"layout":{"type":"flex","orientation":"vertical"}} -->
<div class="wp-block-group">
<!-- wp:post-title {"level":1,"style":{"typography":{"fontStyle":"normal","fontWeight":"400"}},"fontSize":"heading-3","fontFamily":"inter"} /-->

<!-- wp:post-author-name {"isLink":true} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:buttons {"style":{"spacing":{"blockGap":"var:preset|spacing|10"}}} -->
<div class="wp-block-buttons">
<!-- wp:wporg/favorite-button /-->

<!-- wp:button {"className":"is-small"} -->
<div class="wp-block-button is-small"><a class="wp-block-button__link wp-element-button" href="#">Download</a></div>
<!-- /wp:button -->

<!-- wp:button {"className":"is-style-outline is-small"} -->
<div class="wp-block-button is-style-outline is-small"><a class="wp-block-button__link wp-element-button" href="#">Live preview</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:group {"align":"wide","layout":{"type":"default"}} -->
<div class="wp-block-group alignwide">
<!-- wp:paragraph -->
<p>[TABS]</p>
<!-- /wp:paragraph -->

<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%">
<!-- wp:wporg/plugin-section {"section":"description"} /-->

<!-- wp:wporg/plugin-section {"section":"screenshots"} /-->

<!-- wp:wporg/plugin-section {"section":"blocks"} /-->

<!-- wp:wporg/plugin-section {"section":"installation"} /-->

<!-- wp:wporg/plugin-section {"section":"faq"} /-->

<!-- wp:wporg/plugin-section {"section":"reviews"} /-->

<!-- wp:wporg/plugin-section {"section":"developers"} /-->

<!-- wp:wporg/plugin-section {"section":"changelog"} /-->
</div>
<!-- /wp:column -->

<!-- wp:column {"width":"33.33%"} -->
<div class="wp-block-column" style="flex-basis:33.33%">
<!-- wp:pattern {"slug":"wporg-plugins-2024/sidebar"} /-->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "wporg/plugin-section",
"version": "0.1.0",
"title": "Plugin Section",
"category": "design",
"icon": "",
"description": "Display a section of a plugin.",
"textdomain": "wporg",
"attributes": {
"section": {
"type": "string",
"default": "description"
}
},
"supports": {
"html": false
},
"usesContext": [ "postId" ],
"editorScript": "file:./index.js",
"render": "file:./render.php"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* WordPress dependencies
*/
import { Disabled } from '@wordpress/components';
import { registerBlockType } from '@wordpress/blocks';
import ServerSideRender from '@wordpress/server-side-render';
import { useBlockProps } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import metadata from './block.json';

function Edit( { attributes, name } ) {
return (
<div { ...useBlockProps() }>
<Disabled>
<ServerSideRender block={ name } attributes={ attributes } />
</Disabled>
</div>
);
}

registerBlockType( metadata.name, {
edit: Edit,
save: () => null,
} );
Loading