Skip to content

Instantly share code, notes, and snippets.

View hemant-tivlabs's full-sized avatar

Hemant Arora hemant-tivlabs

View GitHub Profile
@hemant-tivlabs
hemant-tivlabs / shopify-search-autocomplete.js
Created January 30, 2020 11:40
Shopify search autocomplete
(function($) {
$(document).ready(function() {
var $search_form = $('#header #form-search'),
search_cache = [];
$search_form.find('input[name="q"]').attr('autocomplete', 'off');
function hide_search_form_autocomplete() {
$search_form.removeClass('show-autocomplete');
}
function show_search_form_autocomplete() {
@hemant-tivlabs
hemant-tivlabs / constrained-float.css
Created December 19, 2019 11:05
Constrained Floating HTML DIV - Stays fixed at the top when the page is scrolled down, but never goes out of the container
.has-constrained-float { position: relative; /* This container div should have a defined height of its own, that defines the range the floating child could travel. In general use, this could be a child of a flex parent, as that would automatically take the height of its sibling */ }
.constrained-float.fixed { position: fixed; top: 0 }
.constrained-float.absolute { bottom: 0; position: absolute; top: auto }
@hemant-tivlabs
hemant-tivlabs / buckets.liquid
Last active September 13, 2017 11:27
Simple yet flexible Shopify section to add a grid of buckets
{% assign bucket_width_class = 'one-half' %}
{% if section.settings.columns == '3' %}
{% assign bucket_width_class = 'one-third' %}
{% elsif section.settings.columns == '4' %}
{% assign bucket_width_class = 'one-quarter' %}
{% endif %}
<section class="wrapper main-content{% if section.settings.width == 'width-full' %} full-width{% endif %}" style="{%
if section.settings.width == 'width-1200' or section.settings.width == 'width-custom'
%}max-width: {% if section_settings.width == 'width-custom' %}{{ section.settings.custom_width }}{% else %}1200{% endif %}px;{%
else %}{% endif %}">
@hemant-tivlabs
hemant-tivlabs / gist:6c512a3209fcaf766b7732b6f56c0c87
Created July 6, 2017 11:12 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@hemant-tivlabs
hemant-tivlabs / WP3.5 Media Uploader
Last active June 20, 2019 12:53 — forked from mauryaratan/WP3.5 Media Uploader
WordPress 3.5 media uploader in easier steps. If using other than edit post screen, don't forget to use wp_enqueue_media(); in your functions.php
jQuery(document).ready(function($){
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$('.stag-metabox-table .button').click(function(e) {
var send_attachment_bkp = wp.media.editor.send.attachment;
var button = $(this);
var id = button.attr('id').replace('_button', '');
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment){
if ( _custom_media ) {