Skip to content

Instantly share code, notes, and snippets.

View ahmadthedev's full-sized avatar

Muhammad Ahmad ahmadthedev

View GitHub Profile
function subMenuSlide() {
if( jQuery('#menu-mega-menu li').hasClass('menu-item-has-children') ) {
jQuery('.menu-item-has-children').append( "<svg viewBox='0 0 140 140' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><g><path d='m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2 1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z' fill='black'/></g></svg>" );
}
jQuery('li.menu-item-has-children > svg').click(function() {
$parent = jQuery(this).parent().closest('li.menu-item-has-children');
if( !$parent.hasClass('child-menu-open') ) {
$parent.addClass('child-menu-open');
} else {
$parent.removeClass('child-menu-open');
<?php
add_action('restrict_manage_posts','ahmeddev125_restrict_properties', 10, 2);
function ahmeddev125_restrict_properties( $post_type, $which ) {
if( 'properties' !== $post_type ) {
return;
}
$taxonomies = array('states', 'counties');
foreach( $taxonomies as $tax_slug ) {
@ahmadthedev
ahmadthedev / post-read-time.php
Last active November 24, 2021 23:11
Post Read Time
<?php
// Reading Time
function dv_reading_time( $post ) {
$mycontent = $post->post_content;
$word = str_word_count(strip_tags($mycontent));
$m = floor($word / 200);
// $s = floor($word % 200 / (200 / 60));
$est = $m . 'm read';
return $est;
}
@ahmadthedev
ahmadthedev / post-publish-time.php
Last active November 24, 2021 23:10
Post Publish Time in (Year, Month, Week, Day, Hour, Minute, Second)
<?php
// Time Function
function time_elapsed_string($datetime, $full = false) {
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
@ahmadthedev
ahmadthedev / wp-admin-panel-search-posts.php
Last active November 24, 2021 23:10
WordPress Admin Panel search posts with custom post meta values along with title
<?php
// WordPress Admin Panel search posts with custom post meta values along with title
if (!function_exists('ahmeddev125_extend_admin_search')) {
add_action('admin_init', 'ahmeddev125_extend_admin_search');
/**
* hook the posts search if we're on the admin page for our type
*/