Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Chinmay Rajyaguru chinmayrajyaguru

🎯
Focusing
Block or report user

Report or block chinmayrajyaguru

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wordpress-w3tc-site.conf
server {
# Redirect yoursite.com to www.yoursite.com
server_name yoursite.com;
rewrite ^(.*) http://www.yoursite.com$1 permanent;
}
server {
# Tell nginx to handle requests for the www.yoursite.com domain
server_name www.yoursite.com;
@chinmayrajyaguru
chinmayrajyaguru / call-recent-comments.php
Last active Mar 22, 2017
WordPress Approved Recent Comments with Gavtar
View call-recent-comments.php
<h3>Recent Comments</h3>
<ul class="recent-comment">
<?php
$comments =get_comments( array('number'=>'5', 'status' => 'approve') );
foreach($comments as $comm) :
$url = '<a href="'. get_permalink($comm->comment_post_ID).'#comment-'.$comm->comment_ID .'" title="'.$comm->comment_author .' | '.get_the_title($comm->comment_post_ID).'">' . $comm->comment_author . '</a>';
?>
<li>
<?php echo get_avatar($comm->comment_author_email, 30); ?>
<strong><?php echo $url; ?></strong>
@chinmayrajyaguru
chinmayrajyaguru / remove-wordpress-query-strings.php
Created Jun 28, 2016
Remove WordPress Query Strings From Static Resources
View remove-wordpress-query-strings.php
#add this to functions.php
function _remove_query_strings_1( $src ){
$rqs = explode( '?ver', $src );
return $rqs[0];
}
if ( is_admin() ) {
// Remove query strings from static resources disabled in admin
}
else {
@chinmayrajyaguru
chinmayrajyaguru / restart-server.sh
Created Jun 27, 2016
Restart nginx, mysql & php7.0-fpm [LEMP Users]
View restart-server.sh
#If you installed / updated / changed anything on live server then this might be helpful!
#test nginx
sudo nginx -t
#restart nginx, mysql & php7.0-fpm
sudo systemctl reload nginx
sudo service mysql restart
systemctl restart php7.0-fpm.service
@chinmayrajyaguru
chinmayrajyaguru / wordpress-directories-file-permissions.sh
Created Jun 27, 2016
Proper WordPress Filesystem Permissions And Ownerships
View wordpress-directories-file-permissions.sh
#I Recommend
sudo find . -type d -exec chmod 755 {} \; #for all directories
sudo find . -type f -exec chmod 644 {} \; #for all files
sudo chmod 444 wp-config.php #change permission for this file only!
# For nginx users /var/www/html/
sudo chmod 444 wp-config.php
sudo chmod 444 nginx.conf
@chinmayrajyaguru
chinmayrajyaguru / changing-the-wordpress-site-url.sql
Last active Jun 27, 2016
Change the WordPress siteurl & home URL using MySQL command line
View changing-the-wordpress-site-url.sql
/* When moving sites from one location to another, it is sometimes necessary to manually modify data in the database to make the new site URL information to be recognized properly. Many tools exist to assist with this, but generally I use this method */
-- Login to MySQL
use database;
show tables;
SELECT *
-> FROM `wp_options`
-> LIMIT 0 , 30;
update wp_options set option_value = 'http://example.com OR http://Server_IP' where option_id = 1; -- Most important to pick correct option_id for change "siteurl" option_value
update wp_options set option_value = 'http://example.com OR http://Server_IP' where option_id = 1; -- Use this command again to change "home" option_value
EXIT
@chinmayrajyaguru
chinmayrajyaguru / example-import.sql
Last active Jun 27, 2016
Import MySQL database through command line
View example-import.sql
/* A common use of mysqldump is for making a backup of an entire database: */
CREATE DATABASE database-name DEFAULT CHARACTER SET utf8 COLLATE utf8_uni code_ci; -- Create new DB if you don't have it.
GRANT ALL ON database-name.* TO 'user-name'@'localhost' IDENTIFIED BY 'user-password'; -- Give permission to access your created DB.
use database-name;
source path/file.sql;
@chinmayrajyaguru
chinmayrajyaguru / example-import.sql
Created Jun 27, 2016
Import database from cPanel to MySQL through command line
View example-import.sql
CREATE DATABASE database-name DEFAULT CHARACTER SET utf8 COLLATE utf8_uni code_ci;
GRANT ALL ON database-name.* TO 'user-name'@'localhost' IDENTIFIED BY 'user-password';
use database-name;
source path/file.sql;
You can’t perform that action at this time.