Skip to content

Instantly share code, notes, and snippets.

View seredniy's full-sized avatar
🏠
Working from home

Anton Serednii seredniy

🏠
Working from home
View GitHub Profile
@seredniy
seredniy / wp-image-placeholder.php
Created October 20, 2019 17:41 — forked from mihdan/wp-image-placeholder.php
Заменяет битые ссылки на кратинки в WordPress на заглушки. Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого.
<?php
/**
* Plugin Name: Mihdan: Image Placeholder
*/
namespace Mihdan_Image_Placeholder;
$images = array(
// Обычные
'https://placeimg.com/640/480/animals',
@seredniy
seredniy / index.php
Created June 18, 2019 13:54 — forked from ciorici/index.php
Featured Products Loop in WooCommerce 3.0
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
@seredniy
seredniy / wc-redirect-after-add-to-cart.php
Created August 17, 2018 08:46 — forked from JeroenSormani/wc-redirect-after-add-to-cart.php
WooCommerce redirect after add to cart
/**
* Redirect to checkout at add-to-cart action.
*/
function redirect_to_checkout() {
return WC()->cart->get_checkout_url();
}
add_filter( 'woocommerce_add_to_cart_redirect', 'redirect_to_checkout' );
------------------------------------
@seredniy
seredniy / wpcf7_modal_right_answer.php
Created July 13, 2018 11:30 — forked from campusboy87/wpcf7_modal_invalid.php
Displays a message about the successful submission of the form in a modal window for the Contact Form 7 plugin
<?php
/**
* Plugin Name: CF7 Modal Right Answer
* Plugin URI: https://gist.github.com/campusboy87/a056c288c99feee70058ed24cee805ad
* Author: Campusboy (wp-plus)
* Author URI: https://www.youtube.com/wp-plus
*/
add_action( 'wp_enqueue_scripts', 'wpcf7_modal_right_answer_js' );
add_action( 'wp_footer', 'wpcf7_modal_right_answer_js_inline', 999 );
@seredniy
seredniy / request.php
Created June 26, 2018 15:01 — forked from campusboy87/request.php
Имитирует функционал "Отображать на статической странице список записей".
<?php
add_filter( 'request', function ( $query_vars ) {
if ( isset( $query_vars['pagename'] ) && $query_vars['pagename'] === 'all-articles' ) {
add_filter( "pre_option_page_for_posts", function () {
return 484; // ID нужной страницы
} );
}
return $query_vars;
@seredniy
seredniy / gist:f46810959ee7939377256cbc8e8ac034
Last active March 13, 2018 09:16 — forked from alwayscoding/gist:5142352
WORDPRESS:GET ALL TAGS FROM A CATEGORY
//FUNCTION FILE
function get_category_tags($args) {
global $wpdb;
$tags = $wpdb->get_results
("
SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link
FROM
wp_posts as p1
LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID
LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
@seredniy
seredniy / index.html
Last active August 28, 2017 13:30
Мобильное меню ( toggle button menu )
<a href="#menu" id="toggle" class="toggle"><span></span></a>
<nav id="menu" class="menu">
<ul>
<li><a href="/">Menu item 1</a></li>
<li><a href="/">Menu item 2</a></li>
<li><a href="/">Menu item 3</a></li>
</ul>
</nav>