• 1.
    add_filter( 'render_block', function( $html, $block ) {
  • 2.
    	/*********************************************************/
  • 3.
    	/**Post Type - add custom datas into block.gb-post-tags**/
  • 4.
    	/*******************************************************/	
  • 5.
    	if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-post-tags' ) !== false ) {
  • 6.
    	
  • 7.
    // load all 'category' terms for the post
  • 8.
    global $post;
  • 9.
    $cats = get_the_terms( get_the_ID(), 'category');
  • 10.
    $tags = get_the_tags($post->ID);			
  • 11.
    $prox = get_field('post_proximity_cpg');
  • 12.
     
  • 13.
    	 $html .="<div class='tags'><span class='post-cat'>";
  • 14.
    		// we will use the first term to load ACF data from
  • 15.
    		if( !empty($cats) ) {
  • 16.
    			$cat = array_pop($cats);
  • 17.
    			$imgcat = get_field('postcat_featured', $cat );
  • 18.
    			
  • 19.
    			$html .= $imgcat . esc_html( $cat->name );
  • 20.
    			/*if (get_field('post_proximity_cpg')) {
  • 21.
    				$html .= $cat_img . esc_html( $term->name );
  • 22.
    			}
  • 23.
    			$html .= esc_html( $term->name );*/
  • 24.
    		}
  • 25.
    		$html .="</span>";
  • 26.
    		
  • 27.
    		if (! empty( $tags )) {
  • 28.
    			$html .= "<span class='post-tag'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'><path d='M168.3 499.2C116.1 435 0 279.4 0 192C0 85.96 85.96 0 192 0C298 0 384 85.96 384 192C384 279.4 267 435 215.7 499.2C203.4 514.5 180.6 514.5 168.3 499.2H168.3zM192 256C227.3 256 256 227.3 256 192C256 156.7 227.3 128 192 128C156.7 128 128 156.7 128 192C128 227.3 156.7 256 192 256z'/></svg>"; 
  • 29.
    			$html .= $tags[0]->name;
  • 30.
    			$html .= "</span>";
  • 31.
    		}
  • 32.
    		
  • 33.
    		 if (! empty( $prox )) {
  • 34.
    			 $html .="<span class='proximity'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'><path d='M256 96C256 113.7 270.3 128 288 128C305.7 128 320 113.7 320 96V32H394.8C421.9 32 446 49.08 455.1 74.63L572.9 407.2C574.9 413 576 419.2 576 425.4C576 455.5 551.5 480 521.4 480H320V416C320 398.3 305.7 384 288 384C270.3 384 256 398.3 256 416V480H54.61C24.45 480 0 455.5 0 425.4C0 419.2 1.06 413 3.133 407.2L120.9 74.63C129.1 49.08 154.1 32 181.2 32H255.1L256 96zM320 224C320 206.3 305.7 192 288 192C270.3 192 256 206.3 256 224V288C256 305.7 270.3 320 288 320C305.7 320 320 305.7 320 288V224z'/></svg>";
  • 35.
    			 $html .= $prox .  esc_html( 'km', 'psj_global' ) ; 
  • 36.
    			 $html .="<span>";
  • 37.
    		 }
  • 38.
    		
  • 39.
    		$html .="</div>";
  • 40.
    		
  • 41.
    	} 
  • 42.
    	/****************************************/
  • 43.
    	/** Locatif Post Type - gb-loc-people **/
  • 44.
    	/**************************************/
  • 45.
    if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-people' ) !== false ) {
  • 46.
    		 $html .="<div class='loc-tips'>";
  • 47.
    		 $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M224 256c70.7 0 128-57.31 128-128s-57.3-128-128-128C153.3 0 96 57.31 96 128S153.3 256 224 256zM274.7 304H173.3C77.61 304 0 381.6 0 477.3c0 19.14 15.52 34.67 34.66 34.67h378.7C432.5 512 448 496.5 448 477.3C448 381.6 370.4 304 274.7 304z'/></svg></span>";
  • 48.
    		$html .="<span class='desc'>" . get_field('loc_people') . esc_html( ' people', 'psj_global' ); "</span>";
  • 49.
    		$html .="</div>";
  • 50.
    	}
  • 51.
    	/*****************************************/
  • 52.
    	/** Locatif Post Type - gb-loc-surface **/
  • 53.
    	/***************************************/	
  • 54.
    if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-surface' ) !== false ) {
  • 55.
    		 $html .="<div class='loc-tips'>";
  • 56.
    		 $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M0 0H512V512H0V0z'/></svg></span>";
  • 57.
    		$html .="<span class='desc'>" . get_field('loc_surface') . esc_html( ' m²', 'psj_global' ); "</span>";
  • 58.
    		$html .="</div>";
  • 59.
    	}	
  • 60.
    	/***************************************/
  • 61.
    	/** Locatif Post Type - gb-loc-rooms **/
  • 62.
    	/*************************************/
  • 63.
    if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-rooms' ) !== false ) {
  • 64.
    		 $html .="<div class='loc-tips'>";
  • 65.
    		 $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 512'><path d='M176 288C220.1 288 256 252.1 256 208S220.1 128 176 128S96 163.9 96 208S131.9 288 176 288zM544 128H304C295.2 128 288 135.2 288 144V320H64V48C64 39.16 56.84 32 48 32h-32C7.163 32 0 39.16 0 48v416C0 472.8 7.163 480 16 480h32C56.84 480 64 472.8 64 464V416h512v48c0 8.837 7.163 16 16 16h32c8.837 0 16-7.163 16-16V224C640 170.1 597 128 544 128z'/></svg></span>";
  • 66.
    		$html .="<span class='desc'>" . get_field('loc_rooms') . esc_html( ' rooms', 'psj_global' ); "</span>";
  • 67.
    		$html .="</div>";
  • 68.
    	}	
  • 69.
    	
  • 70.
    	return $html;
  • 71.
    }, 10, 2 );
  • 72.
     
