SHARE
TWEET

lj-ljr-users-names-paste-shortcodes

tolikpunkoff Jul 27th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Plugin Name: LJ and LJR users shortcodes
  4. Description: adding lj and ljr-like style links on users/blogs LJ and LJR
  5. Version: 0.0.1
  6. Author: Tolik Punkoff & IDT
  7. Author URI: http://tolik-punkoff.com/
  8. License: any
  9. */
  10.  
  11. function ljruser_shortcode($atts)
  12. {
  13.     extract(shortcode_atts(array(
  14.               'user' => '',
  15.               'blank' => 0,
  16.         ), $atts));
  17.     $ret='';
  18.     $target='';
  19.    
  20.     if ($blank==1) $target='target="_blank"';
  21.    
  22.     if ($user=='')
  23.     {
  24.         $ret="<b>[Bad username in LJ tag]</b>";
  25.     }
  26.     else
  27.     {
  28.         $ret = '<span class="ljruser" style="white-space: normal;">';
  29.         $ret = $ret . '<a href="http://lj.rossia.org/userinfo.bml?user=';
  30.         $ret = $ret . $user . '" ' . $target . '>';
  31.         $ret = $ret . '<img src="' . content_url() . '/plugins/lj-ljr-users/img/userinfo-ljr.gif" alt="[info]" style="vertical-align: top; border: 0;" /></a>';
  32.         $ret = $ret . '<a href="http://lj.rossia.org/users/' . $user . '/" ' . $target . '>';
  33.         $ret = $ret . '<b>' . $user . '@ljr' . '</b></a></span>';
  34.     }
  35.  
  36.     return $ret;
  37. }
  38.  
  39. function ljuser_shortcode($atts)
  40. {
  41.     extract(shortcode_atts(array(
  42.               'user' => '',
  43.               'blank' => 0,
  44.         ), $atts));
  45.     $ret='';
  46.     $target='';
  47.    
  48.     if ($blank==1) $target='target="_blank"';
  49.    
  50.     if ($user=='')
  51.     {
  52.         $ret="<b>[Bad username in LJ tag]</b>";
  53.     }
  54.     else
  55.     {
  56.         $ret = '<span class="ljruser" style="white-space: normal;">';
  57.         $ret = $ret . '<a href="http://livejournal.com/userinfo.bml?user=';
  58.         $ret = $ret . $user . '" ' . $target . '>';
  59.         $ret = $ret . '<img src="' . content_url() . '/plugins/lj-ljr-users/img/userinfo-lj.gif" alt="[info]" style="vertical-align: top; border: 0;" /></a>';
  60.         $ret = $ret . '<a href="http://livejournal.com/users/' . $user . '/" ' . $target . '>';
  61.         $ret = $ret . '<b>' . $user . '@lj' . '</b></a></span>';
  62.     }
  63.  
  64.     return $ret;       
  65. }
  66.  
  67. add_shortcode ('lj','ljuser_shortcode');
  68. add_shortcode ('ljr','ljruser_shortcode');
  69.  
  70. ?>
RAW Paste Data
Want to get better at PHP?
Learn to code PHP in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top