Skip to content

Instantly share code, notes, and snippets.

View mohsinrasool's full-sized avatar
💪

Mohsin Rasool mohsinrasool

💪
View GitHub Profile
@mohsinrasool
mohsinrasool / wiki_page_shortcode.php
Created August 28, 2015 10:09
Wikis listing for WPMU Dev Wiki Plugin
add_shortcode('wiki_page','my_wiki_page');
function my_wiki_page($atts, $content) {
ob_start();
$post_type = 'incsub_wiki';
// Gets every "category" (term) in this taxonomy to get the respective posts
//$terms = get_terms( 'wiki_category' );
@mohsinrasool
mohsinrasool / WPML Slug Fixed
Last active August 29, 2015 14:12
WPML Slug Fixed
/**
* This script adds a bulk action on post listing screen. When applied, it updates the slugs of selected translations with
* the slugs of corresponding english translations. Whole idea is to have same slugs for every translation with only difference
* of /language. For example
* /test
* /fr/test
* /de/test
*
* @author mohsinrasool
*/
@mohsinrasool
mohsinrasool / Cleverness-Todos-in-WP-Full-Calendar
Created March 27, 2015 12:39
Displays Assigned Cleverness todos in WP Full Calendar
/**
* Displays Assigned Cleverness todos in WP Full Calendar
*
* @return $items
* @author Mohsin Rasool
**/
add_filter( 'wpfc_events', 'wpfc_add_tasks' );
add_filter( 'wpfc_ajax', 'wpfc_add_tasks' );
@mohsinrasool
mohsinrasool / file_auto_loader.php
Created July 9, 2015 12:32
Function recursively includes all the files in the specified directory $dir and skips the ones in $skipFiles array
<?php
/**
* It recursively includes all the files in the specified directory $dir and skips the ones in $skipFiles array
* Usage:
* include_files(dirname(__FILE__)."/models", $skipFiles);
*
* @return void
* @author Mohsin Rasool
*
@mohsinrasool
mohsinrasool / wp-db-fix-weird-chars.sql
Last active August 29, 2015 14:24
WP Queries to fix weird characters (i.e., – = em dash, and — = en dash) in posts and pages
-- Try 1:
-- Change DB_CHARSET from utf-8 to latin1 in wp-config.php
-- define('DB_CHARSET', 'latin1');
-- Try 2:
-- Clean up post_content
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
@mohsinrasool
mohsinrasool / loadAdaptiveBackground.js
Created July 29, 2015 13:54
Javascript function to load the corresponding image based on window resolution.
/**
* Javascript function to load the corresponding image based on window resolution.
*
* Usage:
* <div id='story' data-adaptive-bg='{
* "desktop": "/static/img/banners/press/press-1920x1080.jpg",
* "tablet": "/static/img/banners/press/press-992x500.jpg",
* "mobile": "/static/img/banners/press/press-768x400.jpg"
* }'>
* </div>
@mohsinrasool
mohsinrasool / login-logout-link-nav.php
Created August 20, 2015 10:26
Add login/logout link to naviagation menu
@mohsinrasool
mohsinrasool / Client.php
Created October 2, 2015 14:14
WordPress Shortcode to Fetch LinkedIn Company Profile updates
<?php
class Client {
public $domain = "https://api.linkedin.com";
/**
* Authorization and AccessToken api endpoints are special in that they live on www.linkedin.com not api.linkedin.com
*/
public $authorizationUrl = "https://www.linkedin.com/uas/oauth2/authorization";
public $accessTokenUrl = "https://www.linkedin.com/uas/oauth2/accessToken";
@mohsinrasool
mohsinrasool / wp_ms_body_class_site_id.php
Created October 26, 2015 16:59
add a class to the body tag identifying the blog on a wordpress multi site install
<?php
add_action( 'body_class', 'my_body_class' );
function my_body_class( $class ) {
global $current_blog;
$class[] = 'site-' . $current_blog-> blog_id;
return $class;
}
?>
@mohsinrasool
mohsinrasool / buddypress-omit-hidden-visibility-search-results.php
Last active October 29, 2015 12:01
This snippet should be placed in member-loop.php within the if statement of bp_has_members check. it finds and remove the members that has the search term in the fields. It is one attempt to do that.
<?php
global $members_template;
$member_count = $members_template->member_count;
$query = $_GET['s'];
for($i=0; $i<$member_count; $i++) {
$list = bp_xprofile_get_hidden_fields_for_user($members_template->members[$i]->ID,bp_loggedin_user_id());