Skip to content

Instantly share code, notes, and snippets.

View aslamdoctor's full-sized avatar
💭
Always working but happy to talk 👍

Aslam Doctor aslamdoctor

💭
Always working but happy to talk 👍
View GitHub Profile
@aslamdoctor
aslamdoctor / package.json
Created August 26, 2022 06:45
Very simple SASS based Project
{
"scripts": {
"build": "npm run sass:dev && npm run postcss:build",
"dev": "npm run sass:dev && npm run postcss:dev",
"watch": "onchange \"assets/scss/**/*.scss\" -- npm run dev",
"sass:dev": "sass assets/scss/custom.scss assets/css/custom.css",
"postcss:dev": "postcss assets/css/custom.css --use=autoprefixer --output=assets/css/custom.css",
"postcss:build": "postcss assets/css/custom.css --use=autoprefixer --use cssnano --output=assets/css/custom.css"
},
"browserslist": [
@aslamdoctor
aslamdoctor / slick-pause-video.js
Created August 15, 2022 14:55
Slick Carousel : Pause YouTube video on slide change
// Pause video when slick slide changed
$('.act-hero-carousel .the-carousel.carousel-1').on(
'beforeChange',
function (slick, currentSlide, nextSlide) {
var player, command;
//find the current slide element and decide which player API we need to use.
currentSlide = $('.act-hero-carousel .the-carousel.carousel-1').find(
'.slick-current'
@aslamdoctor
aslamdoctor / _skip-navigation.scss
Created July 7, 2022 16:22
WCAG : Skip to Navigation Styling
ul.skip-navigation {
@include reset_ul;
li {
a {
position: absolute;
z-index: 10;
left: 0px;
top: -30px;
color: $black;
@aslamdoctor
aslamdoctor / wordpress-transient-api-example.php
Created June 11, 2022 03:29
Snippet : WordPress Transient API Usage Example
<?php
// Get only those services that has people assigned and store them into cache
if ( false === ( $available_services_array = get_transient( 'available_services_array' ) ) ) {
$available_services_array = array();
$services = new WP_Query(
array(
'post_type' => array( 'service' ),
'posts_per_page' => '500',
'post_status' => array( 'publish' ),
'order' => 'ASC',
@aslamdoctor
aslamdoctor / wordpress-debug-ajax.php
Created June 8, 2022 07:46
Snippet : Debug ajax response by calling it from browser url
<?php
add_action( 'wp_ajax_testttt', 'testttt' );
function testttt() {
$our_people = new WP_Query(
array(
'post_type' => array( 'people' ),
'posts_per_page' => '4',
'post_status' => array( 'publish' ),
'orderby' => 'rand',
'meta_query' => array(
@aslamdoctor
aslamdoctor / wordpress-social-share.php
Last active June 6, 2022 13:48
Snippet : Social sharing links for WordPress Single Post
<ul class="sharing-links">
<li>
<a href="javascript:window.open('https://www.linkedin.com/cws/share?url=<?php the_permalink(); ?>', 'linkedin_share', 'height=320, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');"><span class="sr-only">Share on LinkedIn</span><i class="fab fa-linkedin-in"></i></a>
</li>
<li>
<a href="javascript:window.open('http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&amp;t=<?php echo urlencode(get_the_title()); ?>', 'facebook_share', 'height=320, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');"><span class="sr-only">Share on Facebook</span><i class="fab fa-facebook-f"></i></a>
</li>
<li>
<a href="javascript:window.open('http://twitter.com/share?url=<?php the_permalink(); ?>', 'twitter_share', 'height=320, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');"><span class="sr-only">Share on
@aslamdoctor
aslamdoctor / gist:8b3f1e5b80a568aa47376ffec6d3b5d3
Last active May 25, 2022 12:06
Compress video for Web using ffmpeg
@aslamdoctor
aslamdoctor / wordpress-youtube-vimeo-embed.php
Created March 16, 2022 08:08
Snippet : Get embed code from video url for youtube or vimeo
<?php
// ========= Get embed code from video url for youtube or vimeo =============
function wpmix_get_video_embed( $url ) {
$video_type = wpmix_get_video_type( $url );
if ( $video_type == 'youtube' ) {
$video_id = wpmix_get_youtube_id( $url );
return '<div class="embed-responsive embed-responsive-16by9">
<iframe width="1268" height="713" src="https://www.youtube.com/embed/' . $video_id . '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>';
} elseif ( $video_type == 'vimeo' ) {
@aslamdoctor
aslamdoctor / woocommerce-delete-failed-orders.sql
Last active April 16, 2024 00:40
WooCommerce : Delete all failed orders
-- Below queries are just to check the failed order records:
SELECT * FROM `wp_woocommerce_order_itemmeta` WHERE order_item_id IN (SELECT order_item_id FROM `wp_woocommerce_order_items` WHERE order_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND post_status='wc-failed'))
SELECT * FROM `wp_woocommerce_order_items` WHERE order_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND post_status='wc-failed')
SELECT * FROM wp_comments WHERE comment_type = 'order_note' AND comment_post_ID IN(SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND post_status='wc-failed')
SELECT * FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND post_status='wc-failed')
@aslamdoctor
aslamdoctor / woocommerce-product-image-alt-text.php
Created January 25, 2022 08:48
Woocommerce : Change image alt text to product name
<?php
/**
* Change image alt text to product name
*/
add_filter('wp_get_attachment_image_attributes', 'wpmix_attachement_image_attributes', 20, 2);
function wpmix_attachement_image_attributes( $attr, $attachment ){
// Get post parent
$parent = get_post_field( 'post_parent', $attachment);