Skip to content

Instantly share code, notes, and snippets.

View palicko's full-sized avatar

Pavol Caban palicko

View GitHub Profile
@palicko
palicko / mix-asset-resolver.php
Created December 7, 2023 18:39
Laravel Mix Asset Resolver
<?php
namespace Webikon;
/**
* Class AssetResolver
*
* This utility class resolves URIs to built assets in the /dist directory of our theme. Built assets have a version
* hash within their file name – each time the file changes, this hash will change which changes the file name.
*
@palicko
palicko / images-rewrite.conf
Last active March 14, 2022 09:50
PROD images rewrite for nginx
# Rewrite images, add into server/images-rewrite.conf
location ~ ^/wp-content/uploads/(.*) {
if (!-e $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ https://PRODUCTIONSITE.COM/wp-content/uploads/$1 redirect;
}
}
@palicko
palicko / Remove all WP comments SQL
Last active December 9, 2019 11:07
Remove all comments and fix out of sync comments count SQL. Works also with WC reviews.
# Remove all comments
TRUNCATE `wp_commentmeta`;
TRUNCATE `wp_comments`
# We also need to remove comments counts, which are set in postmeta table
# Get count which are out of sync
SELECT wpp.id, wpp.post_title, wpp.comment_count, wpc.cnt
FROM wp_posts wpp
LEFT JOIN
@palicko
palicko / acf-repeater-get-post-meta
Created May 29, 2017 15:44
ACF repeater via get_post_meta()
<?php
// Returns array with repeater subfields and its values
function repeater_get_post_meta( $repeater_key, $post_id, $sub_field_keys ) {
if ( ! $post_id ) {
$post_id = get_the_ID();
}
// get repeater field
$repeater = get_post_meta( get_the_ID(), $repeater_key, true );
@palicko
palicko / async-social-scripts.js
Created December 17, 2016 16:27
Load social scripts after page is loaded
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('//connect.facebook.net/en_US/all.js#appId=272697932759946&xfbml=1', 'fbjssdk');
load('https://apis.google.com/js/plusone.js', 'gplus1js');
load('//platform.twitter.com/widgets.js', 'tweetjs');
@palicko
palicko / sticky-footer.css
Created December 14, 2016 20:40
Sticky footer with flexbox (works in IE11)
/**
* Be sure to include library scripts in this order. Can be placed either
* in the header or footer.
*/
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js"></script>
@palicko
palicko / mq-mixin
Last active November 27, 2016 15:28
Media queries mixin
@mixin for-size($range) {
$phone-upper-boundary: 600px;
$tablet-portrait-upper-boundary: 900px;
$tablet-landscape-upper-boundary: 1200px;
$desktop-upper-boundary: 1800px;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
// First, register your taxonomy and set the slug argument of rewrite to shows:
register_taxonomy(
'show_category',
'show',
array(
'rewrite' => array( 'slug' => 'shows', 'with_front' => false ),
// your other args...
)
);
@palicko
palicko / gist:3ad57429ef9ae196bebd244b235dc69f
Created November 14, 2016 16:12
Order by two meta values using meta_query
$meta_query = array(
'relation' => 'OR',
'featured' => array( // give the first meta key array an array key
'key' => 'is_featured',
'compare' => 'EXISTS',
'type' => 'NUMERIC'
),
'delivery_date' => array( // give the second meta key array an array key
'key' => 'to_be_delivered',
'compare' => 'EXISTS',