Skip to content

Instantly share code, notes, and snippets.

@sumitpore
sumitpore / .htaccess
Last active July 15, 2021 23:37
Disable XDEBUG Debugging for WordPress Admin Requests
# If you are debugging a code in editors like Visual Studio Code (VSCode) or Sublime
# Text and if you see that breakpoints are getting triggered due to WordPress Ajax
# requests, then XDEBUG Remote Debugging can be disabled for Ajax Requests by
# adding code below in .htaccess file.
<If "%{REQUEST_URI} =~ /admin-ajax/">
php_value xdebug.remote_enable 0
</If>
@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:aac8fc0b2b133c098c002fecc0ea88cd
Last active July 23, 2020 13:26
Git process to prevent overriding of other's code
git add .
git stash
git pull --rebase
git stash pop
git status
git commit
git push
@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 / settings.json
Last active October 10, 2019 12:50
VSCode settings.json for PHP Projects. I don't give specific phpcs standards in this config instead I place `.phpcs.xml.dist` in the project directory.
{
"breadcrumbs.enabled": true,
"phpcs.enable": true,
"phpcs.showSources": true,
"phpcs.executablePath": "/usr/local/bin/phpcs",
"phpcs.autoConfigSearch": true,
"phpcs.ignorePatterns": [
"*/vendor/*",
"*/vendors/*",
],
@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