Skip to content

Instantly share code, notes, and snippets.

View hmowais's full-sized avatar
🎯
Focusing

HM Owais hmowais

🎯
Focusing
  • Karachi, Pakistan
View GitHub Profile
@hmowais
hmowais / .htaccess
Last active March 25, 2022 13:01
Htaccess Code for Page Speed
# Enable Image Expiry
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
@hmowais
hmowais / functions.php
Created March 3, 2022 11:02
Allow SVG File in WordPress
<?php
// Allow SVG
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
@hmowais
hmowais / functions.php
Created February 16, 2022 12:59
Popup show Gravity form Coupon Limit ::: Conditional :::
<?php
/* Popup */
function coupon_popup() {
global $wpdb;
$table_name = $wpdb->prefix . "gf_addon_feed";
$coupon = "gravityformscoupons";
$result = $wpdb->get_results( "SELECT * FROM $table_name WHERE addon_slug = '$coupon' " );
foreach($result as $couponData){
@hmowais
hmowais / functions.php
Created February 10, 2022 19:56
Show Blog Post by Category
<?php
global $post;
function blog_lists($atts) {
$a = shortcode_atts(['take' => 10, 'category' => 'uncategorized', 'sorted' => 'no', 'posts_per_page' => 10], $atts );
ob_start();
$count = 0;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = ['post_type' => 'post', 'posts_per_page' => 10,'paged' => $paged];
if ($a['category'] != 'all') {
@hmowais
hmowais / functions.php
Created January 27, 2022 13:36
Get Plugin Name :: Current Version :: latest Version
<?php
function getpluginVersion() {
$update_plugins = get_site_transient( 'update_plugins' );
$required_plugins = $update_plugins->response;
$current_plugins = $update_plugins->checked;
if ( ! empty( $required_plugins ) ) :
?>
<table>
@hmowais
hmowais / functions.php
Created January 22, 2022 07:40
Breadcrumbs Advance With Shortcode
function get_breadcrumb() { ?>
<div class="container-fluid breadcrumb">
<div class="container">
<div class="row">
<div class="py-1">
<?php echo do_shortcode('[custom_breadcrumbs]'); ?>
</div>
</div>
</div>
</div>
@hmowais
hmowais / functions.php
Created January 21, 2022 19:33
Breadcrumbs through Function
function get_breadcrumb() { ?>
<div class="container-fluid breadcrumb">
<div class="container">
<div class="row">
<div class="py-1">
<?php
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
if (is_category() || is_single()) {
echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
the_category(' &bull; ');
@hmowais
hmowais / functions.php
Created January 17, 2022 10:52
Get Data from Data Elements with Jquery
<script>
// Put the data attribute value in the box.
$(document).on('focus','.modal-toggle',function(){
$('.sp_title input').val($(this).data('package'));
$('.sp_price input').val($(this).data('price'));
$('.package_title').html($(this).data('package'));
$('.package_price').html($(this).data('price'));
});
</script>
@hmowais
hmowais / functions.php
Last active January 17, 2022 10:53
Popup as Shortcode [CPT]
<?php
/* Popup Shortcode */
function popup_shortcode() { ?>
<div class="mask" role="dialog"></div>
<?php $args = array(
'post_type' => 'packages',
'post_status' => 'publish',
'posts_per_page' => -1,
'order' => 'ASC'
@hmowais
hmowais / functions.php
Created January 10, 2022 08:05
Get Random Categories of Custom Post Type [Shortcode]
<?php
/* Random Categories */
function category_shortcode() {
ob_start();
$array = array(
'datasheet_category','infographic_category',
);
$taxonomy = array_rand($array);
$rand_taxonomy = $array[$taxonomy];