Skip to content

Instantly share code, notes, and snippets.

View banago's full-sized avatar

Baki Goxhaj banago

View GitHub Profile
@banago
banago / random-testimonial.php
Last active August 29, 2015 13:57
WordPress Random Testimonial Shortcode
<?php
//[random_testimonial]
function random_testimonial_func( $atts ){
$query = new WP_Query( array ( 'category__in' => array( 4 ), 'posts_per_page' => -1, 'ignore_sticky_posts' => 1, ) );
$testimonials = array();
while( $query->have_posts() ) : $query->the_post();
$testimonials[] = get_the_content();
endwhile;
#!/bin/bash
# This script creates a new project (or site) under /var/sites and creates
# new virtual host for that site. With the options a site can also
# install the latest version of Laravel directly.
# This script was originally based on the following script by @Nek from
# Coderwall: https://coderwall.com/p/cqoplg
# Display the usage information of the command.
create-project-usage() {
@banago
banago / convo-feed-api.php
Last active August 29, 2015 14:19
PHP script for working with Convo's custom feed API.
<?php
/* Convo Custom Feed API
*
* This is the PHP version of the python example script Convo offers on their website:
* https://www.convo.com/developer_center/api/imported_feed_api.py
*/
function add_link_in_feed($resource_id, $url, $title, $description, $image, $site_name) {
global $access_key_id, $secret_access_key;
$params = http_build_query(['resource_id' => $resource_id, 'url' => $url, 'title' => $title, 'description' => $description, 'image' => $image, 'site_name' => $site_name ]);
@banago
banago / gist:1292884
Created October 17, 2011 15:35 — forked from billerickson/gist:1243276
Include In Rotator option in Media Uploader
<?php
/**
* Add "Include in Rotator" option to media uploader
*
* @param $form_fields array, fields to include in attachment form
* @param $post object, attachment record in database
* @return $form_fields, modified form fields
*/
@banago
banago / gist:1292885
Created October 17, 2011 15:35 — forked from billerickson/gist:1243289
Get images marked "Include in Rotator"
<?php
// Get all images attached to post that have "Include in Rotator" marked as "Yes"
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => '-1',
'order' => 'ASC',
@banago
banago / gist:1292878
Created October 17, 2011 15:33 — forked from billerickson/gist:1243250
Photo Credit Fields in Media Gallery
<?php
/**
* Add Photographer Name and URL fields to media uploader
*
* @param $form_fields array, fields to include in attachment form
* @param $post object, attachment record in database
* @return $form_fields, modified form fields
*/
@banago
banago / gist:1790188
Created February 10, 2012 15:13 — forked from technosailor/gist:1771566
Oboject Oriented WordPress Ajax API usage
<?php
/*
Plugin Name: Test
*/
class My_Like_Button {
function __construct()
{
$this->hooks();
}
@banago
banago / average.php
Created March 4, 2012 08:56
Calculates average of values taken from custom fields out of a WordPress loop. Built of Jason ;)
<?php
/**
* Function: Average
* Calculates average of values taken from custom fields out of a WordPress loop. Built of Jason ;)
* Author: Baki Goxhaj
*/
function average( $post_no );
$no = 0;
$query = new WP_Query('posts_per_page=' . $post_no ); while( $query->have_posts() ) : $query->the_posts();
@banago
banago / is_ajax.php
Created March 28, 2012 16:41
Tests if the current request is an AJAX request
<?php
/**
* Tests if the current request is an AJAX request by checking the X-Requested-With HTTP
* request header that most popular JS frameworks now set for AJAX calls.
*
* @return boolean
*/
function is_ajax()
{
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
@banago
banago / presentationPrep.js
Created April 6, 2012 22:28 — forked from JeffreyWay/presentationPrep.js
I wish it could be that simple. Something for me to build.
presentation
.title('My Great Presentation')
.slide({
title: 'Learn About Borders',
bullets: [
'Thing 1',
'Thing 2',
],
code: ['path/to/file.css', [2,4]] // path to file, lines to grab