Skip to content

Instantly share code, notes, and snippets.

View Rupashdas's full-sized avatar
🏠
Working from home

Rupash Das Rupashdas

🏠
Working from home
  • Chittagong, Bangladesh
View GitHub Profile
@font-face {
font-family: "freight-sans-pro";
src: url("https://use.typekit.net/af/442215/000000000000000000010b5a/27/l?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n4&v=3") format("woff2"),
url("https://use.typekit.net/af/442215/000000000000000000010b5a/27/d?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n4&v=3") format("woff"),
url("https://use.typekit.net/af/442215/000000000000000000010b5a/27/a?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n4&v=3") format("opentype");
font-display: auto;
font-style: normal;
font-weight: 400;
font-stretch: normal;
}
function countDown(selector) {
var countDownElement = $(selector);
var startAt = parseFloat(countDownElement.attr('start-at'));
var endAt = parseFloat(countDownElement.attr('end-at'));
var animationDuration = parseFloat(countDownElement.attr('animation-duration').replace('ms', ''));
var currentValue = startAt;
var interval = 50;
var steps = (startAt - endAt) / (animationDuration / interval);
var timer = setInterval(function () {
currentValue -= steps;
<?php
function rl_cold_next_post_id( $post_id, $post_type ) {
global $post;
$oldGlobal = $post;
$post = get_post( $post_id );
$previous_post = get_previous_post();
$post = $oldGlobal;
if($previous_post == ""){
return rl_cold_new_post_id($post_type);
}
<?php
function terrawise_exclude_first_post_from_query($query) {
if (!is_admin() && $query->is_main_query() && (is_home() || is_category())) {
if (!$query->get('exclude_first_post')) {
$first_post = get_posts(array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
));
if (!empty($first_post)) {
<script>
(function($){
$(document).ready(function(){
$('#divisiondiv .selectit').on('click', function(event){
var targetElement = event.target;
if($(targetElement).prop("tagName") == 'INPUT'){
var elements = $('#divisiondiv .selectit').find('input[type="checkbox"]');
$(elements).each(function(){
if(targetElement != this){
<?php
function devrupash_customize_init(){
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
}
// Remove comments metabox from dashboard
<?php
// 1.Write a PHP function to sort an array of strings by their length, in ascending order.
function sort_strings_by_length($arrayItem) {
usort($arrayItem, function($a, $b) {
return strlen($a) - strlen($b);
});
return $arrayItem;
}
$strings = array("apple", "banana", "cherry", "date", "elderberry");
$sorted_strings = sort_strings_by_length($strings);
<?php
class MarkSocialIcons_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
public function __construct() {
parent::__construct(
'tb_social_icons', // Base ID
function infiniteInit(articleWrap, append, paginationWrap, loadMore){
let infiniteWrap = $(articleWrap);
infiniteWrap.infiniteScroll({
path: paginationWrap + ' .next',
append: articleWrap + " " + append,
button: loadMore,
history: false,
scrollThreshold: false,
hideNav: paginationWrap,
});
<?php
function get_menu_items_by_registered_slug($menu_slug) {
$menu_items = array();
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_slug ] ) ) {
$menu = get_term( $locations[ $menu_slug ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
}
return $menu_items;
}