(Unattached)
IMG: " . $p->post_title . "";
}
else {
echo "ISOUND: " . $p->post_title . "";
}
echo '
';
}
}
function admin_head() {
global $pagenow;
// Detach
if ( 'upload.php' == $pagenow && isset( $_REQUEST['ais_detach_id'] ) && isset( $_REQUEST['ais_detach_id2'] ) ) {
$id = $_REQUEST['ais_detach_id'];
$id2 = $_REQUEST['ais_detach_id2'];
check_admin_referer( 'ais-remove_' . $id2 );
delete_post_meta( $id, '_asi_link' );
delete_post_meta( $id2, '_asi_link' );
}
}
function wp_redirect( $location )
{
if ( !is_admin() )
return $location;
global $pagenow;
// Attach
if ( 'upload.php' == $pagenow && isset( $_REQUEST['found_ais_id'] ) ) {
$parent_id = (int) $_REQUEST['found_ais_id'];
$current_id = (int) $_REQUEST['current_ais_id'];
if ( !$parent_id || !$current_id )
return $location;
update_post_meta( $current_id, '_asi_link', $parent_id );
update_post_meta( $parent_id, '_asi_link', $current_id );
}
return $location;
}
function wp_ajax_ais_search() {
$type = $_POST['type'];
$s = wp_unslash( $_POST['search'] );
$args = array(
'post_type' => 'attachment',
'post_status' => 'any',
'posts_per_page' => 50,
'post_mime_type' => $type == 'audio' ? array( 'audio/mpeg3', 'audio/mpeg', 'audio/wav' ) :
array( 'image/jpeg', 'image/png', 'image/gif' )
);
if ( '' !== $s )
$args['s'] = $s;
$posts = get_posts( $args );
if ( ! $posts ) {
wp_send_json_error( __( 'No items found.' ) );
}
$html = '
| ' . __(' Title' ) . ' | ' . __( 'Date' ) . ' | |
|---|---|---|
| '; $html .= ' | '.esc_html( $time ) . ' |