Skip to content

Instantly share code, notes, and snippets.

Avatar

Muhammad Saqib Sarwar saqibsarwar

View GitHub Profile
@saqibsarwar
saqibsarwar / replace-property-slug-with-id-in-url.php
Created Sep 22, 2020
Replace Property Slug in URL with Property ID
View replace-property-slug-with-id-in-url.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 / functions.php
Last active Mar 4, 2019
add new enquiry support to Real Homes CRM
View functions.php
function add_new_enquiry_support( $args ) {
$args['capabilities'] = array(
'create_posts' => true,
);
return $args;
}
add_filter( 'recrm_enquiry_post_type_args', 'add_new_enquiry_support' );
@saqibsarwar
saqibsarwar / functions.php
Created Feb 26, 2019
Add Post Views Counter Colunn to Properties
View functions.php
function add_property_views_column( $columns ) {
$columns['post_views'] = '<span class="dash-icon dashicons dashicons-chart-bar" title="' . __( 'Post Views', 'framework' ) . '"></span><span class="dash-title">' . __( 'Post Views', 'framework' ) . '</span>';
return $columns;
}
add_filter( 'manage_edit-property_columns', 'add_property_views_column', PHP_INT_MAX );
@saqibsarwar
saqibsarwar / change-log.txt
Last active Sep 18, 2021
Real Homes Change Log
View change-log.txt
Change Log - Real Homes Theme
=============================
-----------------------------------------------
VERSION 3.15.1 – UPDATED ON 19th September 2021
-----------------------------------------------
Refined styles and fixed few bugs reported after last update.
-----------------------------------------------
VERSION 3.15.0 – UPDATED ON 14th September 2021
View gutenberg-sample-content.html
<!-- wp:paragraph {"align":"center","textColor":"heading-link-color-mako","customBackgroundColor":"#e8eaeb","fontSize":"large"} -->
<p style="background-color:#e8eaeb;text-align:center" class="has-text-color has-background has-large-font-size has-heading-link-color-mako-color"><strong>Gutenberg Sample Content</strong></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>
@saqibsarwar
saqibsarwar / functions.php
Created Aug 30, 2018
Adding REST API Support for Property CPT and Related Taxonomies
View functions.php
/**
* Add REST API support for property
*/
add_action( 'init', 'property_rest_support', 25 );
function property_rest_support() {
global $wp_post_types;
$post_type_name = 'property';
if( isset( $wp_post_types[ $post_type_name ] ) ) {
$wp_post_types[$post_type_name]->show_in_rest = true;
@saqibsarwar
saqibsarwar / functions.php
Created Sep 28, 2017
Load trnalstion from child theme for Real Homes
View functions.php
if ( !function_exists( 'inspiry_load_translation_from_child' ) ) {
/**
* Load translation files from child theme
*/
function inspiry_load_translation_from_child() {
load_child_theme_textdomain ( 'framework', get_stylesheet_directory () . '/languages' );
}
add_action ( 'after_setup_theme', 'inspiry_load_translation_from_child' );
@saqibsarwar
saqibsarwar / property-slider.php
Created Sep 1, 2016
temp solution for WPML clients with no workflow
View property-slider.php
global $post;
$inspiry_current_property_id = $post->ID;
// if WPML is being used
if ( function_exists( 'wpml_get_default_language_filter' ) ) {
$our_default_language = apply_filters( 'wpml_default_language', null );
// Get the original property id to display gallery images properly
$inspiry_current_property_id = apply_filters( 'wpml_object_id', $inspiry_current_property_id, 'property', true, $our_default_language );
}
View add_google_maps_key.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 google_maps_api_key.php
/* Google Maps API Key */
$wp_customize->add_setting( 'inspiry_google_maps_api_key', array(
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'inspiry_google_maps_api_key', array(
'label' => __( 'Google Maps API Key', 'framework' ),
'type' => 'text',
'section' => 'inspiry_misc_section',
) );