~canonical-sysadmins/wordpress/4.8.2

« back to all changes in this revision

Viewing changes to wp-includes/atomlib.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
 
95
95
        $this->feed = new AtomFeed();
96
96
        $this->current = null;
97
 
        $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
98
 
        $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
 
97
        $this->map_attrs_func = array( __CLASS__, 'map_attrs' );
 
98
        $this->map_xmlns_func = array( __CLASS__, 'map_xmlns' );
99
99
    }
100
100
 
101
101
        /**
105
105
                self::__construct();
106
106
        }
107
107
 
 
108
        /**
 
109
         * Map attributes to key="val"
 
110
         *
 
111
         * @param string $k Key
 
112
         * @param string $v Value
 
113
         * @return string
 
114
         */
 
115
        public static function map_attrs($k, $v) {
 
116
                return "$k=\"$v\"";
 
117
        }
 
118
 
 
119
        /**
 
120
         * Map XML namespace to string.
 
121
         *
 
122
         * @param indexish $p XML Namespace element index
 
123
         * @param array $n Two-element array pair. [ 0 => {namespace}, 1 => {url} ]
 
124
         * @return string 'xmlns="{url}"' or 'xmlns:{namespace}="{url}"'
 
125
         */
 
126
        public static function map_xmlns($p, $n) {
 
127
                $xd = "xmlns";
 
128
                if( 0 < strlen($n[0]) ) {
 
129
                        $xd .= ":{$n[0]}";
 
130
                }
 
131
                return "{$xd}=\"{$n[1]}\"";
 
132
        }
 
133
 
108
134
    function _p($msg) {
109
135
        if($this->debug) {
110
136
            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";