Skip to content

Instantly share code, notes, and snippets.

View mujahidi's full-sized avatar

Mujahid Ishtiaq mujahidi

  • Pakistan
View GitHub Profile
@mujahidi
mujahidi / append-param.php
Created March 19, 2024 14:10
Pause video when jQuery SLICK slide changes
<?php
// append custom parameters to YouTube iframe to enable JS API
$custom_parameters = '&amp;rel=0&amp;enablejsapi=1';
// Append custom parameters to the src attribute of the iframe
$modified_iframe = preg_replace('/src="(.*?)"/', 'src="$1' . $custom_parameters . '"', $video_iframe);
// For Vimeo video, make sure to append ?api=1
@mujahidi
mujahidi / functions.php
Created October 19, 2023 15:42
Create Woocommerce custom email notification
<?php
$mailer = WC()->mailer();
$template = '/emails/customer-admin-order-status.php';
//format the email
$subject = 'Order Status Update';
$content = wc_get_template_html( $template, array(
'order' => $order,
@mujahidi
mujahidi / functions.php
Last active July 3, 2023 19:03
Multiple instances of same GF form on the same page
<?php
/**
* Multiple instances of same GF form on the same page
*/
add_filter( 'gform_get_form_filter_1', 'gform_get_form_filter_handler', 10, 2 );
add_filter( 'gform_confirmation_1', 'gform_get_form_filter', 10, 2 );
function gform_get_form_filter_handler( $form_string, $form ){
// if form has been submitted, use the submitted ID, otherwise generate a new unique ID
if ( isset( $_POST['gform_random_id'] ) ) {
$random_id = absint( $_POST['gform_random_id'] ); // Input var okay.
@mujahidi
mujahidi / _mixin.scss
Created April 18, 2023 19:05
SASS mixin
$imagePath: "assets/images";
$breakpoints: (
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px,
);
@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{