根据我所做的测试,占位符字符串选择一个类别…不能用submit_job_form_fields
过滤器,但仍有方法更改该字符串。
更改文本的一种方法是覆盖插件的默认值job-filters.php
使用自己的模板。
复制默认模板,/wp-job-manager/templates/job-filters.php
转到您的主题:/your-theme/job_manager/job-filters.php
编辑主题的副本job-filters.php
通过添加placeholder
两个调用的参数job_manager_dropdown_categories()
:
<?php wp_enqueue_script( \'wp-job-manager-ajax-filters\' ); ?>
<?php do_action( \'job_manager_job_filters_before\', $atts ); ?>
<form class="job_filters">
<?php do_action( \'job_manager_job_filters_start\', $atts ); ?>
<div class="search_jobs">
<?php do_action( \'job_manager_job_filters_search_jobs_start\', $atts ); ?>
<div class="search_keywords">
<label for="search_keywords"><?php _e( \'Keywords\', \'wp-job-manager\' ); ?></label>
<input type="text" name="search_keywords" id="search_keywords" placeholder="<?php esc_attr_e( \'Keywords\', \'wp-job-manager\' ); ?>" value="<?php echo esc_attr( $keywords ); ?>" />
</div>
<div class="search_location">
<label for="search_location"><?php _e( \'Location\', \'wp-job-manager\' ); ?></label>
<input type="text" name="search_location" id="search_location" placeholder="<?php esc_attr_e( \'Location\', \'wp-job-manager\' ); ?>" value="<?php echo esc_attr( $location ); ?>" />
</div>
<?php if ( $categories ) : ?>
<?php foreach ( $categories as $category ) : ?>
<input type="hidden" name="search_categories[]" value="<?php echo sanitize_title( $category ); ?>" />
<?php endforeach; ?>
<?php elseif ( $show_categories && ! is_tax( \'job_listing_category\' ) && get_terms( \'job_listing_category\' ) ) : ?>
<div class="search_categories">
<label for="search_categories"><?php _e( \'Category\', \'wp-job-manager\' ); ?></label>
<?php if ( $show_category_multiselect ) : ?>
<?php job_manager_dropdown_categories( array( \'placeholder\' => __( \'Choose a sector…\', \'your-text-domain\' ), \'taxonomy\' => \'job_listing_category\', \'hierarchical\' => 1, \'name\' => \'search_categories\', \'orderby\' => \'name\', \'selected\' => $selected_category, \'hide_empty\' => false ) ); ?>
<?php else : ?>
<?php job_manager_dropdown_categories( array( \'placeholder\' => __( \'Choose a sector…\', \'your-text-domain\' ), \'taxonomy\' => \'job_listing_category\', \'hierarchical\' => 1, \'show_option_all\' => __( \'Any category\', \'wp-job-manager\' ), \'name\' => \'search_categories\', \'orderby\' => \'name\', \'selected\' => $selected_category, \'multiple\' => false ) ); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php do_action( \'job_manager_job_filters_search_jobs_end\', $atts ); ?>
</div>
<?php do_action( \'job_manager_job_filters_end\', $atts ); ?>
</form>
<?php do_action( \'job_manager_job_filters_after\', $atts ); ?>
<noscript><?php _e( \'Your browser does not support JavaScript, or it is disabled. JavaScript must be enabled in order to view listings.\', \'wp-job-manager\' ); ?></noscript>
另一种改变类别的方法是选择一个类别&hellip文本将使用
gettext
过滤器:
add_filter(\'gettext\', \'wpse243242_change_wp_job_manager_text\', 20, 3 );
function wpse243242_change_wp_job_manager_text( $translated_text, $untranslated_text, $domain ) {
if ( \'wp-job-manager\' !== $domain ) {
return $translated_text;
}
// make the changes to the text
switch( $untranslated_text ) {
// Multi category select
case \'Choose a category…\':
$translated_text = __( \'Choose a sector…\', \'text_domain\' );
break;
// Single category select
case \'Any category\':
$translated_text = __( \'Any sector\', \'text_domain\' );
break;
// add more items
}
return $translated_text;
}