add_filter( 'render_block', function( $html, $block ) { /*********************************************************/ /**Post Type - add custom datas into block.gb-post-tags**/ /*******************************************************/ if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-post-tags' ) !== false ) { // load all 'category' terms for the post global $post; $cats = get_the_terms( get_the_ID(), 'category'); $tags = get_the_tags($post->ID); $prox = get_field('post_proximity_cpg'); $html .="<div class='tags'><span class='post-cat'>"; // we will use the first term to load ACF data from if( !empty($cats) ) { $cat = array_pop($cats); $imgcat = get_field('postcat_featured', $cat ); $html .= $imgcat . esc_html( $cat->name ); /*if (get_field('post_proximity_cpg')) { $html .= $cat_img . esc_html( $term->name ); } $html .= esc_html( $term->name );*/ } $html .="</span>"; if (! empty( $tags )) { $html .= "<span class='post-tag'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'><path d='M168.3 499.2C116.1 435 0 279.4 0 192C0 85.96 85.96 0 192 0C298 0 384 85.96 384 192C384 279.4 267 435 215.7 499.2C203.4 514.5 180.6 514.5 168.3 499.2H168.3zM192 256C227.3 256 256 227.3 256 192C256 156.7 227.3 128 192 128C156.7 128 128 156.7 128 192C128 227.3 156.7 256 192 256z'/></svg>"; $html .= $tags[0]->name; $html .= "</span>"; } if (! empty( $prox )) { $html .="<span class='proximity'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'><path d='M256 96C256 113.7 270.3 128 288 128C305.7 128 320 113.7 320 96V32H394.8C421.9 32 446 49.08 455.1 74.63L572.9 407.2C574.9 413 576 419.2 576 425.4C576 455.5 551.5 480 521.4 480H320V416C320 398.3 305.7 384 288 384C270.3 384 256 398.3 256 416V480H54.61C24.45 480 0 455.5 0 425.4C0 419.2 1.06 413 3.133 407.2L120.9 74.63C129.1 49.08 154.1 32 181.2 32H255.1L256 96zM320 224C320 206.3 305.7 192 288 192C270.3 192 256 206.3 256 224V288C256 305.7 270.3 320 288 320C305.7 320 320 305.7 320 288V224z'/></svg>"; $html .= $prox . esc_html( 'km', 'psj_global' ) ; $html .="<span>"; } $html .="</div>"; } /****************************************/ /** Locatif Post Type - gb-loc-people **/ /**************************************/ if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-people' ) !== false ) { $html .="<div class='loc-tips'>"; $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M224 256c70.7 0 128-57.31 128-128s-57.3-128-128-128C153.3 0 96 57.31 96 128S153.3 256 224 256zM274.7 304H173.3C77.61 304 0 381.6 0 477.3c0 19.14 15.52 34.67 34.66 34.67h378.7C432.5 512 448 496.5 448 477.3C448 381.6 370.4 304 274.7 304z'/></svg></span>"; $html .="<span class='desc'>" . get_field('loc_people') . esc_html( ' people', 'psj_global' ); "</span>"; $html .="</div>"; } /*****************************************/ /** Locatif Post Type - gb-loc-surface **/ /***************************************/ if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-surface' ) !== false ) { $html .="<div class='loc-tips'>"; $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M0 0H512V512H0V0z'/></svg></span>"; $html .="<span class='desc'>" . get_field('loc_surface') . esc_html( ' m²', 'psj_global' ); "</span>"; $html .="</div>"; } /***************************************/ /** Locatif Post Type - gb-loc-rooms **/ /*************************************/ if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'gb-loc-rooms' ) !== false ) { $html .="<div class='loc-tips'>"; $html .="<span class='icon'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 512'><path d='M176 288C220.1 288 256 252.1 256 208S220.1 128 176 128S96 163.9 96 208S131.9 288 176 288zM544 128H304C295.2 128 288 135.2 288 144V320H64V48C64 39.16 56.84 32 48 32h-32C7.163 32 0 39.16 0 48v416C0 472.8 7.163 480 16 480h32C56.84 480 64 472.8 64 464V416h512v48c0 8.837 7.163 16 16 16h32c8.837 0 16-7.163 16-16V224C640 170.1 597 128 544 128z'/></svg></span>"; $html .="<span class='desc'>" . get_field('loc_rooms') . esc_html( ' rooms', 'psj_global' ); "</span>"; $html .="</div>"; } return $html; }, 10, 2 );

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter