Skip to content

Instantly share code, notes, and snippets.

View mohsinrasool's full-sized avatar
💪

Mohsin Rasool mohsinrasool

💪
View GitHub Profile
@mohsinrasool
mohsinrasool / Disable-PHP-Warnings.php
Created January 2, 2023 18:55
This WordPress mu-plugin disables php deprecated messages and warnings,
<?php
/*
Plugin Name: Disable PHP warnings
Description: This plugin disables php deprecated messages and warnings,
Version: 0.1
Author: mohsinrasool
Author URI: https://mohsinrasool.pk
*/
@mohsinrasool
mohsinrasool / script.js
Last active October 25, 2021 21:21
Convert Divi Tabs to Dropdown for Mobile
/** Step 1: Add "mobile-tab-dropdown" to Tab module
* Step 2: Add following script in Divi > Theme Options > Integration > "Add code to <body> tag"
*/
jQuery(document).ready(function () {
if($('.mobile-tab-dropdown').length) {
var html = '<div id="tabs-mobile-dropdown" class="dropdown" style="position: relative;width: 100%;margin: 10px 0;">'
html += '<select class="select-style " style="background: white;width: 100%;">';
$('.et_pb_tabs .et_pb_tabs_controls li').each(function() {
@mohsinrasool
mohsinrasool / skyverge-interview-code-review-1.php
Created August 1, 2019 19:57
SkyVerge First Interview Code Review
<?php
/**
* This code retrieves course data from an external API and displays it in the user's
* My Account area. A merchant has noticed that there's a delay when loading the page.
*
* 1) What changes would you suggest to reduce or remove that delay?
* 2) Is there any other code changes that you would make?
*/
public function add_my_courses_section() {
// MR - Todos
@mohsinrasool
mohsinrasool / wp-fix-cloudflare-ssl.php
Created March 20, 2018 17:27
WordPress Fix for soft SSL provided by Cloudflare
<?php
/**
* Add following snippet in functions.php of your active theme. it should fix both admin and frontend.
*/
function ms_admin_head() {
echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
}
add_action( 'admin_print_styles', 'ms_admin_head', 1 );
add_action( 'wp_head', 'ms_admin_head', 1 );
@mohsinrasool
mohsinrasool / meticulous-product-categories-widget.php
Last active January 12, 2018 09:42
This plugin adds a woocommerce product category widget. Requires WooCommerce
<?php
/**
* Plugin Name: Meticulous Product Categories Widget
* Description: This plugin adds a woocommerce product category widget. Requires WooCommerce
* Version: 1.0
* Author: Meticulous Solutions
* Author URI: http://MeticulouSolutions.com
* License: GPL2
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
@mohsinrasool
mohsinrasool / patch.php
Created December 20, 2017 18:32
Fixing get_country() on null for woocommerce-gateways-country-limiter by WPML
// Change filter_country function to following
function filter_by_country($payment_gateways){
$woocommerce = function_exists('WC') ? WC() : $GLOBALS['woocommerce'];
if($woocommerce == null || $woocommerce->customer == null )
return $payment_gateways;
$customer_country = $woocommerce->customer->get_country();
@mohsinrasool
mohsinrasool / VCF attachment in Contact Form 7
Created May 8, 2017 16:21
VCF attachment in Contact Form 7
/**
* Generate VCF from form's data and send as attachment for admin, in Contact Form 7
*
*/
add_action('wpcf7_before_send_mail', 'wpcf7_add_attachment');
function wpcf7_add_attachment($contact_form) {
global $_POST;
$submission = WPCF7_Submission::get_instance();
$vcf_dir = WP_CONTENT_DIR.'/uploads/2017/04/';
@mohsinrasool
mohsinrasool / .gitignore
Last active November 20, 2021 15:50 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@mohsinrasool
mohsinrasool / add-to-cart-variations.js
Created August 2, 2016 17:29
WooCommerce fix when product variations get removed after load.
/**
* This file contains the fix.
*/
/*global wc_add_to_cart_variation_params, wc_cart_fragments_params */
/*!
* Variations Plugin
*/
;(function ( $, window, document, undefined ) {
@mohsinrasool
mohsinrasool / wp-upme-sync-user-meta-fields.php
Created July 29, 2016 12:08
Map WordPress user meta fields to UPME meta fields
<?php
$wp_user_query = new WP_User_Query( array( 'role' => 'Subscriber', 'fields' => 'all') );
$authors = $wp_user_query->get_results();
if (!empty($authors)) {
echo '<ul>';
$fields = array(
'Membership Category' => 'custom_field_1',