Skip to content

Instantly share code, notes, and snippets.

View Inzman's full-sized avatar

Indrek Palm Inzman

  • Tartu, Estonia
View GitHub Profile
@hofmannsven
hofmannsven / .htaccess
Last active September 21, 2022 20:20
Custom WordPress Setup
# Block access to WordPress specific files
<files .htaccess>
Order allow,deny
Deny from all
</files>
<files readme.html>
Order allow,deny
Deny from all
</files>
<files readme.txt>
@chrisjhoughton
chrisjhoughton / fb-open-graph.liquid
Last active February 10, 2025 17:27
Facebook Open Graph meta tags for Shopify. Add this as a snippet called "fb-open-graph.liquid" in your theme, and then add {% include 'fb-open-graph' %} to your theme.liquid file.
{% if template contains 'product' %}
<meta property="og:type" content="product">
<meta property="og:title" content="{{ product.title | strip_html | escape }}">
<meta property="og:category" content="{{ product.type }}" />
{% for image in product.images limit:3 %}
<meta property="og:image" content="http:{{ image.src | product_img_url: 'master' }}">
<meta property="og:image:secure_url" content="https:{{ image.src | product_img_url: 'master' }}">
{% endfor %}
<meta property="og:price:amount" content="{{ product.price | money_without_currency | stip_html | escape | remove: ',' }}">
<meta property="og:price:currency" content="{{ shop.currency }}">
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[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,
@frrrnd
frrrnd / Real World.
Created September 2, 2013 16:43
Real world. CSS3.
/**
* Real-World CSS
* by @visualidiot. Licensed under WTPFL.
*/
/* @group Blink */
.blink {
-webkit-animation: blink .75s linear infinite;
-moz-animation: blink .75s linear infinite;
@PabloVallejo
PabloVallejo / php.last-inserted-index.php
Created July 23, 2013 20:21
Get index of last inserted element in array
<?php
// Create array
$a = array();
// Add an item to it
$a[] = 1;
// Point to the last index of the array
end( $a );
@un1ko85
un1ko85 / get_posts_cached.php
Created July 4, 2013 11:27
Wrapper around get_posts that utilizes object caching
/**
* Wrapper around get_posts that utilizes object caching
*
* @access public
* @param mixed $args (default: NUL)
* @param bool $force_refresh (default: false)
* @return void
*/
function get_posts_cached( $args = NULL, $force_refresh = false ) {
$cache_incrementor = wp_cache_get( 'get_posts_cached', 'cache_incrementors' );
@charleslouis
charleslouis / custom-search-acf-wordpress.php
Last active March 8, 2026 03:04
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@pjdietz
pjdietz / compare.php
Last active June 13, 2018 11:52
Construct a PHP comparison function for use in usort() given an array of comparion functions.
<?php
/**
* Given an ordered array of comparison functions, return one function that
* starts with the first and uses the subsequent functions in order in the
* event of equal items.
*
* @param $sortFnArr
* @param int $index
* @return callable
@snipe
snipe / htaccess-ip-lock
Created November 6, 2012 03:51
Htaccess to handle IP whitelisting, password prompt otherwise
# Welcome to your htaccess file.
# Remember that modifying this file can break the entire website
# so please edit carefully.
# Also remember that the order of the rules below does matter,
# so be sure of what you're doing before shuffling things around.
AuthType Basic
AuthName "My Dev Environment"
# Specify what user/password file the server should look
@mikejolley
mikejolley / gist:2176823
Created March 24, 2012 00:44
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;