Automattic / vip-go-wpcom-compat

VIP Go / WordPress.com Compatibility
https://wpvip.com
2 stars 6 forks source link

Add support for VIP_CUSTOM_MOBILE_TEMPLATE, VIP_CUSTOM_MOBILE_STYLESHEET #14

Closed joshbetz closed 5 years ago

joshbetz commented 6 years ago

Something like:

if ( defined( 'VIP_CUSTOM_MOBILE_STYLESHEET' ) || defined( 'VIP_CUSTOM_MOBILE_TEMPLATE' ) ) {
add_action( 'jetpack_modules_loaded', function() {
    if ( '' == VIP_CUSTOM_MOBILE_TEMPLATE || '' == VIP_CUSTOM_MOBILE_STYLESHEET )
        return;
    if ( ! jetpack_check_mobile() )
        return;
    // Remove Minileven's path overrides
    remove_filter( 'theme_root', 'minileven_theme_root' );
    remove_filter( 'theme_root_uri', 'minileven_theme_root_uri' );
    add_filter( 'jetpack_mobile_stylesheet', function( $stylesheet, $theme ) {
        return VIP_CUSTOM_MOBILE_STYLESHEET;
    }, 99, 2 );
    add_filter( 'jetpack_mobile_template', function ( $template, $theme ) {
        return VIP_CUSTOM_MOBILE_TEMPLATE;
    }, 99, 2 );
} );
}
mjangda commented 5 years ago

How many sites are currently making use custom mobile themes? If it's a small-ish amount, might be better to keep this within their repo?

joshbetz commented 5 years ago

If it's a small-ish amount, might be better to keep this within their repo?

I have a script running now to check mobile theme usage on VIP sites. So far looks pretty small, so I suspect you're right that it will be better to keep this within client theme repos. Will confirm when the script is done.