Skip to content

Instantly share code, notes, and snippets.

View sh-sabbir's full-sized avatar

Sabbir Hasan sh-sabbir

View GitHub Profile
@sh-sabbir
sh-sabbir / app.css
Last active October 28, 2022 13:54
Multilevel menu with slide effect
.navi-mobile-menu {
display: block;
overflow-x: hidden;
overflow-y: auto;
position: relative;
height: calc(100vh - 100px);
width: 100%;
background: #FBF8EC;
font-family: 'Graphik';
font-weight: 700;
git config alias.change-commits '!'"f() { VAR=\$1; OLD=\$2; NEW=\$3; shift 3; git filter-branch --env-filter \"if [[ \\\"\$\`echo \$VAR\`\\\" = '\$OLD' ]]; then export \$VAR='\$NEW'; fi\" \$@; }; f "
git change-commits GIT_AUTHOR_NAME "<Old Name>" "<New Name>" -f
git change-commits GIT_AUTHOR_EMAIL <old@email.com> <new@email.com> -f
git change-commits GIT_COMMITTER_NAME "<Old Name>" "<New Name>" -f
git change-commits GIT_COMMITTER_EMAIL <old@email.com> <new@email.com> -f
@sh-sabbir
sh-sabbir / search_sorting_logic.php
Created August 10, 2022 15:19
Group and sort search result based on CTP
<?php
$search_query = new WP_Query(
array(
's' => get_search_query(),
'paged' => $paged,
'post_status' => 'publish'
)
);
// Set CTP priority here. First comes first shows
@sh-sabbir
sh-sabbir / wc_order_id_in_checkout.php
Last active July 3, 2022 03:16
WooCommerce: Get order_id for existing order in checkout page
<?php
/*
* Context:
* Sometime we may need to get the `order_id` in checkout page. When redirecting from `order-pay` you can grab it from `query_var`. But as soon as you reload the page it's lost.
*/
// You can access it from WooCommerce Session. For pending order there is a key named `order_awaiting_payment` in WooCommerce Session.
// Method 1: using `WC_Session_Handler`
$wc_session = new WC_Session_Handler();
var tables = document.getElementsByClassName('geotable');
var data = {};
for (var i = 0; i < tables.length; i++) {
var rows = tables.item(i).rows;
var localArray = [];
for (j = 0; j < rows.length; j++){
var oCells = rows.item(j).cells;
@sh-sabbir
sh-sabbir / functions.php
Created May 10, 2021 17:03
Elementor Widget category re-order
<?php
function add_elementor_widget_categories( $elements_manager ) {
$categories = [];
$categories['oceanic'] =
[
'title' => 'Oceanic Widgets',
'icon' => 'fa fa-plug'
];
@sh-sabbir
sh-sabbir / _iphone_mixin.scss
Last active June 24, 2020 17:21
iphone all devices media query mixins. Last thing you will ever need.
// iphone XPro Max
@mixin ipxm-p {
/* iPhone XPro Max portrait */
@media only screen and (min-device-width: 414px) and (max-device-width: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait) {
@content;
}
}
@mixin ipxm-l {
/* iPhone XPro Max landscape */
//Modify this function only
function countries() {
$args = array(
'post_type' => 'country', //change as needed
'post_status' => 'publish',
'posts_per_page' => -1);
$slugs = array();
$countries = new WP_Query( $args );
<?php
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
<?php
/***
* This simple utf-8 word count function (it only counts)
* is a bit faster then the one with preg_match_all
* about 10x slower then the built-in str_word_count
*
* If you need the hyphen or other code points as word-characters
* just put them into the [brackets] like [^\p{L}\p{N}\'\-]
* If the pattern contains utf-8, utf8_encode() the pattern,