Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to hide the branding section of my blog, but only when someone is viewing it from the iPad. I am not sure how to attack this.

EDIT: the function remove_access currently works in my template, but I need to add the iPad function.

So would this look correct for trying to hide the area:

<?php 
function remove_access() {
 if(is_page(array(63, 386, 391, 405, 'forums'))) {
    remove_action('thematic_header','thematic_blogtitle',3);
    remove_action('thematic_header', 'thematic_blogdescription',5);
    remove_action('thematic_header', 'thematic_brandingclosing',7);
    remove_action('thematic_header','thematic_access',9);
    remove_action('thematic_footer','thematic_siteinfoopen',20);
    remove_action('thematic_footer','thematic_siteinfo',30);
  }
}
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) ){
    add_action('template_redirect', 'remove_access');
}

EDIT-3:

the complete function

changed the condition to: if (it's an iPad AND page is blog) OR (if it's one of the pages in array), then remove items.

<?php
function remove_access() {
    if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) && is_page('blog') || is_page(array(63, 386, 391, 405, 'forums')) ){
        remove_action('thematic_header','thematic_blogtitle',3);
        remove_action('thematic_header', 'thematic_blogdescription',5);
        remove_action('thematic_header', 'thematic_brandingclosing',7);
        remove_action('thematic_header','thematic_access',9);
        remove_action('thematic_footer','thematic_siteinfoopen',20);
        remove_action('thematic_footer','thematic_siteinfo',30);
    }
}

add_action('template_redirect', 'remove_access');

EDIT-4:

Add a function to remove from child pages as well. I tried this, but it doesn't seem to work:

function remove_access() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) && is_page('blog') && ($post->post_parent == 'blog') || is_page(array(63, 386, 391, 405, 'forums')) && ($post->post_parent == (63, 386, 391, 405, 'forums')) ){
    remove_action('thematic_header','thematic_blogtitle',3);
    remove_action('thematic_header', 'thematic_blogdescription',5);
    remove_action('thematic_header', 'thematic_brandingclosing',7);
    remove_action('thematic_header','thematic_access',9);
    remove_action('thematic_footer','thematic_siteinfoopen',20);
    remove_action('thematic_footer','thematic_siteinfo',30);
  }
}

add_action('template_redirect', 'remove_access');
share|improve this question
    
I'm a bit confused. you want to remove those things if it's one of the listed pages OR an iPad? –  Milo Jun 23 '11 at 16:26
    
Both. I need those areas to be hidden because they are only being accessed through an iPad app. The original function works fine because I don't have actual links on the website to access them. However, the blog is accessible from both the website navigation and the iPad app. I don't want those areas to display if the user is using an iPad. Hopefully I am clear, I have a tendency to be too vague sometimes... –  chris_s Jun 23 '11 at 16:30
    
I edited your code, see if I understood you correctly. –  Milo Jun 23 '11 at 17:23
    
Perfect, I knew there was a way to combine them. I just wasn't piecing it together in my head. That's a huge help. Thank you! –  chris_s Jun 23 '11 at 17:28
    
Here's another question for you. actions are removed from those pages, however, it seems the child pages still show those areas. How can I hide those areas if they are child pages as well? –  chris_s Jun 23 '11 at 17:36

2 Answers 2

up vote 3 down vote accepted

there's no foolproof method for doing this, but a quick and simple solution is to look at http user agent:

<?php
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) ):
    echo "is iPad";
endif;
share|improve this answer
    
So would this look correct for trying to hide the area: –  chris_s Jun 23 '11 at 15:58
    
@chris_s - edited your code to fix the if() statement. if(): endif; is just a newer alternate syntax of if(){ }. I also moved it to check around the add_action, but I suppose you could do it either way. –  Milo Jun 23 '11 at 16:13

You want to use the WURFL, which is a constantly-updated, open-source device description repository. Follow these instructions to set up the API on your Wordpress install, and then you'll be able to query the WURFL database for "WURFL ID: apple_ipad_ver1"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.