211
правок
8j0rn (обсуждение | вклад) |
8j0rn (обсуждение | вклад) Нет описания правки |
||
| Строка 74: | Строка 74: | ||
<syntaxhighlight lang="php"><?php | <syntaxhighlight lang="php"><?php | ||
// Изменение функции плагина easy-property-listings (epl_button_floor_plan() отключаем и включаем свою функцию) | // Изменение функции плагина easy-property-listings | ||
// (epl_button_floor_plan() отключаем и включаем | |||
// свою функцию) | |||
function remove_epl_button_floor_plan() { | function remove_epl_button_floor_plan() { | ||
// Отключаем стандартную функцию | // Отключаем стандартную функцию | ||
| Строка 122: | Строка 124: | ||
} | } | ||
add_action('epl_buttons_single_property', '_8j0rn_button_floor_plan'); | add_action('epl_buttons_single_property', '_8j0rn_button_floor_plan'); | ||
</syntaxhighlight> | |||
=== 2.6. Изменение кривой функции плагина easy-property-listings (epl_button_floor_plan() отключаем и включаем свою функцию)=== | |||
<syntaxhighlight lang="php"> | |||
// Изменение кривой функции плагина easy-property-listings | |||
// (epl_button_floor_plan() отключаем и включаем свою функцию) | |||
// Удаляем существующий хук | |||
function remove_epl_manage_listing_column_listing_type_callback() { | |||
remove_action( 'epl_manage_listing_column_listing_type', 'epl_manage_listing_column_listing_type_callback' ); | |||
} | |||
add_action('init', 'remove_epl_manage_listing_column_listing_type_callback'); | |||
// Добавляем новый хук с кастомной функцией | |||
function _8j0rn_epl_manage_listing_column_listing_type_callback() { | |||
global $post; | |||
// Get the post meta. | |||
$listing_type = get_post_meta( $post->ID, 'property_com_listing_type', true ); | |||
// If no duration is found, output a default message. | |||
if ( ! empty( $listing_type ) ) { | |||
switch ($listing_type) { | |||
case 'lease': | |||
echo esc_html__( 'For Lease', 'easy-property-listings' ); | |||
break; | |||
case 'sale': | |||
echo esc_html__( 'For Sale', 'easy-property-listings' ); | |||
break; | |||
case 'both': | |||
echo esc_html__( 'For Sale & Lease', 'easy-property-listings' ); | |||
break; | |||
} | |||
} | |||
} | |||
add_action( 'epl_manage_listing_column_listing_type', '_8j0rn_epl_manage_listing_column_listing_type_callback' ); | |||
</syntaxhighlight> | |||
=== 2.7. Изменяем список категорий в разделе Коммерческие=== | |||
<syntaxhighlight lang="php"> | |||
// Изменяем список категорий в разделе Коммерческие | |||
function _8j0rn_epl_listing_meta_commercial_category($defaults) { | |||
// Удаляем ненужные категории | |||
unset($defaults['Commercial Farming']); | |||
unset($defaults['Land/Development']); | |||
unset($defaults['Other']); | |||
// Изменяем или добавляем новые категории | |||
//$defaults['Commercial Farming'] = __( 'Farming', 'easy-property-listings' ); // Изменяем существующую категорию | |||
$defaults['Public catering'] = __( 'Public catering', 'easy-property-listings' ); // Добавляем новую категорию | |||
// Добавляем в конец Другое | |||
$defaults['Other'] = __( 'Other', 'easy-property-listings' ); // Добавляем новую категорию | |||
return $defaults; | |||
} | |||
add_filter('epl_listing_meta_commercial_category', '_8j0rn_epl_listing_meta_commercial_category'); | |||
</syntaxhighlight> | |||
=== 2.8. Переопределяем список единиц измерения площади=== | |||
<syntaxhighlight lang="php"> | |||
// Переопределяем список единиц измерения площади | |||
function _8j0rn_epl_opts_area_unit_filter($defaults) { | |||
// Удаляем ненужные единицы | |||
unset($defaults['square']); | |||
unset($defaults['acre']); | |||
unset($defaults['sqft']); | |||
// Изменяем или добавляем новые единицы измерения | |||
$defaults['squareMeter'] = __( 'square meter', 'easy-property-listings' ); // Изменяем существующую единицу | |||
$defaults['sotka'] = __( 'Sotka', 'easy-property-listings' ); // Добавляем новую единицу | |||
return $defaults; | |||
} | |||
add_filter('epl_opts_area_unit_filter', '_8j0rn_epl_opts_area_unit_filter'); | |||
</syntaxhighlight> | |||
=== 2.9. Переопределяем периоды оплаты=== | |||
<syntaxhighlight lang="php"> | |||
// Переопределяем периоды оплаты | |||
function _8j0rn_epl_rent_period_opts($options) { | |||
// Удаляем ненужные опции | |||
unset( $options['day'] ); | |||
unset( $options['daily'] ); | |||
unset( $options['week'] ); | |||
unset( $options['weekly'] ); | |||
unset( $options['month'] ); | |||
unset( $options['monthly'] ); | |||
// Добавляем нужные опции | |||
$options['_in_month'] = __( ' in month', 'easy-property-listings' ); | |||
$options['_in_year'] = __( ' in year', 'easy-property-listings' ); | |||
$options['_in_week'] = __( ' in week', 'easy-property-listings' ); | |||
$options['_in_day'] = __( ' in day', 'easy-property-listings' ); | |||
return $options; | |||
} | |||
add_filter( 'epl_opts_rent_period_filter', '_8j0rn_epl_rent_period_opts' ); | |||
</syntaxhighlight> | |||
=== 2.10. Исправляем отсутствие перевода периода оплаты в админке в столбце Аренда=== | |||
<syntaxhighlight lang="php"> | |||
// Исправляем отсутствие перевода периода оплаты в админке в столбце Аренда | |||
function _8j0rn_translate_rent_period( $price_rent_period ) { | |||
// Массив переводов (должен совпадать с тем, что в _8j0rn_epl_rent_period_opts) | |||
$rent_period_translations = array( | |||
'_in_month' => __( ' in month', 'easy-property-listings' ), | |||
'_in_year' => __( ' in year', 'easy-property-listings' ), | |||
'_in_week' => __( ' in week', 'easy-property-listings' ), | |||
'_in_day' => __( ' in day', 'easy-property-listings' ), | |||
); | |||
// Если значение $price_rent_period есть в массиве, возвращаем перевод | |||
if ( isset( $rent_period_translations[$price_rent_period] ) ) { | |||
return $rent_period_translations[$price_rent_period]; | |||
} | |||
// Если значение не найдено, возвращаем оригинальное значение | |||
return $price_rent_period; | |||
} | |||
add_filter( 'epl_price_rent_period', '_8j0rn_translate_rent_period' ); | |||
</syntaxhighlight> | </syntaxhighlight> | ||