Skip to content

Instantly share code, notes, and snippets.

Avatar

Muhammad Saqib Sarwar saqibsarwar

View GitHub Profile
@saqibsarwar
saqibsarwar / attached_pdf_to_downloadable_file.php
Created Sep 7, 2022
Download Monitor and WP ALL Import - Attach PDF files to download CPT to make them downloadable.
View attached_pdf_to_downloadable_file.php
<?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 Sep 5, 2022
Disable PHP Warnings while using WP CLI
View wp-config.php
// 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);
View wp-social-share.php
<?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
Frequently used NVM commands
View frequently-used-nvm-commands.txt
// 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
View wp-basic-cleanup.php
<?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
Replace Property Slug in URL with Property ID
View replace-property-slug-with-id-in-url.php
<?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 Jan 3, 2023
Real Homes Change Log
View change-log.txt
Change Log - Real Homes Theme
=============================
-----------------------------------------------
VERSION 4.0.0 – UPDATED ON 4th January 2023
-----------------------------------------------
Added - Completely NEW ULTRA DESIGN VARIATION
Added - New design Ultra demo import option
Added - Reviewer message on edit property page (backend)
Added - Responsive header color settings
@saqibsarwar
saqibsarwar / add_google_maps_key.php
Last active May 8, 2022
Add Google Maps API key to enqueued script in WordPress
View add_google_maps_key.php
<?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 );
View breadcrumbs-items-usage.php
<?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">
View get-breadcrumbs-items.php
<?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
*/