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
<!-- Ниже описан код функции для WordPress, которую можно вставить в functions.php активной темы для работы с адаптивными изображениями. | |
Для работы функция использует плагин Kama Thumbnail. | |
Подробнее об адаптивных изображениях: https://developer.mozilla.org/ru/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images --> | |
<?php | |
function morkovin_get_srcset_sizes( $width, $height, $args, $post_id, $img_src = null, $def_src = "/img/no-photo-1.jpg" ) { | |
if ( ! function_exists( 'kama_thumb_src' ) ) { | |
throw new Exception( 'Должен быть установлен плагин Kama Thumbnail' ); | |
} |
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 | |
/* | |
Plugin Name: Morkovin TOC Category | |
Description: Выводит содержания в рубриках | |
Author: Andrey Morkovin | |
Version: 1.1 | |
*/ | |
require 'mpurl-admin.php'; |
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
Все по немногу о JavaScript и Jquery | |
//jQuery-скрипт в WordPress | |
jQuery(document).ready(function($) { | |
}); | |
//ajax, JSON и преобразование объекта, переданного из PHP, в массив | |
var theme = $('#select-diet-form').data('theme'); | |
var weight = $('#diet-weight option:selected').val(); |
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 | |
function src_simple_recent_comments($src_count=7, $src_length=60) { | |
global $wpdb; | |
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_date, comment_approved, comment_type, | |
SUBSTRING(comment_content,1,$src_length) AS com_excerpt | |
FROM $wpdb->comments | |
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) | |
WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' | |
ORDER BY comment_date_gmt DESC | |
LIMIT $src_count"; |
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( 'the_content', 'filter_function_name_11' ); | |
function filter_function_name_11( $content ) { | |
// Фильтр... | |
return $content; | |
} |
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
$('html, body').animate({scrollTop: 0}, 700); | |
}); | |
var win = $(window); | |
var up = $('#up'); | |
win.on('scroll', function() { | |
if ( win.scrollTop() > win.height() / 3 ) { | |
up.fadeIn(); | |
} else { | |
up.fadeOut(); | |
} |
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
if ( !is_ssl() ) { | |
$https_url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
wp_redirect( $https_url, 301 ); | |
exit; | |
} | |
$_SERVER['DOCUMENT_ROOT'] — путь к корню сайта. | |
get_site_url().$_SERVER['REQUEST_URI']; |
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
# load css/js | |
add_action( 'wp_enqueue_scripts', 'add_styles_scripts' ); | |
function add_styles_scripts() { | |
# Jquery | |
wp_deregister_script('jquery-core'); | |
wp_register_script('jquery-core', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'); | |
wp_enqueue_script('jquery'); | |
# css | |
wp_register_style( 'theme-css', get_bloginfo('template_url').'/style.css' ); |
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( 'wpseo_json_ld_output', '__return_false' ); | |
Подробнее здесь: https://developer.yoast.com/features/schema/api/ | |
И еще одна штука. Можно убрать <meta name="robots" content="index, follow…> | |
add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); | |
function yoast_no_home_noindex($string= "") { | |
if (is_home() || is_front_page()) { | |
$string= "index,follow"; | |
} |