diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/block.json b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/block.json new file mode 100644 index 0000000000..9f02210e15 --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/block.json @@ -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" +} \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.asset.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.asset.php new file mode 100644 index 0000000000..77e0e30e97 --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.asset.php @@ -0,0 +1 @@ + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-server-side-render'), 'version' => '61e703d9bae16dfbd20d'); diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.js b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.js new file mode 100644 index 0000000000..c8c3b24e93 --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/build/blocks/plugin-section/index.js @@ -0,0 +1 @@ +(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,r=window.wp.components,n=window.wp.blocks,o=window.wp.serverSideRender;var a=e.n(o);const i=window.wp.blockEditor,l=JSON.parse('{"u2":"wporg/plugin-section"}');(0,n.registerBlockType)(l.u2,{edit:function({attributes:e,name:n}){return(0,t.createElement)("div",{...(0,i.useBlockProps)()},(0,t.createElement)(r.Disabled,null,(0,t.createElement)(a(),{block:n,attributes:e})))},save:()=>null})})(); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php index 04720253b3..4aef3b4087 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php @@ -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' ); diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/block-bindings.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/block-bindings.php index abce24ab0d..ff1f79de78 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/block-bindings.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/block-bindings.php @@ -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' ); @@ -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( '%s', diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/sidebar.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/sidebar.php index d7be6e19ef..3fb9d7a234 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/sidebar.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/sidebar.php @@ -8,6 +8,12 @@ // This pattern can be expanded as more widgets are converted to blocks and/or block bindings. ?> + + + + + +
@@ -31,3 +37,9 @@
+ + + + + + diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin-closed.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin-closed.php new file mode 100644 index 0000000000..8cf2aaca9a --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin-closed.php @@ -0,0 +1,64 @@ + + + +
+ +
+ + + +
+ +
+ +
+ + + +
+ + + +
+ +
+ +
+ +
+ + + +
+ +

[TABS]

+ + + +
+ +
+ +

This plugin has been closed as of December 12, 2024 and is not available for download. This closure is permanent. Reason: Author Request.

+ +
+ + + +
+ +
+ +
+ +
+ diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin.php new file mode 100644 index 0000000000..65400a597c --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/patterns/single-plugin.php @@ -0,0 +1,90 @@ + + + +
+ +
+ + + +
+ +
+ +
+ + + +
+ + + +
+ +
+ + + +
+ + + + + + + + + +
+ +
+ +
+ + + +
+ +

[TABS]

+ + + +
+ +
+ + + + + + + + + + + + + + + +
+ + + +
+ +
+ +
+ +
+ diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/block.json b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/block.json new file mode 100644 index 0000000000..27074f4531 --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/block.json @@ -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" +} diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.js b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.js new file mode 100644 index 0000000000..9e4580b21f --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.js @@ -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 ( +
+ + + +
+ ); +} + +registerBlockType( metadata.name, { + edit: Edit, + save: () => null, +} ); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.php new file mode 100644 index 0000000000..e28915bc28 --- /dev/null +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/plugin-section/index.php @@ -0,0 +1,159 @@ + __NAMESPACE__ . '\render', + ) + ); +} + +/** + * Render the block content. + * + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. + * + * @return string Returns the block markup. + */ +function render( $attributes, $content, $block ) { + $_post_id = $block->context['postId']; + $slug = $attributes['section']; + if ( ! $_post_id ) { + return; + } + + $titles = Template::get_plugin_section_titles(); + $section_title = $titles[ $slug ] ?? ''; + + $content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content( null, null, $_post_id ) ); + + if ( 'blocks' === $slug ) { + $section_content = render_section_blocks( $_post_id ); + } else if ( in_array( $slug, [ 'screenshots', 'reviews', 'developers' ] ) ) { + // Do the shortcode manually so that we know if it's empty. + $section_content = do_shortcode( $content[ $slug ] ); + } else { + $section_content = $content[ $slug ]; + } + + if ( empty( $section_content ) ) { + return ''; + } + + $wrapper_attributes = get_block_wrapper_attributes( [ 'class' => "is-section-$slug" ] ); + return sprintf( + '
%3$s %4$s
', + $wrapper_attributes, + esc_attr( $slug ), + '

' . $section_title . '

', + trim( apply_filters( 'the_content', $section_content, $slug ) ) + ); +} + +/** + * Render the blocks for the section. + */ +function render_section_blocks( $_post_id ) { + $blocks = get_post_meta( $_post_id, 'all_blocks', true ); + if ( ! $blocks ) { + return ''; + } + + ob_start(); + + $allowed_svg = array( + 'svg' => array( + 'class' => true, + 'aria-hidden' => true, + 'aria-labelledby' => true, + 'role' => true, + 'xmlns' => true, + 'width' => true, + 'height' => true, + 'viewbox' => true, + ), + 'g' => array( 'fill' => true ), + 'title' => array( 'title' => true ), + 'path' => array( + 'd' => true, + 'fill' => true, + 'transform' => true, + ), + ); + ?> + +
- + +