diff --git a/composer.json b/composer.json index c682748a..4390c8c8 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,7 @@ ], "require": { "composer/installers": "~1.0", - "wpackagist-plugin/gutenberg": "17.8.1", + "wpackagist-plugin/gutenberg": "*", "wpackagist-plugin/stream": "*", "wpackagist-plugin/wordpress-importer": "*", "wordpress-meta/wporg": "1", diff --git a/composer.lock b/composer.lock index 6a44e72d..9dc79414 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b9e893473fca2901ccf72d2d3c29e7a9", + "content-hash": "74ea5900c960f7fe6903d62deaf576ae", "packages": [ { "name": "adhocore/jwt", @@ -236,15 +236,15 @@ }, { "name": "wpackagist-plugin/gutenberg", - "version": "17.8.1", + "version": "18.2.0", "source": { "type": "svn", "url": "https://plugins.svn.wordpress.org/gutenberg/", - "reference": "tags/17.8.1" + "reference": "tags/18.2.0" }, "dist": { "type": "zip", - "url": "https://downloads.wordpress.org/plugin/gutenberg.17.8.1.zip" + "url": "https://downloads.wordpress.org/plugin/gutenberg.18.2.0.zip" }, "require": { "composer/installers": "^1.0 || ^2.0" @@ -319,12 +319,12 @@ "source": { "type": "git", "url": "https://github.com/WordPress/wporg-mu-plugins.git", - "reference": "2ef6485db0cfeb1411e8e24bf60832bd8147ea6c" + "reference": "1c01971a816aba069a1c9e5d9c200ac2e20c8dc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/wporg-mu-plugins/zipball/2ef6485db0cfeb1411e8e24bf60832bd8147ea6c", - "reference": "2ef6485db0cfeb1411e8e24bf60832bd8147ea6c", + "url": "https://api.github.com/repos/WordPress/wporg-mu-plugins/zipball/1c01971a816aba069a1c9e5d9c200ac2e20c8dc6", + "reference": "1c01971a816aba069a1c9e5d9c200ac2e20c8dc6", "shasum": "" }, "require": { @@ -365,7 +365,7 @@ "source": "https://github.com/WordPress/wporg-mu-plugins/tree/build", "issues": "https://github.com/WordPress/wporg-mu-plugins/issues" }, - "time": "2024-04-09T17:31:18+00:00" + "time": "2024-04-30T16:50:57+00:00" } ], "packages-dev": [ @@ -813,28 +813,28 @@ }, { "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.2", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/293975b465e0e709b571cbf0c957c6c0a7b9a2ac", + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac", "shasum": "" }, "require": { "phpcompatibility/php-compatibility": "^9.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "paragonie/random_compat": "dev-master", "paragonie/sodium_compat": "dev-master" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -864,22 +864,37 @@ ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" }, - "time": "2022-10-25T01:46:02+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:30:46+00:00" }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.4", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", - "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", "shasum": "" }, "require": { @@ -887,10 +902,10 @@ "phpcompatibility/phpcompatibility-paragonie": "^1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -919,9 +934,24 @@ ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2022-10-24T09:00:36+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:37:59+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2370,16 +2400,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", + "version": "3.9.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -2446,7 +2476,7 @@ "type": "open_collective" } ], - "time": "2024-03-31T21:03:09+00:00" + "time": "2024-04-23T20:25:34+00:00" }, { "name": "theseer/tokenizer", diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php index be688642..427492fb 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php @@ -6,6 +6,7 @@ namespace WordPressdotorg\Theme\Pattern_Directory_2024\Block_Config; use WP_Block_Supports; +use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE; use function WordPressdotorg\Theme\Pattern_Directory_2024\get_patterns_count; add_action( 'init', __NAMESPACE__ . '\register_block_bindings' ); @@ -18,7 +19,8 @@ add_filter( 'render_block_core/query-title', __NAMESPACE__ . '\update_archive_title', 10, 3 ); add_filter( 'render_block_core/site-title', __NAMESPACE__ . '\update_site_title', 10, 3 ); add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\update_site_breadcrumbs' ); -add_filter( 'render_block_data', __NAMESPACE__ . '\modify_pattern_include' ); +add_filter( 'page_template_hierarchy', __NAMESPACE__ . '\modify_page_template' ); +add_filter( 'single_template_hierarchy', __NAMESPACE__ . '\modify_single_template' ); /** * Register block bindings. @@ -535,37 +537,30 @@ function update_site_breadcrumbs( $breadcrumbs ) { } /** - * Update header template based on current query. + * Switch to the "anon" templates when logged out for favorites and my patterns. * - * @param array $parsed_block The block being rendered. - * - * @return array The updated block. + * @param string[] $templates A list of template candidates, in descending order of priority. */ -function modify_pattern_include( $parsed_block ) { - if ( 'core/pattern' !== $parsed_block['blockName'] || empty( $parsed_block['attrs']['slug'] ) ) { - return $parsed_block; - } - - if ( - 'wporg-pattern-directory-2024/single-pattern' === $parsed_block['attrs']['slug'] && - get_current_user_id() === get_the_author_meta( 'ID' ) - ) { - $parsed_block['attrs']['slug'] = 'wporg-pattern-directory-2024/single-my-pattern'; - } - - if ( - 'wporg-pattern-directory-2024/grid-mine' === $parsed_block['attrs']['slug'] && - ! get_current_user_id() - ) { - $parsed_block['attrs']['slug'] = 'wporg-pattern-directory-2024/logged-out-patterns'; +function modify_page_template( $templates ) { + if ( ! get_current_user_id() ) { + if ( is_page( 'favorites' ) ) { + array_unshift( $templates, 'page-favorites-anon.html' ); + } else if ( is_page( 'my-patterns' ) ) { + array_unshift( $templates, 'page-my-patterns-anon.html' ); + } } + return $templates; +} - if ( - 'wporg-pattern-directory-2024/grid-favorites' === $parsed_block['attrs']['slug'] && - ! get_current_user_id() - ) { - $parsed_block['attrs']['slug'] = 'wporg-pattern-directory-2024/logged-out-favorites'; +/** + * Switch to the single-mine.html template on patterns owned by the current user. + * + * @param string[] $templates A list of template candidates, in descending order of priority. + */ +function modify_single_template( $templates ) { + $pattern = get_post(); + if ( POST_TYPE === get_post_type() && get_current_user_id() === (int) $pattern->post_author ) { + array_unshift( $templates, 'single-mine.html' ); } - - return $parsed_block; + return $templates; } diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-favorites.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-favorites.php index b56bd32d..7c1aca01 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-favorites.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-favorites.php @@ -12,8 +12,8 @@ $register_url = wp_registration_url(); ?> - -
+ +

diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-patterns.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-patterns.php index 0e4c6597..8b6498e1 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-patterns.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/_logged-out-patterns.php @@ -12,8 +12,8 @@ $register_url = wp_registration_url(); ?> - -
+ +

diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-favorites-anon.html b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-favorites-anon.html new file mode 100644 index 00000000..ee6fdcaa --- /dev/null +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-favorites-anon.html @@ -0,0 +1,16 @@ + + + +
+ + +
+ + + +
+ +
+ + + diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-my-patterns-anon.html b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-my-patterns-anon.html new file mode 100644 index 00000000..726993f4 --- /dev/null +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/page-my-patterns-anon.html @@ -0,0 +1,16 @@ + + + +
+ + +
+ + + +
+ +
+ + + diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/single-mine.html b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/single-mine.html new file mode 100644 index 00000000..1462be34 --- /dev/null +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/templates/single-mine.html @@ -0,0 +1,9 @@ + + + +
+ +
+ + +