allows to easily remove support by firing remove_theme_support() (with a priority < hu_plugins_compatibility) on hook 'after_setup_theme' * hook : after_setup_theme:20 * */ function hu_set_plugins_supported() { //add support for plugins (added in v3.1+) add_theme_support( 'jetpack' ); add_theme_support( 'buddy-press' ); add_theme_support( 'uris' );///Ultimate Responsive Image Slider add_theme_support( 'the-events-calendar' );///Ultimate Responsive Image Slider add_theme_support( 'woocommerce' );///WooCoomerce add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); add_theme_support( 'wp-pagenavi' );///WP PageNavi add_theme_support( 'polylang' ); add_theme_support( 'wpml' ); } /** * This function handles the following plugins compatibility : Jetpack (for the carousel addon and photon), Bbpress... * hook : after_setup_theme:30 */ function hu_plugins_compatibility() { /* JETPACK */ //adds compatibilty with the jetpack image carousel and photon if ( current_theme_supports( 'jetpack' ) && hu_is_plugin_active('jetpack/jetpack.php') ) hu_set_jetpack_compat(); /* BUDDYPRESS */ //if buddypress is installed and activated, we can check the existence of the contextual boolean function is_buddypress() to execute some code // we have to use buddy-press instead of buddypress as string for theme support as buddypress makes some checks on current_theme_supports('buddypress') which result in not using its templates if ( current_theme_supports( 'buddy-press' ) && hu_is_plugin_active('buddypress/bp-loader.php') ) hu_set_buddypress_compat(); /* Ultimate Responsive Image Slider */ if ( current_theme_supports( 'uris' ) && hu_is_plugin_active('ultimate-responsive-image-slider/ultimate-responsive-image-slider.php') ) hu_set_uris_compat(); /* The Events Calendar */ if ( current_theme_supports( 'the-events-calendar' ) && hu_is_plugin_active('the-events-calendar/the-events-calendar.php') ) hu_set_the_events_calendar_compat(); /* Woocommerce */ if ( current_theme_supports( 'woocommerce' ) && hu_is_plugin_active('woocommerce/woocommerce.php') ) hu_set_woocommerce_compat(); /* WP PageNavi */ if ( current_theme_supports( 'wp-pagenavi' ) && hu_is_plugin_active('wp-pagenavi/wp-pagenavi.php') ) hu_set_wp_pagenavi_compat(); /* Polylang */ if ( current_theme_supports( 'polylang' ) && ( hu_is_plugin_active('polylang/polylang.php') || hu_is_plugin_active('polylang-pro/polylang.php') ) ) hu_set_polylang_compat(); /* WPML */ if ( current_theme_supports( 'wpml' ) && hu_is_plugin_active('sitepress-multilingual-cms/sitepress.php') ) hu_set_wpml_compat(); } /** * Jetpack compat hooks * */ function hu_set_jetpack_compat() { //Photon jetpack's module conflicts with our smartload feature: //Photon removes the width,height attribute in php, then in js it compute them (when they have the special attribute 'data-recalc-dims') //based on the img src. When smartload is enabled the images parsed by its js which are not already smartloaded are dummy //and their width=height is 1. The image is correctly loaded but the space //assigned to it will be 1x1px. Photon js, is compatible with Auttomatic plugin lazy load and it sets the width/height //attribute only when the img is smartloaded. This is pretty useless to me, as it doesn't solve the main issue: //document's height change when the img are smartloaded. //Anyway to avoid the 1x1 issue we alter the img attribute (data-recalc-dims) which photon adds to the img tag(php) so //the width/height will not be erronously recalculated if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) add_filter( 'hu_img_smartloaded', 'hu_jp_smartload_img'); function hu_jp_smartload_img( $img ) { return str_replace( 'data-recalc-dims', 'data-tcjp-recalc-dims', $img ); } }//end jetpack compat /** * BuddyPress compat hooks * */ function hu_set_buddypress_compat() { //disable smartload in change-avatar buddypress profile page //to avoid the img tag (in a template loaded with backbone) being parsed on server side but //not correctly processed by the front js. //the action hook "xprofile_screen_change_avatar" is a buddypress specific hook //fired before wp_head where we hook hu_parse_imgs //side-effect: all the images in this pages will not be smartloaded, this isn't a big deal //as there should be at maximum 2 images there: //1) the avatar, if already set //2) a cover image, if already set //anyways this page is not a regular "front" page as it pertains more to a "backend" side //if we can call it that way. add_action( 'xprofile_screen_change_avatar', 'hu_buddypress_maybe_disable_img_smartload' ); function hu_buddypress_maybe_disable_img_smartload() { add_filter( 'hu_opt_smart_load_img', '__return_false' );//hu_opt_smart_load_image filters the option 'smart_load_img' } } /** * Ultimate Responsive Image Slider compat hooks (uris) * */ function hu_set_uris_compat() { add_filter ( 'hu_img_smart_load_options', 'hu_uris_disable_img_smartload' ) ; function hu_uris_disable_img_smartload( $options ){ if ( !is_array( $options ) ) $options = array(); if ( !is_array( $options['opts'] ) ) $options['opts'] = array(); if ( !is_array( $options['opts']['excludeImg'] ) ) $options['opts']['excludeImg'] = array(); $options['opts']['excludeImg'][] = '.sp-image'; return $options; } }//end uris compat /** * The Events Calendar compat hooks */ function hu_set_the_events_calendar_compat() { /* * Are we in the Events list context? */ if ( !( function_exists( 'hu_is_tec_events_list' ) ) ) { function hu_is_tec_events_list() { return function_exists( 'tribe_is_event_query' ) && tribe_is_event_query() && is_post_type_archive(); } } /* * Are we in single Event context? */ if ( !( function_exists( 'hu_is_tec_single_event' ) ) ) { function hu_is_tec_single_event() { return function_exists( 'tribe_is_event_query' ) && tribe_is_event_query() && is_single(); } } /* * Avoid php smartload image php parsing in events list content * See: https://github.com/presscustomizr/hueman/issues/285 */ add_filter( 'hu_disable_img_smart_load', 'hu_tec_disable_img_smart_load_events_list', 999, 2); function hu_tec_disable_img_smart_load_events_list( $_bool, $parent_filter ) { if ( 'the_content' == $parent_filter && hu_is_tec_events_list() ) return true;//disable return $_bool; } } /** * The Events Calendar compat hooks */ function hu_set_woocommerce_compat() { //Wrappers remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); add_action('woocommerce_before_main_content', 'hu_theme_wrapper_start', 10); add_action('woocommerce_after_main_content', 'hu_theme_wrapper_end', 10); //show hu custom single post meta boxes in product post type add_filter( 'hu_custom_meta_boxes_post_options_in', 'hu_add_woocommerce_custom_meta_boxes_in_product'); if ( !function_exists('hu_add_woocommerce_custom_meta_boxes_in_product') ) { function hu_add_woocommerce_custom_meta_boxes_in_product( $array ) { if ( is_array( $array ) && post_type_exists( 'product' ) ) array_push( $array, 'product' ); return $array; } } if ( apply_filters( 'hu_wc_basic_support', false ) ) { return; } //do not show default shop title, we'll do it add_filter( 'woocommerce_show_page_title', '__return_false' ); add_filter( 'hu_in_wrapper_page_title', 'hu_print_woocommerce_page_title' ); if ( !function_exists('hu_print_woocommerce_page_title') ) { function hu_print_woocommerce_page_title( $title ) { if ( function_exists('is_woocommerce') && is_woocommerce() && function_exists('woocommerce_page_title') ) { ?>