Skip to content

Instantly share code, notes, and snippets.

View mujahidi's full-sized avatar

Mujahid Ishtiaq mujahidi

  • Pakistan
  • 07:04 (UTC +05:00)
View GitHub Profile
@mujahidi
mujahidi / functions.php
Created April 11, 2023 15:19
READ MORE LESS BUTTON SHORTCODE
<?php
add_shortcode('read_more_less', 'read_more_less_button_handler');
function read_more_less_button_handler( $attrs, $content ){
$title = $attrs['title'];
if( !$title )
$title = "Learn More";
return '
<div class="readmorelessbutton-container">
@mujahidi
mujahidi / index.html
Created July 20, 2022 15:00
MP4 Full Width Video Wrapper
<!-- Change POSTER, MP4_URL, WEBM_URL and OGG_URL -->
<!-- Might need to add some height to main element -->
<div class="video-hero jquery-background-video-wrapper demo-video-wrapper">
<video class="jquery-background-video" autoplay muted loop poster="POSTER">
<source src="MP4_URL" type="video/mp4">
<source src="WEBM_URL" type="video/webm">
<source src="OGG_URL" type="video/ogg">
</video>
<div class="video-hero--content"></div>
</div>
@mujahidi
mujahidi / function.php
Last active July 13, 2022 16:00
Add new fields to WC admin Page Setup
<?php
// Admin -> WC -> Settings -> Advanced -> Page Setup
add_filter( 'woocommerce_settings_pages' , 'add_new_woocommerce_settings_pages' );
function add_new_woocommerce_settings_pages( $settings ){
$new_pages = array();
foreach( $settings as $s ){
if( $s['id'] == 'advanced_page_options' ){
$new_pages[] = array(
@mujahidi
mujahidi / functions.php
Created November 29, 2021 12:53
Jump to specific page in Gravity Forms multi-page form
<?php
// ONLY FOR TESTING
add_filter("gform_pre_render", "gform_skip_page");
function gform_skip_page($form) {
if(!rgpost("is_submit_{$form['id']}") && rgget('form_page'))
GFFormDisplay::$submission[$form['id']]["page_number"] = rgget('form_page');
return $form;
}
<?php
add_filter( 'posts_search', 'm_cars_search_vin' );
function m_cars_search_vin( $where ) {
global $pagenow, $wpdb, $wp;
// check if we are on the right page & performing a search & for the right post type
if ( 'edit.php' != $pagenow || ! is_search() || ! isset( $wp->query_vars['s'] ) || 'cars' != $wp->query_vars['post_type'] ) {
return $where;
@mujahidi
mujahidi / vimeo-video.html
Last active November 23, 2021 21:06
Vimeo background video inside container
<div class="video-container">
<div class="another-container">
<iframe src="https://player.vimeo.com/video/VIMEO-ID?background=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
<style>
.video-container{ height: 550px; overflow: hidden; }
.another-container{ height:0; overflow:hidden; position: relative; padding-bottom: 56.25%; /* 16:9 */ }
#mobile_video_container iframe{
@mujahidi
mujahidi / acf-user-field-type.php
Created May 6, 2020 17:09
Querying posts by ACF User field type
<?php
$search_value = 'xyz'; // whatever
$field_value = sprintf( '^%1$s$|s:%2$u:"%1$s";', $search_value, strlen( $search_value ) );
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'user_field',
'value' => $field_value,
@mujahidi
mujahidi / functions.php
Created May 3, 2019 16:17
Remove class hook in WordPress
<?php
function remove_class_hook( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
global $wp_filter;
$is_hook_removed = false;
if ( ! empty( $wp_filter[ $tag ]->callbacks[ $priority ] ) ) {
$methods = wp_list_pluck( $wp_filter[ $tag ]->callbacks[ $priority ], 'function' );
$found_hooks = ! empty( $methods ) ? wp_list_filter( $methods, array( 1 => $method_name ) ) : array();
foreach( $found_hooks as $hook_key => $hook ) {
if ( ! empty( $hook[0] ) && is_object( $hook[0] ) && get_class( $hook[0] ) === $class_name ) {
@mujahidi
mujahidi / responsive-images.css
Created March 26, 2019 20:51
Responsive Images
.myImg {
object-fit: cover; /* also works for videos. Can also use contain*/
width: 320px;
height: 180px;
}
/* The Netflix Way */
/*
this one works everywhere and it is my favorite! You’ll need to wrap your image with a relative padded parent.
@mujahidi
mujahidi / bitnami-fix-cache.txt
Created February 13, 2019 15:33
FIX BITNAMI WEIRD CACHE ISSUE:
FIX BITNAMI WEIRD CACHE ISSUE:
1)Comment out these lines in /opt/bitnami/apache2/conf/httpd.conf using # in front of these 2:
Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf
2) PHP has Op Cache enabled by these lines in sudo nano /opt/bitnami/php/etc/php.ini
opcache.enable=1