Skip to content

Instantly share code, notes, and snippets.

View niladam's full-sized avatar

Madalin Tache niladam

View GitHub Profile
#!/bin/bash
brew_command=/usr/local/bin/brew
brew_cask_command="$brew_command cask"
echo '#!/bin/bash'
echo ''
echo 'trap ctrl_c INT'
echo 'function ctrl_c() {'
echo 'echo "** Trapped CTRL-C"'
@niladam
niladam / Mailer.php
Created September 14, 2016 07:52 — forked from DavidRockin/Mailer.php
PHPMailer save emails to IMAP folder
<?php
class Mailer extends PHPMailer {
/**
* Save email to a folder (via IMAP)
*
* This function will open an IMAP stream using the email
* credentials previously specified, and will save the email
* to a specified folder. Parameter is the folder name (ie, Sent)
@niladam
niladam / single-user-loggin.php
Created September 30, 2016 15:39 — forked from benmay/single-user-loggin.php
Ensures only one user at a time can be logged into WordPress, ie, 2 people can't login using the same account.
<?php
/*
Plugin name: Single user login
Plugin URI:
Description:
Author: Ben May
Author URI:
Version: 0.1
*/
@niladam
niladam / gist:25e808926fa29eb5524371fd39c84c5b
Created October 10, 2016 08:47 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
## Add thumbnail to post columns in Dashboard
```
add_image_size( 'admin-list-thumb', 80, 80, false );
// add featured thumbnail to admin post columns
function wpcs_add_thumbnail_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'featured_thumb' => 'Thumbnail',
@niladam
niladam / wp-start.sh
Created October 24, 2016 13:55 — forked from ethicka/wp-start.sh
WordPress Installation with the Roots/Sage Framework and VirtualHost Creation
#!/bin/bash -e
##
# WordPress Installation and VirtualHost Creation
#
# Description: Installs a WordPress website in the ~/Sites folder, creates a homepage,
# cleans up the WP install a bit, deletes the akismet and hello dolly plugins, creates the permalinks,
# clones the roots/sage theme framework to the theme folder, deletes all the other WP default themes,
# installs/runs npm and bower and runs gulp to create the initial assets, adds a custom gitignore file
# to /wp-content, installs the roots/soil plugin, creates a git repo in wp-content, saves the WordPress
@niladam
niladam / wp-cli.sh
Created October 25, 2016 19:53 — forked from benmay/wp-cli.sh
Bash script used on dev server to create new WordPress sites.
#!/bin/sh
# Set DB Constants
DBHOST="localhost"
DBUSER="root"
DBPASS="123"
DBNAME="wp_$1"
# Set WP Constants
ADMIN_NAME="my_admin_account"
@niladam
niladam / wp-ajax-upload.php
Created October 26, 2016 08:30 — forked from techslides/wp-ajax-upload.php
Upload to WordPress with Ajax and FormData
<input type="file" name="file" id="file">
<input type="submit" id="submit" name="Upload" onclick="upload();return false;">
<script type="text/javascript">
function upload(){
var formData = new FormData();
formData.append("action", "upload-attachment");
var fileInputElement = document.getElementById("file");
formData.append("async-upload", fileInputElement.files[0]);
@niladam
niladam / custom-search-acf-wordpress.php
Created October 28, 2016 13:33 — forked from charleslouis/custom-search-acf-wordpress.php
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;
}
@niladam
niladam / functions.php
Created November 29, 2016 17:41 — forked from renaissance-design/functions.php
Enqueueing jQuery from Google's CDN with local fallback in WordPress
function rd_bulletproof_jquery() {
$protocol = ($_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
$url = $protocol . '://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
wp_deregister_script('jquery');
if (get_transient('google_jquery') == true) {
wp_register_script('jquery', $url, array(), null, true);
}
else {
$resp = wp_remote_head($url);
if (!is_wp_error($resp) && 200 == $resp['response']['code']) {