That should work, yes, as long as the string matches your theme’s stylesheet or template value. For a parent theme, the template is the theme’s directory name. For a child theme, the stylesheet is the child theme’s directory name.
Hi Jeremy,
I’ve tried it, but it didn’t seem to work. It seems to default to a path relative to the plugin’s mobile theme folder. What would the string look like if I wanted to use the following path, for example?
wp-content/themes/mobile/custom/styles.css
Instead of this one:
wp-content/plugins/jetpack/modules/minileven/theme/cutom/mobile/style.css
What would the string look like if I wanted to use the following path, for example?
wp-content/themes/mobile/custom/styles.css
I’d suggest placing your theme in wp-content/themes/mobile/style.css instead, and the template and stylesheet values would then be mobile.
Hi Jeremy. If I use just “mobile” as the return string, Jetpack tries to load it from here:
/wp-content/plugins/jetpack/modules/minileven/theme/mobile/style.css?ver=4.2.1
add_filter( 'jetpack_mobile_stylesheet', 'mobile_theme_callback' );
add_filter( 'jetpack_mobile_template', 'mobile_theme_callback' );
function mobile_theme_callback( ) {
return 'mobile';
}
The only problem with this is that updating the plugin removes the theme directory.
This can be tested with the jetpack_mobile_stylesheet filter. If testing with jetpack_mobile_template filter, it produces a fatal error.
Interesting. It might be a bug with how we define the filter.
Could you try to prefix things with get_theme_root_uri or get_theme_root, and let me know if one of these help?
https://codex.wordpress.org/Function_Reference/get_theme_root_uri
https://codex.wordpress.org/Function_Reference/get_theme_root
That didn’t seem to work. Here’s what happens using those two functions…
add_filter( 'jetpack_mobile_stylesheet', function( $stylesheet, $theme ) {
$ss = get_theme_root() . 'mobile';
return $ss;
} );
Adds the following:
<link rel='stylesheet' id='style-css' href='http://www.[DOMAIN].com/cms/wp-content/plugins/jetpack/modules/minileven/theme//home/[USER]/public_html/cms/wp-content/plugins/jetpack/modules/minileven/thememobile/style.css?ver=4.1.4' type='text/css' media='all' />
add_filter( 'jetpack_mobile_stylesheet', function( $stylesheet, $theme ) {
$ss = get_theme_root_uri() . '/mobile';
return $ss;
} );
Adds the following:
<link rel='stylesheet' id='style-css' href='http://www.[DOMAIN].com/cms/wp-content/plugins/jetpack/modules/minileven/theme/http%3A//www.[DOMAIN].com/cms/wp-content/plugins/jetpack/modules/minileven/theme/mobile/style.css?ver=4.1.4' type='text/css' media='all' />
Thanks for giving it a try. That seems like a bug. I took note of it in this GitHub issue:
https://github.com/Automattic/jetpack/issues/2061
Feel free to follow our progress there. I’ll also post here when I have some news.
Awesome, thank you! I’ve subscribed to the issue on GitHub also.