Skip to content

Instantly share code, notes, and snippets.

View saqibsarwar's full-sized avatar

Muhammad Saqib Sarwar saqibsarwar

View GitHub Profile
@saqibsarwar
saqibsarwar / attached_pdf_to_downloadable_file.php
Created September 7, 2022 18:02
Download Monitor and WP ALL Import - Attach PDF files to download CPT to make them downloadable.
<?php
// Start preparing an array to insert Download Monitor's Download Version (which is a CPT with Download as parent post).
$dlm_download_version = array(
'post_title' => 'Download #' . $download_id . ' File Version',
'post_type' => 'dlm_download_version',
'post_status' => 'publish',
'post_parent' => $download_id,
'post_author' => $attachment->post_author,
);
@saqibsarwar
saqibsarwar / wp-config.php
Created September 5, 2022 15:05
Disable PHP Warnings while using WP CLI
// Disable PHP warnings when running wp-cli
if ( ! defined( '$_SERVER["HTTP_HOST"]' ) ) {
define( 'WP_DEBUG', FALSE );
}
if ( ! defined( 'WP_DEBUG' ) ) {
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG_DISPLAY', false);
<?php
$url_encoded_title = urlencode_deep( get_the_title() );
?>
<a href="https://www.linkedin.com/sharing/share-offsite/?url=<?php the_permalink(); ?>"
title="<?php esc_attr_e( 'Share on LinkedIn', 'domain' ); ?>"
target="_blank">
<span class="icon-linkedin-square"></span>
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&t=<?php echo $url_encoded_title; ?>"
title="<?php esc_attr_e( 'Share on Facebook', 'domain' ); ?>"
@saqibsarwar
saqibsarwar / frequently-used-nvm-commands.txt
Last active May 8, 2022 17:56
Frequently used NVM commands
// check version
node -v || node --version
// list installed versions of node (via nvm)
nvm ls
// install specific version of node
nvm install 16
// set default version of node
<?php
// //remove emoji support
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
// // Remove rss feed links
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
@saqibsarwar
saqibsarwar / replace-property-slug-with-id-in-url.php
Last active May 8, 2022 18:13
Replace Property Slug in URL with Property ID
<?php
/**
* Add new rewrite for post type
* Add permalink structure
*/
function _post_type_rewrite() {
global $wp_rewrite;
// Set the query arguments used by WordPress
$queryarg = 'post_type=property&p=';
@saqibsarwar
saqibsarwar / change-log.txt
Last active November 18, 2024 13:44
Real Homes Change Log
Change Log - Real Homes Theme
=============================
---------------------------------------------
VERSION 4.3.5 – UPDATED ON 19th November 2024
---------------------------------------------
Added - Saved search functionality for non-logged in users
Added - Option to add a space before or after currency sign
Fixed - Pagination layout issue for modern grid properties listing
Fixed - Mapbox zoom not respecting customizer setting for property detail page
@saqibsarwar
saqibsarwar / add_google_maps_key.php
Last active May 8, 2022 18:16
Add Google Maps API key to enqueued script in WordPress
<?php
if ( ! function_exists( 'inspiry_google_maps_api_key' ) ) :
/**
* This function adds API key ( if provided in settings ) to google maps arguments
*/
function inspiry_google_maps_api_key( $google_map_arguments ) {
/* Get Google Maps API Key if available */
$google_maps_api_key = get_option( 'inspiry_google_maps_api_key' );
if ( ! empty( $google_maps_api_key ) ) {
$google_map_arguments[ 'key' ] = urlencode( $google_maps_api_key );
<?php
$breadcrumbs_taxonomy = get_option( 'theme_breadcrumbs_taxonomy' ); // get taxonomy from theme options
$inspiry_breadcrumbs_items = inspiry_get_breadcrumbs_items( $post->ID, $breadcrumbs_taxonomy, false );
$breadcrumbs_count = count( $inspiry_breadcrumbs_items );
if ( is_array( $inspiry_breadcrumbs_items ) && ( 0 < $breadcrumbs_count ) ) {
?>
<div class="page-breadcrumbs">
<nav class="property-breadcrumbs">
<?php
if ( ! function_exists( 'inspiry_get_breadcrumbs_items' ) ) :
/**
* Returns a array of breadcrumbs items
*
* @param $post_id int Post id
* @param $breadcrumbs_taxonomy string Taxonomy name
* @param $skip_home bool skip home entry or not
* @return mixed|void
*/