Tag Info

Hot answers tagged

15

Like most others, I highly recommend using WPTouch. However, it's built more to support blogs than other website formats, so I know it's not the panacea of mobile solutions (I run my portfolio on WordPress as well as my blog, and my portfolio looks like **** in WPTouch). So I did take a look at the code to find the relevant portions that you'd need to use ...


12

When WordPress activates a plugin, it calls the activate_plugin() function. This function activates the plugin in a sandbox and redirects somewhere else on success. It's been used by a few authors to programmatically activate plugin dependencies. There's another function, deactivate_plugin(), that does a similar thing in reverse ... it's actually how ...


8

Yes it works well. It's a very simple function but never found a mobile device not recognized by it. It recognize the 90%+ of mobile devices. Main difference from mobiledetect.net is that doesn't differe from phone and tablets. See the code


7

Step 1: Define two custom image sizes, e.g.: <?php add_image_size( 'normal-thumbnail', 400, 300, false ); // Default image size add_image_size( 'mobile-device-thumbnail', 200, 150, false ); // Mobile-device image size ?> Step 2: Implement your chosen means to determine client. There are several ways, and which method you use is outside the scope ...


7

You might want to look at how the very popular WPtouch plugin does this. It gives a different theme for "iPhone, iPod touch, Android, Opera Mini, Palm Pre, Samsung touch and BlackBerry Storm/Torch mobile devices". I see a list of user agents in their source code, that's probably the key. Another plugin, WP-Wurfled, uses the extensive Wireless Universal ...


6

I personally use the WP Touch plugin on my site. It automatically detects if the user is browsing with an iPhone (or iPad) and reformats the site into an iOS-friendly layout with touch-sensitive controls. There's an option at the bottom for visitors to display the normal site if they want. It's a very well-supported system, and I've used it on 3 of my own ...


5

At the risk of not answering the question, I'd advise to not do so. I've been using iOS devices for months, and one of the first things I did back when I bought my iPad was to try to come up with CSS layout that changed its behavior based on the device used (and, originally, the screen orientation). At the time of writing, it's running on my dev site ...


5

