Skip to content

Instantly share code, notes, and snippets.

@muks999
Created April 7, 2019 10:44
Show Gist options
  • Save muks999/1e56e8b8c31a0d06d6e8f67d1b58b4e3 to your computer and use it in GitHub Desktop.
Save muks999/1e56e8b8c31a0d06d6e8f67d1b58b4e3 to your computer and use it in GitHub Desktop.
откл и вкл полезностей WP
/*-----Убираем показ лишней информации----------------------****/
add_filter('login_errors', create_function('$a', "return null;"));
remove_action('wp_head', 'wp_generator');
/**
* Закрытие страниц пагинации от индексирования
*/
/*add_action( 'wpseo_head', 'art_noindex_paged', 0 );
function art_noindex_paged() {
if ( is_paged() ) {
add_filter( 'wpseo_canonical', '__return_false' ); // отключаем канонические ссылки
add_filter( 'wpseo_disable_adjacent_rel_links', '__return_true' );// отключаем теги prev|next
echo '<meta name="robots" content="noindex,nofollow">';
}
}*/
/**
* Вывод значений ключевых слов
*/
add_action( 'wp_head', 'art_add_field_keyword', 1 );
function art_add_field_keyword() {
global $post;
$keyword_single_field = get_post_meta( $post->ID, 'art_meta_keywords', true );
if ( $keyword_single_field ) {
echo '<meta name="keywords" content="' . esc_html( $keyword_single_field ) . '" />';
}
$term_id = get_queried_object();
$keyword_cat_field = get_term_meta( $term_id->term_id, 'art_meta_keywords', true );
if ( $keyword_cat_field ) {
echo '<meta name="keywords" content="' . esc_html( $keyword_cat_field ) . '" />';
}
}
/*
* Отключаем Emojii
*/
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', 'disable_wp_emojis_in_tinymce' );
function disable_wp_emojis_in_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
/*Откл JQMIGRATE: Migrate is installed, version 1.4.1*/
add_action('wp_default_scripts', function ($scripts) {
if (!empty($scripts->registered['jquery'])) {
$scripts->registered['jquery']->deps = array_diff($scripts->registered['jquery']->deps, ['jquery-migrate']);
}
});
/**
* Заполняет поле для атрибута alt на основе заголовка Записи у картинки при её добавлении в контент.
*
* @param array $response
*
* @return array
*/
function change_empty_alt_to_title( $response ) {
if ( ! $response['alt'] ) {
$response['alt'] = sanitize_text_field( $response['uploadedToTitle'] );
}
return $response;
}
add_filter( 'wp_prepare_attachment_for_js', 'change_empty_alt_to_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment