Skip to content

Instantly share code, notes, and snippets.

View SalmanRavoof's full-sized avatar
🎯
Focusing

Salman Ravoof SalmanRavoof

🎯
Focusing
View GitHub Profile
<html>
<head>
<style>
/* kinsta-banner is used on the homepage only */
.kinsta-banner { font-size: 150% }
.kinsta-banner { width: 75% }
</style>
</head>
<body>
<!-- kinsta banner START -->
@SalmanRavoof
SalmanRavoof / .htaccess
Created October 9, 2019 21:14
Alternative way to force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file. The next bit is WordPress' way of handling Pretty Permalinks.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]
# Please make sure to replace the example.com domain name in line 3 with your own
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@SalmanRavoof
SalmanRavoof / .htaccess
Created October 9, 2019 21:13
Force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file. The next part is WordPress' way of handling Pretty Permalinks.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
@SalmanRavoof
SalmanRavoof / .htaccess
Created October 9, 2019 20:40
Alternative way to force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]
# Please make sure to replace the example.com domain name in line 3 with your own
# BEGIN WordPress
# END WordPress
@SalmanRavoof
SalmanRavoof / .htaccess
Created October 9, 2019 20:36
Force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file. Never put it in between the WordPress tags.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
# BEGIN WordPress
# END WordPress
@SalmanRavoof
SalmanRavoof / wp-config.php
Created October 9, 2019 20:30
Force your WordPress site to use SSL on both frontend and backend.
define('FORCE_SSL', true);
define('FORCE_SSL_ADMIN',true);
@SalmanRavoof
SalmanRavoof / test.php
Created August 20, 2019 07:38
A simple test PHP file.
<html>
<head>
<title>PHP-Test</title>
</head>
<body>
<?php echo '<h1>Hello World!</h1><h3>Welcome to WPMU DEV</h3>'; ?>
</body>
</html>
@SalmanRavoof
SalmanRavoof / test-highlight.php
Created August 11, 2019 15:45 — forked from polybuildr/test-highlight.php
Testing GitHub Gists syntax highlighting for PHP without an opening <?php tag.
$foo = "bar";
echo $foo;
@SalmanRavoof
SalmanRavoof / liker_script.js
Created August 9, 2019 04:37
JavaScript file to add AJAX functionality to your plugin. The 'myAjax.ajaxurl' value is the admin-ajax.php file for your website.
jQuery(document).ready( function() {
jQuery(".user_like").click( function(e) {
e.preventDefault();
post_id = jQuery(this).attr("data-post_id");
nonce = jQuery(this).attr("data-nonce");
jQuery.ajax({
type : "post",
dataType : "json",
url : myAjax.ajaxurl,
data : {action: "my_user_like", post_id : post_id, nonce: nonce},
@SalmanRavoof
SalmanRavoof / Add-Javascript-AJAX-Support.php
Last active January 1, 2021 16:12
Enqueue jQuery library as well as your plugin’s custom JavaScript file by adding it to your plugin.
<?php // used here only for enabling syntax highlighting. Leave this out if it's already included in your plugin file.
// Fires after WordPress has finished loading, but before any headers are sent.
add_action( 'init', 'script_enqueuer' );
function script_enqueuer() {
// Register the JS file with a unique handle, file location, and an array of dependencies
wp_register_script( "liker_script", plugin_dir_url(__FILE__).'liker_script.js', array('jquery') );