something like this maybe: function my_class_names($classes) { $useragent = $_SERVER['HTTP_USER_AGENT']; if(strchr($useragent,'Safari')) $classes[] = 'Safari'; // etc.. return $classes; } add_filter('body_class','my_class_names'); Edit - as per Chip's suggestion, here's the function using the WordPress useragents checks: function ...


5

This is thanks to EAMann's brilliant answer above, and I thought it might be helpful to the original poster too... I needed a solution to make sure users deactivated my plugin if they uploaded the premium version (to avoid potential conflicts). Previously I detected its state with is_plugin_active and showed an admin error message to prompt users to switch ...


5

I would have done it as following, I am sure experts here will have a better way but following is what I could come up with in hurry. First create your controller file in your theme directory (or any other if you like) with the following content. For this example the file name is korkmaz.php UPDATE 1: Please replace the previous korkmaz.php because ...


5

You can use the built in function wp_is_mobile() Override a style with wp_enqueue_style add_action('wp_enqueue_scripts', 'my_mobile_styles'); function my_mobile_styles(){ if(wp_is_mobile()){ wp_register_style( 'my-mobile-style', 'URL_to_stylesheet', array('id-of-main-stylesheet') ); wp_enqueue_style( 'my-mobile-style' ); } } ...


5

Ok, you want that mobile devices always load mobile templates. Desktop devices load template files based on resolution: if < 1080 mobile ones, > 1080 desktop ones. Your workflow should be: On init you check for mobile devices using wp_is_mobile. If true you add a template filter that returns str_replace('.php', '-mobile.php', $template); where ...


4

t f's answer got me thinking. Actually, I can use the core function and adapt it as I like but just put everything in a new function. So here goes: function my_wp_is_mobile() { static $is_mobile; if ( isset($is_mobile) ) return $is_mobile; if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif ( ...


4

My child theme inlcudes php as well as css files. Whenever I switch to a different theme for mobile browsers it works but the custom post types, cats etc are missing in action. I am kind of lost. Your problem is that you're doing too much with the theme. Themes are all about presentation, not about functionality. If your child or parent theme is ...


4

You misunderstand mechanics of how theme works. It does have index.php template, but request is still processed by WordPress main index.php in site's root. It makes no sense to redirect visitor to theme's folder because themes are not meant to be visited directly (they expect WP core to be loaded for them and such). I am not proficient with such plugins, ...


3

Hi @Hamza: I think what you are looking to do is for your plugin to hook 'template_include' to tell it to load a file from your plugin directory. Here's starter code for your plugin: <?php /* Plugin Name: Mobile View Plugin */ if (is_mobile_user()) // YOU NEED TO DEFINE THIS FUNCTION class MobileViewPlugin { static function on_load() { ...


3

Wordpress Mobile pack plugin does the exact job you want http://wordpress.org/extend/plugins/wordpress-mobile-pack/ you can choose different theme for mobile users you are provided with some specially made for phones themes to choose from no hassle - no bugs


3

Yes, there are a few - did you search for them? Here are the top results from Google: WPTouch Carrington Mobile WordPress Mobile Pack


3

Personally I always tend to stick to using responsive design rather than a completely different theme. You then will only have theme to keep updated. Check out this article for more information http://www.techrepublic.com/blog/webmaster/how-to-get-started-with-responsive-web-design/1769


3

While s_ha_dum's answer is not only not wrong, but exactly the answer you'd expect to get, I'd highly advise against using it, whether you are on 3.4+ or not. User agent sniffing sucks. Whether done manually or via a core function. Period. For one, new UA strings pop up like wildfire. For another, a good number of browsers pretend to be something else ...


3

To build the theme in itself i'd recommend you jQuery Mobile. I've already used it for a few wordpress mobile sites, work great. You can then use a plugin like WPtap Mobile Detector to automatically redirect the mobile users to the mobile theme that you've created. This will let them navigate with the same urls as desktop version but through the mobile ...


3

Just wrap you code up in a conditional: if ( $GLOBALS['is_iphone'] ) { // do funky stuff for mini screens } global $is_iphone; will trigger TRUE for all mobile devices incl. tablets. Edit for WP 3.4+ Now there's wp_is_mobile() to make checks for User-Agent. It's basically a wrapper for $is_iphone and does the same.


3

For the record, I'm not sure why anyone would use the JetPack JSON API as it currently works for a self hosted site. If you're doing AJAX and JSON, the whole point is to get back some JSON data FAST. Using jetpack involves an unnecessary call to wordpress.com, which then does a call to your own self hosted blog. Using the wonderful JSON API plugin, you ...


3

global variables are not a good solution Yes, I heard this sentence a lot of times, but as you experienced, sometimes some variables need to be accessed everywhere. Some modern PHP frameworks implement advanced patterns like IOC that helps in such type of things, but wordpress lacks in that, and this is the reason a lot of global variables is used in ...


2

wp_is_mobile should be the switch you need, but you may be talking about a lot of edits to a lot of components to do what you describe. I don't know enough about the rest of your code to guess at what kinds of things you would need.


2

I see 3 ways to edit Jetpack Mobile theme: 1. Use Jetpack's Custom CSS module Jetpack includes a module named "Custom CSS" that allows you to add your own custom CSS without having to edit your theme stylesheet. The custom CSS editor (under Appearance > Edit CSS) also includes an option to include this custom CSS in Jetpack's mobile theme. You could ...


2

For the detection and redirection part, www.handsetdetection.com can help you create a seamless rule that you can implement depending on what you require. To show you how simple it is to set things up you can check this out: How to Add a Site Profile in Handset Detection I Hope this helps. Cheers!


2

Your question conflicts slightly. I get the feeling you don't necessarily want a mobile site, but a mobile-optimized or responsive website. This would mean however that you wouldn't need another subdomain or separate directory, your site would just adapt to the device width. Your development steps are more or less minimal (and would take a day or so). Start ...


2

function mobile_redirect() { if (isset($_COOKIE["redirected"]) && $_COOKIE["redirected"]) return; global $is_iphone; if( isset($is_iphone) && $is_iphone ) { wp_redirect( '/mobile/' ); setcookie("redirected", true); exit; } } add_action('init', 'mobile_redirect'); This code redirects every ...


2

To build it you can use hookpress or the json api. You would need to built a stand alone app and then query wordpress for the info you want, using the above two plugins makes that a lot easier, in effect you turning wordpress into an API. An update to this post since I comes up via the googles: Java for WordPress xmlrpc. ...



Only top voted, non community-wiki answers of a minimum length are eligible