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.
    function yg_yorumsuz_link_gizle($content) {
  global $current_user, $post, $wpdb, $yg_yorumsuz_yazi;
  $mesaj = '';
 //Eğer giriş yapılmamışsa
 if ( !is_user_logged_in() ) {
   $mesaj = '<a href="'.get_bloginfo('url').'/wp-login.php">Bağlantıyı Görmek için Giriş/Yorum Yapmalısınız</a>';
 }else{
   //Giriş yapılmışsa ancak yorum yapılmamışsa
   if ( (int) $yg_yorumsuz_yazi == $post->ID ) $yorum_sayisi = 0;
    else $yorum_sayisi = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND user_id = '%d'", (int) $post->ID, (int) $current_user->ID));
   if ( 1> $yorum_sayisi) {
     $mesaj = '<a href="'.get_permalink().'#respond">Bağlantıyı Görmek için Yorum Yapmalısınız</a>';
     $yg_yorumsuz_yazi = $post->ID;
   }
 }
 if ($mesaj) return preg_replace('/(<a[^>][^<]*<\/a>)/', $mesaj, $content); else return $content;
}
function yg_link_gizle($attr)
{
 if ($attr['title'] == "") $attr['title'] = $attr['link'];
 $link = '<a href="'.$attr['link'].'" title="'.$attr['title'].'">'.$attr['title'].'</a>';
 return yg_yorumsuz_link_gizle($link);
}
add_action('the_content', 'yg_yorumsuz_link_gizle');
add_shortcode('ygizle', 'yg_link_gizle');

i could show my links to my member witch write a comment but the thing is how could i do this to the place i chose

share|improve this question
    
You don't honestly believe that anyone is able to follow code that has A) such a messy styling and B) is commented in something other than English... –  kaiser Feb 8 '13 at 19:45

1 Answer 1

If I understand correctly you don't need a shortcode or a filter. Just paste your yg_yorumsuz_link_gizle function into functions.php and call it from any template file (they all reside in your theme folder) such as single.php, or from a plugin.

if(function_exists('yg_yorumsuz_link_gizle')){ // just in case
    yg_yorumsuz_link_gizle();
}

If you're only doing it in one place then you could even run your code inside the template file directly, without using functions.php. You need to modify the code in both cases to get rid of any $content-related logic.

share|improve this answer
    
function yg_link_gizle($attr) { if ($attr['title'] == "") $attr['title'] = $attr['link']; $link = '<a href="'.$attr['link'].'" title="'.$attr['title'].'">'.$attr['title'].'</a>'; return yg_yorumsuz_link_gizle($link); } i just need to loop with this cods otherwise the other section working beacuse of warning but this cod cannot be using where i want beacuse this cod using like [ygizle link=""] i have to change this like [hide][/hide] this how can i do this by the way thanks for helping to me –  M.UNLU Feb 8 '13 at 19:24
    
Not sure I understand, sorry. Can you try Google Translate perhaps? –  dalbaeb Feb 8 '13 at 19:26
    
function yg_link_gizle($attr) { if ($attr['title'] == "") $attr['title'] = $attr['link']; $link = '<a href="'.$attr['link'].'" title="'.$attr['title'].'">'.$attr['title'].'</a>'; return yg_yorumsuz_link_gizle($link); } i mean ,i have to change this code( [ygizle link=""] )like, [hide][/hide] this one ,my question is how can i do this. for hiding wherever i want, where should i fix on this cod –  M.UNLU Feb 8 '13 at 19:51
    
Check out the code example in this doc. –  dalbaeb Feb 8 '13 at 19:59

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.