Skip to content

Instantly share code, notes, and snippets.

View ell4me's full-sized avatar
😄
I'm fine!

Danil Sennikov ell4me

😄
I'm fine!
View GitHub Profile
@ell4me
ell4me / sort.php
Created December 22, 2020 08:28
Sorting out of stock WooCommerce products
/**
* Sorting out of stock WooCommerce products - Order product collections by stock status, in-stock products first.
*/
class iWC_Orderby_Stock_Status
{
public function __construct()
{
// Check if WooCommerce is active
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000);
@ell4me
ell4me / price.php
Last active April 15, 2020 06:21
Custom html price
function get_price_html_custom( $new_price,$product ) {
if ( '' === $product->get_price() ) {
$price = apply_filters( 'woocommerce_empty_price_html', '', $product );
} elseif ( $product->is_on_sale() && $product->is_type( 'variable' ) ) {
$price = wc_format_sale_price( wc_get_price_to_display( $product, array( 'price' => $product->get_variation_regular_price() ) ), wc_get_price_to_display( $product, array( 'price' => $new_price ) )) . $product->get_price_suffix();
}
elseif ( $product->is_on_sale() ) {
$price = wc_format_sale_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), wc_get_price_to_display( $product, array( 'price' => $new_price ) )) . $product->get_price_suffix();
}
else {
@ell4me
ell4me / drift.html
Last active April 9, 2020 01:56
Using Drift with multiple images and images loaded via ajax
<img class="thumb" src="http://assets.imgix.net/dog.png?w=100" data-zoom="http://assets.imgix.net/dog.png?w=1200">
<img class="thumb" src="http://assets.imgix.net/cat.png?w=100" data-zoom="http://assets.imgix.net/cat.png?w=1200">
<img class="thumb" src="http://assets.imgix.net/frog.png?w=100" data-zoom="http://assets.imgix.net/frog.png?w=1200">
<img class="thumb" src="http://assets.imgix.net/llama.png?w=100" data-zoom="http://assets.imgix.net/llama.png?w=1200">
<p>Aenean lacinia bibendum nulla sed consectetur. Vestibulum id ligula porta felis euismod semper. Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla.</p>
<div class="more-thumbs">
<img class="more" src="http://assets.imgix.net/trees.png?w=100" data-zoom="http://assets.imgix.net/trees.png?w=1200">
<img class="more" src="http://assets.imgix.net/mountains.png?w=100" data-zoom="http://assets.imgix.net/mountains.png?w=1200">
function check($array, $value)
{
foreach ($array as $key => $inner) {
if (is_array($inner)) {
if (check($inner, $value)) {
return $key;
}
} else {
if ($value == $inner) {
return $key;
<?php
function wc_attrs_group($atts) {
global $product;
ob_start();
$return = [];
$attributes = $product->get_attributes();
if (!empty($attributes)) {
//ob_start();
foreach ($attributes as $attr => $attr_deets) {
// cart and checkout inline styles
add_action( 'wp_head', 'custom_inline_styles', 900 );
function custom_inline_styles(){
if ( is_checkout() || is_cart() ){
?><style>
.product-item-thumbnail { float:left; padding-right:10px;}
.product-item-thumbnail img { margin: 0 !important;}
dt.variation-Description { display: none;}
</style><?php
}
HTML:
<div class="wrapper">
<div class="tabs">
<span class="tab">Вкладка 1</span>
<span class="tab">Вкладка 2</span>
<span class="tab">Вкладка 3</span>
</div>
<div class="tab_content">
<div class="tab_item">Содержимое 1</div>
<div class="tab_item">Содержимое 2</div>
function validate($data,$errors) {
// Do your data processing here and in case of an
// error add it to the errors array like:
$errors->add( 'validation', __( 'Not all fields have been filled in correctly.' ));
}
add_action('woocommerce_after_checkout_validation', 'validate',10,2);
$( '.search_button' ).on('click', function() {
if ($('#searchform').hasClass('header-block')) {
$('#searchform').removeClass('header-block');
} else{
$('#searchform').addClass('header-block');
}
});
$( 'html' ).on('click', function(e) {
@ell4me
ell4me / gist:536d9437fb92ff147d0bf9f5418864ab
Last active December 7, 2018 21:27
Settings for plugin All In One WP Security & Firewall
{"aiowps_enable_debug":"","aiowps_remove_wp_generator_meta_info":"1","aiowps_prevent_hotlinking":"1","aiowps_enable_login_lockdown":"1","aiowps_allow_unlock_requests":"","aiowps_max_login_attempts":3,"aiowps_retry_time_period":5,"aiowps_lockout_time_length":60,"aiowps_set_generic_login_msg":"","aiowps_enable_email_notify":"","aiowps_email_address":"9698114@mail.ru","aiowps_enable_forced_logout":"","aiowps_logout_time_period":"60","aiowps_enable_invalid_username_lockdown":"","aiowps_instantly_lockout_specific_usernames":[],"aiowps_unlock_request_secret_key":"9boae3otjbi5x7b7q6kf","aiowps_enable_whitelisting":"","aiowps_allowed_ip_addresses":"","aiowps_enable_login_captcha":"","aiowps_enable_custom_login_captcha":"","aiowps_captcha_secret_key":"y9t13745ja38h0dirf5q","aiowps_enable_manual_registration_approval":"","aiowps_enable_registration_page_captcha":"","aiowps_enable_random_prefix":"","aiowps_enable_automated_backups":"1","aiowps_db_backup_frequency":2,"aiowps_db_backup_interval":"2","aiowps_backup_files_s