Skip to content

Instantly share code, notes, and snippets.

'use strict';
const gulp = require('gulp');
const elixir = require('laravel-elixir');
elixir( (mix) => {
mix.browserSync({
files: ['./resources/templates/**/*.twig'],
proxy: 'example.dev'
});
# Deny all access if user is not logged into WordPress
#
#
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^.*$
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule . - [R=403,L]
<?php
/**
* File field returning ID
*/
if ( get_post_meta($post->ID, 'ENTER_KEY', true) ) {
$id = $cfs->get('ENTER_KEY');
$src = wp_get_attachment_image_src($id, 'large');
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
echo '<img src="' . esc_url($src[0]) . '" alt="' . $alt . '">';
@alenabdula
alenabdula / jQueryFunctions.js
Created May 16, 2016 14:46
Collection of random jQuery stuff!
/**
* Display all images without ALT tag
*/
var images = jQuery('img');
images.each(function(index, value) {
var el = jQuery(this);
var attr = el.attr('alt');
if ( typeof attr !== typeof undefined && attr !== false ) {
if ( attr === '' ) {
@alenabdula
alenabdula / Console.md
Created May 14, 2016 17:17
List of useful terminal commands

List of useful commands

  1. find . -type d -name 'node_modules' | xargs rm -r - removes all node_modules folders recursively.
@alenabdula
alenabdula / LetsEncrypt.sh
Created December 20, 2015 20:38
Let's Encrypt Install Process
# Let's Encrypt
# Install Process
cd ~
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
sudo ./letsencrypt-auto certonly --standalone --agree-tos --redirect --duplicate --text --email EMAIL@EXAMPLE.COM -d EXAMPLE.COM -d WWW.EXAMPLE.COM
# Nginx Configuration
# https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/directive-only/ssl.conf
# Path to Certificates
# /etc/letsencrypt/live/EXAMPLE.COM/privkey.pem
<?php
/**
* Retrive ID from attachment URL
* Source http://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/
*/
function get_id_from_attachment_url($attachment_url = '') {
global $wpdb;
@alenabdula
alenabdula / wordpress-rewrite.php
Created February 1, 2016 15:46
WordPress Custom Post Type & Taxonomy rewrite notes
<?php
/**
* WordPress Custom Post Type & Taxonomy rewrite notes:
* When creating CPT/Tax always rewrite the slug and make sure 'with_front' is set to false
* In the rewrite section add following
*/
$args = array(
'rewrite' => array(
'slug' => 'SLUG', # Used as pretty permalink text (i.e. /tag/) - defaults to $taxonomy (taxonomy's name slug)
function convert( num ) {
var x = '';
[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1].map(
function( obj, i ) {
while ( num >= obj ) {
x += ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'][i];
num -= obj;
}
}
);