Skip to content

Instantly share code, notes, and snippets.

View mohsinrasool's full-sized avatar
💪

Mohsin Rasool mohsinrasool

💪
View GitHub Profile
@mohsinrasool
mohsinrasool / shortcode_weather_forecast.php
Created June 29, 2016 15:04
WordPress shortcode to fetch and display weather forecast
function weather_forecast_func( $atts ) {
$atts = shortcode_atts( array(
'city' => 'Kingston, ON'
), $atts );
// delete_transient( 'weather_forecast' );
if ( false === ( $weather_forecast = get_transient( 'weather_forecast' ) ) ) {
// $weather_forecast_raw = get_transient( 'weather_forecast_raw' );
@mohsinrasool
mohsinrasool / fix-divi-slider-double-load.css
Last active June 23, 2016 18:36
Issue: Fix double animation of Divi slider
.et_pb_slides .et_pb_slide:first-child .et_pb_slide_description {
display:none;
}
@mohsinrasool
mohsinrasool / hover-image-jquery-effect.js
Created February 18, 2016 14:10
JQuery hover effect to replace and preload hover images.
jQuery(document).ready(function($) {
$('.people img').click(function() {
$('.person_details').slideUp('slow',function(){
$(this).remove();
});
$('.people img.clicked').each(function() {
var normalImg = NormalImgOf($(this).attr("src"));
$(this).attr("src", normalImg);
$(this).removeClass('clicked');
});
@mohsinrasool
mohsinrasool / circle-as-path-in-svg.js
Created February 4, 2016 13:39
Javscript function to create path of circle in SVG
<script type="text/javascript">
function circlePath(cx, cy, r){
return 'M '+cx+' '+cy+' m -'+r+', 0 a '+r+','+r+' 0 1,0 '+(r*2)+',0 a '+r+','+r+' 0 1,0 -'+(r*2)+',0';
}
circlePath (40, 60,30);
</script>
@mohsinrasool
mohsinrasool / divi_override_et_pb_fullwidth_portfolio.php
Created January 19, 2016 16:41
Overriding Divi's et_pb_fullwidth_portfolio shortcode
<?php
add_action('the_post', 'cs_setup_theme');
function cs_setup_theme() {
//var_dump($_REQUEST);
if(is_page()) {
if(shortcode_exists( 'et_pb_fullwidth_portfolio' )) {
remove_shortcode('et_pb_fullwidth_portfolio');
add_shortcode('et_pb_fullwidth_portfolio', 'cs_et_pb_fullwidth_portfolio');
@mohsinrasool
mohsinrasool / display-errors-on-white-screen-of-death.php
Last active January 19, 2016 16:42
Display PHP errors on white screen of death
<?php
ini_set('display_errors', 'On');
ini_set('html_errors', 0);
// ----------------------------------------------------------------------------------------------------
// - Error Reporting
// ----------------------------------------------------------------------------------------------------
error_reporting(-1);
// ----------------------------------------------------------------------------------------------------
@mohsinrasool
mohsinrasool / fix-wordpress-permissions.sh
Created January 12, 2016 15:10 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@mohsinrasool
mohsinrasool / .htaccess
Created December 23, 2015 16:41 — forked from eveland/.htaccess
.htaccess
#Require SSL
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@mohsinrasool
mohsinrasool / wp-network-options-table-update.sql
Created December 2, 2015 19:12
Following scripts adds two SQL Procedures to move a WP network from main domain to sub directory ( here "/blogs" ).
/*
Following scripts adds two SQL Procedures to move a WP network from main domain to sub directory ( here "/blogs" ).
run_command: to execute a sql query
update_options_tables: loop through all the options table and update the home and siteurl options
script at the end: updates the wp_blogs and wp_site table plus class the update_options_tables procedure
*/
@mohsinrasool
mohsinrasool / WordPress SQL Queries.sql
Created November 13, 2015 17:02 — forked from janikvonrotz/WordPress SQL Queries.sql
Wordpress SQL Queries #WordPress
-- Change Siteurl & Homeurl
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl'
-- Change GUID
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com')
-- Change URL in Content
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com')
-- Change Image Path Only