Skip to content

Instantly share code, notes, and snippets.

@sumitpore
sumitpore / gist:73ec89098f4c5ac4f9befcaca89b7287
Created April 17, 2019 11:16
Check if Ajax Request in PHP
<?php
if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
{
# Ex. check the query and serve requested data
}
@sumitpore
sumitpore / xdebug.ini
Created May 10, 2019 10:31
xdebug Config
zend_extension=xdebug.so
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.trace_enable_trigger=1
xdebug.trace_format=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.show_mem_delta=1
xdebug.auto_trace=0
xdebug.profiler_output_dir=/tmp
@sumitpore
sumitpore / convert-zip-structure-to-associative-array.php
Last active April 14, 2022 12:44
Convert Zip Structure to Associative Array using PHP
<?php
/**
* Borrowed from https://stackoverflow.com/a/38407568/1994640
*
* Fixed fatal errors and unwanted creation of empty arrays
*/
$filePath = 'hello.zip';
$za = new ZipArchive();
if ($za->open($filePath) !== true) { // check for the zip archive
@sumitpore
sumitpore / readme.md
Last active June 5, 2019 03:16
Image with Caption in Github Readme
| ![Image Alt Text](https://image_url) |
|:--:|
| *Image Caption* |
@sumitpore
sumitpore / class-nonce.php
Last active July 2, 2019 16:18
PHP Nonce Class
<?php
/**
* This class does the operations related to Nonce
*
* It takes care of creating a nonce & verifying a nonce
*
* Example
*
* STEP 1 - CREATION OF NONCE:
* <code>
@sumitpore
sumitpore / .env
Last active October 26, 2019 14:14
Postcss Based Project Starter Kit. I name primary postcss file as 'main.pcss' or index.pcss. Files ending with pcss extension are converted to css file
NODE_ENV=development
@sumitpore
sumitpore / nginx-service.sh
Created November 1, 2019 03:09
nginx-service
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@sumitpore
sumitpore / email-link-issue.patch
Created November 5, 2019 12:58
WP Socializer Patch
@sumitpore
sumitpore / sample-directory-structure.txt
Last active January 29, 2020 04:07
WordPress Plugin Directory Structure
.
├── admin-resources # Holds Admin related CSS, JS and Templates
│   ├── css
│   ├── js
│   └── templates
├── frontend-resources # Holds Frontend related CSS, JS and Templates
│   ├── css
│   ├── js
│   └── templates
├── custom-packages # Composer packages built or modified for Project
@sumitpore
sumitpore / default-values.php
Last active February 3, 2020 16:34
Sample WordPress Settings Page Examples. With and Without Tabs Both!
<?php
/**
* This file contains common functions required in both implementations.
*/
/**
* Provides default values for the Social Options.
*/
function sandbox_settings_default_social_options() {