Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View adeel-raza's full-sized avatar

Adeel adeel-raza

View GitHub Profile
@adeel-raza
adeel-raza / plugin.php
Created January 1, 2022 18:29 — forked from mathetos/plugin.php
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@adeel-raza
adeel-raza / run-multiple-redis-instances.md
Last active November 16, 2018 13:12 — forked from jarvys/run-multiple-redis-instances.md
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
...
@adeel-raza
adeel-raza / gist:6f2a2dcf6a338c4db97c0867cfff363d
Created November 2, 2018 12:29 — forked from sabarasaba/gist:1387550
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
$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' );
@adeel-raza
adeel-raza / wp_mail_smtp.php
Created May 13, 2017 13:23 — forked from butlerblog/wp_config.php
Configure WordPress wp_mail function to send through SMTP server http://b.utler.co/Y3
/**
* This function will connect wp_mail to your authenticated
* SMTP server. This improves reliability of wp_mail, and
* avoids many potential problems.
*
* Author: Chad Butler
* Author URI: http://butlerblog.com
*
* For more information and instructions, see:
* http://b.utler.co/Y3
@adeel-raza
adeel-raza / uploads-remote-nginx-apache.md
Last active October 4, 2016 10:56 — forked from rahilwazir/uploads-remote-nginx-apache.md
Map uploads dir on local system to remote server

Nginx

Put this within server { ... } block of your vhost

location ~ "^(.*)/your_uploads_folder/(.*)$" {
    if (!-e $request_filename) {
        return 302 http://yourlivesite.com$request_uri;
    }
}
@adeel-raza
adeel-raza / dl-file.php
Created July 5, 2016 11:51 — forked from hakre/dl-file.php
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+
@adeel-raza
adeel-raza / fix-wordpress-permissions.sh
Created April 22, 2016 11:29 — forked from Adirael/fix-wordpress-permissions.sh
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
<?php
# RegEx For Eval Removal: \s+(eval\(base64.*?\))\);
exit;
function back_to_for_slash($str) {
return str_replace('\\', '/', $str);
}
$current_dir = back_to_for_slash(dirname(__FILE__) . '/public_html');
$directory = $current_dir;