Skip to content

Instantly share code, notes, and snippets.

View the-sufi's full-sized avatar
🏠
Working from home

the-sufi

🏠
Working from home
View GitHub Profile
@the-sufi
the-sufi / wp-disable_plugin_deactivation.php
Created July 30, 2021 02:00
WordPress - Disable option to deactivate Plugin
<?php
/**
* Disable option to deactivate Plugin
*
* @param $actions
* @param $plugin_file
* @param $plugin_data
* @param $context
* @return mixed
*/
@the-sufi
the-sufi / wp-remove-guttenburg-block-css.php
Created January 5, 2021 11:38
Remove Gutenberg Block Library CSS from loading on the frontend
<?php
/**
* Remove Gutenberg Block Library CSS from loading on the frontend
*/
function dctit_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-block-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'dctit_remove_wp_block_library_css', 100 );
@the-sufi
the-sufi / wp-remove-visual-composer-shortcode-from-relevanssi-search-result.php
Created October 6, 2020 04:03
Remove Visual Composer shortcodes from Relevanssi search result
<?php
/**
* When using relevanssi search with visual composer, search results come with some vc_* shortcode.
* Relevanssi by default removes some of the shortcodes. Sometimes theme also include some custom vc shorttcode.
* This code will remove all of those unwanted vc_* shortcodes from search result.
*
* Goes inside functions.php of active theme
*/
add_filter( 'relevanssi_pre_excerpt_content', 'dctit_vc_filtered_content', 99 );
add_filter( 'relevanssi_post_content', 'dctit_vc_filtered_content', 99 );
@the-sufi
the-sufi / wp-acf-overcome-draft-preview-issue.php
Last active August 25, 2020 15:09
ACF fields don't show up when previewing draft posts. This is an ugly hack to try and overcome that situation.
<?php
/**
* ACF fields don't show up when previewing draft posts. This is an ugly hack to try and overcome that situation.
*/
function dctit_hack_preview() {
$post_types = array ( 'post', 'page' );//add/edit/delete post types as needed
global $post;
if ( !in_array( $post->post_type, $post_types ) ) {
return;
@the-sufi
the-sufi / whmcs-show-credit-balance.php
Last active May 8, 2024 15:49
WHMCS Show Credit Balance on side panel/sidebar
<?php
/**
* code goes inside "includes/hooks" directory
*/
//for customizing nav menu items
use WHMCS\View\Menu\Item as MenuItem;
//for interacting with DB
use Illuminate\Database\Capsule\Manager as Capsule;
@the-sufi
the-sufi / whmcs-remove-announcements-from-clientarea-homepage.php
Last active May 29, 2023 14:16
WHMCS Remove Announcements from clientarea homepage
<?php
/**
* code goes inside "includes/hooks" directory
*/
/**
* Remove Announcements from homepage
*/
function dctit_remove_announcements_from_homepage( $home_page_panels) {
$home_page_panels->removeChild('Recent News');
@the-sufi
the-sufi / whmcs-oldest-ticket-reply-first.php
Last active June 17, 2020 23:13
WHMCS Client Area Ticket View - Show Oldest Reply First
<?php
/**
* code goes inside "includes/hooks" directory
*/
/**
* Client Area Ticket View - Show Oldest Reply First
* @param $vars
* @return array
*/
@the-sufi
the-sufi / wp-custom-search-url.php
Created June 17, 2020 23:02
Change WordPress default search URL
<?php
/*
* Modify Default Search URL
* old url: domain.com?s=[search_term]
* new url: domain.com/search/[search_term]
*/
function dctit_change_search_url() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
exit();
@the-sufi
the-sufi / wp-hide-youtube-related-videos.php
Created June 17, 2020 22:56
Hide Youtube related videos from other channels - WP oEmbed
@the-sufi
the-sufi / wp-hide-acf-menu.php
Last active July 30, 2021 01:56
Hide ACF menu from WP Admin
<?php
/**
* Hide ACF
*/
//hides settings icon from editor screen
function dctit_no_acf_icon() {
echo '<style>.acf-postbox:hover > .hndle .acf-hndle-cog {display: none !important;}.acf-postbox > .hndle:hover .acf-hndle-cog, .acf-postbox > .postbox-header:hover .acf-hndle-cog {display: none !important;}</style>';
}
add_action('admin_footer', 'dctit_no_acf_icon');