function attachment_access() { global $post, $wpdb; if (empty($post)) { global $wp_query; if (!empty($wp_query->query_vars['attachment_id'])) { $post = scoper_get_row("SELECT * FROM {$wpdb->posts} WHERE post_type = 'attachment' AND ID = '{$wp_query->query_vars['attachment_id']}'"); } elseif (!empty($wp_query->query_vars['attachment'])) { $post = scoper_get_row("SELECT * FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_name = '{$wp_query->query_vars['attachment']}'"); } } if (!empty($post)) { $object_type = scoper_get_var("SELECT post_type FROM {$wpdb->posts} WHERE ID = '{$post->post_parent}'"); // default to 'post' object type if retrieval failed for some reason if (empty($object_type)) { $object_type = 'post'; } if ($post->post_parent) { if (!current_user_can("read_{$object_type}", $post->post_parent)) { if (scoper_get_otype_option('do_teaser', 'post')) { if ($use_teaser_type = scoper_get_otype_option('use_teaser', 'post', $object_type)) { AttachmentTemplate_RS::impose_post_teaser($post, $object_type, $use_teaser_type); } else { unset($post); } } else { unset($post); } // WordPress generates 404 if teaser is not enabled } } elseif (defined('SCOPER_BLOCK_UNATTACHED_UPLOADS') && SCOPER_BLOCK_UNATTACHED_UPLOADS) { unset($post); } } }
function act_attachment_access() { if (is_admin() || defined('DISABLE_QUERYFILTERS_RS') || is_content_administrator_rs() || !scoper_get_option('file_filtering')) { return; } // if ( is_attachment() ) { as of WP 2.6, is_attachment() returns false for custom permalink attachment URL if (is_attachment_rs()) { //rs_errlog( 'IS an attachment:' ); require_once dirname(__FILE__) . '/attachment-template_rs.php'; AttachmentTemplate_RS::attachment_access(); } }