privatecollectionswp /htdocs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/lib/shortcodes.php

Language PHP Lines 142
MD5 Hash dc254c92d35983de3dc0b379506cc1de
Repository https://github.com/Fishgate/privatecollectionswp.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
 * @author Alex Rabe, Vincent Prat
 *
 * @since 1.0.0
 * @description Use WordPress Shortcode API for more features
 * @Docs http://codex.wordpress.org/Shortcode_API
 * @todo This file should be merged into another file
 */

class NextGEN_shortcodes {

    // register the new shortcodes
    function NextGEN_shortcodes() {

		// Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
        $pcre_limit = 500000;
        if ((int)ini_get('pcre.backtrack_limit') < $pcre_limit) {
            @ini_set('pcre.backtrack_limit', $pcre_limit);
        }


        // convert the old shortcode
        add_filter('the_content', array(&$this, 'convert_shortcode'));

		// ngglegacy display types use globals. These globals need to be reset
		// at the start of every loop
		add_filter('loop_start',  array(&$this, 'reset_globals'));
    }

	function reset_globals()
	{
		unset($GLOBALS['subalbum']);
		unset($GLOBALS['nggShowGallery']);
	}

     /**
       * NextGEN_shortcodes::convert_shortcode()
       * convert old shortcodes to the new WordPress core style
       * [gallery=1]  ->> [nggallery id=1]
       *
       * @param string $content Content to search for shortcodes
       * @return string Content with new shortcodes.
       */
    function convert_shortcode($content) {

        $ngg_options = nggGallery::get_option('ngg_options');

        if ( stristr( $content, '[singlepic' )) {
            $search = "@\[singlepic=(\d+)(|,\d+|,)(|,\d+|,)(|,watermark|,web20|,)(|,right|,center|,left|,)\]@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    // remove the comma
                    $match[2] = ltrim($match[2], ',');
                    $match[3] = ltrim($match[3], ',');
                    $match[4] = ltrim($match[4], ',');
                    $match[5] = ltrim($match[5], ',');
                    $replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[album' )) {
            $search = "@(?:<p>)*\s*\[album\s*=\s*(\w+|^\+)(|,extend|,compact)\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    // remove the comma
                    $match[2] = ltrim($match[2],',');
                    $replace = "[album id=\"{$match[1]}\" template=\"{$match[2]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[gallery' )) {
            $search = "@(?:<p>)*\s*\[gallery\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    $replace = "[nggallery id=\"{$match[1]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[imagebrowser' )) {
            $search = "@(?:<p>)*\s*\[imagebrowser\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    $replace = "[imagebrowser id=\"{$match[1]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[slideshow' )) {
            $search = "@(?:<p>)*\s*\[slideshow\s*=\s*(\w+|^\+)(|,(\d+)|,)(|,(\d+))\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    // remove the comma
                    $match[3] = ltrim($match[3],',');
                    $match[5] = ltrim($match[5],',');
                    $replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[tags' )) {
            $search = "@(?:<p>)*\s*\[tags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    $replace = "[nggtags gallery=\"{$match[1]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        if ( stristr( $content, '[albumtags' )) {
            $search = "@(?:<p>)*\s*\[albumtags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i";
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

                foreach ($matches as $match) {
                    $replace = "[nggtags album=\"{$match[1]}\"]";
                    $content = str_replace ($match[0], $replace, $content);
                }
            }
        }

        return $content;
    }
}

// let's use it
$nggShortcodes = new NextGEN_Shortcodes;
Back to Top