Skip to content

Instantly share code, notes, and snippets.

View AntoscencoVladimir's full-sized avatar
💭
Deja vu

Vladimir AntoscencoVladimir

💭
Deja vu
  • Chisinau, Moldova
View GitHub Profile
#loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 9999;
@AntoscencoVladimir
AntoscencoVladimir / Delete pages from Search Wordpress
Last active February 14, 2016 09:55
Disable pages from search Wordpress
О том, как из результатов поиска на WordPress можно исключить ВСЕ страницы.
Под ‘страницами’ здесь я подразумеваю одноименный тип контента.
<?php
function bez_stranic_v_poiske($zapros) {
if ($zapros->is_search) :
$zapros->set('post_type', 'post');
endif;
@AntoscencoVladimir
AntoscencoVladimir / Delete anchor from "More" tag Wordpress
Last active January 18, 2016 15:50
Delete anchor from "More" tag Wordpress
function no_more_jumping($post) {
return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Читать далее &raquo;'.'</a>';
}
add_filter('the_content_more_link', 'no_more_jumping');
@AntoscencoVladimir
AntoscencoVladimir / wp-comment-walker
Created January 18, 2016 15:51
Custom comment walker for HTML5 friendly WordPress comment and threaded replies. To be inserted in functions.php.
<?php
class comment_walker extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
<section class="comments-list">
@AntoscencoVladimir
AntoscencoVladimir / functions.php
Created February 14, 2016 10:07
Disable field in comment form
<?php
function remove_comment_fields($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'remove_comment_fields');
?>
<?php wp_nav_menu(array(
'menu' => 'Menu', // (string) Название выводимого меню (указывается в админке при создании меню, приоритетнее
// чем указанное местоположение theme_location - если указано, то параметр theme_location игнорируется)
'container' => 'div', // (string) Контейнер меню. Обворачиватель ul. Указывается тег контейнера (по умолчанию в тег div)
'container_class' => '', // (string) class контейнера (div тега)
'container_id' => '', // (string) id контейнера (div тега)
'menu_class' => 'sf-menu', // (string) class самого меню (ul тега)
'menu_id' => '', // (string) id самого меню (ul тега)
'echo' => true, // (boolean) Выводить на экран или возвращать для обработки
'fallback_cb' => 'wp_page_menu', // (string) Используемая (резервная) функция, если меню не существуе
//Склонение комментариев
function plural_form($number, $after)
{
$cases = array(2, 0, 1, 1, 1, 2);
echo $number . ' ' . $after[($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[min($number % 10, 5)]];
}
@AntoscencoVladimir
AntoscencoVladimir / functions.php
Created April 15, 2016 18:56
Delete anchor from Read more tag
// Delete anchor from Read more tag
function no_more_jumping($post)
{
return '<a href="' . get_permalink($post->ID) . '" class="read-more">' . 'Read more &raquo;' . '</a>';
}
add_filter('the_content_more_link', 'no_more_jumping');
//Проверка
/*
* <!--noindex--> <center><?php print get_num_queries(). ' - столько SQL запросов к базе.<br />'. timer_stop(0, 6). ' - за столько сгенерировалась страница.'; ?></center> <!--/noindex-->
* */
@AntoscencoVladimir
AntoscencoVladimir / woocommerce_functions.php
Created April 16, 2016 14:54
Woocommerce OneSALE customize text
//Woocommerce OneSALE customize text
add_filter('woocommerce_sale_flash', 'my_custom_sale_flash', 10, 3);
function my_custom_sale_flash($text, $post, $_product)
{
return '<span class="onsale">Your text here</span>';
}