Skip to content

Instantly share code, notes, and snippets.

View ohid's full-sized avatar

Ohidul Islam ohid

View GitHub Profile
@ohid
ohid / show_site_id_on_admin_bar.php
Last active September 5, 2020 09:46
This is a mu-plugin that shows the current site id in the admin bar on right side, only useful for multisites.
<?php
/**
* Script Name: Show Site ID on Admin Bar
* Script URI: https://premium.wpmudev.org/
* Description: This is a mu-plugin that shows the current site id in the admin bar on right side, only useful for multisites.
* Author: Ohidul Islam @ WPMU DEV
* Version: 0.1
* Author URI: https://premium.wpmudev.org/
*
*/
@ohid
ohid / wpmudev-hide-plugins.php
Created August 17, 2020 03:46
Hide the specific plugins from the list of plugins page in WordPress. Use this as a mu-plugin
<?php
if( ! function_exists('wpmudev_hide_plugins') ) {
function wpmudev_hide_plugins() {
global $wp_list_table;
$hidearr = array(
'wpmudev-updates/update-notifications.php',
'ultimate-branding/ultimate-branding.php',
'snapshot-backups/snapshot-backups.php',
'forminator/forminator.php',
@ohid
ohid / hmbp-add-font-display-swap-for-google-font.php
Last active September 18, 2020 18:41
[Hummingbird Pro] - Fix font display issue for google fonts
<?php
/**
* Plugin Name: [Hummingbird Pro] - Fix font display issue for google fonts
* Description: [Hummingbird Pro] - Fix font display issue for google fonts - 1155234930966378
* Author: Ohidul Islam @ WPMUDEV
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@ohid
ohid / disable-admin-access-for-subscribers.php
Last active July 29, 2020 08:34
If the user is a subscriber then disable access to the WordPress admin and redirect to the homepage
<?php
if ( ! defined( 'ABSPATH' ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
return;
}
if( ! class_exists( 'WPMU_DISABLE_ADMIN_FOR_SUBSCRIBERS' ) ) {
class WPMU_DISABLE_ADMIN_FOR_SUBSCRIBERS {
// Assume $map looks like this:
$map = array(
array( 'name' => 'Name 1', 'something else' => 'whatever' ),
array( 'name' => 'Name 2', 'something else' => 'whatever' ),
array( 'name' => 'Name 3', 'something else' => 'whatever' ),
array( 'name' => 'Name 4', 'something else' => 'whatever' ),
array( 'name' => 'Name 5', 'something else' => 'whatever' ),
array( 'name' => 'Name 6', 'something else' => 'whatever' ),
array( 'name' => 'Name 7', 'something else' => 'whatever' ),
array( 'name' => 'Name 8', 'something else' => 'whatever' ),
@ohid
ohid / pricing.php
Created September 13, 2019 05:36
This file is only modified for xpider-theme-support plugin and can only be used with that.
<?php
namespace xPiderTS\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Utils;
@ohid
ohid / ip-based-country-redirect.php
Created December 31, 2018 18:33
Client IP based country redirect using PHP
// Function to get the client IP address
function get_client_ip() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
add_action( 'template_redirect', function(){
ob_start( function( $buffer ){
$buffer = str_replace( array( 'type="text/javascript"', "type='text/javascript'" ), '', $buffer );
// Also works with other attributes...
$buffer = str_replace( array( 'type="text/css"', "type='text/css'" ), '', $buffer );
$buffer = str_replace( array( 'frameborder="0"', "frameborder='0'" ), '', $buffer );
$buffer = str_replace( array( 'scrolling="no"', "scrolling='no'" ), '', $buffer );
<?php
add_action('elementor/element/before_section_end', function( $section, $section_id, $args ) {
if( $section->get_name() == 'section' && $section_id == 'section_layout' ){
$section->add_control(
'wpb_section_padding',
[
'label' => _x( 'Section Padding (top & bottom)', 'Section Control', 'wpb-plugins' ),
'type' => Elementor\Controls_Manager::SELECT,
'options' => [
'default' => _x( 'Default', 'Section Control', 'wpb-plugins' ),
<div class="form-group">
[text* name class:form-control placeholder "Your name"]
<div class="form-grad-border"></div>
</div>
<div class="form-group">
[email* email class:form-control placeholder "Your email"]
<div class="form-grad-border"></div>
</div>
<div class="form-group">
[text* subject class:form-control placeholder "Subject"]