Last active
August 21, 2017 12:16
-
-
Save wpmudev-sls/f2dd4c89af9c38970d17f3b986891dea to your computer and use it in GitHub Desktop.
Show Custom Post Type in Upfront Layouts list. Upfront hides 'product' CPT as it relies to ecommerce plugin, this filter will show the CPT in Upfront Layouts list if the CPT was manually created and does not rely on an ecommerce plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: CPT in Upfront Layouts | |
Plugin URI: https://premium.wpmudev.org/ | |
Description: Display CPT in Upfront existing layouts list | |
Version: 1.0 | |
Author: Lindeni Mahlalela @ WPMUDEV | |
Author URI: https://premium.wpmudev.org/ | |
License: GPLv2 or later | |
*/ | |
//TAGS: Upfront, CPT, CustomPress, Upfront Layouts | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_filter('upfront-builder_skip_exported_layouts', 'ufb_unhide_product_cpt', 999, 2 ); | |
function ufb_unhide_product_cpt($default, $layout){ | |
$item = explode('-', $layout['item'] ); | |
$post_type = $item[1]; | |
$post_types = array('product'); //add other post types here | |
if ( post_type_exists ( $post_type ) && in_array( $post_type, $post_types ) ) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to reveal all hidden post types you only need to add them in the '$post_types' list like so:
$post_types = array('product', 'movies', 'etc');