Skip to content

Instantly share code, notes, and snippets.

@sumitpore
sumitpore / oauth-login-error.patch
Last active August 1, 2018 11:39
'OAuth Client (Single Sign On)' WordPress Plugin Patch which diplays error on Login Page occurred During oAuth Authorization.
diff -Naurw single-sign-on-client/includes/callback.php single-sign-on-client-modified/includes/callback.php
--- single-sign-on-client/includes/callback.php 2018-04-12 13:54:50.000000000 +0530
+++ single-sign-on-client-modified/includes/callback.php 2018-08-01 16:32:47.515616000 +0530
@@ -18,6 +18,23 @@
$options = get_option( 'wposso_options' );
$user_redirect = wpssoc_get_user_redirect_url();
+// If error is present in the url, pass that error to login page
+$error_code = isset( $_REQUEST['error'] ) ? $_REQUEST['error'] : '';
+$error_description = isset( $_REQUEST['error_description'] ) ? $_REQUEST['error_description'] : __( 'Error occurred during login. Error Code: ' ) . strtoupper( $error_code );
@sumitpore
sumitpore / multiple-commands-as-www-data-user
Created February 7, 2019 08:08
How to run multiple commands as a www-data user in terminal
sudo -- sh -c "su www-data -s /bin/sh -c 'cd /var/www/html/test-site && wordmove pull -tpmudv -e staging'"
@sumitpore
sumitpore / gist:62c3b53b8c365f5ccf6613ee62e79592
Created February 7, 2019 13:58
Custom command to clone remote website on local machine
// Purpose of the command is to clone remote site on local machine.
// NOTE: It is required to have wordmove installed, WP installed at /var/www/html/test-site & wordmove yml config to be present in /var/www/html/test-site directory
alias clone_site='sudo chmod -R 775 /var/www/html/test-site && sudo chown -R www-data:sumit /var/www/html/test-site && sudo -- sh -c "su www-data -s /bin/sh -c '"'"'cd /var/www/html/test-site && wordmove pull -tpmudv -e staging'"'"'"'
@sumitpore
sumitpore / gist:41cc5847686075e73f9f8c826d738908
Created February 14, 2019 06:21
Copy files from one location to another without affecting destination's permissions
cp -r --no-preserve=mode,ownership /files/from/folder/* /copy/to/this/destination/
@sumitpore
sumitpore / nginx.sh
Created March 20, 2019 10:21
Nginx Start Stop Script
#!/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 / gist:f23c0532eb06af0cd8aea71c3beb72b6
Created March 22, 2019 03:17
Command to list all Services Running on Different Ports
netstat -tulpn
@sumitpore
sumitpore / gist:1777cbf54693091d95f1f1ee231eeb34
Created April 14, 2019 03:01
Keywords to use in code to ignore WordPress rules when it makes no sense
// @codingStandardsIgnoreLine. -> Ignore One Line
// @codingStandardsIgnoreStart. -> Start Ignoring Piece of Code
// @codingStandardsIgnoreEnd. -> End Ignoring Piece of Code. #2 & #3 are used in conjunction to ignore a block of code.
// WPCS: XSS OK. -> Suppress XSS warning. Use only when you know that the text is safe
@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 / readme.md
Last active June 5, 2019 03:16
Image with Caption in Github Readme
| ![Image Alt Text](https://image_url) |
|:--:|
| *Image Caption* |