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 have created a media button as such:

    // Create a media button for pages
function aisis_page_button_link(){
    global $post_ID, $temp_ID, $iframe_post_id;
    $iframe_post_id = (int) (0 == $post_ID ? $temp_ID : $post_ID);
    $url = admin_url("/admin-ajax.php?post_id=$iframe_post_id&codes=aisis-page-codes&action=aisis_page_codes&TB_iframe=true");
    echo "<a href='".$url."' class='move thickbox' title='Create amazing pages with these codes!'>
    <img src='".get_template_directory_uri() . "/lib/images/pages.png" . "' width='16' height='16'></a>";
}

if(!empty($_GET['codes']) && $_GET['codes'] == 'aisis-page-codes'){
    add_action( 'parse_request', 'parse_wp_request' );
    echo parse_aisis_page_request($wp);
    add_action( 'wp_ajax_asisi_page_codes', 'parse_aisis_page_request' );
}

function parse_aisis_page_request($wp){
    aisis_require_page_code_display_page();
    exit;
}

function aisis_require_page_code_display_page(){
    require_once(CORETHEME_SHORTCODES . 'PageCodes.phtml');
}

add_action('media_buttons', 'aisis_page_button_link', 999);

Which then creates the desired effect of:

enter image description here

Note: The above code is for the second "page" like icon.

What I want to do is only have the above code run on pages, and only pages. that is edit and add new page. I know I would edit the aisis_page_button_link() function, and I can figure out how to make it appear for adding a new page, how ever how do you make it appear for editing a page?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Check the post type:

function aisis_page_button_link(){
    global $post_ID, $temp_ID, $iframe_post_id;

    if ( 'page' !== get_post_type( $post_ID ) )
        return;

    // continue
share|improve this answer
    
interesting. thnx –  TheWebs Apr 4 '13 at 19:13

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.