-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/MOOSE-139/update-custom-alignments-plugin
- Loading branch information
Showing
29 changed files
with
1,143 additions
and
1,405 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
wp-content/plugins/core/src/Blocks/Bindings/Binding_Base.php
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,40 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Bindings; | ||
|
||
abstract class Binding_Base implements Binding_Interface { | ||
|
||
protected string $slug = ''; | ||
protected string $label = ''; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
protected array $get_value_callback = []; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
protected array $uses_context = []; | ||
|
||
abstract protected function get_args(): array; | ||
|
||
public function __construct() { | ||
foreach ( $this->get_args() as $key => $value ) { | ||
if ( ! property_exists( $this, $key ) || $key === self::SLUG ) { | ||
continue; | ||
} | ||
|
||
$this->{$key} = $value; | ||
} | ||
} | ||
|
||
public function get_properties(): array { | ||
return array_filter( [ | ||
self::LABEL => $this->label, | ||
self::GET_VALUE_CALLBACK => $this->get_value_callback, | ||
self::USES_CONTEXT => $this->uses_context, | ||
] ); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
wp-content/plugins/core/src/Blocks/Bindings/Binding_Interface.php
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,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Bindings; | ||
|
||
interface Binding_Interface { | ||
|
||
public const SLUG = 'slug'; | ||
public const LABEL = 'label'; | ||
public const GET_VALUE_CALLBACK = 'get_value_callback'; | ||
public const USES_CONTEXT = 'uses_context'; | ||
|
||
public function get_slug(): string; | ||
|
||
public function get_properties(): array; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
wp-content/plugins/core/src/Blocks/Bindings/Binding_Registrar.php
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,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Bindings; | ||
|
||
class Binding_Registrar { | ||
|
||
public function register( Binding_Interface $binding ): void { | ||
if ( ! function_exists( 'register_block_bindings_source' ) ) { | ||
return; | ||
} | ||
|
||
register_block_bindings_source( $binding->get_slug(), $binding->get_properties() ); | ||
} | ||
|
||
} |
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,10 @@ | ||
/* ------------------------------------------------------------------------- | ||
* | ||
* Templates: Search | ||
* | ||
* ------------------------------------------------------------------------- */ | ||
|
||
/* ported from query results count block (now using block bindings) */ | ||
.search-no-results .tribe-query-results-count { | ||
display: none; | ||
} |
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,33 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Theme\bindings; | ||
|
||
use Tribe\Plugin\Blocks\Bindings\Binding_Base; | ||
|
||
class Post_Permalink extends Binding_Base { | ||
|
||
/** | ||
* example markup: | ||
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"tribe/post-permalink"}}}} --> | ||
<p>Post Permalink Placeholder</p> | ||
<!-- /wp:paragraph --> | ||
*/ | ||
|
||
public function get_slug(): string { | ||
return 'tribe/post-permalink'; | ||
} | ||
|
||
public function get_args(): array { | ||
return [ | ||
Binding_Base::LABEL => __( 'Post Permalink', 'tribe' ), | ||
Binding_Base::GET_VALUE_CALLBACK => [ $this, 'tribe_get_post_permalink' ], | ||
]; | ||
} | ||
|
||
public function tribe_get_post_permalink(): string { | ||
$post_permalink = get_the_permalink(); | ||
|
||
return esc_html( $post_permalink ); | ||
} | ||
|
||
} |
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,44 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Theme\bindings; | ||
|
||
use Tribe\Plugin\Blocks\Bindings\Binding_Base; | ||
|
||
class Post_Type_Name extends Binding_Base { | ||
|
||
/** | ||
* example markup: | ||
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"tribe/post-type-name"}}}} --> | ||
<p>Post Type Name Placeholder</p> | ||
<!-- /wp:paragraph --> | ||
*/ | ||
|
||
public function get_slug(): string { | ||
return 'tribe/post-type-name'; | ||
} | ||
|
||
public function get_args(): array { | ||
return [ | ||
Binding_Base::LABEL => __( 'Post Type Name', 'tribe' ), | ||
Binding_Base::GET_VALUE_CALLBACK => [ $this, 'tribe_get_post_type_name' ], | ||
]; | ||
} | ||
|
||
public function tribe_get_post_type_name(): string { | ||
// this gets us the post type, but we really want the name | ||
$block_post_type = get_post_type(); | ||
|
||
if ( ! $block_post_type ) { | ||
return ''; | ||
} | ||
|
||
$post_object = get_post_type_object( $block_post_type ); | ||
|
||
if ( ! $post_object ) { | ||
return ''; | ||
} | ||
|
||
return esc_html__( $post_object->labels->singular_name, 'tribe' ); | ||
} | ||
|
||
} |
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,49 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Theme\bindings; | ||
|
||
use Tribe\Plugin\Blocks\Bindings\Binding_Base; | ||
|
||
class Query_Results_Count extends Binding_Base { | ||
|
||
/** | ||
* example markup: | ||
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"tribe/query-results-count"}}}} --> | ||
<p>Query Results Count Placeholder</p> | ||
<!-- /wp:paragraph --> | ||
*/ | ||
|
||
public function get_slug(): string { | ||
return 'tribe/query-results-count'; | ||
} | ||
|
||
public function get_args(): array { | ||
return [ | ||
Binding_Base::LABEL => __( 'Query Results Count', 'tribe' ), | ||
Binding_Base::GET_VALUE_CALLBACK => [ $this, 'tribe_get_query_results_count' ], | ||
]; | ||
} | ||
|
||
public function tribe_get_query_results_count(): string { | ||
global $wp_query; | ||
$is_search = is_search(); | ||
$count = (int) $wp_query->found_posts; | ||
$output = sprintf( _n( '%d result', '%d results', $count, 'tribe' ), number_format_i18n( $count ) ); | ||
|
||
if ( $is_search ) { | ||
$output = sprintf( | ||
_x( | ||
'%s %s for <span class="search-term" style="font-weight:var(--wp--custom--font-weight--bold)">“%s”</span>', | ||
'First value is the number of results, second is word "result" (pluralized if necessary), third is the search term', | ||
'tribe' | ||
), | ||
number_format_i18n( $count ), | ||
_n( 'result', 'results', $count, 'tribe' ), | ||
get_search_query() | ||
); | ||
} | ||
|
||
return wp_kses_post( $output ); | ||
} | ||
|
||
} |
21 changes: 0 additions & 21 deletions
21
wp-content/themes/core/blocks/tribe/post-permalink/block.json
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
wp-content/themes/core/blocks/tribe/post-permalink/edit.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.