Skip to content

Instantly share code, notes, and snippets.

View adeel-raza's full-sized avatar

Adeel adeel-raza

View GitHub Profile
@sabarasaba
sabarasaba / gist:1387550
Created November 23, 2011 00:36
Setting a timeout for the file_get_contents function
<?php
// Create the stream context
$context = stream_context_create(array(
'http' => array(
'timeout' => 3 // Timeout in seconds
)
));
// Fetch the URL's contents
@hakre
hakre / dl-file.php
Created January 2, 2012 21:41
Wordpress login to download uploaded files
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@vrushank-snippets
vrushank-snippets / PHP : Array To CSV - Download CSV File
Created December 13, 2012 06:21
PHP : Array To CSV - Download CSV File
$fileName = 'Billing-Summary.csv';
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$fileName}");
header("Expires: 0");
header("Pragma: public");
$fh = @fopen( 'php://output', 'w' );
@sudar
sudar / wp-increase-timeout.php
Created February 13, 2013 15:54
Increase the curl timeout in WordPress
<?php
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
@strangerstudios
strangerstudios / pmpro_add_billing_fields_to_profile.php
Last active October 22, 2020 18:30
Add PMPro billing fields to the edit user profile page. You must Paid Memberships Pro and the Register Helper plugin installed. Then add this to a custom plugin or your active theme's functions.php
/*
Add PMPro billing fields to the edit user profile page.
You must Paid Memberships Pro and the Register Helper plugin installed:
http://wordpress.org/extend/plugins/paid-memberships-pro
https://github.com/strangerstudios/pmpro-register-helper
*/
function add_billing_fields_to_profile()
{
global $pmpro_countries;
@jarvys
jarvys / run-multiple-redis-instances.md
Last active September 27, 2022 13:02
run multiple redis instances on the same server for centos
  • create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf
  • edit /etc/redis-xxx.conf, illustrated as below
...
@chrisknepper
chrisknepper / gcal_link.php
Created July 18, 2014 03:51
PHP Google Calendar Link Generator
@NateWr
NateWr / edd-retro-license-emails.php
Created July 23, 2014 21:36
Send an email with the license key to customers when retroactively generating licenses with Easy Digital Download's Software Licensing.
<?php
/**
* Plugin Name: Retroactive License Emails for EDD Software Licensing
* Plugin URI: http://themeofthecrop.com
* Description: Send an email with the license key to customers when retroactively generating licenses with Easy Digital Download's Software Licensing.
* Version: 0.0.1
* Author: Theme of the Crop
* Author URI: http://themeofthecrop.com
* License: GNU General Public License v2.0 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@codelion7
codelion7 / mycred-hook-learndash
Created November 24, 2014 13:10
myCRED Custom Hook: LearnDash
/**
* Register Custom myCRED Hook
* @since 1.0
* @version 1.0
*/
add_filter( 'mycred_setup_hooks', 'Learndash_myCRED_Hook' );
function Learndash_myCRED_Hook( $installed ) {
$installed['hook_learndash'] = array(
'title' => __( 'LearnDash', 'mycred' ),