<?php _e('Auto Attachments Shortcodes','autoa');?> ID; echo ""; } add_action('wp_ajax_ex_aa', 'ex_aa_callback'); function ex_aa_callback() { global $wpdb; $nonce = $_POST['nonce']; $post_id = $_POST['post_id']; $post_meta = $_POST['post_meta']; $durum = $_POST['durum']; if (!wp_verify_nonce($nonce,'ajax-nonce')){ die ( 'Busted!');} else { if ($durum == "resim") { update_post_meta($post_id,'ex_rsm',$post_meta); } if ($durum == "muzik") { update_post_meta($post_id,'ex_muz',$post_meta); } if ($durum == "video") { update_post_meta($post_id,'ex_vid',$post_meta); } if ($durum == "dosya"){ update_post_meta($post_id,'ex_dosya',$post_meta); } } die(); } add_action('wp_ajax_get_imgs', 'ex_getimgs'); function ex_getimgs() { global $wpdb; $post_id = $_GET['post_id']; $postmim = $_GET['postmim']; $args = array( 'post_type'=> 'attachment', 'post_parent'=> $post_id, 'post_mime_type'=> $postmim, 'numberposts' => -1 ); $imgs = get_posts($args); $c = count($imgs); if ($c > 0) { foreach ($imgs as $img) { $ret[]= array('id' =>$img->ID, 'post_name' => $img->post_name); } } else { $ret[] = array('id' => '-', 'post_name' => 'Nope'); } $output = $ret; echo json_encode($output); die(); } // Shortcode for Images function getimages_aa($atts) { global $post; $opts = get_option('auto_attachments_options'); extract(shortcode_atts(array("id" => ''), $atts)); $dis = explode(',',$id); $ex_rsm = get_post_meta($post->ID,'ex_rsm',true); $imageaa = ""; if ($ex_rsm != "") { $imageaa .= "
"; foreach ($dis as $di){ $posti = get_post($di); $aath = wp_get_attachment_image_src($posti->ID, 'aa_thumb'); $aabg = wp_get_attachment_image_src($posti->ID, 'aa_big'); $imageaa .= ""; } $imageaa .="
 
"; } return $imageaa; } add_shortcode('imageaa', 'getimages_aa'); // Shortcode for Images // Shortcode for Files function getfiles_aa($atts) { global $post; $opts = get_option('auto_attachments_options'); extract(shortcode_atts(array("id" => ''), $atts)); $dis = explode(',',$id); $ex_dosya = get_post_meta($post->ID,'ex_dosya',true); $urlp = plugins_url('/auto-attachments/includes'); $filesaa = ""; if ($ex_dosya != "") { $filesaa .= "
"; foreach ($dis as $di){ $posti = get_post($di); $fhh = $opts['fhh']; $fhw = $opts['fhw']; if ($opts['newwindow'] == 'yes') {$target = 'target="_blank"';} else {$target = "";} $_link = wp_get_attachment_url($posti->ID); //get the url for linkage $_name_array = explode("/", $_link); $_post_mime = str_replace("/", "-", $posti->post_mime_type); $_name = array_reverse($_name_array); $filesaa .= "
" . $posti->post_title . "
"; } $filesaa .="
 
"; } return $filesaa; } add_shortcode('filesaa', 'getfiles_aa'); // Shortcode for Audio function getmusic_aa($atts) { global $post; $opts = get_option('auto_attachments_options'); extract(shortcode_atts(array("id" => ''), $atts)); $dis = explode(',',$id); $ex_muz = get_post_meta($post->ID,'ex_muz',true); $urlp = plugins_url('/auto-attachments/includes'); $skin = $opts['jwskin']; $jhw = $opts['jhw']; $musicaa = ""; if ($ex_muz != "") { $musicaa .= "
 
"; } return $musicaa; } add_shortcode('musicaa', 'getmusic_aa'); // Shortcode for Videos function getvideo_aa($atts) { global $post; $opts = get_option('auto_attachments_options'); extract(shortcode_atts(array("id" => ''), $atts)); $dis = explode(',',$id); $ex_vid = get_post_meta($post->ID,'ex_vid',true); $urlp = plugins_url('/auto-attachments/includes'); $skin = $opts['jwskin']; $jhw = $opts['jhw']; $jhh = $opts['jhh']; $videoaa = ""; if ($ex_vid != "") { $videoaa .= "
 
"; } return $videoaa; } add_shortcode('videoaa', 'getvideo_aa'); // End Of shortcodes.php ?>