From 8642c469f0d7313293335d28f69e968fc35b1dcc Mon Sep 17 00:00:00 2001 From: nithinjohn22 Date: Tue, 29 Oct 2024 15:23:41 +0530 Subject: [PATCH 1/2] IMPROVE: Pass attributes in awsm_block_form_outside hook --- inc/templates/block-files/block-job-openings-view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/templates/block-files/block-job-openings-view.php b/inc/templates/block-files/block-job-openings-view.php index 11aafe0e..22c2ac7a 100644 --- a/inc/templates/block-files/block-job-openings-view.php +++ b/inc/templates/block-files/block-job-openings-view.php @@ -27,7 +27,7 @@ * @param array $attributes Attributes array from block. */ do_action( 'awsm_block_filter_form', $attributes ); - do_action( 'awsm_block_form_outside' ); + do_action( 'awsm_block_form_outside' , $attributes); ?>
> From 2676e01fbf536dabf586be9bbd73603292034e86 Mon Sep 17 00:00:00 2001 From: nithinjohn22 Date: Thu, 31 Oct 2024 17:25:07 +0530 Subject: [PATCH 2/2] IMPROVE: Proper documentation added for block custom hooks --- blocks/class-awsm-job-guten-blocks.php | 9 ++++++++ inc/class-awsm-job-openings-block.php | 29 ++++++++++++++++++++++++++ inc/template-functions-block.php | 7 ++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/blocks/class-awsm-job-guten-blocks.php b/blocks/class-awsm-job-guten-blocks.php index a7112d61..cf82b1e3 100644 --- a/blocks/class-awsm-job-guten-blocks.php +++ b/blocks/class-awsm-job-guten-blocks.php @@ -70,6 +70,15 @@ public function block_render_callback( $atts, $content ) { $atts['select_filter_full'] = $atts['select_filter_full']; } + /** + * Filters the block attributes. + * + * Allows modification of block attributes prior to rendering. + * + * @since 3.5.0 + * + * @param array $atts List of supported attributes. + */ $atts = apply_filters( 'awsm_jobs_listings_block_attributes', $atts ); $class_block_init = AWSM_Job_Openings_Block::init(); diff --git a/inc/class-awsm-job-openings-block.php b/inc/class-awsm-job-openings-block.php index 68f65c9f..a416f5df 100644 --- a/inc/class-awsm-job-openings-block.php +++ b/inc/class-awsm-job-openings-block.php @@ -44,6 +44,16 @@ public function awsm_jobs_block_attributes( $blockatts ) { 'select_filter_full' => isset( $blockatts['select_filter_full'] ) ? $blockatts['select_filter_full'] : '', ); + /** + * Filter the attribute set for the Job Listing block. + * + * Allows modification of the attributes set for the job listings block before rendering. + * + * @since 3.5.0 + * + * @param array $block_atts_set List of attributes used for rendering the block. + * @param array $blockatts Original attributes passed to the block. + */ $block_atts_set = apply_filters( 'awsm_jobs_block_attributes_set', $block_atts_set, $blockatts ); $this->unique_listing_id++; @@ -52,6 +62,15 @@ public function awsm_jobs_block_attributes( $blockatts ) { include get_awsm_jobs_template_path( 'block-job-openings-view', 'block-files' ); $block_content = ob_get_clean(); + /** + * Filter the output content for the Job Listing block. + * + * Allows modification of the rendered block content before it is returned. + * + * @since 3.5.0 + * + * @param string $block_content The rendered block content. + */ return apply_filters( 'awsm_jobs_block_output_content', $block_content ); } @@ -298,6 +317,16 @@ public function display_block_filter_form( $block_atts ) { ); } + /** + * Filter the rendered content of the job listings block. + * + * Allows customization of the job listings filter block content, which includes + * + * @since 3.5.0 + * + * @param string $filter_content The generated HTML content for the filter block. + * @param array $available_filters_arr Array of filters available for the block. + */ echo apply_filters( 'awsm_filter_block_content', $filter_content, $available_filters_arr ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } diff --git a/inc/template-functions-block.php b/inc/template-functions-block.php index a0dff89f..946b4d90 100644 --- a/inc/template-functions-block.php +++ b/inc/template-functions-block.php @@ -1,7 +1,9 @@