Skip to content

Instantly share code, notes, and snippets.

View mohsinrasool's full-sized avatar
💪

Mohsin Rasool mohsinrasool

💪
View GitHub Profile
@mohsinrasool
mohsinrasool / Widget Classes
Created November 13, 2015 15:37 — forked from plechazunga/Widget Classes
WordPress
/**
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
*/
function widget_first_last_classes($params) {
global $my_widget_num; // Global a counter array
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
if(!$my_widget_num) {// If the counter array doesn't exist, create it
@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
@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 / wp_body_class.php
Created August 19, 2015 11:58
Add Page slug to the body_class function
// Add to the body_class function
function condensed_body_class($classes) {
global $post;
// add a class for the name of the page - later might want to remove the auto generated pageid class which isn't very useful
if( is_page()) {
$pn = $post->post_name;
$classes[] = "page-".$pn;
}
@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 / 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 / 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 / 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>