Concerns
6 months ago
Elements
2 weeks ago
scripts
1 year ago
BricksDuplicateContentService.php
1 day ago
BricksDynamicDataService.php
6 months ago
BricksElementsService.php
9 months ago
BricksServiceProvider.php
1 day ago
BricksTemplateService.php
10 months ago
BricksDuplicateContentService.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\Bricks; |
| 4 | |
| 5 | /** |
| 6 | * Controls Bricks' "duplicate content" feature on SureCart post types. |
| 7 | */ |
| 8 | class BricksDuplicateContentService { |
| 9 | /** |
| 10 | * Bootstrap the service. |
| 11 | * |
| 12 | * @return void |
| 13 | */ |
| 14 | public function bootstrap() { |
| 15 | add_filter( 'bricks/use_duplicate_content', [ $this, 'disableForCheckoutForms' ], 10, 2 ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Hide Bricks' duplicate row action on checkout forms — they are Gutenberg |
| 20 | * content (no Bricks data) and already have a SureCart-aware Duplicate action. |
| 21 | * |
| 22 | * @param bool $use Whether Bricks shows its duplicate action. |
| 23 | * @param integer $post_id Current post id. |
| 24 | * |
| 25 | * @return bool |
| 26 | */ |
| 27 | public function disableForCheckoutForms( $use, $post_id ) { |
| 28 | return \SureCart::forms()->getPostType() === get_post_type( $post_id ) ? false : $use; |
| 29 | } |
| 30 | } |
| 31 |