Skip to content

Commit

Permalink
IMPROVE: Proper documentation for newly added filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nithinjohn22 committed Oct 31, 2024
2 parents 53b724a + 2676e01 commit 69d360d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
9 changes: 9 additions & 0 deletions blocks/class-awsm-job-guten-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 29 additions & 0 deletions inc/class-awsm-job-openings-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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 );
}

Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 4 additions & 3 deletions inc/template-functions-block.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
/**
* Template specific functions for block
*
*
* @package wp-job-openings
* @version 3.5.0
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -113,7 +115,6 @@ function awsm_block_jobs_paginate_links( $query, $shortcode_atts = array() ) {
}
}


if ( ! function_exists( 'awsm_jobs_block_featured_image' ) ) {
function awsm_jobs_block_featured_image( $echo = true, $size = 'thumbnail', $attr = '', $block_atts = array() ) {
$content = '';
Expand Down Expand Up @@ -155,7 +156,7 @@ function awsm_jobs_block_listing_item_class( $class = array() ) {
/**
* Filters the classes for each job listing item.
*
* @since 2.1.0
* @since 3.5.0
*
* @param array $classes Array of class names.
* @param int $job_id The Job ID.
Expand Down
2 changes: 1 addition & 1 deletion inc/templates/block-files/block-job-openings-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
?>

<div <?php awsm_block_jobs_view_class( '', $attributes ); ?><?php awsm_block_jobs_data_attrs( array(), $attributes ); ?>>
Expand Down

0 comments on commit 69d360d

Please sign in to comment.