-
-
Save hostz-frank/a9e95be476508738b7ba to your computer and use it in GitHub Desktop.
<?php | |
/* | |
Plugin Name: Fusion Core on Events | |
Description: Enables the ThemeFusion Core page builder on post type "tribe_events" of The Events Calendar | |
*/ | |
defined( 'ABSPATH' ) OR die(); | |
/** | |
* Enable Fusion Pagebuilder for post type "tribe_events" (The Events Calendar). | |
*/ | |
add_action ( 'plugins_loaded', function () { | |
remove_action( 'plugins_loaded', array( 'Fusion_Core_PageBuilder', 'get_instance' ) ); | |
if( ! get_option( 'avada_disable_builder' ) ) { | |
if ( is_admin() ) { | |
require_once( WP_PLUGIN_DIR . '/fusion-core/admin/class-pagebuilder.php' ); | |
require_once( WP_PLUGIN_DIR . '/fusion-core/admin/page-builder/classes/class-ui.php' ); | |
$instance = Fusion_Core_PageBuilder::get_instance(); | |
$instance->allowed_post_types[] = 'tribe_events'; | |
$ui = Fusion_Core_PageBuilder_UI::get_instance(); | |
$ui->settings['allowed_post_types'][] = 'tribe_events'; | |
} | |
} | |
}, 9); // priority 9 to be called before the line of fusion-core.php |
If you want your Fusion Builder to support even more Custom Post Types (aka CPT), e.g. such of other plugins (I'll show it below for WooCommerce products as an example), then for each CPT, in the code above, replace this line:
$instance->allowed_post_types[] = 'tribe_events';
with these 2 lines:
$instance->allowed_post_types[] = 'tribe_events';
$instance->allowed_post_types[] = 'product';
and additionally replace this line:
$ui->settings['allowed_post_types'][] = 'tribe_events';
with these 2 lines of code:
$ui->settings['allowed_post_types'][] = 'tribe_events';
$ui->settings['allowed_post_types'][] = 'product';
You grab the name of a CPT of any plugin by scanning the plugin's PHP files for the function "register_post_type()". The first appearing parameter after the opening parantheses ist the name you need.
But be aware that the Builder acts on WordPress "content" only. So if the template of your post type has a sidebar you'll never be able to influence the sidebar by the Fusion Builder but only the "content" section. This means that using the F. Builder on CPT's probably needs to be integrated with the templates of your custom post post type.
And I guess this is the reason why the F. Builder cannot be activated for any custom post type you wish - this would shoot back with a flood of support requests to the Avada guys.
Thanks for this snippet! As you already mentioned - it will be hard for them to integrate it into their core, but they should at least offer an optional setting for people who are not that used to code.
Hi, i put this code in functions.php but doest work, can u say me where i need put this code?
Thanks in advance
Hello,
Can you update this to last version of Avada ?!
regards
For an English version see next comment!
Will man den Fusion-Builder für weitere Custom Post Types anderer Plugins angezeigt haben (z.B. wie unten gezeigt am Beispiel WooCommerce), dann je CPT jeweils unterhalb der folgenden Zeilen (aus dem obenstehenden Code) weitere hinzufügen. Also unterhalb von:
sowie
die folgende Zeilen für WooCommerce-Produkte setzen:
sowie
Den Namen des "Post Types" erfährt man, indem man im betreffenden Plugin nach "register_post_type" sucht. Der erste Parameter hinter der öffnenden Klammer ist, was hier benötigt wird.