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 / index.html
Created October 5, 2022 02:37
Readmore.js Integration
<script src="https://cdnjs.cloudflare.com/ajax/libs/Readmore.js/2.0.2/readmore.min.js" integrity="sha512-llWtDR3k09pa9nOBfutQnrS2kIEG7M6Zm7RIjVVLNab1wRs8NUmA0OjAE38jKzKeCg+A3rdq8AVW41ZTsfhu5Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
@aslamdoctor
aslamdoctor / php-mysql-crud-class.php
Last active August 29, 2022 07:13
Very Simple CRUD Class using PHP
<?php
class CRUD {
protected $conn;
protected $tablename = 'MY_DEFAULT_TABLENAME';
function __construct() {
$this->conn = new mysqli( 'HOST', 'USERNAME', 'PASSWORD', 'DB_NAME' );
if ( $this->conn->connect_error ) {
die( $this->conn->connect_error );
@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' ) {