WPSEO_Import_AIOSEO_V4::replace_custom_field_or_taxonomy_replace_vars
Replaces every AIOSEO custom field/taxonomy/etc. replace var with the Yoast version.
E.g. #custom_field-xyz becomes %%cf_xyz%%.
Метод класса: WPSEO_Import_AIOSEO_V4{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields_or_taxonomies, $wpdb, $aioseo_prefix, $yoast_prefix );
- $unique_custom_fields_or_taxonomies(string[]) (обязательный)
- An array of unique custom fields to replace the replace vars of.
- $wpdb(wpdb) (обязательный)
- The WordPress database object.
- $aioseo_prefix(строка) (обязательный)
- The AiOSEO prefix to use (e.g.
custom-fieldfor custom fields ortax_namefor custom taxonomies). - $yoast_prefix(строка) (обязательный)
- The Yoast prefix to use (e.g.
cffor custom fields).
Код WPSEO_Import_AIOSEO_V4::replace_custom_field_or_taxonomy_replace_vars() WPSEO Import AIOSEO V4::replace custom field or taxonomy replace vars Yoast 27.8
protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields_or_taxonomies, $wpdb, $aioseo_prefix, $yoast_prefix ) {
foreach ( $unique_custom_fields_or_taxonomies as $unique_custom_field_or_taxonomy ) {
$aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
$yoast_variable = "%%{$yoast_prefix}_{$unique_custom_field_or_taxonomy}%%";
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
$aioseo_variable,
$yoast_variable,
),
);
}
}