Customising HTML Output

You may want to customise the default html output provided by the shortcodes / blocks in Matador Job’s Recruiter Profiles extension. Below you will find details about the filters that enable you to do this:

There are two filters to enable you to customise the HTML output: the more general ‘matador_extension_recruiters_$meta_key__html’ and the link-specific ‘matador_extension_recruiters_link_html’.

matador_extension_recruiters_$meta_key_html’

/**
* Filter to modify the HTML output for a specific recruiter meta key.
*
* Allows dynamic alteration of the recruiter's HTML markup based on the meta key.
*
* @since 1.0.0
*
* @param string    $default_html Default HTML markup
* @param string    $meta_value The meta value related to the meta key.
* @param string    $meta_key The current meta key.
* @param int          $recruiter_id Recruiter ID for context.
* @return string     Filtered HTML markup.
*/
$markup = apply_filters( 'matador_extension_rectruiters_' . $meta_key . '_html', '<a href="%s">%s</a>', $meta_value, $meta_key, $recruiter_id );
return apply_filters( 'matador_extension_recruiters_' . $meta_key . '_html', sprintf( $markup, $meta_value ), $meta_value, $meta_key, $recruiter_id );

Use this filter to modify the html output for a given meta key. An example of this might be implementing the html output for a custom field where the default <p> tags are not appropriate.

add_filter( 'matador_extension_rectruiters_my_custom_field_html', 'my_custom_field_html', 10, 4 );

function my_custom_field_html( $default_html, $meta_value, $meta_key, $recruiter_id ) {
    
        return "<div class='custom-class'>" . esc_html( $meta_value ) . "</div>";
    
}
/**
* Filter to modify the overall HTML output of the recruiter link.
*
* Allows for the modification of the recruiter link's HTML markup. 
*
* @since 1.0.0
*
* @param string    $markup The current HTML markup of the link.
* @param string    $link_url The URL of the link.
* @param string    $link_text The text of the link.
* @param string    $meta_key The meta key associated with the link.
* @param int       $recruiter_id Recruiter ID for context.
* @return string   Filtered link HTML markup.
*/
$markup = apply_filters('matador_extension_rectruiters_link_html', $markup, $link_url, $link_text, $meta_key, $recruiter_id );
return sprintf( $markup, esc_url( $link_url ), esc_html( $link_text ) );

Use this filter to modify the html markup for default fields which are links:

  • Mobile Phone
  • Office Phone
  • Email
  • Single Link
  • LinkedIn Profile
  • Facebook Profile
  • Call Link

For example, outputting span rather than anchor tags for recruiters’ email addresses:

add_filter( 'matador_extension_recruiters_link_html', 'format_recruiter_email_as_span', 10, 5 );

function format_recruiter_email_as_span( $markup, $link_url, $link_text, $meta_key, $recruiter_id ) {
    if ( 'recruiter_email' === $meta_key ) {
       
        $email_markup = '<span class="recruiter-email">%2$s</span>'; // %2$s corresponds to $link_text in sprintf
        return $email_markup;
    }

    return $markup;
}
Updated on January 10, 2024
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support