Skip to content

Instantly share code, notes, and snippets.

@sjaved87
sjaved87 / gist:b5bc6053e04be0fbe729
Created May 28, 2015 08:34
Remove tinyMCE buttons based on role
if( !function_exists('wpmu_hide_itmes') ):
function wpmu_hide_itmes($buttons)
{
//do not remoe any button if its super admin or pro users
if(current_user_can('pro') or is_super_admin() ) return $buttons;
//Remove the text color selector
$remove = array( 'msp_shortcodes_button', 'wsalestoolbox_tc_button', 'icon' );
@sjaved87
sjaved87 / disablepluginpersite.php
Last active February 10, 2016 13:57
disable a network enabled plugin for just one or more subsite(s)
<?php
/*
This simple snippet willy disable plugin per site basis.
Replace 2,3,4 with acutal website ID(s) for those you want to disable this plugin
This snippet can also be used to disable any network activated plugin. Only thing you have to do is copy the folder and file name of plugin e.g akismet/akismet.php
*/
add_filter('site_option_active_sitewide_plugins', 'wpmu_modify_sitewide_plugins');
function wpmu_modify_sitewide_plugins($value) {
global $current_blog;
@sjaved87
sjaved87 / remove_notices_for_non_admins.php
Created September 19, 2015 09:48
remove notices for all users except admins
function hide_update_noticee_to_all_but_admin_users()
{
if (!current_user_can('update_core')) {
remove_all_actions( 'admin_notices' );
}
}
add_action( 'admin_head', 'hide_update_noticee_to_all_but_admin_users', 1 );
@sjaved87
sjaved87 / cimy_feilds_in_ms_edit_form.php
Last active February 9, 2016 17:43
This mu-plugin will add cimy user extra fields in Membership 2 edit profile form on frontend. Use it as mu-plugin or copy paste the code in fucntions.php file
<?php
function wpmu_add_cimy_extra_fileds_in_edit_form($feilds, $object){
$user_ID = get_current_user_id();
$user_meta_values = get_cimyFieldValue($user_ID, false);
if($user_meta_values){
//Unset now, we will add those later, at the end :)
unset($feilds['submit'], $feilds['_wpnonce'], $feilds['action']);
@sjaved87
sjaved87 / mp_after_order_remove_register_lightbox.php
Created November 5, 2015 18:41
This code will remove the MarketPress registration PopUp after order. Simply copy and past in functions.php file or use as mu-plugin.
<?php
if ( ! function_exists( 'remove_anonymous_object_filter' ) )
{
/**
* Remove an anonymous object filter.
*
* @param string $tag Hook name.
* @param string $class Class name
* @param string $method Method name
@sjaved87
sjaved87 / wp-list-members.php
Last active June 20, 2016 02:43
List active members of Membership 2 in a table with a shortcode. It can be used standalone without Membership 2 plugin (just remove the condition in loop).
<?php
function listmembers_func( $atts, $content ) {
if ( !defined( 'MS_PLUGIN' ) ) return $content;
$blogusers = get_users( 'blog_id=1&orderby=nicename&role=subscriber' );
// Array of stdClass objects.
$returner = '<table>' ;
$returner .= '<tr>' ;
$returner .= '<th>First Name</th>';
@sjaved87
sjaved87 / filter_attendee_by_payment_status_on_export.php
Created November 12, 2015 21:57
use this mu-plugin to add two seperate buttons for export as paid, not paid and all.
<?php
function wpmu_bookings_export_filter_by_ps($export_data, $event, $booking, $user_data){
//if export all then don't bother.
if(! isset( $_GET['paid'] ) ) return $export_data;
//check if paid event if yes then proceed other wise return.
if ($event->is_premium()) {
$payment_status = $event->user_paid($booking->user_id) ? __('Yes', Eab_EventsHub::TEXT_DOMAIN) : __('No', Eab_EventsHub::TEXT_DOMAIN);
@sjaved87
sjaved87 / change_theme_on_all_subsites.php
Last active July 12, 2016 06:22
This mu-plugin will switch theme on all subsites (except main site) at once. Just change the theme directory slug, save chagnes and move it to wp-content/mu-plugins folder (create if not exists). Be care full if you have hundreds of sites then its not the right approach (will take some time and needs some resources) but good for handsome sites, …
<?php
function wpmu_change_theme_on_all_subsites(){
global $switched;
$theme_directory_slug = 'twentyfourteen';
$sites = wp_get_sites( $args );
if($sites){
@sjaved87
sjaved87 / gist:f434fdae300091cc3bd1
Created November 22, 2015 11:44
Membership 2 : Its a custom add-on to limit the number of blog a member can create within a membersihp. Dependent on membership attributes add-on.
<?php
/**
* Plugin Name: Membership 2 Site Limitation
* Version: 1.0
* Description: Limit number of blogs a member can create on multisite.
* Author: Sajid Javed From Incsub
* Author URI: http://premium.wpmudev.org/
*/
class MS_Custom_Addon_Sitelimit {
@sjaved87
sjaved87 / cp_course_time.php
Created November 27, 2015 18:48
CoursePress Pro - Convert time from minutes into hours.
<?php
add_filter( 'coursepress_unit_time_estimation_minutes_and_seconds_format', 'cp_convert_minutes_to_hours', 10, 2 );
function cp_convert_minutes_to_hours( $time ) {
$get_minutes = explode(":", $time);
if($get_minutes[0] < 90) return $time;
$hours = round( ( $get_minutes[0] / 60 ) , 2) ;