get( 'status_fusion_slider' ) ) {
include_once FUSION_CORE_PATH . '/fusion-slider/class-fusion-slider.php';
}
}
// Setup Avada Slider.
add_action( 'after_setup_theme', 'setup_fusion_slider', 10 );
/**
* Find and include all shortcodes within shortcodes folder.
*
* @since 3.1
* @return void
*/
function fusion_init_shortcodes() {
if ( class_exists( 'Avada' ) ) {
$fusion_settings = awb_get_fusion_settings();
$filenames = glob( FUSION_CORE_PATH . '/shortcodes/*.php', GLOB_NOSORT );
foreach ( $filenames as $filename ) {
$info = pathinfo( $filename );
if ( 'fusion-portfolio' === $info['filename'] && '0' === $fusion_settings->get( 'status_fusion_portfolio' ) || 'fusion-faq' === $info['filename'] && '0' === $fusion_settings->get( 'status_fusion_faqs' ) ) {
continue;
}
require_once wp_normalize_path( $filename );
}
}
}
// Load all shortcode elements.
add_action( 'fusion_builder_shortcodes_init', 'fusion_init_shortcodes' );
/**
* Enable Avada Builder elements on activation.
*
* @access public
* @since 3.1
* @return void
*/
function fusion_core_enable_elements() {
if ( function_exists( 'fusion_builder_auto_activate_element' ) && version_compare( FUSION_BUILDER_VERSION, '1.0.6', '>' ) ) {
fusion_builder_auto_activate_element( 'fusion_portfolio' );
fusion_builder_auto_activate_element( 'fusion_faq' );
fusion_builder_auto_activate_element( 'fusion_fusionslider' );
fusion_builder_auto_activate_element( 'fusion_privacy' );
fusion_builder_auto_activate_element( 'fusion_tb_project_details' );
}
}
register_activation_hook( FUSION_CORE_MAIN_PLUGIN_FILE, 'fusion_core_activation' );
register_deactivation_hook( FUSION_CORE_MAIN_PLUGIN_FILE, 'fusion_core_deactivation' );
/**
* Runs on fusion core activation hook.
*/
function fusion_core_activation() {
// Reset patcher on activation.
fusion_core_reset_patcher_counter();
// Enable fusion core elements on activation.
fusion_core_enable_elements();
}
/**
* Runs on fusion core deactivation hook.
*/
function fusion_core_deactivation() {
// Reset patcher on deactivation.
fusion_core_reset_patcher_counter();
// Delete the option to flush rewrite rules after activation.
delete_option( 'fusion_core_flush_permalinks' );
}
/**
* Resets the patcher counters.
*/
function fusion_core_reset_patcher_counter() {
delete_site_transient( 'fusion_patcher_check_num' );
}
/**
* Add content filter if WPTouch is active.
*
* @access public
* @since 3.1.1
* @return void
*/
function fusion_wptouch_compatiblity() {
global $wptouch_pro;
if ( true === $wptouch_pro->is_mobile_device ) {
add_filter( 'the_content', 'fusion_remove_orphan_shortcodes', 0 );
}
}
add_action( 'wptouch_pro_loaded', 'fusion_wptouch_compatiblity', 11 );
/**
* Add custom thumnail column.
*
* @since 5.3
* @access public
* @param array $existing_columns Array of existing columns.
* @return array The modified columns array.
*/
function fusion_wp_list_add_column( $existing_columns ) {
if ( ! class_exists( 'Avada' ) ) {
return $existing_columns;
}
$columns = [
'cb' => $existing_columns['cb'],
'tf_thumbnail' => '' . esc_attr__( 'Image', 'fusion-core' ) . '',
];
return array_merge( $columns, $existing_columns );
}
// Add thumbnails to blog, Avada Slider and Elastic Slider.
add_filter( 'manage_post_posts_columns', 'fusion_wp_list_add_column', 10 );
add_filter( 'manage_slide_posts_columns', 'fusion_wp_list_add_column', 10 );
add_filter( 'manage_themefusion_elastic_posts_columns', 'fusion_wp_list_add_column', 10 );
/**
* Renders the contents of the thumbnail column.
*
* @since 5.3
* @access public
* @param string $column current column name.
* @param int $post_id cureent post ID.
* @return void
*/
function fusion_add_thumbnail_in_column( $column, $post_id ) {
if ( ! class_exists( 'Avada' ) ) {
return;
}
switch ( $column ) {
case 'tf_thumbnail':
echo '';
if ( has_post_thumbnail( $post_id ) ) {
echo get_the_post_thumbnail( $post_id, 'thumbnail' );
} else {
echo '
';
}
echo '';
break;
}
}
add_action( 'manage_post_posts_custom_column', 'fusion_add_thumbnail_in_column', 10, 2 );
add_action( 'manage_slide_posts_custom_column', 'fusion_add_thumbnail_in_column', 10, 2 );
add_action( 'manage_themefusion_elastic_posts_custom_column', 'fusion_add_thumbnail_in_column', 10, 2 );
/**
* Removes unregistered shortcodes.
*
* @access public
* @since 3.1.1
* @param string $content item content.
* @return string
*/
function fusion_remove_orphan_shortcodes( $content ) {
if ( false === strpos( $content, '[fusion' ) ) {
return $content;
}
global $shortcode_tags;
// Check for active shortcodes.
$active_shortcodes = ( is_array( $shortcode_tags ) && ! empty( $shortcode_tags ) ) ? array_keys( $shortcode_tags ) : [];
// Avoid "/" chars in content breaks preg_replace.
$unique_string_one = md5( microtime() );
$content = str_replace( '[/fusion_', $unique_string_one, $content );
$unique_string_two = md5( microtime() + 1 );
$content = str_replace( '/fusion_', $unique_string_two, $content );
$content = str_replace( $unique_string_one, '[/fusion_', $content );
if ( ! empty( $active_shortcodes ) ) {
// Be sure to keep active shortcodes.
$keep_active = implode( '|', $active_shortcodes );
$content = preg_replace( '~(?:\[/?)(?!(?:' . $keep_active . '))[^/\]]+/?\]~s', '', $content );
} else {
// Strip all shortcodes.
$content = preg_replace( '~(?:\[/?)[^/\]]+/?\]~s', '', $content );
}
// Set "/" back to its place.
$content = str_replace( $unique_string_two, '/', $content );
return $content;
}
/**
* Remove post type from the link selector.
*
* @since 1.0
* @param array $query Default query for link selector.
* @return array $query
*/
function fusion_core_wp_link_query_args( $query ) {
// Get array key for the post type 'slide'.
$slide_post_type_key = array_search( 'slide', $query['post_type'], true );
// Remove the post type from query.
if ( $slide_post_type_key ) {
unset( $query['post_type'][ $slide_post_type_key ] );
}
// Get array key for the post type 'themefusion_elastic'.
$elastic_slider_post_type_key = array_search( 'themefusion_elastic', $query['post_type'], true );
// Remove the post type from query.
if ( $elastic_slider_post_type_key ) {
unset( $query['post_type'][ $elastic_slider_post_type_key ] );
}
// Return updated query.
return $query;
}
add_filter( 'wp_link_query_args', 'fusion_core_wp_link_query_args' );
/**
* Add Template Builder extensions.
*
* @since 2.2
*/
require_once FUSION_CORE_PATH . '/includes/class-fusioncore-template-builder.php';
/**
* Init the languages updater.
*
* @since 4.1
*/
if ( ! class_exists( 'Fusion_Languages_Updater_API' ) ) {
require_once FUSION_CORE_PATH . '/includes/class-fusion-languages-updater-api.php';
}
new Fusion_Languages_Updater_API( 'plugin', 'fusion-core', FUSION_CORE_VERSION );
/**
* Filter WooCommerce Bundled Product plugin compatibility modules.
*
* @access public
* @since 5.1
*
* @param array $module_paths The compatibility module paths.
* @return array The filteres compatibility module paths.
*/
function fusion_core_woocommerce_bundles_compatibility_modules( $module_paths ) {
if ( ! isset( $module_paths['quickview'] ) ) {
$module_paths['quickview'] = 'modules/class-wc-pb-qv-compatibility.php';
}
return $module_paths;
}
add_filter( 'woocommerce_bundles_compatibility_modules', 'fusion_core_woocommerce_bundles_compatibility_modules', 10000 );