Last active
October 6, 2022 20:44
-
-
Save matadorjobs/d32ab59df9a160b651a895de8aea6452 to your computer and use it in GitHub Desktop.
matador_data_source_description hook usage examples
This file contains hidden or 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
<?php | |
namespace matador_docs; | |
add_filter( 'matador_data_source_description', 'matador_docs\matador_data_source_description_1', 10, 4 ); | |
/** | |
* Matador Data Source Description Hook Usage Example 1 | |
* | |
* Change from "{Site Name} Website" to "Corporate Site". | |
* | |
* @see https://docs.matadorjobs.com/articles/matador_data_source_description/ | |
* | |
* @since 2022-09-19 | |
* | |
* @author Matador US, LP | |
* | |
* @return string | |
*/ | |
function matador_data_source_description_1( string $source, string $context, array $data, array $submission ) : string { | |
// Change from "{Site Name} Website" to | |
$source = 'Corporate Site'; | |
return $source; | |
} |
This file contains hidden or 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
<?php | |
namespace matador_docs; | |
add_filter( 'matador_data_source_description', 'matador_docs\matador_data_source_description_2', 10, 4 ); | |
/** | |
* Matador Data Source Description Hook Usage Example 2 | |
* | |
* Change from "{Site Name} Website" to "Corporate Site" only for Submissions (not Candidates) | |
* | |
* @see https://docs.matadorjobs.com/articles/matador_data_source_description/ | |
* | |
* @since 2022-09-19 | |
* | |
* @author Matador US, LP | |
* | |
* @return string | |
*/ | |
function matador_data_source_description_2( string $source, string $context, array $data, array $submission ) : string { | |
if ( 'submission' === $context ) { | |
$source = 'Corporate Site'; | |
} | |
return $source; | |
} |
This file contains hidden or 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
<?php | |
namespace matador_docs; | |
add_filter( 'matador_data_source_description', 'matador_docs\matador_data_source_description_3', 10, 4 ); | |
/** | |
* Matador Data Source Description Hook Usage Example 3 | |
* | |
* Change the Source to a value from the form submission, ie "How Did You Hear About Us?" | |
* | |
* @see https://docs.matadorjobs.com/articles/matador_data_source_description/ | |
* | |
* @since 2022-09-19 | |
* | |
* @author Matador US, LP | |
* | |
* @return string | |
*/ | |
function matador_data_source_description_2( string $source, string $context, array $data, array $submission ) : string { | |
if ( ! empty( $submission['my_custom_form_field'] ) ) { | |
$source = esc_attr( $submission['my_custom_form_field'] ); | |
} | |
return $source; | |
} |
This file contains hidden or 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
add_filter( 'matador_data_source_description', function( $source, $context, $candidate, $submission ){ | |
// get the campaign data matador has saved | |
$campaign = $submission['campaign']; | |
if( ! empty( $campaign ) ) { | |
// look at the source and then the meduim to work out the new source values | |
switch( strtolower( $campaign['source'] ) ){ | |
case 'xing': | |
switch( strtolower( $campaign['medium'] ) ){ | |
case 'posting': | |
$source= 'XING Posting'; | |
break; | |
case 'jobad': | |
$source= 'XING JobAd'; | |
break; | |
case 'activesourcing': | |
$source= 'XING Active Sourcing'; | |
break; | |
} | |
break; | |
case 'linkedin': | |
switch( strtolower( $campaign['medium'] ) ){ | |
case 'posting': | |
$source= 'LinkedIn Posting'; | |
break; | |
case 'jobad': | |
$source= 'LinkedIn JobAd'; | |
break; | |
case 'activesourcing': | |
$source= 'LinkedIn Active Sourcing'; | |
break; | |
case 'ad': | |
$source= 'LinkedIn Ad'; | |
break; | |
} | |
break; | |
case 'indeed': | |
switch( strtolower( $campaign['medium'] ) ) { | |
case 'posting': | |
$source = 'Indeed Posting'; | |
break; | |
case 'jobad': | |
$source = 'Indeed JobAd'; | |
break; | |
} | |
case 'google_jobs_apply': | |
switch( strtolower( $campaign['medium'] ) ) { | |
case 'google_jobs_apply': | |
$source = 'Google Ad'; | |
break; | |
case 'jobad': | |
$source = 'Google JobAd'; | |
break; | |
} | |
case 'homepage': | |
switch( strtolower( $campaign['medium'] ) ) { | |
case 'posting': | |
$source = 'Homepage Posting'; | |
break; | |
case 'jobad': | |
$source = 'Homepage'; | |
break; | |
} | |
break; | |
} | |
} | |
return $source; | |
}, 30, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment