Skip to content

Instantly share code, notes, and snippets.

View qant's full-sized avatar
💫
Permanent study state

Anton qant

💫
Permanent study state
  • lusa realty, lusa legal, banisio
  • Испания
  • X @antseme
View GitHub Profile
@qant
qant / _admin_notice_example.php
Created May 29, 2022 11:29
Wordpress dismissible admin notice example
<?php
if (!defined('ABSPATH')) {
die('-1');
}
if (!class_exists('ANT_NOTICE')) {
class ANT_NOTICE
@qant
qant / _ant_woocommerce_mimi_cart.php
Created May 28, 2022 17:10
Woocommerce minicart
<?php
echo '<a href="#" class="dropdown-back" data-toggle="dropdown"> ';
echo '<i class="fa fa-shopping-cart" aria-hidden="true"></i>';
echo '
<div class="basket-item-count" style="display: inline;">';
echo '<span class="cart-items-count count">';
echo WC()->cart->get_cart_contents_count();
echo '</span>';
echo '
</div>
@qant
qant / kc.ajax.php
Created May 25, 2022 08:08
KingComposer patched get_thumbn and get_thumbn_size because of https://wpscan.com/vulnerability/906d0c31-370e-46b4-af1f-e52fbddd00cb
<?php
/**
*
* King Composer
* (c) KingComposer.com
*
*/
if(!defined('KC_FILE')) {
header('HTTP/1.0 403 Forbidden');
exit;
@qant
qant / filter.php
Created May 7, 2022 07:13 — forked from cfxd/filter.php
Efficient Responsive Images in WordPress. See https://cfxdesign.com/efficient-responsive-images-in-wordpress
<?php
/*
* THE FILTER
*
*/
function custom_responsive_image_sizes($sizes, $img_name, $attachment_id) {
$sizes = wp_get_attachment_image_sizes($attachment_id, 'original');
$meta = wp_get_attachment_metadata($attachment_id);
$width = $meta['width'];
@qant
qant / gist:8ee09e9ab5b79fcfa3e32790f5e0ab85
Created April 9, 2022 09:15
Clear all cart sessions woocommerce
//Using wp cli
wp wc tool run clear_sessions --user=1
Useful related commands: https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Overview#command-1
wp wc tool run delete_orphaned_variations --user=1
wp wc tool run clear_expired_transients --user=1
wp wc tool run clear_transients --user=1
--user=1 is an admin user with ID=1 in my case
@qant
qant / woocommerce-popular-products.php
Created March 24, 2022 08:23 — forked from aslamdoctor/woocommerce-popular-products.php
Woocommerce : Get popular products using wp_query
@qant
qant / tax.php
Created February 8, 2022 07:45
Extra taxes woo
<?php
// Display the custom checkbow field in checkout
add_action( 'woocommerce_review_order_before_order_total', 'fee_installment_checkbox_field', 20 );
function fee_installment_checkbox_field(){
echo '<tr class="packing-select"><th>';
woocommerce_form_field( 'installment_fee', array(
'type' => 'checkbox',
'class' => array('installment-fee form-row-wide'),
'label' => __('Montaža v 14 dneh (predpripravljen prostor) - 170€'),
@qant
qant / package.json
Created December 14, 2021 15:12
Resize and watermark images node
{ "name": "resize_and_watermark_images", "version": "1.0.0", "description": "", "main": "resize.js", "author": "Anton Semenov", "license": "", "dependencies": { "sharp": "^0.29.3" } }
@qant
qant / login_and_redirect_back.php
Created December 2, 2021 13:06
If not logged in. Redirect back to previous url, after login to the WordPress
<?php
//.... load wordpress stuff etc
if(!is_user_logged_in()) {
wp_redirect( wp_login_url($_SERVER['SCRIPT_URI']) );
}
@qant
qant / composer.json
Created October 12, 2021 12:06
Excel and pdf example using php
{
"require": {
"phpoffice/phpspreadsheet": "^1.18",
"mpdf/mpdf": "^8.0"
}
}