NextGEN_shortcodes

The NextGEN Gallery NextGEN shortcodes class.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/ngglegacy/lib/shortcodes.php  
  1. class NextGEN_shortcodes { 
  2.  
  3. // register the new shortcodes 
  4. function __construct() 
  5. // Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553 
  6. $pcre_limit = 500000; 
  7. if ((int)ini_get('pcre.backtrack_limit') < $pcre_limit) { 
  8. @ini_set('pcre.backtrack_limit', $pcre_limit); 
  9.  
  10.  
  11. // convert the old shortcode 
  12. add_filter('the_content', array('NextGEN_shortcodes', 'convert_shortcode')); 
  13.  
  14. // ngglegacy display types use globals. These globals need to be reset 
  15. // at the start of every loop 
  16. add_filter('loop_start', array(&$this, 'reset_globals')); 
  17.  
  18. function reset_globals() 
  19. unset($GLOBALS['subalbum']); 
  20. unset($GLOBALS['nggShowGallery']); 
  21.  
  22. /** 
  23. * NextGEN_shortcodes::convert_shortcode() 
  24. * convert old shortcodes to the new WordPress core style 
  25. * [gallery=1] ->> [nggallery id=1] 
  26. * @param string $content Content to search for shortcodes 
  27. * @return string Content with new shortcodes. 
  28. */ 
  29. static function convert_shortcode($content) { 
  30.  
  31. $ngg_options = nggGallery::get_option('ngg_options'); 
  32.  
  33. if ( stristr( $content, '[singlepic' )) { 
  34. $search = "@\[singlepic=(\d+)(|, \d+|, )(|, \d+|, )(|, watermark|, web20|, )(|, right|, center|, left|, )\]@i"; 
  35. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  36.  
  37. foreach ($matches as $match) { 
  38. // remove the comma 
  39. $match[2] = ltrim($match[2], ', '); 
  40. $match[3] = ltrim($match[3], ', '); 
  41. $match[4] = ltrim($match[4], ', '); 
  42. $match[5] = ltrim($match[5], ', '); 
  43. $replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]"; 
  44. $content = str_replace ($match[0], $replace, $content); 
  45.  
  46. if ( stristr( $content, '[album' )) { 
  47. $search = "@(?:<p>)*\s*\[album\s*=\s*(\w+|^\+)(|, extend|, compact)\]\s*(?:</p>)*@i"; 
  48. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  49.  
  50. foreach ($matches as $match) { 
  51. // remove the comma 
  52. $match[2] = ltrim($match[2], ', '); 
  53. $replace = "[album id=\"{$match[1]}\" template=\"{$match[2]}\"]"; 
  54. $content = str_replace ($match[0], $replace, $content); 
  55.  
  56. if ( stristr( $content, '[gallery' )) { 
  57. $search = "@(?:<p>)*\s*\[gallery\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i"; 
  58. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  59.  
  60. foreach ($matches as $match) { 
  61. $replace = "[nggallery id=\"{$match[1]}\"]"; 
  62. $content = str_replace ($match[0], $replace, $content); 
  63.  
  64. if ( stristr( $content, '[imagebrowser' )) { 
  65. $search = "@(?:<p>)*\s*\[imagebrowser\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i"; 
  66. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  67.  
  68. foreach ($matches as $match) { 
  69. $replace = "[imagebrowser id=\"{$match[1]}\"]"; 
  70. $content = str_replace ($match[0], $replace, $content); 
  71.  
  72. if ( stristr( $content, '[slideshow' )) { 
  73. $search = "@(?:<p>)*\s*\[slideshow\s*=\s*(\w+|^\+)(|, (\d+)|, )(|, (\d+))\]\s*(?:</p>)*@i"; 
  74. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  75.  
  76. foreach ($matches as $match) { 
  77. // remove the comma 
  78. $match[3] = ltrim($match[3], ', '); 
  79. $match[5] = ltrim($match[5], ', '); 
  80. $replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]"; 
  81. $content = str_replace ($match[0], $replace, $content); 
  82.  
  83. if ( stristr( $content, '[tags' )) { 
  84. $search = "@(?:<p>)*\s*\[tags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i"; 
  85. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  86.  
  87. foreach ($matches as $match) { 
  88. $replace = "[nggtags gallery=\"{$match[1]}\"]"; 
  89. $content = str_replace ($match[0], $replace, $content); 
  90.  
  91. if ( stristr( $content, '[albumtags' )) { 
  92. $search = "@(?:<p>)*\s*\[albumtags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i"; 
  93. if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { 
  94.  
  95. foreach ($matches as $match) { 
  96. $replace = "[nggtags album=\"{$match[1]}\"]"; 
  97. $content = str_replace ($match[0], $replace, $content); 
  98.  
  99. return $content;