Skip to content

Instantly share code, notes, and snippets.

View fmtarif's full-sized avatar

Faisal Muhammad fmtarif

View GitHub Profile
<?php
/*
Description: A simple class based on a tutorial at WP.Tuts that creates an page with metaboxes.
Author: Stephen Harris
Author URI: http://www.stephenharris.info
*/
/* Copyright 2011 Stephen Harris (contact@stephenharris.info)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@fmtarif
fmtarif / .htaccess
Created September 27, 2013 10:49 — forked from vinaydotblog/.htaccess
AddType text/cache-manifest manifest
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /
# Do not enable rewriting for files or directories that exist
@fmtarif
fmtarif / .htaccess
Created September 27, 2013 10:53 — forked from lavoiesl/.htaccess
# LESS compiler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ^(.*)\.css
RewriteCond %1.less -f
RewriteRule ^(.*)\.css lessphp/less.php?f=$1.less
/**
Uploading files
Taken from: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/
INSTRUCTIONS:
In the page you wish to use this script you'll need to enque the media scripts and this script.
Then create a input box and a button with NOTHING in between.. with the class 'upload_image_button'
<?php
wp_enqueue_media();
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
<?php
// PHP Logical operators: The difference between OR vs ||, AND vs &&
// Key concept #1: "||" and "&&" have greater precedence than "=", "OR", "AND"
// http://php.net/manual/en/language.operators.precedence.php
// Key concept #2: PHP logical operators are short-circuit
// http://en.wikipedia.org/wiki/Short-circuit_evaluation
// http://php.net/manual/en/language.operators.logical.php
@fmtarif
fmtarif / backup-cleanup.sh
Created April 29, 2014 07:28
#linux #sysadmin backup scripts
#!/bin/bash
#start
#-----------------------------------------------------------------------
find /srv/backup/daily/databases/ -name '*.gz' -mtime +7 | xargs rm -f;
find /srv/backup/daily/websites/ -name '*.gz' -mtime +7 | xargs rm -f;
# Are Weekly Backups Implemented?
# find /srv/backup/weekly/ -name '*.gz' -mtime +30 | xargs rm -f;
#-----------------------------------------------------------------------
#end
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
* Tip: http://pivotallabs.com/users/jdean/blog/articles/1400-working-with-asynchronously-loaded-javascript
*/
(function(doc, script) {
var js,
@fmtarif
fmtarif / countries.json
Last active August 29, 2015 14:04 — forked from keeguon/countries.json
#ng #js
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@fmtarif
fmtarif / wp-query-ref.php
Last active August 29, 2015 14:21 — forked from luetkemj/wp-query-ref.php
#wp #wordress WP Query ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(