@@ -1072,6 +1072,9 @@ discard block |
||
| 1072 | 1072 | return true; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | + /** |
|
| 1076 | + * @param boolean $ScanAsCBR |
|
| 1077 | + */ |
|
| 1075 | 1078 | public function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) { |
| 1076 | 1079 | $info = &$this->getid3->info; |
| 1077 | 1080 | $firstframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']); |
@@ -1686,6 +1689,9 @@ discard block |
||
| 1686 | 1689 | return $MPEGaudioEmphasis; |
| 1687 | 1690 | } |
| 1688 | 1691 | |
| 1692 | + /** |
|
| 1693 | + * @param string $head4 |
|
| 1694 | + */ |
|
| 1689 | 1695 | public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) { |
| 1690 | 1696 | return self::MPEGaudioHeaderValid(self::MPEGaudioHeaderDecode($head4), false, $allowBitrate15); |
| 1691 | 1697 | } |
@@ -1936,6 +1942,9 @@ discard block |
||
| 1936 | 1942 | return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : ''); |
| 1937 | 1943 | } |
| 1938 | 1944 | |
| 1945 | + /** |
|
| 1946 | + * @param integer $SourceSampleFrequencyID |
|
| 1947 | + */ |
|
| 1939 | 1948 | public static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) { |
| 1940 | 1949 | static $LAMEmiscSourceSampleFrequencyLookup = array( |
| 1941 | 1950 | 0 => '<= 32 kHz', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $initialOffset = $info['avdataoffset']; |
| 34 | 34 | |
| 35 | - if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) { |
|
| 35 | + if ( ! $this->getOnlyMPEGaudioInfo($info['avdataoffset'])) { |
|
| 36 | 36 | if ($this->allow_bruteforce) { |
| 37 | 37 | $info['error'][] = 'Rescanning file in BruteForce mode'; |
| 38 | 38 | $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) { |
|
| 47 | + if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || ( ! isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) { |
|
| 48 | 48 | |
| 49 | 49 | $synchoffsetwarning = 'Unknown data before synch '; |
| 50 | 50 | if (isset($info['id3v2']['headerlength'])) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $synchoffsetwarning .= 'synch detected at '.$info['avdataoffset'].')'; |
| 58 | 58 | if (isset($info['audio']['bitrate_mode']) && ($info['audio']['bitrate_mode'] == 'cbr')) { |
| 59 | 59 | |
| 60 | - if (!empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) { |
|
| 60 | + if ( ! empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) { |
|
| 61 | 61 | |
| 62 | 62 | $synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.'; |
| 63 | 63 | $info['audio']['codec'] = 'LAME'; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | if (isset($info['mpeg']['audio']['LAME'])) { |
| 80 | 80 | $info['audio']['codec'] = 'LAME'; |
| 81 | - if (!empty($info['mpeg']['audio']['LAME']['long_version'])) { |
|
| 81 | + if ( ! empty($info['mpeg']['audio']['LAME']['long_version'])) { |
|
| 82 | 82 | $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['long_version'], "\x00"); |
| 83 | - } elseif (!empty($info['mpeg']['audio']['LAME']['short_version'])) { |
|
| 83 | + } elseif ( ! empty($info['mpeg']['audio']['LAME']['short_version'])) { |
|
| 84 | 84 | $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['short_version'], "\x00"); |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : '')); |
|
| 89 | - if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && !preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) { |
|
| 88 | + $CurrentDataLAMEversionString = ( ! empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : '')); |
|
| 89 | + if ( ! empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && ! preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) { |
|
| 90 | 90 | // a version number of LAME that does not end with a number like "LAME3.92" |
| 91 | 91 | // or with a closing parenthesis like "LAME3.88 (alpha)" |
| 92 | 92 | // or a version of LAME with the LAMEtag-not-filled-in-DLL-mode bug (3.90-3.92) |
@@ -115,14 +115,12 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | - if (!empty($info['audio']['encoder'])) { |
|
| 118 | + if ( ! empty($info['audio']['encoder'])) { |
|
| 119 | 119 | $info['audio']['encoder'] = rtrim($info['audio']['encoder'], "\x00 "); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | switch (isset($info['mpeg']['audio']['layer']) ? $info['mpeg']['audio']['layer'] : '') { |
| 123 | - case 1: |
|
| 124 | - case 2: |
|
| 125 | - $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer']; |
|
| 123 | + case 1 : case 2 : $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer']; |
|
| 126 | 124 | break; |
| 127 | 125 | } |
| 128 | 126 | if (isset($info['fileformat']) && ($info['fileformat'] == 'mp3')) { |
@@ -151,7 +149,7 @@ discard block |
||
| 151 | 149 | $info['audio']['lossless'] = false; |
| 152 | 150 | |
| 153 | 151 | // Calculate playtime |
| 154 | - if (!isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) { |
|
| 152 | + if ( ! isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) { |
|
| 155 | 153 | $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['audio']['bitrate']; |
| 156 | 154 | } |
| 157 | 155 | |
@@ -164,9 +162,9 @@ discard block |
||
| 164 | 162 | public function GuessEncoderOptions() { |
| 165 | 163 | // shortcuts |
| 166 | 164 | $info = &$this->getid3->info; |
| 167 | - if (!empty($info['mpeg']['audio'])) { |
|
| 165 | + if ( ! empty($info['mpeg']['audio'])) { |
|
| 168 | 166 | $thisfile_mpeg_audio = &$info['mpeg']['audio']; |
| 169 | - if (!empty($thisfile_mpeg_audio['LAME'])) { |
|
| 167 | + if ( ! empty($thisfile_mpeg_audio['LAME'])) { |
|
| 170 | 168 | $thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME']; |
| 171 | 169 | } |
| 172 | 170 | } |
@@ -174,71 +172,71 @@ discard block |
||
| 174 | 172 | $encoder_options = ''; |
| 175 | 173 | static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256); |
| 176 | 174 | |
| 177 | - if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) { |
|
| 175 | + if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && ! empty($thisfile_mpeg_audio['VBR_quality'])) { |
|
| 178 | 176 | |
| 179 | 177 | $encoder_options = 'VBR q'.$thisfile_mpeg_audio['VBR_quality']; |
| 180 | 178 | |
| 181 | - } elseif (!empty($thisfile_mpeg_audio_lame['preset_used']) && (!in_array($thisfile_mpeg_audio_lame['preset_used_id'], $NamedPresetBitrates))) { |
|
| 179 | + } elseif ( ! empty($thisfile_mpeg_audio_lame['preset_used']) && ( ! in_array($thisfile_mpeg_audio_lame['preset_used_id'], $NamedPresetBitrates))) { |
|
| 182 | 180 | |
| 183 | 181 | $encoder_options = $thisfile_mpeg_audio_lame['preset_used']; |
| 184 | 182 | |
| 185 | - } elseif (!empty($thisfile_mpeg_audio_lame['vbr_quality'])) { |
|
| 183 | + } elseif ( ! empty($thisfile_mpeg_audio_lame['vbr_quality'])) { |
|
| 186 | 184 | |
| 187 | 185 | static $KnownEncoderValues = array(); |
| 188 | 186 | if (empty($KnownEncoderValues)) { |
| 189 | 187 | |
| 190 | 188 | //$KnownEncoderValues[abrbitrate_minbitrate][vbr_quality][raw_vbr_method][raw_noise_shaping][raw_stereo_mode][ath_type][lowpass_frequency] = 'preset name'; |
| 191 | - $KnownEncoderValues[0xFF][58][1][1][3][2][20500] = '--alt-preset insane'; // 3.90, 3.90.1, 3.92 |
|
| 192 | - $KnownEncoderValues[0xFF][58][1][1][3][2][20600] = '--alt-preset insane'; // 3.90.2, 3.90.3, 3.91 |
|
| 193 | - $KnownEncoderValues[0xFF][57][1][1][3][4][20500] = '--alt-preset insane'; // 3.94, 3.95 |
|
| 194 | - $KnownEncoderValues['**'][78][3][2][3][2][19500] = '--alt-preset extreme'; // 3.90, 3.90.1, 3.92 |
|
| 195 | - $KnownEncoderValues['**'][78][3][2][3][2][19600] = '--alt-preset extreme'; // 3.90.2, 3.91 |
|
| 196 | - $KnownEncoderValues['**'][78][3][1][3][2][19600] = '--alt-preset extreme'; // 3.90.3 |
|
| 197 | - $KnownEncoderValues['**'][78][4][2][3][2][19500] = '--alt-preset fast extreme'; // 3.90, 3.90.1, 3.92 |
|
| 198 | - $KnownEncoderValues['**'][78][4][2][3][2][19600] = '--alt-preset fast extreme'; // 3.90.2, 3.90.3, 3.91 |
|
| 199 | - $KnownEncoderValues['**'][78][3][2][3][4][19000] = '--alt-preset standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 200 | - $KnownEncoderValues['**'][78][3][1][3][4][19000] = '--alt-preset standard'; // 3.90.3 |
|
| 189 | + $KnownEncoderValues[0xFF][58][1][1][3][2][20500] = '--alt-preset insane'; // 3.90, 3.90.1, 3.92 |
|
| 190 | + $KnownEncoderValues[0xFF][58][1][1][3][2][20600] = '--alt-preset insane'; // 3.90.2, 3.90.3, 3.91 |
|
| 191 | + $KnownEncoderValues[0xFF][57][1][1][3][4][20500] = '--alt-preset insane'; // 3.94, 3.95 |
|
| 192 | + $KnownEncoderValues['**'][78][3][2][3][2][19500] = '--alt-preset extreme'; // 3.90, 3.90.1, 3.92 |
|
| 193 | + $KnownEncoderValues['**'][78][3][2][3][2][19600] = '--alt-preset extreme'; // 3.90.2, 3.91 |
|
| 194 | + $KnownEncoderValues['**'][78][3][1][3][2][19600] = '--alt-preset extreme'; // 3.90.3 |
|
| 195 | + $KnownEncoderValues['**'][78][4][2][3][2][19500] = '--alt-preset fast extreme'; // 3.90, 3.90.1, 3.92 |
|
| 196 | + $KnownEncoderValues['**'][78][4][2][3][2][19600] = '--alt-preset fast extreme'; // 3.90.2, 3.90.3, 3.91 |
|
| 197 | + $KnownEncoderValues['**'][78][3][2][3][4][19000] = '--alt-preset standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 198 | + $KnownEncoderValues['**'][78][3][1][3][4][19000] = '--alt-preset standard'; // 3.90.3 |
|
| 201 | 199 | $KnownEncoderValues['**'][78][4][2][3][4][19000] = '--alt-preset fast standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
| 202 | 200 | $KnownEncoderValues['**'][78][4][1][3][4][19000] = '--alt-preset fast standard'; // 3.90.3 |
| 203 | - $KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix'; // 3.90, 3.90.1, 3.92 |
|
| 204 | - $KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix'; // 3.90.2, 3.90.3, 3.91 |
|
| 205 | - $KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix'; // 3.94, 3.95 |
|
| 206 | - $KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium'; // 3.90.3 |
|
| 207 | - $KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium'; // 3.90.3 |
|
| 208 | - |
|
| 209 | - $KnownEncoderValues[0xFF][99][1][1][1][2][0] = '--preset studio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 210 | - $KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio'; // 3.90.3, 3.93.1 |
|
| 211 | - $KnownEncoderValues[0xFF][58][2][1][3][2][20500] = '--preset studio'; // 3.93 |
|
| 212 | - $KnownEncoderValues[0xFF][57][2][1][3][4][20500] = '--preset studio'; // 3.94, 3.95 |
|
| 213 | - $KnownEncoderValues[0xC0][88][1][1][1][2][0] = '--preset cd'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 214 | - $KnownEncoderValues[0xC0][58][2][2][3][2][19600] = '--preset cd'; // 3.90.3, 3.93.1 |
|
| 215 | - $KnownEncoderValues[0xC0][58][2][2][3][2][19500] = '--preset cd'; // 3.93 |
|
| 216 | - $KnownEncoderValues[0xC0][57][2][1][3][4][19500] = '--preset cd'; // 3.94, 3.95 |
|
| 217 | - $KnownEncoderValues[0xA0][78][1][1][3][2][18000] = '--preset hifi'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 218 | - $KnownEncoderValues[0xA0][58][2][2][3][2][18000] = '--preset hifi'; // 3.90.3, 3.93, 3.93.1 |
|
| 219 | - $KnownEncoderValues[0xA0][57][2][1][3][4][18000] = '--preset hifi'; // 3.94, 3.95 |
|
| 220 | - $KnownEncoderValues[0x80][67][1][1][3][2][18000] = '--preset tape'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 221 | - $KnownEncoderValues[0x80][67][1][1][3][2][15000] = '--preset radio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 222 | - $KnownEncoderValues[0x70][67][1][1][3][2][15000] = '--preset fm'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 223 | - $KnownEncoderValues[0x70][58][2][2][3][2][16000] = '--preset tape/radio/fm'; // 3.90.3, 3.93, 3.93.1 |
|
| 224 | - $KnownEncoderValues[0x70][57][2][1][3][4][16000] = '--preset tape/radio/fm'; // 3.94, 3.95 |
|
| 225 | - $KnownEncoderValues[0x38][58][2][2][0][2][10000] = '--preset voice'; // 3.90.3, 3.93, 3.93.1 |
|
| 226 | - $KnownEncoderValues[0x38][57][2][1][0][4][15000] = '--preset voice'; // 3.94, 3.95 |
|
| 227 | - $KnownEncoderValues[0x38][57][2][1][0][4][16000] = '--preset voice'; // 3.94a14 |
|
| 228 | - $KnownEncoderValues[0x28][65][1][1][0][2][7500] = '--preset mw-us'; // 3.90, 3.90.1, 3.92 |
|
| 229 | - $KnownEncoderValues[0x28][65][1][1][0][2][7600] = '--preset mw-us'; // 3.90.2, 3.91 |
|
| 230 | - $KnownEncoderValues[0x28][58][2][2][0][2][7000] = '--preset mw-us'; // 3.90.3, 3.93, 3.93.1 |
|
| 231 | - $KnownEncoderValues[0x28][57][2][1][0][4][10500] = '--preset mw-us'; // 3.94, 3.95 |
|
| 232 | - $KnownEncoderValues[0x28][57][2][1][0][4][11200] = '--preset mw-us'; // 3.94a14 |
|
| 233 | - $KnownEncoderValues[0x28][57][2][1][0][4][8800] = '--preset mw-us'; // 3.94a15 |
|
| 201 | + $KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix'; // 3.90, 3.90.1, 3.92 |
|
| 202 | + $KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix'; // 3.90.2, 3.90.3, 3.91 |
|
| 203 | + $KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix'; // 3.94, 3.95 |
|
| 204 | + $KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium'; // 3.90.3 |
|
| 205 | + $KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium'; // 3.90.3 |
|
| 206 | + |
|
| 207 | + $KnownEncoderValues[0xFF][99][1][1][1][2][0] = '--preset studio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 208 | + $KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio'; // 3.90.3, 3.93.1 |
|
| 209 | + $KnownEncoderValues[0xFF][58][2][1][3][2][20500] = '--preset studio'; // 3.93 |
|
| 210 | + $KnownEncoderValues[0xFF][57][2][1][3][4][20500] = '--preset studio'; // 3.94, 3.95 |
|
| 211 | + $KnownEncoderValues[0xC0][88][1][1][1][2][0] = '--preset cd'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 212 | + $KnownEncoderValues[0xC0][58][2][2][3][2][19600] = '--preset cd'; // 3.90.3, 3.93.1 |
|
| 213 | + $KnownEncoderValues[0xC0][58][2][2][3][2][19500] = '--preset cd'; // 3.93 |
|
| 214 | + $KnownEncoderValues[0xC0][57][2][1][3][4][19500] = '--preset cd'; // 3.94, 3.95 |
|
| 215 | + $KnownEncoderValues[0xA0][78][1][1][3][2][18000] = '--preset hifi'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 216 | + $KnownEncoderValues[0xA0][58][2][2][3][2][18000] = '--preset hifi'; // 3.90.3, 3.93, 3.93.1 |
|
| 217 | + $KnownEncoderValues[0xA0][57][2][1][3][4][18000] = '--preset hifi'; // 3.94, 3.95 |
|
| 218 | + $KnownEncoderValues[0x80][67][1][1][3][2][18000] = '--preset tape'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 219 | + $KnownEncoderValues[0x80][67][1][1][3][2][15000] = '--preset radio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 220 | + $KnownEncoderValues[0x70][67][1][1][3][2][15000] = '--preset fm'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 |
|
| 221 | + $KnownEncoderValues[0x70][58][2][2][3][2][16000] = '--preset tape/radio/fm'; // 3.90.3, 3.93, 3.93.1 |
|
| 222 | + $KnownEncoderValues[0x70][57][2][1][3][4][16000] = '--preset tape/radio/fm'; // 3.94, 3.95 |
|
| 223 | + $KnownEncoderValues[0x38][58][2][2][0][2][10000] = '--preset voice'; // 3.90.3, 3.93, 3.93.1 |
|
| 224 | + $KnownEncoderValues[0x38][57][2][1][0][4][15000] = '--preset voice'; // 3.94, 3.95 |
|
| 225 | + $KnownEncoderValues[0x38][57][2][1][0][4][16000] = '--preset voice'; // 3.94a14 |
|
| 226 | + $KnownEncoderValues[0x28][65][1][1][0][2][7500] = '--preset mw-us'; // 3.90, 3.90.1, 3.92 |
|
| 227 | + $KnownEncoderValues[0x28][65][1][1][0][2][7600] = '--preset mw-us'; // 3.90.2, 3.91 |
|
| 228 | + $KnownEncoderValues[0x28][58][2][2][0][2][7000] = '--preset mw-us'; // 3.90.3, 3.93, 3.93.1 |
|
| 229 | + $KnownEncoderValues[0x28][57][2][1][0][4][10500] = '--preset mw-us'; // 3.94, 3.95 |
|
| 230 | + $KnownEncoderValues[0x28][57][2][1][0][4][11200] = '--preset mw-us'; // 3.94a14 |
|
| 231 | + $KnownEncoderValues[0x28][57][2][1][0][4][8800] = '--preset mw-us'; // 3.94a15 |
|
| 234 | 232 | $KnownEncoderValues[0x18][58][2][2][0][2][4000] = '--preset phon+/lw/mw-eu/sw'; // 3.90.3, 3.93.1 |
| 235 | 233 | $KnownEncoderValues[0x18][58][2][2][0][2][3900] = '--preset phon+/lw/mw-eu/sw'; // 3.93 |
| 236 | 234 | $KnownEncoderValues[0x18][57][2][1][0][4][5900] = '--preset phon+/lw/mw-eu/sw'; // 3.94, 3.95 |
| 237 | 235 | $KnownEncoderValues[0x18][57][2][1][0][4][6200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a14 |
| 238 | 236 | $KnownEncoderValues[0x18][57][2][1][0][4][3200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a15 |
| 239 | - $KnownEncoderValues[0x10][58][2][2][0][2][3800] = '--preset phone'; // 3.90.3, 3.93.1 |
|
| 240 | - $KnownEncoderValues[0x10][58][2][2][0][2][3700] = '--preset phone'; // 3.93 |
|
| 241 | - $KnownEncoderValues[0x10][57][2][1][0][4][5600] = '--preset phone'; // 3.94, 3.95 |
|
| 237 | + $KnownEncoderValues[0x10][58][2][2][0][2][3800] = '--preset phone'; // 3.90.3, 3.93.1 |
|
| 238 | + $KnownEncoderValues[0x10][58][2][2][0][2][3700] = '--preset phone'; // 3.93 |
|
| 239 | + $KnownEncoderValues[0x10][57][2][1][0][4][5600] = '--preset phone'; // 3.94, 3.95 |
|
| 242 | 240 | } |
| 243 | 241 | |
| 244 | 242 | if (isset($KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) { |
@@ -269,11 +267,11 @@ discard block |
||
| 269 | 267 | |
| 270 | 268 | } |
| 271 | 269 | |
| 272 | - } elseif (!empty($thisfile_mpeg_audio_lame['bitrate_abr'])) { |
|
| 270 | + } elseif ( ! empty($thisfile_mpeg_audio_lame['bitrate_abr'])) { |
|
| 273 | 271 | |
| 274 | 272 | $encoder_options = 'ABR'.$thisfile_mpeg_audio_lame['bitrate_abr']; |
| 275 | 273 | |
| 276 | - } elseif (!empty($info['audio']['bitrate'])) { |
|
| 274 | + } elseif ( ! empty($info['audio']['bitrate'])) { |
|
| 277 | 275 | |
| 278 | 276 | if ($info['audio']['bitrate_mode'] == 'cbr') { |
| 279 | 277 | $encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000); |
@@ -282,15 +280,15 @@ discard block |
||
| 282 | 280 | } |
| 283 | 281 | |
| 284 | 282 | } |
| 285 | - if (!empty($thisfile_mpeg_audio_lame['bitrate_min'])) { |
|
| 283 | + if ( ! empty($thisfile_mpeg_audio_lame['bitrate_min'])) { |
|
| 286 | 284 | $encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min']; |
| 287 | 285 | } |
| 288 | 286 | |
| 289 | - if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) { |
|
| 287 | + if ( ! empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || ! empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) { |
|
| 290 | 288 | $encoder_options .= ' --nogap'; |
| 291 | 289 | } |
| 292 | 290 | |
| 293 | - if (!empty($thisfile_mpeg_audio_lame['lowpass_frequency'])) { |
|
| 291 | + if ( ! empty($thisfile_mpeg_audio_lame['lowpass_frequency'])) { |
|
| 294 | 292 | $ExplodedOptions = explode(' ', $encoder_options, 4); |
| 295 | 293 | if ($ExplodedOptions[0] == '--r3mix') { |
| 296 | 294 | $ExplodedOptions[1] = 'r3mix'; |
@@ -316,20 +314,20 @@ discard block |
||
| 316 | 314 | case 'r3mix': |
| 317 | 315 | static $ExpectedLowpass = array( |
| 318 | 316 | 'insane|20500' => 20500, |
| 319 | - 'insane|20600' => 20600, // 3.90.2, 3.90.3, 3.91 |
|
| 317 | + 'insane|20600' => 20600, // 3.90.2, 3.90.3, 3.91 |
|
| 320 | 318 | 'medium|18000' => 18000, |
| 321 | 319 | 'fast medium|18000' => 18000, |
| 322 | - 'extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 |
|
| 323 | - 'extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 |
|
| 324 | - 'fast extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 |
|
| 325 | - 'fast extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 |
|
| 320 | + 'extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 |
|
| 321 | + 'extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 |
|
| 322 | + 'fast extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 |
|
| 323 | + 'fast extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 |
|
| 326 | 324 | 'standard|19000' => 19000, |
| 327 | 325 | 'fast standard|19000' => 19000, |
| 328 | - 'r3mix|19500' => 19500, // 3.90, 3.90.1, 3.92 |
|
| 329 | - 'r3mix|19600' => 19600, // 3.90.2, 3.90.3, 3.91 |
|
| 330 | - 'r3mix|18000' => 18000, // 3.94, 3.95 |
|
| 326 | + 'r3mix|19500' => 19500, // 3.90, 3.90.1, 3.92 |
|
| 327 | + 'r3mix|19600' => 19600, // 3.90.2, 3.90.3, 3.91 |
|
| 328 | + 'r3mix|18000' => 18000, // 3.94, 3.95 |
|
| 331 | 329 | ); |
| 332 | - if (!isset($ExpectedLowpass[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio_lame['lowpass_frequency']]) && ($thisfile_mpeg_audio_lame['lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame['lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio['sample_rate'] / 2000))) { |
|
| 330 | + if ( ! isset($ExpectedLowpass[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio_lame['lowpass_frequency']]) && ($thisfile_mpeg_audio_lame['lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame['lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio['sample_rate'] / 2000))) { |
|
| 333 | 331 | $encoder_options .= ' --lowpass '.$thisfile_mpeg_audio_lame['lowpass_frequency']; |
| 334 | 332 | } |
| 335 | 333 | break; |
@@ -380,7 +378,7 @@ discard block |
||
| 380 | 378 | 'fm/radio|32000' => 32000, // 3.92 |
| 381 | 379 | 'fm|32000' => 32000, // 3.90 |
| 382 | 380 | 'voice|32000' => 32000); |
| 383 | - if (!isset($ExpectedResampledRate[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio['sample_rate']])) { |
|
| 381 | + if ( ! isset($ExpectedResampledRate[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio['sample_rate']])) { |
|
| 384 | 382 | $encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate']; |
| 385 | 383 | } |
| 386 | 384 | break; |
@@ -396,7 +394,7 @@ discard block |
||
| 396 | 394 | } |
| 397 | 395 | } |
| 398 | 396 | } |
| 399 | - if (empty($encoder_options) && !empty($info['audio']['bitrate']) && !empty($info['audio']['bitrate_mode'])) { |
|
| 397 | + if (empty($encoder_options) && ! empty($info['audio']['bitrate']) && ! empty($info['audio']['bitrate_mode'])) { |
|
| 400 | 398 | //$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000); |
| 401 | 399 | $encoder_options = strtoupper($info['audio']['bitrate_mode']); |
| 402 | 400 | } |
@@ -405,7 +403,7 @@ discard block |
||
| 405 | 403 | } |
| 406 | 404 | |
| 407 | 405 | |
| 408 | - public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) { |
|
| 406 | + public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch = true, $ScanAsCBR = false, $FastMPEGheaderScan = false) { |
|
| 409 | 407 | static $MPEGaudioVersionLookup; |
| 410 | 408 | static $MPEGaudioLayerLookup; |
| 411 | 409 | static $MPEGaudioBitrateLookup; |
@@ -447,13 +445,13 @@ discard block |
||
| 447 | 445 | } |
| 448 | 446 | |
| 449 | 447 | static $MPEGaudioHeaderValidCache = array(); |
| 450 | - if (!isset($MPEGaudioHeaderValidCache[$head4])) { // Not in cache |
|
| 448 | + if ( ! isset($MPEGaudioHeaderValidCache[$head4])) { // Not in cache |
|
| 451 | 449 | //$MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1) |
| 452 | 450 | $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, false); |
| 453 | 451 | } |
| 454 | 452 | |
| 455 | 453 | // shortcut |
| 456 | - if (!isset($info['mpeg']['audio'])) { |
|
| 454 | + if ( ! isset($info['mpeg']['audio'])) { |
|
| 457 | 455 | $info['mpeg']['audio'] = array(); |
| 458 | 456 | } |
| 459 | 457 | $thisfile_mpeg_audio = &$info['mpeg']['audio']; |
@@ -466,14 +464,14 @@ discard block |
||
| 466 | 464 | return false; |
| 467 | 465 | } |
| 468 | 466 | |
| 469 | - if (!$FastMPEGheaderScan) { |
|
| 467 | + if ( ! $FastMPEGheaderScan) { |
|
| 470 | 468 | $thisfile_mpeg_audio['version'] = $MPEGaudioVersionLookup[$thisfile_mpeg_audio['raw']['version']]; |
| 471 | 469 | $thisfile_mpeg_audio['layer'] = $MPEGaudioLayerLookup[$thisfile_mpeg_audio['raw']['layer']]; |
| 472 | 470 | |
| 473 | 471 | $thisfile_mpeg_audio['channelmode'] = $MPEGaudioChannelModeLookup[$thisfile_mpeg_audio['raw']['channelmode']]; |
| 474 | 472 | $thisfile_mpeg_audio['channels'] = (($thisfile_mpeg_audio['channelmode'] == 'mono') ? 1 : 2); |
| 475 | 473 | $thisfile_mpeg_audio['sample_rate'] = $MPEGaudioFrequencyLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['raw']['sample_rate']]; |
| 476 | - $thisfile_mpeg_audio['protection'] = !$thisfile_mpeg_audio['raw']['protection']; |
|
| 474 | + $thisfile_mpeg_audio['protection'] = ! $thisfile_mpeg_audio['raw']['protection']; |
|
| 477 | 475 | $thisfile_mpeg_audio['private'] = (bool) $thisfile_mpeg_audio['raw']['private']; |
| 478 | 476 | $thisfile_mpeg_audio['modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['modeextension']]; |
| 479 | 477 | $thisfile_mpeg_audio['copyright'] = (bool) $thisfile_mpeg_audio['raw']['copyright']; |
@@ -503,7 +501,7 @@ discard block |
||
| 503 | 501 | } |
| 504 | 502 | |
| 505 | 503 | // For Layer 2 there are some combinations of bitrate and mode which are not allowed. |
| 506 | - if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio['layer'] == '2')) { |
|
| 504 | + if ( ! $FastMPEGheaderScan && ($thisfile_mpeg_audio['layer'] == '2')) { |
|
| 507 | 505 | |
| 508 | 506 | $info['audio']['dataformat'] = 'mp2'; |
| 509 | 507 | switch ($thisfile_mpeg_audio['channelmode']) { |
@@ -562,15 +560,15 @@ discard block |
||
| 562 | 560 | |
| 563 | 561 | $thisfile_mpeg_audio['bitrate_mode'] = 'vbr'; |
| 564 | 562 | $thisfile_mpeg_audio['VBR_method'] = 'Fraunhofer'; |
| 565 | - $info['audio']['codec'] = 'Fraunhofer'; |
|
| 563 | + $info['audio']['codec'] = 'Fraunhofer'; |
|
| 566 | 564 | |
| 567 | 565 | $SideInfoData = substr($headerstring, 4 + 2, 32); |
| 568 | 566 | |
| 569 | 567 | $FraunhoferVBROffset = 36; |
| 570 | 568 | |
| 571 | - $thisfile_mpeg_audio['VBR_encoder_version'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 4, 2)); // VbriVersion |
|
| 572 | - $thisfile_mpeg_audio['VBR_encoder_delay'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 6, 2)); // VbriDelay |
|
| 573 | - $thisfile_mpeg_audio['VBR_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 8, 2)); // VbriQuality |
|
| 569 | + $thisfile_mpeg_audio['VBR_encoder_version'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 4, 2)); // VbriVersion |
|
| 570 | + $thisfile_mpeg_audio['VBR_encoder_delay'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 6, 2)); // VbriDelay |
|
| 571 | + $thisfile_mpeg_audio['VBR_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 8, 2)); // VbriQuality |
|
| 574 | 572 | $thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 10, 4)); // VbriStreamBytes |
| 575 | 573 | $thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 14, 4)); // VbriStreamFrames |
| 576 | 574 | $thisfile_mpeg_audio['VBR_seek_offsets'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 18, 2)); // VbriTableSize |
@@ -640,15 +638,15 @@ discard block |
||
| 640 | 638 | $thisfile_mpeg_audio['xing_flags']['vbr_scale'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000008); |
| 641 | 639 | |
| 642 | 640 | if ($thisfile_mpeg_audio['xing_flags']['frames']) { |
| 643 | - $thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 8, 4)); |
|
| 641 | + $thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 8, 4)); |
|
| 644 | 642 | //$thisfile_mpeg_audio['VBR_frames']--; // don't count header Xing/Info frame |
| 645 | 643 | } |
| 646 | 644 | if ($thisfile_mpeg_audio['xing_flags']['bytes']) { |
| 647 | - $thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 12, 4)); |
|
| 645 | + $thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 12, 4)); |
|
| 648 | 646 | } |
| 649 | 647 | |
| 650 | 648 | //if (($thisfile_mpeg_audio['bitrate'] == 'free') && !empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) { |
| 651 | - if (!empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) { |
|
| 649 | + if ( ! empty($thisfile_mpeg_audio['VBR_frames']) && ! empty($thisfile_mpeg_audio['VBR_bytes'])) { |
|
| 652 | 650 | |
| 653 | 651 | $framelengthfloat = $thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']; |
| 654 | 652 | |
@@ -720,7 +718,7 @@ discard block |
||
| 720 | 718 | $LAMEtagRevisionVBRmethod = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA5, 1)); |
| 721 | 719 | |
| 722 | 720 | $thisfile_mpeg_audio_lame['tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4; |
| 723 | - $thisfile_mpeg_audio_lame_raw['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F; |
|
| 721 | + $thisfile_mpeg_audio_lame_raw['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F; |
|
| 724 | 722 | $thisfile_mpeg_audio_lame['vbr_method'] = self::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw['vbr_method']); |
| 725 | 723 | $thisfile_mpeg_audio['bitrate_mode'] = substr($thisfile_mpeg_audio_lame['vbr_method'], 0, 3); // usually either 'cbr' or 'vbr', but truncates 'vbr-old / vbr-rh' to 'vbr' |
| 726 | 724 | |
@@ -745,8 +743,8 @@ discard block |
||
| 745 | 743 | $thisfile_mpeg_audio_lame_RGAD['peak_db'] = getid3_lib::RGADamplitude2dB($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']); |
| 746 | 744 | } |
| 747 | 745 | |
| 748 | - $thisfile_mpeg_audio_lame_raw['RGAD_track'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2)); |
|
| 749 | - $thisfile_mpeg_audio_lame_raw['RGAD_album'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2)); |
|
| 746 | + $thisfile_mpeg_audio_lame_raw['RGAD_track'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2)); |
|
| 747 | + $thisfile_mpeg_audio_lame_raw['RGAD_album'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2)); |
|
| 750 | 748 | |
| 751 | 749 | |
| 752 | 750 | if ($thisfile_mpeg_audio_lame_raw['RGAD_track'] != 0) { |
@@ -754,13 +752,13 @@ discard block |
||
| 754 | 752 | $thisfile_mpeg_audio_lame_RGAD_track['raw']['name'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0xE000) >> 13; |
| 755 | 753 | $thisfile_mpeg_audio_lame_RGAD_track['raw']['originator'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x1C00) >> 10; |
| 756 | 754 | $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x0200) >> 9; |
| 757 | - $thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x01FF; |
|
| 755 | + $thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x01FF; |
|
| 758 | 756 | $thisfile_mpeg_audio_lame_RGAD_track['name'] = getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['name']); |
| 759 | 757 | $thisfile_mpeg_audio_lame_RGAD_track['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['originator']); |
| 760 | 758 | $thisfile_mpeg_audio_lame_RGAD_track['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit']); |
| 761 | 759 | |
| 762 | - if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { |
|
| 763 | - $info['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; |
|
| 760 | + if ( ! empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { |
|
| 761 | + $info['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; |
|
| 764 | 762 | } |
| 765 | 763 | $info['replay_gain']['track']['originator'] = $thisfile_mpeg_audio_lame_RGAD_track['originator']; |
| 766 | 764 | $info['replay_gain']['track']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track['gain_db']; |
@@ -777,8 +775,8 @@ discard block |
||
| 777 | 775 | $thisfile_mpeg_audio_lame_RGAD_album['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['originator']); |
| 778 | 776 | $thisfile_mpeg_audio_lame_RGAD_album['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit']); |
| 779 | 777 | |
| 780 | - if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { |
|
| 781 | - $info['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; |
|
| 778 | + if ( ! empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { |
|
| 779 | + $info['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; |
|
| 782 | 780 | } |
| 783 | 781 | $info['replay_gain']['album']['originator'] = $thisfile_mpeg_audio_lame_RGAD_album['originator']; |
| 784 | 782 | $info['replay_gain']['album']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album['gain_db']; |
@@ -796,7 +794,7 @@ discard block |
||
| 796 | 794 | $thisfile_mpeg_audio_lame['encoding_flags']['nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20); |
| 797 | 795 | $thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'] = (bool) ($EncodingFlagsATHtype & 0x40); |
| 798 | 796 | $thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev'] = (bool) ($EncodingFlagsATHtype & 0x80); |
| 799 | - $thisfile_mpeg_audio_lame['ath_type'] = $EncodingFlagsATHtype & 0x0F; |
|
| 797 | + $thisfile_mpeg_audio_lame['ath_type'] = $EncodingFlagsATHtype & 0x0F; |
|
| 800 | 798 | |
| 801 | 799 | // byte $B0 if ABR {specified bitrate} else {minimal bitrate} |
| 802 | 800 | $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB0, 1)); |
@@ -811,7 +809,7 @@ discard block |
||
| 811 | 809 | // bytes $B1-$B3 Encoder delays |
| 812 | 810 | $EncoderDelays = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB1, 3)); |
| 813 | 811 | $thisfile_mpeg_audio_lame['encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12; |
| 814 | - $thisfile_mpeg_audio_lame['end_padding'] = $EncoderDelays & 0x000FFF; |
|
| 812 | + $thisfile_mpeg_audio_lame['end_padding'] = $EncoderDelays & 0x000FFF; |
|
| 815 | 813 | |
| 816 | 814 | // byte $B4 Misc |
| 817 | 815 | $MiscByte = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB4, 1)); |
@@ -836,10 +834,10 @@ discard block |
||
| 836 | 834 | $thisfile_mpeg_audio_lame['surround_info'] = self::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw['surround_info']); |
| 837 | 835 | $thisfile_mpeg_audio_lame['preset_used_id'] = ($PresetSurroundBytes & 0x07FF); |
| 838 | 836 | $thisfile_mpeg_audio_lame['preset_used'] = self::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame); |
| 839 | - if (!empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) { |
|
| 837 | + if ( ! empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) { |
|
| 840 | 838 | $info['warning'][] = 'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to [email protected]'; |
| 841 | 839 | } |
| 842 | - if (($thisfile_mpeg_audio_lame['short_version'] == 'LAME3.90.') && !empty($thisfile_mpeg_audio_lame['preset_used_id'])) { |
|
| 840 | + if (($thisfile_mpeg_audio_lame['short_version'] == 'LAME3.90.') && ! empty($thisfile_mpeg_audio_lame['preset_used_id'])) { |
|
| 843 | 841 | // this may change if 3.90.4 ever comes out |
| 844 | 842 | $thisfile_mpeg_audio_lame['short_version'] = 'LAME3.90.3'; |
| 845 | 843 | } |
@@ -948,7 +946,7 @@ discard block |
||
| 948 | 946 | } |
| 949 | 947 | $thisfile_mpeg_audio['VBR_bitrate'] = (isset($thisfile_mpeg_audio['VBR_bytes']) ? (($thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($info['audio']['sample_rate'] / $bytes_per_frame) : 0); |
| 950 | 948 | if ($thisfile_mpeg_audio['VBR_bitrate'] > 0) { |
| 951 | - $info['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; |
|
| 949 | + $info['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; |
|
| 952 | 950 | $thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; // to avoid confusion |
| 953 | 951 | } |
| 954 | 952 | break; |
@@ -960,7 +958,7 @@ discard block |
||
| 960 | 958 | |
| 961 | 959 | if ($recursivesearch) { |
| 962 | 960 | |
| 963 | - if (!$this->RecursiveFrameScanning($offset, $nextframetestoffset, $ScanAsCBR)) { |
|
| 961 | + if ( ! $this->RecursiveFrameScanning($offset, $nextframetestoffset, $ScanAsCBR)) { |
|
| 964 | 962 | return false; |
| 965 | 963 | } |
| 966 | 964 | |
@@ -1088,7 +1086,7 @@ discard block |
||
| 1088 | 1086 | if ($this->decodeMPEGaudioHeader($nextframetestoffset, $nextframetestarray, false)) { |
| 1089 | 1087 | if ($ScanAsCBR) { |
| 1090 | 1088 | // force CBR mode, used for trying to pick out invalid audio streams with valid(?) VBR headers, or VBR streams with no VBR header |
| 1091 | - if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($firstframetestarray['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $firstframetestarray['mpeg']['audio']['bitrate'])) { |
|
| 1089 | + if ( ! isset($nextframetestarray['mpeg']['audio']['bitrate']) || ! isset($firstframetestarray['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $firstframetestarray['mpeg']['audio']['bitrate'])) { |
|
| 1092 | 1090 | return false; |
| 1093 | 1091 | } |
| 1094 | 1092 | } |
@@ -1102,7 +1100,7 @@ discard block |
||
| 1102 | 1100 | return false; |
| 1103 | 1101 | } |
| 1104 | 1102 | |
| 1105 | - } elseif (!empty($firstframetestarray['mpeg']['audio']['framelength']) && (($nextframetestoffset + $firstframetestarray['mpeg']['audio']['framelength']) > $info['avdataend'])) { |
|
| 1103 | + } elseif ( ! empty($firstframetestarray['mpeg']['audio']['framelength']) && (($nextframetestoffset + $firstframetestarray['mpeg']['audio']['framelength']) > $info['avdataend'])) { |
|
| 1106 | 1104 | |
| 1107 | 1105 | // it's not the end of the file, but there's not enough data left for another frame, so assume it's garbage/padding and return OK |
| 1108 | 1106 | return true; |
@@ -1118,7 +1116,7 @@ discard block |
||
| 1118 | 1116 | return true; |
| 1119 | 1117 | } |
| 1120 | 1118 | |
| 1121 | - public function FreeFormatFrameLength($offset, $deepscan=false) { |
|
| 1119 | + public function FreeFormatFrameLength($offset, $deepscan = false) { |
|
| 1122 | 1120 | $info = &$this->getid3->info; |
| 1123 | 1121 | |
| 1124 | 1122 | $this->fseek($offset); |
@@ -1140,7 +1138,7 @@ discard block |
||
| 1140 | 1138 | if (($framelength2 > 4) && ($framelength2 < $framelength1)) { |
| 1141 | 1139 | $framelength = $framelength2; |
| 1142 | 1140 | } |
| 1143 | - if (!$framelength) { |
|
| 1141 | + if ( ! $framelength) { |
|
| 1144 | 1142 | |
| 1145 | 1143 | // LAME 3.88 has a different value for modeextension on the first frame vs the rest |
| 1146 | 1144 | $framelength1 = strpos($MPEGaudioData, substr($SyncPattern1, 0, 3), 4); |
@@ -1152,7 +1150,7 @@ discard block |
||
| 1152 | 1150 | if (($framelength2 > 4) && ($framelength2 < $framelength1)) { |
| 1153 | 1151 | $framelength = $framelength2; |
| 1154 | 1152 | } |
| 1155 | - if (!$framelength) { |
|
| 1153 | + if ( ! $framelength) { |
|
| 1156 | 1154 | $info['error'][] = 'Cannot find next free-format synch pattern ('.getid3_lib::PrintHexBytes($SyncPattern1).' or '.getid3_lib::PrintHexBytes($SyncPattern2).') after offset '.$offset; |
| 1157 | 1155 | return false; |
| 1158 | 1156 | } else { |
@@ -1239,15 +1237,15 @@ discard block |
||
| 1239 | 1237 | } |
| 1240 | 1238 | continue; |
| 1241 | 1239 | } |
| 1242 | - if (!isset($MPEGaudioHeaderDecodeCache[$head4])) { |
|
| 1240 | + if ( ! isset($MPEGaudioHeaderDecodeCache[$head4])) { |
|
| 1243 | 1241 | $MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4); |
| 1244 | 1242 | } |
| 1245 | - if (!isset($MPEGaudioHeaderValidCache[$head4])) { |
|
| 1243 | + if ( ! isset($MPEGaudioHeaderValidCache[$head4])) { |
|
| 1246 | 1244 | $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false); |
| 1247 | 1245 | } |
| 1248 | 1246 | if ($MPEGaudioHeaderValidCache[$head4]) { |
| 1249 | 1247 | |
| 1250 | - if (!isset($MPEGaudioHeaderLengthCache[$head4])) { |
|
| 1248 | + if ( ! isset($MPEGaudioHeaderLengthCache[$head4])) { |
|
| 1251 | 1249 | $LongMPEGversionLookup[$head4] = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4]['version']]; |
| 1252 | 1250 | $LongMPEGlayerLookup[$head4] = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4]['layer']]; |
| 1253 | 1251 | $LongMPEGbitrateLookup[$head4] = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']]; |
@@ -1265,10 +1263,10 @@ discard block |
||
| 1265 | 1263 | $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR); |
| 1266 | 1264 | $next4 = $this->fread(4); |
| 1267 | 1265 | if ($next4{0} == "\xFF") { |
| 1268 | - if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { |
|
| 1266 | + if ( ! isset($MPEGaudioHeaderDecodeCache[$next4])) { |
|
| 1269 | 1267 | $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4); |
| 1270 | 1268 | } |
| 1271 | - if (!isset($MPEGaudioHeaderValidCache[$next4])) { |
|
| 1269 | + if ( ! isset($MPEGaudioHeaderValidCache[$next4])) { |
|
| 1272 | 1270 | $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false); |
| 1273 | 1271 | } |
| 1274 | 1272 | if ($MPEGaudioHeaderValidCache[$next4]) { |
@@ -1324,7 +1322,7 @@ discard block |
||
| 1324 | 1322 | $bittotal += ($bitratevalue * $bitratecount); |
| 1325 | 1323 | } |
| 1326 | 1324 | } |
| 1327 | - $info['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']); |
|
| 1325 | + $info['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']); |
|
| 1328 | 1326 | if ($info['mpeg']['audio']['frame_count'] == 0) { |
| 1329 | 1327 | $info['error'][] = 'no MPEG audio frames found'; |
| 1330 | 1328 | return false; |
@@ -1343,7 +1341,7 @@ discard block |
||
| 1343 | 1341 | } |
| 1344 | 1342 | |
| 1345 | 1343 | |
| 1346 | - public function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) { |
|
| 1344 | + public function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram = false) { |
|
| 1347 | 1345 | // looks for synch, decodes MPEG audio header |
| 1348 | 1346 | |
| 1349 | 1347 | $info = &$this->getid3->info; |
@@ -1368,7 +1366,7 @@ discard block |
||
| 1368 | 1366 | $sync_seek_buffer_size = strlen($header); |
| 1369 | 1367 | $SynchSeekOffset = 0; |
| 1370 | 1368 | while ($SynchSeekOffset < $sync_seek_buffer_size) { |
| 1371 | - if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !feof($this->getid3->fp)) { |
|
| 1369 | + if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && ! feof($this->getid3->fp)) { |
|
| 1372 | 1370 | |
| 1373 | 1371 | if ($SynchSeekOffset > $sync_seek_buffer_size) { |
| 1374 | 1372 | // if a synch's not found within the first 128k bytes, then give up |
@@ -1393,7 +1391,7 @@ discard block |
||
| 1393 | 1391 | if (isset($info['mpeg']['audio'])) { |
| 1394 | 1392 | unset($info['mpeg']['audio']); |
| 1395 | 1393 | } |
| 1396 | - if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) { |
|
| 1394 | + if (isset($info['mpeg']) && ( ! is_array($info['mpeg']) || (count($info['mpeg']) == 0))) { |
|
| 1397 | 1395 | unset($info['mpeg']); |
| 1398 | 1396 | } |
| 1399 | 1397 | return false; |
@@ -1406,10 +1404,10 @@ discard block |
||
| 1406 | 1404 | } |
| 1407 | 1405 | |
| 1408 | 1406 | if (($header{$SynchSeekOffset} == "\xFF") && ($header{($SynchSeekOffset + 1)} > "\xE0")) { // synch detected |
| 1409 | - if (!isset($FirstFrameThisfileInfo) && !isset($info['mpeg']['audio'])) { |
|
| 1407 | + if ( ! isset($FirstFrameThisfileInfo) && ! isset($info['mpeg']['audio'])) { |
|
| 1410 | 1408 | $FirstFrameThisfileInfo = $info; |
| 1411 | 1409 | $FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset; |
| 1412 | - if (!$this->decodeMPEGaudioHeader($FirstFrameAVDataOffset, $FirstFrameThisfileInfo, false)) { |
|
| 1410 | + if ( ! $this->decodeMPEGaudioHeader($FirstFrameAVDataOffset, $FirstFrameThisfileInfo, false)) { |
|
| 1413 | 1411 | // if this is the first valid MPEG-audio frame, save it in case it's a VBR header frame and there's |
| 1414 | 1412 | // garbage between this frame and a valid sequence of MPEG-audio frames, to be restored below |
| 1415 | 1413 | unset($FirstFrameThisfileInfo); |
@@ -1421,16 +1419,12 @@ discard block |
||
| 1421 | 1419 | $info = $dummy; |
| 1422 | 1420 | $info['avdataoffset'] = $avdataoffset + $SynchSeekOffset; |
| 1423 | 1421 | switch (isset($info['fileformat']) ? $info['fileformat'] : '') { |
| 1424 | - case '': |
|
| 1425 | - case 'id3': |
|
| 1426 | - case 'ape': |
|
| 1427 | - case 'mp3': |
|
| 1428 | - $info['fileformat'] = 'mp3'; |
|
| 1422 | + case '' : case 'id3' : case 'ape' : case 'mp3' : $info['fileformat'] = 'mp3'; |
|
| 1429 | 1423 | $info['audio']['dataformat'] = 'mp3'; |
| 1430 | 1424 | break; |
| 1431 | 1425 | } |
| 1432 | 1426 | if (isset($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode']) && ($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr')) { |
| 1433 | - if (!(abs($info['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) { |
|
| 1427 | + if ( ! (abs($info['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) { |
|
| 1434 | 1428 | // If there is garbage data between a valid VBR header frame and a sequence |
| 1435 | 1429 | // of valid MPEG-audio frames the VBR data is no longer discarded. |
| 1436 | 1430 | $info = $FirstFrameThisfileInfo; |
@@ -1450,7 +1444,7 @@ discard block |
||
| 1450 | 1444 | } |
| 1451 | 1445 | } |
| 1452 | 1446 | } |
| 1453 | - if (isset($info['mpeg']['audio']['bitrate_mode']) && ($info['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($info['mpeg']['audio']['VBR_method'])) { |
|
| 1447 | + if (isset($info['mpeg']['audio']['bitrate_mode']) && ($info['mpeg']['audio']['bitrate_mode'] == 'vbr') && ! isset($info['mpeg']['audio']['VBR_method'])) { |
|
| 1454 | 1448 | // VBR file with no VBR header |
| 1455 | 1449 | $BitrateHistogram = true; |
| 1456 | 1450 | } |
@@ -1479,7 +1473,7 @@ discard block |
||
| 1479 | 1473 | $this->fseek($info['avdataoffset']); |
| 1480 | 1474 | |
| 1481 | 1475 | // you can play with these numbers: |
| 1482 | - $max_frames_scan = 50000; |
|
| 1476 | + $max_frames_scan = 50000; |
|
| 1483 | 1477 | $max_scan_segments = 10; |
| 1484 | 1478 | |
| 1485 | 1479 | // don't play with these numbers: |
@@ -1541,7 +1535,7 @@ discard block |
||
| 1541 | 1535 | if ($pct_data_scanned > 0) { |
| 1542 | 1536 | $info['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.'; |
| 1543 | 1537 | foreach ($info['mpeg']['audio'] as $key1 => $value1) { |
| 1544 | - if (!preg_match('#_distribution$#i', $key1)) { |
|
| 1538 | + if ( ! preg_match('#_distribution$#i', $key1)) { |
|
| 1545 | 1539 | continue; |
| 1546 | 1540 | } |
| 1547 | 1541 | foreach ($value1 as $key2 => $value2) { |
@@ -1606,7 +1600,7 @@ discard block |
||
| 1606 | 1600 | if (isset($info['mpeg']['audio'])) { |
| 1607 | 1601 | unset($info['mpeg']['audio']); |
| 1608 | 1602 | } |
| 1609 | - if (isset($info['mpeg']) && (!is_array($info['mpeg']) || empty($info['mpeg']))) { |
|
| 1603 | + if (isset($info['mpeg']) && ( ! is_array($info['mpeg']) || empty($info['mpeg']))) { |
|
| 1610 | 1604 | unset($info['mpeg']); |
| 1611 | 1605 | } |
| 1612 | 1606 | return false; |
@@ -1636,14 +1630,14 @@ discard block |
||
| 1636 | 1630 | public static function MPEGaudioBitrateArray() { |
| 1637 | 1631 | static $MPEGaudioBitrate; |
| 1638 | 1632 | if (empty($MPEGaudioBitrate)) { |
| 1639 | - $MPEGaudioBitrate = array ( |
|
| 1640 | - '1' => array (1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000), |
|
| 1641 | - 2 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000), |
|
| 1642 | - 3 => array('free', 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000) |
|
| 1633 | + $MPEGaudioBitrate = array( |
|
| 1634 | + '1' => array(1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000), |
|
| 1635 | + 2 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000), |
|
| 1636 | + 3 => array('free', 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000) |
|
| 1643 | 1637 | ), |
| 1644 | 1638 | |
| 1645 | - '2' => array (1 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000), |
|
| 1646 | - 2 => array('free', 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000), |
|
| 1639 | + '2' => array(1 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000), |
|
| 1640 | + 2 => array('free', 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000), |
|
| 1647 | 1641 | ) |
| 1648 | 1642 | ); |
| 1649 | 1643 | $MPEGaudioBitrate['2'][3] = $MPEGaudioBitrate['2'][2]; |
@@ -1655,10 +1649,10 @@ discard block |
||
| 1655 | 1649 | public static function MPEGaudioFrequencyArray() { |
| 1656 | 1650 | static $MPEGaudioFrequency; |
| 1657 | 1651 | if (empty($MPEGaudioFrequency)) { |
| 1658 | - $MPEGaudioFrequency = array ( |
|
| 1652 | + $MPEGaudioFrequency = array( |
|
| 1659 | 1653 | '1' => array(44100, 48000, 32000), |
| 1660 | 1654 | '2' => array(22050, 24000, 16000), |
| 1661 | - '2.5' => array(11025, 12000, 8000) |
|
| 1655 | + '2.5' => array(11025, 12000, 8000) |
|
| 1662 | 1656 | ); |
| 1663 | 1657 | } |
| 1664 | 1658 | return $MPEGaudioFrequency; |
@@ -1672,7 +1666,7 @@ discard block |
||
| 1672 | 1666 | public static function MPEGaudioModeExtensionArray() { |
| 1673 | 1667 | static $MPEGaudioModeExtension; |
| 1674 | 1668 | if (empty($MPEGaudioModeExtension)) { |
| 1675 | - $MPEGaudioModeExtension = array ( |
|
| 1669 | + $MPEGaudioModeExtension = array( |
|
| 1676 | 1670 | 1 => array('4-31', '8-31', '12-31', '16-31'), |
| 1677 | 1671 | 2 => array('4-31', '8-31', '12-31', '16-31'), |
| 1678 | 1672 | 3 => array('', 'IS', 'MS', 'IS+MS') |
@@ -1686,11 +1680,11 @@ discard block |
||
| 1686 | 1680 | return $MPEGaudioEmphasis; |
| 1687 | 1681 | } |
| 1688 | 1682 | |
| 1689 | - public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) { |
|
| 1683 | + public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15 = false) { |
|
| 1690 | 1684 | return self::MPEGaudioHeaderValid(self::MPEGaudioHeaderDecode($head4), false, $allowBitrate15); |
| 1691 | 1685 | } |
| 1692 | 1686 | |
| 1693 | - public static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) { |
|
| 1687 | + public static function MPEGaudioHeaderValid($rawarray, $echoerrors = false, $allowBitrate15 = false) { |
|
| 1694 | 1688 | if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) { |
| 1695 | 1689 | return false; |
| 1696 | 1690 | } |
@@ -1724,31 +1718,31 @@ discard block |
||
| 1724 | 1718 | echo ($echoerrors ? "\n".'invalid Layer ('.$rawarray['layer'].')' : ''); |
| 1725 | 1719 | return false; |
| 1726 | 1720 | } |
| 1727 | - if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) { |
|
| 1721 | + if ( ! isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) { |
|
| 1728 | 1722 | echo ($echoerrors ? "\n".'invalid Bitrate ('.$rawarray['bitrate'].')' : ''); |
| 1729 | 1723 | if ($rawarray['bitrate'] == 15) { |
| 1730 | 1724 | // known issue in LAME 3.90 - 3.93.1 where free-format has bitrate ID of 15 instead of 0 |
| 1731 | 1725 | // let it go through here otherwise file will not be identified |
| 1732 | - if (!$allowBitrate15) { |
|
| 1726 | + if ( ! $allowBitrate15) { |
|
| 1733 | 1727 | return false; |
| 1734 | 1728 | } |
| 1735 | 1729 | } else { |
| 1736 | 1730 | return false; |
| 1737 | 1731 | } |
| 1738 | 1732 | } |
| 1739 | - if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) { |
|
| 1733 | + if ( ! isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) { |
|
| 1740 | 1734 | echo ($echoerrors ? "\n".'invalid Frequency ('.$rawarray['sample_rate'].')' : ''); |
| 1741 | 1735 | return false; |
| 1742 | 1736 | } |
| 1743 | - if (!isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) { |
|
| 1737 | + if ( ! isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) { |
|
| 1744 | 1738 | echo ($echoerrors ? "\n".'invalid ChannelMode ('.$rawarray['channelmode'].')' : ''); |
| 1745 | 1739 | return false; |
| 1746 | 1740 | } |
| 1747 | - if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) { |
|
| 1741 | + if ( ! isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) { |
|
| 1748 | 1742 | echo ($echoerrors ? "\n".'invalid Mode Extension ('.$rawarray['modeextension'].')' : ''); |
| 1749 | 1743 | return false; |
| 1750 | 1744 | } |
| 1751 | - if (!isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) { |
|
| 1745 | + if ( ! isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) { |
|
| 1752 | 1746 | echo ($echoerrors ? "\n".'invalid Emphasis ('.$rawarray['emphasis'].')' : ''); |
| 1753 | 1747 | return false; |
| 1754 | 1748 | } |
@@ -1785,16 +1779,16 @@ discard block |
||
| 1785 | 1779 | $MPEGrawHeader['synch'] = (getid3_lib::BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xFFE0) >> 4; |
| 1786 | 1780 | $MPEGrawHeader['version'] = (ord($Header4Bytes{1}) & 0x18) >> 3; // BB |
| 1787 | 1781 | $MPEGrawHeader['layer'] = (ord($Header4Bytes{1}) & 0x06) >> 1; // CC |
| 1788 | - $MPEGrawHeader['protection'] = (ord($Header4Bytes{1}) & 0x01); // D |
|
| 1782 | + $MPEGrawHeader['protection'] = (ord($Header4Bytes{1}) & 0x01); // D |
|
| 1789 | 1783 | $MPEGrawHeader['bitrate'] = (ord($Header4Bytes{2}) & 0xF0) >> 4; // EEEE |
| 1790 | 1784 | $MPEGrawHeader['sample_rate'] = (ord($Header4Bytes{2}) & 0x0C) >> 2; // FF |
| 1791 | 1785 | $MPEGrawHeader['padding'] = (ord($Header4Bytes{2}) & 0x02) >> 1; // G |
| 1792 | - $MPEGrawHeader['private'] = (ord($Header4Bytes{2}) & 0x01); // H |
|
| 1786 | + $MPEGrawHeader['private'] = (ord($Header4Bytes{2}) & 0x01); // H |
|
| 1793 | 1787 | $MPEGrawHeader['channelmode'] = (ord($Header4Bytes{3}) & 0xC0) >> 6; // II |
| 1794 | 1788 | $MPEGrawHeader['modeextension'] = (ord($Header4Bytes{3}) & 0x30) >> 4; // JJ |
| 1795 | 1789 | $MPEGrawHeader['copyright'] = (ord($Header4Bytes{3}) & 0x08) >> 3; // K |
| 1796 | 1790 | $MPEGrawHeader['original'] = (ord($Header4Bytes{3}) & 0x04) >> 2; // L |
| 1797 | - $MPEGrawHeader['emphasis'] = (ord($Header4Bytes{3}) & 0x03); // MM |
|
| 1791 | + $MPEGrawHeader['emphasis'] = (ord($Header4Bytes{3}) & 0x03); // MM |
|
| 1798 | 1792 | |
| 1799 | 1793 | return $MPEGrawHeader; |
| 1800 | 1794 | } |
@@ -1802,7 +1796,7 @@ discard block |
||
| 1802 | 1796 | public static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) { |
| 1803 | 1797 | static $AudioFrameLengthCache = array(); |
| 1804 | 1798 | |
| 1805 | - if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) { |
|
| 1799 | + if ( ! isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) { |
|
| 1806 | 1800 | $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = false; |
| 1807 | 1801 | if ($bitrate != 'free') { |
| 1808 | 1802 | |
@@ -1861,10 +1855,10 @@ discard block |
||
| 1861 | 1855 | } |
| 1862 | 1856 | |
| 1863 | 1857 | public static function ClosestStandardMP3Bitrate($bit_rate) { |
| 1864 | - static $standard_bit_rates = array (320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000); |
|
| 1865 | - static $bit_rate_table = array (0=>'-'); |
|
| 1858 | + static $standard_bit_rates = array(320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000); |
|
| 1859 | + static $bit_rate_table = array(0=>'-'); |
|
| 1866 | 1860 | $round_bit_rate = intval(round($bit_rate, -3)); |
| 1867 | - if (!isset($bit_rate_table[$round_bit_rate])) { |
|
| 1861 | + if ( ! isset($bit_rate_table[$round_bit_rate])) { |
|
| 1868 | 1862 | if ($round_bit_rate > max($standard_bit_rates)) { |
| 1869 | 1863 | $bit_rate_table[$round_bit_rate] = round($bit_rate, 2 - strlen($bit_rate)); |
| 1870 | 1864 | } else { |
@@ -1883,20 +1877,20 @@ discard block |
||
| 1883 | 1877 | public static function XingVBRidOffset($version, $channelmode) { |
| 1884 | 1878 | static $XingVBRidOffsetCache = array(); |
| 1885 | 1879 | if (empty($XingVBRidOffset)) { |
| 1886 | - $XingVBRidOffset = array ( |
|
| 1887 | - '1' => array ('mono' => 0x15, // 4 + 17 = 21 |
|
| 1880 | + $XingVBRidOffset = array( |
|
| 1881 | + '1' => array('mono' => 0x15, // 4 + 17 = 21 |
|
| 1888 | 1882 | 'stereo' => 0x24, // 4 + 32 = 36 |
| 1889 | 1883 | 'joint stereo' => 0x24, |
| 1890 | 1884 | 'dual channel' => 0x24 |
| 1891 | 1885 | ), |
| 1892 | 1886 | |
| 1893 | - '2' => array ('mono' => 0x0D, // 4 + 9 = 13 |
|
| 1887 | + '2' => array('mono' => 0x0D, // 4 + 9 = 13 |
|
| 1894 | 1888 | 'stereo' => 0x15, // 4 + 17 = 21 |
| 1895 | 1889 | 'joint stereo' => 0x15, |
| 1896 | 1890 | 'dual channel' => 0x15 |
| 1897 | 1891 | ), |
| 1898 | 1892 | |
| 1899 | - '2.5' => array ('mono' => 0x15, |
|
| 1893 | + '2.5' => array('mono' => 0x15, |
|
| 1900 | 1894 | 'stereo' => 0x15, |
| 1901 | 1895 | 'joint stereo' => 0x15, |
| 1902 | 1896 | 'dual channel' => 0x15 |
@@ -1991,20 +1985,20 @@ discard block |
||
| 1991 | 1985 | $LAMEpresetUsedLookup[1007] = '--alt-preset fast medium'; |
| 1992 | 1986 | |
| 1993 | 1987 | // LAME 3.94 additions/changes |
| 1994 | - $LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003 |
|
| 1995 | - $LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003 |
|
| 1988 | + $LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003 |
|
| 1989 | + $LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003 |
|
| 1996 | 1990 | |
| 1997 | - $LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003 |
|
| 1991 | + $LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003 |
|
| 1998 | 1992 | $LAMEpresetUsedLookup[410] = '-V9'; |
| 1999 | 1993 | $LAMEpresetUsedLookup[420] = '-V8'; |
| 2000 | 1994 | $LAMEpresetUsedLookup[440] = '-V6'; |
| 2001 | - $LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003 |
|
| 2002 | - $LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003 |
|
| 2003 | - $LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003 |
|
| 2004 | - $LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003 |
|
| 2005 | - $LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003 |
|
| 1995 | + $LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003 |
|
| 1996 | + $LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003 |
|
| 1997 | + $LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003 |
|
| 1998 | + $LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003 |
|
| 1999 | + $LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003 |
|
| 2006 | 2000 | $LAMEpresetUsedLookup[490] = '-V1'; |
| 2007 | - $LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003 |
|
| 2001 | + $LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003 |
|
| 2008 | 2002 | |
| 2009 | 2003 | return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to [email protected]'); |
| 2010 | 2004 | } |
@@ -893,11 +893,9 @@ |
||
| 893 | 893 | if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) { |
| 894 | 894 | if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) { |
| 895 | 895 | // ignore, audio data is broken into chunks so will always be data "missing" |
| 896 | - } |
|
| 897 | - elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) { |
|
| 896 | + } elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) { |
|
| 898 | 897 | $this->warning('Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)'); |
| 899 | - } |
|
| 900 | - else { |
|
| 898 | + } else { |
|
| 901 | 899 | $this->warning('Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)'); |
| 902 | 900 | } |
| 903 | 901 | } else { |
@@ -427,6 +427,11 @@ |
||
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // http://tools.ietf.org/html/draft-ietf-codec-oggopus-03 |
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * @param string $filedata |
|
| 433 | + * @param integer $filedataoffset |
|
| 434 | + */ |
|
| 430 | 435 | public function ParseOpusPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) { |
| 431 | 436 | $info = &$this->getid3->info; |
| 432 | 437 | $info['audio']['dataformat'] = 'opus'; |
@@ -528,7 +528,7 @@ |
||
| 528 | 528 | return $oggheader; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005 |
|
| 531 | + // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005 |
|
| 532 | 532 | public function ParseVorbisComments() { |
| 533 | 533 | $info = &$this->getid3->info; |
| 534 | 534 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | } elseif (substr($filedata, 0, 8) == 'OpusHead') { |
| 67 | 67 | |
| 68 | - if( $this->ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) == false ) { |
|
| 68 | + if ($this->ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) == false) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | $info['audio']['bitrate_mode'] = 'abr'; |
| 79 | 79 | $info['audio']['lossless'] = false; |
| 80 | 80 | |
| 81 | - $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex ' |
|
| 81 | + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex ' |
|
| 82 | 82 | $filedataoffset += 8; |
| 83 | - $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20); |
|
| 83 | + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20); |
|
| 84 | 84 | $filedataoffset += 20; |
| 85 | 85 | $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
| 86 | 86 | $filedataoffset += 4; |
@@ -125,45 +125,45 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | // http://www.theora.org/doc/Theora.pdf (section 6.2) |
| 127 | 127 | |
| 128 | - $info['ogg']['pageheader']['theora']['theora_magic'] = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora' |
|
| 128 | + $info['ogg']['pageheader']['theora']['theora_magic'] = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora' |
|
| 129 | 129 | $filedataoffset += 7; |
| 130 | - $info['ogg']['pageheader']['theora']['version_major'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 130 | + $info['ogg']['pageheader']['theora']['version_major'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 131 | 131 | $filedataoffset += 1; |
| 132 | - $info['ogg']['pageheader']['theora']['version_minor'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 132 | + $info['ogg']['pageheader']['theora']['version_minor'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 133 | 133 | $filedataoffset += 1; |
| 134 | - $info['ogg']['pageheader']['theora']['version_revision'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 134 | + $info['ogg']['pageheader']['theora']['version_revision'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 135 | 135 | $filedataoffset += 1; |
| 136 | - $info['ogg']['pageheader']['theora']['frame_width_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 136 | + $info['ogg']['pageheader']['theora']['frame_width_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 137 | 137 | $filedataoffset += 2; |
| 138 | - $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 138 | + $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 139 | 139 | $filedataoffset += 2; |
| 140 | - $info['ogg']['pageheader']['theora']['resolution_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 140 | + $info['ogg']['pageheader']['theora']['resolution_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 141 | 141 | $filedataoffset += 3; |
| 142 | - $info['ogg']['pageheader']['theora']['resolution_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 142 | + $info['ogg']['pageheader']['theora']['resolution_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 143 | 143 | $filedataoffset += 3; |
| 144 | - $info['ogg']['pageheader']['theora']['picture_offset_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 144 | + $info['ogg']['pageheader']['theora']['picture_offset_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 145 | 145 | $filedataoffset += 1; |
| 146 | - $info['ogg']['pageheader']['theora']['picture_offset_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 146 | + $info['ogg']['pageheader']['theora']['picture_offset_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 147 | 147 | $filedataoffset += 1; |
| 148 | - $info['ogg']['pageheader']['theora']['frame_rate_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 148 | + $info['ogg']['pageheader']['theora']['frame_rate_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 149 | 149 | $filedataoffset += 4; |
| 150 | - $info['ogg']['pageheader']['theora']['frame_rate_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 150 | + $info['ogg']['pageheader']['theora']['frame_rate_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 151 | 151 | $filedataoffset += 4; |
| 152 | - $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 152 | + $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 153 | 153 | $filedataoffset += 3; |
| 154 | - $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 154 | + $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 155 | 155 | $filedataoffset += 3; |
| 156 | - $info['ogg']['pageheader']['theora']['color_space_id'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 156 | + $info['ogg']['pageheader']['theora']['color_space_id'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 157 | 157 | $filedataoffset += 1; |
| 158 | - $info['ogg']['pageheader']['theora']['nominal_bitrate'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 158 | + $info['ogg']['pageheader']['theora']['nominal_bitrate'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); |
|
| 159 | 159 | $filedataoffset += 3; |
| 160 | - $info['ogg']['pageheader']['theora']['flags'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 160 | + $info['ogg']['pageheader']['theora']['flags'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 161 | 161 | $filedataoffset += 2; |
| 162 | 162 | |
| 163 | 163 | $info['ogg']['pageheader']['theora']['quality'] = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10; |
| 164 | - $info['ogg']['pageheader']['theora']['kfg_shift'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5; |
|
| 165 | - $info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3; |
|
| 166 | - $info['ogg']['pageheader']['theora']['reserved'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0 |
|
| 164 | + $info['ogg']['pageheader']['theora']['kfg_shift'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5; |
|
| 165 | + $info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3; |
|
| 166 | + $info['ogg']['pageheader']['theora']['reserved'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0 |
|
| 167 | 167 | $info['ogg']['pageheader']['theora']['color_space'] = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']); |
| 168 | 168 | $info['ogg']['pageheader']['theora']['pixel_format'] = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']); |
| 169 | 169 | |
@@ -187,24 +187,24 @@ discard block |
||
| 187 | 187 | // Ogg Skeleton version 3.0 Format Specification |
| 188 | 188 | // http://xiph.org/ogg/doc/skeleton.html |
| 189 | 189 | $filedataoffset += 8; |
| 190 | - $info['ogg']['skeleton']['fishead']['raw']['version_major'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 190 | + $info['ogg']['skeleton']['fishead']['raw']['version_major'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 191 | 191 | $filedataoffset += 2; |
| 192 | - $info['ogg']['skeleton']['fishead']['raw']['version_minor'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 192 | + $info['ogg']['skeleton']['fishead']['raw']['version_minor'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 193 | 193 | $filedataoffset += 2; |
| 194 | - $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 194 | + $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 195 | 195 | $filedataoffset += 8; |
| 196 | - $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 196 | + $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 197 | 197 | $filedataoffset += 8; |
| 198 | - $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 198 | + $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 199 | 199 | $filedataoffset += 8; |
| 200 | - $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 200 | + $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 201 | 201 | $filedataoffset += 8; |
| 202 | 202 | $info['ogg']['skeleton']['fishead']['raw']['utc'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 20)); |
| 203 | 203 | $filedataoffset += 20; |
| 204 | 204 | |
| 205 | 205 | $info['ogg']['skeleton']['fishead']['version'] = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor']; |
| 206 | 206 | $info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator']; |
| 207 | - $info['ogg']['skeleton']['fishead']['basetime'] = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']; |
|
| 207 | + $info['ogg']['skeleton']['fishead']['basetime'] = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']; |
|
| 208 | 208 | $info['ogg']['skeleton']['fishead']['utc'] = $info['ogg']['skeleton']['fishead']['raw']['utc']; |
| 209 | 209 | |
| 210 | 210 | |
@@ -218,23 +218,23 @@ discard block |
||
| 218 | 218 | if (substr($filedata, 0, 8) == "fisbone\x00") { |
| 219 | 219 | |
| 220 | 220 | $filedataoffset = 8; |
| 221 | - $info['ogg']['skeleton']['fisbone']['raw']['message_header_offset'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 221 | + $info['ogg']['skeleton']['fisbone']['raw']['message_header_offset'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 222 | 222 | $filedataoffset += 4; |
| 223 | - $info['ogg']['skeleton']['fisbone']['raw']['serial_number'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 223 | + $info['ogg']['skeleton']['fisbone']['raw']['serial_number'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 224 | 224 | $filedataoffset += 4; |
| 225 | - $info['ogg']['skeleton']['fisbone']['raw']['number_header_packets'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 225 | + $info['ogg']['skeleton']['fisbone']['raw']['number_header_packets'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 226 | 226 | $filedataoffset += 4; |
| 227 | - $info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 227 | + $info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 228 | 228 | $filedataoffset += 8; |
| 229 | - $info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 229 | + $info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 230 | 230 | $filedataoffset += 8; |
| 231 | - $info['ogg']['skeleton']['fisbone']['raw']['basegranule'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 231 | + $info['ogg']['skeleton']['fisbone']['raw']['basegranule'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); |
|
| 232 | 232 | $filedataoffset += 8; |
| 233 | - $info['ogg']['skeleton']['fisbone']['raw']['preroll'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 233 | + $info['ogg']['skeleton']['fisbone']['raw']['preroll'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 234 | 234 | $filedataoffset += 4; |
| 235 | - $info['ogg']['skeleton']['fisbone']['raw']['granuleshift'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 235 | + $info['ogg']['skeleton']['fisbone']['raw']['granuleshift'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 236 | 236 | $filedataoffset += 1; |
| 237 | - $info['ogg']['skeleton']['fisbone']['raw']['padding'] = substr($filedata, $filedataoffset, 3); |
|
| 237 | + $info['ogg']['skeleton']['fisbone']['raw']['padding'] = substr($filedata, $filedataoffset, 3); |
|
| 238 | 238 | $filedataoffset += 3; |
| 239 | 239 | |
| 240 | 240 | } elseif (substr($filedata, 1, 6) == 'theora') { |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | case 'vorbis': |
| 277 | 277 | $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); |
| 278 | 278 | $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1)); |
| 279 | - $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis' |
|
| 279 | + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis' |
|
| 280 | 280 | |
| 281 | 281 | $this->ParseVorbisComments(); |
| 282 | 282 | break; |
| 283 | 283 | |
| 284 | 284 | case 'flac': |
| 285 | 285 | $flac = new getid3_flac($this->getid3); |
| 286 | - if (!$flac->parseMETAdata()) { |
|
| 286 | + if ( ! $flac->parseMETAdata()) { |
|
| 287 | 287 | $info['error'][] = 'Failed to parse FLAC headers'; |
| 288 | 288 | return false; |
| 289 | 289 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | case 'opus': |
| 299 | 299 | $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); |
| 300 | 300 | $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 0, 8); // hard-coded to 'OpusTags' |
| 301 | - if(substr($filedata, 0, 8) != 'OpusTags') { |
|
| 301 | + if (substr($filedata, 0, 8) != 'OpusTags') { |
|
| 302 | 302 | $info['error'][] = 'Expected "OpusTags" as header but got "'.substr($filedata, 0, 8).'"'; |
| 303 | 303 | return false; |
| 304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Last Page - Number of Samples |
| 312 | - if (!getid3_lib::intValueSupported($info['avdataend'])) { |
|
| 312 | + if ( ! getid3_lib::intValueSupported($info['avdataend'])) { |
|
| 313 | 313 | |
| 314 | 314 | $info['warning'][] = 'Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)'; |
| 315 | 315 | |
@@ -321,26 +321,26 @@ discard block |
||
| 321 | 321 | $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO'))); |
| 322 | 322 | $info['avdataend'] = $this->ftell(); |
| 323 | 323 | $info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader(); |
| 324 | - $info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position']; |
|
| 324 | + $info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position']; |
|
| 325 | 325 | if ($info['ogg']['samples'] == 0) { |
| 326 | 326 | $info['error'][] = 'Corrupt Ogg file: eos.number of samples == zero'; |
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | - if (!empty($info['audio']['sample_rate'])) { |
|
| 329 | + if ( ! empty($info['audio']['sample_rate'])) { |
|
| 330 | 330 | $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']); |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if (!empty($info['ogg']['bitrate_average'])) { |
|
| 336 | + if ( ! empty($info['ogg']['bitrate_average'])) { |
|
| 337 | 337 | $info['audio']['bitrate'] = $info['ogg']['bitrate_average']; |
| 338 | - } elseif (!empty($info['ogg']['bitrate_nominal'])) { |
|
| 338 | + } elseif ( ! empty($info['ogg']['bitrate_nominal'])) { |
|
| 339 | 339 | $info['audio']['bitrate'] = $info['ogg']['bitrate_nominal']; |
| 340 | - } elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) { |
|
| 340 | + } elseif ( ! empty($info['ogg']['bitrate_min']) && ! empty($info['ogg']['bitrate_max'])) { |
|
| 341 | 341 | $info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2; |
| 342 | 342 | } |
| 343 | - if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) { |
|
| 343 | + if (isset($info['audio']['bitrate']) && ! isset($info['playtime_seconds'])) { |
|
| 344 | 344 | if ($info['audio']['bitrate'] == 0) { |
| 345 | 345 | $info['error'][] = 'Corrupt Ogg file: bitrate_audio == zero'; |
| 346 | 346 | return false; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | if ($info['audio']['dataformat'] == 'vorbis') { |
| 356 | 356 | |
| 357 | 357 | // Vorbis 1.0 starts with Xiph.Org |
| 358 | - if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) { |
|
| 358 | + if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) { |
|
| 359 | 359 | |
| 360 | 360 | if ($info['audio']['bitrate_mode'] == 'abr') { |
| 361 | 361 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) { |
|
| 372 | + if (empty($info['audio']['encoder_options']) && ! empty($info['ogg']['bitrate_nominal'])) { |
|
| 373 | 373 | $info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps'; |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $filedataoffset += 4; |
| 408 | 408 | $info['ogg']['bitrate_min'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
| 409 | 409 | $filedataoffset += 4; |
| 410 | - $info['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F); |
|
| 410 | + $info['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F); |
|
| 411 | 411 | $info['ogg']['blocksize_large'] = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4); |
| 412 | 412 | $info['ogg']['stop_bit'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet |
| 413 | 413 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | $info['ogg']['pageheader']['opus']['opus_magic'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'OpusHead' |
| 441 | 441 | $filedataoffset += 8; |
| 442 | - $info['ogg']['pageheader']['opus']['version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 442 | + $info['ogg']['pageheader']['opus']['version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 443 | 443 | $filedataoffset += 1; |
| 444 | 444 | |
| 445 | 445 | if ($info['ogg']['pageheader']['opus']['version'] < 1 || $info['ogg']['pageheader']['opus']['version'] > 15) { |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | return false; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 450 | + $info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); |
|
| 451 | 451 | $filedataoffset += 1; |
| 452 | 452 | |
| 453 | 453 | if ($info['ogg']['pageheader']['opus']['out_channel_count'] == 0) { |
@@ -455,10 +455,10 @@ discard block |
||
| 455 | 455 | return false; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 458 | + $info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
|
| 459 | 459 | $filedataoffset += 2; |
| 460 | 460 | |
| 461 | - $info['ogg']['pageheader']['opus']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 461 | + $info['ogg']['pageheader']['opus']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); |
|
| 462 | 462 | $filedataoffset += 4; |
| 463 | 463 | |
| 464 | 464 | //$info['ogg']['pageheader']['opus']['output_gain'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | case 'vorbis': |
| 541 | 541 | case 'speex': |
| 542 | 542 | case 'opus': |
| 543 | - $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block |
|
| 543 | + $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block |
|
| 544 | 544 | $this->fseek($CommentStartOffset); |
| 545 | 545 | $commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments']; |
| 546 | 546 | $commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset); |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $commentdata .= $AsYetUnusedData; |
| 642 | 642 | |
| 643 | 643 | //$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); |
| 644 | - if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) { |
|
| 644 | + if ( ! isset($info['ogg']['pageheader'][$VorbisCommentPage])) { |
|
| 645 | 645 | $info['warning'][] = 'undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell(); |
| 646 | 646 | break; |
| 647 | 647 | } |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | $commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']); |
| 659 | 659 | $commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size']; |
| 660 | 660 | |
| 661 | - if (!$commentstring) { |
|
| 661 | + if ( ! $commentstring) { |
|
| 662 | 662 | |
| 663 | 663 | // no comment? |
| 664 | 664 | $info['warning'][] = 'Blank Ogg comment ['.$i.']'; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | $this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure'); |
| 687 | 687 | /** @todo use 'coverartmime' where available */ |
| 688 | 688 | $imageinfo = getid3_lib::GetDataImageSize($data); |
| 689 | - if ($imageinfo === false || !isset($imageinfo['mime'])) { |
|
| 689 | + if ($imageinfo === false || ! isset($imageinfo['mime'])) { |
|
| 690 | 690 | $this->warning('COVERART vorbiscomment tag contains invalid image'); |
| 691 | 691 | continue; |
| 692 | 692 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | |
| 778 | - public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) { |
|
| 778 | + public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber = 1) { |
|
| 779 | 779 | for ($i = 0; $i < $SegmentNumber; $i++) { |
| 780 | 780 | $segmentlength = 0; |
| 781 | 781 | foreach ($OggInfoArray['segment_table'] as $key => $value) { |
@@ -547,8 +547,7 @@ |
||
| 547 | 547 | |
| 548 | 548 | if ($info['audio']['dataformat'] == 'vorbis') { |
| 549 | 549 | $commentdataoffset += (strlen('vorbis') + 1); |
| 550 | - } |
|
| 551 | - else if ($info['audio']['dataformat'] == 'opus') { |
|
| 550 | + } else if ($info['audio']['dataformat'] == 'opus') { |
|
| 552 | 551 | $commentdataoffset += strlen('OpusTags'); |
| 553 | 552 | } |
| 554 | 553 | |
@@ -331,6 +331,9 @@ |
||
| 331 | 331 | return true; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | + /** |
|
| 335 | + * @param string $APEheaderFooterData |
|
| 336 | + */ |
|
| 334 | 337 | public function parseAPEheaderFooter($APEheaderFooterData) { |
| 335 | 338 | // http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html |
| 336 | 339 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function Analyze() { |
| 23 | 23 | $info = &$this->getid3->info; |
| 24 | 24 | |
| 25 | - if (!getid3_lib::intValueSupported($info['filesize'])) { |
|
| 25 | + if ( ! getid3_lib::intValueSupported($info['filesize'])) { |
|
| 26 | 26 | $info['warning'][] = 'Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
| 27 | 27 | return false; |
| 28 | 28 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | } |
| 61 | - if (!isset($info['ape']['tag_offset_end'])) { |
|
| 61 | + if ( ! isset($info['ape']['tag_offset_end'])) { |
|
| 62 | 62 | |
| 63 | 63 | // APE tag not found |
| 64 | 64 | unset($info['ape']); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize); |
| 73 | 73 | $APEfooterData = $this->fread(32); |
| 74 | - if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) { |
|
| 74 | + if ( ! ($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) { |
|
| 75 | 75 | $info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']; |
| 76 | 76 | return false; |
| 77 | 77 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | } elseif (is_string($this->inline_attachments)) { |
| 284 | 284 | $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR); |
| 285 | - if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) { |
|
| 285 | + if ( ! is_dir($this->inline_attachments) || ! is_writable($this->inline_attachments)) { |
|
| 286 | 286 | // cannot write, skip |
| 287 | 287 | $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)'; |
| 288 | 288 | unset($thisfile_ape_items_current['data']); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | // if we get this far, must be OK |
| 293 | 293 | if (is_string($this->inline_attachments)) { |
| 294 | 294 | $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset']; |
| 295 | - if (!file_exists($destination_filename) || is_writable($destination_filename)) { |
|
| 295 | + if ( ! file_exists($destination_filename) || is_writable($destination_filename)) { |
|
| 296 | 296 | file_put_contents($destination_filename, $thisfile_ape_items_current['data']); |
| 297 | 297 | } else { |
| 298 | 298 | $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)'; |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $thisfile_ape_items_current['data_filename'] = $destination_filename; |
| 301 | 301 | unset($thisfile_ape_items_current['data']); |
| 302 | 302 | } else { |
| 303 | - if (!isset($info['ape']['comments']['picture'])) { |
|
| 303 | + if ( ! isset($info['ape']['comments']['picture'])) { |
|
| 304 | 304 | $info['ape']['comments']['picture'] = array(); |
| 305 | 305 | } |
| 306 | 306 | $comments_picture_data = array(); |
@@ -338,17 +338,17 @@ discard block |
||
| 338 | 338 | $headerfooterinfo['raw'] = array(); |
| 339 | 339 | $headerfooterinfo_raw = &$headerfooterinfo['raw']; |
| 340 | 340 | |
| 341 | - $headerfooterinfo_raw['footer_tag'] = substr($APEheaderFooterData, 0, 8); |
|
| 341 | + $headerfooterinfo_raw['footer_tag'] = substr($APEheaderFooterData, 0, 8); |
|
| 342 | 342 | if ($headerfooterinfo_raw['footer_tag'] != 'APETAGEX') { |
| 343 | 343 | return false; |
| 344 | 344 | } |
| 345 | - $headerfooterinfo_raw['version'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 8, 4)); |
|
| 345 | + $headerfooterinfo_raw['version'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 8, 4)); |
|
| 346 | 346 | $headerfooterinfo_raw['tagsize'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 12, 4)); |
| 347 | 347 | $headerfooterinfo_raw['tag_items'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 16, 4)); |
| 348 | 348 | $headerfooterinfo_raw['global_flags'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 20, 4)); |
| 349 | - $headerfooterinfo_raw['reserved'] = substr($APEheaderFooterData, 24, 8); |
|
| 349 | + $headerfooterinfo_raw['reserved'] = substr($APEheaderFooterData, 24, 8); |
|
| 350 | 350 | |
| 351 | - $headerfooterinfo['tag_version'] = $headerfooterinfo_raw['version'] / 1000; |
|
| 351 | + $headerfooterinfo['tag_version'] = $headerfooterinfo_raw['version'] / 1000; |
|
| 352 | 352 | if ($headerfooterinfo['tag_version'] >= 2) { |
| 353 | 353 | $headerfooterinfo['flags'] = $this->parseAPEtagFlags($headerfooterinfo_raw['global_flags']); |
| 354 | 354 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $flags['header'] = (bool) ($rawflagint & 0x80000000); |
| 363 | 363 | $flags['footer'] = (bool) ($rawflagint & 0x40000000); |
| 364 | 364 | $flags['this_is_header'] = (bool) ($rawflagint & 0x20000000); |
| 365 | - $flags['item_contents_raw'] = ($rawflagint & 0x00000006) >> 1; |
|
| 365 | + $flags['item_contents_raw'] = ($rawflagint & 0x00000006) >> 1; |
|
| 366 | 366 | $flags['read_only'] = (bool) ($rawflagint & 0x00000001); |
| 367 | 367 | |
| 368 | 368 | $flags['item_contents'] = $this->APEcontentTypeFlagLookup($flags['item_contents_raw']); |
@@ -2596,6 +2596,9 @@ discard block |
||
| 2596 | 2596 | |
| 2597 | 2597 | |
| 2598 | 2598 | |
| 2599 | + /** |
|
| 2600 | + * @param string $languagecode |
|
| 2601 | + */ |
|
| 2599 | 2602 | public static function LanguageLookup($languagecode, $casesensitive=false) { |
| 2600 | 2603 | |
| 2601 | 2604 | if (!$casesensitive) { |
@@ -3052,6 +3055,9 @@ discard block |
||
| 3052 | 3055 | } |
| 3053 | 3056 | |
| 3054 | 3057 | |
| 3058 | + /** |
|
| 3059 | + * @param string $index |
|
| 3060 | + */ |
|
| 3055 | 3061 | public static function ETCOEventLookup($index) { |
| 3056 | 3062 | if (($index >= 0x17) && ($index <= 0xDF)) { |
| 3057 | 3063 | return 'reserved for future use'; |
@@ -3095,6 +3101,9 @@ discard block |
||
| 3095 | 3101 | return (isset($EventLookup[$index]) ? $EventLookup[$index] : ''); |
| 3096 | 3102 | } |
| 3097 | 3103 | |
| 3104 | + /** |
|
| 3105 | + * @param integer $index |
|
| 3106 | + */ |
|
| 3098 | 3107 | public static function SYTLContentTypeLookup($index) { |
| 3099 | 3108 | static $SYTLContentTypeLookup = array( |
| 3100 | 3109 | 0x00 => 'other', |
@@ -3111,6 +3120,9 @@ discard block |
||
| 3111 | 3120 | return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : ''); |
| 3112 | 3121 | } |
| 3113 | 3122 | |
| 3123 | + /** |
|
| 3124 | + * @param integer $index |
|
| 3125 | + */ |
|
| 3114 | 3126 | public static function APICPictureTypeLookup($index, $returnarray=false) { |
| 3115 | 3127 | static $APICPictureTypeLookup = array( |
| 3116 | 3128 | 0x00 => 'Other', |
@@ -3141,6 +3153,9 @@ discard block |
||
| 3141 | 3153 | return (isset($APICPictureTypeLookup[$index]) ? $APICPictureTypeLookup[$index] : ''); |
| 3142 | 3154 | } |
| 3143 | 3155 | |
| 3156 | + /** |
|
| 3157 | + * @param integer $index |
|
| 3158 | + */ |
|
| 3144 | 3159 | public static function COMRReceivedAsLookup($index) { |
| 3145 | 3160 | static $COMRReceivedAsLookup = array( |
| 3146 | 3161 | 0x00 => 'Other', |
@@ -3157,6 +3172,9 @@ discard block |
||
| 3157 | 3172 | return (isset($COMRReceivedAsLookup[$index]) ? $COMRReceivedAsLookup[$index] : ''); |
| 3158 | 3173 | } |
| 3159 | 3174 | |
| 3175 | + /** |
|
| 3176 | + * @param integer $index |
|
| 3177 | + */ |
|
| 3160 | 3178 | public static function RVA2ChannelTypeLookup($index) { |
| 3161 | 3179 | static $RVA2ChannelTypeLookup = array( |
| 3162 | 3180 | 0x00 => 'Other', |
@@ -3536,6 +3554,9 @@ discard block |
||
| 3536 | 3554 | return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short'); |
| 3537 | 3555 | } |
| 3538 | 3556 | |
| 3557 | + /** |
|
| 3558 | + * @param integer $encoding |
|
| 3559 | + */ |
|
| 3539 | 3560 | public static function TextEncodingTerminatorLookup($encoding) { |
| 3540 | 3561 | // http://www.id3.org/id3v2.4.0-structure.txt |
| 3541 | 3562 | // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: |
@@ -3562,6 +3583,9 @@ discard block |
||
| 3562 | 3583 | return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1'); |
| 3563 | 3584 | } |
| 3564 | 3585 | |
| 3586 | + /** |
|
| 3587 | + * @param string $framename |
|
| 3588 | + */ |
|
| 3565 | 3589 | public static function IsValidID3v2FrameName($framename, $id3v2majorversion) { |
| 3566 | 3590 | switch ($id3v2majorversion) { |
| 3567 | 3591 | case 2: |
@@ -3591,6 +3615,9 @@ discard block |
||
| 3591 | 3615 | return true; |
| 3592 | 3616 | } |
| 3593 | 3617 | |
| 3618 | + /** |
|
| 3619 | + * @param string $datestamp |
|
| 3620 | + */ |
|
| 3594 | 3621 | public static function IsValidDateStampString($datestamp) { |
| 3595 | 3622 | if (strlen($datestamp) != 8) { |
| 3596 | 3623 | return false; |
@@ -1972,9 +1972,9 @@ discard block |
||
| 1972 | 1972 | // Element ID <text string> $00 |
| 1973 | 1973 | // Start time $xx xx xx xx |
| 1974 | 1974 | // End time $xx xx xx xx |
| 1975 | - // Start offset $xx xx xx xx |
|
| 1976 | - // End offset $xx xx xx xx |
|
| 1977 | - // <Optional embedded sub-frames> |
|
| 1975 | + // Start offset $xx xx xx xx |
|
| 1976 | + // End offset $xx xx xx xx |
|
| 1977 | + // <Optional embedded sub-frames> |
|
| 1978 | 1978 | |
| 1979 | 1979 | $frame_offset = 0; |
| 1980 | 1980 | @list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2); |
@@ -2069,7 +2069,7 @@ discard block |
||
| 2069 | 2069 | // CTOC flags %xx |
| 2070 | 2070 | // Entry count $xx |
| 2071 | 2071 | // Child Element ID <string>$00 /* zero or more child CHAP or CTOC entries */ |
| 2072 | - // <Optional embedded sub-frames> |
|
| 2072 | + // <Optional embedded sub-frames> |
|
| 2073 | 2073 | |
| 2074 | 2074 | $frame_offset = 0; |
| 2075 | 2075 | @list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2); |
@@ -2392,8 +2392,7 @@ discard block |
||
| 2392 | 2392 | ZAR Rand |
| 2393 | 2393 | ZMK Kwacha |
| 2394 | 2394 | ZWD Zimbabwe Dollars |
| 2395 | - |
|
| 2396 | - */ |
|
| 2395 | + */ |
|
| 2397 | 2396 | |
| 2398 | 2397 | return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-units'); |
| 2399 | 2398 | } |
@@ -2588,8 +2587,7 @@ discard block |
||
| 2588 | 2587 | ZAR South Africa |
| 2589 | 2588 | ZMK Zambia |
| 2590 | 2589 | ZWD Zimbabwe |
| 2591 | - |
|
| 2592 | - */ |
|
| 2590 | + */ |
|
| 2593 | 2591 | |
| 2594 | 2592 | return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-country'); |
| 2595 | 2593 | } |
@@ -3045,8 +3043,7 @@ discard block |
||
| 3045 | 3043 | zho Chinese |
| 3046 | 3044 | zul Zulu |
| 3047 | 3045 | zun Zuni |
| 3048 | - |
|
| 3049 | - */ |
|
| 3046 | + */ |
|
| 3050 | 3047 | |
| 3051 | 3048 | return getid3_lib::EmbeddedLookup($languagecode, $begin, __LINE__, __FILE__, 'id3v2-languagecode'); |
| 3052 | 3049 | } |
@@ -3346,8 +3343,7 @@ discard block |
||
| 3346 | 3343 | TFEA Featured Artist |
| 3347 | 3344 | TSTU Recording Studio |
| 3348 | 3345 | rgad Replay Gain Adjustment |
| 3349 | - |
|
| 3350 | - */ |
|
| 3346 | + */ |
|
| 3351 | 3347 | |
| 3352 | 3348 | return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_long'); |
| 3353 | 3349 | |
@@ -3530,8 +3526,7 @@ discard block |
||
| 3530 | 3526 | TFEA featured_artist |
| 3531 | 3527 | TSTU recording_studio |
| 3532 | 3528 | rgad replay_gain_adjustment |
| 3533 | - |
|
| 3534 | - */ |
|
| 3529 | + */ |
|
| 3535 | 3530 | |
| 3536 | 3531 | return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short'); |
| 3537 | 3532 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | // shortcuts |
| 49 | 49 | $info['id3v2']['header'] = true; |
| 50 | 50 | $thisfile_id3v2 = &$info['id3v2']; |
| 51 | - $thisfile_id3v2['flags'] = array(); |
|
| 51 | + $thisfile_id3v2['flags'] = array(); |
|
| 52 | 52 | $thisfile_id3v2_flags = &$thisfile_id3v2['flags']; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | $this->fseek($this->StartingOffset); |
| 56 | 56 | $header = $this->fread(10); |
| 57 | - if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
| 57 | + if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
| 58 | 58 | |
| 59 | 59 | $thisfile_id3v2['majorversion'] = ord($header{3}); |
| 60 | 60 | $thisfile_id3v2['minorversion'] = ord($header{4}); |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | // Flags $xx xx |
| 125 | 125 | |
| 126 | 126 | $sizeofframes = $thisfile_id3v2['headerlength'] - 10; // not including 10-byte initial header |
| 127 | - if (!empty($thisfile_id3v2['exthead']['length'])) { |
|
| 127 | + if ( ! empty($thisfile_id3v2['exthead']['length'])) { |
|
| 128 | 128 | $sizeofframes -= ($thisfile_id3v2['exthead']['length'] + 4); |
| 129 | 129 | } |
| 130 | - if (!empty($thisfile_id3v2_flags['isfooter'])) { |
|
| 130 | + if ( ! empty($thisfile_id3v2_flags['isfooter'])) { |
|
| 131 | 131 | $sizeofframes -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio |
| 132 | 132 | } |
| 133 | 133 | if ($sizeofframes > 0) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $framedata = $this->fread($sizeofframes); // read all frames from file into $framedata variable |
| 136 | 136 | |
| 137 | 137 | // if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x) |
| 138 | - if (!empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) { |
|
| 138 | + if ( ! empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) { |
|
| 139 | 139 | $framedata = $this->DeUnsynchronise($framedata); |
| 140 | 140 | } |
| 141 | 141 | // [in ID3v2.4.0] Unsynchronisation [S:6.1] is done on frame level, instead |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | // Extended Header |
| 153 | - if (!empty($thisfile_id3v2_flags['exthead'])) { |
|
| 153 | + if ( ! empty($thisfile_id3v2_flags['exthead'])) { |
|
| 154 | 154 | $extended_header_offset = 0; |
| 155 | 155 | |
| 156 | 156 | if ($id3v2_majorversion == 3) { |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | // Flags $xx xx |
| 273 | 273 | |
| 274 | 274 | $frame_header = substr($framedata, 0, 6); // take next 6 bytes for header |
| 275 | - $framedata = substr($framedata, 6); // and leave the rest in $framedata |
|
| 275 | + $framedata = substr($framedata, 6); // and leave the rest in $framedata |
|
| 276 | 276 | $frame_name = substr($frame_header, 0, 3); |
| 277 | 277 | $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 3, 3), 0); |
| 278 | 278 | $frame_flags = 0; // not used for anything in ID3v2.2, just set to avoid E_NOTICEs |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | // Flags $xx xx |
| 285 | 285 | |
| 286 | 286 | $frame_header = substr($framedata, 0, 10); // take next 10 bytes for header |
| 287 | - $framedata = substr($framedata, 10); // and leave the rest in $framedata |
|
| 287 | + $framedata = substr($framedata, 10); // and leave the rest in $framedata |
|
| 288 | 288 | |
| 289 | 289 | $frame_name = substr($frame_header, 0, 4); |
| 290 | 290 | if ($id3v2_majorversion == 3) { |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | $info['warning'][] = 'Invalid ID3v2 frame size, aborting.'; |
| 380 | 380 | |
| 381 | 381 | } |
| 382 | - if (!$this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) { |
|
| 382 | + if ( ! $this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) { |
|
| 383 | 383 | |
| 384 | 384 | switch ($frame_name) { |
| 385 | 385 | case "\x00\x00".'MP': |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | break; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - } elseif (!isset($framedata) || ($frame_size > strlen($framedata))) { |
|
| 400 | + } elseif ( ! isset($framedata) || ($frame_size > strlen($framedata))) { |
|
| 401 | 401 | |
| 402 | 402 | $info['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: $frame_size ('.$frame_size.') > strlen($framedata) ('.(isset($framedata) ? strlen($framedata) : 'null').')).'; |
| 403 | 403 | |
@@ -456,27 +456,27 @@ discard block |
||
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if (!isset($thisfile_id3v2['comments']['year']) && !empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) { |
|
| 459 | + if ( ! isset($thisfile_id3v2['comments']['year']) && ! empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) { |
|
| 460 | 460 | $thisfile_id3v2['comments']['year'] = array($matches[1]); |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | |
| 464 | - if (!empty($thisfile_id3v2['TXXX'])) { |
|
| 464 | + if ( ! empty($thisfile_id3v2['TXXX'])) { |
|
| 465 | 465 | // MediaMonkey does this, maybe others: write a blank RGAD frame, but put replay-gain adjustment values in TXXX frames |
| 466 | 466 | foreach ($thisfile_id3v2['TXXX'] as $txxx_array) { |
| 467 | 467 | switch ($txxx_array['description']) { |
| 468 | 468 | case 'replaygain_track_gain': |
| 469 | - if (empty($info['replay_gain']['track']['adjustment']) && !empty($txxx_array['data'])) { |
|
| 469 | + if (empty($info['replay_gain']['track']['adjustment']) && ! empty($txxx_array['data'])) { |
|
| 470 | 470 | $info['replay_gain']['track']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data']))); |
| 471 | 471 | } |
| 472 | 472 | break; |
| 473 | 473 | case 'replaygain_track_peak': |
| 474 | - if (empty($info['replay_gain']['track']['peak']) && !empty($txxx_array['data'])) { |
|
| 474 | + if (empty($info['replay_gain']['track']['peak']) && ! empty($txxx_array['data'])) { |
|
| 475 | 475 | $info['replay_gain']['track']['peak'] = floatval($txxx_array['data']); |
| 476 | 476 | } |
| 477 | 477 | break; |
| 478 | 478 | case 'replaygain_album_gain': |
| 479 | - if (empty($info['replay_gain']['album']['adjustment']) && !empty($txxx_array['data'])) { |
|
| 479 | + if (empty($info['replay_gain']['album']['adjustment']) && ! empty($txxx_array['data'])) { |
|
| 480 | 480 | $info['replay_gain']['album']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data']))); |
| 481 | 481 | } |
| 482 | 482 | break; |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | $info = &$this->getid3->info; |
| 525 | 525 | $id3v2_majorversion = $info['id3v2']['majorversion']; |
| 526 | 526 | |
| 527 | - $parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']); |
|
| 527 | + $parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']); |
|
| 528 | 528 | if (empty($parsedFrame['framenamelong'])) { |
| 529 | 529 | unset($parsedFrame['framenamelong']); |
| 530 | 530 | } |
@@ -563,14 +563,14 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | if ($parsedFrame['flags']['DataLengthIndicator']) { |
| 565 | 565 | $parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1); |
| 566 | - $parsedFrame['data'] = substr($parsedFrame['data'], 4); |
|
| 566 | + $parsedFrame['data'] = substr($parsedFrame['data'], 4); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // Frame-level de-compression |
| 571 | 571 | if ($parsedFrame['flags']['compression']) { |
| 572 | 572 | $parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4)); |
| 573 | - if (!function_exists('gzuncompress')) { |
|
| 573 | + if ( ! function_exists('gzuncompress')) { |
|
| 574 | 574 | $info['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"'; |
| 575 | 575 | } else { |
| 576 | 576 | if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) { |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if (!empty($parsedFrame['flags']['DataLengthIndicator'])) { |
|
| 587 | + if ( ! empty($parsedFrame['flags']['DataLengthIndicator'])) { |
|
| 588 | 588 | if ($parsedFrame['data_length_indicator'] != strlen($parsedFrame['data'])) { |
| 589 | 589 | $info['warning'][] = 'ID3v2 frame "'.$parsedFrame['frame_name'].'" should be '.$parsedFrame['data_length_indicator'].' bytes long according to DataLengthIndicator, but found '.strlen($parsedFrame['data']).' bytes of data'; |
| 590 | 590 | } |
@@ -643,9 +643,9 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | $parsedFrame['description'] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $frame_description)); |
| 645 | 645 | $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); |
| 646 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 646 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 647 | 647 | $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); |
| 648 | - if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { |
|
| 648 | + if ( ! isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || ! array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { |
|
| 649 | 649 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); |
| 650 | 650 | } else { |
| 651 | 651 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $parsedFrame['encodingid'] = $frame_textencoding; |
| 673 | 673 | $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); |
| 674 | 674 | |
| 675 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 675 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 676 | 676 | // ID3v2.3 specs say that TPE1 (and others) can contain multiple artist values separated with / |
| 677 | 677 | // This of course breaks when an artist name contains slash character, e.g. "AC/DC" |
| 678 | 678 | // MP3tag (maybe others) implement alternative system where multiple artists are null-separated, which makes more sense |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | $Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset); |
| 701 | 701 | foreach ($Txxx_elements as $Txxx_element) { |
| 702 | 702 | $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $Txxx_element); |
| 703 | - if (!empty($string)) { |
|
| 703 | + if ( ! empty($string)) { |
|
| 704 | 704 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string; |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | $parsedFrame['url'] = $frame_urldata; |
| 754 | 754 | $parsedFrame['description'] = $frame_description; |
| 755 | - if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 755 | + if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 756 | 756 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['url']); |
| 757 | 757 | } |
| 758 | 758 | unset($parsedFrame['data']); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | // URL <text string> |
| 767 | 767 | |
| 768 | 768 | $parsedFrame['url'] = trim($parsedFrame['data']); |
| 769 | - if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 769 | + if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 770 | 770 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['url']; |
| 771 | 771 | } |
| 772 | 772 | unset($parsedFrame['data']); |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | $parsedFrame['data'] = $IPLS_parts; |
| 849 | 849 | |
| 850 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 850 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 851 | 851 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data']; |
| 852 | 852 | } |
| 853 | 853 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | // <Header for 'Music CD identifier', ID: 'MCDI'> |
| 859 | 859 | // CD TOC <binary data> |
| 860 | 860 | |
| 861 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 861 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 862 | 862 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data']; |
| 863 | 863 | } |
| 864 | 864 | |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | $parsedFrame['language'] = $frame_language; |
| 984 | 984 | $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); |
| 985 | 985 | $parsedFrame['description'] = $frame_description; |
| 986 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 986 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 987 | 987 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); |
| 988 | 988 | } |
| 989 | 989 | unset($parsedFrame['data']); |
@@ -1091,9 +1091,9 @@ discard block |
||
| 1091 | 1091 | $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); |
| 1092 | 1092 | $parsedFrame['description'] = $frame_description; |
| 1093 | 1093 | $parsedFrame['data'] = $frame_text; |
| 1094 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 1095 | - $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (!empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); |
|
| 1096 | - if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { |
|
| 1094 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 1095 | + $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : ( ! empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); |
|
| 1096 | + if ( ! isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || ! array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { |
|
| 1097 | 1097 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); |
| 1098 | 1098 | } else { |
| 1099 | 1099 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | break; |
| 1137 | 1137 | } |
| 1138 | 1138 | $frame_bytespeakvolume = ceil($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] / 8); |
| 1139 | - $parsedFrame[$RVA2channelcounter]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume)); |
|
| 1139 | + $parsedFrame[$RVA2channelcounter]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume)); |
|
| 1140 | 1140 | $frame_remainingdata = substr($frame_remainingdata, $frame_offset + $frame_bytespeakvolume); |
| 1141 | 1141 | $RVA2channelcounter++; |
| 1142 | 1142 | } |
@@ -1404,7 +1404,7 @@ discard block |
||
| 1404 | 1404 | $imageinfo = array(); |
| 1405 | 1405 | $imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data'], $imageinfo); |
| 1406 | 1406 | if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) { |
| 1407 | - $parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]); |
|
| 1407 | + $parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]); |
|
| 1408 | 1408 | if ($imagechunkcheck[0]) { |
| 1409 | 1409 | $parsedFrame['image_width'] = $imagechunkcheck[0]; |
| 1410 | 1410 | } |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | */ |
| 1433 | 1433 | } elseif (is_string($this->getid3->option_save_attachments)) { |
| 1434 | 1434 | $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR); |
| 1435 | - if (!is_dir($dir) || !is_writable($dir)) { |
|
| 1435 | + if ( ! is_dir($dir) || ! is_writable($dir)) { |
|
| 1436 | 1436 | // cannot write, skip |
| 1437 | 1437 | $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$dir.'" (not writable)'; |
| 1438 | 1438 | unset($parsedFrame['data']); |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | // if we get this far, must be OK |
| 1443 | 1443 | if (is_string($this->getid3->option_save_attachments)) { |
| 1444 | 1444 | $destination_filename = $dir.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$frame_offset; |
| 1445 | - if (!file_exists($destination_filename) || is_writable($destination_filename)) { |
|
| 1445 | + if ( ! file_exists($destination_filename) || is_writable($destination_filename)) { |
|
| 1446 | 1446 | file_put_contents($destination_filename, $parsedFrame['data']); |
| 1447 | 1447 | } else { |
| 1448 | 1448 | $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$destination_filename.'" (not writable)'; |
@@ -1450,8 +1450,8 @@ discard block |
||
| 1450 | 1450 | $parsedFrame['data_filename'] = $destination_filename; |
| 1451 | 1451 | unset($parsedFrame['data']); |
| 1452 | 1452 | } else { |
| 1453 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 1454 | - if (!isset($info['id3v2']['comments']['picture'])) { |
|
| 1453 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 1454 | + if ( ! isset($info['id3v2']['comments']['picture'])) { |
|
| 1455 | 1455 | $info['id3v2']['comments']['picture'] = array(); |
| 1456 | 1456 | } |
| 1457 | 1457 | $comments_picture_data = array(); |
@@ -1530,7 +1530,7 @@ discard block |
||
| 1530 | 1530 | // <Header for 'Play counter', ID: 'PCNT'> |
| 1531 | 1531 | // Counter $xx xx xx xx (xx ...) |
| 1532 | 1532 | |
| 1533 | - $parsedFrame['data'] = getid3_lib::BigEndian2Int($parsedFrame['data']); |
|
| 1533 | + $parsedFrame['data'] = getid3_lib::BigEndian2Int($parsedFrame['data']); |
|
| 1534 | 1534 | |
| 1535 | 1535 | |
| 1536 | 1536 | } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'POPM')) || // 4.17 POPM Popularimeter |
@@ -1654,7 +1654,7 @@ discard block |
||
| 1654 | 1654 | $parsedFrame['url'] = $frame_url; |
| 1655 | 1655 | |
| 1656 | 1656 | $parsedFrame['additionaldata'] = (string) substr($parsedFrame['data'], $frame_offset); |
| 1657 | - if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 1657 | + if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { |
|
| 1658 | 1658 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback_iso88591_utf8($parsedFrame['url']); |
| 1659 | 1659 | } |
| 1660 | 1660 | unset($parsedFrame['data']); |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); |
| 1694 | 1694 | |
| 1695 | 1695 | $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); |
| 1696 | - if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { |
|
| 1696 | + if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) { |
|
| 1697 | 1697 | $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); |
| 1698 | 1698 | } |
| 1699 | 1699 | unset($parsedFrame['data']); |
@@ -1724,8 +1724,8 @@ discard block |
||
| 1724 | 1724 | $parsedFrame['pricepaid']['value'] = substr($frame_pricepaid, 3); |
| 1725 | 1725 | |
| 1726 | 1726 | $parsedFrame['purchasedate'] = substr($parsedFrame['data'], $frame_offset, 8); |
| 1727 | - if (!$this->IsValidDateStampString($parsedFrame['purchasedate'])) { |
|
| 1728 | - $parsedFrame['purchasedateunix'] = mktime (0, 0, 0, substr($parsedFrame['purchasedate'], 4, 2), substr($parsedFrame['purchasedate'], 6, 2), substr($parsedFrame['purchasedate'], 0, 4)); |
|
| 1727 | + if ( ! $this->IsValidDateStampString($parsedFrame['purchasedate'])) { |
|
| 1728 | + $parsedFrame['purchasedateunix'] = mktime(0, 0, 0, substr($parsedFrame['purchasedate'], 4, 2), substr($parsedFrame['purchasedate'], 6, 2), substr($parsedFrame['purchasedate'], 0, 4)); |
|
| 1729 | 1729 | } |
| 1730 | 1730 | $frame_offset += 8; |
| 1731 | 1731 | |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | // Minimum offset to next tag $xx xx xx xx |
| 1897 | 1897 | |
| 1898 | 1898 | $frame_offset = 0; |
| 1899 | - $parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
|
| 1899 | + $parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
|
| 1900 | 1900 | |
| 1901 | 1901 | |
| 1902 | 1902 | } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'ASPI')) { // 4.30 ASPI Audio seek point index (ID3v2.4+ only) |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | $frame_offset += 4; |
| 1991 | 1991 | if (substr($parsedFrame['data'], $frame_offset, 4) != "\xFF\xFF\xFF\xFF") { |
| 1992 | 1992 | // "If these bytes are all set to 0xFF then the value should be ignored and the start time value should be utilized." |
| 1993 | - $parsedFrame['offset_end'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
|
| 1993 | + $parsedFrame['offset_end'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
|
| 1994 | 1994 | } |
| 1995 | 1995 | $frame_offset += 4; |
| 1996 | 1996 | |
@@ -1999,7 +1999,7 @@ discard block |
||
| 1999 | 1999 | while ($frame_offset < strlen($parsedFrame['data'])) { |
| 2000 | 2000 | // <Optional embedded sub-frames> |
| 2001 | 2001 | $subframe = array(); |
| 2002 | - $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); |
|
| 2002 | + $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); |
|
| 2003 | 2003 | $frame_offset += 4; |
| 2004 | 2004 | $subframe['size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
| 2005 | 2005 | $frame_offset += 4; |
@@ -2013,9 +2013,9 @@ discard block |
||
| 2013 | 2013 | $frame_offset += $subframe['size']; |
| 2014 | 2014 | |
| 2015 | 2015 | $subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1)); |
| 2016 | - $subframe['text'] = substr($subframe_rawdata, 1); |
|
| 2016 | + $subframe['text'] = substr($subframe_rawdata, 1); |
|
| 2017 | 2017 | $subframe['encoding'] = $this->TextEncodingNameLookup($subframe['encodingid']); |
| 2018 | - $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));; |
|
| 2018 | + $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text'])); ; |
|
| 2019 | 2019 | switch (substr($encoding_converted_text, 0, 2)) { |
| 2020 | 2020 | case "\xFF\xFE": |
| 2021 | 2021 | case "\xFE\xFF": |
@@ -2055,7 +2055,7 @@ discard block |
||
| 2055 | 2055 | $id3v2_chapter_entry[$id3v2_chapter_key] = $parsedFrame[$id3v2_chapter_key]; |
| 2056 | 2056 | } |
| 2057 | 2057 | } |
| 2058 | - if (!isset($info['id3v2']['chapters'])) { |
|
| 2058 | + if ( ! isset($info['id3v2']['chapters'])) { |
|
| 2059 | 2059 | $info['id3v2']['chapters'] = array(); |
| 2060 | 2060 | } |
| 2061 | 2061 | $info['id3v2']['chapters'][] = $id3v2_chapter_entry; |
@@ -2096,7 +2096,7 @@ discard block |
||
| 2096 | 2096 | while ($frame_offset < strlen($parsedFrame['data'])) { |
| 2097 | 2097 | // <Optional embedded sub-frames> |
| 2098 | 2098 | $subframe = array(); |
| 2099 | - $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); |
|
| 2099 | + $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); |
|
| 2100 | 2100 | $frame_offset += 4; |
| 2101 | 2101 | $subframe['size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); |
| 2102 | 2102 | $frame_offset += 4; |
@@ -2110,9 +2110,9 @@ discard block |
||
| 2110 | 2110 | $frame_offset += $subframe['size']; |
| 2111 | 2111 | |
| 2112 | 2112 | $subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1)); |
| 2113 | - $subframe['text'] = substr($subframe_rawdata, 1); |
|
| 2113 | + $subframe['text'] = substr($subframe_rawdata, 1); |
|
| 2114 | 2114 | $subframe['encoding'] = $this->TextEncodingNameLookup($subframe['encodingid']); |
| 2115 | - $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));; |
|
| 2115 | + $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text'])); ; |
|
| 2116 | 2116 | switch (substr($encoding_converted_text, 0, 2)) { |
| 2117 | 2117 | case "\xFF\xFE": |
| 2118 | 2118 | case "\xFE\xFF": |
@@ -2596,9 +2596,9 @@ discard block |
||
| 2596 | 2596 | |
| 2597 | 2597 | |
| 2598 | 2598 | |
| 2599 | - public static function LanguageLookup($languagecode, $casesensitive=false) { |
|
| 2599 | + public static function LanguageLookup($languagecode, $casesensitive = false) { |
|
| 2600 | 2600 | |
| 2601 | - if (!$casesensitive) { |
|
| 2601 | + if ( ! $casesensitive) { |
|
| 2602 | 2602 | $languagecode = strtolower($languagecode); |
| 2603 | 2603 | } |
| 2604 | 2604 | |
@@ -3101,8 +3101,8 @@ discard block |
||
| 3101 | 3101 | 0x01 => 'lyrics', |
| 3102 | 3102 | 0x02 => 'text transcription', |
| 3103 | 3103 | 0x03 => 'movement/part name', // (e.g. 'Adagio') |
| 3104 | - 0x04 => 'events', // (e.g. 'Don Quijote enters the stage') |
|
| 3105 | - 0x05 => 'chord', // (e.g. 'Bb F Fsus') |
|
| 3104 | + 0x04 => 'events', // (e.g. 'Don Quijote enters the stage') |
|
| 3105 | + 0x05 => 'chord', // (e.g. 'Bb F Fsus') |
|
| 3106 | 3106 | 0x06 => 'trivia/\'pop up\' information', |
| 3107 | 3107 | 0x07 => 'URLs to webpages', |
| 3108 | 3108 | 0x08 => 'URLs to images' |
@@ -3111,7 +3111,7 @@ discard block |
||
| 3111 | 3111 | return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : ''); |
| 3112 | 3112 | } |
| 3113 | 3113 | |
| 3114 | - public static function APICPictureTypeLookup($index, $returnarray=false) { |
|
| 3114 | + public static function APICPictureTypeLookup($index, $returnarray = false) { |
|
| 3115 | 3115 | static $APICPictureTypeLookup = array( |
| 3116 | 3116 | 0x00 => 'Other', |
| 3117 | 3117 | 0x01 => '32x32 pixels \'file icon\' (PNG only)', |
@@ -3540,10 +3540,10 @@ discard block |
||
| 3540 | 3540 | // http://www.id3.org/id3v2.4.0-structure.txt |
| 3541 | 3541 | // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: |
| 3542 | 3542 | static $TextEncodingTerminatorLookup = array( |
| 3543 | - 0 => "\x00", // $00 ISO-8859-1. Terminated with $00. |
|
| 3543 | + 0 => "\x00", // $00 ISO-8859-1. Terminated with $00. |
|
| 3544 | 3544 | 1 => "\x00\x00", // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. |
| 3545 | 3545 | 2 => "\x00\x00", // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. |
| 3546 | - 3 => "\x00", // $03 UTF-8 encoded Unicode. Terminated with $00. |
|
| 3546 | + 3 => "\x00", // $03 UTF-8 encoded Unicode. Terminated with $00. |
|
| 3547 | 3547 | 255 => "\x00\x00" |
| 3548 | 3548 | ); |
| 3549 | 3549 | return (isset($TextEncodingTerminatorLookup[$encoding]) ? $TextEncodingTerminatorLookup[$encoding] : "\x00"); |
@@ -3554,9 +3554,9 @@ discard block |
||
| 3554 | 3554 | // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: |
| 3555 | 3555 | static $TextEncodingNameLookup = array( |
| 3556 | 3556 | 0 => 'ISO-8859-1', // $00 ISO-8859-1. Terminated with $00. |
| 3557 | - 1 => 'UTF-16', // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. |
|
| 3558 | - 2 => 'UTF-16BE', // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. |
|
| 3559 | - 3 => 'UTF-8', // $03 UTF-8 encoded Unicode. Terminated with $00. |
|
| 3557 | + 1 => 'UTF-16', // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. |
|
| 3558 | + 2 => 'UTF-16BE', // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. |
|
| 3559 | + 3 => 'UTF-8', // $03 UTF-8 encoded Unicode. Terminated with $00. |
|
| 3560 | 3560 | 255 => 'UTF-16BE' |
| 3561 | 3561 | ); |
| 3562 | 3562 | return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1'); |
@@ -3576,7 +3576,7 @@ discard block |
||
| 3576 | 3576 | return false; |
| 3577 | 3577 | } |
| 3578 | 3578 | |
| 3579 | - public static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) { |
|
| 3579 | + public static function IsANumber($numberstring, $allowdecimal = false, $allownegative = false) { |
|
| 3580 | 3580 | for ($i = 0; $i < strlen($numberstring); $i++) { |
| 3581 | 3581 | if ((chr($numberstring{$i}) < chr('0')) || (chr($numberstring{$i}) > chr('9'))) { |
| 3582 | 3582 | if (($numberstring{$i} == '.') && $allowdecimal) { |
@@ -3595,7 +3595,7 @@ discard block |
||
| 3595 | 3595 | if (strlen($datestamp) != 8) { |
| 3596 | 3596 | return false; |
| 3597 | 3597 | } |
| 3598 | - if (!self::IsANumber($datestamp, false)) { |
|
| 3598 | + if ( ! self::IsANumber($datestamp, false)) { |
|
| 3599 | 3599 | return false; |
| 3600 | 3600 | } |
| 3601 | 3601 | $year = substr($datestamp, 0, 4); |
@@ -126,6 +126,9 @@ discard block |
||
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | + /** |
|
| 130 | + * @param integer $version |
|
| 131 | + */ |
|
| 129 | 132 | public function getLyrics3Data($endoffset, $version, $length) { |
| 130 | 133 | // http://www.volweb.cz/str/tags.htm |
| 131 | 134 | |
@@ -287,6 +290,9 @@ discard block |
||
| 287 | 290 | return true; |
| 288 | 291 | } |
| 289 | 292 | |
| 293 | + /** |
|
| 294 | + * @param string $char |
|
| 295 | + */ |
|
| 290 | 296 | public function IntString2Bool($char) { |
| 291 | 297 | if ($char == '1') { |
| 292 | 298 | return true; |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | // http://www.volweb.cz/str/tags.htm |
| 25 | 25 | |
| 26 | - if (!getid3_lib::intValueSupported($info['filesize'])) { |
|
| 26 | + if ( ! getid3_lib::intValueSupported($info['filesize'])) { |
|
| 27 | 27 | $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
| 28 | 28 | return false; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
|
| 31 | + $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
|
| 32 | 32 | $lyrics3_id3v1 = $this->fread(128 + 9 + 6); |
| 33 | - $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
|
| 34 | - $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
|
| 33 | + $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
|
| 34 | + $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
|
| 35 | 35 | $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 |
| 36 | 36 | |
| 37 | 37 | if ($lyrics3end == 'LYRICSEND') { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $info['avdataend'] = $lyrics3offset; |
| 101 | 101 | $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size); |
| 102 | 102 | |
| 103 | - if (!isset($info['ape'])) { |
|
| 103 | + if ( ! isset($info['ape'])) { |
|
| 104 | 104 | if (isset($info['lyrics3']['tag_offset_start'])) { |
| 105 | 105 | $GETID3_ERRORARRAY = &$info['warning']; |
| 106 | 106 | getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | $getid3_apetag = new getid3_apetag($getid3_temp); |
| 110 | 110 | $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; |
| 111 | 111 | $getid3_apetag->Analyze(); |
| 112 | - if (!empty($getid3_temp->info['ape'])) { |
|
| 112 | + if ( ! empty($getid3_temp->info['ape'])) { |
|
| 113 | 113 | $info['ape'] = $getid3_temp->info['ape']; |
| 114 | 114 | } |
| 115 | - if (!empty($getid3_temp->info['replay_gain'])) { |
|
| 115 | + if ( ! empty($getid3_temp->info['replay_gain'])) { |
|
| 116 | 116 | $info['replay_gain'] = $getid3_temp->info['replay_gain']; |
| 117 | 117 | } |
| 118 | 118 | unset($getid3_temp, $getid3_apetag); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $info = &$this->getid3->info; |
| 133 | 133 | |
| 134 | - if (!getid3_lib::intValueSupported($endoffset)) { |
|
| 134 | + if ( ! getid3_lib::intValueSupported($endoffset)) { |
|
| 135 | 135 | $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
| 136 | 136 | return false; |
| 137 | 137 | } |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | foreach ($imagestrings as $key => $imagestring) { |
| 212 | 212 | if (strpos($imagestring, '||') !== false) { |
| 213 | 213 | $imagearray = explode('||', $imagestring); |
| 214 | - $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : ''); |
|
| 215 | - $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : ''); |
|
| 214 | + $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : ''); |
|
| 215 | + $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : ''); |
|
| 216 | 216 | $ParsedLyrics3['images'][$key]['timestamp'] = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : ''); |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -1667,6 +1667,7 @@ |
||
| 1667 | 1667 | * Inline CSS filter |
| 1668 | 1668 | * |
| 1669 | 1669 | * @since 2.8.1 |
| 1670 | + * @param string $css |
|
| 1670 | 1671 | */ |
| 1671 | 1672 | function safecss_filter_attr( $css, $deprecated = '' ) { |
| 1672 | 1673 | if ( !empty( $deprecated ) ) |
@@ -1,35 +1,35 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * kses 0.2.2 - HTML/XHTML filter that only allows some elements and attributes |
|
| 4 | - * Copyright (C) 2002, 2003, 2005 Ulf Harnhammar |
|
| 5 | - * |
|
| 6 | - * This program is free software and open source software; you can redistribute |
|
| 7 | - * it and/or modify it under the terms of the GNU General Public License as |
|
| 8 | - * published by the Free Software Foundation; either version 2 of the License, |
|
| 9 | - * or (at your option) any later version. |
|
| 10 | - * |
|
| 11 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|
| 12 | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
| 13 | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
| 14 | - * more details. |
|
| 15 | - * |
|
| 16 | - * You should have received a copy of the GNU General Public License along |
|
| 17 | - * with this program; if not, write to the Free Software Foundation, Inc., |
|
| 18 | - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
|
| 19 | - * http://www.gnu.org/licenses/gpl.html |
|
| 20 | - * |
|
| 21 | - * [kses strips evil scripts!] |
|
| 22 | - * |
|
| 23 | - * Added wp_ prefix to avoid conflicts with existing kses users |
|
| 24 | - * |
|
| 25 | - * @version 0.2.2 |
|
| 26 | - * @copyright (C) 2002, 2003, 2005 |
|
| 27 | - * @author Ulf Harnhammar <http://advogato.org/person/metaur/> |
|
| 28 | - * |
|
| 29 | - * @package External |
|
| 30 | - * @subpackage KSES |
|
| 31 | - * |
|
| 32 | - */ |
|
| 3 | + * kses 0.2.2 - HTML/XHTML filter that only allows some elements and attributes |
|
| 4 | + * Copyright (C) 2002, 2003, 2005 Ulf Harnhammar |
|
| 5 | + * |
|
| 6 | + * This program is free software and open source software; you can redistribute |
|
| 7 | + * it and/or modify it under the terms of the GNU General Public License as |
|
| 8 | + * published by the Free Software Foundation; either version 2 of the License, |
|
| 9 | + * or (at your option) any later version. |
|
| 10 | + * |
|
| 11 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
|
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
| 14 | + * more details. |
|
| 15 | + * |
|
| 16 | + * You should have received a copy of the GNU General Public License along |
|
| 17 | + * with this program; if not, write to the Free Software Foundation, Inc., |
|
| 18 | + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
|
| 19 | + * http://www.gnu.org/licenses/gpl.html |
|
| 20 | + * |
|
| 21 | + * [kses strips evil scripts!] |
|
| 22 | + * |
|
| 23 | + * Added wp_ prefix to avoid conflicts with existing kses users |
|
| 24 | + * |
|
| 25 | + * @version 0.2.2 |
|
| 26 | + * @copyright (C) 2002, 2003, 2005 |
|
| 27 | + * @author Ulf Harnhammar <http://advogato.org/person/metaur/> |
|
| 28 | + * |
|
| 29 | + * @package External |
|
| 30 | + * @subpackage KSES |
|
| 31 | + * |
|
| 32 | + */ |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * You can override this in a plugin. |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @since 1.2.0 |
| 43 | 43 | */ |
| 44 | -if ( ! defined( 'CUSTOM_TAGS' ) ) |
|
| 45 | - define( 'CUSTOM_TAGS', false ); |
|
| 44 | +if ( ! defined('CUSTOM_TAGS')) |
|
| 45 | + define('CUSTOM_TAGS', false); |
|
| 46 | 46 | |
| 47 | 47 | // Ensure that these variables are added to the global namespace |
| 48 | 48 | // (e.g. if using namespaces / autoload in the current PHP environment). |
| 49 | 49 | global $allowedposttags, $allowedtags, $allowedentitynames; |
| 50 | 50 | |
| 51 | -if ( ! CUSTOM_TAGS ) { |
|
| 51 | +if ( ! CUSTOM_TAGS) { |
|
| 52 | 52 | /** |
| 53 | 53 | * Kses global for default allowable HTML tags. |
| 54 | 54 | * |
@@ -447,55 +447,55 @@ discard block |
||
| 447 | 447 | ); |
| 448 | 448 | |
| 449 | 449 | $allowedentitynames = array( |
| 450 | - 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', |
|
| 451 | - 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', |
|
| 452 | - 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', |
|
| 453 | - 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', |
|
| 454 | - 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', |
|
| 455 | - 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', |
|
| 456 | - 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', |
|
| 457 | - 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', |
|
| 458 | - 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', |
|
| 459 | - 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', |
|
| 460 | - 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', |
|
| 461 | - 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', |
|
| 462 | - 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', |
|
| 463 | - 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', |
|
| 464 | - 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', |
|
| 465 | - 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', |
|
| 466 | - 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', |
|
| 467 | - 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', |
|
| 468 | - 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', |
|
| 469 | - 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', |
|
| 470 | - 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', |
|
| 471 | - 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', |
|
| 472 | - 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', |
|
| 473 | - 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', |
|
| 474 | - 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', |
|
| 475 | - 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', |
|
| 476 | - 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', |
|
| 477 | - 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', |
|
| 478 | - 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', |
|
| 479 | - 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', |
|
| 480 | - 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', |
|
| 481 | - 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', |
|
| 482 | - 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', |
|
| 483 | - 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', |
|
| 484 | - 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', |
|
| 485 | - 'radic', 'prop', 'infin', 'ang', 'and', 'or', |
|
| 486 | - 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', |
|
| 487 | - 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', |
|
| 488 | - 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', |
|
| 489 | - 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', |
|
| 490 | - 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', |
|
| 491 | - 'sup1', 'sup2', 'sup3', 'frac14', 'frac12', 'frac34', |
|
| 450 | + 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', |
|
| 451 | + 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', |
|
| 452 | + 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', |
|
| 453 | + 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', |
|
| 454 | + 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', |
|
| 455 | + 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', |
|
| 456 | + 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', |
|
| 457 | + 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', |
|
| 458 | + 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', |
|
| 459 | + 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', |
|
| 460 | + 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', |
|
| 461 | + 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', |
|
| 462 | + 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', |
|
| 463 | + 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', |
|
| 464 | + 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', |
|
| 465 | + 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', |
|
| 466 | + 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', |
|
| 467 | + 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', |
|
| 468 | + 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', |
|
| 469 | + 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', |
|
| 470 | + 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', |
|
| 471 | + 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', |
|
| 472 | + 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', |
|
| 473 | + 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', |
|
| 474 | + 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', |
|
| 475 | + 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', |
|
| 476 | + 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', |
|
| 477 | + 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', |
|
| 478 | + 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', |
|
| 479 | + 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', |
|
| 480 | + 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', |
|
| 481 | + 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', |
|
| 482 | + 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', |
|
| 483 | + 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', |
|
| 484 | + 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', |
|
| 485 | + 'radic', 'prop', 'infin', 'ang', 'and', 'or', |
|
| 486 | + 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', |
|
| 487 | + 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', |
|
| 488 | + 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', |
|
| 489 | + 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', |
|
| 490 | + 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', |
|
| 491 | + 'sup1', 'sup2', 'sup3', 'frac14', 'frac12', 'frac34', |
|
| 492 | 492 | 'there4', |
| 493 | 493 | ); |
| 494 | 494 | |
| 495 | - $allowedposttags = array_map( '_wp_add_global_attributes', $allowedposttags ); |
|
| 495 | + $allowedposttags = array_map('_wp_add_global_attributes', $allowedposttags); |
|
| 496 | 496 | } else { |
| 497 | - $allowedtags = wp_kses_array_lc( $allowedtags ); |
|
| 498 | - $allowedposttags = wp_kses_array_lc( $allowedposttags ); |
|
| 497 | + $allowedtags = wp_kses_array_lc($allowedtags); |
|
| 498 | + $allowedposttags = wp_kses_array_lc($allowedposttags); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | /** |
@@ -518,10 +518,10 @@ discard block |
||
| 518 | 518 | * @param array $allowed_protocols Optional. Allowed protocol in links. |
| 519 | 519 | * @return string Filtered content with only allowed HTML elements |
| 520 | 520 | */ |
| 521 | -function wp_kses( $string, $allowed_html, $allowed_protocols = array() ) { |
|
| 522 | - if ( empty( $allowed_protocols ) ) |
|
| 521 | +function wp_kses($string, $allowed_html, $allowed_protocols = array()) { |
|
| 522 | + if (empty($allowed_protocols)) |
|
| 523 | 523 | $allowed_protocols = wp_allowed_protocols(); |
| 524 | - $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); |
|
| 524 | + $string = wp_kses_no_null($string, array('slash_zero' => 'keep')); |
|
| 525 | 525 | $string = wp_kses_js_entities($string); |
| 526 | 526 | $string = wp_kses_normalize_entities($string); |
| 527 | 527 | $string = wp_kses_hook($string, $allowed_html, $allowed_protocols); // WP changed the order of these funcs and added args to wp_kses_hook |
@@ -540,12 +540,12 @@ discard block |
||
| 540 | 540 | * @param string $element The element name to which the attribute belongs. |
| 541 | 541 | * @return string Filtered attribute. |
| 542 | 542 | */ |
| 543 | -function wp_kses_one_attr( $string, $element ) { |
|
| 543 | +function wp_kses_one_attr($string, $element) { |
|
| 544 | 544 | $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action'); |
| 545 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
| 545 | + $allowed_html = wp_kses_allowed_html('post'); |
|
| 546 | 546 | $allowed_protocols = wp_allowed_protocols(); |
| 547 | - $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); |
|
| 548 | - $string = wp_kses_js_entities( $string ); |
|
| 547 | + $string = wp_kses_no_null($string, array('slash_zero' => 'keep')); |
|
| 548 | + $string = wp_kses_js_entities($string); |
|
| 549 | 549 | |
| 550 | 550 | // Preserve leading and trailing whitespace. |
| 551 | 551 | $matches = array(); |
@@ -553,40 +553,40 @@ discard block |
||
| 553 | 553 | $lead = $matches[0]; |
| 554 | 554 | preg_match('/\s*$/', $string, $matches); |
| 555 | 555 | $trail = $matches[0]; |
| 556 | - if ( empty( $trail ) ) { |
|
| 557 | - $string = substr( $string, strlen( $lead ) ); |
|
| 556 | + if (empty($trail)) { |
|
| 557 | + $string = substr($string, strlen($lead)); |
|
| 558 | 558 | } else { |
| 559 | - $string = substr( $string, strlen( $lead ), -strlen( $trail ) ); |
|
| 559 | + $string = substr($string, strlen($lead), -strlen($trail)); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // Parse attribute name and value from input. |
| 563 | - $split = preg_split( '/\s*=\s*/', $string, 2 ); |
|
| 563 | + $split = preg_split('/\s*=\s*/', $string, 2); |
|
| 564 | 564 | $name = $split[0]; |
| 565 | - if ( count( $split ) == 2 ) { |
|
| 565 | + if (count($split) == 2) { |
|
| 566 | 566 | $value = $split[1]; |
| 567 | 567 | |
| 568 | 568 | // Remove quotes surrounding $value. |
| 569 | 569 | // Also guarantee correct quoting in $string for this one attribute. |
| 570 | - if ( '' == $value ) { |
|
| 570 | + if ('' == $value) { |
|
| 571 | 571 | $quote = ''; |
| 572 | 572 | } else { |
| 573 | 573 | $quote = $value[0]; |
| 574 | 574 | } |
| 575 | - if ( '"' == $quote || "'" == $quote ) { |
|
| 576 | - if ( substr( $value, -1 ) != $quote ) { |
|
| 575 | + if ('"' == $quote || "'" == $quote) { |
|
| 576 | + if (substr($value, -1) != $quote) { |
|
| 577 | 577 | return ''; |
| 578 | 578 | } |
| 579 | - $value = substr( $value, 1, -1 ); |
|
| 579 | + $value = substr($value, 1, -1); |
|
| 580 | 580 | } else { |
| 581 | 581 | $quote = '"'; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | // Sanitize quotes, angle braces, and entities. |
| 585 | - $value = esc_attr( $value ); |
|
| 585 | + $value = esc_attr($value); |
|
| 586 | 586 | |
| 587 | 587 | // Sanitize URI values. |
| 588 | - if ( in_array( strtolower( $name ), $uris ) ) { |
|
| 589 | - $value = wp_kses_bad_protocol( $value, $allowed_protocols ); |
|
| 588 | + if (in_array(strtolower($name), $uris)) { |
|
| 589 | + $value = wp_kses_bad_protocol($value, $allowed_protocols); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | $string = "$name=$quote$value$quote"; |
@@ -597,10 +597,10 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | // Sanitize attribute by name. |
| 600 | - wp_kses_attr_check( $name, $value, $string, $vless, $element, $allowed_html ); |
|
| 600 | + wp_kses_attr_check($name, $value, $string, $vless, $element, $allowed_html); |
|
| 601 | 601 | |
| 602 | 602 | // Restore whitespace. |
| 603 | - return $lead . $string . $trail; |
|
| 603 | + return $lead.$string.$trail; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -617,10 +617,10 @@ discard block |
||
| 617 | 617 | * the name of a field filter such as pre_user_description. |
| 618 | 618 | * @return array List of allowed tags and their allowed attributes. |
| 619 | 619 | */ |
| 620 | -function wp_kses_allowed_html( $context = '' ) { |
|
| 620 | +function wp_kses_allowed_html($context = '') { |
|
| 621 | 621 | global $allowedposttags, $allowedtags, $allowedentitynames; |
| 622 | 622 | |
| 623 | - if ( is_array( $context ) ) { |
|
| 623 | + if (is_array($context)) { |
|
| 624 | 624 | /** |
| 625 | 625 | * Filter HTML elements allowed for a given context. |
| 626 | 626 | * |
@@ -630,33 +630,33 @@ discard block |
||
| 630 | 630 | * @param string $context Context to judge allowed tags by. Allowed values are 'post', |
| 631 | 631 | * 'data', 'strip', 'entities', 'explicit', or the name of a filter. |
| 632 | 632 | */ |
| 633 | - return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' ); |
|
| 633 | + return apply_filters('wp_kses_allowed_html', $context, 'explicit'); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - switch ( $context ) { |
|
| 636 | + switch ($context) { |
|
| 637 | 637 | case 'post': |
| 638 | 638 | /** This filter is documented in wp-includes/kses.php */ |
| 639 | - return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context ); |
|
| 639 | + return apply_filters('wp_kses_allowed_html', $allowedposttags, $context); |
|
| 640 | 640 | |
| 641 | 641 | case 'user_description': |
| 642 | 642 | case 'pre_user_description': |
| 643 | 643 | $tags = $allowedtags; |
| 644 | 644 | $tags['a']['rel'] = true; |
| 645 | 645 | /** This filter is documented in wp-includes/kses.php */ |
| 646 | - return apply_filters( 'wp_kses_allowed_html', $tags, $context ); |
|
| 646 | + return apply_filters('wp_kses_allowed_html', $tags, $context); |
|
| 647 | 647 | |
| 648 | 648 | case 'strip': |
| 649 | 649 | /** This filter is documented in wp-includes/kses.php */ |
| 650 | - return apply_filters( 'wp_kses_allowed_html', array(), $context ); |
|
| 650 | + return apply_filters('wp_kses_allowed_html', array(), $context); |
|
| 651 | 651 | |
| 652 | 652 | case 'entities': |
| 653 | 653 | /** This filter is documented in wp-includes/kses.php */ |
| 654 | - return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context); |
|
| 654 | + return apply_filters('wp_kses_allowed_html', $allowedentitynames, $context); |
|
| 655 | 655 | |
| 656 | 656 | case 'data': |
| 657 | 657 | default: |
| 658 | 658 | /** This filter is documented in wp-includes/kses.php */ |
| 659 | - return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context ); |
|
| 659 | + return apply_filters('wp_kses_allowed_html', $allowedtags, $context); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | * @param array $allowed_protocols Allowed protocol in links |
| 674 | 674 | * @return string Filtered content through 'pre_kses' hook |
| 675 | 675 | */ |
| 676 | -function wp_kses_hook( $string, $allowed_html, $allowed_protocols ) { |
|
| 676 | +function wp_kses_hook($string, $allowed_html, $allowed_protocols) { |
|
| 677 | 677 | /** |
| 678 | 678 | * Filter content to be run through kses. |
| 679 | 679 | * |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | * @param array $allowed_html Allowed HTML elements. |
| 684 | 684 | * @param array $allowed_protocols Allowed protocol in links. |
| 685 | 685 | */ |
| 686 | - return apply_filters( 'pre_kses', $string, $allowed_html, $allowed_protocols ); |
|
| 686 | + return apply_filters('pre_kses', $string, $allowed_html, $allowed_protocols); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -712,11 +712,11 @@ discard block |
||
| 712 | 712 | * @param array $allowed_protocols Allowed protocols to keep |
| 713 | 713 | * @return string Content with fixed HTML tags |
| 714 | 714 | */ |
| 715 | -function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { |
|
| 715 | +function wp_kses_split($string, $allowed_html, $allowed_protocols) { |
|
| 716 | 716 | global $pass_allowed_html, $pass_allowed_protocols; |
| 717 | 717 | $pass_allowed_html = $allowed_html; |
| 718 | 718 | $pass_allowed_protocols = $allowed_protocols; |
| 719 | - return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string ); |
|
| 719 | + return preg_replace_callback('%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -730,9 +730,9 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @return string |
| 732 | 732 | */ |
| 733 | -function _wp_kses_split_callback( $match ) { |
|
| 733 | +function _wp_kses_split_callback($match) { |
|
| 734 | 734 | global $pass_allowed_html, $pass_allowed_protocols; |
| 735 | - return wp_kses_split2( $match[0], $pass_allowed_html, $pass_allowed_protocols ); |
|
| 735 | + return wp_kses_split2($match[0], $pass_allowed_html, $pass_allowed_protocols); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -762,11 +762,11 @@ discard block |
||
| 762 | 762 | return '>'; |
| 763 | 763 | // It matched a ">" character |
| 764 | 764 | |
| 765 | - if ( '<!--' == substr( $string, 0, 4 ) ) { |
|
| 766 | - $string = str_replace( array('<!--', '-->'), '', $string ); |
|
| 767 | - while ( $string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols)) ) |
|
| 765 | + if ('<!--' == substr($string, 0, 4)) { |
|
| 766 | + $string = str_replace(array('<!--', '-->'), '', $string); |
|
| 767 | + while ($string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols))) |
|
| 768 | 768 | $string = $newstring; |
| 769 | - if ( $string == '' ) |
|
| 769 | + if ($string == '') |
|
| 770 | 770 | return ''; |
| 771 | 771 | // prevent multiple dashes in comments |
| 772 | 772 | $string = preg_replace('/--+/', '-', $string); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | // Allow HTML comments |
| 778 | 778 | |
| 779 | - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) |
|
| 779 | + if ( ! preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) |
|
| 780 | 780 | return ''; |
| 781 | 781 | // It's seriously malformed |
| 782 | 782 | |
@@ -784,10 +784,10 @@ discard block |
||
| 784 | 784 | $elem = $matches[2]; |
| 785 | 785 | $attrlist = $matches[3]; |
| 786 | 786 | |
| 787 | - if ( ! is_array( $allowed_html ) ) |
|
| 788 | - $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 787 | + if ( ! is_array($allowed_html)) |
|
| 788 | + $allowed_html = wp_kses_allowed_html($allowed_html); |
|
| 789 | 789 | |
| 790 | - if ( ! isset($allowed_html[strtolower($elem)]) ) |
|
| 790 | + if ( ! isset($allowed_html[strtolower($elem)])) |
|
| 791 | 791 | return ''; |
| 792 | 792 | // They are using a not allowed HTML element |
| 793 | 793 | |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | return "</$elem>"; |
| 796 | 796 | // No attributes are allowed for closing elements |
| 797 | 797 | |
| 798 | - return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); |
|
| 798 | + return wp_kses_attr($elem, $attrlist, $allowed_html, $allowed_protocols); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -816,8 +816,8 @@ discard block |
||
| 816 | 816 | * @return string Sanitized HTML element |
| 817 | 817 | */ |
| 818 | 818 | function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { |
| 819 | - if ( ! is_array( $allowed_html ) ) |
|
| 820 | - $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 819 | + if ( ! is_array($allowed_html)) |
|
| 820 | + $allowed_html = wp_kses_allowed_html($allowed_html); |
|
| 821 | 821 | |
| 822 | 822 | // Is there a closing XHTML slash at the end of the attributes? |
| 823 | 823 | $xhtml_slash = ''; |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | $xhtml_slash = ' /'; |
| 826 | 826 | |
| 827 | 827 | // Are any attributes allowed at all for this element? |
| 828 | - if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 ) |
|
| 828 | + if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0) |
|
| 829 | 829 | return "<$element$xhtml_slash>"; |
| 830 | 830 | |
| 831 | 831 | // Split it |
@@ -834,8 +834,8 @@ discard block |
||
| 834 | 834 | // Go through $attrarr, and save the allowed attributes for this element |
| 835 | 835 | // in $attr2 |
| 836 | 836 | $attr2 = ''; |
| 837 | - foreach ( $attrarr as $arreach ) { |
|
| 838 | - if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { |
|
| 837 | + foreach ($attrarr as $arreach) { |
|
| 838 | + if (wp_kses_attr_check($arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html)) { |
|
| 839 | 839 | $attr2 .= ' '.$arreach['whole']; |
| 840 | 840 | } |
| 841 | 841 | } |
@@ -859,31 +859,31 @@ discard block |
||
| 859 | 859 | * @param array $allowed_html The full list of allowed elements and attributes. |
| 860 | 860 | * @return bool Is the attribute allowed? |
| 861 | 861 | */ |
| 862 | -function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) { |
|
| 863 | - $allowed_attr = $allowed_html[strtolower( $element )]; |
|
| 862 | +function wp_kses_attr_check(&$name, &$value, &$whole, $vless, $element, $allowed_html) { |
|
| 863 | + $allowed_attr = $allowed_html[strtolower($element)]; |
|
| 864 | 864 | |
| 865 | - $name_low = strtolower( $name ); |
|
| 866 | - if ( ! isset( $allowed_attr[$name_low] ) || '' == $allowed_attr[$name_low] ) { |
|
| 865 | + $name_low = strtolower($name); |
|
| 866 | + if ( ! isset($allowed_attr[$name_low]) || '' == $allowed_attr[$name_low]) { |
|
| 867 | 867 | $name = $value = $whole = ''; |
| 868 | 868 | return false; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( 'style' == $name_low ) { |
|
| 872 | - $new_value = safecss_filter_attr( $value ); |
|
| 871 | + if ('style' == $name_low) { |
|
| 872 | + $new_value = safecss_filter_attr($value); |
|
| 873 | 873 | |
| 874 | - if ( empty( $new_value ) ) { |
|
| 874 | + if (empty($new_value)) { |
|
| 875 | 875 | $name = $value = $whole = ''; |
| 876 | 876 | return false; |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - $whole = str_replace( $value, $new_value, $whole ); |
|
| 879 | + $whole = str_replace($value, $new_value, $whole); |
|
| 880 | 880 | $value = $new_value; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - if ( is_array( $allowed_attr[$name_low] ) ) { |
|
| 883 | + if (is_array($allowed_attr[$name_low])) { |
|
| 884 | 884 | // there are some checks |
| 885 | - foreach ( $allowed_attr[$name_low] as $currkey => $currval ) { |
|
| 886 | - if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) { |
|
| 885 | + foreach ($allowed_attr[$name_low] as $currkey => $currval) { |
|
| 886 | + if ( ! wp_kses_check_attr_val($value, $vless, $currkey, $currval)) { |
|
| 887 | 887 | $name = $value = $whole = ''; |
| 888 | 888 | return false; |
| 889 | 889 | } |
@@ -924,10 +924,10 @@ discard block |
||
| 924 | 924 | switch ($mode) { |
| 925 | 925 | case 0 : // attribute name, href for instance |
| 926 | 926 | |
| 927 | - if ( preg_match('/^([-a-zA-Z:]+)/', $attr, $match ) ) { |
|
| 927 | + if (preg_match('/^([-a-zA-Z:]+)/', $attr, $match)) { |
|
| 928 | 928 | $attrname = $match[1]; |
| 929 | 929 | $working = $mode = 1; |
| 930 | - $attr = preg_replace( '/^[-a-zA-Z:]+/', '', $attr ); |
|
| 930 | + $attr = preg_replace('/^[-a-zA-Z:]+/', '', $attr); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | break; |
@@ -946,8 +946,8 @@ discard block |
||
| 946 | 946 | { |
| 947 | 947 | $working = 1; |
| 948 | 948 | $mode = 0; |
| 949 | - if(false === array_key_exists($attrname, $attrarr)) { |
|
| 950 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
| 949 | + if (false === array_key_exists($attrname, $attrarr)) { |
|
| 950 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
| 951 | 951 | } |
| 952 | 952 | $attr = preg_replace('/^\s+/', '', $attr); |
| 953 | 953 | } |
@@ -960,11 +960,11 @@ discard block |
||
| 960 | 960 | // "value" |
| 961 | 961 | { |
| 962 | 962 | $thisval = $match[1]; |
| 963 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 963 | + if (in_array(strtolower($attrname), $uris)) |
|
| 964 | 964 | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| 965 | 965 | |
| 966 | - if(false === array_key_exists($attrname, $attrarr)) { |
|
| 967 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
| 966 | + if (false === array_key_exists($attrname, $attrarr)) { |
|
| 967 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
| 968 | 968 | } |
| 969 | 969 | $working = 1; |
| 970 | 970 | $mode = 0; |
@@ -976,11 +976,11 @@ discard block |
||
| 976 | 976 | // 'value' |
| 977 | 977 | { |
| 978 | 978 | $thisval = $match[1]; |
| 979 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 979 | + if (in_array(strtolower($attrname), $uris)) |
|
| 980 | 980 | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| 981 | 981 | |
| 982 | - if(false === array_key_exists($attrname, $attrarr)) { |
|
| 983 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
|
| 982 | + if (false === array_key_exists($attrname, $attrarr)) { |
|
| 983 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
|
| 984 | 984 | } |
| 985 | 985 | $working = 1; |
| 986 | 986 | $mode = 0; |
@@ -992,11 +992,11 @@ discard block |
||
| 992 | 992 | // value |
| 993 | 993 | { |
| 994 | 994 | $thisval = $match[1]; |
| 995 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 995 | + if (in_array(strtolower($attrname), $uris)) |
|
| 996 | 996 | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| 997 | 997 | |
| 998 | - if(false === array_key_exists($attrname, $attrarr)) { |
|
| 999 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
| 998 | + if (false === array_key_exists($attrname, $attrarr)) { |
|
| 999 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | // We add quotes to conform to W3C's HTML spec. |
| 1002 | 1002 | $working = 1; |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | if ($mode == 1 && false === array_key_exists($attrname, $attrarr)) |
| 1018 | 1018 | // special case, for when the attribute list ends with a valueless |
| 1019 | 1019 | // attribute like "selected" |
| 1020 | - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
| 1020 | + $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
|
| 1021 | 1021 | |
| 1022 | 1022 | return $attrarr; |
| 1023 | 1023 | } |
@@ -1034,40 +1034,40 @@ discard block |
||
| 1034 | 1034 | * @param string $element HTML element/tag |
| 1035 | 1035 | * @return array|bool List of attributes found in $element. Returns false on failure. |
| 1036 | 1036 | */ |
| 1037 | -function wp_kses_attr_parse( $element ) { |
|
| 1037 | +function wp_kses_attr_parse($element) { |
|
| 1038 | 1038 | $valid = preg_match('%^(<\s*)(/\s*)?([a-zA-Z0-9]+\s*)([^>]*)(>?)$%', $element, $matches); |
| 1039 | - if ( 1 !== $valid ) { |
|
| 1039 | + if (1 !== $valid) { |
|
| 1040 | 1040 | return false; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - $begin = $matches[1]; |
|
| 1044 | - $slash = $matches[2]; |
|
| 1043 | + $begin = $matches[1]; |
|
| 1044 | + $slash = $matches[2]; |
|
| 1045 | 1045 | $elname = $matches[3]; |
| 1046 | - $attr = $matches[4]; |
|
| 1047 | - $end = $matches[5]; |
|
| 1046 | + $attr = $matches[4]; |
|
| 1047 | + $end = $matches[5]; |
|
| 1048 | 1048 | |
| 1049 | - if ( '' !== $slash ) { |
|
| 1049 | + if ('' !== $slash) { |
|
| 1050 | 1050 | // Closing elements do not get parsed. |
| 1051 | 1051 | return false; |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | // Is there a closing XHTML slash at the end of the attributes? |
| 1055 | - if ( 1 === preg_match( '%\s*/\s*$%', $attr, $matches ) ) { |
|
| 1055 | + if (1 === preg_match('%\s*/\s*$%', $attr, $matches)) { |
|
| 1056 | 1056 | $xhtml_slash = $matches[0]; |
| 1057 | - $attr = substr( $attr, 0, -strlen( $xhtml_slash ) ); |
|
| 1057 | + $attr = substr($attr, 0, -strlen($xhtml_slash)); |
|
| 1058 | 1058 | } else { |
| 1059 | 1059 | $xhtml_slash = ''; |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | // Split it |
| 1063 | - $attrarr = wp_kses_hair_parse( $attr ); |
|
| 1064 | - if ( false === $attrarr ) { |
|
| 1063 | + $attrarr = wp_kses_hair_parse($attr); |
|
| 1064 | + if (false === $attrarr) { |
|
| 1065 | 1065 | return false; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | // Make sure all input is returned by adding front and back matter. |
| 1069 | - array_unshift( $attrarr, $begin . $slash . $elname ); |
|
| 1070 | - array_push( $attrarr, $xhtml_slash . $end ); |
|
| 1069 | + array_unshift($attrarr, $begin.$slash.$elname); |
|
| 1070 | + array_push($attrarr, $xhtml_slash.$end); |
|
| 1071 | 1071 | |
| 1072 | 1072 | return $attrarr; |
| 1073 | 1073 | } |
@@ -1085,8 +1085,8 @@ discard block |
||
| 1085 | 1085 | * @param string $attr Attribute list from HTML element to closing HTML element tag |
| 1086 | 1086 | * @return array|bool List of attributes found in $attr. Returns false on failure. |
| 1087 | 1087 | */ |
| 1088 | -function wp_kses_hair_parse( $attr ) { |
|
| 1089 | - if ( '' === $attr ) { |
|
| 1088 | +function wp_kses_hair_parse($attr) { |
|
| 1089 | + if ('' === $attr) { |
|
| 1090 | 1090 | return array(); |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | . '|' |
| 1110 | 1110 | . '(?:\s|$)' // If attribute has no value, space is required. |
| 1111 | 1111 | . ')' |
| 1112 | - . '\s*'; // Trailing space is optional except as mentioned above. |
|
| 1112 | + . '\s*'; // Trailing space is optional except as mentioned above. |
|
| 1113 | 1113 | |
| 1114 | 1114 | // Although it is possible to reduce this procedure to a single regexp, |
| 1115 | 1115 | // we must run that regexp twice to get exactly the expected result. |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | $validation = "%^($regex)+$%"; |
| 1118 | 1118 | $extraction = "%$regex%"; |
| 1119 | 1119 | |
| 1120 | - if ( 1 === preg_match( $validation, $attr ) ) { |
|
| 1121 | - preg_match_all( $extraction, $attr, $attrarr ); |
|
| 1120 | + if (1 === preg_match($validation, $attr)) { |
|
| 1121 | + preg_match_all($extraction, $attr, $attrarr); |
|
| 1122 | 1122 | return $attrarr[0]; |
| 1123 | 1123 | } else { |
| 1124 | 1124 | return false; |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | // value is not greater than the given value. |
| 1168 | 1168 | // This check can be used to avoid Denial of Service attacks. |
| 1169 | 1169 | |
| 1170 | - if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1170 | + if ( ! preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1171 | 1171 | $ok = false; |
| 1172 | 1172 | if ($value > $checkvalue) |
| 1173 | 1173 | $ok = false; |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | // The minval check makes sure that the attribute value is a positive integer, |
| 1178 | 1178 | // and that it is not smaller than the given value. |
| 1179 | 1179 | |
| 1180 | - if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1180 | + if ( ! preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1181 | 1181 | $ok = false; |
| 1182 | 1182 | if ($value < $checkvalue) |
| 1183 | 1183 | $ok = false; |
@@ -1218,9 +1218,9 @@ discard block |
||
| 1218 | 1218 | do { |
| 1219 | 1219 | $original_string = $string; |
| 1220 | 1220 | $string = wp_kses_bad_protocol_once($string, $allowed_protocols); |
| 1221 | - } while ( $original_string != $string && ++$iterations < 6 ); |
|
| 1221 | + } while ($original_string != $string && ++$iterations < 6); |
|
| 1222 | 1222 | |
| 1223 | - if ( $original_string != $string ) |
|
| 1223 | + if ($original_string != $string) |
|
| 1224 | 1224 | return ''; |
| 1225 | 1225 | |
| 1226 | 1226 | return $string; |
@@ -1237,14 +1237,14 @@ discard block |
||
| 1237 | 1237 | * @param array $options Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'. |
| 1238 | 1238 | * @return string |
| 1239 | 1239 | */ |
| 1240 | -function wp_kses_no_null( $string, $options = null ) { |
|
| 1241 | - if ( ! isset( $options['slash_zero'] ) ) { |
|
| 1242 | - $options = array( 'slash_zero' => 'remove' ); |
|
| 1240 | +function wp_kses_no_null($string, $options = null) { |
|
| 1241 | + if ( ! isset($options['slash_zero'])) { |
|
| 1242 | + $options = array('slash_zero' => 'remove'); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - $string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string ); |
|
| 1246 | - if ( 'remove' == $options['slash_zero'] ) { |
|
| 1247 | - $string = preg_replace( '/\\\\+0+/', '', $string ); |
|
| 1245 | + $string = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string); |
|
| 1246 | + if ('remove' == $options['slash_zero']) { |
|
| 1247 | + $string = preg_replace('/\\\\+0+/', '', $string); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | return $string; |
@@ -1275,13 +1275,13 @@ discard block |
||
| 1275 | 1275 | * @return array Fixed array with all lowercase keys |
| 1276 | 1276 | */ |
| 1277 | 1277 | function wp_kses_array_lc($inarray) { |
| 1278 | - $outarray = array (); |
|
| 1278 | + $outarray = array(); |
|
| 1279 | 1279 | |
| 1280 | - foreach ( (array) $inarray as $inkey => $inval) { |
|
| 1280 | + foreach ((array) $inarray as $inkey => $inval) { |
|
| 1281 | 1281 | $outkey = strtolower($inkey); |
| 1282 | - $outarray[$outkey] = array (); |
|
| 1282 | + $outarray[$outkey] = array(); |
|
| 1283 | 1283 | |
| 1284 | - foreach ( (array) $inval as $inkey2 => $inval2) { |
|
| 1284 | + foreach ((array) $inval as $inkey2 => $inval2) { |
|
| 1285 | 1285 | $outkey2 = strtolower($inkey2); |
| 1286 | 1286 | $outarray[$outkey][$outkey2] = $inval2; |
| 1287 | 1287 | } // foreach $inval |
@@ -1329,19 +1329,19 @@ discard block |
||
| 1329 | 1329 | * @param string $allowed_protocols Allowed protocols |
| 1330 | 1330 | * @return string Sanitized content |
| 1331 | 1331 | */ |
| 1332 | -function wp_kses_bad_protocol_once($string, $allowed_protocols, $count = 1 ) { |
|
| 1333 | - $string2 = preg_split( '/:|�*58;|�*3a;/i', $string, 2 ); |
|
| 1334 | - if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) ) { |
|
| 1335 | - $string = trim( $string2[1] ); |
|
| 1336 | - $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); |
|
| 1337 | - if ( 'feed:' == $protocol ) { |
|
| 1338 | - if ( $count > 2 ) |
|
| 1332 | +function wp_kses_bad_protocol_once($string, $allowed_protocols, $count = 1) { |
|
| 1333 | + $string2 = preg_split('/:|�*58;|�*3a;/i', $string, 2); |
|
| 1334 | + if (isset($string2[1]) && ! preg_match('%/\?%', $string2[0])) { |
|
| 1335 | + $string = trim($string2[1]); |
|
| 1336 | + $protocol = wp_kses_bad_protocol_once2($string2[0], $allowed_protocols); |
|
| 1337 | + if ('feed:' == $protocol) { |
|
| 1338 | + if ($count > 2) |
|
| 1339 | 1339 | return ''; |
| 1340 | - $string = wp_kses_bad_protocol_once( $string, $allowed_protocols, ++$count ); |
|
| 1341 | - if ( empty( $string ) ) |
|
| 1340 | + $string = wp_kses_bad_protocol_once($string, $allowed_protocols, ++$count); |
|
| 1341 | + if (empty($string)) |
|
| 1342 | 1342 | return $string; |
| 1343 | 1343 | } |
| 1344 | - $string = $protocol . $string; |
|
| 1344 | + $string = $protocol.$string; |
|
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | 1347 | return $string; |
@@ -1360,15 +1360,15 @@ discard block |
||
| 1360 | 1360 | * @param string $allowed_protocols Allowed protocols |
| 1361 | 1361 | * @return string Sanitized content |
| 1362 | 1362 | */ |
| 1363 | -function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) { |
|
| 1363 | +function wp_kses_bad_protocol_once2($string, $allowed_protocols) { |
|
| 1364 | 1364 | $string2 = wp_kses_decode_entities($string); |
| 1365 | 1365 | $string2 = preg_replace('/\s/', '', $string2); |
| 1366 | 1366 | $string2 = wp_kses_no_null($string2); |
| 1367 | 1367 | $string2 = strtolower($string2); |
| 1368 | 1368 | |
| 1369 | 1369 | $allowed = false; |
| 1370 | - foreach ( (array) $allowed_protocols as $one_protocol ) |
|
| 1371 | - if ( strtolower($one_protocol) == $string2 ) { |
|
| 1370 | + foreach ((array) $allowed_protocols as $one_protocol) |
|
| 1371 | + if (strtolower($one_protocol) == $string2) { |
|
| 1372 | 1372 | $allowed = true; |
| 1373 | 1373 | break; |
| 1374 | 1374 | } |
@@ -1418,11 +1418,11 @@ discard block |
||
| 1418 | 1418 | function wp_kses_named_entities($matches) { |
| 1419 | 1419 | global $allowedentitynames; |
| 1420 | 1420 | |
| 1421 | - if ( empty($matches[1]) ) |
|
| 1421 | + if (empty($matches[1])) |
|
| 1422 | 1422 | return ''; |
| 1423 | 1423 | |
| 1424 | 1424 | $i = $matches[1]; |
| 1425 | - return ( ! in_array( $i, $allowedentitynames ) ) ? "&$i;" : "&$i;"; |
|
| 1425 | + return ( ! in_array($i, $allowedentitynames)) ? "&$i;" : "&$i;"; |
|
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | /** |
@@ -1438,12 +1438,12 @@ discard block |
||
| 1438 | 1438 | * @return string Correctly encoded entity |
| 1439 | 1439 | */ |
| 1440 | 1440 | function wp_kses_normalize_entities2($matches) { |
| 1441 | - if ( empty($matches[1]) ) |
|
| 1441 | + if (empty($matches[1])) |
|
| 1442 | 1442 | return ''; |
| 1443 | 1443 | |
| 1444 | 1444 | $i = $matches[1]; |
| 1445 | 1445 | if (valid_unicode($i)) { |
| 1446 | - $i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT); |
|
| 1446 | + $i = str_pad(ltrim($i, '0'), 3, '0', STR_PAD_LEFT); |
|
| 1447 | 1447 | $i = "&#$i;"; |
| 1448 | 1448 | } else { |
| 1449 | 1449 | $i = "&#$i;"; |
@@ -1464,11 +1464,11 @@ discard block |
||
| 1464 | 1464 | * @return string Correctly encoded entity |
| 1465 | 1465 | */ |
| 1466 | 1466 | function wp_kses_normalize_entities3($matches) { |
| 1467 | - if ( empty($matches[1]) ) |
|
| 1467 | + if (empty($matches[1])) |
|
| 1468 | 1468 | return ''; |
| 1469 | 1469 | |
| 1470 | 1470 | $hexchars = $matches[1]; |
| 1471 | - return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';'; |
|
| 1471 | + return ( ! valid_unicode(hexdec($hexchars))) ? "&#x$hexchars;" : '&#x'.ltrim($hexchars, '0').';'; |
|
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | 1474 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
| 1478 | 1478 | * @return bool True if the value was a valid Unicode number |
| 1479 | 1479 | */ |
| 1480 | 1480 | function valid_unicode($i) { |
| 1481 | - return ( $i == 0x9 || $i == 0xa || $i == 0xd || |
|
| 1481 | + return ($i == 0x9 || $i == 0xa || $i == 0xd || |
|
| 1482 | 1482 | ($i >= 0x20 && $i <= 0xd7ff) || |
| 1483 | 1483 | ($i >= 0xe000 && $i <= 0xfffd) || |
| 1484 | - ($i >= 0x10000 && $i <= 0x10ffff) ); |
|
| 1484 | + ($i >= 0x10000 && $i <= 0x10ffff)); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | /** |
@@ -1509,8 +1509,8 @@ discard block |
||
| 1509 | 1509 | * @param array $match preg match |
| 1510 | 1510 | * @return string |
| 1511 | 1511 | */ |
| 1512 | -function _wp_kses_decode_entities_chr( $match ) { |
|
| 1513 | - return chr( $match[1] ); |
|
| 1512 | +function _wp_kses_decode_entities_chr($match) { |
|
| 1513 | + return chr($match[1]); |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | /** |
@@ -1519,8 +1519,8 @@ discard block |
||
| 1519 | 1519 | * @param array $match preg match |
| 1520 | 1520 | * @return string |
| 1521 | 1521 | */ |
| 1522 | -function _wp_kses_decode_entities_chr_hexdec( $match ) { |
|
| 1523 | - return chr( hexdec( $match[1] ) ); |
|
| 1522 | +function _wp_kses_decode_entities_chr_hexdec($match) { |
|
| 1523 | + return chr(hexdec($match[1])); |
|
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | /** |
@@ -1531,8 +1531,8 @@ discard block |
||
| 1531 | 1531 | * @param string $data Content to filter, expected to be escaped with slashes |
| 1532 | 1532 | * @return string Filtered content |
| 1533 | 1533 | */ |
| 1534 | -function wp_filter_kses( $data ) { |
|
| 1535 | - return addslashes( wp_kses( stripslashes( $data ), current_filter() ) ); |
|
| 1534 | +function wp_filter_kses($data) { |
|
| 1535 | + return addslashes(wp_kses(stripslashes($data), current_filter())); |
|
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | /** |
@@ -1543,8 +1543,8 @@ discard block |
||
| 1543 | 1543 | * @param string $data Content to filter, expected to not be escaped |
| 1544 | 1544 | * @return string Filtered content |
| 1545 | 1545 | */ |
| 1546 | -function wp_kses_data( $data ) { |
|
| 1547 | - return wp_kses( $data, current_filter() ); |
|
| 1546 | +function wp_kses_data($data) { |
|
| 1547 | + return wp_kses($data, current_filter()); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | /** |
@@ -1558,8 +1558,8 @@ discard block |
||
| 1558 | 1558 | * @param string $data Post content to filter, expected to be escaped with slashes |
| 1559 | 1559 | * @return string Filtered post content with allowed HTML tags and attributes intact. |
| 1560 | 1560 | */ |
| 1561 | -function wp_filter_post_kses( $data ) { |
|
| 1562 | - return addslashes( wp_kses( stripslashes( $data ), 'post' ) ); |
|
| 1561 | +function wp_filter_post_kses($data) { |
|
| 1562 | + return addslashes(wp_kses(stripslashes($data), 'post')); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | 1565 | /** |
@@ -1573,8 +1573,8 @@ discard block |
||
| 1573 | 1573 | * @param string $data Post content to filter |
| 1574 | 1574 | * @return string Filtered post content with allowed HTML tags and attributes intact. |
| 1575 | 1575 | */ |
| 1576 | -function wp_kses_post( $data ) { |
|
| 1577 | - return wp_kses( $data, 'post' ); |
|
| 1576 | +function wp_kses_post($data) { |
|
| 1577 | + return wp_kses($data, 'post'); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
@@ -1585,8 +1585,8 @@ discard block |
||
| 1585 | 1585 | * @param string $data Content to strip all HTML from |
| 1586 | 1586 | * @return string Filtered content without any HTML |
| 1587 | 1587 | */ |
| 1588 | -function wp_filter_nohtml_kses( $data ) { |
|
| 1589 | - return addslashes( wp_kses( stripslashes( $data ), 'strip' ) ); |
|
| 1588 | +function wp_filter_nohtml_kses($data) { |
|
| 1589 | + return addslashes(wp_kses(stripslashes($data), 'strip')); |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | /** |
@@ -1605,10 +1605,10 @@ discard block |
||
| 1605 | 1605 | add_filter('title_save_pre', 'wp_filter_kses'); |
| 1606 | 1606 | |
| 1607 | 1607 | // Comment filtering |
| 1608 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 1609 | - add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); |
|
| 1608 | + if (current_user_can('unfiltered_html')) |
|
| 1609 | + add_filter('pre_comment_content', 'wp_filter_post_kses'); |
|
| 1610 | 1610 | else |
| 1611 | - add_filter( 'pre_comment_content', 'wp_filter_kses' ); |
|
| 1611 | + add_filter('pre_comment_content', 'wp_filter_kses'); |
|
| 1612 | 1612 | |
| 1613 | 1613 | // Post filtering |
| 1614 | 1614 | add_filter('content_save_pre', 'wp_filter_post_kses'); |
@@ -1633,8 +1633,8 @@ discard block |
||
| 1633 | 1633 | remove_filter('title_save_pre', 'wp_filter_kses'); |
| 1634 | 1634 | |
| 1635 | 1635 | // Comment filtering |
| 1636 | - remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); |
|
| 1637 | - remove_filter( 'pre_comment_content', 'wp_filter_kses' ); |
|
| 1636 | + remove_filter('pre_comment_content', 'wp_filter_post_kses'); |
|
| 1637 | + remove_filter('pre_comment_content', 'wp_filter_kses'); |
|
| 1638 | 1638 | |
| 1639 | 1639 | // Post filtering |
| 1640 | 1640 | remove_filter('content_save_pre', 'wp_filter_post_kses'); |
@@ -1658,7 +1658,7 @@ discard block |
||
| 1658 | 1658 | function kses_init() { |
| 1659 | 1659 | kses_remove_filters(); |
| 1660 | 1660 | |
| 1661 | - if ( ! current_user_can( 'unfiltered_html' ) ) { |
|
| 1661 | + if ( ! current_user_can('unfiltered_html')) { |
|
| 1662 | 1662 | kses_init_filters(); |
| 1663 | 1663 | } |
| 1664 | 1664 | } |
@@ -1668,17 +1668,17 @@ discard block |
||
| 1668 | 1668 | * |
| 1669 | 1669 | * @since 2.8.1 |
| 1670 | 1670 | */ |
| 1671 | -function safecss_filter_attr( $css, $deprecated = '' ) { |
|
| 1672 | - if ( !empty( $deprecated ) ) |
|
| 1673 | - _deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented |
|
| 1671 | +function safecss_filter_attr($css, $deprecated = '') { |
|
| 1672 | + if ( ! empty($deprecated)) |
|
| 1673 | + _deprecated_argument(__FUNCTION__, '2.8.1'); // Never implemented |
|
| 1674 | 1674 | |
| 1675 | 1675 | $css = wp_kses_no_null($css); |
| 1676 | - $css = str_replace(array("\n","\r","\t"), '', $css); |
|
| 1676 | + $css = str_replace(array("\n", "\r", "\t"), '', $css); |
|
| 1677 | 1677 | |
| 1678 | - if ( preg_match( '%[\\\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments |
|
| 1678 | + if (preg_match('%[\\\\(&=}]|/\*%', $css)) // remove any inline css containing \ ( & } = or comments |
|
| 1679 | 1679 | return ''; |
| 1680 | 1680 | |
| 1681 | - $css_array = explode( ';', trim( $css ) ); |
|
| 1681 | + $css_array = explode(';', trim($css)); |
|
| 1682 | 1682 | |
| 1683 | 1683 | /** |
| 1684 | 1684 | * Filter list of allowed CSS attributes. |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | * |
| 1688 | 1688 | * @param array $attr List of allowed CSS attributes. |
| 1689 | 1689 | */ |
| 1690 | - $allowed_attr = apply_filters( 'safe_style_css', array( 'text-align', 'margin', 'color', 'float', |
|
| 1690 | + $allowed_attr = apply_filters('safe_style_css', array('text-align', 'margin', 'color', 'float', |
|
| 1691 | 1691 | 'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color', |
| 1692 | 1692 | 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left', |
| 1693 | 1693 | 'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color', |
@@ -1697,26 +1697,26 @@ discard block |
||
| 1697 | 1697 | 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom', |
| 1698 | 1698 | 'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom', |
| 1699 | 1699 | 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align', |
| 1700 | - 'width' ) ); |
|
| 1700 | + 'width')); |
|
| 1701 | 1701 | |
| 1702 | - if ( empty($allowed_attr) ) |
|
| 1702 | + if (empty($allowed_attr)) |
|
| 1703 | 1703 | return $css; |
| 1704 | 1704 | |
| 1705 | 1705 | $css = ''; |
| 1706 | - foreach ( $css_array as $css_item ) { |
|
| 1707 | - if ( $css_item == '' ) |
|
| 1706 | + foreach ($css_array as $css_item) { |
|
| 1707 | + if ($css_item == '') |
|
| 1708 | 1708 | continue; |
| 1709 | - $css_item = trim( $css_item ); |
|
| 1709 | + $css_item = trim($css_item); |
|
| 1710 | 1710 | $found = false; |
| 1711 | - if ( strpos( $css_item, ':' ) === false ) { |
|
| 1711 | + if (strpos($css_item, ':') === false) { |
|
| 1712 | 1712 | $found = true; |
| 1713 | 1713 | } else { |
| 1714 | - $parts = explode( ':', $css_item ); |
|
| 1715 | - if ( in_array( trim( $parts[0] ), $allowed_attr ) ) |
|
| 1714 | + $parts = explode(':', $css_item); |
|
| 1715 | + if (in_array(trim($parts[0]), $allowed_attr)) |
|
| 1716 | 1716 | $found = true; |
| 1717 | 1717 | } |
| 1718 | - if ( $found ) { |
|
| 1719 | - if( $css != '' ) |
|
| 1718 | + if ($found) { |
|
| 1719 | + if ($css != '') |
|
| 1720 | 1720 | $css .= ';'; |
| 1721 | 1721 | $css .= $css_item; |
| 1722 | 1722 | } |
@@ -1734,7 +1734,7 @@ discard block |
||
| 1734 | 1734 | * @param array $value An array of attributes. |
| 1735 | 1735 | * @return array The array of attributes with global attributes added. |
| 1736 | 1736 | */ |
| 1737 | -function _wp_add_global_attributes( $value ) { |
|
| 1737 | +function _wp_add_global_attributes($value) { |
|
| 1738 | 1738 | $global_attributes = array( |
| 1739 | 1739 | 'class' => true, |
| 1740 | 1740 | 'id' => true, |
@@ -1743,11 +1743,11 @@ discard block |
||
| 1743 | 1743 | 'role' => true, |
| 1744 | 1744 | ); |
| 1745 | 1745 | |
| 1746 | - if ( true === $value ) |
|
| 1746 | + if (true === $value) |
|
| 1747 | 1747 | $value = array(); |
| 1748 | 1748 | |
| 1749 | - if ( is_array( $value ) ) |
|
| 1750 | - return array_merge( $value, $global_attributes ); |
|
| 1749 | + if (is_array($value)) |
|
| 1750 | + return array_merge($value, $global_attributes); |
|
| 1751 | 1751 | |
| 1752 | 1752 | return $value; |
| 1753 | 1753 | } |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @since 1.2.0 |
| 43 | 43 | */ |
| 44 | -if ( ! defined( 'CUSTOM_TAGS' ) ) |
|
| 44 | +if ( ! defined( 'CUSTOM_TAGS' ) ) { |
|
| 45 | 45 | define( 'CUSTOM_TAGS', false ); |
| 46 | +} |
|
| 46 | 47 | |
| 47 | 48 | // Ensure that these variables are added to the global namespace |
| 48 | 49 | // (e.g. if using namespaces / autoload in the current PHP environment). |
@@ -519,8 +520,9 @@ discard block |
||
| 519 | 520 | * @return string Filtered content with only allowed HTML elements |
| 520 | 521 | */ |
| 521 | 522 | function wp_kses( $string, $allowed_html, $allowed_protocols = array() ) { |
| 522 | - if ( empty( $allowed_protocols ) ) |
|
| 523 | - $allowed_protocols = wp_allowed_protocols(); |
|
| 523 | + if ( empty( $allowed_protocols ) ) { |
|
| 524 | + $allowed_protocols = wp_allowed_protocols(); |
|
| 525 | + } |
|
| 524 | 526 | $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); |
| 525 | 527 | $string = wp_kses_js_entities($string); |
| 526 | 528 | $string = wp_kses_normalize_entities($string); |
@@ -758,16 +760,19 @@ discard block |
||
| 758 | 760 | function wp_kses_split2($string, $allowed_html, $allowed_protocols) { |
| 759 | 761 | $string = wp_kses_stripslashes($string); |
| 760 | 762 | |
| 761 | - if (substr($string, 0, 1) != '<') |
|
| 762 | - return '>'; |
|
| 763 | + if (substr($string, 0, 1) != '<') { |
|
| 764 | + return '>'; |
|
| 765 | + } |
|
| 763 | 766 | // It matched a ">" character |
| 764 | 767 | |
| 765 | 768 | if ( '<!--' == substr( $string, 0, 4 ) ) { |
| 766 | 769 | $string = str_replace( array('<!--', '-->'), '', $string ); |
| 767 | - while ( $string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols)) ) |
|
| 768 | - $string = $newstring; |
|
| 769 | - if ( $string == '' ) |
|
| 770 | - return ''; |
|
| 770 | + while ( $string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols)) ) { |
|
| 771 | + $string = $newstring; |
|
| 772 | + } |
|
| 773 | + if ( $string == '' ) { |
|
| 774 | + return ''; |
|
| 775 | + } |
|
| 771 | 776 | // prevent multiple dashes in comments |
| 772 | 777 | $string = preg_replace('/--+/', '-', $string); |
| 773 | 778 | // prevent three dashes closing a comment |
@@ -776,23 +781,27 @@ discard block |
||
| 776 | 781 | } |
| 777 | 782 | // Allow HTML comments |
| 778 | 783 | |
| 779 | - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) |
|
| 780 | - return ''; |
|
| 784 | + if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) { |
|
| 785 | + return ''; |
|
| 786 | + } |
|
| 781 | 787 | // It's seriously malformed |
| 782 | 788 | |
| 783 | 789 | $slash = trim($matches[1]); |
| 784 | 790 | $elem = $matches[2]; |
| 785 | 791 | $attrlist = $matches[3]; |
| 786 | 792 | |
| 787 | - if ( ! is_array( $allowed_html ) ) |
|
| 788 | - $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 793 | + if ( ! is_array( $allowed_html ) ) { |
|
| 794 | + $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 795 | + } |
|
| 789 | 796 | |
| 790 | - if ( ! isset($allowed_html[strtolower($elem)]) ) |
|
| 791 | - return ''; |
|
| 797 | + if ( ! isset($allowed_html[strtolower($elem)]) ) { |
|
| 798 | + return ''; |
|
| 799 | + } |
|
| 792 | 800 | // They are using a not allowed HTML element |
| 793 | 801 | |
| 794 | - if ($slash != '') |
|
| 795 | - return "</$elem>"; |
|
| 802 | + if ($slash != '') { |
|
| 803 | + return "</$elem>"; |
|
| 804 | + } |
|
| 796 | 805 | // No attributes are allowed for closing elements |
| 797 | 806 | |
| 798 | 807 | return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); |
@@ -816,17 +825,20 @@ discard block |
||
| 816 | 825 | * @return string Sanitized HTML element |
| 817 | 826 | */ |
| 818 | 827 | function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { |
| 819 | - if ( ! is_array( $allowed_html ) ) |
|
| 820 | - $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 828 | + if ( ! is_array( $allowed_html ) ) { |
|
| 829 | + $allowed_html = wp_kses_allowed_html( $allowed_html ); |
|
| 830 | + } |
|
| 821 | 831 | |
| 822 | 832 | // Is there a closing XHTML slash at the end of the attributes? |
| 823 | 833 | $xhtml_slash = ''; |
| 824 | - if (preg_match('%\s*/\s*$%', $attr)) |
|
| 825 | - $xhtml_slash = ' /'; |
|
| 834 | + if (preg_match('%\s*/\s*$%', $attr)) { |
|
| 835 | + $xhtml_slash = ' /'; |
|
| 836 | + } |
|
| 826 | 837 | |
| 827 | 838 | // Are any attributes allowed at all for this element? |
| 828 | - if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 ) |
|
| 829 | - return "<$element$xhtml_slash>"; |
|
| 839 | + if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 ) { |
|
| 840 | + return "<$element$xhtml_slash>"; |
|
| 841 | + } |
|
| 830 | 842 | |
| 831 | 843 | // Split it |
| 832 | 844 | $attrarr = wp_kses_hair($attr, $allowed_protocols); |
@@ -934,17 +946,21 @@ discard block |
||
| 934 | 946 | |
| 935 | 947 | case 1 : // equals sign or valueless ("selected") |
| 936 | 948 | |
| 937 | - if (preg_match('/^\s*=\s*/', $attr)) // equals sign |
|
| 949 | + if (preg_match('/^\s*=\s*/', $attr)) { |
|
| 950 | + // equals sign |
|
| 938 | 951 | { |
| 939 | 952 | $working = 1; |
| 953 | + } |
|
| 940 | 954 | $mode = 2; |
| 941 | 955 | $attr = preg_replace('/^\s*=\s*/', '', $attr); |
| 942 | 956 | break; |
| 943 | 957 | } |
| 944 | 958 | |
| 945 | - if (preg_match('/^\s+/', $attr)) // valueless |
|
| 959 | + if (preg_match('/^\s+/', $attr)) { |
|
| 960 | + // valueless |
|
| 946 | 961 | { |
| 947 | 962 | $working = 1; |
| 963 | + } |
|
| 948 | 964 | $mode = 0; |
| 949 | 965 | if(false === array_key_exists($attrname, $attrarr)) { |
| 950 | 966 | $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
@@ -956,12 +972,14 @@ discard block |
||
| 956 | 972 | |
| 957 | 973 | case 2 : // attribute value, a URL after href= for instance |
| 958 | 974 | |
| 959 | - if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match)) |
|
| 960 | - // "value" |
|
| 975 | + if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match)) { |
|
| 976 | + // "value" |
|
| 961 | 977 | { |
| 962 | 978 | $thisval = $match[1]; |
| 963 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 964 | - $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 979 | + } |
|
| 980 | + if ( in_array(strtolower($attrname), $uris) ) { |
|
| 981 | + $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 982 | + } |
|
| 965 | 983 | |
| 966 | 984 | if(false === array_key_exists($attrname, $attrarr)) { |
| 967 | 985 | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
@@ -972,12 +990,14 @@ discard block |
||
| 972 | 990 | break; |
| 973 | 991 | } |
| 974 | 992 | |
| 975 | - if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match)) |
|
| 976 | - // 'value' |
|
| 993 | + if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match)) { |
|
| 994 | + // 'value' |
|
| 977 | 995 | { |
| 978 | 996 | $thisval = $match[1]; |
| 979 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 980 | - $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 997 | + } |
|
| 998 | + if ( in_array(strtolower($attrname), $uris) ) { |
|
| 999 | + $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 1000 | + } |
|
| 981 | 1001 | |
| 982 | 1002 | if(false === array_key_exists($attrname, $attrarr)) { |
| 983 | 1003 | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
@@ -988,12 +1008,14 @@ discard block |
||
| 988 | 1008 | break; |
| 989 | 1009 | } |
| 990 | 1010 | |
| 991 | - if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match)) |
|
| 992 | - // value |
|
| 1011 | + if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match)) { |
|
| 1012 | + // value |
|
| 993 | 1013 | { |
| 994 | 1014 | $thisval = $match[1]; |
| 995 | - if ( in_array(strtolower($attrname), $uris) ) |
|
| 996 | - $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 1015 | + } |
|
| 1016 | + if ( in_array(strtolower($attrname), $uris) ) { |
|
| 1017 | + $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
|
| 1018 | + } |
|
| 997 | 1019 | |
| 998 | 1020 | if(false === array_key_exists($attrname, $attrarr)) { |
| 999 | 1021 | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
@@ -1007,17 +1029,20 @@ discard block |
||
| 1007 | 1029 | break; |
| 1008 | 1030 | } // switch |
| 1009 | 1031 | |
| 1010 | - if ($working == 0) // not well formed, remove and try again |
|
| 1032 | + if ($working == 0) { |
|
| 1033 | + // not well formed, remove and try again |
|
| 1011 | 1034 | { |
| 1012 | 1035 | $attr = wp_kses_html_error($attr); |
| 1036 | + } |
|
| 1013 | 1037 | $mode = 0; |
| 1014 | 1038 | } |
| 1015 | 1039 | } // while |
| 1016 | 1040 | |
| 1017 | - if ($mode == 1 && false === array_key_exists($attrname, $attrarr)) |
|
| 1018 | - // special case, for when the attribute list ends with a valueless |
|
| 1041 | + if ($mode == 1 && false === array_key_exists($attrname, $attrarr)) { |
|
| 1042 | + // special case, for when the attribute list ends with a valueless |
|
| 1019 | 1043 | // attribute like "selected" |
| 1020 | 1044 | $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
| 1045 | + } |
|
| 1021 | 1046 | |
| 1022 | 1047 | return $attrarr; |
| 1023 | 1048 | } |
@@ -1148,16 +1173,18 @@ discard block |
||
| 1148 | 1173 | // greater than the given value. This can be used to avoid Buffer Overflows |
| 1149 | 1174 | // in WWW clients and various Internet servers. |
| 1150 | 1175 | |
| 1151 | - if (strlen($value) > $checkvalue) |
|
| 1152 | - $ok = false; |
|
| 1176 | + if (strlen($value) > $checkvalue) { |
|
| 1177 | + $ok = false; |
|
| 1178 | + } |
|
| 1153 | 1179 | break; |
| 1154 | 1180 | |
| 1155 | 1181 | case 'minlen' : |
| 1156 | 1182 | // The minlen check makes sure that the attribute value has a length not |
| 1157 | 1183 | // smaller than the given value. |
| 1158 | 1184 | |
| 1159 | - if (strlen($value) < $checkvalue) |
|
| 1160 | - $ok = false; |
|
| 1185 | + if (strlen($value) < $checkvalue) { |
|
| 1186 | + $ok = false; |
|
| 1187 | + } |
|
| 1161 | 1188 | break; |
| 1162 | 1189 | |
| 1163 | 1190 | case 'maxval' : |
@@ -1167,20 +1194,24 @@ discard block |
||
| 1167 | 1194 | // value is not greater than the given value. |
| 1168 | 1195 | // This check can be used to avoid Denial of Service attacks. |
| 1169 | 1196 | |
| 1170 | - if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1171 | - $ok = false; |
|
| 1172 | - if ($value > $checkvalue) |
|
| 1173 | - $ok = false; |
|
| 1197 | + if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) { |
|
| 1198 | + $ok = false; |
|
| 1199 | + } |
|
| 1200 | + if ($value > $checkvalue) { |
|
| 1201 | + $ok = false; |
|
| 1202 | + } |
|
| 1174 | 1203 | break; |
| 1175 | 1204 | |
| 1176 | 1205 | case 'minval' : |
| 1177 | 1206 | // The minval check makes sure that the attribute value is a positive integer, |
| 1178 | 1207 | // and that it is not smaller than the given value. |
| 1179 | 1208 | |
| 1180 | - if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
|
| 1181 | - $ok = false; |
|
| 1182 | - if ($value < $checkvalue) |
|
| 1183 | - $ok = false; |
|
| 1209 | + if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) { |
|
| 1210 | + $ok = false; |
|
| 1211 | + } |
|
| 1212 | + if ($value < $checkvalue) { |
|
| 1213 | + $ok = false; |
|
| 1214 | + } |
|
| 1184 | 1215 | break; |
| 1185 | 1216 | |
| 1186 | 1217 | case 'valueless' : |
@@ -1189,8 +1220,9 @@ discard block |
||
| 1189 | 1220 | // is a "y" or a "Y", the attribute must not have a value. |
| 1190 | 1221 | // If the given value is an "n" or an "N", the attribute must have one. |
| 1191 | 1222 | |
| 1192 | - if (strtolower($checkvalue) != $vless) |
|
| 1193 | - $ok = false; |
|
| 1223 | + if (strtolower($checkvalue) != $vless) { |
|
| 1224 | + $ok = false; |
|
| 1225 | + } |
|
| 1194 | 1226 | break; |
| 1195 | 1227 | } // switch |
| 1196 | 1228 | |
@@ -1220,8 +1252,9 @@ discard block |
||
| 1220 | 1252 | $string = wp_kses_bad_protocol_once($string, $allowed_protocols); |
| 1221 | 1253 | } while ( $original_string != $string && ++$iterations < 6 ); |
| 1222 | 1254 | |
| 1223 | - if ( $original_string != $string ) |
|
| 1224 | - return ''; |
|
| 1255 | + if ( $original_string != $string ) { |
|
| 1256 | + return ''; |
|
| 1257 | + } |
|
| 1225 | 1258 | |
| 1226 | 1259 | return $string; |
| 1227 | 1260 | } |
@@ -1335,11 +1368,13 @@ discard block |
||
| 1335 | 1368 | $string = trim( $string2[1] ); |
| 1336 | 1369 | $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); |
| 1337 | 1370 | if ( 'feed:' == $protocol ) { |
| 1338 | - if ( $count > 2 ) |
|
| 1339 | - return ''; |
|
| 1371 | + if ( $count > 2 ) { |
|
| 1372 | + return ''; |
|
| 1373 | + } |
|
| 1340 | 1374 | $string = wp_kses_bad_protocol_once( $string, $allowed_protocols, ++$count ); |
| 1341 | - if ( empty( $string ) ) |
|
| 1342 | - return $string; |
|
| 1375 | + if ( empty( $string ) ) { |
|
| 1376 | + return $string; |
|
| 1377 | + } |
|
| 1343 | 1378 | } |
| 1344 | 1379 | $string = $protocol . $string; |
| 1345 | 1380 | } |
@@ -1367,17 +1402,19 @@ discard block |
||
| 1367 | 1402 | $string2 = strtolower($string2); |
| 1368 | 1403 | |
| 1369 | 1404 | $allowed = false; |
| 1370 | - foreach ( (array) $allowed_protocols as $one_protocol ) |
|
| 1371 | - if ( strtolower($one_protocol) == $string2 ) { |
|
| 1405 | + foreach ( (array) $allowed_protocols as $one_protocol ) { |
|
| 1406 | + if ( strtolower($one_protocol) == $string2 ) { |
|
| 1372 | 1407 | $allowed = true; |
| 1408 | + } |
|
| 1373 | 1409 | break; |
| 1374 | 1410 | } |
| 1375 | 1411 | |
| 1376 | - if ($allowed) |
|
| 1377 | - return "$string2:"; |
|
| 1378 | - else |
|
| 1379 | - return ''; |
|
| 1380 | -} |
|
| 1412 | + if ($allowed) { |
|
| 1413 | + return "$string2:"; |
|
| 1414 | + } else { |
|
| 1415 | + return ''; |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1381 | 1418 | |
| 1382 | 1419 | /** |
| 1383 | 1420 | * Converts and fixes HTML entities. |
@@ -1418,8 +1455,9 @@ discard block |
||
| 1418 | 1455 | function wp_kses_named_entities($matches) { |
| 1419 | 1456 | global $allowedentitynames; |
| 1420 | 1457 | |
| 1421 | - if ( empty($matches[1]) ) |
|
| 1422 | - return ''; |
|
| 1458 | + if ( empty($matches[1]) ) { |
|
| 1459 | + return ''; |
|
| 1460 | + } |
|
| 1423 | 1461 | |
| 1424 | 1462 | $i = $matches[1]; |
| 1425 | 1463 | return ( ! in_array( $i, $allowedentitynames ) ) ? "&$i;" : "&$i;"; |
@@ -1438,8 +1476,9 @@ discard block |
||
| 1438 | 1476 | * @return string Correctly encoded entity |
| 1439 | 1477 | */ |
| 1440 | 1478 | function wp_kses_normalize_entities2($matches) { |
| 1441 | - if ( empty($matches[1]) ) |
|
| 1442 | - return ''; |
|
| 1479 | + if ( empty($matches[1]) ) { |
|
| 1480 | + return ''; |
|
| 1481 | + } |
|
| 1443 | 1482 | |
| 1444 | 1483 | $i = $matches[1]; |
| 1445 | 1484 | if (valid_unicode($i)) { |
@@ -1464,8 +1503,9 @@ discard block |
||
| 1464 | 1503 | * @return string Correctly encoded entity |
| 1465 | 1504 | */ |
| 1466 | 1505 | function wp_kses_normalize_entities3($matches) { |
| 1467 | - if ( empty($matches[1]) ) |
|
| 1468 | - return ''; |
|
| 1506 | + if ( empty($matches[1]) ) { |
|
| 1507 | + return ''; |
|
| 1508 | + } |
|
| 1469 | 1509 | |
| 1470 | 1510 | $hexchars = $matches[1]; |
| 1471 | 1511 | return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';'; |
@@ -1605,10 +1645,11 @@ discard block |
||
| 1605 | 1645 | add_filter('title_save_pre', 'wp_filter_kses'); |
| 1606 | 1646 | |
| 1607 | 1647 | // Comment filtering |
| 1608 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 1609 | - add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); |
|
| 1610 | - else |
|
| 1611 | - add_filter( 'pre_comment_content', 'wp_filter_kses' ); |
|
| 1648 | + if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 1649 | + add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); |
|
| 1650 | + } else { |
|
| 1651 | + add_filter( 'pre_comment_content', 'wp_filter_kses' ); |
|
| 1652 | + } |
|
| 1612 | 1653 | |
| 1613 | 1654 | // Post filtering |
| 1614 | 1655 | add_filter('content_save_pre', 'wp_filter_post_kses'); |
@@ -1669,14 +1710,18 @@ discard block |
||
| 1669 | 1710 | * @since 2.8.1 |
| 1670 | 1711 | */ |
| 1671 | 1712 | function safecss_filter_attr( $css, $deprecated = '' ) { |
| 1672 | - if ( !empty( $deprecated ) ) |
|
| 1673 | - _deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented |
|
| 1713 | + if ( !empty( $deprecated ) ) { |
|
| 1714 | + _deprecated_argument( __FUNCTION__, '2.8.1' ); |
|
| 1715 | + } |
|
| 1716 | + // Never implemented |
|
| 1674 | 1717 | |
| 1675 | 1718 | $css = wp_kses_no_null($css); |
| 1676 | 1719 | $css = str_replace(array("\n","\r","\t"), '', $css); |
| 1677 | 1720 | |
| 1678 | - if ( preg_match( '%[\\\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments |
|
| 1721 | + if ( preg_match( '%[\\\\(&=}]|/\*%', $css ) ) { |
|
| 1722 | + // remove any inline css containing \ ( & } = or comments |
|
| 1679 | 1723 | return ''; |
| 1724 | + } |
|
| 1680 | 1725 | |
| 1681 | 1726 | $css_array = explode( ';', trim( $css ) ); |
| 1682 | 1727 | |
@@ -1699,25 +1744,29 @@ discard block |
||
| 1699 | 1744 | 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align', |
| 1700 | 1745 | 'width' ) ); |
| 1701 | 1746 | |
| 1702 | - if ( empty($allowed_attr) ) |
|
| 1703 | - return $css; |
|
| 1747 | + if ( empty($allowed_attr) ) { |
|
| 1748 | + return $css; |
|
| 1749 | + } |
|
| 1704 | 1750 | |
| 1705 | 1751 | $css = ''; |
| 1706 | 1752 | foreach ( $css_array as $css_item ) { |
| 1707 | - if ( $css_item == '' ) |
|
| 1708 | - continue; |
|
| 1753 | + if ( $css_item == '' ) { |
|
| 1754 | + continue; |
|
| 1755 | + } |
|
| 1709 | 1756 | $css_item = trim( $css_item ); |
| 1710 | 1757 | $found = false; |
| 1711 | 1758 | if ( strpos( $css_item, ':' ) === false ) { |
| 1712 | 1759 | $found = true; |
| 1713 | 1760 | } else { |
| 1714 | 1761 | $parts = explode( ':', $css_item ); |
| 1715 | - if ( in_array( trim( $parts[0] ), $allowed_attr ) ) |
|
| 1716 | - $found = true; |
|
| 1762 | + if ( in_array( trim( $parts[0] ), $allowed_attr ) ) { |
|
| 1763 | + $found = true; |
|
| 1764 | + } |
|
| 1717 | 1765 | } |
| 1718 | 1766 | if ( $found ) { |
| 1719 | - if( $css != '' ) |
|
| 1720 | - $css .= ';'; |
|
| 1767 | + if( $css != '' ) { |
|
| 1768 | + $css .= ';'; |
|
| 1769 | + } |
|
| 1721 | 1770 | $css .= $css_item; |
| 1722 | 1771 | } |
| 1723 | 1772 | } |
@@ -1743,11 +1792,13 @@ discard block |
||
| 1743 | 1792 | 'role' => true, |
| 1744 | 1793 | ); |
| 1745 | 1794 | |
| 1746 | - if ( true === $value ) |
|
| 1747 | - $value = array(); |
|
| 1795 | + if ( true === $value ) { |
|
| 1796 | + $value = array(); |
|
| 1797 | + } |
|
| 1748 | 1798 | |
| 1749 | - if ( is_array( $value ) ) |
|
| 1750 | - return array_merge( $value, $global_attributes ); |
|
| 1799 | + if ( is_array( $value ) ) { |
|
| 1800 | + return array_merge( $value, $global_attributes ); |
|
| 1801 | + } |
|
| 1751 | 1802 | |
| 1752 | 1803 | return $value; |
| 1753 | 1804 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @see get_permalink() |
| 93 | 93 | * |
| 94 | - * @param int|WP_Post $id Optional. Post ID or post object. Default is the current post. |
|
| 94 | + * @param integer $id Optional. Post ID or post object. Default is the current post. |
|
| 95 | 95 | * @param bool $leavename Optional. Whether to keep post name or page name. Default false. |
| 96 | 96 | * @return string|false The permalink URL or false if post does not exist. |
| 97 | 97 | */ |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @since 1.0.0 |
| 106 | 106 | * |
| 107 | - * @param int|WP_Post $id Optional. Post ID or post object. Default current post. |
|
| 107 | + * @param integer $id Optional. Post ID or post object. Default current post. |
|
| 108 | 108 | * @param bool $leavename Optional. Whether to keep post name or page name. Default false. |
| 109 | 109 | * @return string|false The permalink URL or false if post does not exist. |
| 110 | 110 | */ |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * |
| 1348 | 1348 | * @since 2.7.0 |
| 1349 | 1349 | * |
| 1350 | - * @param int|stdClass $link Optional. Bookmark ID. |
|
| 1350 | + * @param integer $link Optional. Bookmark ID. |
|
| 1351 | 1351 | * @return string|void The edit bookmark link URL. |
| 1352 | 1352 | */ |
| 1353 | 1353 | function get_edit_bookmark_link( $link = 0 ) { |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @since 1.5.0 |
| 1446 | 1446 | * |
| 1447 | 1447 | * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. |
| 1448 | - * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1448 | + * @param string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1449 | 1449 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1450 | 1450 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
| 1451 | 1451 | */ |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | * @since 1.5.0 |
| 1460 | 1460 | * |
| 1461 | 1461 | * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. |
| 1462 | - * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1462 | + * @param string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1463 | 1463 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1464 | 1464 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
| 1465 | 1465 | */ |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
| 1481 | 1481 | * @param bool $previous Optional. Whether to retrieve previous post. |
| 1482 | 1482 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1483 | - * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
|
| 1483 | + * @return integer Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
|
| 1484 | 1484 | */ |
| 1485 | 1485 | function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1486 | 1486 | global $wpdb; |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | * @since 2.8.0 |
| 1743 | 1743 | * |
| 1744 | 1744 | * @param bool $in_same_term Optional. Whether returned post should be in a same taxonomy term. |
| 1745 | - * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1745 | + * @param string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
|
| 1746 | 1746 | * @param bool $start Optional. Whether to retrieve first or last post. |
| 1747 | 1747 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1748 | 1748 | * @return null|array Array containing the boundary post object if successful, null otherwise. |
@@ -2707,7 +2707,7 @@ discard block |
||
| 2707 | 2707 | * |
| 2708 | 2708 | * @param int $blog_id Optional. Blog ID. Default null (current blog). |
| 2709 | 2709 | * @param string $path Optional. Path relative to the home URL. Default empty. |
| 2710 | - * @param string|null $orig_scheme Optional. Scheme to give the home URL context. Accepts |
|
| 2710 | + * @param string $scheme Optional. Scheme to give the home URL context. Accepts |
|
| 2711 | 2711 | * 'http', 'https', 'relative', or null. Default null. |
| 2712 | 2712 | * @return string Home URL link with optional path appended. |
| 2713 | 2713 | */ |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Link Template Functions |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Template |
|
| 7 | - */ |
|
| 3 | + * WordPress Link Template Functions |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Template |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Display the permalink for the current post. |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param string $permalink The permalink for the current post. |
| 21 | 21 | */ |
| 22 | - echo esc_url( apply_filters( 'the_permalink', get_permalink() ) ); |
|
| 22 | + echo esc_url(apply_filters('the_permalink', get_permalink())); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function user_trailingslashit($string, $type_of_url = '') { |
| 41 | 41 | global $wp_rewrite; |
| 42 | - if ( $wp_rewrite->use_trailing_slashes ) |
|
| 42 | + if ($wp_rewrite->use_trailing_slashes) |
|
| 43 | 43 | $string = trailingslashit($string); |
| 44 | 44 | else |
| 45 | 45 | $string = untrailingslashit($string); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * 'single_feed', 'single_paged', 'feed', 'category', 'page', 'year', |
| 56 | 56 | * 'month', 'day', 'paged', 'post_type_archive'. |
| 57 | 57 | */ |
| 58 | - return apply_filters( 'user_trailingslashit', $string, $type_of_url ); |
|
| 58 | + return apply_filters('user_trailingslashit', $string, $type_of_url); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'. |
| 70 | 70 | */ |
| 71 | -function permalink_anchor( $mode = 'id' ) { |
|
| 71 | +function permalink_anchor($mode = 'id') { |
|
| 72 | 72 | $post = get_post(); |
| 73 | - switch ( strtolower( $mode ) ) { |
|
| 73 | + switch (strtolower($mode)) { |
|
| 74 | 74 | case 'title': |
| 75 | - $title = sanitize_title( $post->post_title ) . '-' . $post->ID; |
|
| 75 | + $title = sanitize_title($post->post_title).'-'.$post->ID; |
|
| 76 | 76 | echo '<a id="'.$title.'"></a>'; |
| 77 | 77 | break; |
| 78 | 78 | case 'id': |
| 79 | 79 | default: |
| 80 | - echo '<a id="post-' . $post->ID . '"></a>'; |
|
| 80 | + echo '<a id="post-'.$post->ID.'"></a>'; |
|
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | * @param bool $leavename Optional. Whether to keep post name or page name. Default false. |
| 96 | 96 | * @return string|false The permalink URL or false if post does not exist. |
| 97 | 97 | */ |
| 98 | -function get_the_permalink( $id = 0, $leavename = false ) { |
|
| 99 | - return get_permalink( $id, $leavename ); |
|
| 98 | +function get_the_permalink($id = 0, $leavename = false) { |
|
| 99 | + return get_permalink($id, $leavename); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param bool $leavename Optional. Whether to keep post name or page name. Default false. |
| 109 | 109 | * @return string|false The permalink URL or false if post does not exist. |
| 110 | 110 | */ |
| 111 | -function get_permalink( $id = 0, $leavename = false ) { |
|
| 111 | +function get_permalink($id = 0, $leavename = false) { |
|
| 112 | 112 | $rewritecode = array( |
| 113 | 113 | '%year%', |
| 114 | 114 | '%monthnum%', |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | '%hour%', |
| 117 | 117 | '%minute%', |
| 118 | 118 | '%second%', |
| 119 | - $leavename? '' : '%postname%', |
|
| 119 | + $leavename ? '' : '%postname%', |
|
| 120 | 120 | '%post_id%', |
| 121 | 121 | '%category%', |
| 122 | 122 | '%author%', |
| 123 | - $leavename? '' : '%pagename%', |
|
| 123 | + $leavename ? '' : '%pagename%', |
|
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) { |
|
| 126 | + if (is_object($id) && isset($id->filter) && 'sample' == $id->filter) { |
|
| 127 | 127 | $post = $id; |
| 128 | 128 | $sample = true; |
| 129 | 129 | } else { |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $sample = false; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( empty($post->ID) ) |
|
| 134 | + if (empty($post->ID)) |
|
| 135 | 135 | return false; |
| 136 | 136 | |
| 137 | - if ( $post->post_type == 'page' ) |
|
| 137 | + if ($post->post_type == 'page') |
|
| 138 | 138 | return get_page_link($post, $leavename, $sample); |
| 139 | - elseif ( $post->post_type == 'attachment' ) |
|
| 140 | - return get_attachment_link( $post, $leavename ); |
|
| 141 | - elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) |
|
| 139 | + elseif ($post->post_type == 'attachment') |
|
| 140 | + return get_attachment_link($post, $leavename); |
|
| 141 | + elseif (in_array($post->post_type, get_post_types(array('_builtin' => false)))) |
|
| 142 | 142 | return get_post_permalink($post, $leavename, $sample); |
| 143 | 143 | |
| 144 | 144 | $permalink = get_option('permalink_structure'); |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | * @param WP_Post $post The post in question. |
| 155 | 155 | * @param bool $leavename Whether to keep the post name. |
| 156 | 156 | */ |
| 157 | - $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); |
|
| 157 | + $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); |
|
| 158 | 158 | |
| 159 | - if ( '' != $permalink && !in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) { |
|
| 159 | + if ('' != $permalink && ! in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future'))) { |
|
| 160 | 160 | $unixtime = strtotime($post->post_date); |
| 161 | 161 | |
| 162 | 162 | $category = ''; |
| 163 | - if ( strpos($permalink, '%category%') !== false ) { |
|
| 163 | + if (strpos($permalink, '%category%') !== false) { |
|
| 164 | 164 | $cats = get_the_category($post->ID); |
| 165 | - if ( $cats ) { |
|
| 165 | + if ($cats) { |
|
| 166 | 166 | usort($cats, '_usort_terms_by_ID'); // order by ID |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -174,28 +174,28 @@ discard block |
||
| 174 | 174 | * @param array $cats Array of all categories associated with the post. |
| 175 | 175 | * @param WP_Post $post The post in question. |
| 176 | 176 | */ |
| 177 | - $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); |
|
| 177 | + $category_object = apply_filters('post_link_category', $cats[0], $cats, $post); |
|
| 178 | 178 | |
| 179 | - $category_object = get_term( $category_object, 'category' ); |
|
| 179 | + $category_object = get_term($category_object, 'category'); |
|
| 180 | 180 | $category = $category_object->slug; |
| 181 | - if ( $parent = $category_object->parent ) |
|
| 182 | - $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 181 | + if ($parent = $category_object->parent) |
|
| 182 | + $category = get_category_parents($parent, false, '/', true).$category; |
|
| 183 | 183 | } |
| 184 | 184 | // show default category in permalinks, without |
| 185 | 185 | // having to assign it explicitly |
| 186 | - if ( empty($category) ) { |
|
| 187 | - $default_category = get_term( get_option( 'default_category' ), 'category' ); |
|
| 188 | - $category = is_wp_error( $default_category ) ? '' : $default_category->slug; |
|
| 186 | + if (empty($category)) { |
|
| 187 | + $default_category = get_term(get_option('default_category'), 'category'); |
|
| 188 | + $category = is_wp_error($default_category) ? '' : $default_category->slug; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $author = ''; |
| 193 | - if ( strpos($permalink, '%author%') !== false ) { |
|
| 193 | + if (strpos($permalink, '%author%') !== false) { |
|
| 194 | 194 | $authordata = get_userdata($post->post_author); |
| 195 | 195 | $author = $authordata->user_nicename; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $date = explode(" ",date('Y m d H i s', $unixtime)); |
|
| 198 | + $date = explode(" ", date('Y m d H i s', $unixtime)); |
|
| 199 | 199 | $rewritereplace = |
| 200 | 200 | array( |
| 201 | 201 | $date[0], |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | $author, |
| 211 | 211 | $post->post_name, |
| 212 | 212 | ); |
| 213 | - $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) ); |
|
| 213 | + $permalink = home_url(str_replace($rewritecode, $rewritereplace, $permalink)); |
|
| 214 | 214 | $permalink = user_trailingslashit($permalink, 'single'); |
| 215 | 215 | } else { // if they're not using the fancy permalink option |
| 216 | - $permalink = home_url('?p=' . $post->ID); |
|
| 216 | + $permalink = home_url('?p='.$post->ID); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param WP_Post $post The post in question. |
| 228 | 228 | * @param bool $leavename Whether to keep the post name. |
| 229 | 229 | */ |
| 230 | - return apply_filters( 'post_link', $permalink, $post, $leavename ); |
|
| 230 | + return apply_filters('post_link', $permalink, $post, $leavename); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -242,33 +242,33 @@ discard block |
||
| 242 | 242 | * @param bool $sample Optional, defaults to false. Is it a sample permalink. |
| 243 | 243 | * @return string|WP_Error The post permalink. |
| 244 | 244 | */ |
| 245 | -function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { |
|
| 245 | +function get_post_permalink($id = 0, $leavename = false, $sample = false) { |
|
| 246 | 246 | global $wp_rewrite; |
| 247 | 247 | |
| 248 | 248 | $post = get_post($id); |
| 249 | 249 | |
| 250 | - if ( is_wp_error( $post ) ) |
|
| 250 | + if (is_wp_error($post)) |
|
| 251 | 251 | return $post; |
| 252 | 252 | |
| 253 | 253 | $post_link = $wp_rewrite->get_extra_permastruct($post->post_type); |
| 254 | 254 | |
| 255 | 255 | $slug = $post->post_name; |
| 256 | 256 | |
| 257 | - $draft_or_pending = isset( $post->post_status ) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ); |
|
| 257 | + $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future')); |
|
| 258 | 258 | |
| 259 | 259 | $post_type = get_post_type_object($post->post_type); |
| 260 | 260 | |
| 261 | - if ( $post_type->hierarchical ) { |
|
| 262 | - $slug = get_page_uri( $id ); |
|
| 261 | + if ($post_type->hierarchical) { |
|
| 262 | + $slug = get_page_uri($id); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) { |
|
| 266 | - if ( ! $leavename ) { |
|
| 265 | + if ( ! empty($post_link) && ( ! $draft_or_pending || $sample)) { |
|
| 266 | + if ( ! $leavename) { |
|
| 267 | 267 | $post_link = str_replace("%$post->post_type%", $slug, $post_link); |
| 268 | 268 | } |
| 269 | - $post_link = home_url( user_trailingslashit($post_link) ); |
|
| 269 | + $post_link = home_url(user_trailingslashit($post_link)); |
|
| 270 | 270 | } else { |
| 271 | - if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) |
|
| 271 | + if ($post_type->query_var && (isset($post->post_status) && ! $draft_or_pending)) |
|
| 272 | 272 | $post_link = add_query_arg($post_type->query_var, $slug, ''); |
| 273 | 273 | else |
| 274 | 274 | $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param bool $leavename Whether to keep the post name. |
| 286 | 286 | * @param bool $sample Is it a sample permalink. |
| 287 | 287 | */ |
| 288 | - return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample ); |
|
| 288 | + return apply_filters('post_type_link', $post_link, $post, $leavename, $sample); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | * @param bool $sample Optional, defaults to false. Is it a sample permalink. |
| 301 | 301 | * @return string The page permalink. |
| 302 | 302 | */ |
| 303 | -function get_page_link( $post = false, $leavename = false, $sample = false ) { |
|
| 304 | - $post = get_post( $post ); |
|
| 303 | +function get_page_link($post = false, $leavename = false, $sample = false) { |
|
| 304 | + $post = get_post($post); |
|
| 305 | 305 | |
| 306 | - if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) |
|
| 306 | + if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) |
|
| 307 | 307 | $link = home_url('/'); |
| 308 | 308 | else |
| 309 | - $link = _get_page_link( $post, $leavename, $sample ); |
|
| 309 | + $link = _get_page_link($post, $leavename, $sample); |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * Filter the permalink for a page. |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @param int $post_id The ID of the page. |
| 318 | 318 | * @param bool $sample Is it a sample permalink. |
| 319 | 319 | */ |
| 320 | - return apply_filters( 'page_link', $link, $post->ID, $sample ); |
|
| 320 | + return apply_filters('page_link', $link, $post->ID, $sample); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -335,24 +335,24 @@ discard block |
||
| 335 | 335 | * @param bool $sample Optional. Sample permalink. |
| 336 | 336 | * @return string The page permalink. |
| 337 | 337 | */ |
| 338 | -function _get_page_link( $post = false, $leavename = false, $sample = false ) { |
|
| 338 | +function _get_page_link($post = false, $leavename = false, $sample = false) { |
|
| 339 | 339 | global $wp_rewrite; |
| 340 | 340 | |
| 341 | - $post = get_post( $post ); |
|
| 341 | + $post = get_post($post); |
|
| 342 | 342 | |
| 343 | - $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); |
|
| 343 | + $draft_or_pending = in_array($post->post_status, array('draft', 'pending', 'auto-draft')); |
|
| 344 | 344 | |
| 345 | 345 | $link = $wp_rewrite->get_page_permastruct(); |
| 346 | 346 | |
| 347 | - if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { |
|
| 348 | - if ( ! $leavename ) { |
|
| 349 | - $link = str_replace('%pagename%', get_page_uri( $post ), $link); |
|
| 347 | + if ( ! empty($link) && ((isset($post->post_status) && ! $draft_or_pending) || $sample)) { |
|
| 348 | + if ( ! $leavename) { |
|
| 349 | + $link = str_replace('%pagename%', get_page_uri($post), $link); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $link = home_url($link); |
| 353 | 353 | $link = user_trailingslashit($link, 'page'); |
| 354 | 354 | } else { |
| 355 | - $link = home_url( '?page_id=' . $post->ID ); |
|
| 355 | + $link = home_url('?page_id='.$post->ID); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param string $link The page's permalink. |
| 364 | 364 | * @param int $post_id The ID of the page. |
| 365 | 365 | */ |
| 366 | - return apply_filters( '_get_page_link', $link, $post->ID ); |
|
| 366 | + return apply_filters('_get_page_link', $link, $post->ID); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -379,34 +379,34 @@ discard block |
||
| 379 | 379 | * @param bool $leavename Optional. Leave name. |
| 380 | 380 | * @return string The attachment permalink. |
| 381 | 381 | */ |
| 382 | -function get_attachment_link( $post = null, $leavename = false ) { |
|
| 382 | +function get_attachment_link($post = null, $leavename = false) { |
|
| 383 | 383 | global $wp_rewrite; |
| 384 | 384 | |
| 385 | 385 | $link = false; |
| 386 | 386 | |
| 387 | - $post = get_post( $post ); |
|
| 388 | - $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false; |
|
| 387 | + $post = get_post($post); |
|
| 388 | + $parent = ($post->post_parent > 0 && $post->post_parent != $post->ID) ? get_post($post->post_parent) : false; |
|
| 389 | 389 | |
| 390 | - if ( $wp_rewrite->using_permalinks() && $parent ) { |
|
| 391 | - if ( 'page' == $parent->post_type ) |
|
| 392 | - $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front |
|
| 390 | + if ($wp_rewrite->using_permalinks() && $parent) { |
|
| 391 | + if ('page' == $parent->post_type) |
|
| 392 | + $parentlink = _get_page_link($post->post_parent); // Ignores page_on_front |
|
| 393 | 393 | else |
| 394 | - $parentlink = get_permalink( $post->post_parent ); |
|
| 394 | + $parentlink = get_permalink($post->post_parent); |
|
| 395 | 395 | |
| 396 | - if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) |
|
| 397 | - $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 396 | + if (is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%')) |
|
| 397 | + $name = 'attachment/'.$post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 398 | 398 | else |
| 399 | 399 | $name = $post->post_name; |
| 400 | 400 | |
| 401 | - if ( strpos($parentlink, '?') === false ) |
|
| 402 | - $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 401 | + if (strpos($parentlink, '?') === false) |
|
| 402 | + $link = user_trailingslashit(trailingslashit($parentlink).'%postname%'); |
|
| 403 | 403 | |
| 404 | - if ( ! $leavename ) |
|
| 405 | - $link = str_replace( '%postname%', $name, $link ); |
|
| 404 | + if ( ! $leavename) |
|
| 405 | + $link = str_replace('%postname%', $name, $link); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if ( ! $link ) |
|
| 409 | - $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 408 | + if ( ! $link) |
|
| 409 | + $link = home_url('/?attachment_id='.$post->ID); |
|
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | 412 | * Filter the permalink for an attachment. |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | * @param string $link The attachment's permalink. |
| 417 | 417 | * @param int $post_id Attachment ID. |
| 418 | 418 | */ |
| 419 | - return apply_filters( 'attachment_link', $link, $post->ID ); |
|
| 419 | + return apply_filters('attachment_link', $link, $post->ID); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -431,14 +431,14 @@ discard block |
||
| 431 | 431 | */ |
| 432 | 432 | function get_year_link($year) { |
| 433 | 433 | global $wp_rewrite; |
| 434 | - if ( !$year ) |
|
| 434 | + if ( ! $year) |
|
| 435 | 435 | $year = gmdate('Y', current_time('timestamp')); |
| 436 | 436 | $yearlink = $wp_rewrite->get_year_permastruct(); |
| 437 | - if ( !empty($yearlink) ) { |
|
| 437 | + if ( ! empty($yearlink)) { |
|
| 438 | 438 | $yearlink = str_replace('%year%', $year, $yearlink); |
| 439 | - $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); |
|
| 439 | + $yearlink = home_url(user_trailingslashit($yearlink, 'year')); |
|
| 440 | 440 | } else { |
| 441 | - $yearlink = home_url( '?m=' . $year ); |
|
| 441 | + $yearlink = home_url('?m='.$year); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param string $yearlink Permalink for the year archive. |
| 450 | 450 | * @param int $year Year for the archive. |
| 451 | 451 | */ |
| 452 | - return apply_filters( 'year_link', $yearlink, $year ); |
|
| 452 | + return apply_filters('year_link', $yearlink, $year); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -465,17 +465,17 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function get_month_link($year, $month) { |
| 467 | 467 | global $wp_rewrite; |
| 468 | - if ( !$year ) |
|
| 468 | + if ( ! $year) |
|
| 469 | 469 | $year = gmdate('Y', current_time('timestamp')); |
| 470 | - if ( !$month ) |
|
| 470 | + if ( ! $month) |
|
| 471 | 471 | $month = gmdate('m', current_time('timestamp')); |
| 472 | 472 | $monthlink = $wp_rewrite->get_month_permastruct(); |
| 473 | - if ( !empty($monthlink) ) { |
|
| 473 | + if ( ! empty($monthlink)) { |
|
| 474 | 474 | $monthlink = str_replace('%year%', $year, $monthlink); |
| 475 | 475 | $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); |
| 476 | - $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); |
|
| 476 | + $monthlink = home_url(user_trailingslashit($monthlink, 'month')); |
|
| 477 | 477 | } else { |
| 478 | - $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); |
|
| 478 | + $monthlink = home_url('?m='.$year.zeroise($month, 2)); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @param int $year Year for the archive. |
| 488 | 488 | * @param int $month The month for the archive. |
| 489 | 489 | */ |
| 490 | - return apply_filters( 'month_link', $monthlink, $year, $month ); |
|
| 490 | + return apply_filters('month_link', $monthlink, $year, $month); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -504,21 +504,21 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | function get_day_link($year, $month, $day) { |
| 506 | 506 | global $wp_rewrite; |
| 507 | - if ( !$year ) |
|
| 507 | + if ( ! $year) |
|
| 508 | 508 | $year = gmdate('Y', current_time('timestamp')); |
| 509 | - if ( !$month ) |
|
| 509 | + if ( ! $month) |
|
| 510 | 510 | $month = gmdate('m', current_time('timestamp')); |
| 511 | - if ( !$day ) |
|
| 511 | + if ( ! $day) |
|
| 512 | 512 | $day = gmdate('j', current_time('timestamp')); |
| 513 | 513 | |
| 514 | 514 | $daylink = $wp_rewrite->get_day_permastruct(); |
| 515 | - if ( !empty($daylink) ) { |
|
| 515 | + if ( ! empty($daylink)) { |
|
| 516 | 516 | $daylink = str_replace('%year%', $year, $daylink); |
| 517 | 517 | $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); |
| 518 | 518 | $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); |
| 519 | - $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); |
|
| 519 | + $daylink = home_url(user_trailingslashit($daylink, 'day')); |
|
| 520 | 520 | } else { |
| 521 | - $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); |
|
| 521 | + $daylink = home_url('?m='.$year.zeroise($month, 2).zeroise($day, 2)); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * @param int $month Month for the archive. |
| 532 | 532 | * @param int $day The day for the archive. |
| 533 | 533 | */ |
| 534 | - return apply_filters( 'day_link', $daylink, $year, $month, $day ); |
|
| 534 | + return apply_filters('day_link', $daylink, $year, $month, $day); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -542,8 +542,8 @@ discard block |
||
| 542 | 542 | * @param string $anchor The link's anchor text. |
| 543 | 543 | * @param string $feed Optional, defaults to default feed. Feed type. |
| 544 | 544 | */ |
| 545 | -function the_feed_link( $anchor, $feed = '' ) { |
|
| 546 | - $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; |
|
| 545 | +function the_feed_link($anchor, $feed = '') { |
|
| 546 | + $link = '<a href="'.esc_url(get_feed_link($feed)).'">'.$anchor.'</a>'; |
|
| 547 | 547 | |
| 548 | 548 | /** |
| 549 | 549 | * Filter the feed link anchor tag. |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | * @param string $feed The feed type, or an empty string for the |
| 555 | 555 | * default feed type. |
| 556 | 556 | */ |
| 557 | - echo apply_filters( 'the_feed_link', $link, $feed ); |
|
| 557 | + echo apply_filters('the_feed_link', $link, $feed); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -571,23 +571,23 @@ discard block |
||
| 571 | 571 | global $wp_rewrite; |
| 572 | 572 | |
| 573 | 573 | $permalink = $wp_rewrite->get_feed_permastruct(); |
| 574 | - if ( '' != $permalink ) { |
|
| 575 | - if ( false !== strpos($feed, 'comments_') ) { |
|
| 574 | + if ('' != $permalink) { |
|
| 575 | + if (false !== strpos($feed, 'comments_')) { |
|
| 576 | 576 | $feed = str_replace('comments_', '', $feed); |
| 577 | 577 | $permalink = $wp_rewrite->get_comment_feed_permastruct(); |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - if ( get_default_feed() == $feed ) |
|
| 580 | + if (get_default_feed() == $feed) |
|
| 581 | 581 | $feed = ''; |
| 582 | 582 | |
| 583 | 583 | $permalink = str_replace('%feed%', $feed, $permalink); |
| 584 | 584 | $permalink = preg_replace('#/+#', '/', "/$permalink"); |
| 585 | - $output = home_url( user_trailingslashit($permalink, 'feed') ); |
|
| 585 | + $output = home_url(user_trailingslashit($permalink, 'feed')); |
|
| 586 | 586 | } else { |
| 587 | - if ( empty($feed) ) |
|
| 587 | + if (empty($feed)) |
|
| 588 | 588 | $feed = get_default_feed(); |
| 589 | 589 | |
| 590 | - if ( false !== strpos($feed, 'comments_') ) |
|
| 590 | + if (false !== strpos($feed, 'comments_')) |
|
| 591 | 591 | $feed = str_replace('comments_', 'comments-', $feed); |
| 592 | 592 | |
| 593 | 593 | $output = home_url("?feed={$feed}"); |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * @param string $output The feed permalink. |
| 602 | 602 | * @param string $feed Feed type. |
| 603 | 603 | */ |
| 604 | - return apply_filters( 'feed_link', $output, $feed ); |
|
| 604 | + return apply_filters('feed_link', $output, $feed); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -614,30 +614,30 @@ discard block |
||
| 614 | 614 | * @return string The permalink for the comments feed for the given post. |
| 615 | 615 | */ |
| 616 | 616 | function get_post_comments_feed_link($post_id = 0, $feed = '') { |
| 617 | - $post_id = absint( $post_id ); |
|
| 617 | + $post_id = absint($post_id); |
|
| 618 | 618 | |
| 619 | - if ( ! $post_id ) |
|
| 619 | + if ( ! $post_id) |
|
| 620 | 620 | $post_id = get_the_ID(); |
| 621 | 621 | |
| 622 | - if ( empty( $feed ) ) |
|
| 622 | + if (empty($feed)) |
|
| 623 | 623 | $feed = get_default_feed(); |
| 624 | 624 | |
| 625 | - if ( '' != get_option('permalink_structure') ) { |
|
| 626 | - if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) |
|
| 627 | - $url = _get_page_link( $post_id ); |
|
| 625 | + if ('' != get_option('permalink_structure')) { |
|
| 626 | + if ('page' == get_option('show_on_front') && $post_id == get_option('page_on_front')) |
|
| 627 | + $url = _get_page_link($post_id); |
|
| 628 | 628 | else |
| 629 | 629 | $url = get_permalink($post_id); |
| 630 | 630 | |
| 631 | - $url = trailingslashit($url) . 'feed'; |
|
| 632 | - if ( $feed != get_default_feed() ) |
|
| 631 | + $url = trailingslashit($url).'feed'; |
|
| 632 | + if ($feed != get_default_feed()) |
|
| 633 | 633 | $url .= "/$feed"; |
| 634 | 634 | $url = user_trailingslashit($url, 'single_feed'); |
| 635 | 635 | } else { |
| 636 | 636 | $type = get_post_field('post_type', $post_id); |
| 637 | - if ( 'page' == $type ) |
|
| 638 | - $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) ); |
|
| 637 | + if ('page' == $type) |
|
| 638 | + $url = add_query_arg(array('feed' => $feed, 'page_id' => $post_id), home_url('/')); |
|
| 639 | 639 | else |
| 640 | - $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); |
|
| 640 | + $url = add_query_arg(array('feed' => $feed, 'p' => $post_id), home_url('/')); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | * |
| 648 | 648 | * @param string $url Post comments feed permalink. |
| 649 | 649 | */ |
| 650 | - return apply_filters( 'post_comments_feed_link', $url ); |
|
| 650 | + return apply_filters('post_comments_feed_link', $url); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | * @param int $post_id Optional post ID. Default to current post. |
| 664 | 664 | * @param string $feed Optional. Feed format. |
| 665 | 665 | */ |
| 666 | -function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { |
|
| 667 | - $url = esc_url( get_post_comments_feed_link( $post_id, $feed ) ); |
|
| 668 | - if ( empty($link_text) ) |
|
| 666 | +function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { |
|
| 667 | + $url = esc_url(get_post_comments_feed_link($post_id, $feed)); |
|
| 668 | + if (empty($link_text)) |
|
| 669 | 669 | $link_text = __('Comments Feed'); |
| 670 | 670 | |
| 671 | 671 | /** |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @param int $post_id Post ID. |
| 678 | 678 | * @param string $feed The feed type, or an empty string for the default feed type. |
| 679 | 679 | */ |
| 680 | - echo apply_filters( 'post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed ); |
|
| 680 | + echo apply_filters('post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -692,23 +692,23 @@ discard block |
||
| 692 | 692 | * @param string $feed Optional. Feed type. |
| 693 | 693 | * @return string Link to the feed for the author specified by $author_id. |
| 694 | 694 | */ |
| 695 | -function get_author_feed_link( $author_id, $feed = '' ) { |
|
| 695 | +function get_author_feed_link($author_id, $feed = '') { |
|
| 696 | 696 | $author_id = (int) $author_id; |
| 697 | 697 | $permalink_structure = get_option('permalink_structure'); |
| 698 | 698 | |
| 699 | - if ( empty($feed) ) |
|
| 699 | + if (empty($feed)) |
|
| 700 | 700 | $feed = get_default_feed(); |
| 701 | 701 | |
| 702 | - if ( '' == $permalink_structure ) { |
|
| 703 | - $link = home_url("?feed=$feed&author=" . $author_id); |
|
| 702 | + if ('' == $permalink_structure) { |
|
| 703 | + $link = home_url("?feed=$feed&author=".$author_id); |
|
| 704 | 704 | } else { |
| 705 | 705 | $link = get_author_posts_url($author_id); |
| 706 | - if ( $feed == get_default_feed() ) |
|
| 706 | + if ($feed == get_default_feed()) |
|
| 707 | 707 | $feed_link = 'feed'; |
| 708 | 708 | else |
| 709 | 709 | $feed_link = "feed/$feed"; |
| 710 | 710 | |
| 711 | - $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); |
|
| 711 | + $link = trailingslashit($link).user_trailingslashit($feed_link, 'feed'); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | * @param string $link The author feed link. |
| 720 | 720 | * @param string $feed Feed type. |
| 721 | 721 | */ |
| 722 | - $link = apply_filters( 'author_feed_link', $link, $feed ); |
|
| 722 | + $link = apply_filters('author_feed_link', $link, $feed); |
|
| 723 | 723 | |
| 724 | 724 | return $link; |
| 725 | 725 | } |
@@ -736,8 +736,8 @@ discard block |
||
| 736 | 736 | * @param string $feed Optional. Feed type. |
| 737 | 737 | * @return string Link to the feed for the category specified by $cat_id. |
| 738 | 738 | */ |
| 739 | -function get_category_feed_link( $cat_id, $feed = '' ) { |
|
| 740 | - return get_term_feed_link( $cat_id, 'category', $feed ); |
|
| 739 | +function get_category_feed_link($cat_id, $feed = '') { |
|
| 740 | + return get_term_feed_link($cat_id, 'category', $feed); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -753,40 +753,40 @@ discard block |
||
| 753 | 753 | * @param string $feed Optional. Feed type. |
| 754 | 754 | * @return string|false Link to the feed for the term specified by $term_id and $taxonomy. |
| 755 | 755 | */ |
| 756 | -function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { |
|
| 757 | - $term_id = ( int ) $term_id; |
|
| 756 | +function get_term_feed_link($term_id, $taxonomy = 'category', $feed = '') { |
|
| 757 | + $term_id = (int) $term_id; |
|
| 758 | 758 | |
| 759 | - $term = get_term( $term_id, $taxonomy ); |
|
| 759 | + $term = get_term($term_id, $taxonomy); |
|
| 760 | 760 | |
| 761 | - if ( empty( $term ) || is_wp_error( $term ) ) |
|
| 761 | + if (empty($term) || is_wp_error($term)) |
|
| 762 | 762 | return false; |
| 763 | 763 | |
| 764 | - if ( empty( $feed ) ) |
|
| 764 | + if (empty($feed)) |
|
| 765 | 765 | $feed = get_default_feed(); |
| 766 | 766 | |
| 767 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 767 | + $permalink_structure = get_option('permalink_structure'); |
|
| 768 | 768 | |
| 769 | - if ( '' == $permalink_structure ) { |
|
| 770 | - if ( 'category' == $taxonomy ) { |
|
| 769 | + if ('' == $permalink_structure) { |
|
| 770 | + if ('category' == $taxonomy) { |
|
| 771 | 771 | $link = home_url("?feed=$feed&cat=$term_id"); |
| 772 | 772 | } |
| 773 | - elseif ( 'post_tag' == $taxonomy ) { |
|
| 773 | + elseif ('post_tag' == $taxonomy) { |
|
| 774 | 774 | $link = home_url("?feed=$feed&tag=$term->slug"); |
| 775 | 775 | } else { |
| 776 | - $t = get_taxonomy( $taxonomy ); |
|
| 776 | + $t = get_taxonomy($taxonomy); |
|
| 777 | 777 | $link = home_url("?feed=$feed&$t->query_var=$term->slug"); |
| 778 | 778 | } |
| 779 | 779 | } else { |
| 780 | - $link = get_term_link( $term_id, $term->taxonomy ); |
|
| 781 | - if ( $feed == get_default_feed() ) |
|
| 780 | + $link = get_term_link($term_id, $term->taxonomy); |
|
| 781 | + if ($feed == get_default_feed()) |
|
| 782 | 782 | $feed_link = 'feed'; |
| 783 | 783 | else |
| 784 | 784 | $feed_link = "feed/$feed"; |
| 785 | 785 | |
| 786 | - $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); |
|
| 786 | + $link = trailingslashit($link).user_trailingslashit($feed_link, 'feed'); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - if ( 'category' == $taxonomy ) { |
|
| 789 | + if ('category' == $taxonomy) { |
|
| 790 | 790 | /** |
| 791 | 791 | * Filter the category feed link. |
| 792 | 792 | * |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | * @param string $link The category feed link. |
| 796 | 796 | * @param string $feed Feed type. |
| 797 | 797 | */ |
| 798 | - $link = apply_filters( 'category_feed_link', $link, $feed ); |
|
| 799 | - } elseif ( 'post_tag' == $taxonomy ) { |
|
| 798 | + $link = apply_filters('category_feed_link', $link, $feed); |
|
| 799 | + } elseif ('post_tag' == $taxonomy) { |
|
| 800 | 800 | /** |
| 801 | 801 | * Filter the post tag feed link. |
| 802 | 802 | * |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * @param string $link The tag feed link. |
| 806 | 806 | * @param string $feed Feed type. |
| 807 | 807 | */ |
| 808 | - $link = apply_filters( 'tag_feed_link', $link, $feed ); |
|
| 808 | + $link = apply_filters('tag_feed_link', $link, $feed); |
|
| 809 | 809 | } else { |
| 810 | 810 | /** |
| 811 | 811 | * Filter the feed link for a taxonomy other than 'category' or 'post_tag'. |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | * @param string $feed Feed type. |
| 817 | 817 | * @param string $feed The taxonomy name. |
| 818 | 818 | */ |
| 819 | - $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); |
|
| 819 | + $link = apply_filters('taxonomy_feed_link', $link, $feed, $taxonomy); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | return $link; |
@@ -831,8 +831,8 @@ discard block |
||
| 831 | 831 | * @param string $feed Optional. Feed type. |
| 832 | 832 | * @return string The feed permalink for the given tag. |
| 833 | 833 | */ |
| 834 | -function get_tag_feed_link( $tag_id, $feed = '' ) { |
|
| 835 | - return get_term_feed_link( $tag_id, 'post_tag', $feed ); |
|
| 834 | +function get_tag_feed_link($tag_id, $feed = '') { |
|
| 835 | + return get_term_feed_link($tag_id, 'post_tag', $feed); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | * @param string $taxonomy Taxonomy |
| 845 | 845 | * @return string The edit tag link URL for the given tag. |
| 846 | 846 | */ |
| 847 | -function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { |
|
| 847 | +function get_edit_tag_link($tag_id, $taxonomy = 'post_tag') { |
|
| 848 | 848 | /** |
| 849 | 849 | * Filter the edit link for a tag (or term in another taxonomy). |
| 850 | 850 | * |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | * |
| 853 | 853 | * @param string $link The term edit link. |
| 854 | 854 | */ |
| 855 | - return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) ); |
|
| 855 | + return apply_filters('get_edit_tag_link', get_edit_term_link($tag_id, $taxonomy)); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | * @param string $after Optional. Display after edit link. |
| 866 | 866 | * @param object $tag Tag object. |
| 867 | 867 | */ |
| 868 | -function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { |
|
| 869 | - $link = edit_term_link( $link, '', '', $tag, false ); |
|
| 868 | +function edit_tag_link($link = '', $before = '', $after = '', $tag = null) { |
|
| 869 | + $link = edit_term_link($link, '', '', $tag, false); |
|
| 870 | 870 | |
| 871 | 871 | /** |
| 872 | 872 | * Filter the anchor tag for the edit link for a tag (or term in another taxonomy). |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | * |
| 876 | 876 | * @param string $link The anchor tag for the edit link. |
| 877 | 877 | */ |
| 878 | - echo $before . apply_filters( 'edit_tag_link', $link ) . $after; |
|
| 878 | + echo $before.apply_filters('edit_tag_link', $link).$after; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -889,14 +889,14 @@ discard block |
||
| 889 | 889 | * Defaults to the first object_type associated with the taxonomy. |
| 890 | 890 | * @return string|null The edit term link URL for the given term, or null on failure. |
| 891 | 891 | */ |
| 892 | -function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { |
|
| 893 | - $tax = get_taxonomy( $taxonomy ); |
|
| 894 | - if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) { |
|
| 892 | +function get_edit_term_link($term_id, $taxonomy, $object_type = '') { |
|
| 893 | + $tax = get_taxonomy($taxonomy); |
|
| 894 | + if ( ! $tax || ! current_user_can($tax->cap->edit_terms)) { |
|
| 895 | 895 | return; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - $term = get_term( $term_id, $taxonomy ); |
|
| 899 | - if ( ! $term || is_wp_error( $term ) ) { |
|
| 898 | + $term = get_term($term_id, $taxonomy); |
|
| 899 | + if ( ! $term || is_wp_error($term)) { |
|
| 900 | 900 | return; |
| 901 | 901 | } |
| 902 | 902 | |
@@ -906,13 +906,13 @@ discard block |
||
| 906 | 906 | 'tag_ID' => $term->term_id, |
| 907 | 907 | ); |
| 908 | 908 | |
| 909 | - if ( $object_type ) { |
|
| 909 | + if ($object_type) { |
|
| 910 | 910 | $args['post_type'] = $object_type; |
| 911 | - } elseif ( ! empty( $tax->object_type ) ) { |
|
| 912 | - $args['post_type'] = reset( $tax->object_type ); |
|
| 911 | + } elseif ( ! empty($tax->object_type)) { |
|
| 912 | + $args['post_type'] = reset($tax->object_type); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); |
|
| 915 | + $location = add_query_arg($args, admin_url('edit-tags.php')); |
|
| 916 | 916 | |
| 917 | 917 | /** |
| 918 | 918 | * Filter the edit link for a term. |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * @param string $taxonomy Taxonomy name. |
| 925 | 925 | * @param string $object_type The object type (eg. the post type). |
| 926 | 926 | */ |
| 927 | - return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); |
|
| 927 | + return apply_filters('get_edit_term_link', $location, $term_id, $taxonomy, $object_type); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | /** |
@@ -939,21 +939,21 @@ discard block |
||
| 939 | 939 | * @param bool $echo Optional. Whether or not to echo the return. Default true. |
| 940 | 940 | * @return string|void HTML content. |
| 941 | 941 | */ |
| 942 | -function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { |
|
| 943 | - if ( is_null( $term ) ) |
|
| 942 | +function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true) { |
|
| 943 | + if (is_null($term)) |
|
| 944 | 944 | $term = get_queried_object(); |
| 945 | 945 | |
| 946 | - if ( ! $term ) |
|
| 946 | + if ( ! $term) |
|
| 947 | 947 | return; |
| 948 | 948 | |
| 949 | - $tax = get_taxonomy( $term->taxonomy ); |
|
| 950 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
| 949 | + $tax = get_taxonomy($term->taxonomy); |
|
| 950 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
| 951 | 951 | return; |
| 952 | 952 | |
| 953 | - if ( empty( $link ) ) |
|
| 953 | + if (empty($link)) |
|
| 954 | 954 | $link = __('Edit This'); |
| 955 | 955 | |
| 956 | - $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; |
|
| 956 | + $link = '<a href="'.get_edit_term_link($term->term_id, $term->taxonomy).'">'.$link.'</a>'; |
|
| 957 | 957 | |
| 958 | 958 | /** |
| 959 | 959 | * Filter the anchor tag for the edit link of a term. |
@@ -963,9 +963,9 @@ discard block |
||
| 963 | 963 | * @param string $link The anchor tag for the edit link. |
| 964 | 964 | * @param int $term_id Term ID. |
| 965 | 965 | */ |
| 966 | - $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; |
|
| 966 | + $link = $before.apply_filters('edit_term_link', $link, $term->term_id).$after; |
|
| 967 | 967 | |
| 968 | - if ( $echo ) |
|
| 968 | + if ($echo) |
|
| 969 | 969 | echo $link; |
| 970 | 970 | else |
| 971 | 971 | return $link; |
@@ -981,23 +981,23 @@ discard block |
||
| 981 | 981 | * @param string $query Optional. The query string to use. If empty the current query is used. |
| 982 | 982 | * @return string The search permalink. |
| 983 | 983 | */ |
| 984 | -function get_search_link( $query = '' ) { |
|
| 984 | +function get_search_link($query = '') { |
|
| 985 | 985 | global $wp_rewrite; |
| 986 | 986 | |
| 987 | - if ( empty($query) ) |
|
| 988 | - $search = get_search_query( false ); |
|
| 987 | + if (empty($query)) |
|
| 988 | + $search = get_search_query(false); |
|
| 989 | 989 | else |
| 990 | 990 | $search = stripslashes($query); |
| 991 | 991 | |
| 992 | 992 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 993 | 993 | |
| 994 | - if ( empty( $permastruct ) ) { |
|
| 995 | - $link = home_url('?s=' . urlencode($search) ); |
|
| 994 | + if (empty($permastruct)) { |
|
| 995 | + $link = home_url('?s='.urlencode($search)); |
|
| 996 | 996 | } else { |
| 997 | 997 | $search = urlencode($search); |
| 998 | 998 | $search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it unencoded. |
| 999 | - $link = str_replace( '%search%', $search, $permastruct ); |
|
| 1000 | - $link = home_url( user_trailingslashit( $link, 'search' ) ); |
|
| 999 | + $link = str_replace('%search%', $search, $permastruct); |
|
| 1000 | + $link = home_url(user_trailingslashit($link, 'search')); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | * @param string $link Search permalink. |
| 1009 | 1009 | * @param string $search The URL-encoded search term. |
| 1010 | 1010 | */ |
| 1011 | - return apply_filters( 'search_link', $link, $search ); |
|
| 1011 | + return apply_filters('search_link', $link, $search); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /** |
@@ -1026,12 +1026,12 @@ discard block |
||
| 1026 | 1026 | global $wp_rewrite; |
| 1027 | 1027 | $link = get_search_link($search_query); |
| 1028 | 1028 | |
| 1029 | - if ( empty($feed) ) |
|
| 1029 | + if (empty($feed)) |
|
| 1030 | 1030 | $feed = get_default_feed(); |
| 1031 | 1031 | |
| 1032 | 1032 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1033 | 1033 | |
| 1034 | - if ( empty($permastruct) ) { |
|
| 1034 | + if (empty($permastruct)) { |
|
| 1035 | 1035 | $link = add_query_arg('feed', $feed, $link); |
| 1036 | 1036 | } else { |
| 1037 | 1037 | $link = trailingslashit($link); |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | * @param string $feed Feed type. |
| 1048 | 1048 | * @param string $type The search type. One of 'posts' or 'comments'. |
| 1049 | 1049 | */ |
| 1050 | - return apply_filters( 'search_feed_link', $link, $feed, 'posts' ); |
|
| 1050 | + return apply_filters('search_feed_link', $link, $feed, 'posts'); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1064,20 +1064,20 @@ discard block |
||
| 1064 | 1064 | function get_search_comments_feed_link($search_query = '', $feed = '') { |
| 1065 | 1065 | global $wp_rewrite; |
| 1066 | 1066 | |
| 1067 | - if ( empty($feed) ) |
|
| 1067 | + if (empty($feed)) |
|
| 1068 | 1068 | $feed = get_default_feed(); |
| 1069 | 1069 | |
| 1070 | 1070 | $link = get_search_feed_link($search_query, $feed); |
| 1071 | 1071 | |
| 1072 | 1072 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1073 | 1073 | |
| 1074 | - if ( empty($permastruct) ) |
|
| 1075 | - $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1074 | + if (empty($permastruct)) |
|
| 1075 | + $link = add_query_arg('feed', 'comments-'.$feed, $link); |
|
| 1076 | 1076 | else |
| 1077 | 1077 | $link = add_query_arg('withcomments', 1, $link); |
| 1078 | 1078 | |
| 1079 | 1079 | /** This filter is documented in wp-includes/link-template.php */ |
| 1080 | - return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); |
|
| 1080 | + return apply_filters('search_feed_link', $link, $feed, 'comments'); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
@@ -1090,23 +1090,23 @@ discard block |
||
| 1090 | 1090 | * @param string $post_type Post type |
| 1091 | 1091 | * @return string|false The post type archive permalink. |
| 1092 | 1092 | */ |
| 1093 | -function get_post_type_archive_link( $post_type ) { |
|
| 1093 | +function get_post_type_archive_link($post_type) { |
|
| 1094 | 1094 | global $wp_rewrite; |
| 1095 | - if ( ! $post_type_obj = get_post_type_object( $post_type ) ) |
|
| 1095 | + if ( ! $post_type_obj = get_post_type_object($post_type)) |
|
| 1096 | 1096 | return false; |
| 1097 | 1097 | |
| 1098 | - if ( ! $post_type_obj->has_archive ) |
|
| 1098 | + if ( ! $post_type_obj->has_archive) |
|
| 1099 | 1099 | return false; |
| 1100 | 1100 | |
| 1101 | - if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { |
|
| 1102 | - $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
|
| 1103 | - if ( $post_type_obj->rewrite['with_front'] ) |
|
| 1104 | - $struct = $wp_rewrite->front . $struct; |
|
| 1101 | + if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) { |
|
| 1102 | + $struct = (true === $post_type_obj->has_archive) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
|
| 1103 | + if ($post_type_obj->rewrite['with_front']) |
|
| 1104 | + $struct = $wp_rewrite->front.$struct; |
|
| 1105 | 1105 | else |
| 1106 | - $struct = $wp_rewrite->root . $struct; |
|
| 1107 | - $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); |
|
| 1106 | + $struct = $wp_rewrite->root.$struct; |
|
| 1107 | + $link = home_url(user_trailingslashit($struct, 'post_type_archive')); |
|
| 1108 | 1108 | } else { |
| 1109 | - $link = home_url( '?post_type=' . $post_type ); |
|
| 1109 | + $link = home_url('?post_type='.$post_type); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | /** |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | * @param string $link The post type archive permalink. |
| 1118 | 1118 | * @param string $post_type Post type name. |
| 1119 | 1119 | */ |
| 1120 | - return apply_filters( 'post_type_archive_link', $link, $post_type ); |
|
| 1120 | + return apply_filters('post_type_archive_link', $link, $post_type); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1129,22 +1129,22 @@ discard block |
||
| 1129 | 1129 | * @param string $feed Optional. Feed type |
| 1130 | 1130 | * @return string|false The post type feed permalink. |
| 1131 | 1131 | */ |
| 1132 | -function get_post_type_archive_feed_link( $post_type, $feed = '' ) { |
|
| 1132 | +function get_post_type_archive_feed_link($post_type, $feed = '') { |
|
| 1133 | 1133 | $default_feed = get_default_feed(); |
| 1134 | - if ( empty( $feed ) ) |
|
| 1134 | + if (empty($feed)) |
|
| 1135 | 1135 | $feed = $default_feed; |
| 1136 | 1136 | |
| 1137 | - if ( ! $link = get_post_type_archive_link( $post_type ) ) |
|
| 1137 | + if ( ! $link = get_post_type_archive_link($post_type)) |
|
| 1138 | 1138 | return false; |
| 1139 | 1139 | |
| 1140 | - $post_type_obj = get_post_type_object( $post_type ); |
|
| 1141 | - if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { |
|
| 1142 | - $link = trailingslashit( $link ); |
|
| 1140 | + $post_type_obj = get_post_type_object($post_type); |
|
| 1141 | + if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) { |
|
| 1142 | + $link = trailingslashit($link); |
|
| 1143 | 1143 | $link .= 'feed/'; |
| 1144 | - if ( $feed != $default_feed ) |
|
| 1144 | + if ($feed != $default_feed) |
|
| 1145 | 1145 | $link .= "$feed/"; |
| 1146 | 1146 | } else { |
| 1147 | - $link = add_query_arg( 'feed', $feed, $link ); |
|
| 1147 | + $link = add_query_arg('feed', $feed, $link); |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | /** |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | * @param string $link The post type archive feed link. |
| 1156 | 1156 | * @param string $feed Feed type. |
| 1157 | 1157 | */ |
| 1158 | - return apply_filters( 'post_type_archive_feed_link', $link, $feed ); |
|
| 1158 | + return apply_filters('post_type_archive_feed_link', $link, $feed); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | /** |
@@ -1170,22 +1170,22 @@ discard block |
||
| 1170 | 1170 | * @param string $context Optional, defaults to display. How to write the '&', defaults to '&'. |
| 1171 | 1171 | * @return string|void The edit post link for the given post. |
| 1172 | 1172 | */ |
| 1173 | -function get_edit_post_link( $id = 0, $context = 'display' ) { |
|
| 1174 | - if ( ! $post = get_post( $id ) ) |
|
| 1173 | +function get_edit_post_link($id = 0, $context = 'display') { |
|
| 1174 | + if ( ! $post = get_post($id)) |
|
| 1175 | 1175 | return; |
| 1176 | 1176 | |
| 1177 | - if ( 'revision' === $post->post_type ) |
|
| 1177 | + if ('revision' === $post->post_type) |
|
| 1178 | 1178 | $action = ''; |
| 1179 | - elseif ( 'display' == $context ) |
|
| 1179 | + elseif ('display' == $context) |
|
| 1180 | 1180 | $action = '&action=edit'; |
| 1181 | 1181 | else |
| 1182 | 1182 | $action = '&action=edit'; |
| 1183 | 1183 | |
| 1184 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1185 | - if ( !$post_type_object ) |
|
| 1184 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1185 | + if ( ! $post_type_object) |
|
| 1186 | 1186 | return; |
| 1187 | 1187 | |
| 1188 | - if ( !current_user_can( 'edit_post', $post->ID ) ) |
|
| 1188 | + if ( ! current_user_can('edit_post', $post->ID)) |
|
| 1189 | 1189 | return; |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | * @param string $context The link context. If set to 'display' then ampersands |
| 1199 | 1199 | * are encoded. |
| 1200 | 1200 | */ |
| 1201 | - return apply_filters( 'get_edit_post_link', admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ), $post->ID, $context ); |
|
| 1201 | + return apply_filters('get_edit_post_link', admin_url(sprintf($post_type_object->_edit_link.$action, $post->ID)), $post->ID, $context); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1211,20 +1211,20 @@ discard block |
||
| 1211 | 1211 | * @param string $after Optional. Display after edit link. |
| 1212 | 1212 | * @param int $id Optional. Post ID. |
| 1213 | 1213 | */ |
| 1214 | -function edit_post_link( $text = null, $before = '', $after = '', $id = 0 ) { |
|
| 1215 | - if ( ! $post = get_post( $id ) ) { |
|
| 1214 | +function edit_post_link($text = null, $before = '', $after = '', $id = 0) { |
|
| 1215 | + if ( ! $post = get_post($id)) { |
|
| 1216 | 1216 | return; |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | - if ( ! $url = get_edit_post_link( $post->ID ) ) { |
|
| 1219 | + if ( ! $url = get_edit_post_link($post->ID)) { |
|
| 1220 | 1220 | return; |
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | - if ( null === $text ) { |
|
| 1224 | - $text = __( 'Edit This' ); |
|
| 1223 | + if (null === $text) { |
|
| 1224 | + $text = __('Edit This'); |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | - $link = '<a class="post-edit-link" href="' . $url . '">' . $text . '</a>'; |
|
| 1227 | + $link = '<a class="post-edit-link" href="'.$url.'">'.$text.'</a>'; |
|
| 1228 | 1228 | |
| 1229 | 1229 | /** |
| 1230 | 1230 | * Filter the post edit link anchor tag. |
@@ -1235,7 +1235,7 @@ discard block |
||
| 1235 | 1235 | * @param int $post_id Post ID. |
| 1236 | 1236 | * @param string $text Anchor text. |
| 1237 | 1237 | */ |
| 1238 | - echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; |
|
| 1238 | + echo $before.apply_filters('edit_post_link', $link, $post->ID, $text).$after; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | /** |
@@ -1250,23 +1250,23 @@ discard block |
||
| 1250 | 1250 | * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. |
| 1251 | 1251 | * @return string|void The delete post link URL for the given post. |
| 1252 | 1252 | */ |
| 1253 | -function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) { |
|
| 1254 | - if ( ! empty( $deprecated ) ) |
|
| 1255 | - _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 1253 | +function get_delete_post_link($id = 0, $deprecated = '', $force_delete = false) { |
|
| 1254 | + if ( ! empty($deprecated)) |
|
| 1255 | + _deprecated_argument(__FUNCTION__, '3.0'); |
|
| 1256 | 1256 | |
| 1257 | - if ( !$post = get_post( $id ) ) |
|
| 1257 | + if ( ! $post = get_post($id)) |
|
| 1258 | 1258 | return; |
| 1259 | 1259 | |
| 1260 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1261 | - if ( !$post_type_object ) |
|
| 1260 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1261 | + if ( ! $post_type_object) |
|
| 1262 | 1262 | return; |
| 1263 | 1263 | |
| 1264 | - if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
| 1264 | + if ( ! current_user_can('delete_post', $post->ID)) |
|
| 1265 | 1265 | return; |
| 1266 | 1266 | |
| 1267 | - $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; |
|
| 1267 | + $action = ($force_delete || ! EMPTY_TRASH_DAYS) ? 'delete' : 'trash'; |
|
| 1268 | 1268 | |
| 1269 | - $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); |
|
| 1269 | + $delete_link = add_query_arg('action', $action, admin_url(sprintf($post_type_object->_edit_link, $post->ID))); |
|
| 1270 | 1270 | |
| 1271 | 1271 | /** |
| 1272 | 1272 | * Filter the post delete link. |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | * @param int $post_id Post ID. |
| 1278 | 1278 | * @param bool $force_delete Whether to bypass the trash and force deletion. Default false. |
| 1279 | 1279 | */ |
| 1280 | - return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); |
|
| 1280 | + return apply_filters('get_delete_post_link', wp_nonce_url($delete_link, "$action-post_{$post->ID}"), $post->ID, $force_delete); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | /** |
@@ -1288,13 +1288,13 @@ discard block |
||
| 1288 | 1288 | * @param int $comment_id Optional. Comment ID. |
| 1289 | 1289 | * @return string|void The edit comment link URL for the given comment. |
| 1290 | 1290 | */ |
| 1291 | -function get_edit_comment_link( $comment_id = 0 ) { |
|
| 1292 | - $comment = get_comment( $comment_id ); |
|
| 1291 | +function get_edit_comment_link($comment_id = 0) { |
|
| 1292 | + $comment = get_comment($comment_id); |
|
| 1293 | 1293 | |
| 1294 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
| 1294 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) |
|
| 1295 | 1295 | return; |
| 1296 | 1296 | |
| 1297 | - $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; |
|
| 1297 | + $location = admin_url('comment.php?action=editcomment&c=').$comment->comment_ID; |
|
| 1298 | 1298 | |
| 1299 | 1299 | /** |
| 1300 | 1300 | * Filter the comment edit link. |
@@ -1303,7 +1303,7 @@ discard block |
||
| 1303 | 1303 | * |
| 1304 | 1304 | * @param string $location The edit link. |
| 1305 | 1305 | */ |
| 1306 | - return apply_filters( 'get_edit_comment_link', $location ); |
|
| 1306 | + return apply_filters('get_edit_comment_link', $location); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | /** |
@@ -1317,18 +1317,18 @@ discard block |
||
| 1317 | 1317 | * @param string $before Optional. Display before edit link. |
| 1318 | 1318 | * @param string $after Optional. Display after edit link. |
| 1319 | 1319 | */ |
| 1320 | -function edit_comment_link( $text = null, $before = '', $after = '' ) { |
|
| 1320 | +function edit_comment_link($text = null, $before = '', $after = '') { |
|
| 1321 | 1321 | global $comment; |
| 1322 | 1322 | |
| 1323 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
| 1323 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) { |
|
| 1324 | 1324 | return; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - if ( null === $text ) { |
|
| 1328 | - $text = __( 'Edit This' ); |
|
| 1327 | + if (null === $text) { |
|
| 1328 | + $text = __('Edit This'); |
|
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | - $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $text . '</a>'; |
|
| 1331 | + $link = '<a class="comment-edit-link" href="'.get_edit_comment_link($comment->comment_ID).'">'.$text.'</a>'; |
|
| 1332 | 1332 | |
| 1333 | 1333 | /** |
| 1334 | 1334 | * Filter the comment edit link anchor tag. |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | * @param int $comment_id Comment ID. |
| 1340 | 1340 | * @param string $text Anchor text. |
| 1341 | 1341 | */ |
| 1342 | - echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; |
|
| 1342 | + echo $before.apply_filters('edit_comment_link', $link, $comment->comment_ID, $text).$after; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | /** |
@@ -1350,13 +1350,13 @@ discard block |
||
| 1350 | 1350 | * @param int|stdClass $link Optional. Bookmark ID. |
| 1351 | 1351 | * @return string|void The edit bookmark link URL. |
| 1352 | 1352 | */ |
| 1353 | -function get_edit_bookmark_link( $link = 0 ) { |
|
| 1354 | - $link = get_bookmark( $link ); |
|
| 1353 | +function get_edit_bookmark_link($link = 0) { |
|
| 1354 | + $link = get_bookmark($link); |
|
| 1355 | 1355 | |
| 1356 | - if ( !current_user_can('manage_links') ) |
|
| 1356 | + if ( ! current_user_can('manage_links')) |
|
| 1357 | 1357 | return; |
| 1358 | 1358 | |
| 1359 | - $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; |
|
| 1359 | + $location = admin_url('link.php?action=edit&link_id=').$link->link_id; |
|
| 1360 | 1360 | |
| 1361 | 1361 | /** |
| 1362 | 1362 | * Filter the bookmark (link) edit link. |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | * @param string $location The edit link. |
| 1367 | 1367 | * @param int $link_id Bookmark ID. |
| 1368 | 1368 | */ |
| 1369 | - return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); |
|
| 1369 | + return apply_filters('get_edit_bookmark_link', $location, $link->link_id); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | /** |
@@ -1379,16 +1379,16 @@ discard block |
||
| 1379 | 1379 | * @param string $after Optional. Display after edit link. |
| 1380 | 1380 | * @param int $bookmark Optional. Bookmark ID. |
| 1381 | 1381 | */ |
| 1382 | -function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { |
|
| 1382 | +function edit_bookmark_link($link = '', $before = '', $after = '', $bookmark = null) { |
|
| 1383 | 1383 | $bookmark = get_bookmark($bookmark); |
| 1384 | 1384 | |
| 1385 | - if ( !current_user_can('manage_links') ) |
|
| 1385 | + if ( ! current_user_can('manage_links')) |
|
| 1386 | 1386 | return; |
| 1387 | 1387 | |
| 1388 | - if ( empty($link) ) |
|
| 1388 | + if (empty($link)) |
|
| 1389 | 1389 | $link = __('Edit This'); |
| 1390 | 1390 | |
| 1391 | - $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>'; |
|
| 1391 | + $link = '<a href="'.get_edit_bookmark_link($bookmark).'">'.$link.'</a>'; |
|
| 1392 | 1392 | |
| 1393 | 1393 | /** |
| 1394 | 1394 | * Filter the bookmark edit link anchor tag. |
@@ -1398,7 +1398,7 @@ discard block |
||
| 1398 | 1398 | * @param string $link Anchor tag for the edit link. |
| 1399 | 1399 | * @param int $link_id Bookmark ID. |
| 1400 | 1400 | */ |
| 1401 | - echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; |
|
| 1401 | + echo $before.apply_filters('edit_bookmark_link', $link, $bookmark->link_id).$after; |
|
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | 1404 | /** |
@@ -1409,22 +1409,22 @@ discard block |
||
| 1409 | 1409 | * @param int $user_id Optional. User ID. Defaults to the current user. |
| 1410 | 1410 | * @return string URL to edit user page or empty string. |
| 1411 | 1411 | */ |
| 1412 | -function get_edit_user_link( $user_id = null ) { |
|
| 1413 | - if ( ! $user_id ) |
|
| 1412 | +function get_edit_user_link($user_id = null) { |
|
| 1413 | + if ( ! $user_id) |
|
| 1414 | 1414 | $user_id = get_current_user_id(); |
| 1415 | 1415 | |
| 1416 | - if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) |
|
| 1416 | + if (empty($user_id) || ! current_user_can('edit_user', $user_id)) |
|
| 1417 | 1417 | return ''; |
| 1418 | 1418 | |
| 1419 | - $user = get_userdata( $user_id ); |
|
| 1419 | + $user = get_userdata($user_id); |
|
| 1420 | 1420 | |
| 1421 | - if ( ! $user ) |
|
| 1421 | + if ( ! $user) |
|
| 1422 | 1422 | return ''; |
| 1423 | 1423 | |
| 1424 | - if ( get_current_user_id() == $user->ID ) |
|
| 1425 | - $link = get_edit_profile_url( $user->ID ); |
|
| 1424 | + if (get_current_user_id() == $user->ID) |
|
| 1425 | + $link = get_edit_profile_url($user->ID); |
|
| 1426 | 1426 | else |
| 1427 | - $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1427 | + $link = add_query_arg('user_id', $user->ID, self_admin_url('user-edit.php')); |
|
| 1428 | 1428 | |
| 1429 | 1429 | /** |
| 1430 | 1430 | * Filter the user edit link. |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | * @param string $link The edit link. |
| 1435 | 1435 | * @param int $user_id User ID. |
| 1436 | 1436 | */ |
| 1437 | - return apply_filters( 'get_edit_user_link', $link, $user->ID ); |
|
| 1437 | + return apply_filters('get_edit_user_link', $link, $user->ID); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | // Navigation links |
@@ -1449,8 +1449,8 @@ discard block |
||
| 1449 | 1449 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1450 | 1450 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
| 1451 | 1451 | */ |
| 1452 | -function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1453 | - return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1452 | +function get_previous_post($in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1453 | + return get_adjacent_post($in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | 1456 | /** |
@@ -1463,8 +1463,8 @@ discard block |
||
| 1463 | 1463 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1464 | 1464 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
| 1465 | 1465 | */ |
| 1466 | -function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1467 | - return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1466 | +function get_next_post($in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1467 | + return get_adjacent_post($in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | /** |
@@ -1482,10 +1482,10 @@ discard block |
||
| 1482 | 1482 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1483 | 1483 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. |
| 1484 | 1484 | */ |
| 1485 | -function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1485 | +function get_adjacent_post($in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1486 | 1486 | global $wpdb; |
| 1487 | 1487 | |
| 1488 | - if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) |
|
| 1488 | + if (( ! $post = get_post()) || ! taxonomy_exists($taxonomy)) |
|
| 1489 | 1489 | return null; |
| 1490 | 1490 | |
| 1491 | 1491 | $current_post_date = $post->post_date; |
@@ -1493,50 +1493,50 @@ discard block |
||
| 1493 | 1493 | $join = ''; |
| 1494 | 1494 | $where = ''; |
| 1495 | 1495 | |
| 1496 | - if ( $in_same_term || ! empty( $excluded_terms ) ) { |
|
| 1496 | + if ($in_same_term || ! empty($excluded_terms)) { |
|
| 1497 | 1497 | $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; |
| 1498 | - $where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); |
|
| 1498 | + $where = $wpdb->prepare("AND tt.taxonomy = %s", $taxonomy); |
|
| 1499 | 1499 | |
| 1500 | - if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { |
|
| 1500 | + if ( ! empty($excluded_terms) && ! is_array($excluded_terms)) { |
|
| 1501 | 1501 | // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " |
| 1502 | - if ( false !== strpos( $excluded_terms, ' and ' ) ) { |
|
| 1503 | - _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); |
|
| 1504 | - $excluded_terms = explode( ' and ', $excluded_terms ); |
|
| 1502 | + if (false !== strpos($excluded_terms, ' and ')) { |
|
| 1503 | + _deprecated_argument(__FUNCTION__, '3.3', sprintf(__('Use commas instead of %s to separate excluded terms.'), "'and'")); |
|
| 1504 | + $excluded_terms = explode(' and ', $excluded_terms); |
|
| 1505 | 1505 | } else { |
| 1506 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1506 | + $excluded_terms = explode(',', $excluded_terms); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | - $excluded_terms = array_map( 'intval', $excluded_terms ); |
|
| 1509 | + $excluded_terms = array_map('intval', $excluded_terms); |
|
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - if ( $in_same_term ) { |
|
| 1513 | - if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
|
| 1512 | + if ($in_same_term) { |
|
| 1513 | + if ( ! is_object_in_taxonomy($post->post_type, $taxonomy)) |
|
| 1514 | 1514 | return ''; |
| 1515 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1515 | + $term_array = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); |
|
| 1516 | 1516 | |
| 1517 | 1517 | // Remove any exclusions from the term array to include. |
| 1518 | - $term_array = array_diff( $term_array, (array) $excluded_terms ); |
|
| 1519 | - $term_array = array_map( 'intval', $term_array ); |
|
| 1518 | + $term_array = array_diff($term_array, (array) $excluded_terms); |
|
| 1519 | + $term_array = array_map('intval', $term_array); |
|
| 1520 | 1520 | |
| 1521 | - if ( ! $term_array || is_wp_error( $term_array ) ) |
|
| 1521 | + if ( ! $term_array || is_wp_error($term_array)) |
|
| 1522 | 1522 | return ''; |
| 1523 | 1523 | |
| 1524 | - $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; |
|
| 1524 | + $where .= " AND tt.term_id IN (".implode(',', $term_array).")"; |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | - if ( ! empty( $excluded_terms ) ) { |
|
| 1528 | - $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )'; |
|
| 1527 | + if ( ! empty($excluded_terms)) { |
|
| 1528 | + $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (".implode($excluded_terms, ',').') )'; |
|
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | // 'post_status' clause depends on the current user. |
| 1533 | - if ( is_user_logged_in() ) { |
|
| 1533 | + if (is_user_logged_in()) { |
|
| 1534 | 1534 | $user_id = get_current_user_id(); |
| 1535 | 1535 | |
| 1536 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1537 | - if ( empty( $post_type_object ) ) { |
|
| 1536 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1537 | + if (empty($post_type_object)) { |
|
| 1538 | 1538 | $post_type_cap = $post->post_type; |
| 1539 | - $read_private_cap = 'read_private_' . $post_type_cap . 's'; |
|
| 1539 | + $read_private_cap = 'read_private_'.$post_type_cap.'s'; |
|
| 1540 | 1540 | } else { |
| 1541 | 1541 | $read_private_cap = $post_type_object->cap->read_private_posts; |
| 1542 | 1542 | } |
@@ -1545,13 +1545,13 @@ discard block |
||
| 1545 | 1545 | * Results should include private posts belonging to the current user, or private posts where the |
| 1546 | 1546 | * current user has the 'read_private_posts' cap. |
| 1547 | 1547 | */ |
| 1548 | - $private_states = get_post_stati( array( 'private' => true ) ); |
|
| 1548 | + $private_states = get_post_stati(array('private' => true)); |
|
| 1549 | 1549 | $where .= " AND ( p.post_status = 'publish'"; |
| 1550 | - foreach ( (array) $private_states as $state ) { |
|
| 1551 | - if ( current_user_can( $read_private_cap ) ) { |
|
| 1552 | - $where .= $wpdb->prepare( " OR p.post_status = %s", $state ); |
|
| 1550 | + foreach ((array) $private_states as $state) { |
|
| 1551 | + if (current_user_can($read_private_cap)) { |
|
| 1552 | + $where .= $wpdb->prepare(" OR p.post_status = %s", $state); |
|
| 1553 | 1553 | } else { |
| 1554 | - $where .= $wpdb->prepare( " OR (p.post_author = %d AND p.post_status = %s)", $user_id, $state ); |
|
| 1554 | + $where .= $wpdb->prepare(" OR (p.post_author = %d AND p.post_status = %s)", $user_id, $state); |
|
| 1555 | 1555 | } |
| 1556 | 1556 | } |
| 1557 | 1557 | $where .= " )"; |
@@ -1575,7 +1575,7 @@ discard block |
||
| 1575 | 1575 | * @param bool $in_same_term Whether post should be in a same taxonomy term. |
| 1576 | 1576 | * @param array $excluded_terms Array of excluded term IDs. |
| 1577 | 1577 | */ |
| 1578 | - $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms ); |
|
| 1578 | + $join = apply_filters("get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms); |
|
| 1579 | 1579 | |
| 1580 | 1580 | /** |
| 1581 | 1581 | * Filter the WHERE clause in the SQL for an adjacent post query. |
@@ -1589,7 +1589,7 @@ discard block |
||
| 1589 | 1589 | * @param bool $in_same_term Whether post should be in a same taxonomy term. |
| 1590 | 1590 | * @param array $excluded_terms Array of excluded term IDs. |
| 1591 | 1591 | */ |
| 1592 | - $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms ); |
|
| 1592 | + $where = apply_filters("get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type), $in_same_term, $excluded_terms); |
|
| 1593 | 1593 | |
| 1594 | 1594 | /** |
| 1595 | 1595 | * Filter the ORDER BY clause in the SQL for an adjacent post query. |
@@ -1601,25 +1601,25 @@ discard block |
||
| 1601 | 1601 | * |
| 1602 | 1602 | * @param string $order_by The `ORDER BY` clause in the SQL. |
| 1603 | 1603 | */ |
| 1604 | - $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); |
|
| 1604 | + $sort = apply_filters("get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1"); |
|
| 1605 | 1605 | |
| 1606 | 1606 | $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; |
| 1607 | - $query_key = 'adjacent_post_' . md5( $query ); |
|
| 1608 | - $result = wp_cache_get( $query_key, 'counts' ); |
|
| 1609 | - if ( false !== $result ) { |
|
| 1610 | - if ( $result ) |
|
| 1611 | - $result = get_post( $result ); |
|
| 1607 | + $query_key = 'adjacent_post_'.md5($query); |
|
| 1608 | + $result = wp_cache_get($query_key, 'counts'); |
|
| 1609 | + if (false !== $result) { |
|
| 1610 | + if ($result) |
|
| 1611 | + $result = get_post($result); |
|
| 1612 | 1612 | return $result; |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | - $result = $wpdb->get_var( $query ); |
|
| 1616 | - if ( null === $result ) |
|
| 1615 | + $result = $wpdb->get_var($query); |
|
| 1616 | + if (null === $result) |
|
| 1617 | 1617 | $result = ''; |
| 1618 | 1618 | |
| 1619 | - wp_cache_set( $query_key, $result, 'counts' ); |
|
| 1619 | + wp_cache_set($query_key, $result, 'counts'); |
|
| 1620 | 1620 | |
| 1621 | - if ( $result ) |
|
| 1622 | - $result = get_post( $result ); |
|
| 1621 | + if ($result) |
|
| 1622 | + $result = get_post($result); |
|
| 1623 | 1623 | |
| 1624 | 1624 | return $result; |
| 1625 | 1625 | } |
@@ -1638,28 +1638,28 @@ discard block |
||
| 1638 | 1638 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1639 | 1639 | * @return string|void The adjacent post relational link URL. |
| 1640 | 1640 | */ |
| 1641 | -function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1642 | - if ( $previous && is_attachment() && $post = get_post() ) |
|
| 1643 | - $post = get_post( $post->post_parent ); |
|
| 1641 | +function get_adjacent_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1642 | + if ($previous && is_attachment() && $post = get_post()) |
|
| 1643 | + $post = get_post($post->post_parent); |
|
| 1644 | 1644 | else |
| 1645 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1645 | + $post = get_adjacent_post($in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 1646 | 1646 | |
| 1647 | - if ( empty( $post ) ) |
|
| 1647 | + if (empty($post)) |
|
| 1648 | 1648 | return; |
| 1649 | 1649 | |
| 1650 | - $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) ); |
|
| 1650 | + $post_title = the_title_attribute(array('echo' => false, 'post' => $post)); |
|
| 1651 | 1651 | |
| 1652 | - if ( empty( $post_title ) ) |
|
| 1653 | - $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1652 | + if (empty($post_title)) |
|
| 1653 | + $post_title = $previous ? __('Previous Post') : __('Next Post'); |
|
| 1654 | 1654 | |
| 1655 | - $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
|
| 1655 | + $date = mysql2date(get_option('date_format'), $post->post_date); |
|
| 1656 | 1656 | |
| 1657 | - $title = str_replace( '%title', $post_title, $title ); |
|
| 1658 | - $title = str_replace( '%date', $date, $title ); |
|
| 1657 | + $title = str_replace('%title', $post_title, $title); |
|
| 1658 | + $title = str_replace('%date', $date, $title); |
|
| 1659 | 1659 | |
| 1660 | 1660 | $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; |
| 1661 | - $link .= esc_attr( $title ); |
|
| 1662 | - $link .= "' href='" . get_permalink( $post ) . "' />\n"; |
|
| 1661 | + $link .= esc_attr($title); |
|
| 1662 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
| 1663 | 1663 | |
| 1664 | 1664 | $adjacent = $previous ? 'previous' : 'next'; |
| 1665 | 1665 | |
@@ -1673,7 +1673,7 @@ discard block |
||
| 1673 | 1673 | * |
| 1674 | 1674 | * @param string $link The relational link. |
| 1675 | 1675 | */ |
| 1676 | - return apply_filters( "{$adjacent}_post_rel_link", $link ); |
|
| 1676 | + return apply_filters("{$adjacent}_post_rel_link", $link); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | /** |
@@ -1686,9 +1686,9 @@ discard block |
||
| 1686 | 1686 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
| 1687 | 1687 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1688 | 1688 | */ |
| 1689 | -function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1690 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1691 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1689 | +function adjacent_posts_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1690 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1691 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | /** |
@@ -1699,7 +1699,7 @@ discard block |
||
| 1699 | 1699 | * |
| 1700 | 1700 | */ |
| 1701 | 1701 | function adjacent_posts_rel_link_wp_head() { |
| 1702 | - if ( ! is_single() || is_attachment() ) { |
|
| 1702 | + if ( ! is_single() || is_attachment()) { |
|
| 1703 | 1703 | return; |
| 1704 | 1704 | } |
| 1705 | 1705 | adjacent_posts_rel_link(); |
@@ -1715,8 +1715,8 @@ discard block |
||
| 1715 | 1715 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
| 1716 | 1716 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1717 | 1717 | */ |
| 1718 | -function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1719 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1718 | +function next_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1719 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | /** |
@@ -1729,8 +1729,8 @@ discard block |
||
| 1729 | 1729 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default true. |
| 1730 | 1730 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1731 | 1731 | */ |
| 1732 | -function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1733 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1732 | +function prev_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1733 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | /** |
@@ -1747,9 +1747,9 @@ discard block |
||
| 1747 | 1747 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1748 | 1748 | * @return null|array Array containing the boundary post object if successful, null otherwise. |
| 1749 | 1749 | */ |
| 1750 | -function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { |
|
| 1750 | +function get_boundary_post($in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category') { |
|
| 1751 | 1751 | $post = get_post(); |
| 1752 | - if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) |
|
| 1752 | + if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists($taxonomy)) |
|
| 1753 | 1753 | return null; |
| 1754 | 1754 | |
| 1755 | 1755 | $query_args = array( |
@@ -1761,34 +1761,34 @@ discard block |
||
| 1761 | 1761 | |
| 1762 | 1762 | $term_array = array(); |
| 1763 | 1763 | |
| 1764 | - if ( ! is_array( $excluded_terms ) ) { |
|
| 1765 | - if ( ! empty( $excluded_terms ) ) |
|
| 1766 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1764 | + if ( ! is_array($excluded_terms)) { |
|
| 1765 | + if ( ! empty($excluded_terms)) |
|
| 1766 | + $excluded_terms = explode(',', $excluded_terms); |
|
| 1767 | 1767 | else |
| 1768 | 1768 | $excluded_terms = array(); |
| 1769 | 1769 | } |
| 1770 | 1770 | |
| 1771 | - if ( $in_same_term || ! empty( $excluded_terms ) ) { |
|
| 1772 | - if ( $in_same_term ) |
|
| 1773 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1771 | + if ($in_same_term || ! empty($excluded_terms)) { |
|
| 1772 | + if ($in_same_term) |
|
| 1773 | + $term_array = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); |
|
| 1774 | 1774 | |
| 1775 | - if ( ! empty( $excluded_terms ) ) { |
|
| 1776 | - $excluded_terms = array_map( 'intval', $excluded_terms ); |
|
| 1777 | - $excluded_terms = array_diff( $excluded_terms, $term_array ); |
|
| 1775 | + if ( ! empty($excluded_terms)) { |
|
| 1776 | + $excluded_terms = array_map('intval', $excluded_terms); |
|
| 1777 | + $excluded_terms = array_diff($excluded_terms, $term_array); |
|
| 1778 | 1778 | |
| 1779 | 1779 | $inverse_terms = array(); |
| 1780 | - foreach ( $excluded_terms as $excluded_term ) |
|
| 1780 | + foreach ($excluded_terms as $excluded_term) |
|
| 1781 | 1781 | $inverse_terms[] = $excluded_term * -1; |
| 1782 | 1782 | $excluded_terms = $inverse_terms; |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | - $query_args[ 'tax_query' ] = array( array( |
|
| 1785 | + $query_args['tax_query'] = array(array( |
|
| 1786 | 1786 | 'taxonomy' => $taxonomy, |
| 1787 | - 'terms' => array_merge( $term_array, $excluded_terms ) |
|
| 1788 | - ) ); |
|
| 1787 | + 'terms' => array_merge($term_array, $excluded_terms) |
|
| 1788 | + )); |
|
| 1789 | 1789 | } |
| 1790 | 1790 | |
| 1791 | - return get_posts( $query_args ); |
|
| 1791 | + return get_posts($query_args); |
|
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | 1794 | /* |
@@ -1803,8 +1803,8 @@ discard block |
||
| 1803 | 1803 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1804 | 1804 | * @return string The link URL of the previous post in relation to the current post. |
| 1805 | 1805 | */ |
| 1806 | -function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1807 | - return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1806 | +function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1807 | + return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | /** |
@@ -1819,8 +1819,8 @@ discard block |
||
| 1819 | 1819 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
| 1820 | 1820 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1821 | 1821 | */ |
| 1822 | -function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1823 | - echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); |
|
| 1822 | +function previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1823 | + echo get_previous_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy); |
|
| 1824 | 1824 | } |
| 1825 | 1825 | |
| 1826 | 1826 | /** |
@@ -1835,8 +1835,8 @@ discard block |
||
| 1835 | 1835 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1836 | 1836 | * @return string The link URL of the next post in relation to the current post. |
| 1837 | 1837 | */ |
| 1838 | -function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1839 | - return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1838 | +function get_next_post_link($format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1839 | + return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | /** |
@@ -1851,8 +1851,8 @@ discard block |
||
| 1851 | 1851 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
| 1852 | 1852 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1853 | 1853 | */ |
| 1854 | -function next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1855 | - echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); |
|
| 1854 | +function next_post_link($format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1855 | + echo get_next_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1870,32 +1870,32 @@ discard block |
||
| 1870 | 1870 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1871 | 1871 | * @return string The link URL of the previous or next post in relation to the current post. |
| 1872 | 1872 | */ |
| 1873 | -function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1874 | - if ( $previous && is_attachment() ) |
|
| 1875 | - $post = get_post( get_post()->post_parent ); |
|
| 1873 | +function get_adjacent_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1874 | + if ($previous && is_attachment()) |
|
| 1875 | + $post = get_post(get_post()->post_parent); |
|
| 1876 | 1876 | else |
| 1877 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1877 | + $post = get_adjacent_post($in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 1878 | 1878 | |
| 1879 | - if ( ! $post ) { |
|
| 1879 | + if ( ! $post) { |
|
| 1880 | 1880 | $output = ''; |
| 1881 | 1881 | } else { |
| 1882 | 1882 | $title = $post->post_title; |
| 1883 | 1883 | |
| 1884 | - if ( empty( $post->post_title ) ) |
|
| 1885 | - $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1884 | + if (empty($post->post_title)) |
|
| 1885 | + $title = $previous ? __('Previous Post') : __('Next Post'); |
|
| 1886 | 1886 | |
| 1887 | 1887 | /** This filter is documented in wp-includes/post-template.php */ |
| 1888 | - $title = apply_filters( 'the_title', $title, $post->ID ); |
|
| 1888 | + $title = apply_filters('the_title', $title, $post->ID); |
|
| 1889 | 1889 | |
| 1890 | - $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
|
| 1890 | + $date = mysql2date(get_option('date_format'), $post->post_date); |
|
| 1891 | 1891 | $rel = $previous ? 'prev' : 'next'; |
| 1892 | 1892 | |
| 1893 | - $string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">'; |
|
| 1894 | - $inlink = str_replace( '%title', $title, $link ); |
|
| 1895 | - $inlink = str_replace( '%date', $date, $inlink ); |
|
| 1896 | - $inlink = $string . $inlink . '</a>'; |
|
| 1893 | + $string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">'; |
|
| 1894 | + $inlink = str_replace('%title', $title, $link); |
|
| 1895 | + $inlink = str_replace('%date', $date, $inlink); |
|
| 1896 | + $inlink = $string.$inlink.'</a>'; |
|
| 1897 | 1897 | |
| 1898 | - $output = str_replace( '%link', $inlink, $format ); |
|
| 1898 | + $output = str_replace('%link', $inlink, $format); |
|
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | $adjacent = $previous ? 'previous' : 'next'; |
@@ -1915,7 +1915,7 @@ discard block |
||
| 1915 | 1915 | * @param WP_Post $post The adjacent post. |
| 1916 | 1916 | * @param string $adjacent Whether the post is previous or next. |
| 1917 | 1917 | */ |
| 1918 | - return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent ); |
|
| 1918 | + return apply_filters("{$adjacent}_post_link", $output, $format, $link, $post, $adjacent); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | /** |
@@ -1932,8 +1932,8 @@ discard block |
||
| 1932 | 1932 | * @param bool $previous Optional. Whether to display link to previous or next post. Default true. |
| 1933 | 1933 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1934 | 1934 | */ |
| 1935 | -function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1936 | - echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1935 | +function adjacent_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1936 | + echo get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | /** |
@@ -1948,53 +1948,53 @@ discard block |
||
| 1948 | 1948 | * Otherwise, prepares the URL with esc_url_raw(). |
| 1949 | 1949 | * @return string The link URL for the given page number. |
| 1950 | 1950 | */ |
| 1951 | -function get_pagenum_link($pagenum = 1, $escape = true ) { |
|
| 1951 | +function get_pagenum_link($pagenum = 1, $escape = true) { |
|
| 1952 | 1952 | global $wp_rewrite; |
| 1953 | 1953 | |
| 1954 | 1954 | $pagenum = (int) $pagenum; |
| 1955 | 1955 | |
| 1956 | - $request = remove_query_arg( 'paged' ); |
|
| 1956 | + $request = remove_query_arg('paged'); |
|
| 1957 | 1957 | |
| 1958 | 1958 | $home_root = parse_url(home_url()); |
| 1959 | - $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : ''; |
|
| 1960 | - $home_root = preg_quote( $home_root, '|' ); |
|
| 1959 | + $home_root = (isset($home_root['path'])) ? $home_root['path'] : ''; |
|
| 1960 | + $home_root = preg_quote($home_root, '|'); |
|
| 1961 | 1961 | |
| 1962 | - $request = preg_replace('|^'. $home_root . '|i', '', $request); |
|
| 1962 | + $request = preg_replace('|^'.$home_root.'|i', '', $request); |
|
| 1963 | 1963 | $request = preg_replace('|^/+|', '', $request); |
| 1964 | 1964 | |
| 1965 | - if ( !$wp_rewrite->using_permalinks() || is_admin() ) { |
|
| 1966 | - $base = trailingslashit( get_bloginfo( 'url' ) ); |
|
| 1965 | + if ( ! $wp_rewrite->using_permalinks() || is_admin()) { |
|
| 1966 | + $base = trailingslashit(get_bloginfo('url')); |
|
| 1967 | 1967 | |
| 1968 | - if ( $pagenum > 1 ) { |
|
| 1969 | - $result = add_query_arg( 'paged', $pagenum, $base . $request ); |
|
| 1968 | + if ($pagenum > 1) { |
|
| 1969 | + $result = add_query_arg('paged', $pagenum, $base.$request); |
|
| 1970 | 1970 | } else { |
| 1971 | - $result = $base . $request; |
|
| 1971 | + $result = $base.$request; |
|
| 1972 | 1972 | } |
| 1973 | 1973 | } else { |
| 1974 | 1974 | $qs_regex = '|\?.*?$|'; |
| 1975 | - preg_match( $qs_regex, $request, $qs_match ); |
|
| 1975 | + preg_match($qs_regex, $request, $qs_match); |
|
| 1976 | 1976 | |
| 1977 | - if ( !empty( $qs_match[0] ) ) { |
|
| 1977 | + if ( ! empty($qs_match[0])) { |
|
| 1978 | 1978 | $query_string = $qs_match[0]; |
| 1979 | - $request = preg_replace( $qs_regex, '', $request ); |
|
| 1979 | + $request = preg_replace($qs_regex, '', $request); |
|
| 1980 | 1980 | } else { |
| 1981 | 1981 | $query_string = ''; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request); |
|
| 1985 | - $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request); |
|
| 1984 | + $request = preg_replace("|$wp_rewrite->pagination_base/\d+/?$|", '', $request); |
|
| 1985 | + $request = preg_replace('|^'.preg_quote($wp_rewrite->index, '|').'|i', '', $request); |
|
| 1986 | 1986 | $request = ltrim($request, '/'); |
| 1987 | 1987 | |
| 1988 | - $base = trailingslashit( get_bloginfo( 'url' ) ); |
|
| 1988 | + $base = trailingslashit(get_bloginfo('url')); |
|
| 1989 | 1989 | |
| 1990 | - if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) |
|
| 1991 | - $base .= $wp_rewrite->index . '/'; |
|
| 1990 | + if ($wp_rewrite->using_index_permalinks() && ($pagenum > 1 || '' != $request)) |
|
| 1991 | + $base .= $wp_rewrite->index.'/'; |
|
| 1992 | 1992 | |
| 1993 | - if ( $pagenum > 1 ) { |
|
| 1994 | - $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' ); |
|
| 1993 | + if ($pagenum > 1) { |
|
| 1994 | + $request = (( ! empty($request)) ? trailingslashit($request) : $request).user_trailingslashit($wp_rewrite->pagination_base."/".$pagenum, 'paged'); |
|
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | - $result = $base . $request . $query_string; |
|
| 1997 | + $result = $base.$request.$query_string; |
|
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | /** |
@@ -2004,12 +2004,12 @@ discard block |
||
| 2004 | 2004 | * |
| 2005 | 2005 | * @param string $result The page number link. |
| 2006 | 2006 | */ |
| 2007 | - $result = apply_filters( 'get_pagenum_link', $result ); |
|
| 2007 | + $result = apply_filters('get_pagenum_link', $result); |
|
| 2008 | 2008 | |
| 2009 | - if ( $escape ) |
|
| 2010 | - return esc_url( $result ); |
|
| 2009 | + if ($escape) |
|
| 2010 | + return esc_url($result); |
|
| 2011 | 2011 | else |
| 2012 | - return esc_url_raw( $result ); |
|
| 2012 | + return esc_url_raw($result); |
|
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | /** |
@@ -2027,11 +2027,11 @@ discard block |
||
| 2027 | 2027 | function get_next_posts_page_link($max_page = 0) { |
| 2028 | 2028 | global $paged; |
| 2029 | 2029 | |
| 2030 | - if ( !is_single() ) { |
|
| 2031 | - if ( !$paged ) |
|
| 2030 | + if ( ! is_single()) { |
|
| 2031 | + if ( ! $paged) |
|
| 2032 | 2032 | $paged = 1; |
| 2033 | 2033 | $nextpage = intval($paged) + 1; |
| 2034 | - if ( !$max_page || $max_page >= $nextpage ) |
|
| 2034 | + if ( ! $max_page || $max_page >= $nextpage) |
|
| 2035 | 2035 | return get_pagenum_link($nextpage); |
| 2036 | 2036 | } |
| 2037 | 2037 | } |
@@ -2045,10 +2045,10 @@ discard block |
||
| 2045 | 2045 | * @param bool $echo Optional. Echo or return; |
| 2046 | 2046 | * @return string|void The link URL for next posts page if `$echo = false`. |
| 2047 | 2047 | */ |
| 2048 | -function next_posts( $max_page = 0, $echo = true ) { |
|
| 2049 | - $output = esc_url( get_next_posts_page_link( $max_page ) ); |
|
| 2048 | +function next_posts($max_page = 0, $echo = true) { |
|
| 2049 | + $output = esc_url(get_next_posts_page_link($max_page)); |
|
| 2050 | 2050 | |
| 2051 | - if ( $echo ) |
|
| 2051 | + if ($echo) |
|
| 2052 | 2052 | echo $output; |
| 2053 | 2053 | else |
| 2054 | 2054 | return $output; |
@@ -2066,21 +2066,21 @@ discard block |
||
| 2066 | 2066 | * @param int $max_page Optional. Max pages. |
| 2067 | 2067 | * @return string|void HTML-formatted next posts page link. |
| 2068 | 2068 | */ |
| 2069 | -function get_next_posts_link( $label = null, $max_page = 0 ) { |
|
| 2069 | +function get_next_posts_link($label = null, $max_page = 0) { |
|
| 2070 | 2070 | global $paged, $wp_query; |
| 2071 | 2071 | |
| 2072 | - if ( !$max_page ) |
|
| 2072 | + if ( ! $max_page) |
|
| 2073 | 2073 | $max_page = $wp_query->max_num_pages; |
| 2074 | 2074 | |
| 2075 | - if ( !$paged ) |
|
| 2075 | + if ( ! $paged) |
|
| 2076 | 2076 | $paged = 1; |
| 2077 | 2077 | |
| 2078 | 2078 | $nextpage = intval($paged) + 1; |
| 2079 | 2079 | |
| 2080 | - if ( null === $label ) |
|
| 2081 | - $label = __( 'Next Page »' ); |
|
| 2080 | + if (null === $label) |
|
| 2081 | + $label = __('Next Page »'); |
|
| 2082 | 2082 | |
| 2083 | - if ( !is_single() && ( $nextpage <= $max_page ) ) { |
|
| 2083 | + if ( ! is_single() && ($nextpage <= $max_page)) { |
|
| 2084 | 2084 | /** |
| 2085 | 2085 | * Filter the anchor tag attributes for the next posts page link. |
| 2086 | 2086 | * |
@@ -2088,9 +2088,9 @@ discard block |
||
| 2088 | 2088 | * |
| 2089 | 2089 | * @param string $attributes Attributes for the anchor tag. |
| 2090 | 2090 | */ |
| 2091 | - $attr = apply_filters( 'next_posts_link_attributes', '' ); |
|
| 2091 | + $attr = apply_filters('next_posts_link_attributes', ''); |
|
| 2092 | 2092 | |
| 2093 | - return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>'; |
|
| 2093 | + return '<a href="'.next_posts($max_page, false)."\" $attr>".preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2094 | 2094 | } |
| 2095 | 2095 | } |
| 2096 | 2096 | |
@@ -2102,8 +2102,8 @@ discard block |
||
| 2102 | 2102 | * @param string $label Content for link text. |
| 2103 | 2103 | * @param int $max_page Optional. Max pages. |
| 2104 | 2104 | */ |
| 2105 | -function next_posts_link( $label = null, $max_page = 0 ) { |
|
| 2106 | - echo get_next_posts_link( $label, $max_page ); |
|
| 2105 | +function next_posts_link($label = null, $max_page = 0) { |
|
| 2106 | + echo get_next_posts_link($label, $max_page); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | /** |
@@ -2122,9 +2122,9 @@ discard block |
||
| 2122 | 2122 | function get_previous_posts_page_link() { |
| 2123 | 2123 | global $paged; |
| 2124 | 2124 | |
| 2125 | - if ( !is_single() ) { |
|
| 2125 | + if ( ! is_single()) { |
|
| 2126 | 2126 | $nextpage = intval($paged) - 1; |
| 2127 | - if ( $nextpage < 1 ) |
|
| 2127 | + if ($nextpage < 1) |
|
| 2128 | 2128 | $nextpage = 1; |
| 2129 | 2129 | return get_pagenum_link($nextpage); |
| 2130 | 2130 | } |
@@ -2138,10 +2138,10 @@ discard block |
||
| 2138 | 2138 | * @param bool $echo Optional. Echo or return; |
| 2139 | 2139 | * @return string|void The previous posts page link if `$echo = false`. |
| 2140 | 2140 | */ |
| 2141 | -function previous_posts( $echo = true ) { |
|
| 2142 | - $output = esc_url( get_previous_posts_page_link() ); |
|
| 2141 | +function previous_posts($echo = true) { |
|
| 2142 | + $output = esc_url(get_previous_posts_page_link()); |
|
| 2143 | 2143 | |
| 2144 | - if ( $echo ) |
|
| 2144 | + if ($echo) |
|
| 2145 | 2145 | echo $output; |
| 2146 | 2146 | else |
| 2147 | 2147 | return $output; |
@@ -2157,13 +2157,13 @@ discard block |
||
| 2157 | 2157 | * @param string $label Optional. Previous page link text. |
| 2158 | 2158 | * @return string|void HTML-formatted previous page link. |
| 2159 | 2159 | */ |
| 2160 | -function get_previous_posts_link( $label = null ) { |
|
| 2160 | +function get_previous_posts_link($label = null) { |
|
| 2161 | 2161 | global $paged; |
| 2162 | 2162 | |
| 2163 | - if ( null === $label ) |
|
| 2164 | - $label = __( '« Previous Page' ); |
|
| 2163 | + if (null === $label) |
|
| 2164 | + $label = __('« Previous Page'); |
|
| 2165 | 2165 | |
| 2166 | - if ( !is_single() && $paged > 1 ) { |
|
| 2166 | + if ( ! is_single() && $paged > 1) { |
|
| 2167 | 2167 | /** |
| 2168 | 2168 | * Filter the anchor tag attributes for the previous posts page link. |
| 2169 | 2169 | * |
@@ -2171,8 +2171,8 @@ discard block |
||
| 2171 | 2171 | * |
| 2172 | 2172 | * @param string $attributes Attributes for the anchor tag. |
| 2173 | 2173 | */ |
| 2174 | - $attr = apply_filters( 'previous_posts_link_attributes', '' ); |
|
| 2175 | - return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'</a>'; |
|
| 2174 | + $attr = apply_filters('previous_posts_link_attributes', ''); |
|
| 2175 | + return '<a href="'.previous_posts(false)."\" $attr>".preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2176 | 2176 | } |
| 2177 | 2177 | } |
| 2178 | 2178 | |
@@ -2183,8 +2183,8 @@ discard block |
||
| 2183 | 2183 | * |
| 2184 | 2184 | * @param string $label Optional. Previous page link text. |
| 2185 | 2185 | */ |
| 2186 | -function previous_posts_link( $label = null ) { |
|
| 2187 | - echo get_previous_posts_link( $label ); |
|
| 2186 | +function previous_posts_link($label = null) { |
|
| 2187 | + echo get_previous_posts_link($label); |
|
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | 2190 | /** |
@@ -2197,18 +2197,18 @@ discard block |
||
| 2197 | 2197 | * @param string|array $args Optional args. |
| 2198 | 2198 | * @return string The posts link navigation. |
| 2199 | 2199 | */ |
| 2200 | -function get_posts_nav_link( $args = array() ) { |
|
| 2200 | +function get_posts_nav_link($args = array()) { |
|
| 2201 | 2201 | global $wp_query; |
| 2202 | 2202 | |
| 2203 | 2203 | $return = ''; |
| 2204 | 2204 | |
| 2205 | - if ( !is_singular() ) { |
|
| 2205 | + if ( ! is_singular()) { |
|
| 2206 | 2206 | $defaults = array( |
| 2207 | 2207 | 'sep' => ' — ', |
| 2208 | 2208 | 'prelabel' => __('« Previous Page'), |
| 2209 | 2209 | 'nxtlabel' => __('Next Page »'), |
| 2210 | 2210 | ); |
| 2211 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2211 | + $args = wp_parse_args($args, $defaults); |
|
| 2212 | 2212 | |
| 2213 | 2213 | $max_num_pages = $wp_query->max_num_pages; |
| 2214 | 2214 | $paged = get_query_var('paged'); |
@@ -2218,7 +2218,7 @@ discard block |
||
| 2218 | 2218 | $args['sep'] = ''; |
| 2219 | 2219 | } |
| 2220 | 2220 | |
| 2221 | - if ( $max_num_pages > 1 ) { |
|
| 2221 | + if ($max_num_pages > 1) { |
|
| 2222 | 2222 | $return = get_previous_posts_link($args['prelabel']); |
| 2223 | 2223 | $return .= preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $args['sep']); |
| 2224 | 2224 | $return .= get_next_posts_link($args['nxtlabel']); |
@@ -2237,8 +2237,8 @@ discard block |
||
| 2237 | 2237 | * @param string $prelabel Optional. Label for previous pages. |
| 2238 | 2238 | * @param string $nxtlabel Optional Label for next pages. |
| 2239 | 2239 | */ |
| 2240 | -function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { |
|
| 2241 | - $args = array_filter( compact('sep', 'prelabel', 'nxtlabel') ); |
|
| 2240 | +function posts_nav_link($sep = '', $prelabel = '', $nxtlabel = '') { |
|
| 2241 | + $args = array_filter(compact('sep', 'prelabel', 'nxtlabel')); |
|
| 2242 | 2242 | echo get_posts_nav_link($args); |
| 2243 | 2243 | } |
| 2244 | 2244 | |
@@ -2256,20 +2256,20 @@ discard block |
||
| 2256 | 2256 | * } |
| 2257 | 2257 | * @return string Markup for post links. |
| 2258 | 2258 | */ |
| 2259 | -function get_the_post_navigation( $args = array() ) { |
|
| 2260 | - $args = wp_parse_args( $args, array( |
|
| 2259 | +function get_the_post_navigation($args = array()) { |
|
| 2260 | + $args = wp_parse_args($args, array( |
|
| 2261 | 2261 | 'prev_text' => '%title', |
| 2262 | 2262 | 'next_text' => '%title', |
| 2263 | - 'screen_reader_text' => __( 'Post navigation' ), |
|
| 2264 | - ) ); |
|
| 2263 | + 'screen_reader_text' => __('Post navigation'), |
|
| 2264 | + )); |
|
| 2265 | 2265 | |
| 2266 | 2266 | $navigation = ''; |
| 2267 | - $previous = get_previous_post_link( '<div class="nav-previous">%link</div>', $args['prev_text'] ); |
|
| 2268 | - $next = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'] ); |
|
| 2267 | + $previous = get_previous_post_link('<div class="nav-previous">%link</div>', $args['prev_text']); |
|
| 2268 | + $next = get_next_post_link('<div class="nav-next">%link</div>', $args['next_text']); |
|
| 2269 | 2269 | |
| 2270 | 2270 | // Only add markup if there's somewhere to navigate to. |
| 2271 | - if ( $previous || $next ) { |
|
| 2272 | - $navigation = _navigation_markup( $previous . $next, 'post-navigation', $args['screen_reader_text'] ); |
|
| 2271 | + if ($previous || $next) { |
|
| 2272 | + $navigation = _navigation_markup($previous.$next, 'post-navigation', $args['screen_reader_text']); |
|
| 2273 | 2273 | } |
| 2274 | 2274 | |
| 2275 | 2275 | return $navigation; |
@@ -2283,8 +2283,8 @@ discard block |
||
| 2283 | 2283 | * @param array $args Optional. See {@see get_the_post_navigation()} for available |
| 2284 | 2284 | * arguments. Default empty array. |
| 2285 | 2285 | */ |
| 2286 | -function the_post_navigation( $args = array() ) { |
|
| 2287 | - echo get_the_post_navigation( $args ); |
|
| 2286 | +function the_post_navigation($args = array()) { |
|
| 2287 | + echo get_the_post_navigation($args); |
|
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | 2290 | /** |
@@ -2306,29 +2306,29 @@ discard block |
||
| 2306 | 2306 | * } |
| 2307 | 2307 | * @return string Markup for posts links. |
| 2308 | 2308 | */ |
| 2309 | -function get_the_posts_navigation( $args = array() ) { |
|
| 2309 | +function get_the_posts_navigation($args = array()) { |
|
| 2310 | 2310 | $navigation = ''; |
| 2311 | 2311 | |
| 2312 | 2312 | // Don't print empty markup if there's only one page. |
| 2313 | - if ( $GLOBALS['wp_query']->max_num_pages > 1 ) { |
|
| 2314 | - $args = wp_parse_args( $args, array( |
|
| 2315 | - 'prev_text' => __( 'Older posts' ), |
|
| 2316 | - 'next_text' => __( 'Newer posts' ), |
|
| 2317 | - 'screen_reader_text' => __( 'Posts navigation' ), |
|
| 2318 | - ) ); |
|
| 2319 | - |
|
| 2320 | - $next_link = get_previous_posts_link( $args['next_text'] ); |
|
| 2321 | - $prev_link = get_next_posts_link( $args['prev_text'] ); |
|
| 2322 | - |
|
| 2323 | - if ( $prev_link ) { |
|
| 2324 | - $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; |
|
| 2313 | + if ($GLOBALS['wp_query']->max_num_pages > 1) { |
|
| 2314 | + $args = wp_parse_args($args, array( |
|
| 2315 | + 'prev_text' => __('Older posts'), |
|
| 2316 | + 'next_text' => __('Newer posts'), |
|
| 2317 | + 'screen_reader_text' => __('Posts navigation'), |
|
| 2318 | + )); |
|
| 2319 | + |
|
| 2320 | + $next_link = get_previous_posts_link($args['next_text']); |
|
| 2321 | + $prev_link = get_next_posts_link($args['prev_text']); |
|
| 2322 | + |
|
| 2323 | + if ($prev_link) { |
|
| 2324 | + $navigation .= '<div class="nav-previous">'.$prev_link.'</div>'; |
|
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | - if ( $next_link ) { |
|
| 2328 | - $navigation .= '<div class="nav-next">' . $next_link . '</div>'; |
|
| 2327 | + if ($next_link) { |
|
| 2328 | + $navigation .= '<div class="nav-next">'.$next_link.'</div>'; |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | - $navigation = _navigation_markup( $navigation, 'posts-navigation', $args['screen_reader_text'] ); |
|
| 2331 | + $navigation = _navigation_markup($navigation, 'posts-navigation', $args['screen_reader_text']); |
|
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | 2334 | return $navigation; |
@@ -2342,8 +2342,8 @@ discard block |
||
| 2342 | 2342 | * @param array $args Optional. See {@see get_the_posts_navigation()} for available |
| 2343 | 2343 | * arguments. Default empty array. |
| 2344 | 2344 | */ |
| 2345 | -function the_posts_navigation( $args = array() ) { |
|
| 2346 | - echo get_the_posts_navigation( $args ); |
|
| 2345 | +function the_posts_navigation($args = array()) { |
|
| 2346 | + echo get_the_posts_navigation($args); |
|
| 2347 | 2347 | } |
| 2348 | 2348 | |
| 2349 | 2349 | /** |
@@ -2360,28 +2360,28 @@ discard block |
||
| 2360 | 2360 | * } |
| 2361 | 2361 | * @return string Markup for pagination links. |
| 2362 | 2362 | */ |
| 2363 | -function get_the_posts_pagination( $args = array() ) { |
|
| 2363 | +function get_the_posts_pagination($args = array()) { |
|
| 2364 | 2364 | $navigation = ''; |
| 2365 | 2365 | |
| 2366 | 2366 | // Don't print empty markup if there's only one page. |
| 2367 | - if ( $GLOBALS['wp_query']->max_num_pages > 1 ) { |
|
| 2368 | - $args = wp_parse_args( $args, array( |
|
| 2367 | + if ($GLOBALS['wp_query']->max_num_pages > 1) { |
|
| 2368 | + $args = wp_parse_args($args, array( |
|
| 2369 | 2369 | 'mid_size' => 1, |
| 2370 | - 'prev_text' => _x( 'Previous', 'previous post' ), |
|
| 2371 | - 'next_text' => _x( 'Next', 'next post' ), |
|
| 2372 | - 'screen_reader_text' => __( 'Posts navigation' ), |
|
| 2373 | - ) ); |
|
| 2370 | + 'prev_text' => _x('Previous', 'previous post'), |
|
| 2371 | + 'next_text' => _x('Next', 'next post'), |
|
| 2372 | + 'screen_reader_text' => __('Posts navigation'), |
|
| 2373 | + )); |
|
| 2374 | 2374 | |
| 2375 | 2375 | // Make sure we get a string back. Plain is the next best thing. |
| 2376 | - if ( isset( $args['type'] ) && 'array' == $args['type'] ) { |
|
| 2376 | + if (isset($args['type']) && 'array' == $args['type']) { |
|
| 2377 | 2377 | $args['type'] = 'plain'; |
| 2378 | 2378 | } |
| 2379 | 2379 | |
| 2380 | 2380 | // Set up paginated links. |
| 2381 | - $links = paginate_links( $args ); |
|
| 2381 | + $links = paginate_links($args); |
|
| 2382 | 2382 | |
| 2383 | - if ( $links ) { |
|
| 2384 | - $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] ); |
|
| 2383 | + if ($links) { |
|
| 2384 | + $navigation = _navigation_markup($links, 'pagination', $args['screen_reader_text']); |
|
| 2385 | 2385 | } |
| 2386 | 2386 | } |
| 2387 | 2387 | |
@@ -2397,8 +2397,8 @@ discard block |
||
| 2397 | 2397 | * @param array $args Optional. See {@see get_the_posts_pagination()} for available arguments. |
| 2398 | 2398 | * Default empty array. |
| 2399 | 2399 | */ |
| 2400 | -function the_posts_pagination( $args = array() ) { |
|
| 2401 | - echo get_the_posts_pagination( $args ); |
|
| 2400 | +function the_posts_pagination($args = array()) { |
|
| 2401 | + echo get_the_posts_pagination($args); |
|
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | 2404 | /** |
@@ -2412,9 +2412,9 @@ discard block |
||
| 2412 | 2412 | * @param string $screen_reader_text Optional. Screen reader text for nav element. Default: 'Posts navigation'. |
| 2413 | 2413 | * @return string Navigation template tag. |
| 2414 | 2414 | */ |
| 2415 | -function _navigation_markup( $links, $class = 'posts-navigation', $screen_reader_text = '' ) { |
|
| 2416 | - if ( empty( $screen_reader_text ) ) { |
|
| 2417 | - $screen_reader_text = __( 'Posts navigation' ); |
|
| 2415 | +function _navigation_markup($links, $class = 'posts-navigation', $screen_reader_text = '') { |
|
| 2416 | + if (empty($screen_reader_text)) { |
|
| 2417 | + $screen_reader_text = __('Posts navigation'); |
|
| 2418 | 2418 | } |
| 2419 | 2419 | |
| 2420 | 2420 | $template = ' |
@@ -2423,7 +2423,7 @@ discard block |
||
| 2423 | 2423 | <div class="nav-links">%3$s</div> |
| 2424 | 2424 | </nav>'; |
| 2425 | 2425 | |
| 2426 | - return sprintf( $template, sanitize_html_class( $class ), esc_html( $screen_reader_text ), $links ); |
|
| 2426 | + return sprintf($template, sanitize_html_class($class), esc_html($screen_reader_text), $links); |
|
| 2427 | 2427 | } |
| 2428 | 2428 | |
| 2429 | 2429 | /** |
@@ -2437,25 +2437,25 @@ discard block |
||
| 2437 | 2437 | * @param int $max_page Optional. The maximum number of comment pages. |
| 2438 | 2438 | * @return string The comments page number link URL. |
| 2439 | 2439 | */ |
| 2440 | -function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { |
|
| 2440 | +function get_comments_pagenum_link($pagenum = 1, $max_page = 0) { |
|
| 2441 | 2441 | global $wp_rewrite; |
| 2442 | 2442 | |
| 2443 | 2443 | $pagenum = (int) $pagenum; |
| 2444 | 2444 | |
| 2445 | 2445 | $result = get_permalink(); |
| 2446 | 2446 | |
| 2447 | - if ( 'newest' == get_option('default_comments_page') ) { |
|
| 2448 | - if ( $pagenum != $max_page ) { |
|
| 2449 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2450 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2447 | + if ('newest' == get_option('default_comments_page')) { |
|
| 2448 | + if ($pagenum != $max_page) { |
|
| 2449 | + if ($wp_rewrite->using_permalinks()) |
|
| 2450 | + $result = user_trailingslashit(trailingslashit($result).$wp_rewrite->comments_pagination_base.'-'.$pagenum, 'commentpaged'); |
|
| 2451 | 2451 | else |
| 2452 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2452 | + $result = add_query_arg('cpage', $pagenum, $result); |
|
| 2453 | 2453 | } |
| 2454 | - } elseif ( $pagenum > 1 ) { |
|
| 2455 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2456 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2454 | + } elseif ($pagenum > 1) { |
|
| 2455 | + if ($wp_rewrite->using_permalinks()) |
|
| 2456 | + $result = user_trailingslashit(trailingslashit($result).$wp_rewrite->comments_pagination_base.'-'.$pagenum, 'commentpaged'); |
|
| 2457 | 2457 | else |
| 2458 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2458 | + $result = add_query_arg('cpage', $pagenum, $result); |
|
| 2459 | 2459 | } |
| 2460 | 2460 | |
| 2461 | 2461 | $result .= '#comments'; |
@@ -2467,7 +2467,7 @@ discard block |
||
| 2467 | 2467 | * |
| 2468 | 2468 | * @param string $result The comments page number link. |
| 2469 | 2469 | */ |
| 2470 | - return apply_filters( 'get_comments_pagenum_link', $result ); |
|
| 2470 | + return apply_filters('get_comments_pagenum_link', $result); |
|
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | /** |
@@ -2481,30 +2481,30 @@ discard block |
||
| 2481 | 2481 | * @param int $max_page Optional. Max page. |
| 2482 | 2482 | * @return string|void HTML-formatted link for the next page of comments. |
| 2483 | 2483 | */ |
| 2484 | -function get_next_comments_link( $label = '', $max_page = 0 ) { |
|
| 2484 | +function get_next_comments_link($label = '', $max_page = 0) { |
|
| 2485 | 2485 | global $wp_query; |
| 2486 | 2486 | |
| 2487 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2487 | + if ( ! is_singular() || ! get_option('page_comments')) |
|
| 2488 | 2488 | return; |
| 2489 | 2489 | |
| 2490 | 2490 | $page = get_query_var('cpage'); |
| 2491 | 2491 | |
| 2492 | - if ( ! $page ) { |
|
| 2492 | + if ( ! $page) { |
|
| 2493 | 2493 | $page = 1; |
| 2494 | 2494 | } |
| 2495 | 2495 | |
| 2496 | 2496 | $nextpage = intval($page) + 1; |
| 2497 | 2497 | |
| 2498 | - if ( empty($max_page) ) |
|
| 2498 | + if (empty($max_page)) |
|
| 2499 | 2499 | $max_page = $wp_query->max_num_comment_pages; |
| 2500 | 2500 | |
| 2501 | - if ( empty($max_page) ) |
|
| 2501 | + if (empty($max_page)) |
|
| 2502 | 2502 | $max_page = get_comment_pages_count(); |
| 2503 | 2503 | |
| 2504 | - if ( $nextpage > $max_page ) |
|
| 2504 | + if ($nextpage > $max_page) |
|
| 2505 | 2505 | return; |
| 2506 | 2506 | |
| 2507 | - if ( empty($label) ) |
|
| 2507 | + if (empty($label)) |
|
| 2508 | 2508 | $label = __('Newer Comments »'); |
| 2509 | 2509 | |
| 2510 | 2510 | /** |
@@ -2514,7 +2514,7 @@ discard block |
||
| 2514 | 2514 | * |
| 2515 | 2515 | * @param string $attributes Attributes for the anchor tag. |
| 2516 | 2516 | */ |
| 2517 | - return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; |
|
| 2517 | + return '<a href="'.esc_url(get_comments_pagenum_link($nextpage, $max_page)).'" '.apply_filters('next_comments_link_attributes', '').'>'.preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2518 | 2518 | } |
| 2519 | 2519 | |
| 2520 | 2520 | /** |
@@ -2525,8 +2525,8 @@ discard block |
||
| 2525 | 2525 | * @param string $label Optional. Label for link text. |
| 2526 | 2526 | * @param int $max_page Optional. Max page. |
| 2527 | 2527 | */ |
| 2528 | -function next_comments_link( $label = '', $max_page = 0 ) { |
|
| 2529 | - echo get_next_comments_link( $label, $max_page ); |
|
| 2528 | +function next_comments_link($label = '', $max_page = 0) { |
|
| 2529 | + echo get_next_comments_link($label, $max_page); |
|
| 2530 | 2530 | } |
| 2531 | 2531 | |
| 2532 | 2532 | /** |
@@ -2537,18 +2537,18 @@ discard block |
||
| 2537 | 2537 | * @param string $label Optional. Label for comments link text. |
| 2538 | 2538 | * @return string|void HTML-formatted link for the previous page of comments. |
| 2539 | 2539 | */ |
| 2540 | -function get_previous_comments_link( $label = '' ) { |
|
| 2541 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2540 | +function get_previous_comments_link($label = '') { |
|
| 2541 | + if ( ! is_singular() || ! get_option('page_comments')) |
|
| 2542 | 2542 | return; |
| 2543 | 2543 | |
| 2544 | 2544 | $page = get_query_var('cpage'); |
| 2545 | 2545 | |
| 2546 | - if ( intval($page) <= 1 ) |
|
| 2546 | + if (intval($page) <= 1) |
|
| 2547 | 2547 | return; |
| 2548 | 2548 | |
| 2549 | 2549 | $prevpage = intval($page) - 1; |
| 2550 | 2550 | |
| 2551 | - if ( empty($label) ) |
|
| 2551 | + if (empty($label)) |
|
| 2552 | 2552 | $label = __('« Older Comments'); |
| 2553 | 2553 | |
| 2554 | 2554 | /** |
@@ -2558,7 +2558,7 @@ discard block |
||
| 2558 | 2558 | * |
| 2559 | 2559 | * @param string $attributes Attributes for the anchor tag. |
| 2560 | 2560 | */ |
| 2561 | - return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; |
|
| 2561 | + return '<a href="'.esc_url(get_comments_pagenum_link($prevpage)).'" '.apply_filters('previous_comments_link_attributes', '').'>'.preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | 2564 | /** |
@@ -2568,8 +2568,8 @@ discard block |
||
| 2568 | 2568 | * |
| 2569 | 2569 | * @param string $label Optional. Label for comments link text. |
| 2570 | 2570 | */ |
| 2571 | -function previous_comments_link( $label = '' ) { |
|
| 2572 | - echo get_previous_comments_link( $label ); |
|
| 2571 | +function previous_comments_link($label = '') { |
|
| 2572 | + echo get_previous_comments_link($label); |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | /** |
@@ -2586,28 +2586,28 @@ discard block |
||
| 2586 | 2586 | function paginate_comments_links($args = array()) { |
| 2587 | 2587 | global $wp_rewrite; |
| 2588 | 2588 | |
| 2589 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2589 | + if ( ! is_singular() || ! get_option('page_comments')) |
|
| 2590 | 2590 | return; |
| 2591 | 2591 | |
| 2592 | 2592 | $page = get_query_var('cpage'); |
| 2593 | - if ( !$page ) |
|
| 2593 | + if ( ! $page) |
|
| 2594 | 2594 | $page = 1; |
| 2595 | 2595 | $max_page = get_comment_pages_count(); |
| 2596 | 2596 | $defaults = array( |
| 2597 | - 'base' => add_query_arg( 'cpage', '%#%' ), |
|
| 2597 | + 'base' => add_query_arg('cpage', '%#%'), |
|
| 2598 | 2598 | 'format' => '', |
| 2599 | 2599 | 'total' => $max_page, |
| 2600 | 2600 | 'current' => $page, |
| 2601 | 2601 | 'echo' => true, |
| 2602 | 2602 | 'add_fragment' => '#comments' |
| 2603 | 2603 | ); |
| 2604 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2605 | - $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2604 | + if ($wp_rewrite->using_permalinks()) |
|
| 2605 | + $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()).$wp_rewrite->comments_pagination_base.'-%#%', 'commentpaged'); |
|
| 2606 | 2606 | |
| 2607 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2608 | - $page_links = paginate_links( $args ); |
|
| 2607 | + $args = wp_parse_args($args, $defaults); |
|
| 2608 | + $page_links = paginate_links($args); |
|
| 2609 | 2609 | |
| 2610 | - if ( $args['echo'] ) |
|
| 2610 | + if ($args['echo']) |
|
| 2611 | 2611 | echo $page_links; |
| 2612 | 2612 | else |
| 2613 | 2613 | return $page_links; |
@@ -2629,11 +2629,11 @@ discard block |
||
| 2629 | 2629 | function get_shortcut_link() { |
| 2630 | 2630 | global $is_IE, $wp_version; |
| 2631 | 2631 | |
| 2632 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); |
|
| 2632 | + include_once(ABSPATH.'wp-admin/includes/class-wp-press-this.php'); |
|
| 2633 | 2633 | $bookmarklet_version = $GLOBALS['wp_press_this']->version; |
| 2634 | 2634 | $link = ''; |
| 2635 | 2635 | |
| 2636 | - if ( $is_IE ) { |
|
| 2636 | + if ($is_IE) { |
|
| 2637 | 2637 | /** |
| 2638 | 2638 | * Return the old/shorter bookmarklet code for MSIE 8 and lower, |
| 2639 | 2639 | * since they only support a max length of ~2000 characters for |
@@ -2643,27 +2643,27 @@ discard block |
||
| 2643 | 2643 | */ |
| 2644 | 2644 | $ua = $_SERVER['HTTP_USER_AGENT']; |
| 2645 | 2645 | |
| 2646 | - if ( ! empty( $ua ) && preg_match( '/\bMSIE (\d)/', $ua, $matches ) && (int) $matches[1] <= 8 ) { |
|
| 2647 | - $url = wp_json_encode( admin_url( 'press-this.php' ) ); |
|
| 2646 | + if ( ! empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) { |
|
| 2647 | + $url = wp_json_encode(admin_url('press-this.php')); |
|
| 2648 | 2648 | |
| 2649 | - $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . |
|
| 2650 | - 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . |
|
| 2651 | - 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' . |
|
| 2652 | - 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . |
|
| 2649 | + $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,'. |
|
| 2650 | + 's=(e?e():(k)?k():(x?x.createRange().text:0)),f='.$url.',l=d.location,e=encodeURIComponent,'. |
|
| 2651 | + 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v='.$bookmarklet_version.'";'. |
|
| 2652 | + 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};'. |
|
| 2653 | 2653 | 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)'; |
| 2654 | 2654 | } |
| 2655 | 2655 | } |
| 2656 | 2656 | |
| 2657 | - if ( empty( $link ) ) { |
|
| 2658 | - $src = @file_get_contents( ABSPATH . 'wp-admin/js/bookmarklet.min.js' ); |
|
| 2657 | + if (empty($link)) { |
|
| 2658 | + $src = @file_get_contents(ABSPATH.'wp-admin/js/bookmarklet.min.js'); |
|
| 2659 | 2659 | |
| 2660 | - if ( $src ) { |
|
| 2661 | - $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version ); |
|
| 2662 | - $link = 'javascript:' . str_replace( 'window.pt_url', $url, $src ); |
|
| 2660 | + if ($src) { |
|
| 2661 | + $url = wp_json_encode(admin_url('press-this.php').'?v='.$bookmarklet_version); |
|
| 2662 | + $link = 'javascript:'.str_replace('window.pt_url', $url, $src); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | } |
| 2665 | 2665 | |
| 2666 | - $link = str_replace( array( "\r", "\n", "\t" ), '', $link ); |
|
| 2666 | + $link = str_replace(array("\r", "\n", "\t"), '', $link); |
|
| 2667 | 2667 | |
| 2668 | 2668 | /** |
| 2669 | 2669 | * Filter the Press This bookmarklet link. |
@@ -2672,7 +2672,7 @@ discard block |
||
| 2672 | 2672 | * |
| 2673 | 2673 | * @param string $link The Press This bookmarklet link. |
| 2674 | 2674 | */ |
| 2675 | - return apply_filters( 'shortcut_link', $link ); |
|
| 2675 | + return apply_filters('shortcut_link', $link); |
|
| 2676 | 2676 | } |
| 2677 | 2677 | |
| 2678 | 2678 | /** |
@@ -2689,8 +2689,8 @@ discard block |
||
| 2689 | 2689 | * 'http', 'https', or 'relative'. Default null. |
| 2690 | 2690 | * @return string Home url link with optional path appended. |
| 2691 | 2691 | */ |
| 2692 | -function home_url( $path = '', $scheme = null ) { |
|
| 2693 | - return get_home_url( null, $path, $scheme ); |
|
| 2692 | +function home_url($path = '', $scheme = null) { |
|
| 2693 | + return get_home_url(null, $path, $scheme); |
|
| 2694 | 2694 | } |
| 2695 | 2695 | |
| 2696 | 2696 | /** |
@@ -2711,28 +2711,28 @@ discard block |
||
| 2711 | 2711 | * 'http', 'https', 'relative', or null. Default null. |
| 2712 | 2712 | * @return string Home URL link with optional path appended. |
| 2713 | 2713 | */ |
| 2714 | -function get_home_url( $blog_id = null, $path = '', $scheme = null ) { |
|
| 2714 | +function get_home_url($blog_id = null, $path = '', $scheme = null) { |
|
| 2715 | 2715 | $orig_scheme = $scheme; |
| 2716 | 2716 | |
| 2717 | - if ( empty( $blog_id ) || !is_multisite() ) { |
|
| 2718 | - $url = get_option( 'home' ); |
|
| 2717 | + if (empty($blog_id) || ! is_multisite()) { |
|
| 2718 | + $url = get_option('home'); |
|
| 2719 | 2719 | } else { |
| 2720 | - switch_to_blog( $blog_id ); |
|
| 2721 | - $url = get_option( 'home' ); |
|
| 2720 | + switch_to_blog($blog_id); |
|
| 2721 | + $url = get_option('home'); |
|
| 2722 | 2722 | restore_current_blog(); |
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
|
| 2726 | - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) |
|
| 2725 | + if ( ! in_array($scheme, array('http', 'https', 'relative'))) { |
|
| 2726 | + if (is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow']) |
|
| 2727 | 2727 | $scheme = 'https'; |
| 2728 | 2728 | else |
| 2729 | - $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 2729 | + $scheme = parse_url($url, PHP_URL_SCHEME); |
|
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | - $url = set_url_scheme( $url, $scheme ); |
|
| 2732 | + $url = set_url_scheme($url, $scheme); |
|
| 2733 | 2733 | |
| 2734 | - if ( $path && is_string( $path ) ) |
|
| 2735 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 2734 | + if ($path && is_string($path)) |
|
| 2735 | + $url .= '/'.ltrim($path, '/'); |
|
| 2736 | 2736 | |
| 2737 | 2737 | /** |
| 2738 | 2738 | * Filter the home URL. |
@@ -2744,7 +2744,7 @@ discard block |
||
| 2744 | 2744 | * @param string|null $orig_scheme Scheme to give the home URL context. Accepts 'http', 'https', 'relative' or null. |
| 2745 | 2745 | * @param int|null $blog_id Blog ID, or null for the current blog. |
| 2746 | 2746 | */ |
| 2747 | - return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); |
|
| 2747 | + return apply_filters('home_url', $url, $path, $orig_scheme, $blog_id); |
|
| 2748 | 2748 | } |
| 2749 | 2749 | |
| 2750 | 2750 | /** |
@@ -2760,8 +2760,8 @@ discard block |
||
| 2760 | 2760 | * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme(). |
| 2761 | 2761 | * @return string Site url link with optional path appended. |
| 2762 | 2762 | */ |
| 2763 | -function site_url( $path = '', $scheme = null ) { |
|
| 2764 | - return get_site_url( null, $path, $scheme ); |
|
| 2763 | +function site_url($path = '', $scheme = null) { |
|
| 2764 | + return get_site_url(null, $path, $scheme); |
|
| 2765 | 2765 | } |
| 2766 | 2766 | |
| 2767 | 2767 | /** |
@@ -2780,19 +2780,19 @@ discard block |
||
| 2780 | 2780 | * 'relative'. Default null. |
| 2781 | 2781 | * @return string Site url link with optional path appended. |
| 2782 | 2782 | */ |
| 2783 | -function get_site_url( $blog_id = null, $path = '', $scheme = null ) { |
|
| 2784 | - if ( empty( $blog_id ) || !is_multisite() ) { |
|
| 2785 | - $url = get_option( 'siteurl' ); |
|
| 2783 | +function get_site_url($blog_id = null, $path = '', $scheme = null) { |
|
| 2784 | + if (empty($blog_id) || ! is_multisite()) { |
|
| 2785 | + $url = get_option('siteurl'); |
|
| 2786 | 2786 | } else { |
| 2787 | - switch_to_blog( $blog_id ); |
|
| 2788 | - $url = get_option( 'siteurl' ); |
|
| 2787 | + switch_to_blog($blog_id); |
|
| 2788 | + $url = get_option('siteurl'); |
|
| 2789 | 2789 | restore_current_blog(); |
| 2790 | 2790 | } |
| 2791 | 2791 | |
| 2792 | - $url = set_url_scheme( $url, $scheme ); |
|
| 2792 | + $url = set_url_scheme($url, $scheme); |
|
| 2793 | 2793 | |
| 2794 | - if ( $path && is_string( $path ) ) |
|
| 2795 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 2794 | + if ($path && is_string($path)) |
|
| 2795 | + $url .= '/'.ltrim($path, '/'); |
|
| 2796 | 2796 | |
| 2797 | 2797 | /** |
| 2798 | 2798 | * Filter the site URL. |
@@ -2805,7 +2805,7 @@ discard block |
||
| 2805 | 2805 | * 'login_post', 'admin', 'relative' or null. |
| 2806 | 2806 | * @param int|null $blog_id Blog ID, or null for the current blog. |
| 2807 | 2807 | */ |
| 2808 | - return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); |
|
| 2808 | + return apply_filters('site_url', $url, $path, $scheme, $blog_id); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | /** |
@@ -2817,8 +2817,8 @@ discard block |
||
| 2817 | 2817 | * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 2818 | 2818 | * @return string Admin url link with optional path appended. |
| 2819 | 2819 | */ |
| 2820 | -function admin_url( $path = '', $scheme = 'admin' ) { |
|
| 2821 | - return get_admin_url( null, $path, $scheme ); |
|
| 2820 | +function admin_url($path = '', $scheme = 'admin') { |
|
| 2821 | + return get_admin_url(null, $path, $scheme); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | 2824 | /** |
@@ -2833,11 +2833,11 @@ discard block |
||
| 2833 | 2833 | * {@see force_ssl_admin()} and {@see is_ssl()}. |
| 2834 | 2834 | * @return string Admin url link with optional path appended. |
| 2835 | 2835 | */ |
| 2836 | -function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { |
|
| 2836 | +function get_admin_url($blog_id = null, $path = '', $scheme = 'admin') { |
|
| 2837 | 2837 | $url = get_site_url($blog_id, 'wp-admin/', $scheme); |
| 2838 | 2838 | |
| 2839 | - if ( $path && is_string( $path ) ) |
|
| 2840 | - $url .= ltrim( $path, '/' ); |
|
| 2839 | + if ($path && is_string($path)) |
|
| 2840 | + $url .= ltrim($path, '/'); |
|
| 2841 | 2841 | |
| 2842 | 2842 | /** |
| 2843 | 2843 | * Filter the admin area URL. |
@@ -2848,7 +2848,7 @@ discard block |
||
| 2848 | 2848 | * @param string $path Path relative to the admin area URL. Blank string if no path is specified. |
| 2849 | 2849 | * @param int|null $blog_id Blog ID, or null for the current blog. |
| 2850 | 2850 | */ |
| 2851 | - return apply_filters( 'admin_url', $url, $path, $blog_id ); |
|
| 2851 | + return apply_filters('admin_url', $url, $path, $blog_id); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
@@ -2860,10 +2860,10 @@ discard block |
||
| 2860 | 2860 | * @param string $scheme Optional. Scheme to give the includes url context. |
| 2861 | 2861 | * @return string Includes url link with optional path appended. |
| 2862 | 2862 | */ |
| 2863 | -function includes_url( $path = '', $scheme = null ) { |
|
| 2864 | - $url = site_url( '/' . WPINC . '/', $scheme ); |
|
| 2863 | +function includes_url($path = '', $scheme = null) { |
|
| 2864 | + $url = site_url('/'.WPINC.'/', $scheme); |
|
| 2865 | 2865 | |
| 2866 | - if ( $path && is_string( $path ) ) |
|
| 2866 | + if ($path && is_string($path)) |
|
| 2867 | 2867 | $url .= ltrim($path, '/'); |
| 2868 | 2868 | |
| 2869 | 2869 | /** |
@@ -2875,7 +2875,7 @@ discard block |
||
| 2875 | 2875 | * @param string $path Path relative to the URL to the wp-includes directory. Blank string |
| 2876 | 2876 | * if no path is specified. |
| 2877 | 2877 | */ |
| 2878 | - return apply_filters( 'includes_url', $url, $path ); |
|
| 2878 | + return apply_filters('includes_url', $url, $path); |
|
| 2879 | 2879 | } |
| 2880 | 2880 | |
| 2881 | 2881 | /** |
@@ -2887,10 +2887,10 @@ discard block |
||
| 2887 | 2887 | * @return string Content url link with optional path appended. |
| 2888 | 2888 | */ |
| 2889 | 2889 | function content_url($path = '') { |
| 2890 | - $url = set_url_scheme( WP_CONTENT_URL ); |
|
| 2890 | + $url = set_url_scheme(WP_CONTENT_URL); |
|
| 2891 | 2891 | |
| 2892 | - if ( $path && is_string( $path ) ) |
|
| 2893 | - $url .= '/' . ltrim($path, '/'); |
|
| 2892 | + if ($path && is_string($path)) |
|
| 2893 | + $url .= '/'.ltrim($path, '/'); |
|
| 2894 | 2894 | |
| 2895 | 2895 | /** |
| 2896 | 2896 | * Filter the URL to the content directory. |
@@ -2901,7 +2901,7 @@ discard block |
||
| 2901 | 2901 | * @param string $path Path relative to the URL to the content directory. Blank string |
| 2902 | 2902 | * if no path is specified. |
| 2903 | 2903 | */ |
| 2904 | - return apply_filters( 'content_url', $url, $path); |
|
| 2904 | + return apply_filters('content_url', $url, $path); |
|
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | 2907 | /** |
@@ -2918,28 +2918,28 @@ discard block |
||
| 2918 | 2918 | * Typically this is done by passing `__FILE__` as the argument. |
| 2919 | 2919 | * @return string Plugins URL link with optional paths appended. |
| 2920 | 2920 | */ |
| 2921 | -function plugins_url( $path = '', $plugin = '' ) { |
|
| 2921 | +function plugins_url($path = '', $plugin = '') { |
|
| 2922 | 2922 | |
| 2923 | - $path = wp_normalize_path( $path ); |
|
| 2924 | - $plugin = wp_normalize_path( $plugin ); |
|
| 2925 | - $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); |
|
| 2923 | + $path = wp_normalize_path($path); |
|
| 2924 | + $plugin = wp_normalize_path($plugin); |
|
| 2925 | + $mu_plugin_dir = wp_normalize_path(WPMU_PLUGIN_DIR); |
|
| 2926 | 2926 | |
| 2927 | - if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) |
|
| 2927 | + if ( ! empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir)) |
|
| 2928 | 2928 | $url = WPMU_PLUGIN_URL; |
| 2929 | 2929 | else |
| 2930 | 2930 | $url = WP_PLUGIN_URL; |
| 2931 | 2931 | |
| 2932 | 2932 | |
| 2933 | - $url = set_url_scheme( $url ); |
|
| 2933 | + $url = set_url_scheme($url); |
|
| 2934 | 2934 | |
| 2935 | - if ( !empty($plugin) && is_string($plugin) ) { |
|
| 2935 | + if ( ! empty($plugin) && is_string($plugin)) { |
|
| 2936 | 2936 | $folder = dirname(plugin_basename($plugin)); |
| 2937 | - if ( '.' != $folder ) |
|
| 2938 | - $url .= '/' . ltrim($folder, '/'); |
|
| 2937 | + if ('.' != $folder) |
|
| 2938 | + $url .= '/'.ltrim($folder, '/'); |
|
| 2939 | 2939 | } |
| 2940 | 2940 | |
| 2941 | - if ( $path && is_string( $path ) ) |
|
| 2942 | - $url .= '/' . ltrim($path, '/'); |
|
| 2941 | + if ($path && is_string($path)) |
|
| 2942 | + $url .= '/'.ltrim($path, '/'); |
|
| 2943 | 2943 | |
| 2944 | 2944 | /** |
| 2945 | 2945 | * Filter the URL to the plugins directory. |
@@ -2952,7 +2952,7 @@ discard block |
||
| 2952 | 2952 | * @param string $plugin The plugin file path to be relative to. Blank string if no plugin |
| 2953 | 2953 | * is specified. |
| 2954 | 2954 | */ |
| 2955 | - return apply_filters( 'plugins_url', $url, $path, $plugin ); |
|
| 2955 | + return apply_filters('plugins_url', $url, $path, $plugin); |
|
| 2956 | 2956 | } |
| 2957 | 2957 | |
| 2958 | 2958 | /** |
@@ -2968,19 +2968,19 @@ discard block |
||
| 2968 | 2968 | * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme(). |
| 2969 | 2969 | * @return string Site url link with optional path appended. |
| 2970 | 2970 | */ |
| 2971 | -function network_site_url( $path = '', $scheme = null ) { |
|
| 2972 | - if ( ! is_multisite() ) |
|
| 2971 | +function network_site_url($path = '', $scheme = null) { |
|
| 2972 | + if ( ! is_multisite()) |
|
| 2973 | 2973 | return site_url($path, $scheme); |
| 2974 | 2974 | |
| 2975 | 2975 | $current_site = get_current_site(); |
| 2976 | 2976 | |
| 2977 | - if ( 'relative' == $scheme ) |
|
| 2977 | + if ('relative' == $scheme) |
|
| 2978 | 2978 | $url = $current_site->path; |
| 2979 | 2979 | else |
| 2980 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 2980 | + $url = set_url_scheme('http://'.$current_site->domain.$current_site->path, $scheme); |
|
| 2981 | 2981 | |
| 2982 | - if ( $path && is_string( $path ) ) |
|
| 2983 | - $url .= ltrim( $path, '/' ); |
|
| 2982 | + if ($path && is_string($path)) |
|
| 2983 | + $url .= ltrim($path, '/'); |
|
| 2984 | 2984 | |
| 2985 | 2985 | /** |
| 2986 | 2986 | * Filter the network site URL. |
@@ -2993,7 +2993,7 @@ discard block |
||
| 2993 | 2993 | * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https', |
| 2994 | 2994 | * 'relative' or null. |
| 2995 | 2995 | */ |
| 2996 | - return apply_filters( 'network_site_url', $url, $path, $scheme ); |
|
| 2996 | + return apply_filters('network_site_url', $url, $path, $scheme); |
|
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | 2999 | /** |
@@ -3010,23 +3010,23 @@ discard block |
||
| 3010 | 3010 | * 'http', 'https', or 'relative'. Default null. |
| 3011 | 3011 | * @return string Home url link with optional path appended. |
| 3012 | 3012 | */ |
| 3013 | -function network_home_url( $path = '', $scheme = null ) { |
|
| 3014 | - if ( ! is_multisite() ) |
|
| 3013 | +function network_home_url($path = '', $scheme = null) { |
|
| 3014 | + if ( ! is_multisite()) |
|
| 3015 | 3015 | return home_url($path, $scheme); |
| 3016 | 3016 | |
| 3017 | 3017 | $current_site = get_current_site(); |
| 3018 | 3018 | $orig_scheme = $scheme; |
| 3019 | 3019 | |
| 3020 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) |
|
| 3020 | + if ( ! in_array($scheme, array('http', 'https', 'relative'))) |
|
| 3021 | 3021 | $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
| 3022 | 3022 | |
| 3023 | - if ( 'relative' == $scheme ) |
|
| 3023 | + if ('relative' == $scheme) |
|
| 3024 | 3024 | $url = $current_site->path; |
| 3025 | 3025 | else |
| 3026 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3026 | + $url = set_url_scheme('http://'.$current_site->domain.$current_site->path, $scheme); |
|
| 3027 | 3027 | |
| 3028 | - if ( $path && is_string( $path ) ) |
|
| 3029 | - $url .= ltrim( $path, '/' ); |
|
| 3028 | + if ($path && is_string($path)) |
|
| 3029 | + $url .= ltrim($path, '/'); |
|
| 3030 | 3030 | |
| 3031 | 3031 | /** |
| 3032 | 3032 | * Filter the network home URL. |
@@ -3039,7 +3039,7 @@ discard block |
||
| 3039 | 3039 | * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https', |
| 3040 | 3040 | * 'relative' or null. |
| 3041 | 3041 | */ |
| 3042 | - return apply_filters( 'network_home_url', $url, $path, $orig_scheme); |
|
| 3042 | + return apply_filters('network_home_url', $url, $path, $orig_scheme); |
|
| 3043 | 3043 | } |
| 3044 | 3044 | |
| 3045 | 3045 | /** |
@@ -3051,13 +3051,13 @@ discard block |
||
| 3051 | 3051 | * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3052 | 3052 | * @return string Admin url link with optional path appended. |
| 3053 | 3053 | */ |
| 3054 | -function network_admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3055 | - if ( ! is_multisite() ) |
|
| 3056 | - return admin_url( $path, $scheme ); |
|
| 3054 | +function network_admin_url($path = '', $scheme = 'admin') { |
|
| 3055 | + if ( ! is_multisite()) |
|
| 3056 | + return admin_url($path, $scheme); |
|
| 3057 | 3057 | |
| 3058 | 3058 | $url = network_site_url('wp-admin/network/', $scheme); |
| 3059 | 3059 | |
| 3060 | - if ( $path && is_string( $path ) ) |
|
| 3060 | + if ($path && is_string($path)) |
|
| 3061 | 3061 | $url .= ltrim($path, '/'); |
| 3062 | 3062 | |
| 3063 | 3063 | /** |
@@ -3069,7 +3069,7 @@ discard block |
||
| 3069 | 3069 | * @param string $path Path relative to the network admin URL. Blank string if |
| 3070 | 3070 | * no path is specified. |
| 3071 | 3071 | */ |
| 3072 | - return apply_filters( 'network_admin_url', $url, $path ); |
|
| 3072 | + return apply_filters('network_admin_url', $url, $path); |
|
| 3073 | 3073 | } |
| 3074 | 3074 | |
| 3075 | 3075 | /** |
@@ -3081,10 +3081,10 @@ discard block |
||
| 3081 | 3081 | * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3082 | 3082 | * @return string Admin url link with optional path appended. |
| 3083 | 3083 | */ |
| 3084 | -function user_admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3084 | +function user_admin_url($path = '', $scheme = 'admin') { |
|
| 3085 | 3085 | $url = network_site_url('wp-admin/user/', $scheme); |
| 3086 | 3086 | |
| 3087 | - if ( $path && is_string( $path ) ) |
|
| 3087 | + if ($path && is_string($path)) |
|
| 3088 | 3088 | $url .= ltrim($path, '/'); |
| 3089 | 3089 | |
| 3090 | 3090 | /** |
@@ -3096,7 +3096,7 @@ discard block |
||
| 3096 | 3096 | * @param string $path Path relative to the URL. Blank string if |
| 3097 | 3097 | * no path is specified. |
| 3098 | 3098 | */ |
| 3099 | - return apply_filters( 'user_admin_url', $url, $path ); |
|
| 3099 | + return apply_filters('user_admin_url', $url, $path); |
|
| 3100 | 3100 | } |
| 3101 | 3101 | |
| 3102 | 3102 | /** |
@@ -3109,9 +3109,9 @@ discard block |
||
| 3109 | 3109 | * @return string Admin url link with optional path appended. |
| 3110 | 3110 | */ |
| 3111 | 3111 | function self_admin_url($path = '', $scheme = 'admin') { |
| 3112 | - if ( is_network_admin() ) |
|
| 3112 | + if (is_network_admin()) |
|
| 3113 | 3113 | return network_admin_url($path, $scheme); |
| 3114 | - elseif ( is_user_admin() ) |
|
| 3114 | + elseif (is_user_admin()) |
|
| 3115 | 3115 | return user_admin_url($path, $scheme); |
| 3116 | 3116 | else |
| 3117 | 3117 | return admin_url($path, $scheme); |
@@ -3126,27 +3126,27 @@ discard block |
||
| 3126 | 3126 | * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'. |
| 3127 | 3127 | * @return string $url URL with chosen scheme. |
| 3128 | 3128 | */ |
| 3129 | -function set_url_scheme( $url, $scheme = null ) { |
|
| 3129 | +function set_url_scheme($url, $scheme = null) { |
|
| 3130 | 3130 | $orig_scheme = $scheme; |
| 3131 | 3131 | |
| 3132 | - if ( ! $scheme ) { |
|
| 3132 | + if ( ! $scheme) { |
|
| 3133 | 3133 | $scheme = is_ssl() ? 'https' : 'http'; |
| 3134 | - } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) { |
|
| 3134 | + } elseif ($scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc') { |
|
| 3135 | 3135 | $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; |
| 3136 | - } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) { |
|
| 3136 | + } elseif ($scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative') { |
|
| 3137 | 3137 | $scheme = is_ssl() ? 'https' : 'http'; |
| 3138 | 3138 | } |
| 3139 | 3139 | |
| 3140 | - $url = trim( $url ); |
|
| 3141 | - if ( substr( $url, 0, 2 ) === '//' ) |
|
| 3142 | - $url = 'http:' . $url; |
|
| 3140 | + $url = trim($url); |
|
| 3141 | + if (substr($url, 0, 2) === '//') |
|
| 3142 | + $url = 'http:'.$url; |
|
| 3143 | 3143 | |
| 3144 | - if ( 'relative' == $scheme ) { |
|
| 3145 | - $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); |
|
| 3146 | - if ( $url !== '' && $url[0] === '/' ) |
|
| 3147 | - $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3144 | + if ('relative' == $scheme) { |
|
| 3145 | + $url = ltrim(preg_replace('#^\w+://[^/]*#', '', $url)); |
|
| 3146 | + if ($url !== '' && $url[0] === '/') |
|
| 3147 | + $url = '/'.ltrim($url, "/ \t\n\r\0\x0B"); |
|
| 3148 | 3148 | } else { |
| 3149 | - $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); |
|
| 3149 | + $url = preg_replace('#^\w+://#', $scheme.'://', $url); |
|
| 3150 | 3150 | } |
| 3151 | 3151 | |
| 3152 | 3152 | /** |
@@ -3159,7 +3159,7 @@ discard block |
||
| 3159 | 3159 | * @param string $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', |
| 3160 | 3160 | * 'login_post', 'admin', 'rpc', or 'relative'. |
| 3161 | 3161 | */ |
| 3162 | - return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); |
|
| 3162 | + return apply_filters('set_url_scheme', $url, $scheme, $orig_scheme); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | |
| 3165 | 3165 | /** |
@@ -3176,24 +3176,24 @@ discard block |
||
| 3176 | 3176 | * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3177 | 3177 | * @return string Dashboard url link with optional path appended. |
| 3178 | 3178 | */ |
| 3179 | -function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) { |
|
| 3179 | +function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin') { |
|
| 3180 | 3180 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3181 | 3181 | |
| 3182 | - $blogs = get_blogs_of_user( $user_id ); |
|
| 3183 | - if ( ! is_super_admin() && empty($blogs) ) { |
|
| 3184 | - $url = user_admin_url( $path, $scheme ); |
|
| 3185 | - } elseif ( ! is_multisite() ) { |
|
| 3186 | - $url = admin_url( $path, $scheme ); |
|
| 3182 | + $blogs = get_blogs_of_user($user_id); |
|
| 3183 | + if ( ! is_super_admin() && empty($blogs)) { |
|
| 3184 | + $url = user_admin_url($path, $scheme); |
|
| 3185 | + } elseif ( ! is_multisite()) { |
|
| 3186 | + $url = admin_url($path, $scheme); |
|
| 3187 | 3187 | } else { |
| 3188 | 3188 | $current_blog = get_current_blog_id(); |
| 3189 | - if ( $current_blog && ( is_super_admin( $user_id ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) { |
|
| 3190 | - $url = admin_url( $path, $scheme ); |
|
| 3189 | + if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) { |
|
| 3190 | + $url = admin_url($path, $scheme); |
|
| 3191 | 3191 | } else { |
| 3192 | - $active = get_active_blog_for_user( $user_id ); |
|
| 3193 | - if ( $active ) |
|
| 3194 | - $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3192 | + $active = get_active_blog_for_user($user_id); |
|
| 3193 | + if ($active) |
|
| 3194 | + $url = get_admin_url($active->blog_id, $path, $scheme); |
|
| 3195 | 3195 | else |
| 3196 | - $url = user_admin_url( $path, $scheme ); |
|
| 3196 | + $url = user_admin_url($path, $scheme); |
|
| 3197 | 3197 | } |
| 3198 | 3198 | } |
| 3199 | 3199 | |
@@ -3208,7 +3208,7 @@ discard block |
||
| 3208 | 3208 | * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', |
| 3209 | 3209 | * 'login_post', 'admin', 'relative' or null. |
| 3210 | 3210 | */ |
| 3211 | - return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme); |
|
| 3211 | + return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme); |
|
| 3212 | 3212 | } |
| 3213 | 3213 | |
| 3214 | 3214 | /** |
@@ -3221,15 +3221,15 @@ discard block |
||
| 3221 | 3221 | * 'http' or 'https' can be passed to force those schemes. |
| 3222 | 3222 | * @return string Dashboard url link with optional path appended. |
| 3223 | 3223 | */ |
| 3224 | -function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) { |
|
| 3224 | +function get_edit_profile_url($user_id = 0, $scheme = 'admin') { |
|
| 3225 | 3225 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3226 | 3226 | |
| 3227 | - if ( is_user_admin() ) |
|
| 3228 | - $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3229 | - elseif ( is_network_admin() ) |
|
| 3230 | - $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3227 | + if (is_user_admin()) |
|
| 3228 | + $url = user_admin_url('profile.php', $scheme); |
|
| 3229 | + elseif (is_network_admin()) |
|
| 3230 | + $url = network_admin_url('profile.php', $scheme); |
|
| 3231 | 3231 | else |
| 3232 | - $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3232 | + $url = get_dashboard_url($user_id, 'profile.php', $scheme); |
|
| 3233 | 3233 | |
| 3234 | 3234 | /** |
| 3235 | 3235 | * Filter the URL for a user's profile editor. |
@@ -3241,7 +3241,7 @@ discard block |
||
| 3241 | 3241 | * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', |
| 3242 | 3242 | * 'login_post', 'admin', 'relative' or null. |
| 3243 | 3243 | */ |
| 3244 | - return apply_filters( 'edit_profile_url', $url, $user_id, $scheme); |
|
| 3244 | + return apply_filters('edit_profile_url', $url, $user_id, $scheme); |
|
| 3245 | 3245 | } |
| 3246 | 3246 | |
| 3247 | 3247 | /** |
@@ -3252,17 +3252,17 @@ discard block |
||
| 3252 | 3252 | * @global WP_Query $wp_the_query |
| 3253 | 3253 | */ |
| 3254 | 3254 | function rel_canonical() { |
| 3255 | - if ( !is_singular() ) |
|
| 3255 | + if ( ! is_singular()) |
|
| 3256 | 3256 | return; |
| 3257 | 3257 | |
| 3258 | 3258 | global $wp_the_query; |
| 3259 | - if ( !$id = $wp_the_query->get_queried_object_id() ) |
|
| 3259 | + if ( ! $id = $wp_the_query->get_queried_object_id()) |
|
| 3260 | 3260 | return; |
| 3261 | 3261 | |
| 3262 | - $link = get_permalink( $id ); |
|
| 3262 | + $link = get_permalink($id); |
|
| 3263 | 3263 | |
| 3264 | - if ( $page = get_query_var('cpage') ) |
|
| 3265 | - $link = get_comments_pagenum_link( $page ); |
|
| 3264 | + if ($page = get_query_var('cpage')) |
|
| 3265 | + $link = get_comments_pagenum_link($page); |
|
| 3266 | 3266 | |
| 3267 | 3267 | echo "<link rel='canonical' href='$link' />\n"; |
| 3268 | 3268 | } |
@@ -3301,32 +3301,32 @@ discard block |
||
| 3301 | 3301 | * @param string $context The context for the link. One of 'post' or 'query', |
| 3302 | 3302 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
| 3303 | 3303 | */ |
| 3304 | - $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); |
|
| 3304 | + $shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs); |
|
| 3305 | 3305 | |
| 3306 | - if ( false !== $shortlink ) |
|
| 3306 | + if (false !== $shortlink) |
|
| 3307 | 3307 | return $shortlink; |
| 3308 | 3308 | |
| 3309 | 3309 | global $wp_query; |
| 3310 | 3310 | $post_id = 0; |
| 3311 | - if ( 'query' == $context && is_singular() ) { |
|
| 3311 | + if ('query' == $context && is_singular()) { |
|
| 3312 | 3312 | $post_id = $wp_query->get_queried_object_id(); |
| 3313 | - $post = get_post( $post_id ); |
|
| 3314 | - } elseif ( 'post' == $context ) { |
|
| 3315 | - $post = get_post( $id ); |
|
| 3316 | - if ( ! empty( $post->ID ) ) |
|
| 3313 | + $post = get_post($post_id); |
|
| 3314 | + } elseif ('post' == $context) { |
|
| 3315 | + $post = get_post($id); |
|
| 3316 | + if ( ! empty($post->ID)) |
|
| 3317 | 3317 | $post_id = $post->ID; |
| 3318 | 3318 | } |
| 3319 | 3319 | |
| 3320 | 3320 | $shortlink = ''; |
| 3321 | 3321 | |
| 3322 | 3322 | // Return p= link for all public post types. |
| 3323 | - if ( ! empty( $post_id ) ) { |
|
| 3324 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 3323 | + if ( ! empty($post_id)) { |
|
| 3324 | + $post_type = get_post_type_object($post->post_type); |
|
| 3325 | 3325 | |
| 3326 | - if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) { |
|
| 3327 | - $shortlink = home_url( '/' ); |
|
| 3328 | - } elseif ( $post_type->public ) { |
|
| 3329 | - $shortlink = home_url( '?p=' . $post_id ); |
|
| 3326 | + if ('page' === $post->post_type && $post->ID == get_option('page_on_front') && 'page' == get_option('show_on_front')) { |
|
| 3327 | + $shortlink = home_url('/'); |
|
| 3328 | + } elseif ($post_type->public) { |
|
| 3329 | + $shortlink = home_url('?p='.$post_id); |
|
| 3330 | 3330 | } |
| 3331 | 3331 | } |
| 3332 | 3332 | |
@@ -3340,7 +3340,7 @@ discard block |
||
| 3340 | 3340 | * @param string $context The context for the link. One of 'post' or 'query', |
| 3341 | 3341 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default. |
| 3342 | 3342 | */ |
| 3343 | - return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs ); |
|
| 3343 | + return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs); |
|
| 3344 | 3344 | } |
| 3345 | 3345 | |
| 3346 | 3346 | /** |
@@ -3351,12 +3351,12 @@ discard block |
||
| 3351 | 3351 | * @since 3.0.0 |
| 3352 | 3352 | */ |
| 3353 | 3353 | function wp_shortlink_wp_head() { |
| 3354 | - $shortlink = wp_get_shortlink( 0, 'query' ); |
|
| 3354 | + $shortlink = wp_get_shortlink(0, 'query'); |
|
| 3355 | 3355 | |
| 3356 | - if ( empty( $shortlink ) ) |
|
| 3356 | + if (empty($shortlink)) |
|
| 3357 | 3357 | return; |
| 3358 | 3358 | |
| 3359 | - echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n"; |
|
| 3359 | + echo "<link rel='shortlink' href='".esc_url($shortlink)."' />\n"; |
|
| 3360 | 3360 | } |
| 3361 | 3361 | |
| 3362 | 3362 | /** |
@@ -3367,15 +3367,15 @@ discard block |
||
| 3367 | 3367 | * @since 3.0.0 |
| 3368 | 3368 | */ |
| 3369 | 3369 | function wp_shortlink_header() { |
| 3370 | - if ( headers_sent() ) |
|
| 3370 | + if (headers_sent()) |
|
| 3371 | 3371 | return; |
| 3372 | 3372 | |
| 3373 | 3373 | $shortlink = wp_get_shortlink(0, 'query'); |
| 3374 | 3374 | |
| 3375 | - if ( empty($shortlink) ) |
|
| 3375 | + if (empty($shortlink)) |
|
| 3376 | 3376 | return; |
| 3377 | 3377 | |
| 3378 | - header('Link: <' . $shortlink . '>; rel=shortlink', false); |
|
| 3378 | + header('Link: <'.$shortlink.'>; rel=shortlink', false); |
|
| 3379 | 3379 | } |
| 3380 | 3380 | |
| 3381 | 3381 | /** |
@@ -3392,19 +3392,19 @@ discard block |
||
| 3392 | 3392 | * @param string $before Optional HTML to display before the link. |
| 3393 | 3393 | * @param string $after Optional HTML to display after the link. |
| 3394 | 3394 | */ |
| 3395 | -function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { |
|
| 3395 | +function the_shortlink($text = '', $title = '', $before = '', $after = '') { |
|
| 3396 | 3396 | $post = get_post(); |
| 3397 | 3397 | |
| 3398 | - if ( empty( $text ) ) |
|
| 3398 | + if (empty($text)) |
|
| 3399 | 3399 | $text = __('This is the short link.'); |
| 3400 | 3400 | |
| 3401 | - if ( empty( $title ) ) |
|
| 3402 | - $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3401 | + if (empty($title)) |
|
| 3402 | + $title = the_title_attribute(array('echo' => false)); |
|
| 3403 | 3403 | |
| 3404 | - $shortlink = wp_get_shortlink( $post->ID ); |
|
| 3404 | + $shortlink = wp_get_shortlink($post->ID); |
|
| 3405 | 3405 | |
| 3406 | - if ( !empty( $shortlink ) ) { |
|
| 3407 | - $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; |
|
| 3406 | + if ( ! empty($shortlink)) { |
|
| 3407 | + $link = '<a rel="shortlink" href="'.esc_url($shortlink).'" title="'.$title.'">'.$text.'</a>'; |
|
| 3408 | 3408 | |
| 3409 | 3409 | /** |
| 3410 | 3410 | * Filter the shortlink anchor tag for a post. |
@@ -3416,7 +3416,7 @@ discard block |
||
| 3416 | 3416 | * @param string $text Shortlink's text. |
| 3417 | 3417 | * @param string $title Shortlink's title attribute. |
| 3418 | 3418 | */ |
| 3419 | - $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); |
|
| 3419 | + $link = apply_filters('the_shortlink', $link, $shortlink, $text, $title); |
|
| 3420 | 3420 | echo $before, $link, $after; |
| 3421 | 3421 | } |
| 3422 | 3422 | } |
@@ -3449,8 +3449,8 @@ discard block |
||
| 3449 | 3449 | * } |
| 3450 | 3450 | * @return false|string The URL of the avatar we found, or false if we couldn't find an avatar. |
| 3451 | 3451 | */ |
| 3452 | -function get_avatar_url( $id_or_email, $args = null ) { |
|
| 3453 | - $args = get_avatar_data( $id_or_email, $args ); |
|
| 3452 | +function get_avatar_url($id_or_email, $args = null) { |
|
| 3453 | + $args = get_avatar_data($id_or_email, $args); |
|
| 3454 | 3454 | return $args['url']; |
| 3455 | 3455 | } |
| 3456 | 3456 | |
@@ -3490,51 +3490,51 @@ discard block |
||
| 3490 | 3490 | * @type string $url The URL of the avatar we found. |
| 3491 | 3491 | * } |
| 3492 | 3492 | */ |
| 3493 | -function get_avatar_data( $id_or_email, $args = null ) { |
|
| 3494 | - $args = wp_parse_args( $args, array( |
|
| 3493 | +function get_avatar_data($id_or_email, $args = null) { |
|
| 3494 | + $args = wp_parse_args($args, array( |
|
| 3495 | 3495 | 'size' => 96, |
| 3496 | 3496 | 'height' => null, |
| 3497 | 3497 | 'width' => null, |
| 3498 | - 'default' => get_option( 'avatar_default', 'mystery' ), |
|
| 3498 | + 'default' => get_option('avatar_default', 'mystery'), |
|
| 3499 | 3499 | 'force_default' => false, |
| 3500 | - 'rating' => get_option( 'avatar_rating' ), |
|
| 3500 | + 'rating' => get_option('avatar_rating'), |
|
| 3501 | 3501 | 'scheme' => null, |
| 3502 | 3502 | 'processed_args' => null, // if used, should be a reference |
| 3503 | 3503 | 'extra_attr' => '', |
| 3504 | - ) ); |
|
| 3504 | + )); |
|
| 3505 | 3505 | |
| 3506 | - if ( is_numeric( $args['size'] ) ) { |
|
| 3507 | - $args['size'] = absint( $args['size'] ); |
|
| 3508 | - if ( ! $args['size'] ) { |
|
| 3506 | + if (is_numeric($args['size'])) { |
|
| 3507 | + $args['size'] = absint($args['size']); |
|
| 3508 | + if ( ! $args['size']) { |
|
| 3509 | 3509 | $args['size'] = 96; |
| 3510 | 3510 | } |
| 3511 | 3511 | } else { |
| 3512 | 3512 | $args['size'] = 96; |
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | - if ( is_numeric( $args['height'] ) ) { |
|
| 3516 | - $args['height'] = absint( $args['height'] ); |
|
| 3517 | - if ( ! $args['height'] ) { |
|
| 3515 | + if (is_numeric($args['height'])) { |
|
| 3516 | + $args['height'] = absint($args['height']); |
|
| 3517 | + if ( ! $args['height']) { |
|
| 3518 | 3518 | $args['height'] = $args['size']; |
| 3519 | 3519 | } |
| 3520 | 3520 | } else { |
| 3521 | 3521 | $args['height'] = $args['size']; |
| 3522 | 3522 | } |
| 3523 | 3523 | |
| 3524 | - if ( is_numeric( $args['width'] ) ) { |
|
| 3525 | - $args['width'] = absint( $args['width'] ); |
|
| 3526 | - if ( ! $args['width'] ) { |
|
| 3524 | + if (is_numeric($args['width'])) { |
|
| 3525 | + $args['width'] = absint($args['width']); |
|
| 3526 | + if ( ! $args['width']) { |
|
| 3527 | 3527 | $args['width'] = $args['size']; |
| 3528 | 3528 | } |
| 3529 | 3529 | } else { |
| 3530 | 3530 | $args['width'] = $args['size']; |
| 3531 | 3531 | } |
| 3532 | 3532 | |
| 3533 | - if ( empty( $args['default'] ) ) { |
|
| 3534 | - $args['default'] = get_option( 'avatar_default', 'mystery' ); |
|
| 3533 | + if (empty($args['default'])) { |
|
| 3534 | + $args['default'] = get_option('avatar_default', 'mystery'); |
|
| 3535 | 3535 | } |
| 3536 | 3536 | |
| 3537 | - switch ( $args['default'] ) { |
|
| 3537 | + switch ($args['default']) { |
|
| 3538 | 3538 | case 'mm' : |
| 3539 | 3539 | case 'mystery' : |
| 3540 | 3540 | case 'mysteryman' : |
@@ -3547,7 +3547,7 @@ discard block |
||
| 3547 | 3547 | |
| 3548 | 3548 | $args['force_default'] = (bool) $args['force_default']; |
| 3549 | 3549 | |
| 3550 | - $args['rating'] = strtolower( $args['rating'] ); |
|
| 3550 | + $args['rating'] = strtolower($args['rating']); |
|
| 3551 | 3551 | |
| 3552 | 3552 | $args['found_avatar'] = false; |
| 3553 | 3553 | |
@@ -3563,34 +3563,34 @@ discard block |
||
| 3563 | 3563 | * @param array $args Arguments passed to get_avatar_data(), after processing. |
| 3564 | 3564 | * @param int|object|string $id_or_email A user ID, email address, or comment object. |
| 3565 | 3565 | */ |
| 3566 | - $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email ); |
|
| 3566 | + $args = apply_filters('pre_get_avatar_data', $args, $id_or_email); |
|
| 3567 | 3567 | |
| 3568 | - if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) { |
|
| 3568 | + if (isset($args['url']) && ! is_null($args['url'])) { |
|
| 3569 | 3569 | /** This filter is documented in wp-includes/link-template.php */ |
| 3570 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 3570 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 3571 | 3571 | } |
| 3572 | 3572 | |
| 3573 | 3573 | $email_hash = ''; |
| 3574 | 3574 | $user = $email = false; |
| 3575 | 3575 | |
| 3576 | 3576 | // Process the user identifier. |
| 3577 | - if ( is_numeric( $id_or_email ) ) { |
|
| 3578 | - $user = get_user_by( 'id', absint( $id_or_email ) ); |
|
| 3579 | - } elseif ( is_string( $id_or_email ) ) { |
|
| 3580 | - if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) { |
|
| 3577 | + if (is_numeric($id_or_email)) { |
|
| 3578 | + $user = get_user_by('id', absint($id_or_email)); |
|
| 3579 | + } elseif (is_string($id_or_email)) { |
|
| 3580 | + if (strpos($id_or_email, '@md5.gravatar.com')) { |
|
| 3581 | 3581 | // md5 hash |
| 3582 | - list( $email_hash ) = explode( '@', $id_or_email ); |
|
| 3582 | + list($email_hash) = explode('@', $id_or_email); |
|
| 3583 | 3583 | } else { |
| 3584 | 3584 | // email address |
| 3585 | 3585 | $email = $id_or_email; |
| 3586 | 3586 | } |
| 3587 | - } elseif ( $id_or_email instanceof WP_User ) { |
|
| 3587 | + } elseif ($id_or_email instanceof WP_User) { |
|
| 3588 | 3588 | // User Object |
| 3589 | 3589 | $user = $id_or_email; |
| 3590 | - } elseif ( $id_or_email instanceof WP_Post ) { |
|
| 3590 | + } elseif ($id_or_email instanceof WP_Post) { |
|
| 3591 | 3591 | // Post Object |
| 3592 | - $user = get_user_by( 'id', (int) $id_or_email->post_author ); |
|
| 3593 | - } elseif ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { |
|
| 3592 | + $user = get_user_by('id', (int) $id_or_email->post_author); |
|
| 3593 | + } elseif (is_object($id_or_email) && isset($id_or_email->comment_ID)) { |
|
| 3594 | 3594 | // Comment Object |
| 3595 | 3595 | |
| 3596 | 3596 | /** |
@@ -3600,36 +3600,36 @@ discard block |
||
| 3600 | 3600 | * |
| 3601 | 3601 | * @param array $types An array of content types. Default only contains 'comment'. |
| 3602 | 3602 | */ |
| 3603 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 3604 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 3603 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 3604 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 3605 | 3605 | $args['url'] = false; |
| 3606 | 3606 | /** This filter is documented in wp-includes/link-template.php */ |
| 3607 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 3607 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 3611 | - $user = get_user_by( 'id', (int) $id_or_email->user_id ); |
|
| 3610 | + if ( ! empty($id_or_email->user_id)) { |
|
| 3611 | + $user = get_user_by('id', (int) $id_or_email->user_id); |
|
| 3612 | 3612 | } |
| 3613 | - if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) { |
|
| 3613 | + if (( ! $user || is_wp_error($user)) && ! empty($id_or_email->comment_author_email)) { |
|
| 3614 | 3614 | $email = $id_or_email->comment_author_email; |
| 3615 | 3615 | } |
| 3616 | 3616 | } |
| 3617 | 3617 | |
| 3618 | - if ( ! $email_hash ) { |
|
| 3619 | - if ( $user ) { |
|
| 3618 | + if ( ! $email_hash) { |
|
| 3619 | + if ($user) { |
|
| 3620 | 3620 | $email = $user->user_email; |
| 3621 | 3621 | } |
| 3622 | 3622 | |
| 3623 | - if ( $email ) { |
|
| 3624 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
| 3623 | + if ($email) { |
|
| 3624 | + $email_hash = md5(strtolower(trim($email))); |
|
| 3625 | 3625 | } |
| 3626 | 3626 | } |
| 3627 | 3627 | |
| 3628 | - if ( $email_hash ) { |
|
| 3628 | + if ($email_hash) { |
|
| 3629 | 3629 | $args['found_avatar'] = true; |
| 3630 | - $gravatar_server = hexdec( $email_hash[0] ) % 3; |
|
| 3630 | + $gravatar_server = hexdec($email_hash[0]) % 3; |
|
| 3631 | 3631 | } else { |
| 3632 | - $gravatar_server = rand( 0, 2 ); |
|
| 3632 | + $gravatar_server = rand(0, 2); |
|
| 3633 | 3633 | } |
| 3634 | 3634 | |
| 3635 | 3635 | $url_args = array( |
@@ -3639,15 +3639,15 @@ discard block |
||
| 3639 | 3639 | 'r' => $args['rating'], |
| 3640 | 3640 | ); |
| 3641 | 3641 | |
| 3642 | - if ( is_ssl() ) { |
|
| 3643 | - $url = 'https://secure.gravatar.com/avatar/' . $email_hash; |
|
| 3642 | + if (is_ssl()) { |
|
| 3643 | + $url = 'https://secure.gravatar.com/avatar/'.$email_hash; |
|
| 3644 | 3644 | } else { |
| 3645 | - $url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash ); |
|
| 3645 | + $url = sprintf('http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash); |
|
| 3646 | 3646 | } |
| 3647 | 3647 | |
| 3648 | 3648 | $url = add_query_arg( |
| 3649 | - rawurlencode_deep( array_filter( $url_args ) ), |
|
| 3650 | - set_url_scheme( $url, $args['scheme'] ) |
|
| 3649 | + rawurlencode_deep(array_filter($url_args)), |
|
| 3650 | + set_url_scheme($url, $args['scheme']) |
|
| 3651 | 3651 | ); |
| 3652 | 3652 | |
| 3653 | 3653 | /** |
@@ -3659,7 +3659,7 @@ discard block |
||
| 3659 | 3659 | * @param int|object|string $id_or_email A user ID, email address, or comment object. |
| 3660 | 3660 | * @param array $args Arguments passed to get_avatar_data(), after processing. |
| 3661 | 3661 | */ |
| 3662 | - $args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args ); |
|
| 3662 | + $args['url'] = apply_filters('get_avatar_url', $url, $id_or_email, $args); |
|
| 3663 | 3663 | |
| 3664 | 3664 | /** |
| 3665 | 3665 | * Filter the avatar data. |
@@ -3669,5 +3669,5 @@ discard block |
||
| 3669 | 3669 | * @param array $args Arguments passed to get_avatar_data(), after processing. |
| 3670 | 3670 | * @param int|object|string $id_or_email A user ID, email address, or comment object. |
| 3671 | 3671 | */ |
| 3672 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 3672 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 3673 | 3673 | } |
@@ -39,10 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function user_trailingslashit($string, $type_of_url = '') { |
| 41 | 41 | global $wp_rewrite; |
| 42 | - if ( $wp_rewrite->use_trailing_slashes ) |
|
| 43 | - $string = trailingslashit($string); |
|
| 44 | - else |
|
| 45 | - $string = untrailingslashit($string); |
|
| 42 | + if ( $wp_rewrite->use_trailing_slashes ) { |
|
| 43 | + $string = trailingslashit($string); |
|
| 44 | + } else { |
|
| 45 | + $string = untrailingslashit($string); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | /** |
| 48 | 49 | * Filter the trailing slashed string, depending on whether the site is set |
@@ -131,15 +132,17 @@ discard block |
||
| 131 | 132 | $sample = false; |
| 132 | 133 | } |
| 133 | 134 | |
| 134 | - if ( empty($post->ID) ) |
|
| 135 | - return false; |
|
| 135 | + if ( empty($post->ID) ) { |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 136 | 138 | |
| 137 | - if ( $post->post_type == 'page' ) |
|
| 138 | - return get_page_link($post, $leavename, $sample); |
|
| 139 | - elseif ( $post->post_type == 'attachment' ) |
|
| 140 | - return get_attachment_link( $post, $leavename ); |
|
| 141 | - elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) |
|
| 142 | - return get_post_permalink($post, $leavename, $sample); |
|
| 139 | + if ( $post->post_type == 'page' ) { |
|
| 140 | + return get_page_link($post, $leavename, $sample); |
|
| 141 | + } elseif ( $post->post_type == 'attachment' ) { |
|
| 142 | + return get_attachment_link( $post, $leavename ); |
|
| 143 | + } elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) { |
|
| 144 | + return get_post_permalink($post, $leavename, $sample); |
|
| 145 | + } |
|
| 143 | 146 | |
| 144 | 147 | $permalink = get_option('permalink_structure'); |
| 145 | 148 | |
@@ -178,8 +181,9 @@ discard block |
||
| 178 | 181 | |
| 179 | 182 | $category_object = get_term( $category_object, 'category' ); |
| 180 | 183 | $category = $category_object->slug; |
| 181 | - if ( $parent = $category_object->parent ) |
|
| 182 | - $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 184 | + if ( $parent = $category_object->parent ) { |
|
| 185 | + $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 186 | + } |
|
| 183 | 187 | } |
| 184 | 188 | // show default category in permalinks, without |
| 185 | 189 | // having to assign it explicitly |
@@ -247,8 +251,9 @@ discard block |
||
| 247 | 251 | |
| 248 | 252 | $post = get_post($id); |
| 249 | 253 | |
| 250 | - if ( is_wp_error( $post ) ) |
|
| 251 | - return $post; |
|
| 254 | + if ( is_wp_error( $post ) ) { |
|
| 255 | + return $post; |
|
| 256 | + } |
|
| 252 | 257 | |
| 253 | 258 | $post_link = $wp_rewrite->get_extra_permastruct($post->post_type); |
| 254 | 259 | |
@@ -268,10 +273,11 @@ discard block |
||
| 268 | 273 | } |
| 269 | 274 | $post_link = home_url( user_trailingslashit($post_link) ); |
| 270 | 275 | } else { |
| 271 | - if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) |
|
| 272 | - $post_link = add_query_arg($post_type->query_var, $slug, ''); |
|
| 273 | - else |
|
| 274 | - $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
|
| 276 | + if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) { |
|
| 277 | + $post_link = add_query_arg($post_type->query_var, $slug, ''); |
|
| 278 | + } else { |
|
| 279 | + $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
|
| 280 | + } |
|
| 275 | 281 | $post_link = home_url($post_link); |
| 276 | 282 | } |
| 277 | 283 | |
@@ -303,10 +309,11 @@ discard block |
||
| 303 | 309 | function get_page_link( $post = false, $leavename = false, $sample = false ) { |
| 304 | 310 | $post = get_post( $post ); |
| 305 | 311 | |
| 306 | - if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) |
|
| 307 | - $link = home_url('/'); |
|
| 308 | - else |
|
| 309 | - $link = _get_page_link( $post, $leavename, $sample ); |
|
| 312 | + if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) { |
|
| 313 | + $link = home_url('/'); |
|
| 314 | + } else { |
|
| 315 | + $link = _get_page_link( $post, $leavename, $sample ); |
|
| 316 | + } |
|
| 310 | 317 | |
| 311 | 318 | /** |
| 312 | 319 | * Filter the permalink for a page. |
@@ -388,25 +395,34 @@ discard block |
||
| 388 | 395 | $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false; |
| 389 | 396 | |
| 390 | 397 | if ( $wp_rewrite->using_permalinks() && $parent ) { |
| 391 | - if ( 'page' == $parent->post_type ) |
|
| 392 | - $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front |
|
| 393 | - else |
|
| 394 | - $parentlink = get_permalink( $post->post_parent ); |
|
| 398 | + if ( 'page' == $parent->post_type ) { |
|
| 399 | + $parentlink = _get_page_link( $post->post_parent ); |
|
| 400 | + } |
|
| 401 | + // Ignores page_on_front |
|
| 402 | + else { |
|
| 403 | + $parentlink = get_permalink( $post->post_parent ); |
|
| 404 | + } |
|
| 395 | 405 | |
| 396 | - if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) |
|
| 397 | - $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 398 | - else |
|
| 399 | - $name = $post->post_name; |
|
| 406 | + if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) { |
|
| 407 | + $name = 'attachment/' . $post->post_name; |
|
| 408 | + } |
|
| 409 | + // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 410 | + else { |
|
| 411 | + $name = $post->post_name; |
|
| 412 | + } |
|
| 400 | 413 | |
| 401 | - if ( strpos($parentlink, '?') === false ) |
|
| 402 | - $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 414 | + if ( strpos($parentlink, '?') === false ) { |
|
| 415 | + $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 416 | + } |
|
| 403 | 417 | |
| 404 | - if ( ! $leavename ) |
|
| 405 | - $link = str_replace( '%postname%', $name, $link ); |
|
| 418 | + if ( ! $leavename ) { |
|
| 419 | + $link = str_replace( '%postname%', $name, $link ); |
|
| 420 | + } |
|
| 406 | 421 | } |
| 407 | 422 | |
| 408 | - if ( ! $link ) |
|
| 409 | - $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 423 | + if ( ! $link ) { |
|
| 424 | + $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 425 | + } |
|
| 410 | 426 | |
| 411 | 427 | /** |
| 412 | 428 | * Filter the permalink for an attachment. |
@@ -431,8 +447,9 @@ discard block |
||
| 431 | 447 | */ |
| 432 | 448 | function get_year_link($year) { |
| 433 | 449 | global $wp_rewrite; |
| 434 | - if ( !$year ) |
|
| 435 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 450 | + if ( !$year ) { |
|
| 451 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 452 | + } |
|
| 436 | 453 | $yearlink = $wp_rewrite->get_year_permastruct(); |
| 437 | 454 | if ( !empty($yearlink) ) { |
| 438 | 455 | $yearlink = str_replace('%year%', $year, $yearlink); |
@@ -465,10 +482,12 @@ discard block |
||
| 465 | 482 | */ |
| 466 | 483 | function get_month_link($year, $month) { |
| 467 | 484 | global $wp_rewrite; |
| 468 | - if ( !$year ) |
|
| 469 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 470 | - if ( !$month ) |
|
| 471 | - $month = gmdate('m', current_time('timestamp')); |
|
| 485 | + if ( !$year ) { |
|
| 486 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 487 | + } |
|
| 488 | + if ( !$month ) { |
|
| 489 | + $month = gmdate('m', current_time('timestamp')); |
|
| 490 | + } |
|
| 472 | 491 | $monthlink = $wp_rewrite->get_month_permastruct(); |
| 473 | 492 | if ( !empty($monthlink) ) { |
| 474 | 493 | $monthlink = str_replace('%year%', $year, $monthlink); |
@@ -504,12 +523,15 @@ discard block |
||
| 504 | 523 | */ |
| 505 | 524 | function get_day_link($year, $month, $day) { |
| 506 | 525 | global $wp_rewrite; |
| 507 | - if ( !$year ) |
|
| 508 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 509 | - if ( !$month ) |
|
| 510 | - $month = gmdate('m', current_time('timestamp')); |
|
| 511 | - if ( !$day ) |
|
| 512 | - $day = gmdate('j', current_time('timestamp')); |
|
| 526 | + if ( !$year ) { |
|
| 527 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 528 | + } |
|
| 529 | + if ( !$month ) { |
|
| 530 | + $month = gmdate('m', current_time('timestamp')); |
|
| 531 | + } |
|
| 532 | + if ( !$day ) { |
|
| 533 | + $day = gmdate('j', current_time('timestamp')); |
|
| 534 | + } |
|
| 513 | 535 | |
| 514 | 536 | $daylink = $wp_rewrite->get_day_permastruct(); |
| 515 | 537 | if ( !empty($daylink) ) { |
@@ -577,18 +599,21 @@ discard block |
||
| 577 | 599 | $permalink = $wp_rewrite->get_comment_feed_permastruct(); |
| 578 | 600 | } |
| 579 | 601 | |
| 580 | - if ( get_default_feed() == $feed ) |
|
| 581 | - $feed = ''; |
|
| 602 | + if ( get_default_feed() == $feed ) { |
|
| 603 | + $feed = ''; |
|
| 604 | + } |
|
| 582 | 605 | |
| 583 | 606 | $permalink = str_replace('%feed%', $feed, $permalink); |
| 584 | 607 | $permalink = preg_replace('#/+#', '/', "/$permalink"); |
| 585 | 608 | $output = home_url( user_trailingslashit($permalink, 'feed') ); |
| 586 | 609 | } else { |
| 587 | - if ( empty($feed) ) |
|
| 588 | - $feed = get_default_feed(); |
|
| 610 | + if ( empty($feed) ) { |
|
| 611 | + $feed = get_default_feed(); |
|
| 612 | + } |
|
| 589 | 613 | |
| 590 | - if ( false !== strpos($feed, 'comments_') ) |
|
| 591 | - $feed = str_replace('comments_', 'comments-', $feed); |
|
| 614 | + if ( false !== strpos($feed, 'comments_') ) { |
|
| 615 | + $feed = str_replace('comments_', 'comments-', $feed); |
|
| 616 | + } |
|
| 592 | 617 | |
| 593 | 618 | $output = home_url("?feed={$feed}"); |
| 594 | 619 | } |
@@ -616,28 +641,33 @@ discard block |
||
| 616 | 641 | function get_post_comments_feed_link($post_id = 0, $feed = '') { |
| 617 | 642 | $post_id = absint( $post_id ); |
| 618 | 643 | |
| 619 | - if ( ! $post_id ) |
|
| 620 | - $post_id = get_the_ID(); |
|
| 644 | + if ( ! $post_id ) { |
|
| 645 | + $post_id = get_the_ID(); |
|
| 646 | + } |
|
| 621 | 647 | |
| 622 | - if ( empty( $feed ) ) |
|
| 623 | - $feed = get_default_feed(); |
|
| 648 | + if ( empty( $feed ) ) { |
|
| 649 | + $feed = get_default_feed(); |
|
| 650 | + } |
|
| 624 | 651 | |
| 625 | 652 | if ( '' != get_option('permalink_structure') ) { |
| 626 | - if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) |
|
| 627 | - $url = _get_page_link( $post_id ); |
|
| 628 | - else |
|
| 629 | - $url = get_permalink($post_id); |
|
| 653 | + if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) { |
|
| 654 | + $url = _get_page_link( $post_id ); |
|
| 655 | + } else { |
|
| 656 | + $url = get_permalink($post_id); |
|
| 657 | + } |
|
| 630 | 658 | |
| 631 | 659 | $url = trailingslashit($url) . 'feed'; |
| 632 | - if ( $feed != get_default_feed() ) |
|
| 633 | - $url .= "/$feed"; |
|
| 660 | + if ( $feed != get_default_feed() ) { |
|
| 661 | + $url .= "/$feed"; |
|
| 662 | + } |
|
| 634 | 663 | $url = user_trailingslashit($url, 'single_feed'); |
| 635 | 664 | } else { |
| 636 | 665 | $type = get_post_field('post_type', $post_id); |
| 637 | - if ( 'page' == $type ) |
|
| 638 | - $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) ); |
|
| 639 | - else |
|
| 640 | - $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); |
|
| 666 | + if ( 'page' == $type ) { |
|
| 667 | + $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) ); |
|
| 668 | + } else { |
|
| 669 | + $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); |
|
| 670 | + } |
|
| 641 | 671 | } |
| 642 | 672 | |
| 643 | 673 | /** |
@@ -665,8 +695,9 @@ discard block |
||
| 665 | 695 | */ |
| 666 | 696 | function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { |
| 667 | 697 | $url = esc_url( get_post_comments_feed_link( $post_id, $feed ) ); |
| 668 | - if ( empty($link_text) ) |
|
| 669 | - $link_text = __('Comments Feed'); |
|
| 698 | + if ( empty($link_text) ) { |
|
| 699 | + $link_text = __('Comments Feed'); |
|
| 700 | + } |
|
| 670 | 701 | |
| 671 | 702 | /** |
| 672 | 703 | * Filter the post comment feed link anchor tag. |
@@ -696,17 +727,19 @@ discard block |
||
| 696 | 727 | $author_id = (int) $author_id; |
| 697 | 728 | $permalink_structure = get_option('permalink_structure'); |
| 698 | 729 | |
| 699 | - if ( empty($feed) ) |
|
| 700 | - $feed = get_default_feed(); |
|
| 730 | + if ( empty($feed) ) { |
|
| 731 | + $feed = get_default_feed(); |
|
| 732 | + } |
|
| 701 | 733 | |
| 702 | 734 | if ( '' == $permalink_structure ) { |
| 703 | 735 | $link = home_url("?feed=$feed&author=" . $author_id); |
| 704 | 736 | } else { |
| 705 | 737 | $link = get_author_posts_url($author_id); |
| 706 | - if ( $feed == get_default_feed() ) |
|
| 707 | - $feed_link = 'feed'; |
|
| 708 | - else |
|
| 709 | - $feed_link = "feed/$feed"; |
|
| 738 | + if ( $feed == get_default_feed() ) { |
|
| 739 | + $feed_link = 'feed'; |
|
| 740 | + } else { |
|
| 741 | + $feed_link = "feed/$feed"; |
|
| 742 | + } |
|
| 710 | 743 | |
| 711 | 744 | $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); |
| 712 | 745 | } |
@@ -758,19 +791,20 @@ discard block |
||
| 758 | 791 | |
| 759 | 792 | $term = get_term( $term_id, $taxonomy ); |
| 760 | 793 | |
| 761 | - if ( empty( $term ) || is_wp_error( $term ) ) |
|
| 762 | - return false; |
|
| 794 | + if ( empty( $term ) || is_wp_error( $term ) ) { |
|
| 795 | + return false; |
|
| 796 | + } |
|
| 763 | 797 | |
| 764 | - if ( empty( $feed ) ) |
|
| 765 | - $feed = get_default_feed(); |
|
| 798 | + if ( empty( $feed ) ) { |
|
| 799 | + $feed = get_default_feed(); |
|
| 800 | + } |
|
| 766 | 801 | |
| 767 | 802 | $permalink_structure = get_option( 'permalink_structure' ); |
| 768 | 803 | |
| 769 | 804 | if ( '' == $permalink_structure ) { |
| 770 | 805 | if ( 'category' == $taxonomy ) { |
| 771 | 806 | $link = home_url("?feed=$feed&cat=$term_id"); |
| 772 | - } |
|
| 773 | - elseif ( 'post_tag' == $taxonomy ) { |
|
| 807 | + } elseif ( 'post_tag' == $taxonomy ) { |
|
| 774 | 808 | $link = home_url("?feed=$feed&tag=$term->slug"); |
| 775 | 809 | } else { |
| 776 | 810 | $t = get_taxonomy( $taxonomy ); |
@@ -778,10 +812,11 @@ discard block |
||
| 778 | 812 | } |
| 779 | 813 | } else { |
| 780 | 814 | $link = get_term_link( $term_id, $term->taxonomy ); |
| 781 | - if ( $feed == get_default_feed() ) |
|
| 782 | - $feed_link = 'feed'; |
|
| 783 | - else |
|
| 784 | - $feed_link = "feed/$feed"; |
|
| 815 | + if ( $feed == get_default_feed() ) { |
|
| 816 | + $feed_link = 'feed'; |
|
| 817 | + } else { |
|
| 818 | + $feed_link = "feed/$feed"; |
|
| 819 | + } |
|
| 785 | 820 | |
| 786 | 821 | $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); |
| 787 | 822 | } |
@@ -940,18 +975,22 @@ discard block |
||
| 940 | 975 | * @return string|void HTML content. |
| 941 | 976 | */ |
| 942 | 977 | function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { |
| 943 | - if ( is_null( $term ) ) |
|
| 944 | - $term = get_queried_object(); |
|
| 978 | + if ( is_null( $term ) ) { |
|
| 979 | + $term = get_queried_object(); |
|
| 980 | + } |
|
| 945 | 981 | |
| 946 | - if ( ! $term ) |
|
| 947 | - return; |
|
| 982 | + if ( ! $term ) { |
|
| 983 | + return; |
|
| 984 | + } |
|
| 948 | 985 | |
| 949 | 986 | $tax = get_taxonomy( $term->taxonomy ); |
| 950 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
| 951 | - return; |
|
| 987 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
| 988 | + return; |
|
| 989 | + } |
|
| 952 | 990 | |
| 953 | - if ( empty( $link ) ) |
|
| 954 | - $link = __('Edit This'); |
|
| 991 | + if ( empty( $link ) ) { |
|
| 992 | + $link = __('Edit This'); |
|
| 993 | + } |
|
| 955 | 994 | |
| 956 | 995 | $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; |
| 957 | 996 | |
@@ -965,11 +1004,12 @@ discard block |
||
| 965 | 1004 | */ |
| 966 | 1005 | $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; |
| 967 | 1006 | |
| 968 | - if ( $echo ) |
|
| 969 | - echo $link; |
|
| 970 | - else |
|
| 971 | - return $link; |
|
| 972 | -} |
|
| 1007 | + if ( $echo ) { |
|
| 1008 | + echo $link; |
|
| 1009 | + } else { |
|
| 1010 | + return $link; |
|
| 1011 | + } |
|
| 1012 | + } |
|
| 973 | 1013 | |
| 974 | 1014 | /** |
| 975 | 1015 | * Retrieve permalink for search. |
@@ -984,10 +1024,11 @@ discard block |
||
| 984 | 1024 | function get_search_link( $query = '' ) { |
| 985 | 1025 | global $wp_rewrite; |
| 986 | 1026 | |
| 987 | - if ( empty($query) ) |
|
| 988 | - $search = get_search_query( false ); |
|
| 989 | - else |
|
| 990 | - $search = stripslashes($query); |
|
| 1027 | + if ( empty($query) ) { |
|
| 1028 | + $search = get_search_query( false ); |
|
| 1029 | + } else { |
|
| 1030 | + $search = stripslashes($query); |
|
| 1031 | + } |
|
| 991 | 1032 | |
| 992 | 1033 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 993 | 1034 | |
@@ -1026,8 +1067,9 @@ discard block |
||
| 1026 | 1067 | global $wp_rewrite; |
| 1027 | 1068 | $link = get_search_link($search_query); |
| 1028 | 1069 | |
| 1029 | - if ( empty($feed) ) |
|
| 1030 | - $feed = get_default_feed(); |
|
| 1070 | + if ( empty($feed) ) { |
|
| 1071 | + $feed = get_default_feed(); |
|
| 1072 | + } |
|
| 1031 | 1073 | |
| 1032 | 1074 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1033 | 1075 | |
@@ -1064,17 +1106,19 @@ discard block |
||
| 1064 | 1106 | function get_search_comments_feed_link($search_query = '', $feed = '') { |
| 1065 | 1107 | global $wp_rewrite; |
| 1066 | 1108 | |
| 1067 | - if ( empty($feed) ) |
|
| 1068 | - $feed = get_default_feed(); |
|
| 1109 | + if ( empty($feed) ) { |
|
| 1110 | + $feed = get_default_feed(); |
|
| 1111 | + } |
|
| 1069 | 1112 | |
| 1070 | 1113 | $link = get_search_feed_link($search_query, $feed); |
| 1071 | 1114 | |
| 1072 | 1115 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1073 | 1116 | |
| 1074 | - if ( empty($permastruct) ) |
|
| 1075 | - $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1076 | - else |
|
| 1077 | - $link = add_query_arg('withcomments', 1, $link); |
|
| 1117 | + if ( empty($permastruct) ) { |
|
| 1118 | + $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1119 | + } else { |
|
| 1120 | + $link = add_query_arg('withcomments', 1, $link); |
|
| 1121 | + } |
|
| 1078 | 1122 | |
| 1079 | 1123 | /** This filter is documented in wp-includes/link-template.php */ |
| 1080 | 1124 | return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); |
@@ -1092,18 +1136,21 @@ discard block |
||
| 1092 | 1136 | */ |
| 1093 | 1137 | function get_post_type_archive_link( $post_type ) { |
| 1094 | 1138 | global $wp_rewrite; |
| 1095 | - if ( ! $post_type_obj = get_post_type_object( $post_type ) ) |
|
| 1096 | - return false; |
|
| 1139 | + if ( ! $post_type_obj = get_post_type_object( $post_type ) ) { |
|
| 1140 | + return false; |
|
| 1141 | + } |
|
| 1097 | 1142 | |
| 1098 | - if ( ! $post_type_obj->has_archive ) |
|
| 1099 | - return false; |
|
| 1143 | + if ( ! $post_type_obj->has_archive ) { |
|
| 1144 | + return false; |
|
| 1145 | + } |
|
| 1100 | 1146 | |
| 1101 | 1147 | if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { |
| 1102 | 1148 | $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
| 1103 | - if ( $post_type_obj->rewrite['with_front'] ) |
|
| 1104 | - $struct = $wp_rewrite->front . $struct; |
|
| 1105 | - else |
|
| 1106 | - $struct = $wp_rewrite->root . $struct; |
|
| 1149 | + if ( $post_type_obj->rewrite['with_front'] ) { |
|
| 1150 | + $struct = $wp_rewrite->front . $struct; |
|
| 1151 | + } else { |
|
| 1152 | + $struct = $wp_rewrite->root . $struct; |
|
| 1153 | + } |
|
| 1107 | 1154 | $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); |
| 1108 | 1155 | } else { |
| 1109 | 1156 | $link = home_url( '?post_type=' . $post_type ); |
@@ -1131,18 +1178,21 @@ discard block |
||
| 1131 | 1178 | */ |
| 1132 | 1179 | function get_post_type_archive_feed_link( $post_type, $feed = '' ) { |
| 1133 | 1180 | $default_feed = get_default_feed(); |
| 1134 | - if ( empty( $feed ) ) |
|
| 1135 | - $feed = $default_feed; |
|
| 1181 | + if ( empty( $feed ) ) { |
|
| 1182 | + $feed = $default_feed; |
|
| 1183 | + } |
|
| 1136 | 1184 | |
| 1137 | - if ( ! $link = get_post_type_archive_link( $post_type ) ) |
|
| 1138 | - return false; |
|
| 1185 | + if ( ! $link = get_post_type_archive_link( $post_type ) ) { |
|
| 1186 | + return false; |
|
| 1187 | + } |
|
| 1139 | 1188 | |
| 1140 | 1189 | $post_type_obj = get_post_type_object( $post_type ); |
| 1141 | 1190 | if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { |
| 1142 | 1191 | $link = trailingslashit( $link ); |
| 1143 | 1192 | $link .= 'feed/'; |
| 1144 | - if ( $feed != $default_feed ) |
|
| 1145 | - $link .= "$feed/"; |
|
| 1193 | + if ( $feed != $default_feed ) { |
|
| 1194 | + $link .= "$feed/"; |
|
| 1195 | + } |
|
| 1146 | 1196 | } else { |
| 1147 | 1197 | $link = add_query_arg( 'feed', $feed, $link ); |
| 1148 | 1198 | } |
@@ -1171,22 +1221,26 @@ discard block |
||
| 1171 | 1221 | * @return string|void The edit post link for the given post. |
| 1172 | 1222 | */ |
| 1173 | 1223 | function get_edit_post_link( $id = 0, $context = 'display' ) { |
| 1174 | - if ( ! $post = get_post( $id ) ) |
|
| 1175 | - return; |
|
| 1224 | + if ( ! $post = get_post( $id ) ) { |
|
| 1225 | + return; |
|
| 1226 | + } |
|
| 1176 | 1227 | |
| 1177 | - if ( 'revision' === $post->post_type ) |
|
| 1178 | - $action = ''; |
|
| 1179 | - elseif ( 'display' == $context ) |
|
| 1180 | - $action = '&action=edit'; |
|
| 1181 | - else |
|
| 1182 | - $action = '&action=edit'; |
|
| 1228 | + if ( 'revision' === $post->post_type ) { |
|
| 1229 | + $action = ''; |
|
| 1230 | + } elseif ( 'display' == $context ) { |
|
| 1231 | + $action = '&action=edit'; |
|
| 1232 | + } else { |
|
| 1233 | + $action = '&action=edit'; |
|
| 1234 | + } |
|
| 1183 | 1235 | |
| 1184 | 1236 | $post_type_object = get_post_type_object( $post->post_type ); |
| 1185 | - if ( !$post_type_object ) |
|
| 1186 | - return; |
|
| 1237 | + if ( !$post_type_object ) { |
|
| 1238 | + return; |
|
| 1239 | + } |
|
| 1187 | 1240 | |
| 1188 | - if ( !current_user_can( 'edit_post', $post->ID ) ) |
|
| 1189 | - return; |
|
| 1241 | + if ( !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1242 | + return; |
|
| 1243 | + } |
|
| 1190 | 1244 | |
| 1191 | 1245 | /** |
| 1192 | 1246 | * Filter the post edit link. |
@@ -1251,18 +1305,22 @@ discard block |
||
| 1251 | 1305 | * @return string|void The delete post link URL for the given post. |
| 1252 | 1306 | */ |
| 1253 | 1307 | function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) { |
| 1254 | - if ( ! empty( $deprecated ) ) |
|
| 1255 | - _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 1308 | + if ( ! empty( $deprecated ) ) { |
|
| 1309 | + _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 1310 | + } |
|
| 1256 | 1311 | |
| 1257 | - if ( !$post = get_post( $id ) ) |
|
| 1258 | - return; |
|
| 1312 | + if ( !$post = get_post( $id ) ) { |
|
| 1313 | + return; |
|
| 1314 | + } |
|
| 1259 | 1315 | |
| 1260 | 1316 | $post_type_object = get_post_type_object( $post->post_type ); |
| 1261 | - if ( !$post_type_object ) |
|
| 1262 | - return; |
|
| 1317 | + if ( !$post_type_object ) { |
|
| 1318 | + return; |
|
| 1319 | + } |
|
| 1263 | 1320 | |
| 1264 | - if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
| 1265 | - return; |
|
| 1321 | + if ( !current_user_can( 'delete_post', $post->ID ) ) { |
|
| 1322 | + return; |
|
| 1323 | + } |
|
| 1266 | 1324 | |
| 1267 | 1325 | $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; |
| 1268 | 1326 | |
@@ -1291,8 +1349,9 @@ discard block |
||
| 1291 | 1349 | function get_edit_comment_link( $comment_id = 0 ) { |
| 1292 | 1350 | $comment = get_comment( $comment_id ); |
| 1293 | 1351 | |
| 1294 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
| 1295 | - return; |
|
| 1352 | + if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
| 1353 | + return; |
|
| 1354 | + } |
|
| 1296 | 1355 | |
| 1297 | 1356 | $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; |
| 1298 | 1357 | |
@@ -1353,8 +1412,9 @@ discard block |
||
| 1353 | 1412 | function get_edit_bookmark_link( $link = 0 ) { |
| 1354 | 1413 | $link = get_bookmark( $link ); |
| 1355 | 1414 | |
| 1356 | - if ( !current_user_can('manage_links') ) |
|
| 1357 | - return; |
|
| 1415 | + if ( !current_user_can('manage_links') ) { |
|
| 1416 | + return; |
|
| 1417 | + } |
|
| 1358 | 1418 | |
| 1359 | 1419 | $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; |
| 1360 | 1420 | |
@@ -1382,11 +1442,13 @@ discard block |
||
| 1382 | 1442 | function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { |
| 1383 | 1443 | $bookmark = get_bookmark($bookmark); |
| 1384 | 1444 | |
| 1385 | - if ( !current_user_can('manage_links') ) |
|
| 1386 | - return; |
|
| 1445 | + if ( !current_user_can('manage_links') ) { |
|
| 1446 | + return; |
|
| 1447 | + } |
|
| 1387 | 1448 | |
| 1388 | - if ( empty($link) ) |
|
| 1389 | - $link = __('Edit This'); |
|
| 1449 | + if ( empty($link) ) { |
|
| 1450 | + $link = __('Edit This'); |
|
| 1451 | + } |
|
| 1390 | 1452 | |
| 1391 | 1453 | $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>'; |
| 1392 | 1454 | |
@@ -1410,21 +1472,25 @@ discard block |
||
| 1410 | 1472 | * @return string URL to edit user page or empty string. |
| 1411 | 1473 | */ |
| 1412 | 1474 | function get_edit_user_link( $user_id = null ) { |
| 1413 | - if ( ! $user_id ) |
|
| 1414 | - $user_id = get_current_user_id(); |
|
| 1475 | + if ( ! $user_id ) { |
|
| 1476 | + $user_id = get_current_user_id(); |
|
| 1477 | + } |
|
| 1415 | 1478 | |
| 1416 | - if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) |
|
| 1417 | - return ''; |
|
| 1479 | + if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) { |
|
| 1480 | + return ''; |
|
| 1481 | + } |
|
| 1418 | 1482 | |
| 1419 | 1483 | $user = get_userdata( $user_id ); |
| 1420 | 1484 | |
| 1421 | - if ( ! $user ) |
|
| 1422 | - return ''; |
|
| 1485 | + if ( ! $user ) { |
|
| 1486 | + return ''; |
|
| 1487 | + } |
|
| 1423 | 1488 | |
| 1424 | - if ( get_current_user_id() == $user->ID ) |
|
| 1425 | - $link = get_edit_profile_url( $user->ID ); |
|
| 1426 | - else |
|
| 1427 | - $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1489 | + if ( get_current_user_id() == $user->ID ) { |
|
| 1490 | + $link = get_edit_profile_url( $user->ID ); |
|
| 1491 | + } else { |
|
| 1492 | + $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1493 | + } |
|
| 1428 | 1494 | |
| 1429 | 1495 | /** |
| 1430 | 1496 | * Filter the user edit link. |
@@ -1485,8 +1551,9 @@ discard block |
||
| 1485 | 1551 | function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1486 | 1552 | global $wpdb; |
| 1487 | 1553 | |
| 1488 | - if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) |
|
| 1489 | - return null; |
|
| 1554 | + if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) { |
|
| 1555 | + return null; |
|
| 1556 | + } |
|
| 1490 | 1557 | |
| 1491 | 1558 | $current_post_date = $post->post_date; |
| 1492 | 1559 | |
@@ -1510,16 +1577,18 @@ discard block |
||
| 1510 | 1577 | } |
| 1511 | 1578 | |
| 1512 | 1579 | if ( $in_same_term ) { |
| 1513 | - if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
|
| 1514 | - return ''; |
|
| 1580 | + if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { |
|
| 1581 | + return ''; |
|
| 1582 | + } |
|
| 1515 | 1583 | $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
| 1516 | 1584 | |
| 1517 | 1585 | // Remove any exclusions from the term array to include. |
| 1518 | 1586 | $term_array = array_diff( $term_array, (array) $excluded_terms ); |
| 1519 | 1587 | $term_array = array_map( 'intval', $term_array ); |
| 1520 | 1588 | |
| 1521 | - if ( ! $term_array || is_wp_error( $term_array ) ) |
|
| 1522 | - return ''; |
|
| 1589 | + if ( ! $term_array || is_wp_error( $term_array ) ) { |
|
| 1590 | + return ''; |
|
| 1591 | + } |
|
| 1523 | 1592 | |
| 1524 | 1593 | $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; |
| 1525 | 1594 | } |
@@ -1607,19 +1676,22 @@ discard block |
||
| 1607 | 1676 | $query_key = 'adjacent_post_' . md5( $query ); |
| 1608 | 1677 | $result = wp_cache_get( $query_key, 'counts' ); |
| 1609 | 1678 | if ( false !== $result ) { |
| 1610 | - if ( $result ) |
|
| 1611 | - $result = get_post( $result ); |
|
| 1679 | + if ( $result ) { |
|
| 1680 | + $result = get_post( $result ); |
|
| 1681 | + } |
|
| 1612 | 1682 | return $result; |
| 1613 | 1683 | } |
| 1614 | 1684 | |
| 1615 | 1685 | $result = $wpdb->get_var( $query ); |
| 1616 | - if ( null === $result ) |
|
| 1617 | - $result = ''; |
|
| 1686 | + if ( null === $result ) { |
|
| 1687 | + $result = ''; |
|
| 1688 | + } |
|
| 1618 | 1689 | |
| 1619 | 1690 | wp_cache_set( $query_key, $result, 'counts' ); |
| 1620 | 1691 | |
| 1621 | - if ( $result ) |
|
| 1622 | - $result = get_post( $result ); |
|
| 1692 | + if ( $result ) { |
|
| 1693 | + $result = get_post( $result ); |
|
| 1694 | + } |
|
| 1623 | 1695 | |
| 1624 | 1696 | return $result; |
| 1625 | 1697 | } |
@@ -1639,18 +1711,21 @@ discard block |
||
| 1639 | 1711 | * @return string|void The adjacent post relational link URL. |
| 1640 | 1712 | */ |
| 1641 | 1713 | function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1642 | - if ( $previous && is_attachment() && $post = get_post() ) |
|
| 1643 | - $post = get_post( $post->post_parent ); |
|
| 1644 | - else |
|
| 1645 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1714 | + if ( $previous && is_attachment() && $post = get_post() ) { |
|
| 1715 | + $post = get_post( $post->post_parent ); |
|
| 1716 | + } else { |
|
| 1717 | + $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1718 | + } |
|
| 1646 | 1719 | |
| 1647 | - if ( empty( $post ) ) |
|
| 1648 | - return; |
|
| 1720 | + if ( empty( $post ) ) { |
|
| 1721 | + return; |
|
| 1722 | + } |
|
| 1649 | 1723 | |
| 1650 | 1724 | $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) ); |
| 1651 | 1725 | |
| 1652 | - if ( empty( $post_title ) ) |
|
| 1653 | - $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1726 | + if ( empty( $post_title ) ) { |
|
| 1727 | + $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1728 | + } |
|
| 1654 | 1729 | |
| 1655 | 1730 | $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
| 1656 | 1731 | |
@@ -1749,8 +1824,9 @@ discard block |
||
| 1749 | 1824 | */ |
| 1750 | 1825 | function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { |
| 1751 | 1826 | $post = get_post(); |
| 1752 | - if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) |
|
| 1753 | - return null; |
|
| 1827 | + if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) { |
|
| 1828 | + return null; |
|
| 1829 | + } |
|
| 1754 | 1830 | |
| 1755 | 1831 | $query_args = array( |
| 1756 | 1832 | 'posts_per_page' => 1, |
@@ -1762,23 +1838,26 @@ discard block |
||
| 1762 | 1838 | $term_array = array(); |
| 1763 | 1839 | |
| 1764 | 1840 | if ( ! is_array( $excluded_terms ) ) { |
| 1765 | - if ( ! empty( $excluded_terms ) ) |
|
| 1766 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1767 | - else |
|
| 1768 | - $excluded_terms = array(); |
|
| 1841 | + if ( ! empty( $excluded_terms ) ) { |
|
| 1842 | + $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1843 | + } else { |
|
| 1844 | + $excluded_terms = array(); |
|
| 1845 | + } |
|
| 1769 | 1846 | } |
| 1770 | 1847 | |
| 1771 | 1848 | if ( $in_same_term || ! empty( $excluded_terms ) ) { |
| 1772 | - if ( $in_same_term ) |
|
| 1773 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1849 | + if ( $in_same_term ) { |
|
| 1850 | + $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1851 | + } |
|
| 1774 | 1852 | |
| 1775 | 1853 | if ( ! empty( $excluded_terms ) ) { |
| 1776 | 1854 | $excluded_terms = array_map( 'intval', $excluded_terms ); |
| 1777 | 1855 | $excluded_terms = array_diff( $excluded_terms, $term_array ); |
| 1778 | 1856 | |
| 1779 | 1857 | $inverse_terms = array(); |
| 1780 | - foreach ( $excluded_terms as $excluded_term ) |
|
| 1781 | - $inverse_terms[] = $excluded_term * -1; |
|
| 1858 | + foreach ( $excluded_terms as $excluded_term ) { |
|
| 1859 | + $inverse_terms[] = $excluded_term * -1; |
|
| 1860 | + } |
|
| 1782 | 1861 | $excluded_terms = $inverse_terms; |
| 1783 | 1862 | } |
| 1784 | 1863 | |
@@ -1871,18 +1950,20 @@ discard block |
||
| 1871 | 1950 | * @return string The link URL of the previous or next post in relation to the current post. |
| 1872 | 1951 | */ |
| 1873 | 1952 | function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1874 | - if ( $previous && is_attachment() ) |
|
| 1875 | - $post = get_post( get_post()->post_parent ); |
|
| 1876 | - else |
|
| 1877 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1953 | + if ( $previous && is_attachment() ) { |
|
| 1954 | + $post = get_post( get_post()->post_parent ); |
|
| 1955 | + } else { |
|
| 1956 | + $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1957 | + } |
|
| 1878 | 1958 | |
| 1879 | 1959 | if ( ! $post ) { |
| 1880 | 1960 | $output = ''; |
| 1881 | 1961 | } else { |
| 1882 | 1962 | $title = $post->post_title; |
| 1883 | 1963 | |
| 1884 | - if ( empty( $post->post_title ) ) |
|
| 1885 | - $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1964 | + if ( empty( $post->post_title ) ) { |
|
| 1965 | + $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1966 | + } |
|
| 1886 | 1967 | |
| 1887 | 1968 | /** This filter is documented in wp-includes/post-template.php */ |
| 1888 | 1969 | $title = apply_filters( 'the_title', $title, $post->ID ); |
@@ -1987,8 +2068,9 @@ discard block |
||
| 1987 | 2068 | |
| 1988 | 2069 | $base = trailingslashit( get_bloginfo( 'url' ) ); |
| 1989 | 2070 | |
| 1990 | - if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) |
|
| 1991 | - $base .= $wp_rewrite->index . '/'; |
|
| 2071 | + if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) { |
|
| 2072 | + $base .= $wp_rewrite->index . '/'; |
|
| 2073 | + } |
|
| 1992 | 2074 | |
| 1993 | 2075 | if ( $pagenum > 1 ) { |
| 1994 | 2076 | $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' ); |
@@ -2006,11 +2088,12 @@ discard block |
||
| 2006 | 2088 | */ |
| 2007 | 2089 | $result = apply_filters( 'get_pagenum_link', $result ); |
| 2008 | 2090 | |
| 2009 | - if ( $escape ) |
|
| 2010 | - return esc_url( $result ); |
|
| 2011 | - else |
|
| 2012 | - return esc_url_raw( $result ); |
|
| 2013 | -} |
|
| 2091 | + if ( $escape ) { |
|
| 2092 | + return esc_url( $result ); |
|
| 2093 | + } else { |
|
| 2094 | + return esc_url_raw( $result ); |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2014 | 2097 | |
| 2015 | 2098 | /** |
| 2016 | 2099 | * Retrieve next posts page link. |
@@ -2028,11 +2111,13 @@ discard block |
||
| 2028 | 2111 | global $paged; |
| 2029 | 2112 | |
| 2030 | 2113 | if ( !is_single() ) { |
| 2031 | - if ( !$paged ) |
|
| 2032 | - $paged = 1; |
|
| 2114 | + if ( !$paged ) { |
|
| 2115 | + $paged = 1; |
|
| 2116 | + } |
|
| 2033 | 2117 | $nextpage = intval($paged) + 1; |
| 2034 | - if ( !$max_page || $max_page >= $nextpage ) |
|
| 2035 | - return get_pagenum_link($nextpage); |
|
| 2118 | + if ( !$max_page || $max_page >= $nextpage ) { |
|
| 2119 | + return get_pagenum_link($nextpage); |
|
| 2120 | + } |
|
| 2036 | 2121 | } |
| 2037 | 2122 | } |
| 2038 | 2123 | |
@@ -2048,11 +2133,12 @@ discard block |
||
| 2048 | 2133 | function next_posts( $max_page = 0, $echo = true ) { |
| 2049 | 2134 | $output = esc_url( get_next_posts_page_link( $max_page ) ); |
| 2050 | 2135 | |
| 2051 | - if ( $echo ) |
|
| 2052 | - echo $output; |
|
| 2053 | - else |
|
| 2054 | - return $output; |
|
| 2055 | -} |
|
| 2136 | + if ( $echo ) { |
|
| 2137 | + echo $output; |
|
| 2138 | + } else { |
|
| 2139 | + return $output; |
|
| 2140 | + } |
|
| 2141 | + } |
|
| 2056 | 2142 | |
| 2057 | 2143 | /** |
| 2058 | 2144 | * Return the next posts page link. |
@@ -2069,16 +2155,19 @@ discard block |
||
| 2069 | 2155 | function get_next_posts_link( $label = null, $max_page = 0 ) { |
| 2070 | 2156 | global $paged, $wp_query; |
| 2071 | 2157 | |
| 2072 | - if ( !$max_page ) |
|
| 2073 | - $max_page = $wp_query->max_num_pages; |
|
| 2158 | + if ( !$max_page ) { |
|
| 2159 | + $max_page = $wp_query->max_num_pages; |
|
| 2160 | + } |
|
| 2074 | 2161 | |
| 2075 | - if ( !$paged ) |
|
| 2076 | - $paged = 1; |
|
| 2162 | + if ( !$paged ) { |
|
| 2163 | + $paged = 1; |
|
| 2164 | + } |
|
| 2077 | 2165 | |
| 2078 | 2166 | $nextpage = intval($paged) + 1; |
| 2079 | 2167 | |
| 2080 | - if ( null === $label ) |
|
| 2081 | - $label = __( 'Next Page »' ); |
|
| 2168 | + if ( null === $label ) { |
|
| 2169 | + $label = __( 'Next Page »' ); |
|
| 2170 | + } |
|
| 2082 | 2171 | |
| 2083 | 2172 | if ( !is_single() && ( $nextpage <= $max_page ) ) { |
| 2084 | 2173 | /** |
@@ -2124,8 +2213,9 @@ discard block |
||
| 2124 | 2213 | |
| 2125 | 2214 | if ( !is_single() ) { |
| 2126 | 2215 | $nextpage = intval($paged) - 1; |
| 2127 | - if ( $nextpage < 1 ) |
|
| 2128 | - $nextpage = 1; |
|
| 2216 | + if ( $nextpage < 1 ) { |
|
| 2217 | + $nextpage = 1; |
|
| 2218 | + } |
|
| 2129 | 2219 | return get_pagenum_link($nextpage); |
| 2130 | 2220 | } |
| 2131 | 2221 | } |
@@ -2141,11 +2231,12 @@ discard block |
||
| 2141 | 2231 | function previous_posts( $echo = true ) { |
| 2142 | 2232 | $output = esc_url( get_previous_posts_page_link() ); |
| 2143 | 2233 | |
| 2144 | - if ( $echo ) |
|
| 2145 | - echo $output; |
|
| 2146 | - else |
|
| 2147 | - return $output; |
|
| 2148 | -} |
|
| 2234 | + if ( $echo ) { |
|
| 2235 | + echo $output; |
|
| 2236 | + } else { |
|
| 2237 | + return $output; |
|
| 2238 | + } |
|
| 2239 | + } |
|
| 2149 | 2240 | |
| 2150 | 2241 | /** |
| 2151 | 2242 | * Return the previous posts page link. |
@@ -2160,8 +2251,9 @@ discard block |
||
| 2160 | 2251 | function get_previous_posts_link( $label = null ) { |
| 2161 | 2252 | global $paged; |
| 2162 | 2253 | |
| 2163 | - if ( null === $label ) |
|
| 2164 | - $label = __( '« Previous Page' ); |
|
| 2254 | + if ( null === $label ) { |
|
| 2255 | + $label = __( '« Previous Page' ); |
|
| 2256 | + } |
|
| 2165 | 2257 | |
| 2166 | 2258 | if ( !is_single() && $paged > 1 ) { |
| 2167 | 2259 | /** |
@@ -2446,16 +2538,18 @@ discard block |
||
| 2446 | 2538 | |
| 2447 | 2539 | if ( 'newest' == get_option('default_comments_page') ) { |
| 2448 | 2540 | if ( $pagenum != $max_page ) { |
| 2449 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2450 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2451 | - else |
|
| 2452 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2541 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2542 | + $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2543 | + } else { |
|
| 2544 | + $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2545 | + } |
|
| 2453 | 2546 | } |
| 2454 | 2547 | } elseif ( $pagenum > 1 ) { |
| 2455 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2456 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2457 | - else |
|
| 2458 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2548 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2549 | + $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2550 | + } else { |
|
| 2551 | + $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2552 | + } |
|
| 2459 | 2553 | } |
| 2460 | 2554 | |
| 2461 | 2555 | $result .= '#comments'; |
@@ -2484,8 +2578,9 @@ discard block |
||
| 2484 | 2578 | function get_next_comments_link( $label = '', $max_page = 0 ) { |
| 2485 | 2579 | global $wp_query; |
| 2486 | 2580 | |
| 2487 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2488 | - return; |
|
| 2581 | + if ( !is_singular() || !get_option('page_comments') ) { |
|
| 2582 | + return; |
|
| 2583 | + } |
|
| 2489 | 2584 | |
| 2490 | 2585 | $page = get_query_var('cpage'); |
| 2491 | 2586 | |
@@ -2495,17 +2590,21 @@ discard block |
||
| 2495 | 2590 | |
| 2496 | 2591 | $nextpage = intval($page) + 1; |
| 2497 | 2592 | |
| 2498 | - if ( empty($max_page) ) |
|
| 2499 | - $max_page = $wp_query->max_num_comment_pages; |
|
| 2593 | + if ( empty($max_page) ) { |
|
| 2594 | + $max_page = $wp_query->max_num_comment_pages; |
|
| 2595 | + } |
|
| 2500 | 2596 | |
| 2501 | - if ( empty($max_page) ) |
|
| 2502 | - $max_page = get_comment_pages_count(); |
|
| 2597 | + if ( empty($max_page) ) { |
|
| 2598 | + $max_page = get_comment_pages_count(); |
|
| 2599 | + } |
|
| 2503 | 2600 | |
| 2504 | - if ( $nextpage > $max_page ) |
|
| 2505 | - return; |
|
| 2601 | + if ( $nextpage > $max_page ) { |
|
| 2602 | + return; |
|
| 2603 | + } |
|
| 2506 | 2604 | |
| 2507 | - if ( empty($label) ) |
|
| 2508 | - $label = __('Newer Comments »'); |
|
| 2605 | + if ( empty($label) ) { |
|
| 2606 | + $label = __('Newer Comments »'); |
|
| 2607 | + } |
|
| 2509 | 2608 | |
| 2510 | 2609 | /** |
| 2511 | 2610 | * Filter the anchor tag attributes for the next comments page link. |
@@ -2538,18 +2637,21 @@ discard block |
||
| 2538 | 2637 | * @return string|void HTML-formatted link for the previous page of comments. |
| 2539 | 2638 | */ |
| 2540 | 2639 | function get_previous_comments_link( $label = '' ) { |
| 2541 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2542 | - return; |
|
| 2640 | + if ( !is_singular() || !get_option('page_comments') ) { |
|
| 2641 | + return; |
|
| 2642 | + } |
|
| 2543 | 2643 | |
| 2544 | 2644 | $page = get_query_var('cpage'); |
| 2545 | 2645 | |
| 2546 | - if ( intval($page) <= 1 ) |
|
| 2547 | - return; |
|
| 2646 | + if ( intval($page) <= 1 ) { |
|
| 2647 | + return; |
|
| 2648 | + } |
|
| 2548 | 2649 | |
| 2549 | 2650 | $prevpage = intval($page) - 1; |
| 2550 | 2651 | |
| 2551 | - if ( empty($label) ) |
|
| 2552 | - $label = __('« Older Comments'); |
|
| 2652 | + if ( empty($label) ) { |
|
| 2653 | + $label = __('« Older Comments'); |
|
| 2654 | + } |
|
| 2553 | 2655 | |
| 2554 | 2656 | /** |
| 2555 | 2657 | * Filter the anchor tag attributes for the previous comments page link. |
@@ -2586,12 +2688,14 @@ discard block |
||
| 2586 | 2688 | function paginate_comments_links($args = array()) { |
| 2587 | 2689 | global $wp_rewrite; |
| 2588 | 2690 | |
| 2589 | - if ( !is_singular() || !get_option('page_comments') ) |
|
| 2590 | - return; |
|
| 2691 | + if ( !is_singular() || !get_option('page_comments') ) { |
|
| 2692 | + return; |
|
| 2693 | + } |
|
| 2591 | 2694 | |
| 2592 | 2695 | $page = get_query_var('cpage'); |
| 2593 | - if ( !$page ) |
|
| 2594 | - $page = 1; |
|
| 2696 | + if ( !$page ) { |
|
| 2697 | + $page = 1; |
|
| 2698 | + } |
|
| 2595 | 2699 | $max_page = get_comment_pages_count(); |
| 2596 | 2700 | $defaults = array( |
| 2597 | 2701 | 'base' => add_query_arg( 'cpage', '%#%' ), |
@@ -2601,17 +2705,19 @@ discard block |
||
| 2601 | 2705 | 'echo' => true, |
| 2602 | 2706 | 'add_fragment' => '#comments' |
| 2603 | 2707 | ); |
| 2604 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2605 | - $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2708 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2709 | + $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2710 | + } |
|
| 2606 | 2711 | |
| 2607 | 2712 | $args = wp_parse_args( $args, $defaults ); |
| 2608 | 2713 | $page_links = paginate_links( $args ); |
| 2609 | 2714 | |
| 2610 | - if ( $args['echo'] ) |
|
| 2611 | - echo $page_links; |
|
| 2612 | - else |
|
| 2613 | - return $page_links; |
|
| 2614 | -} |
|
| 2715 | + if ( $args['echo'] ) { |
|
| 2716 | + echo $page_links; |
|
| 2717 | + } else { |
|
| 2718 | + return $page_links; |
|
| 2719 | + } |
|
| 2720 | + } |
|
| 2615 | 2721 | |
| 2616 | 2722 | /** |
| 2617 | 2723 | * Retrieve the Press This bookmarklet link. |
@@ -2723,16 +2829,18 @@ discard block |
||
| 2723 | 2829 | } |
| 2724 | 2830 | |
| 2725 | 2831 | if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
| 2726 | - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) |
|
| 2727 | - $scheme = 'https'; |
|
| 2728 | - else |
|
| 2729 | - $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 2832 | + if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) { |
|
| 2833 | + $scheme = 'https'; |
|
| 2834 | + } else { |
|
| 2835 | + $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 2836 | + } |
|
| 2730 | 2837 | } |
| 2731 | 2838 | |
| 2732 | 2839 | $url = set_url_scheme( $url, $scheme ); |
| 2733 | 2840 | |
| 2734 | - if ( $path && is_string( $path ) ) |
|
| 2735 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 2841 | + if ( $path && is_string( $path ) ) { |
|
| 2842 | + $url .= '/' . ltrim( $path, '/' ); |
|
| 2843 | + } |
|
| 2736 | 2844 | |
| 2737 | 2845 | /** |
| 2738 | 2846 | * Filter the home URL. |
@@ -2791,8 +2899,9 @@ discard block |
||
| 2791 | 2899 | |
| 2792 | 2900 | $url = set_url_scheme( $url, $scheme ); |
| 2793 | 2901 | |
| 2794 | - if ( $path && is_string( $path ) ) |
|
| 2795 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 2902 | + if ( $path && is_string( $path ) ) { |
|
| 2903 | + $url .= '/' . ltrim( $path, '/' ); |
|
| 2904 | + } |
|
| 2796 | 2905 | |
| 2797 | 2906 | /** |
| 2798 | 2907 | * Filter the site URL. |
@@ -2836,8 +2945,9 @@ discard block |
||
| 2836 | 2945 | function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { |
| 2837 | 2946 | $url = get_site_url($blog_id, 'wp-admin/', $scheme); |
| 2838 | 2947 | |
| 2839 | - if ( $path && is_string( $path ) ) |
|
| 2840 | - $url .= ltrim( $path, '/' ); |
|
| 2948 | + if ( $path && is_string( $path ) ) { |
|
| 2949 | + $url .= ltrim( $path, '/' ); |
|
| 2950 | + } |
|
| 2841 | 2951 | |
| 2842 | 2952 | /** |
| 2843 | 2953 | * Filter the admin area URL. |
@@ -2863,8 +2973,9 @@ discard block |
||
| 2863 | 2973 | function includes_url( $path = '', $scheme = null ) { |
| 2864 | 2974 | $url = site_url( '/' . WPINC . '/', $scheme ); |
| 2865 | 2975 | |
| 2866 | - if ( $path && is_string( $path ) ) |
|
| 2867 | - $url .= ltrim($path, '/'); |
|
| 2976 | + if ( $path && is_string( $path ) ) { |
|
| 2977 | + $url .= ltrim($path, '/'); |
|
| 2978 | + } |
|
| 2868 | 2979 | |
| 2869 | 2980 | /** |
| 2870 | 2981 | * Filter the URL to the includes directory. |
@@ -2889,8 +3000,9 @@ discard block |
||
| 2889 | 3000 | function content_url($path = '') { |
| 2890 | 3001 | $url = set_url_scheme( WP_CONTENT_URL ); |
| 2891 | 3002 | |
| 2892 | - if ( $path && is_string( $path ) ) |
|
| 2893 | - $url .= '/' . ltrim($path, '/'); |
|
| 3003 | + if ( $path && is_string( $path ) ) { |
|
| 3004 | + $url .= '/' . ltrim($path, '/'); |
|
| 3005 | + } |
|
| 2894 | 3006 | |
| 2895 | 3007 | /** |
| 2896 | 3008 | * Filter the URL to the content directory. |
@@ -2924,22 +3036,25 @@ discard block |
||
| 2924 | 3036 | $plugin = wp_normalize_path( $plugin ); |
| 2925 | 3037 | $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); |
| 2926 | 3038 | |
| 2927 | - if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) |
|
| 2928 | - $url = WPMU_PLUGIN_URL; |
|
| 2929 | - else |
|
| 2930 | - $url = WP_PLUGIN_URL; |
|
| 3039 | + if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) { |
|
| 3040 | + $url = WPMU_PLUGIN_URL; |
|
| 3041 | + } else { |
|
| 3042 | + $url = WP_PLUGIN_URL; |
|
| 3043 | + } |
|
| 2931 | 3044 | |
| 2932 | 3045 | |
| 2933 | 3046 | $url = set_url_scheme( $url ); |
| 2934 | 3047 | |
| 2935 | 3048 | if ( !empty($plugin) && is_string($plugin) ) { |
| 2936 | 3049 | $folder = dirname(plugin_basename($plugin)); |
| 2937 | - if ( '.' != $folder ) |
|
| 2938 | - $url .= '/' . ltrim($folder, '/'); |
|
| 3050 | + if ( '.' != $folder ) { |
|
| 3051 | + $url .= '/' . ltrim($folder, '/'); |
|
| 3052 | + } |
|
| 2939 | 3053 | } |
| 2940 | 3054 | |
| 2941 | - if ( $path && is_string( $path ) ) |
|
| 2942 | - $url .= '/' . ltrim($path, '/'); |
|
| 3055 | + if ( $path && is_string( $path ) ) { |
|
| 3056 | + $url .= '/' . ltrim($path, '/'); |
|
| 3057 | + } |
|
| 2943 | 3058 | |
| 2944 | 3059 | /** |
| 2945 | 3060 | * Filter the URL to the plugins directory. |
@@ -2969,18 +3084,21 @@ discard block |
||
| 2969 | 3084 | * @return string Site url link with optional path appended. |
| 2970 | 3085 | */ |
| 2971 | 3086 | function network_site_url( $path = '', $scheme = null ) { |
| 2972 | - if ( ! is_multisite() ) |
|
| 2973 | - return site_url($path, $scheme); |
|
| 3087 | + if ( ! is_multisite() ) { |
|
| 3088 | + return site_url($path, $scheme); |
|
| 3089 | + } |
|
| 2974 | 3090 | |
| 2975 | 3091 | $current_site = get_current_site(); |
| 2976 | 3092 | |
| 2977 | - if ( 'relative' == $scheme ) |
|
| 2978 | - $url = $current_site->path; |
|
| 2979 | - else |
|
| 2980 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3093 | + if ( 'relative' == $scheme ) { |
|
| 3094 | + $url = $current_site->path; |
|
| 3095 | + } else { |
|
| 3096 | + $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3097 | + } |
|
| 2981 | 3098 | |
| 2982 | - if ( $path && is_string( $path ) ) |
|
| 2983 | - $url .= ltrim( $path, '/' ); |
|
| 3099 | + if ( $path && is_string( $path ) ) { |
|
| 3100 | + $url .= ltrim( $path, '/' ); |
|
| 3101 | + } |
|
| 2984 | 3102 | |
| 2985 | 3103 | /** |
| 2986 | 3104 | * Filter the network site URL. |
@@ -3011,22 +3129,26 @@ discard block |
||
| 3011 | 3129 | * @return string Home url link with optional path appended. |
| 3012 | 3130 | */ |
| 3013 | 3131 | function network_home_url( $path = '', $scheme = null ) { |
| 3014 | - if ( ! is_multisite() ) |
|
| 3015 | - return home_url($path, $scheme); |
|
| 3132 | + if ( ! is_multisite() ) { |
|
| 3133 | + return home_url($path, $scheme); |
|
| 3134 | + } |
|
| 3016 | 3135 | |
| 3017 | 3136 | $current_site = get_current_site(); |
| 3018 | 3137 | $orig_scheme = $scheme; |
| 3019 | 3138 | |
| 3020 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) |
|
| 3021 | - $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
|
| 3139 | + if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
|
| 3140 | + $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
|
| 3141 | + } |
|
| 3022 | 3142 | |
| 3023 | - if ( 'relative' == $scheme ) |
|
| 3024 | - $url = $current_site->path; |
|
| 3025 | - else |
|
| 3026 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3143 | + if ( 'relative' == $scheme ) { |
|
| 3144 | + $url = $current_site->path; |
|
| 3145 | + } else { |
|
| 3146 | + $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3147 | + } |
|
| 3027 | 3148 | |
| 3028 | - if ( $path && is_string( $path ) ) |
|
| 3029 | - $url .= ltrim( $path, '/' ); |
|
| 3149 | + if ( $path && is_string( $path ) ) { |
|
| 3150 | + $url .= ltrim( $path, '/' ); |
|
| 3151 | + } |
|
| 3030 | 3152 | |
| 3031 | 3153 | /** |
| 3032 | 3154 | * Filter the network home URL. |
@@ -3052,13 +3174,15 @@ discard block |
||
| 3052 | 3174 | * @return string Admin url link with optional path appended. |
| 3053 | 3175 | */ |
| 3054 | 3176 | function network_admin_url( $path = '', $scheme = 'admin' ) { |
| 3055 | - if ( ! is_multisite() ) |
|
| 3056 | - return admin_url( $path, $scheme ); |
|
| 3177 | + if ( ! is_multisite() ) { |
|
| 3178 | + return admin_url( $path, $scheme ); |
|
| 3179 | + } |
|
| 3057 | 3180 | |
| 3058 | 3181 | $url = network_site_url('wp-admin/network/', $scheme); |
| 3059 | 3182 | |
| 3060 | - if ( $path && is_string( $path ) ) |
|
| 3061 | - $url .= ltrim($path, '/'); |
|
| 3183 | + if ( $path && is_string( $path ) ) { |
|
| 3184 | + $url .= ltrim($path, '/'); |
|
| 3185 | + } |
|
| 3062 | 3186 | |
| 3063 | 3187 | /** |
| 3064 | 3188 | * Filter the network admin URL. |
@@ -3084,8 +3208,9 @@ discard block |
||
| 3084 | 3208 | function user_admin_url( $path = '', $scheme = 'admin' ) { |
| 3085 | 3209 | $url = network_site_url('wp-admin/user/', $scheme); |
| 3086 | 3210 | |
| 3087 | - if ( $path && is_string( $path ) ) |
|
| 3088 | - $url .= ltrim($path, '/'); |
|
| 3211 | + if ( $path && is_string( $path ) ) { |
|
| 3212 | + $url .= ltrim($path, '/'); |
|
| 3213 | + } |
|
| 3089 | 3214 | |
| 3090 | 3215 | /** |
| 3091 | 3216 | * Filter the user admin URL for the current user. |
@@ -3109,13 +3234,14 @@ discard block |
||
| 3109 | 3234 | * @return string Admin url link with optional path appended. |
| 3110 | 3235 | */ |
| 3111 | 3236 | function self_admin_url($path = '', $scheme = 'admin') { |
| 3112 | - if ( is_network_admin() ) |
|
| 3113 | - return network_admin_url($path, $scheme); |
|
| 3114 | - elseif ( is_user_admin() ) |
|
| 3115 | - return user_admin_url($path, $scheme); |
|
| 3116 | - else |
|
| 3117 | - return admin_url($path, $scheme); |
|
| 3118 | -} |
|
| 3237 | + if ( is_network_admin() ) { |
|
| 3238 | + return network_admin_url($path, $scheme); |
|
| 3239 | + } elseif ( is_user_admin() ) { |
|
| 3240 | + return user_admin_url($path, $scheme); |
|
| 3241 | + } else { |
|
| 3242 | + return admin_url($path, $scheme); |
|
| 3243 | + } |
|
| 3244 | + } |
|
| 3119 | 3245 | |
| 3120 | 3246 | /** |
| 3121 | 3247 | * Set the scheme for a URL |
@@ -3138,13 +3264,15 @@ discard block |
||
| 3138 | 3264 | } |
| 3139 | 3265 | |
| 3140 | 3266 | $url = trim( $url ); |
| 3141 | - if ( substr( $url, 0, 2 ) === '//' ) |
|
| 3142 | - $url = 'http:' . $url; |
|
| 3267 | + if ( substr( $url, 0, 2 ) === '//' ) { |
|
| 3268 | + $url = 'http:' . $url; |
|
| 3269 | + } |
|
| 3143 | 3270 | |
| 3144 | 3271 | if ( 'relative' == $scheme ) { |
| 3145 | 3272 | $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); |
| 3146 | - if ( $url !== '' && $url[0] === '/' ) |
|
| 3147 | - $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3273 | + if ( $url !== '' && $url[0] === '/' ) { |
|
| 3274 | + $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3275 | + } |
|
| 3148 | 3276 | } else { |
| 3149 | 3277 | $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); |
| 3150 | 3278 | } |
@@ -3190,10 +3318,11 @@ discard block |
||
| 3190 | 3318 | $url = admin_url( $path, $scheme ); |
| 3191 | 3319 | } else { |
| 3192 | 3320 | $active = get_active_blog_for_user( $user_id ); |
| 3193 | - if ( $active ) |
|
| 3194 | - $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3195 | - else |
|
| 3196 | - $url = user_admin_url( $path, $scheme ); |
|
| 3321 | + if ( $active ) { |
|
| 3322 | + $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3323 | + } else { |
|
| 3324 | + $url = user_admin_url( $path, $scheme ); |
|
| 3325 | + } |
|
| 3197 | 3326 | } |
| 3198 | 3327 | } |
| 3199 | 3328 | |
@@ -3224,12 +3353,13 @@ discard block |
||
| 3224 | 3353 | function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) { |
| 3225 | 3354 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3226 | 3355 | |
| 3227 | - if ( is_user_admin() ) |
|
| 3228 | - $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3229 | - elseif ( is_network_admin() ) |
|
| 3230 | - $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3231 | - else |
|
| 3232 | - $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3356 | + if ( is_user_admin() ) { |
|
| 3357 | + $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3358 | + } elseif ( is_network_admin() ) { |
|
| 3359 | + $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3360 | + } else { |
|
| 3361 | + $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3362 | + } |
|
| 3233 | 3363 | |
| 3234 | 3364 | /** |
| 3235 | 3365 | * Filter the URL for a user's profile editor. |
@@ -3252,17 +3382,20 @@ discard block |
||
| 3252 | 3382 | * @global WP_Query $wp_the_query |
| 3253 | 3383 | */ |
| 3254 | 3384 | function rel_canonical() { |
| 3255 | - if ( !is_singular() ) |
|
| 3256 | - return; |
|
| 3385 | + if ( !is_singular() ) { |
|
| 3386 | + return; |
|
| 3387 | + } |
|
| 3257 | 3388 | |
| 3258 | 3389 | global $wp_the_query; |
| 3259 | - if ( !$id = $wp_the_query->get_queried_object_id() ) |
|
| 3260 | - return; |
|
| 3390 | + if ( !$id = $wp_the_query->get_queried_object_id() ) { |
|
| 3391 | + return; |
|
| 3392 | + } |
|
| 3261 | 3393 | |
| 3262 | 3394 | $link = get_permalink( $id ); |
| 3263 | 3395 | |
| 3264 | - if ( $page = get_query_var('cpage') ) |
|
| 3265 | - $link = get_comments_pagenum_link( $page ); |
|
| 3396 | + if ( $page = get_query_var('cpage') ) { |
|
| 3397 | + $link = get_comments_pagenum_link( $page ); |
|
| 3398 | + } |
|
| 3266 | 3399 | |
| 3267 | 3400 | echo "<link rel='canonical' href='$link' />\n"; |
| 3268 | 3401 | } |
@@ -3303,8 +3436,9 @@ discard block |
||
| 3303 | 3436 | */ |
| 3304 | 3437 | $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); |
| 3305 | 3438 | |
| 3306 | - if ( false !== $shortlink ) |
|
| 3307 | - return $shortlink; |
|
| 3439 | + if ( false !== $shortlink ) { |
|
| 3440 | + return $shortlink; |
|
| 3441 | + } |
|
| 3308 | 3442 | |
| 3309 | 3443 | global $wp_query; |
| 3310 | 3444 | $post_id = 0; |
@@ -3313,8 +3447,9 @@ discard block |
||
| 3313 | 3447 | $post = get_post( $post_id ); |
| 3314 | 3448 | } elseif ( 'post' == $context ) { |
| 3315 | 3449 | $post = get_post( $id ); |
| 3316 | - if ( ! empty( $post->ID ) ) |
|
| 3317 | - $post_id = $post->ID; |
|
| 3450 | + if ( ! empty( $post->ID ) ) { |
|
| 3451 | + $post_id = $post->ID; |
|
| 3452 | + } |
|
| 3318 | 3453 | } |
| 3319 | 3454 | |
| 3320 | 3455 | $shortlink = ''; |
@@ -3353,8 +3488,9 @@ discard block |
||
| 3353 | 3488 | function wp_shortlink_wp_head() { |
| 3354 | 3489 | $shortlink = wp_get_shortlink( 0, 'query' ); |
| 3355 | 3490 | |
| 3356 | - if ( empty( $shortlink ) ) |
|
| 3357 | - return; |
|
| 3491 | + if ( empty( $shortlink ) ) { |
|
| 3492 | + return; |
|
| 3493 | + } |
|
| 3358 | 3494 | |
| 3359 | 3495 | echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n"; |
| 3360 | 3496 | } |
@@ -3367,13 +3503,15 @@ discard block |
||
| 3367 | 3503 | * @since 3.0.0 |
| 3368 | 3504 | */ |
| 3369 | 3505 | function wp_shortlink_header() { |
| 3370 | - if ( headers_sent() ) |
|
| 3371 | - return; |
|
| 3506 | + if ( headers_sent() ) { |
|
| 3507 | + return; |
|
| 3508 | + } |
|
| 3372 | 3509 | |
| 3373 | 3510 | $shortlink = wp_get_shortlink(0, 'query'); |
| 3374 | 3511 | |
| 3375 | - if ( empty($shortlink) ) |
|
| 3376 | - return; |
|
| 3512 | + if ( empty($shortlink) ) { |
|
| 3513 | + return; |
|
| 3514 | + } |
|
| 3377 | 3515 | |
| 3378 | 3516 | header('Link: <' . $shortlink . '>; rel=shortlink', false); |
| 3379 | 3517 | } |
@@ -3395,11 +3533,13 @@ discard block |
||
| 3395 | 3533 | function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { |
| 3396 | 3534 | $post = get_post(); |
| 3397 | 3535 | |
| 3398 | - if ( empty( $text ) ) |
|
| 3399 | - $text = __('This is the short link.'); |
|
| 3536 | + if ( empty( $text ) ) { |
|
| 3537 | + $text = __('This is the short link.'); |
|
| 3538 | + } |
|
| 3400 | 3539 | |
| 3401 | - if ( empty( $title ) ) |
|
| 3402 | - $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3540 | + if ( empty( $title ) ) { |
|
| 3541 | + $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3542 | + } |
|
| 3403 | 3543 | |
| 3404 | 3544 | $shortlink = wp_get_shortlink( $post->ID ); |
| 3405 | 3545 | |
@@ -218,7 +218,7 @@ |
||
| 218 | 218 | * @global float $timestart Seconds from when timer_start() is called. |
| 219 | 219 | * @global float $timeend Seconds from when function is called. |
| 220 | 220 | * |
| 221 | - * @param int|bool $display Whether to echo or return the results. Accepts 0|false for return, |
|
| 221 | + * @param integer $display Whether to echo or return the results. Accepts 0|false for return, |
|
| 222 | 222 | * 1|true for echo. Default 0|false. |
| 223 | 223 | * @param int $precision The number of digits from the right of the decimal to display. |
| 224 | 224 | * Default 3. |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * These functions are needed to load WordPress. |
|
| 4 | - * |
|
| 5 | - * @internal This file must be parsable by PHP4. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - */ |
|
| 3 | + * These functions are needed to load WordPress. |
|
| 4 | + * |
|
| 5 | + * @internal This file must be parsable by PHP4. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Turn register globals off. |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | * @access private |
| 15 | 15 | */ |
| 16 | 16 | function wp_unregister_GLOBALS() { |
| 17 | - if ( !ini_get( 'register_globals' ) ) |
|
| 17 | + if ( ! ini_get('register_globals')) |
|
| 18 | 18 | return; |
| 19 | 19 | |
| 20 | - if ( isset( $_REQUEST['GLOBALS'] ) ) |
|
| 21 | - die( 'GLOBALS overwrite attempt detected' ); |
|
| 20 | + if (isset($_REQUEST['GLOBALS'])) |
|
| 21 | + die('GLOBALS overwrite attempt detected'); |
|
| 22 | 22 | |
| 23 | 23 | // Variables that shouldn't be unset |
| 24 | - $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
|
| 24 | + $no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); |
|
| 25 | 25 | |
| 26 | - $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
|
| 27 | - foreach ( $input as $k => $v ) |
|
| 28 | - if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
| 29 | - unset( $GLOBALS[$k] ); |
|
| 26 | + $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); |
|
| 27 | + foreach ($input as $k => $v) |
|
| 28 | + if ( ! in_array($k, $no_unset) && isset($GLOBALS[$k])) { |
|
| 29 | + unset($GLOBALS[$k]); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
@@ -47,50 +47,50 @@ discard block |
||
| 47 | 47 | 'REQUEST_URI' => '', |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $_SERVER = array_merge( $default_server_values, $_SERVER ); |
|
| 50 | + $_SERVER = array_merge($default_server_values, $_SERVER); |
|
| 51 | 51 | |
| 52 | 52 | // Fix for IIS when running with PHP ISAPI |
| 53 | - if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
|
| 53 | + if (empty($_SERVER['REQUEST_URI']) || (PHP_SAPI != 'cgi-fcgi' && preg_match('/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE']))) { |
|
| 54 | 54 | |
| 55 | 55 | // IIS Mod-Rewrite |
| 56 | - if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
| 56 | + if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { |
|
| 57 | 57 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
| 58 | 58 | } |
| 59 | 59 | // IIS Isapi_Rewrite |
| 60 | - elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
|
| 60 | + elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { |
|
| 61 | 61 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
| 62 | 62 | } else { |
| 63 | 63 | // Use ORIG_PATH_INFO if there is no PATH_INFO |
| 64 | - if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
|
| 64 | + if ( ! isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) |
|
| 65 | 65 | $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
| 66 | 66 | |
| 67 | 67 | // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
| 68 | - if ( isset( $_SERVER['PATH_INFO'] ) ) { |
|
| 69 | - if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
|
| 68 | + if (isset($_SERVER['PATH_INFO'])) { |
|
| 69 | + if ($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME']) |
|
| 70 | 70 | $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
| 71 | 71 | else |
| 72 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
| 72 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO']; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Append the query string if it exists and isn't null |
| 76 | - if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
|
| 77 | - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 76 | + if ( ! empty($_SERVER['QUERY_STRING'])) { |
|
| 77 | + $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
| 83 | - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
|
| 83 | + if (isset($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7)) |
|
| 84 | 84 | $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
| 85 | 85 | |
| 86 | 86 | // Fix for Dreamhost and other PHP as CGI hosts |
| 87 | - if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
|
| 88 | - unset( $_SERVER['PATH_INFO'] ); |
|
| 87 | + if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) |
|
| 88 | + unset($_SERVER['PATH_INFO']); |
|
| 89 | 89 | |
| 90 | 90 | // Fix empty PHP_SELF |
| 91 | 91 | $PHP_SELF = $_SERVER['PHP_SELF']; |
| 92 | - if ( empty( $PHP_SELF ) ) |
|
| 93 | - $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
| 92 | + if (empty($PHP_SELF)) |
|
| 93 | + $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace('/(\?.*)?$/', '', $_SERVER["REQUEST_URI"]); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -109,16 +109,16 @@ discard block |
||
| 109 | 109 | global $required_php_version, $wp_version; |
| 110 | 110 | $php_version = phpversion(); |
| 111 | 111 | |
| 112 | - if ( version_compare( $required_php_version, $php_version, '>' ) ) { |
|
| 112 | + if (version_compare($required_php_version, $php_version, '>')) { |
|
| 113 | 113 | wp_load_translations_early(); |
| 114 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 115 | - die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) ); |
|
| 114 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 115 | + die(sprintf(__('Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'), $php_version, $wp_version, $required_php_version)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
|
| 118 | + if ( ! extension_loaded('mysql') && ! extension_loaded('mysqli') && ! file_exists(WP_CONTENT_DIR.'/db.php')) { |
|
| 119 | 119 | wp_load_translations_early(); |
| 120 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 121 | - die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) ); |
|
| 120 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 121 | + die(__('Your PHP installation appears to be missing the MySQL extension which is required by WordPress.')); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @since 3.0.0 |
| 131 | 131 | */ |
| 132 | 132 | function wp_favicon_request() { |
| 133 | - if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { |
|
| 133 | + if ('/favicon.ico' == $_SERVER['REQUEST_URI']) { |
|
| 134 | 134 | header('Content-Type: image/vnd.microsoft.icon'); |
| 135 | 135 | header('Content-Length: 0'); |
| 136 | 136 | exit; |
@@ -154,39 +154,39 @@ discard block |
||
| 154 | 154 | * @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
| 155 | 155 | */ |
| 156 | 156 | function wp_maintenance() { |
| 157 | - if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) ) |
|
| 157 | + if ( ! file_exists(ABSPATH.'.maintenance') || defined('WP_INSTALLING')) |
|
| 158 | 158 | return; |
| 159 | 159 | |
| 160 | 160 | global $upgrading; |
| 161 | 161 | |
| 162 | - include( ABSPATH . '.maintenance' ); |
|
| 162 | + include(ABSPATH.'.maintenance'); |
|
| 163 | 163 | // If the $upgrading timestamp is older than 10 minutes, don't die. |
| 164 | - if ( ( time() - $upgrading ) >= 600 ) |
|
| 164 | + if ((time() - $upgrading) >= 600) |
|
| 165 | 165 | return; |
| 166 | 166 | |
| 167 | - if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
|
| 168 | - require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
|
| 167 | + if (file_exists(WP_CONTENT_DIR.'/maintenance.php')) { |
|
| 168 | + require_once(WP_CONTENT_DIR.'/maintenance.php'); |
|
| 169 | 169 | die(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | wp_load_translations_early(); |
| 173 | 173 | |
| 174 | 174 | $protocol = $_SERVER["SERVER_PROTOCOL"]; |
| 175 | - if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) |
|
| 175 | + if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) |
|
| 176 | 176 | $protocol = 'HTTP/1.0'; |
| 177 | - header( "$protocol 503 Service Unavailable", true, 503 ); |
|
| 178 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 179 | - header( 'Retry-After: 600' ); |
|
| 177 | + header("$protocol 503 Service Unavailable", true, 503); |
|
| 178 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 179 | + header('Retry-After: 600'); |
|
| 180 | 180 | ?> |
| 181 | 181 | <!DOCTYPE html> |
| 182 | - <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
| 182 | + <html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>> |
|
| 183 | 183 | <head> |
| 184 | 184 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 185 | - <title><?php _e( 'Maintenance' ); ?></title> |
|
| 185 | + <title><?php _e('Maintenance'); ?></title> |
|
| 186 | 186 | |
| 187 | 187 | </head> |
| 188 | 188 | <body> |
| 189 | - <h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1> |
|
| 189 | + <h1><?php _e('Briefly unavailable for scheduled maintenance. Check back in a minute.'); ?></h1> |
|
| 190 | 190 | </body> |
| 191 | 191 | </html> |
| 192 | 192 | <?php |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | function timer_start() { |
| 208 | 208 | global $timestart; |
| 209 | - $timestart = microtime( true ); |
|
| 209 | + $timestart = microtime(true); |
|
| 210 | 210 | return true; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | * @return string The "second.microsecond" finished time calculation. The number is formatted |
| 226 | 226 | * for human consumption, both localized and rounded. |
| 227 | 227 | */ |
| 228 | -function timer_stop( $display = 0, $precision = 3 ) { |
|
| 228 | +function timer_stop($display = 0, $precision = 3) { |
|
| 229 | 229 | global $timestart, $timeend; |
| 230 | - $timeend = microtime( true ); |
|
| 230 | + $timeend = microtime(true); |
|
| 231 | 231 | $timetotal = $timeend - $timestart; |
| 232 | - $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
|
| 233 | - if ( $display ) |
|
| 232 | + $r = (function_exists('number_format_i18n')) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); |
|
| 233 | + if ($display) |
|
| 234 | 234 | echo $r; |
| 235 | 235 | return $r; |
| 236 | 236 | } |
@@ -266,23 +266,23 @@ discard block |
||
| 266 | 266 | * @access private |
| 267 | 267 | */ |
| 268 | 268 | function wp_debug_mode() { |
| 269 | - if ( WP_DEBUG ) { |
|
| 270 | - error_reporting( E_ALL ); |
|
| 269 | + if (WP_DEBUG) { |
|
| 270 | + error_reporting(E_ALL); |
|
| 271 | 271 | |
| 272 | - if ( WP_DEBUG_DISPLAY ) |
|
| 273 | - ini_set( 'display_errors', 1 ); |
|
| 274 | - elseif ( null !== WP_DEBUG_DISPLAY ) |
|
| 275 | - ini_set( 'display_errors', 0 ); |
|
| 272 | + if (WP_DEBUG_DISPLAY) |
|
| 273 | + ini_set('display_errors', 1); |
|
| 274 | + elseif (null !== WP_DEBUG_DISPLAY) |
|
| 275 | + ini_set('display_errors', 0); |
|
| 276 | 276 | |
| 277 | - if ( WP_DEBUG_LOG ) { |
|
| 278 | - ini_set( 'log_errors', 1 ); |
|
| 279 | - ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); |
|
| 277 | + if (WP_DEBUG_LOG) { |
|
| 278 | + ini_set('log_errors', 1); |
|
| 279 | + ini_set('error_log', WP_CONTENT_DIR.'/debug.log'); |
|
| 280 | 280 | } |
| 281 | 281 | } else { |
| 282 | - error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
|
| 282 | + error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); |
|
| 283 | 283 | } |
| 284 | - if ( defined( 'XMLRPC_REQUEST' ) ) |
|
| 285 | - ini_set( 'display_errors', 0 ); |
|
| 284 | + if (defined('XMLRPC_REQUEST')) |
|
| 285 | + ini_set('display_errors', 0); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | * @access private |
| 300 | 300 | */ |
| 301 | 301 | function wp_set_lang_dir() { |
| 302 | - if ( !defined( 'WP_LANG_DIR' ) ) { |
|
| 303 | - if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) { |
|
| 302 | + if ( ! defined('WP_LANG_DIR')) { |
|
| 303 | + if (file_exists(WP_CONTENT_DIR.'/languages') && @is_dir(WP_CONTENT_DIR.'/languages') || ! @is_dir(ABSPATH.WPINC.'/languages')) { |
|
| 304 | 304 | /** |
| 305 | 305 | * Server path of the language directory. |
| 306 | 306 | * |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | * |
| 309 | 309 | * @since 2.1.0 |
| 310 | 310 | */ |
| 311 | - define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
| 312 | - if ( !defined( 'LANGDIR' ) ) { |
|
| 311 | + define('WP_LANG_DIR', WP_CONTENT_DIR.'/languages'); |
|
| 312 | + if ( ! defined('LANGDIR')) { |
|
| 313 | 313 | // Old static relative path maintained for limited backwards compatibility - won't work in some cases |
| 314 | - define( 'LANGDIR', 'wp-content/languages' ); |
|
| 314 | + define('LANGDIR', 'wp-content/languages'); |
|
| 315 | 315 | } |
| 316 | 316 | } else { |
| 317 | 317 | /** |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @since 2.1.0 |
| 323 | 323 | */ |
| 324 | - define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
| 325 | - if ( !defined( 'LANGDIR' ) ) { |
|
| 324 | + define('WP_LANG_DIR', ABSPATH.WPINC.'/languages'); |
|
| 325 | + if ( ! defined('LANGDIR')) { |
|
| 326 | 326 | // Old relative path maintained for backwards compatibility |
| 327 | - define( 'LANGDIR', WPINC . '/languages' ); |
|
| 327 | + define('LANGDIR', WPINC.'/languages'); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -340,14 +340,14 @@ discard block |
||
| 340 | 340 | function require_wp_db() { |
| 341 | 341 | global $wpdb; |
| 342 | 342 | |
| 343 | - require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
| 344 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
| 345 | - require_once( WP_CONTENT_DIR . '/db.php' ); |
|
| 343 | + require_once(ABSPATH.WPINC.'/wp-db.php'); |
|
| 344 | + if (file_exists(WP_CONTENT_DIR.'/db.php')) |
|
| 345 | + require_once(WP_CONTENT_DIR.'/db.php'); |
|
| 346 | 346 | |
| 347 | - if ( isset( $wpdb ) ) |
|
| 347 | + if (isset($wpdb)) |
|
| 348 | 348 | return; |
| 349 | 349 | |
| 350 | - $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
|
| 350 | + $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -364,22 +364,22 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | function wp_set_wpdb_vars() { |
| 366 | 366 | global $wpdb, $table_prefix; |
| 367 | - if ( !empty( $wpdb->error ) ) |
|
| 367 | + if ( ! empty($wpdb->error)) |
|
| 368 | 368 | dead_db(); |
| 369 | 369 | |
| 370 | - $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
| 371 | - 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
| 370 | + $wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
| 371 | + 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
| 372 | 372 | 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', |
| 373 | 373 | 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', |
| 374 | 374 | // multisite: |
| 375 | 375 | 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', |
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | - $prefix = $wpdb->set_prefix( $table_prefix ); |
|
| 378 | + $prefix = $wpdb->set_prefix($table_prefix); |
|
| 379 | 379 | |
| 380 | - if ( is_wp_error( $prefix ) ) { |
|
| 380 | + if (is_wp_error($prefix)) { |
|
| 381 | 381 | wp_load_translations_early(); |
| 382 | - wp_die( __( '<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.' ) ); |
|
| 382 | + wp_die(__('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.')); |
|
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
@@ -394,10 +394,10 @@ discard block |
||
| 394 | 394 | * @param bool $using Whether external object cache is being used. |
| 395 | 395 | * @return bool The current 'using' setting. |
| 396 | 396 | */ |
| 397 | -function wp_using_ext_object_cache( $using = null ) { |
|
| 397 | +function wp_using_ext_object_cache($using = null) { |
|
| 398 | 398 | global $_wp_using_ext_object_cache; |
| 399 | 399 | $current_using = $_wp_using_ext_object_cache; |
| 400 | - if ( null !== $using ) |
|
| 400 | + if (null !== $using) |
|
| 401 | 401 | $_wp_using_ext_object_cache = $using; |
| 402 | 402 | return $current_using; |
| 403 | 403 | } |
@@ -417,40 +417,40 @@ discard block |
||
| 417 | 417 | global $blog_id; |
| 418 | 418 | |
| 419 | 419 | $first_init = false; |
| 420 | - if ( ! function_exists( 'wp_cache_init' ) ) { |
|
| 421 | - if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
| 422 | - require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
|
| 423 | - if ( function_exists( 'wp_cache_init' ) ) |
|
| 424 | - wp_using_ext_object_cache( true ); |
|
| 420 | + if ( ! function_exists('wp_cache_init')) { |
|
| 421 | + if (file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
| 422 | + require_once (WP_CONTENT_DIR.'/object-cache.php'); |
|
| 423 | + if (function_exists('wp_cache_init')) |
|
| 424 | + wp_using_ext_object_cache(true); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $first_init = true; |
| 428 | - } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
| 428 | + } elseif ( ! wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
| 429 | 429 | /* |
| 430 | 430 | * Sometimes advanced-cache.php can load object-cache.php before |
| 431 | 431 | * it is loaded here. This breaks the function_exists check above |
| 432 | 432 | * and can result in `$_wp_using_ext_object_cache` being set |
| 433 | 433 | * incorrectly. Double check if an external cache exists. |
| 434 | 434 | */ |
| 435 | - wp_using_ext_object_cache( true ); |
|
| 435 | + wp_using_ext_object_cache(true); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( ! wp_using_ext_object_cache() ) |
|
| 439 | - require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
| 438 | + if ( ! wp_using_ext_object_cache()) |
|
| 439 | + require_once (ABSPATH.WPINC.'/cache.php'); |
|
| 440 | 440 | |
| 441 | 441 | /* |
| 442 | 442 | * If cache supports reset, reset instead of init if already |
| 443 | 443 | * initialized. Reset signals to the cache that global IDs |
| 444 | 444 | * have changed and it may need to update keys and cleanup caches. |
| 445 | 445 | */ |
| 446 | - if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
|
| 447 | - wp_cache_switch_to_blog( $blog_id ); |
|
| 448 | - elseif ( function_exists( 'wp_cache_init' ) ) |
|
| 446 | + if ( ! $first_init && function_exists('wp_cache_switch_to_blog')) |
|
| 447 | + wp_cache_switch_to_blog($blog_id); |
|
| 448 | + elseif (function_exists('wp_cache_init')) |
|
| 449 | 449 | wp_cache_init(); |
| 450 | 450 | |
| 451 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
| 452 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) ); |
|
| 453 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
| 451 | + if (function_exists('wp_cache_add_global_groups')) { |
|
| 452 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache')); |
|
| 453 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
@@ -463,22 +463,22 @@ discard block |
||
| 463 | 463 | * @access private |
| 464 | 464 | */ |
| 465 | 465 | function wp_not_installed() { |
| 466 | - if ( is_multisite() ) { |
|
| 467 | - if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) { |
|
| 466 | + if (is_multisite()) { |
|
| 467 | + if ( ! is_blog_installed() && ! defined('WP_INSTALLING')) { |
|
| 468 | 468 | nocache_headers(); |
| 469 | 469 | |
| 470 | - wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
|
| 470 | + wp_die(__('The site you have requested is not installed properly. Please contact the system administrator.')); |
|
| 471 | 471 | } |
| 472 | - } elseif ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) { |
|
| 472 | + } elseif ( ! is_blog_installed() && ! defined('WP_INSTALLING')) { |
|
| 473 | 473 | nocache_headers(); |
| 474 | 474 | |
| 475 | - require( ABSPATH . WPINC . '/kses.php' ); |
|
| 476 | - require( ABSPATH . WPINC . '/pluggable.php' ); |
|
| 477 | - require( ABSPATH . WPINC . '/formatting.php' ); |
|
| 475 | + require(ABSPATH.WPINC.'/kses.php'); |
|
| 476 | + require(ABSPATH.WPINC.'/pluggable.php'); |
|
| 477 | + require(ABSPATH.WPINC.'/formatting.php'); |
|
| 478 | 478 | |
| 479 | - $link = wp_guess_url() . '/wp-admin/install.php'; |
|
| 479 | + $link = wp_guess_url().'/wp-admin/install.php'; |
|
| 480 | 480 | |
| 481 | - wp_redirect( $link ); |
|
| 481 | + wp_redirect($link); |
|
| 482 | 482 | die(); |
| 483 | 483 | } |
| 484 | 484 | } |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | */ |
| 498 | 498 | function wp_get_mu_plugins() { |
| 499 | 499 | $mu_plugins = array(); |
| 500 | - if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 500 | + if ( ! is_dir(WPMU_PLUGIN_DIR)) |
|
| 501 | 501 | return $mu_plugins; |
| 502 | - if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
| 502 | + if ( ! $dh = opendir(WPMU_PLUGIN_DIR)) |
|
| 503 | 503 | return $mu_plugins; |
| 504 | - while ( ( $plugin = readdir( $dh ) ) !== false ) { |
|
| 505 | - if ( substr( $plugin, -4 ) == '.php' ) |
|
| 506 | - $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
| 504 | + while (($plugin = readdir($dh)) !== false) { |
|
| 505 | + if (substr($plugin, -4) == '.php') |
|
| 506 | + $mu_plugins[] = WPMU_PLUGIN_DIR.'/'.$plugin; |
|
| 507 | 507 | } |
| 508 | - closedir( $dh ); |
|
| 509 | - sort( $mu_plugins ); |
|
| 508 | + closedir($dh); |
|
| 509 | + sort($mu_plugins); |
|
| 510 | 510 | |
| 511 | 511 | return $mu_plugins; |
| 512 | 512 | } |
@@ -527,27 +527,27 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | function wp_get_active_and_valid_plugins() { |
| 529 | 529 | $plugins = array(); |
| 530 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
| 530 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
| 531 | 531 | |
| 532 | 532 | // Check for hacks file if the option is enabled |
| 533 | - if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
|
| 534 | - _deprecated_file( 'my-hacks.php', '1.5' ); |
|
| 535 | - array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
|
| 533 | + if (get_option('hack_file') && file_exists(ABSPATH.'my-hacks.php')) { |
|
| 534 | + _deprecated_file('my-hacks.php', '1.5'); |
|
| 535 | + array_unshift($plugins, ABSPATH.'my-hacks.php'); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | - if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) |
|
| 538 | + if (empty($active_plugins) || defined('WP_INSTALLING')) |
|
| 539 | 539 | return $plugins; |
| 540 | 540 | |
| 541 | 541 | $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
| 542 | 542 | |
| 543 | - foreach ( $active_plugins as $plugin ) { |
|
| 544 | - if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
| 545 | - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
| 546 | - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
| 543 | + foreach ($active_plugins as $plugin) { |
|
| 544 | + if ( ! validate_file($plugin) // $plugin must validate as file |
|
| 545 | + && '.php' == substr($plugin, -4) // $plugin must end with '.php' |
|
| 546 | + && file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist |
|
| 547 | 547 | // not already included as a network plugin |
| 548 | - && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
|
| 548 | + && ( ! $network_plugins || ! in_array(WP_PLUGIN_DIR.'/'.$plugin, $network_plugins)) |
|
| 549 | 549 | ) |
| 550 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 550 | + $plugins[] = WP_PLUGIN_DIR.'/'.$plugin; |
|
| 551 | 551 | } |
| 552 | 552 | return $plugins; |
| 553 | 553 | } |
@@ -562,10 +562,10 @@ discard block |
||
| 562 | 562 | * @access private |
| 563 | 563 | */ |
| 564 | 564 | function wp_set_internal_encoding() { |
| 565 | - if ( function_exists( 'mb_internal_encoding' ) ) { |
|
| 566 | - $charset = get_option( 'blog_charset' ); |
|
| 567 | - if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
| 568 | - mb_internal_encoding( 'UTF-8' ); |
|
| 565 | + if (function_exists('mb_internal_encoding')) { |
|
| 566 | + $charset = get_option('blog_charset'); |
|
| 567 | + if ( ! $charset || ! @mb_internal_encoding($charset)) |
|
| 568 | + mb_internal_encoding('UTF-8'); |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
@@ -580,20 +580,20 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | function wp_magic_quotes() { |
| 582 | 582 | // If already slashed, strip. |
| 583 | - if ( get_magic_quotes_gpc() ) { |
|
| 584 | - $_GET = stripslashes_deep( $_GET ); |
|
| 585 | - $_POST = stripslashes_deep( $_POST ); |
|
| 586 | - $_COOKIE = stripslashes_deep( $_COOKIE ); |
|
| 583 | + if (get_magic_quotes_gpc()) { |
|
| 584 | + $_GET = stripslashes_deep($_GET); |
|
| 585 | + $_POST = stripslashes_deep($_POST); |
|
| 586 | + $_COOKIE = stripslashes_deep($_COOKIE); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | // Escape with wpdb. |
| 590 | - $_GET = add_magic_quotes( $_GET ); |
|
| 591 | - $_POST = add_magic_quotes( $_POST ); |
|
| 592 | - $_COOKIE = add_magic_quotes( $_COOKIE ); |
|
| 593 | - $_SERVER = add_magic_quotes( $_SERVER ); |
|
| 590 | + $_GET = add_magic_quotes($_GET); |
|
| 591 | + $_POST = add_magic_quotes($_POST); |
|
| 592 | + $_COOKIE = add_magic_quotes($_COOKIE); |
|
| 593 | + $_SERVER = add_magic_quotes($_SERVER); |
|
| 594 | 594 | |
| 595 | 595 | // Force REQUEST to be GET + POST. |
| 596 | - $_REQUEST = array_merge( $_GET, $_POST ); |
|
| 596 | + $_REQUEST = array_merge($_GET, $_POST); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | * |
| 609 | 609 | * @since 1.2.0 |
| 610 | 610 | */ |
| 611 | - do_action( 'shutdown' ); |
|
| 611 | + do_action('shutdown'); |
|
| 612 | 612 | |
| 613 | 613 | wp_cache_close(); |
| 614 | 614 | } |
@@ -622,9 +622,9 @@ discard block |
||
| 622 | 622 | * @param object $object The object to clone. |
| 623 | 623 | * @return object The cloned object. |
| 624 | 624 | */ |
| 625 | -function wp_clone( $object ) { |
|
| 625 | +function wp_clone($object) { |
|
| 626 | 626 | // Use parens for clone to accommodate PHP 4. See #17880 |
| 627 | - return clone( $object ); |
|
| 627 | + return clone($object); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -640,9 +640,9 @@ discard block |
||
| 640 | 640 | * @return bool True if inside WordPress administration interface, false otherwise. |
| 641 | 641 | */ |
| 642 | 642 | function is_admin() { |
| 643 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 643 | + if (isset($GLOBALS['current_screen'])) |
|
| 644 | 644 | return $GLOBALS['current_screen']->in_admin(); |
| 645 | - elseif ( defined( 'WP_ADMIN' ) ) |
|
| 645 | + elseif (defined('WP_ADMIN')) |
|
| 646 | 646 | return WP_ADMIN; |
| 647 | 647 | |
| 648 | 648 | return false; |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | * @return bool True if inside WordPress blog administration pages. |
| 664 | 664 | */ |
| 665 | 665 | function is_blog_admin() { |
| 666 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 667 | - return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
| 668 | - elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
| 666 | + if (isset($GLOBALS['current_screen'])) |
|
| 667 | + return $GLOBALS['current_screen']->in_admin('site'); |
|
| 668 | + elseif (defined('WP_BLOG_ADMIN')) |
|
| 669 | 669 | return WP_BLOG_ADMIN; |
| 670 | 670 | |
| 671 | 671 | return false; |
@@ -686,9 +686,9 @@ discard block |
||
| 686 | 686 | * @return bool True if inside WordPress network administration pages. |
| 687 | 687 | */ |
| 688 | 688 | function is_network_admin() { |
| 689 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 690 | - return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
| 691 | - elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
| 689 | + if (isset($GLOBALS['current_screen'])) |
|
| 690 | + return $GLOBALS['current_screen']->in_admin('network'); |
|
| 691 | + elseif (defined('WP_NETWORK_ADMIN')) |
|
| 692 | 692 | return WP_NETWORK_ADMIN; |
| 693 | 693 | |
| 694 | 694 | return false; |
@@ -710,9 +710,9 @@ discard block |
||
| 710 | 710 | * @return bool True if inside WordPress user administration pages. |
| 711 | 711 | */ |
| 712 | 712 | function is_user_admin() { |
| 713 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 714 | - return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
| 715 | - elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
| 713 | + if (isset($GLOBALS['current_screen'])) |
|
| 714 | + return $GLOBALS['current_screen']->in_admin('user'); |
|
| 715 | + elseif (defined('WP_USER_ADMIN')) |
|
| 716 | 716 | return WP_USER_ADMIN; |
| 717 | 717 | |
| 718 | 718 | return false; |
@@ -726,10 +726,10 @@ discard block |
||
| 726 | 726 | * @return bool True if Multisite is enabled, false otherwise. |
| 727 | 727 | */ |
| 728 | 728 | function is_multisite() { |
| 729 | - if ( defined( 'MULTISITE' ) ) |
|
| 729 | + if (defined('MULTISITE')) |
|
| 730 | 730 | return MULTISITE; |
| 731 | 731 | |
| 732 | - if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
| 732 | + if (defined('SUBDOMAIN_INSTALL') || defined('VHOST') || defined('SUNRISE')) |
|
| 733 | 733 | return true; |
| 734 | 734 | |
| 735 | 735 | return false; |
@@ -771,62 +771,62 @@ discard block |
||
| 771 | 771 | global $text_direction, $wp_locale; |
| 772 | 772 | |
| 773 | 773 | static $loaded = false; |
| 774 | - if ( $loaded ) |
|
| 774 | + if ($loaded) |
|
| 775 | 775 | return; |
| 776 | 776 | $loaded = true; |
| 777 | 777 | |
| 778 | - if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
| 778 | + if (function_exists('did_action') && did_action('init')) |
|
| 779 | 779 | return; |
| 780 | 780 | |
| 781 | 781 | // We need $wp_local_package |
| 782 | - require ABSPATH . WPINC . '/version.php'; |
|
| 782 | + require ABSPATH.WPINC.'/version.php'; |
|
| 783 | 783 | |
| 784 | 784 | // Translation and localization |
| 785 | - require_once ABSPATH . WPINC . '/pomo/mo.php'; |
|
| 786 | - require_once ABSPATH . WPINC . '/l10n.php'; |
|
| 787 | - require_once ABSPATH . WPINC . '/locale.php'; |
|
| 785 | + require_once ABSPATH.WPINC.'/pomo/mo.php'; |
|
| 786 | + require_once ABSPATH.WPINC.'/l10n.php'; |
|
| 787 | + require_once ABSPATH.WPINC.'/locale.php'; |
|
| 788 | 788 | |
| 789 | 789 | // General libraries |
| 790 | - require_once ABSPATH . WPINC . '/plugin.php'; |
|
| 790 | + require_once ABSPATH.WPINC.'/plugin.php'; |
|
| 791 | 791 | |
| 792 | 792 | $locales = $locations = array(); |
| 793 | 793 | |
| 794 | - while ( true ) { |
|
| 795 | - if ( defined( 'WPLANG' ) ) { |
|
| 796 | - if ( '' == WPLANG ) |
|
| 794 | + while (true) { |
|
| 795 | + if (defined('WPLANG')) { |
|
| 796 | + if ('' == WPLANG) |
|
| 797 | 797 | break; |
| 798 | 798 | $locales[] = WPLANG; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( isset( $wp_local_package ) ) |
|
| 801 | + if (isset($wp_local_package)) |
|
| 802 | 802 | $locales[] = $wp_local_package; |
| 803 | 803 | |
| 804 | - if ( ! $locales ) |
|
| 804 | + if ( ! $locales) |
|
| 805 | 805 | break; |
| 806 | 806 | |
| 807 | - if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
| 807 | + if (defined('WP_LANG_DIR') && @is_dir(WP_LANG_DIR)) |
|
| 808 | 808 | $locations[] = WP_LANG_DIR; |
| 809 | 809 | |
| 810 | - if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
| 811 | - $locations[] = WP_CONTENT_DIR . '/languages'; |
|
| 810 | + if (defined('WP_CONTENT_DIR') && @is_dir(WP_CONTENT_DIR.'/languages')) |
|
| 811 | + $locations[] = WP_CONTENT_DIR.'/languages'; |
|
| 812 | 812 | |
| 813 | - if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
| 814 | - $locations[] = ABSPATH . 'wp-content/languages'; |
|
| 813 | + if (@is_dir(ABSPATH.'wp-content/languages')) |
|
| 814 | + $locations[] = ABSPATH.'wp-content/languages'; |
|
| 815 | 815 | |
| 816 | - if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
| 817 | - $locations[] = ABSPATH . WPINC . '/languages'; |
|
| 816 | + if (@is_dir(ABSPATH.WPINC.'/languages')) |
|
| 817 | + $locations[] = ABSPATH.WPINC.'/languages'; |
|
| 818 | 818 | |
| 819 | - if ( ! $locations ) |
|
| 819 | + if ( ! $locations) |
|
| 820 | 820 | break; |
| 821 | 821 | |
| 822 | - $locations = array_unique( $locations ); |
|
| 822 | + $locations = array_unique($locations); |
|
| 823 | 823 | |
| 824 | - foreach ( $locales as $locale ) { |
|
| 825 | - foreach ( $locations as $location ) { |
|
| 826 | - if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
| 827 | - load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
|
| 828 | - if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
| 829 | - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
| 824 | + foreach ($locales as $locale) { |
|
| 825 | + foreach ($locations as $location) { |
|
| 826 | + if (file_exists($location.'/'.$locale.'.mo')) { |
|
| 827 | + load_textdomain('default', $location.'/'.$locale.'.mo'); |
|
| 828 | + if (defined('WP_SETUP_CONFIG') && file_exists($location.'/admin-'.$locale.'.mo')) |
|
| 829 | + load_textdomain('default', $location.'/admin-'.$locale.'.mo'); |
|
| 830 | 830 | break 2; |
| 831 | 831 | } |
| 832 | 832 | } |
@@ -14,19 +14,22 @@ discard block |
||
| 14 | 14 | * @access private |
| 15 | 15 | */ |
| 16 | 16 | function wp_unregister_GLOBALS() { |
| 17 | - if ( !ini_get( 'register_globals' ) ) |
|
| 18 | - return; |
|
| 17 | + if ( !ini_get( 'register_globals' ) ) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | - if ( isset( $_REQUEST['GLOBALS'] ) ) |
|
| 21 | - die( 'GLOBALS overwrite attempt detected' ); |
|
| 21 | + if ( isset( $_REQUEST['GLOBALS'] ) ) { |
|
| 22 | + die( 'GLOBALS overwrite attempt detected' ); |
|
| 23 | + } |
|
| 22 | 24 | |
| 23 | 25 | // Variables that shouldn't be unset |
| 24 | 26 | $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
| 25 | 27 | |
| 26 | 28 | $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
| 27 | - foreach ( $input as $k => $v ) |
|
| 28 | - if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
| 29 | + foreach ( $input as $k => $v ) { |
|
| 30 | + if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
| 29 | 31 | unset( $GLOBALS[$k] ); |
| 32 | + } |
|
| 30 | 33 | } |
| 31 | 34 | } |
| 32 | 35 | |
@@ -61,15 +64,17 @@ discard block |
||
| 61 | 64 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
| 62 | 65 | } else { |
| 63 | 66 | // Use ORIG_PATH_INFO if there is no PATH_INFO |
| 64 | - if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
|
| 65 | - $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
| 67 | + if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { |
|
| 68 | + $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
| 68 | 72 | if ( isset( $_SERVER['PATH_INFO'] ) ) { |
| 69 | - if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
|
| 70 | - $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
|
| 71 | - else |
|
| 72 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
| 73 | + if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { |
|
| 74 | + $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
|
| 75 | + } else { |
|
| 76 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
| 77 | + } |
|
| 73 | 78 | } |
| 74 | 79 | |
| 75 | 80 | // Append the query string if it exists and isn't null |
@@ -80,18 +85,21 @@ discard block |
||
| 80 | 85 | } |
| 81 | 86 | |
| 82 | 87 | // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
| 83 | - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
|
| 84 | - $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
| 88 | + if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
|
| 89 | + $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
| 90 | + } |
|
| 85 | 91 | |
| 86 | 92 | // Fix for Dreamhost and other PHP as CGI hosts |
| 87 | - if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
|
| 88 | - unset( $_SERVER['PATH_INFO'] ); |
|
| 93 | + if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { |
|
| 94 | + unset( $_SERVER['PATH_INFO'] ); |
|
| 95 | + } |
|
| 89 | 96 | |
| 90 | 97 | // Fix empty PHP_SELF |
| 91 | 98 | $PHP_SELF = $_SERVER['PHP_SELF']; |
| 92 | - if ( empty( $PHP_SELF ) ) |
|
| 93 | - $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
| 94 | -} |
|
| 99 | + if ( empty( $PHP_SELF ) ) { |
|
| 100 | + $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
| 101 | + } |
|
| 102 | + } |
|
| 95 | 103 | |
| 96 | 104 | /** |
| 97 | 105 | * Check for the required PHP version, and the MySQL extension or |
@@ -154,15 +162,17 @@ discard block |
||
| 154 | 162 | * @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
| 155 | 163 | */ |
| 156 | 164 | function wp_maintenance() { |
| 157 | - if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) ) |
|
| 158 | - return; |
|
| 165 | + if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) ) { |
|
| 166 | + return; |
|
| 167 | + } |
|
| 159 | 168 | |
| 160 | 169 | global $upgrading; |
| 161 | 170 | |
| 162 | 171 | include( ABSPATH . '.maintenance' ); |
| 163 | 172 | // If the $upgrading timestamp is older than 10 minutes, don't die. |
| 164 | - if ( ( time() - $upgrading ) >= 600 ) |
|
| 165 | - return; |
|
| 173 | + if ( ( time() - $upgrading ) >= 600 ) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 166 | 176 | |
| 167 | 177 | if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
| 168 | 178 | require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
@@ -172,14 +182,18 @@ discard block |
||
| 172 | 182 | wp_load_translations_early(); |
| 173 | 183 | |
| 174 | 184 | $protocol = $_SERVER["SERVER_PROTOCOL"]; |
| 175 | - if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) |
|
| 176 | - $protocol = 'HTTP/1.0'; |
|
| 185 | + if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) { |
|
| 186 | + $protocol = 'HTTP/1.0'; |
|
| 187 | + } |
|
| 177 | 188 | header( "$protocol 503 Service Unavailable", true, 503 ); |
| 178 | 189 | header( 'Content-Type: text/html; charset=utf-8' ); |
| 179 | 190 | header( 'Retry-After: 600' ); |
| 180 | 191 | ?> |
| 181 | 192 | <!DOCTYPE html> |
| 182 | - <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
| 193 | + <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) { |
|
| 194 | + echo ' dir="rtl"'; |
|
| 195 | +} |
|
| 196 | +?>> |
|
| 183 | 197 | <head> |
| 184 | 198 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 185 | 199 | <title><?php _e( 'Maintenance' ); ?></title> |
@@ -230,8 +244,9 @@ discard block |
||
| 230 | 244 | $timeend = microtime( true ); |
| 231 | 245 | $timetotal = $timeend - $timestart; |
| 232 | 246 | $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
| 233 | - if ( $display ) |
|
| 234 | - echo $r; |
|
| 247 | + if ( $display ) { |
|
| 248 | + echo $r; |
|
| 249 | + } |
|
| 235 | 250 | return $r; |
| 236 | 251 | } |
| 237 | 252 | |
@@ -269,10 +284,11 @@ discard block |
||
| 269 | 284 | if ( WP_DEBUG ) { |
| 270 | 285 | error_reporting( E_ALL ); |
| 271 | 286 | |
| 272 | - if ( WP_DEBUG_DISPLAY ) |
|
| 273 | - ini_set( 'display_errors', 1 ); |
|
| 274 | - elseif ( null !== WP_DEBUG_DISPLAY ) |
|
| 275 | - ini_set( 'display_errors', 0 ); |
|
| 287 | + if ( WP_DEBUG_DISPLAY ) { |
|
| 288 | + ini_set( 'display_errors', 1 ); |
|
| 289 | + } elseif ( null !== WP_DEBUG_DISPLAY ) { |
|
| 290 | + ini_set( 'display_errors', 0 ); |
|
| 291 | + } |
|
| 276 | 292 | |
| 277 | 293 | if ( WP_DEBUG_LOG ) { |
| 278 | 294 | ini_set( 'log_errors', 1 ); |
@@ -281,9 +297,10 @@ discard block |
||
| 281 | 297 | } else { |
| 282 | 298 | error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
| 283 | 299 | } |
| 284 | - if ( defined( 'XMLRPC_REQUEST' ) ) |
|
| 285 | - ini_set( 'display_errors', 0 ); |
|
| 286 | -} |
|
| 300 | + if ( defined( 'XMLRPC_REQUEST' ) ) { |
|
| 301 | + ini_set( 'display_errors', 0 ); |
|
| 302 | + } |
|
| 303 | + } |
|
| 287 | 304 | |
| 288 | 305 | /** |
| 289 | 306 | * Set the location of the language directory. |
@@ -341,11 +358,13 @@ discard block |
||
| 341 | 358 | global $wpdb; |
| 342 | 359 | |
| 343 | 360 | require_once( ABSPATH . WPINC . '/wp-db.php' ); |
| 344 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
| 345 | - require_once( WP_CONTENT_DIR . '/db.php' ); |
|
| 361 | + if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
|
| 362 | + require_once( WP_CONTENT_DIR . '/db.php' ); |
|
| 363 | + } |
|
| 346 | 364 | |
| 347 | - if ( isset( $wpdb ) ) |
|
| 348 | - return; |
|
| 365 | + if ( isset( $wpdb ) ) { |
|
| 366 | + return; |
|
| 367 | + } |
|
| 349 | 368 | |
| 350 | 369 | $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
| 351 | 370 | } |
@@ -364,8 +383,9 @@ discard block |
||
| 364 | 383 | */ |
| 365 | 384 | function wp_set_wpdb_vars() { |
| 366 | 385 | global $wpdb, $table_prefix; |
| 367 | - if ( !empty( $wpdb->error ) ) |
|
| 368 | - dead_db(); |
|
| 386 | + if ( !empty( $wpdb->error ) ) { |
|
| 387 | + dead_db(); |
|
| 388 | + } |
|
| 369 | 389 | |
| 370 | 390 | $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
| 371 | 391 | 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
@@ -397,8 +417,9 @@ discard block |
||
| 397 | 417 | function wp_using_ext_object_cache( $using = null ) { |
| 398 | 418 | global $_wp_using_ext_object_cache; |
| 399 | 419 | $current_using = $_wp_using_ext_object_cache; |
| 400 | - if ( null !== $using ) |
|
| 401 | - $_wp_using_ext_object_cache = $using; |
|
| 420 | + if ( null !== $using ) { |
|
| 421 | + $_wp_using_ext_object_cache = $using; |
|
| 422 | + } |
|
| 402 | 423 | return $current_using; |
| 403 | 424 | } |
| 404 | 425 | |
@@ -420,8 +441,9 @@ discard block |
||
| 420 | 441 | if ( ! function_exists( 'wp_cache_init' ) ) { |
| 421 | 442 | if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
| 422 | 443 | require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
| 423 | - if ( function_exists( 'wp_cache_init' ) ) |
|
| 424 | - wp_using_ext_object_cache( true ); |
|
| 444 | + if ( function_exists( 'wp_cache_init' ) ) { |
|
| 445 | + wp_using_ext_object_cache( true ); |
|
| 446 | + } |
|
| 425 | 447 | } |
| 426 | 448 | |
| 427 | 449 | $first_init = true; |
@@ -435,18 +457,20 @@ discard block |
||
| 435 | 457 | wp_using_ext_object_cache( true ); |
| 436 | 458 | } |
| 437 | 459 | |
| 438 | - if ( ! wp_using_ext_object_cache() ) |
|
| 439 | - require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
| 460 | + if ( ! wp_using_ext_object_cache() ) { |
|
| 461 | + require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
| 462 | + } |
|
| 440 | 463 | |
| 441 | 464 | /* |
| 442 | 465 | * If cache supports reset, reset instead of init if already |
| 443 | 466 | * initialized. Reset signals to the cache that global IDs |
| 444 | 467 | * have changed and it may need to update keys and cleanup caches. |
| 445 | 468 | */ |
| 446 | - if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
|
| 447 | - wp_cache_switch_to_blog( $blog_id ); |
|
| 448 | - elseif ( function_exists( 'wp_cache_init' ) ) |
|
| 449 | - wp_cache_init(); |
|
| 469 | + if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
| 470 | + wp_cache_switch_to_blog( $blog_id ); |
|
| 471 | + } elseif ( function_exists( 'wp_cache_init' ) ) { |
|
| 472 | + wp_cache_init(); |
|
| 473 | + } |
|
| 450 | 474 | |
| 451 | 475 | if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
| 452 | 476 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) ); |
@@ -497,13 +521,16 @@ discard block |
||
| 497 | 521 | */ |
| 498 | 522 | function wp_get_mu_plugins() { |
| 499 | 523 | $mu_plugins = array(); |
| 500 | - if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 501 | - return $mu_plugins; |
|
| 502 | - if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
| 503 | - return $mu_plugins; |
|
| 524 | + if ( !is_dir( WPMU_PLUGIN_DIR ) ) { |
|
| 525 | + return $mu_plugins; |
|
| 526 | + } |
|
| 527 | + if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) { |
|
| 528 | + return $mu_plugins; |
|
| 529 | + } |
|
| 504 | 530 | while ( ( $plugin = readdir( $dh ) ) !== false ) { |
| 505 | - if ( substr( $plugin, -4 ) == '.php' ) |
|
| 506 | - $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
| 531 | + if ( substr( $plugin, -4 ) == '.php' ) { |
|
| 532 | + $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
| 533 | + } |
|
| 507 | 534 | } |
| 508 | 535 | closedir( $dh ); |
| 509 | 536 | sort( $mu_plugins ); |
@@ -535,8 +562,9 @@ discard block |
||
| 535 | 562 | array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
| 536 | 563 | } |
| 537 | 564 | |
| 538 | - if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) |
|
| 539 | - return $plugins; |
|
| 565 | + if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) { |
|
| 566 | + return $plugins; |
|
| 567 | + } |
|
| 540 | 568 | |
| 541 | 569 | $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
| 542 | 570 | |
@@ -546,8 +574,9 @@ discard block |
||
| 546 | 574 | && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
| 547 | 575 | // not already included as a network plugin |
| 548 | 576 | && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
| 549 | - ) |
|
| 550 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 577 | + ) { |
|
| 578 | + $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 579 | + } |
|
| 551 | 580 | } |
| 552 | 581 | return $plugins; |
| 553 | 582 | } |
@@ -564,8 +593,9 @@ discard block |
||
| 564 | 593 | function wp_set_internal_encoding() { |
| 565 | 594 | if ( function_exists( 'mb_internal_encoding' ) ) { |
| 566 | 595 | $charset = get_option( 'blog_charset' ); |
| 567 | - if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
| 568 | - mb_internal_encoding( 'UTF-8' ); |
|
| 596 | + if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { |
|
| 597 | + mb_internal_encoding( 'UTF-8' ); |
|
| 598 | + } |
|
| 569 | 599 | } |
| 570 | 600 | } |
| 571 | 601 | |
@@ -640,10 +670,11 @@ discard block |
||
| 640 | 670 | * @return bool True if inside WordPress administration interface, false otherwise. |
| 641 | 671 | */ |
| 642 | 672 | function is_admin() { |
| 643 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 644 | - return $GLOBALS['current_screen']->in_admin(); |
|
| 645 | - elseif ( defined( 'WP_ADMIN' ) ) |
|
| 646 | - return WP_ADMIN; |
|
| 673 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
| 674 | + return $GLOBALS['current_screen']->in_admin(); |
|
| 675 | + } elseif ( defined( 'WP_ADMIN' ) ) { |
|
| 676 | + return WP_ADMIN; |
|
| 677 | + } |
|
| 647 | 678 | |
| 648 | 679 | return false; |
| 649 | 680 | } |
@@ -663,10 +694,11 @@ discard block |
||
| 663 | 694 | * @return bool True if inside WordPress blog administration pages. |
| 664 | 695 | */ |
| 665 | 696 | function is_blog_admin() { |
| 666 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 667 | - return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
| 668 | - elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
| 669 | - return WP_BLOG_ADMIN; |
|
| 697 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
| 698 | + return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
| 699 | + } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { |
|
| 700 | + return WP_BLOG_ADMIN; |
|
| 701 | + } |
|
| 670 | 702 | |
| 671 | 703 | return false; |
| 672 | 704 | } |
@@ -686,10 +718,11 @@ discard block |
||
| 686 | 718 | * @return bool True if inside WordPress network administration pages. |
| 687 | 719 | */ |
| 688 | 720 | function is_network_admin() { |
| 689 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 690 | - return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
| 691 | - elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
| 692 | - return WP_NETWORK_ADMIN; |
|
| 721 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
| 722 | + return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
| 723 | + } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { |
|
| 724 | + return WP_NETWORK_ADMIN; |
|
| 725 | + } |
|
| 693 | 726 | |
| 694 | 727 | return false; |
| 695 | 728 | } |
@@ -710,10 +743,11 @@ discard block |
||
| 710 | 743 | * @return bool True if inside WordPress user administration pages. |
| 711 | 744 | */ |
| 712 | 745 | function is_user_admin() { |
| 713 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 714 | - return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
| 715 | - elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
| 716 | - return WP_USER_ADMIN; |
|
| 746 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
| 747 | + return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
| 748 | + } elseif ( defined( 'WP_USER_ADMIN' ) ) { |
|
| 749 | + return WP_USER_ADMIN; |
|
| 750 | + } |
|
| 717 | 751 | |
| 718 | 752 | return false; |
| 719 | 753 | } |
@@ -726,11 +760,13 @@ discard block |
||
| 726 | 760 | * @return bool True if Multisite is enabled, false otherwise. |
| 727 | 761 | */ |
| 728 | 762 | function is_multisite() { |
| 729 | - if ( defined( 'MULTISITE' ) ) |
|
| 730 | - return MULTISITE; |
|
| 763 | + if ( defined( 'MULTISITE' ) ) { |
|
| 764 | + return MULTISITE; |
|
| 765 | + } |
|
| 731 | 766 | |
| 732 | - if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
| 733 | - return true; |
|
| 767 | + if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { |
|
| 768 | + return true; |
|
| 769 | + } |
|
| 734 | 770 | |
| 735 | 771 | return false; |
| 736 | 772 | } |
@@ -771,12 +807,14 @@ discard block |
||
| 771 | 807 | global $text_direction, $wp_locale; |
| 772 | 808 | |
| 773 | 809 | static $loaded = false; |
| 774 | - if ( $loaded ) |
|
| 775 | - return; |
|
| 810 | + if ( $loaded ) { |
|
| 811 | + return; |
|
| 812 | + } |
|
| 776 | 813 | $loaded = true; |
| 777 | 814 | |
| 778 | - if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
| 779 | - return; |
|
| 815 | + if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { |
|
| 816 | + return; |
|
| 817 | + } |
|
| 780 | 818 | |
| 781 | 819 | // We need $wp_local_package |
| 782 | 820 | require ABSPATH . WPINC . '/version.php'; |
@@ -793,31 +831,39 @@ discard block |
||
| 793 | 831 | |
| 794 | 832 | while ( true ) { |
| 795 | 833 | if ( defined( 'WPLANG' ) ) { |
| 796 | - if ( '' == WPLANG ) |
|
| 797 | - break; |
|
| 834 | + if ( '' == WPLANG ) { |
|
| 835 | + break; |
|
| 836 | + } |
|
| 798 | 837 | $locales[] = WPLANG; |
| 799 | 838 | } |
| 800 | 839 | |
| 801 | - if ( isset( $wp_local_package ) ) |
|
| 802 | - $locales[] = $wp_local_package; |
|
| 840 | + if ( isset( $wp_local_package ) ) { |
|
| 841 | + $locales[] = $wp_local_package; |
|
| 842 | + } |
|
| 803 | 843 | |
| 804 | - if ( ! $locales ) |
|
| 805 | - break; |
|
| 844 | + if ( ! $locales ) { |
|
| 845 | + break; |
|
| 846 | + } |
|
| 806 | 847 | |
| 807 | - if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
| 808 | - $locations[] = WP_LANG_DIR; |
|
| 848 | + if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { |
|
| 849 | + $locations[] = WP_LANG_DIR; |
|
| 850 | + } |
|
| 809 | 851 | |
| 810 | - if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
| 811 | - $locations[] = WP_CONTENT_DIR . '/languages'; |
|
| 852 | + if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { |
|
| 853 | + $locations[] = WP_CONTENT_DIR . '/languages'; |
|
| 854 | + } |
|
| 812 | 855 | |
| 813 | - if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
| 814 | - $locations[] = ABSPATH . 'wp-content/languages'; |
|
| 856 | + if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { |
|
| 857 | + $locations[] = ABSPATH . 'wp-content/languages'; |
|
| 858 | + } |
|
| 815 | 859 | |
| 816 | - if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
| 817 | - $locations[] = ABSPATH . WPINC . '/languages'; |
|
| 860 | + if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
|
| 861 | + $locations[] = ABSPATH . WPINC . '/languages'; |
|
| 862 | + } |
|
| 818 | 863 | |
| 819 | - if ( ! $locations ) |
|
| 820 | - break; |
|
| 864 | + if ( ! $locations ) { |
|
| 865 | + break; |
|
| 866 | + } |
|
| 821 | 867 | |
| 822 | 868 | $locations = array_unique( $locations ); |
| 823 | 869 | |
@@ -825,8 +871,9 @@ discard block |
||
| 825 | 871 | foreach ( $locations as $location ) { |
| 826 | 872 | if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
| 827 | 873 | load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
| 828 | - if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
| 829 | - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
| 874 | + if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { |
|
| 875 | + load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
| 876 | + } |
|
| 830 | 877 | break 2; |
| 831 | 878 | } |
| 832 | 879 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param int $width Image width in pixels. |
| 288 | 288 | * @param int $height Image height in pixels. |
| 289 | - * @param bool|array $crop Optional. Whether to crop images to specified height and width or resize. |
|
| 289 | + * @param boolean $crop Optional. Whether to crop images to specified height and width or resize. |
|
| 290 | 290 | * An array can specify positioning of the crop area. Default false. |
| 291 | 291 | */ |
| 292 | 292 | function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) { |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param string $alt Image Description for the alt attribute. |
| 312 | 312 | * @param string $title Image Description for the title attribute. |
| 313 | 313 | * @param string $align Part of the class name for aligning the image. |
| 314 | - * @param string|array $size Optional. Registered image size to retrieve a tag for, or flat array |
|
| 314 | + * @param string $size Optional. Registered image size to retrieve a tag for, or flat array |
|
| 315 | 315 | * of height and width values. Default 'medium'. |
| 316 | 316 | * @return string HTML IMG element for given image attachment |
| 317 | 317 | */ |
@@ -3200,7 +3200,7 @@ discard block |
||
| 3200 | 3200 | * @since 3.6.0 |
| 3201 | 3201 | * |
| 3202 | 3202 | * @param string $type Mime type. |
| 3203 | - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3203 | + * @param integer $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3204 | 3204 | * @return array Found attachments. |
| 3205 | 3205 | */ |
| 3206 | 3206 | function get_attached_media( $type, $post = 0 ) { |
@@ -3339,7 +3339,7 @@ discard block |
||
| 3339 | 3339 | * |
| 3340 | 3340 | * @since 3.6.0 |
| 3341 | 3341 | * |
| 3342 | - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3342 | + * @param integer $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3343 | 3343 | * @param bool $html Optional. Whether to return HTML or data. Default is true. |
| 3344 | 3344 | * @return string|array Gallery data and srcs parsed from the expanded shortcode. |
| 3345 | 3345 | */ |
@@ -3366,7 +3366,7 @@ discard block |
||
| 3366 | 3366 | * |
| 3367 | 3367 | * @see get_post_galleries() |
| 3368 | 3368 | * |
| 3369 | - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. |
|
| 3369 | + * @param integer $post Optional. Post ID or WP_Post object. Default is global `$post`. |
|
| 3370 | 3370 | * @return array A list of lists, each containing image srcs parsed. |
| 3371 | 3371 | * from an expanded shortcode |
| 3372 | 3372 | */ |
@@ -3382,7 +3382,7 @@ discard block |
||
| 3382 | 3382 | * |
| 3383 | 3383 | * @see get_post_gallery() |
| 3384 | 3384 | * |
| 3385 | - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. |
|
| 3385 | + * @param integer $post Optional. Post ID or WP_Post object. Default is global `$post`. |
|
| 3386 | 3386 | * @return array A list of a gallery's image srcs in order. |
| 3387 | 3387 | */ |
| 3388 | 3388 | function get_post_gallery_images( $post = 0 ) { |
@@ -3461,7 +3461,7 @@ discard block |
||
| 3461 | 3461 | * |
| 3462 | 3462 | * @global string $wp_version |
| 3463 | 3463 | * |
| 3464 | - * @return array The relevant CSS file URLs. |
|
| 3464 | + * @return string[] The relevant CSS file URLs. |
|
| 3465 | 3465 | */ |
| 3466 | 3466 | function wpview_media_sandbox_styles() { |
| 3467 | 3467 | $version = 'ver=' . $GLOBALS['wp_version']; |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress API for media display. |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Media |
|
| 7 | - */ |
|
| 3 | + * WordPress API for media display. |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Media |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Scale down the default size of an image. |
@@ -1533,28 +1533,28 @@ discard block |
||
| 1533 | 1533 | return apply_filters( 'wp_get_attachment_id3_keys', $fields, $attachment, $context ); |
| 1534 | 1534 | } |
| 1535 | 1535 | /** |
| 1536 | - * Builds the Audio shortcode output. |
|
| 1537 | - * |
|
| 1538 | - * This implements the functionality of the Audio Shortcode for displaying |
|
| 1539 | - * WordPress mp3s in a post. |
|
| 1540 | - * |
|
| 1541 | - * @since 3.6.0 |
|
| 1542 | - * |
|
| 1543 | - * @staticvar int $instance |
|
| 1544 | - * |
|
| 1545 | - * @param array $attr { |
|
| 1546 | - * Attributes of the audio shortcode. |
|
| 1547 | - * |
|
| 1548 | - * @type string $src URL to the source of the audio file. Default empty. |
|
| 1549 | - * @type string $loop The 'loop' attribute for the `<audio>` element. Default empty. |
|
| 1550 | - * @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty. |
|
| 1551 | - * @type string $preload The 'preload' attribute for the `<audio>` element. Default empty. |
|
| 1552 | - * @type string $class The 'class' attribute for the `<audio>` element. Default 'wp-audio-shortcode'. |
|
| 1553 | - * @type string $style The 'style' attribute for the `<audio>` element. Default 'width: 100%'. |
|
| 1554 | - * } |
|
| 1555 | - * @param string $content Shortcode content. |
|
| 1556 | - * @return string|void HTML content to display audio. |
|
| 1557 | - */ |
|
| 1536 | + * Builds the Audio shortcode output. |
|
| 1537 | + * |
|
| 1538 | + * This implements the functionality of the Audio Shortcode for displaying |
|
| 1539 | + * WordPress mp3s in a post. |
|
| 1540 | + * |
|
| 1541 | + * @since 3.6.0 |
|
| 1542 | + * |
|
| 1543 | + * @staticvar int $instance |
|
| 1544 | + * |
|
| 1545 | + * @param array $attr { |
|
| 1546 | + * Attributes of the audio shortcode. |
|
| 1547 | + * |
|
| 1548 | + * @type string $src URL to the source of the audio file. Default empty. |
|
| 1549 | + * @type string $loop The 'loop' attribute for the `<audio>` element. Default empty. |
|
| 1550 | + * @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty. |
|
| 1551 | + * @type string $preload The 'preload' attribute for the `<audio>` element. Default empty. |
|
| 1552 | + * @type string $class The 'class' attribute for the `<audio>` element. Default 'wp-audio-shortcode'. |
|
| 1553 | + * @type string $style The 'style' attribute for the `<audio>` element. Default 'width: 100%'. |
|
| 1554 | + * } |
|
| 1555 | + * @param string $content Shortcode content. |
|
| 1556 | + * @return string|void HTML content to display audio. |
|
| 1557 | + */ |
|
| 1558 | 1558 | function wp_audio_shortcode( $attr, $content = '' ) { |
| 1559 | 1559 | $post_id = get_post() ? get_the_ID() : 0; |
| 1560 | 1560 | |
@@ -37,31 +37,31 @@ discard block |
||
| 37 | 37 | * (like inserting into an editor). Default null. |
| 38 | 38 | * @return array Width and height of what the result image should resize to. |
| 39 | 39 | */ |
| 40 | -function image_constrain_size_for_editor( $width, $height, $size = 'medium', $context = null ) { |
|
| 40 | +function image_constrain_size_for_editor($width, $height, $size = 'medium', $context = null) { |
|
| 41 | 41 | global $content_width, $_wp_additional_image_sizes; |
| 42 | 42 | |
| 43 | - if ( ! $context ) |
|
| 43 | + if ( ! $context) |
|
| 44 | 44 | $context = is_admin() ? 'edit' : 'display'; |
| 45 | 45 | |
| 46 | - if ( is_array($size) ) { |
|
| 46 | + if (is_array($size)) { |
|
| 47 | 47 | $max_width = $size[0]; |
| 48 | 48 | $max_height = $size[1]; |
| 49 | 49 | } |
| 50 | - elseif ( $size == 'thumb' || $size == 'thumbnail' ) { |
|
| 50 | + elseif ($size == 'thumb' || $size == 'thumbnail') { |
|
| 51 | 51 | $max_width = intval(get_option('thumbnail_size_w')); |
| 52 | 52 | $max_height = intval(get_option('thumbnail_size_h')); |
| 53 | 53 | // last chance thumbnail size defaults |
| 54 | - if ( !$max_width && !$max_height ) { |
|
| 54 | + if ( ! $max_width && ! $max_height) { |
|
| 55 | 55 | $max_width = 128; |
| 56 | 56 | $max_height = 96; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - elseif ( $size == 'medium' ) { |
|
| 59 | + elseif ($size == 'medium') { |
|
| 60 | 60 | $max_width = intval(get_option('medium_size_w')); |
| 61 | 61 | $max_height = intval(get_option('medium_size_h')); |
| 62 | 62 | // if no width is set, default to the theme content width if available |
| 63 | 63 | } |
| 64 | - elseif ( $size == 'large' ) { |
|
| 64 | + elseif ($size == 'large') { |
|
| 65 | 65 | /* |
| 66 | 66 | * We're inserting a large size image into the editor. If it's a really |
| 67 | 67 | * big image we'll scale it down to fit reasonably within the editor |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | $max_width = intval(get_option('large_size_w')); |
| 72 | 72 | $max_height = intval(get_option('large_size_h')); |
| 73 | - if ( intval($content_width) > 0 ) |
|
| 74 | - $max_width = min( intval($content_width), $max_width ); |
|
| 75 | - } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) { |
|
| 76 | - $max_width = intval( $_wp_additional_image_sizes[$size]['width'] ); |
|
| 77 | - $max_height = intval( $_wp_additional_image_sizes[$size]['height'] ); |
|
| 78 | - if ( intval($content_width) > 0 && 'edit' == $context ) // Only in admin. Assume that theme authors know what they're doing. |
|
| 79 | - $max_width = min( intval($content_width), $max_width ); |
|
| 73 | + if (intval($content_width) > 0) |
|
| 74 | + $max_width = min(intval($content_width), $max_width); |
|
| 75 | + } elseif (isset($_wp_additional_image_sizes) && count($_wp_additional_image_sizes) && in_array($size, array_keys($_wp_additional_image_sizes))) { |
|
| 76 | + $max_width = intval($_wp_additional_image_sizes[$size]['width']); |
|
| 77 | + $max_height = intval($_wp_additional_image_sizes[$size]['height']); |
|
| 78 | + if (intval($content_width) > 0 && 'edit' == $context) // Only in admin. Assume that theme authors know what they're doing. |
|
| 79 | + $max_width = min(intval($content_width), $max_width); |
|
| 80 | 80 | } |
| 81 | 81 | // $size == 'full' has no constraint |
| 82 | 82 | else { |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | * Possible values are 'display' (like in a theme) |
| 97 | 97 | * or 'edit' (like inserting into an editor). |
| 98 | 98 | */ |
| 99 | - list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size, $context ); |
|
| 99 | + list($max_width, $max_height) = apply_filters('editor_max_image_size', array($max_width, $max_height), $size, $context); |
|
| 100 | 100 | |
| 101 | - return wp_constrain_dimensions( $width, $height, $max_width, $max_height ); |
|
| 101 | + return wp_constrain_dimensions($width, $height, $max_width, $max_height); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @param int|string $height Image height in pixels. |
| 119 | 119 | * @return string HTML attributes for width and, or height. |
| 120 | 120 | */ |
| 121 | -function image_hwstring( $width, $height ) { |
|
| 121 | +function image_hwstring($width, $height) { |
|
| 122 | 122 | $out = ''; |
| 123 | 123 | if ($width) |
| 124 | 124 | $out .= 'width="'.intval($width).'" '; |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * or flat array of height and width values. Default 'medium'. |
| 151 | 151 | * @return false|array False on failure, array on success. |
| 152 | 152 | */ |
| 153 | -function image_downsize( $id, $size = 'medium' ) { |
|
| 153 | +function image_downsize($id, $size = 'medium') { |
|
| 154 | 154 | |
| 155 | - if ( !wp_attachment_is_image($id) ) |
|
| 155 | + if ( ! wp_attachment_is_image($id)) |
|
| 156 | 156 | return false; |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param int $id Attachment ID for image. |
| 168 | 168 | * @param array|string $size Size of image, either array or string. Default 'medium'. |
| 169 | 169 | */ |
| 170 | - if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) { |
|
| 170 | + if ($out = apply_filters('image_downsize', false, $id, $size)) { |
|
| 171 | 171 | return $out; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,32 +178,32 @@ discard block |
||
| 178 | 178 | $img_url_basename = wp_basename($img_url); |
| 179 | 179 | |
| 180 | 180 | // try for a new style intermediate size |
| 181 | - if ( $intermediate = image_get_intermediate_size($id, $size) ) { |
|
| 181 | + if ($intermediate = image_get_intermediate_size($id, $size)) { |
|
| 182 | 182 | $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url); |
| 183 | 183 | $width = $intermediate['width']; |
| 184 | 184 | $height = $intermediate['height']; |
| 185 | 185 | $is_intermediate = true; |
| 186 | 186 | } |
| 187 | - elseif ( $size == 'thumbnail' ) { |
|
| 187 | + elseif ($size == 'thumbnail') { |
|
| 188 | 188 | // fall back to the old thumbnail |
| 189 | - if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) { |
|
| 189 | + if (($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file)) { |
|
| 190 | 190 | $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url); |
| 191 | 191 | $width = $info[0]; |
| 192 | 192 | $height = $info[1]; |
| 193 | 193 | $is_intermediate = true; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | - if ( !$width && !$height && isset( $meta['width'], $meta['height'] ) ) { |
|
| 196 | + if ( ! $width && ! $height && isset($meta['width'], $meta['height'])) { |
|
| 197 | 197 | // any other type: use the real image |
| 198 | 198 | $width = $meta['width']; |
| 199 | 199 | $height = $meta['height']; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( $img_url) { |
|
| 202 | + if ($img_url) { |
|
| 203 | 203 | // we have the actual image size, but might need to further constrain it if content_width is narrower |
| 204 | - list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size ); |
|
| 204 | + list($width, $height) = image_constrain_size_for_editor($width, $height, $size); |
|
| 205 | 205 | |
| 206 | - return array( $img_url, $width, $height, $is_intermediate ); |
|
| 206 | + return array($img_url, $width, $height, $is_intermediate); |
|
| 207 | 207 | } |
| 208 | 208 | return false; |
| 209 | 209 | |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | * @param bool|array $crop Optional. Whether to crop images to specified height and width or resize. |
| 231 | 231 | * An array can specify positioning of the crop area. Default false. |
| 232 | 232 | */ |
| 233 | -function add_image_size( $name, $width = 0, $height = 0, $crop = false ) { |
|
| 233 | +function add_image_size($name, $width = 0, $height = 0, $crop = false) { |
|
| 234 | 234 | global $_wp_additional_image_sizes; |
| 235 | 235 | |
| 236 | - $_wp_additional_image_sizes[ $name ] = array( |
|
| 237 | - 'width' => absint( $width ), |
|
| 238 | - 'height' => absint( $height ), |
|
| 236 | + $_wp_additional_image_sizes[$name] = array( |
|
| 237 | + 'width' => absint($width), |
|
| 238 | + 'height' => absint($height), |
|
| 239 | 239 | 'crop' => $crop, |
| 240 | 240 | ); |
| 241 | 241 | } |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | * @param string $name The image size to check. |
| 251 | 251 | * @return bool True if the image size exists, false if not. |
| 252 | 252 | */ |
| 253 | -function has_image_size( $name ) { |
|
| 253 | +function has_image_size($name) { |
|
| 254 | 254 | global $_wp_additional_image_sizes; |
| 255 | 255 | |
| 256 | - return isset( $_wp_additional_image_sizes[ $name ] ); |
|
| 256 | + return isset($_wp_additional_image_sizes[$name]); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | * @param string $name The image size to remove. |
| 267 | 267 | * @return bool True if the image size was successfully removed, false on failure. |
| 268 | 268 | */ |
| 269 | -function remove_image_size( $name ) { |
|
| 269 | +function remove_image_size($name) { |
|
| 270 | 270 | global $_wp_additional_image_sizes; |
| 271 | 271 | |
| 272 | - if ( isset( $_wp_additional_image_sizes[ $name ] ) ) { |
|
| 273 | - unset( $_wp_additional_image_sizes[ $name ] ); |
|
| 272 | + if (isset($_wp_additional_image_sizes[$name])) { |
|
| 273 | + unset($_wp_additional_image_sizes[$name]); |
|
| 274 | 274 | return true; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param bool|array $crop Optional. Whether to crop images to specified height and width or resize. |
| 290 | 290 | * An array can specify positioning of the crop area. Default false. |
| 291 | 291 | */ |
| 292 | -function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) { |
|
| 293 | - add_image_size( 'post-thumbnail', $width, $height, $crop ); |
|
| 292 | +function set_post_thumbnail_size($width = 0, $height = 0, $crop = false) { |
|
| 293 | + add_image_size('post-thumbnail', $width, $height, $crop); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | * of height and width values. Default 'medium'. |
| 316 | 316 | * @return string HTML IMG element for given image attachment |
| 317 | 317 | */ |
| 318 | -function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) { |
|
| 318 | +function get_image_tag($id, $alt, $title, $align, $size = 'medium') { |
|
| 319 | 319 | |
| 320 | - list( $img_src, $width, $height ) = image_downsize($id, $size); |
|
| 320 | + list($img_src, $width, $height) = image_downsize($id, $size); |
|
| 321 | 321 | $hwstring = image_hwstring($width, $height); |
| 322 | 322 | |
| 323 | - $title = $title ? 'title="' . esc_attr( $title ) . '" ' : ''; |
|
| 323 | + $title = $title ? 'title="'.esc_attr($title).'" ' : ''; |
|
| 324 | 324 | |
| 325 | - $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id; |
|
| 325 | + $class = 'align'.esc_attr($align).' size-'.esc_attr($size).' wp-image-'.$id; |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Filter the value of the attachment's image tag class attribute. |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | * @param string $align Part of the class name for aligning the image. |
| 335 | 335 | * @param string $size Optional. Default is 'medium'. |
| 336 | 336 | */ |
| 337 | - $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size ); |
|
| 337 | + $class = apply_filters('get_image_tag_class', $class, $id, $align, $size); |
|
| 338 | 338 | |
| 339 | - $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />'; |
|
| 339 | + $html = '<img src="'.esc_attr($img_src).'" alt="'.esc_attr($alt).'" '.$title.$hwstring.'class="'.$class.'" />'; |
|
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * Filter the HTML content for the image tag. |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param string $align Part of the class name for aligning the image. |
| 351 | 351 | * @param string $size Optional. Default is 'medium'. |
| 352 | 352 | */ |
| 353 | - return apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size ); |
|
| 353 | + return apply_filters('get_image_tag', $html, $id, $alt, $title, $align, $size); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -367,28 +367,28 @@ discard block |
||
| 367 | 367 | * @param int $max_height Optional. Max height in pixels to constrain to. Default 0. |
| 368 | 368 | * @return array First item is the width, the second item is the height. |
| 369 | 369 | */ |
| 370 | -function wp_constrain_dimensions( $current_width, $current_height, $max_width = 0, $max_height = 0 ) { |
|
| 371 | - if ( !$max_width && !$max_height ) |
|
| 372 | - return array( $current_width, $current_height ); |
|
| 370 | +function wp_constrain_dimensions($current_width, $current_height, $max_width = 0, $max_height = 0) { |
|
| 371 | + if ( ! $max_width && ! $max_height) |
|
| 372 | + return array($current_width, $current_height); |
|
| 373 | 373 | |
| 374 | 374 | $width_ratio = $height_ratio = 1.0; |
| 375 | 375 | $did_width = $did_height = false; |
| 376 | 376 | |
| 377 | - if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) { |
|
| 377 | + if ($max_width > 0 && $current_width > 0 && $current_width > $max_width) { |
|
| 378 | 378 | $width_ratio = $max_width / $current_width; |
| 379 | 379 | $did_width = true; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height ) { |
|
| 382 | + if ($max_height > 0 && $current_height > 0 && $current_height > $max_height) { |
|
| 383 | 383 | $height_ratio = $max_height / $current_height; |
| 384 | 384 | $did_height = true; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Calculate the larger/smaller ratios |
| 388 | - $smaller_ratio = min( $width_ratio, $height_ratio ); |
|
| 389 | - $larger_ratio = max( $width_ratio, $height_ratio ); |
|
| 388 | + $smaller_ratio = min($width_ratio, $height_ratio); |
|
| 389 | + $larger_ratio = max($width_ratio, $height_ratio); |
|
| 390 | 390 | |
| 391 | - if ( (int) round( $current_width * $larger_ratio ) > $max_width || (int) round( $current_height * $larger_ratio ) > $max_height ) { |
|
| 391 | + if ((int) round($current_width * $larger_ratio) > $max_width || (int) round($current_height * $larger_ratio) > $max_height) { |
|
| 392 | 392 | // The larger ratio is too big. It would result in an overflow. |
| 393 | 393 | $ratio = $smaller_ratio; |
| 394 | 394 | } else { |
@@ -397,20 +397,20 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | // Very small dimensions may result in 0, 1 should be the minimum. |
| 400 | - $w = max ( 1, (int) round( $current_width * $ratio ) ); |
|
| 401 | - $h = max ( 1, (int) round( $current_height * $ratio ) ); |
|
| 400 | + $w = max(1, (int) round($current_width * $ratio)); |
|
| 401 | + $h = max(1, (int) round($current_height * $ratio)); |
|
| 402 | 402 | |
| 403 | 403 | // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short |
| 404 | 404 | // We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result. |
| 405 | 405 | // Thus we look for dimensions that are one pixel shy of the max value and bump them up |
| 406 | 406 | |
| 407 | 407 | // Note: $did_width means it is possible $smaller_ratio == $width_ratio. |
| 408 | - if ( $did_width && $w == $max_width - 1 ) { |
|
| 408 | + if ($did_width && $w == $max_width - 1) { |
|
| 409 | 409 | $w = $max_width; // Round it up |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Note: $did_height means it is possible $smaller_ratio == $height_ratio. |
| 413 | - if ( $did_height && $h == $max_height - 1 ) { |
|
| 413 | + if ($did_height && $h == $max_height - 1) { |
|
| 414 | 414 | $h = $max_height; // Round it up |
| 415 | 415 | } |
| 416 | 416 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param int $max_width The maximum width permitted. |
| 426 | 426 | * @param int $max_height The maximum height permitted. |
| 427 | 427 | */ |
| 428 | - return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height ); |
|
| 428 | + return apply_filters('wp_constrain_dimensions', array($w, $h), $current_width, $current_height, $max_width, $max_height); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -476,22 +476,22 @@ discard block |
||
| 476 | 476 | * @param bool|array $crop Whether to crop image to specified height and width or resize. |
| 477 | 477 | * An array can specify positioning of the crop area. Default false. |
| 478 | 478 | */ |
| 479 | - $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop ); |
|
| 480 | - if ( null !== $output ) |
|
| 479 | + $output = apply_filters('image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop); |
|
| 480 | + if (null !== $output) |
|
| 481 | 481 | return $output; |
| 482 | 482 | |
| 483 | - if ( $crop ) { |
|
| 483 | + if ($crop) { |
|
| 484 | 484 | // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h |
| 485 | 485 | $aspect_ratio = $orig_w / $orig_h; |
| 486 | 486 | $new_w = min($dest_w, $orig_w); |
| 487 | 487 | $new_h = min($dest_h, $orig_h); |
| 488 | 488 | |
| 489 | - if ( ! $new_w ) { |
|
| 490 | - $new_w = (int) round( $new_h * $aspect_ratio ); |
|
| 489 | + if ( ! $new_w) { |
|
| 490 | + $new_w = (int) round($new_h * $aspect_ratio); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - if ( ! $new_h ) { |
|
| 494 | - $new_h = (int) round( $new_w / $aspect_ratio ); |
|
| 493 | + if ( ! $new_h) { |
|
| 494 | + $new_h = (int) round($new_w / $aspect_ratio); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); |
@@ -499,26 +499,26 @@ discard block |
||
| 499 | 499 | $crop_w = round($new_w / $size_ratio); |
| 500 | 500 | $crop_h = round($new_h / $size_ratio); |
| 501 | 501 | |
| 502 | - if ( ! is_array( $crop ) || count( $crop ) !== 2 ) { |
|
| 503 | - $crop = array( 'center', 'center' ); |
|
| 502 | + if ( ! is_array($crop) || count($crop) !== 2) { |
|
| 503 | + $crop = array('center', 'center'); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - list( $x, $y ) = $crop; |
|
| 506 | + list($x, $y) = $crop; |
|
| 507 | 507 | |
| 508 | - if ( 'left' === $x ) { |
|
| 508 | + if ('left' === $x) { |
|
| 509 | 509 | $s_x = 0; |
| 510 | - } elseif ( 'right' === $x ) { |
|
| 510 | + } elseif ('right' === $x) { |
|
| 511 | 511 | $s_x = $orig_w - $crop_w; |
| 512 | 512 | } else { |
| 513 | - $s_x = floor( ( $orig_w - $crop_w ) / 2 ); |
|
| 513 | + $s_x = floor(($orig_w - $crop_w) / 2); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if ( 'top' === $y ) { |
|
| 516 | + if ('top' === $y) { |
|
| 517 | 517 | $s_y = 0; |
| 518 | - } elseif ( 'bottom' === $y ) { |
|
| 518 | + } elseif ('bottom' === $y) { |
|
| 519 | 519 | $s_y = $orig_h - $crop_h; |
| 520 | 520 | } else { |
| 521 | - $s_y = floor( ( $orig_h - $crop_h ) / 2 ); |
|
| 521 | + $s_y = floor(($orig_h - $crop_h) / 2); |
|
| 522 | 522 | } |
| 523 | 523 | } else { |
| 524 | 524 | // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box |
@@ -528,17 +528,17 @@ discard block |
||
| 528 | 528 | $s_x = 0; |
| 529 | 529 | $s_y = 0; |
| 530 | 530 | |
| 531 | - list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); |
|
| 531 | + list($new_w, $new_h) = wp_constrain_dimensions($orig_w, $orig_h, $dest_w, $dest_h); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // if the resulting image would be the same size or larger we don't want to resize it |
| 535 | - if ( $new_w >= $orig_w && $new_h >= $orig_h && $dest_w != $orig_w && $dest_h != $orig_h ) { |
|
| 535 | + if ($new_w >= $orig_w && $new_h >= $orig_h && $dest_w != $orig_w && $dest_h != $orig_h) { |
|
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | // the return array matches the parameters to imagecopyresampled() |
| 540 | 540 | // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h |
| 541 | - return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h ); |
|
| 541 | + return array(0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h); |
|
| 542 | 542 | |
| 543 | 543 | } |
| 544 | 544 | |
@@ -558,17 +558,17 @@ discard block |
||
| 558 | 558 | * Default false. |
| 559 | 559 | * @return false|array False, if no image was created. Metadata array on success. |
| 560 | 560 | */ |
| 561 | -function image_make_intermediate_size( $file, $width, $height, $crop = false ) { |
|
| 562 | - if ( $width || $height ) { |
|
| 563 | - $editor = wp_get_image_editor( $file ); |
|
| 561 | +function image_make_intermediate_size($file, $width, $height, $crop = false) { |
|
| 562 | + if ($width || $height) { |
|
| 563 | + $editor = wp_get_image_editor($file); |
|
| 564 | 564 | |
| 565 | - if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) |
|
| 565 | + if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) |
|
| 566 | 566 | return false; |
| 567 | 567 | |
| 568 | 568 | $resized_file = $editor->save(); |
| 569 | 569 | |
| 570 | - if ( ! is_wp_error( $resized_file ) && $resized_file ) { |
|
| 571 | - unset( $resized_file['path'] ); |
|
| 570 | + if ( ! is_wp_error($resized_file) && $resized_file) { |
|
| 571 | + unset($resized_file['path']); |
|
| 572 | 572 | return $resized_file; |
| 573 | 573 | } |
| 574 | 574 | } |
@@ -601,54 +601,54 @@ discard block |
||
| 601 | 601 | * and width dimensions. Default 'thumbnail'. |
| 602 | 602 | * @return false|array False on failure or array of file path, width, and height on success. |
| 603 | 603 | */ |
| 604 | -function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) { |
|
| 605 | - if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) ) |
|
| 604 | +function image_get_intermediate_size($post_id, $size = 'thumbnail') { |
|
| 605 | + if ( ! is_array($imagedata = wp_get_attachment_metadata($post_id))) |
|
| 606 | 606 | return false; |
| 607 | 607 | |
| 608 | 608 | // get the best one for a specified set of dimensions |
| 609 | - if ( is_array($size) && !empty($imagedata['sizes']) ) { |
|
| 609 | + if (is_array($size) && ! empty($imagedata['sizes'])) { |
|
| 610 | 610 | $areas = array(); |
| 611 | 611 | |
| 612 | - foreach ( $imagedata['sizes'] as $_size => $data ) { |
|
| 612 | + foreach ($imagedata['sizes'] as $_size => $data) { |
|
| 613 | 613 | // already cropped to width or height; so use this size |
| 614 | - if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { |
|
| 614 | + if (($data['width'] == $size[0] && $data['height'] <= $size[1]) || ($data['height'] == $size[1] && $data['width'] <= $size[0])) { |
|
| 615 | 615 | $file = $data['file']; |
| 616 | - list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
|
| 617 | - return compact( 'file', 'width', 'height' ); |
|
| 616 | + list($width, $height) = image_constrain_size_for_editor($data['width'], $data['height'], $size); |
|
| 617 | + return compact('file', 'width', 'height'); |
|
| 618 | 618 | } |
| 619 | 619 | // add to lookup table: area => size |
| 620 | 620 | $areas[$data['width'] * $data['height']] = $_size; |
| 621 | 621 | } |
| 622 | - if ( !$size || !empty($areas) ) { |
|
| 622 | + if ( ! $size || ! empty($areas)) { |
|
| 623 | 623 | // find for the smallest image not smaller than the desired size |
| 624 | 624 | ksort($areas); |
| 625 | - foreach ( $areas as $_size ) { |
|
| 625 | + foreach ($areas as $_size) { |
|
| 626 | 626 | $data = $imagedata['sizes'][$_size]; |
| 627 | - if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) { |
|
| 627 | + if ($data['width'] >= $size[0] || $data['height'] >= $size[1]) { |
|
| 628 | 628 | // Skip images with unexpectedly divergent aspect ratios (crops) |
| 629 | 629 | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| 630 | - $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
|
| 630 | + $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false); |
|
| 631 | 631 | // If the size doesn't match within one pixel, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size |
| 632 | - if ( 'thumbnail' != $_size && ( !$maybe_cropped || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) ) ) |
|
| 632 | + if ('thumbnail' != $_size && ( ! $maybe_cropped || ($maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width']) || ($maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height']))) |
|
| 633 | 633 | continue; |
| 634 | 634 | // If we're still here, then we're going to use this size |
| 635 | 635 | $file = $data['file']; |
| 636 | - list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
|
| 637 | - return compact( 'file', 'width', 'height' ); |
|
| 636 | + list($width, $height) = image_constrain_size_for_editor($data['width'], $data['height'], $size); |
|
| 637 | + return compact('file', 'width', 'height'); |
|
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) |
|
| 643 | + if (is_array($size) || empty($size) || empty($imagedata['sizes'][$size])) |
|
| 644 | 644 | return false; |
| 645 | 645 | |
| 646 | 646 | $data = $imagedata['sizes'][$size]; |
| 647 | 647 | // include the full filesystem path of the intermediate file |
| 648 | - if ( empty($data['path']) && !empty($data['file']) ) { |
|
| 648 | + if (empty($data['path']) && ! empty($data['file'])) { |
|
| 649 | 649 | $file_url = wp_get_attachment_url($post_id); |
| 650 | - $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); |
|
| 651 | - $data['url'] = path_join( dirname($file_url), $data['file'] ); |
|
| 650 | + $data['path'] = path_join(dirname($imagedata['file']), $data['file']); |
|
| 651 | + $data['url'] = path_join(dirname($file_url), $data['file']); |
|
| 652 | 652 | } |
| 653 | 653 | return $data; |
| 654 | 654 | } |
@@ -665,8 +665,8 @@ discard block |
||
| 665 | 665 | function get_intermediate_image_sizes() { |
| 666 | 666 | global $_wp_additional_image_sizes; |
| 667 | 667 | $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes |
| 668 | - if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) |
|
| 669 | - $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) ); |
|
| 668 | + if (isset($_wp_additional_image_sizes) && count($_wp_additional_image_sizes)) |
|
| 669 | + $image_sizes = array_merge($image_sizes, array_keys($_wp_additional_image_sizes)); |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Filter the list of intermediate image sizes. |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | * @param array $image_sizes An array of intermediate image sizes. Defaults |
| 677 | 677 | * are 'thumbnail', 'medium', 'large'. |
| 678 | 678 | */ |
| 679 | - return apply_filters( 'intermediate_image_sizes', $image_sizes ); |
|
| 679 | + return apply_filters('intermediate_image_sizes', $image_sizes); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | /** |
@@ -692,22 +692,22 @@ discard block |
||
| 692 | 692 | * @param bool $icon Optional. Whether the image should be treated as an icon. Default false. |
| 693 | 693 | * @return false|array Returns an array (url, width, height), or false, if no image is available. |
| 694 | 694 | */ |
| 695 | -function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { |
|
| 695 | +function wp_get_attachment_image_src($attachment_id, $size = 'thumbnail', $icon = false) { |
|
| 696 | 696 | // get a thumbnail or intermediate image if there is one |
| 697 | - $image = image_downsize( $attachment_id, $size ); |
|
| 698 | - if ( ! $image ) { |
|
| 697 | + $image = image_downsize($attachment_id, $size); |
|
| 698 | + if ( ! $image) { |
|
| 699 | 699 | $src = false; |
| 700 | 700 | |
| 701 | - if ( $icon && $src = wp_mime_type_icon( $attachment_id ) ) { |
|
| 701 | + if ($icon && $src = wp_mime_type_icon($attachment_id)) { |
|
| 702 | 702 | /** This filter is documented in wp-includes/post.php */ |
| 703 | - $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ); |
|
| 703 | + $icon_dir = apply_filters('icon_dir', ABSPATH.WPINC.'/images/media'); |
|
| 704 | 704 | |
| 705 | - $src_file = $icon_dir . '/' . wp_basename( $src ); |
|
| 706 | - @list( $width, $height ) = getimagesize( $src_file ); |
|
| 705 | + $src_file = $icon_dir.'/'.wp_basename($src); |
|
| 706 | + @list($width, $height) = getimagesize($src_file); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if ( $src && $width && $height ) { |
|
| 710 | - $image = array( $src, $width, $height ); |
|
| 709 | + if ($src && $width && $height) { |
|
| 710 | + $image = array($src, $width, $height); |
|
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | 713 | /** |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | * array of height and width dimensions. Default 'thumbnail'. |
| 722 | 722 | * @param bool $icon Whether the image should be treated as an icon. Default false. |
| 723 | 723 | */ |
| 724 | - return apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ); |
|
| 724 | + return apply_filters('wp_get_attachment_image_src', $image, $attachment_id, $size, $icon); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
@@ -744,23 +744,23 @@ discard block |
||
| 744 | 744 | function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') { |
| 745 | 745 | $html = ''; |
| 746 | 746 | $image = wp_get_attachment_image_src($attachment_id, $size, $icon); |
| 747 | - if ( $image ) { |
|
| 747 | + if ($image) { |
|
| 748 | 748 | list($src, $width, $height) = $image; |
| 749 | 749 | $hwstring = image_hwstring($width, $height); |
| 750 | 750 | $size_class = $size; |
| 751 | - if ( is_array( $size_class ) ) { |
|
| 752 | - $size_class = join( 'x', $size_class ); |
|
| 751 | + if (is_array($size_class)) { |
|
| 752 | + $size_class = join('x', $size_class); |
|
| 753 | 753 | } |
| 754 | 754 | $attachment = get_post($attachment_id); |
| 755 | 755 | $default_attr = array( |
| 756 | 756 | 'src' => $src, |
| 757 | 757 | 'class' => "attachment-$size_class", |
| 758 | - 'alt' => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first |
|
| 758 | + 'alt' => trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true))), // Use Alt field first |
|
| 759 | 759 | ); |
| 760 | - if ( empty($default_attr['alt']) ) |
|
| 761 | - $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption |
|
| 762 | - if ( empty($default_attr['alt']) ) |
|
| 763 | - $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title |
|
| 760 | + if (empty($default_attr['alt'])) |
|
| 761 | + $default_attr['alt'] = trim(strip_tags($attachment->post_excerpt)); // If not, Use the Caption |
|
| 762 | + if (empty($default_attr['alt'])) |
|
| 763 | + $default_attr['alt'] = trim(strip_tags($attachment->post_title)); // Finally, use the title |
|
| 764 | 764 | |
| 765 | 765 | $attr = wp_parse_args($attr, $default_attr); |
| 766 | 766 | |
@@ -773,11 +773,11 @@ discard block |
||
| 773 | 773 | * @param WP_Post $attachment Image attachment post. |
| 774 | 774 | * @param string|array $size Requested size. |
| 775 | 775 | */ |
| 776 | - $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size ); |
|
| 777 | - $attr = array_map( 'esc_attr', $attr ); |
|
| 776 | + $attr = apply_filters('wp_get_attachment_image_attributes', $attr, $attachment, $size); |
|
| 777 | + $attr = array_map('esc_attr', $attr); |
|
| 778 | 778 | $html = rtrim("<img $hwstring"); |
| 779 | - foreach ( $attr as $name => $value ) { |
|
| 780 | - $html .= " $name=" . '"' . $value . '"'; |
|
| 779 | + foreach ($attr as $name => $value) { |
|
| 780 | + $html .= " $name=".'"'.$value.'"'; |
|
| 781 | 781 | } |
| 782 | 782 | $html .= ' />'; |
| 783 | 783 | } |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | * @param array $attr Thumbnail attributes including src, class, alt, title. |
| 798 | 798 | * @return array Modified array of attributes including the new 'wp-post-image' class. |
| 799 | 799 | */ |
| 800 | -function _wp_post_thumbnail_class_filter( $attr ) { |
|
| 800 | +function _wp_post_thumbnail_class_filter($attr) { |
|
| 801 | 801 | $attr['class'] .= ' wp-post-image'; |
| 802 | 802 | return $attr; |
| 803 | 803 | } |
@@ -811,8 +811,8 @@ discard block |
||
| 811 | 811 | * |
| 812 | 812 | * @param array $attr Thumbnail attributes including src, class, alt, title. |
| 813 | 813 | */ |
| 814 | -function _wp_post_thumbnail_class_filter_add( $attr ) { |
|
| 815 | - add_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' ); |
|
| 814 | +function _wp_post_thumbnail_class_filter_add($attr) { |
|
| 815 | + add_filter('wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter'); |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | /** |
@@ -824,8 +824,8 @@ discard block |
||
| 824 | 824 | * |
| 825 | 825 | * @param array $attr Thumbnail attributes including src, class, alt, title. |
| 826 | 826 | */ |
| 827 | -function _wp_post_thumbnail_class_filter_remove( $attr ) { |
|
| 828 | - remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' ); |
|
| 827 | +function _wp_post_thumbnail_class_filter_remove($attr) { |
|
| 828 | + remove_filter('wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter'); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | add_shortcode('wp_caption', 'img_caption_shortcode'); |
@@ -856,12 +856,12 @@ discard block |
||
| 856 | 856 | * @param string $content Shortcode content. |
| 857 | 857 | * @return string HTML content to display the caption. |
| 858 | 858 | */ |
| 859 | -function img_caption_shortcode( $attr, $content = null ) { |
|
| 859 | +function img_caption_shortcode($attr, $content = null) { |
|
| 860 | 860 | // New-style shortcode with the caption inside the shortcode with the link and image tags. |
| 861 | - if ( ! isset( $attr['caption'] ) ) { |
|
| 862 | - if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { |
|
| 861 | + if ( ! isset($attr['caption'])) { |
|
| 862 | + if (preg_match('#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches)) { |
|
| 863 | 863 | $content = $matches[1]; |
| 864 | - $attr['caption'] = trim( $matches[2] ); |
|
| 864 | + $attr['caption'] = trim($matches[2]); |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | |
@@ -879,30 +879,30 @@ discard block |
||
| 879 | 879 | * @param array $attr Attributes of the caption shortcode. |
| 880 | 880 | * @param string $content The image element, possibly wrapped in a hyperlink. |
| 881 | 881 | */ |
| 882 | - $output = apply_filters( 'img_caption_shortcode', '', $attr, $content ); |
|
| 883 | - if ( $output != '' ) |
|
| 882 | + $output = apply_filters('img_caption_shortcode', '', $attr, $content); |
|
| 883 | + if ($output != '') |
|
| 884 | 884 | return $output; |
| 885 | 885 | |
| 886 | - $atts = shortcode_atts( array( |
|
| 886 | + $atts = shortcode_atts(array( |
|
| 887 | 887 | 'id' => '', |
| 888 | 888 | 'align' => 'alignnone', |
| 889 | 889 | 'width' => '', |
| 890 | 890 | 'caption' => '', |
| 891 | 891 | 'class' => '', |
| 892 | - ), $attr, 'caption' ); |
|
| 892 | + ), $attr, 'caption'); |
|
| 893 | 893 | |
| 894 | 894 | $atts['width'] = (int) $atts['width']; |
| 895 | - if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) |
|
| 895 | + if ($atts['width'] < 1 || empty($atts['caption'])) |
|
| 896 | 896 | return $content; |
| 897 | 897 | |
| 898 | - if ( ! empty( $atts['id'] ) ) |
|
| 899 | - $atts['id'] = 'id="' . esc_attr( sanitize_html_class( $atts['id'] ) ) . '" '; |
|
| 898 | + if ( ! empty($atts['id'])) |
|
| 899 | + $atts['id'] = 'id="'.esc_attr(sanitize_html_class($atts['id'])).'" '; |
|
| 900 | 900 | |
| 901 | - $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); |
|
| 901 | + $class = trim('wp-caption '.$atts['align'].' '.$atts['class']); |
|
| 902 | 902 | |
| 903 | - if ( current_theme_supports( 'html5', 'caption' ) ) { |
|
| 904 | - return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">' |
|
| 905 | - . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>'; |
|
| 903 | + if (current_theme_supports('html5', 'caption')) { |
|
| 904 | + return '<figure '.$atts['id'].'style="width: '.(int) $atts['width'].'px;" class="'.esc_attr($class).'">' |
|
| 905 | + . do_shortcode($content).'<figcaption class="wp-caption-text">'.$atts['caption'].'</figcaption></figure>'; |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | $caption_width = 10 + $atts['width']; |
@@ -922,14 +922,14 @@ discard block |
||
| 922 | 922 | * @param array $atts Attributes of the caption shortcode. |
| 923 | 923 | * @param string $content The image element, possibly wrapped in a hyperlink. |
| 924 | 924 | */ |
| 925 | - $caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content ); |
|
| 925 | + $caption_width = apply_filters('img_caption_shortcode_width', $caption_width, $atts, $content); |
|
| 926 | 926 | |
| 927 | 927 | $style = ''; |
| 928 | - if ( $caption_width ) |
|
| 929 | - $style = 'style="width: ' . (int) $caption_width . 'px" '; |
|
| 928 | + if ($caption_width) |
|
| 929 | + $style = 'style="width: '.(int) $caption_width.'px" '; |
|
| 930 | 930 | |
| 931 | - return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">' |
|
| 932 | - . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>'; |
|
| 931 | + return '<div '.$atts['id'].$style.'class="'.esc_attr($class).'">' |
|
| 932 | + . do_shortcode($content).'<p class="wp-caption-text">'.$atts['caption'].'</p></div>'; |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | add_shortcode('gallery', 'gallery_shortcode'); |
@@ -967,15 +967,15 @@ discard block |
||
| 967 | 967 | * } |
| 968 | 968 | * @return string HTML content to display gallery. |
| 969 | 969 | */ |
| 970 | -function gallery_shortcode( $attr ) { |
|
| 970 | +function gallery_shortcode($attr) { |
|
| 971 | 971 | $post = get_post(); |
| 972 | 972 | |
| 973 | 973 | static $instance = 0; |
| 974 | 974 | $instance++; |
| 975 | 975 | |
| 976 | - if ( ! empty( $attr['ids'] ) ) { |
|
| 976 | + if ( ! empty($attr['ids'])) { |
|
| 977 | 977 | // 'ids' is explicitly ordered, unless you specify otherwise. |
| 978 | - if ( empty( $attr['orderby'] ) ) { |
|
| 978 | + if (empty($attr['orderby'])) { |
|
| 979 | 979 | $attr['orderby'] = 'post__in'; |
| 980 | 980 | } |
| 981 | 981 | $attr['include'] = $attr['ids']; |
@@ -996,69 +996,69 @@ discard block |
||
| 996 | 996 | * @param array $attr Attributes of the gallery shortcode. |
| 997 | 997 | * @param int $instance Unique numeric ID of this gallery shortcode instance. |
| 998 | 998 | */ |
| 999 | - $output = apply_filters( 'post_gallery', '', $attr, $instance ); |
|
| 1000 | - if ( $output != '' ) { |
|
| 999 | + $output = apply_filters('post_gallery', '', $attr, $instance); |
|
| 1000 | + if ($output != '') { |
|
| 1001 | 1001 | return $output; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - $html5 = current_theme_supports( 'html5', 'gallery' ); |
|
| 1005 | - $atts = shortcode_atts( array( |
|
| 1004 | + $html5 = current_theme_supports('html5', 'gallery'); |
|
| 1005 | + $atts = shortcode_atts(array( |
|
| 1006 | 1006 | 'order' => 'ASC', |
| 1007 | 1007 | 'orderby' => 'menu_order ID', |
| 1008 | 1008 | 'id' => $post ? $post->ID : 0, |
| 1009 | - 'itemtag' => $html5 ? 'figure' : 'dl', |
|
| 1010 | - 'icontag' => $html5 ? 'div' : 'dt', |
|
| 1009 | + 'itemtag' => $html5 ? 'figure' : 'dl', |
|
| 1010 | + 'icontag' => $html5 ? 'div' : 'dt', |
|
| 1011 | 1011 | 'captiontag' => $html5 ? 'figcaption' : 'dd', |
| 1012 | 1012 | 'columns' => 3, |
| 1013 | 1013 | 'size' => 'thumbnail', |
| 1014 | 1014 | 'include' => '', |
| 1015 | 1015 | 'exclude' => '', |
| 1016 | 1016 | 'link' => '' |
| 1017 | - ), $attr, 'gallery' ); |
|
| 1017 | + ), $attr, 'gallery'); |
|
| 1018 | 1018 | |
| 1019 | - $id = intval( $atts['id'] ); |
|
| 1019 | + $id = intval($atts['id']); |
|
| 1020 | 1020 | |
| 1021 | - if ( ! empty( $atts['include'] ) ) { |
|
| 1022 | - $_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); |
|
| 1021 | + if ( ! empty($atts['include'])) { |
|
| 1022 | + $_attachments = get_posts(array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'])); |
|
| 1023 | 1023 | |
| 1024 | 1024 | $attachments = array(); |
| 1025 | - foreach ( $_attachments as $key => $val ) { |
|
| 1025 | + foreach ($_attachments as $key => $val) { |
|
| 1026 | 1026 | $attachments[$val->ID] = $_attachments[$key]; |
| 1027 | 1027 | } |
| 1028 | - } elseif ( ! empty( $atts['exclude'] ) ) { |
|
| 1029 | - $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); |
|
| 1028 | + } elseif ( ! empty($atts['exclude'])) { |
|
| 1029 | + $attachments = get_children(array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'])); |
|
| 1030 | 1030 | } else { |
| 1031 | - $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); |
|
| 1031 | + $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'])); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - if ( empty( $attachments ) ) { |
|
| 1034 | + if (empty($attachments)) { |
|
| 1035 | 1035 | return ''; |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - if ( is_feed() ) { |
|
| 1038 | + if (is_feed()) { |
|
| 1039 | 1039 | $output = "\n"; |
| 1040 | - foreach ( $attachments as $att_id => $attachment ) { |
|
| 1041 | - $output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n"; |
|
| 1040 | + foreach ($attachments as $att_id => $attachment) { |
|
| 1041 | + $output .= wp_get_attachment_link($att_id, $atts['size'], true)."\n"; |
|
| 1042 | 1042 | } |
| 1043 | 1043 | return $output; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - $itemtag = tag_escape( $atts['itemtag'] ); |
|
| 1047 | - $captiontag = tag_escape( $atts['captiontag'] ); |
|
| 1048 | - $icontag = tag_escape( $atts['icontag'] ); |
|
| 1049 | - $valid_tags = wp_kses_allowed_html( 'post' ); |
|
| 1050 | - if ( ! isset( $valid_tags[ $itemtag ] ) ) { |
|
| 1046 | + $itemtag = tag_escape($atts['itemtag']); |
|
| 1047 | + $captiontag = tag_escape($atts['captiontag']); |
|
| 1048 | + $icontag = tag_escape($atts['icontag']); |
|
| 1049 | + $valid_tags = wp_kses_allowed_html('post'); |
|
| 1050 | + if ( ! isset($valid_tags[$itemtag])) { |
|
| 1051 | 1051 | $itemtag = 'dl'; |
| 1052 | 1052 | } |
| 1053 | - if ( ! isset( $valid_tags[ $captiontag ] ) ) { |
|
| 1053 | + if ( ! isset($valid_tags[$captiontag])) { |
|
| 1054 | 1054 | $captiontag = 'dd'; |
| 1055 | 1055 | } |
| 1056 | - if ( ! isset( $valid_tags[ $icontag ] ) ) { |
|
| 1056 | + if ( ! isset($valid_tags[$icontag])) { |
|
| 1057 | 1057 | $icontag = 'dt'; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - $columns = intval( $atts['columns'] ); |
|
| 1061 | - $itemwidth = $columns > 0 ? floor(100/$columns) : 100; |
|
| 1060 | + $columns = intval($atts['columns']); |
|
| 1061 | + $itemwidth = $columns > 0 ? floor(100 / $columns) : 100; |
|
| 1062 | 1062 | $float = is_rtl() ? 'right' : 'left'; |
| 1063 | 1063 | |
| 1064 | 1064 | $selector = "gallery-{$instance}"; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | * Defaults to false if the theme supports HTML5 galleries. |
| 1075 | 1075 | * Otherwise, defaults to true. |
| 1076 | 1076 | */ |
| 1077 | - if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) { |
|
| 1077 | + if (apply_filters('use_default_gallery_style', ! $html5)) { |
|
| 1078 | 1078 | $gallery_style = " |
| 1079 | 1079 | <style type='text/css'> |
| 1080 | 1080 | #{$selector} { |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | </style>\n\t\t"; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - $size_class = sanitize_html_class( $atts['size'] ); |
|
| 1099 | + $size_class = sanitize_html_class($atts['size']); |
|
| 1100 | 1100 | $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; |
| 1101 | 1101 | |
| 1102 | 1102 | /** |
@@ -1107,43 +1107,43 @@ discard block |
||
| 1107 | 1107 | * @param string $gallery_style Default CSS styles and opening HTML div container |
| 1108 | 1108 | * for the gallery shortcode output. |
| 1109 | 1109 | */ |
| 1110 | - $output = apply_filters( 'gallery_style', $gallery_style . $gallery_div ); |
|
| 1110 | + $output = apply_filters('gallery_style', $gallery_style.$gallery_div); |
|
| 1111 | 1111 | |
| 1112 | 1112 | $i = 0; |
| 1113 | - foreach ( $attachments as $id => $attachment ) { |
|
| 1113 | + foreach ($attachments as $id => $attachment) { |
|
| 1114 | 1114 | |
| 1115 | - $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : ''; |
|
| 1116 | - if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) { |
|
| 1117 | - $image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr ); |
|
| 1118 | - } elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) { |
|
| 1119 | - $image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr ); |
|
| 1115 | + $attr = (trim($attachment->post_excerpt)) ? array('aria-describedby' => "$selector-$id") : ''; |
|
| 1116 | + if ( ! empty($atts['link']) && 'file' === $atts['link']) { |
|
| 1117 | + $image_output = wp_get_attachment_link($id, $atts['size'], false, false, false, $attr); |
|
| 1118 | + } elseif ( ! empty($atts['link']) && 'none' === $atts['link']) { |
|
| 1119 | + $image_output = wp_get_attachment_image($id, $atts['size'], false, $attr); |
|
| 1120 | 1120 | } else { |
| 1121 | - $image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr ); |
|
| 1121 | + $image_output = wp_get_attachment_link($id, $atts['size'], true, false, false, $attr); |
|
| 1122 | 1122 | } |
| 1123 | - $image_meta = wp_get_attachment_metadata( $id ); |
|
| 1123 | + $image_meta = wp_get_attachment_metadata($id); |
|
| 1124 | 1124 | |
| 1125 | 1125 | $orientation = ''; |
| 1126 | - if ( isset( $image_meta['height'], $image_meta['width'] ) ) { |
|
| 1127 | - $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; |
|
| 1126 | + if (isset($image_meta['height'], $image_meta['width'])) { |
|
| 1127 | + $orientation = ($image_meta['height'] > $image_meta['width']) ? 'portrait' : 'landscape'; |
|
| 1128 | 1128 | } |
| 1129 | 1129 | $output .= "<{$itemtag} class='gallery-item'>"; |
| 1130 | 1130 | $output .= " |
| 1131 | 1131 | <{$icontag} class='gallery-icon {$orientation}'> |
| 1132 | 1132 | $image_output |
| 1133 | 1133 | </{$icontag}>"; |
| 1134 | - if ( $captiontag && trim($attachment->post_excerpt) ) { |
|
| 1134 | + if ($captiontag && trim($attachment->post_excerpt)) { |
|
| 1135 | 1135 | $output .= " |
| 1136 | 1136 | <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'> |
| 1137 | - " . wptexturize($attachment->post_excerpt) . " |
|
| 1137 | + ".wptexturize($attachment->post_excerpt)." |
|
| 1138 | 1138 | </{$captiontag}>"; |
| 1139 | 1139 | } |
| 1140 | 1140 | $output .= "</{$itemtag}>"; |
| 1141 | - if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) { |
|
| 1141 | + if ( ! $html5 && $columns > 0 && ++$i % $columns == 0) { |
|
| 1142 | 1142 | $output .= '<br style="clear: both" />'; |
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | - if ( ! $html5 && $columns > 0 && $i % $columns !== 0 ) { |
|
| 1146 | + if ( ! $html5 && $columns > 0 && $i % $columns !== 0) { |
|
| 1147 | 1147 | $output .= " |
| 1148 | 1148 | <br style='clear: both' />"; |
| 1149 | 1149 | } |
@@ -1199,14 +1199,14 @@ discard block |
||
| 1199 | 1199 | * |
| 1200 | 1200 | * @param string $type Type of playlist. Accepts 'audio' or 'video'. |
| 1201 | 1201 | */ |
| 1202 | -function wp_playlist_scripts( $type ) { |
|
| 1203 | - wp_enqueue_style( 'wp-mediaelement' ); |
|
| 1204 | - wp_enqueue_script( 'wp-playlist' ); |
|
| 1202 | +function wp_playlist_scripts($type) { |
|
| 1203 | + wp_enqueue_style('wp-mediaelement'); |
|
| 1204 | + wp_enqueue_script('wp-playlist'); |
|
| 1205 | 1205 | ?> |
| 1206 | -<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ) ?>');</script><![endif]--> |
|
| 1206 | +<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js($type) ?>');</script><![endif]--> |
|
| 1207 | 1207 | <?php |
| 1208 | - add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 ); |
|
| 1209 | - add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 ); |
|
| 1208 | + add_action('wp_footer', 'wp_underscore_playlist_templates', 0); |
|
| 1209 | + add_action('admin_footer', 'wp_underscore_playlist_templates', 0); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -1246,16 +1246,16 @@ discard block |
||
| 1246 | 1246 | * |
| 1247 | 1247 | * @return string Playlist output. Empty string if the passed type is unsupported. |
| 1248 | 1248 | */ |
| 1249 | -function wp_playlist_shortcode( $attr ) { |
|
| 1249 | +function wp_playlist_shortcode($attr) { |
|
| 1250 | 1250 | global $content_width; |
| 1251 | 1251 | $post = get_post(); |
| 1252 | 1252 | |
| 1253 | 1253 | static $instance = 0; |
| 1254 | 1254 | $instance++; |
| 1255 | 1255 | |
| 1256 | - if ( ! empty( $attr['ids'] ) ) { |
|
| 1256 | + if ( ! empty($attr['ids'])) { |
|
| 1257 | 1257 | // 'ids' is explicitly ordered, unless you specify otherwise. |
| 1258 | - if ( empty( $attr['orderby'] ) ) { |
|
| 1258 | + if (empty($attr['orderby'])) { |
|
| 1259 | 1259 | $attr['orderby'] = 'post__in'; |
| 1260 | 1260 | } |
| 1261 | 1261 | $attr['include'] = $attr['ids']; |
@@ -1274,12 +1274,12 @@ discard block |
||
| 1274 | 1274 | * @param array $attr An array of shortcode attributes. |
| 1275 | 1275 | * @param int $instance Unique numeric ID of this playlist shortcode instance. |
| 1276 | 1276 | */ |
| 1277 | - $output = apply_filters( 'post_playlist', '', $attr, $instance ); |
|
| 1278 | - if ( $output != '' ) { |
|
| 1277 | + $output = apply_filters('post_playlist', '', $attr, $instance); |
|
| 1278 | + if ($output != '') { |
|
| 1279 | 1279 | return $output; |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - $atts = shortcode_atts( array( |
|
| 1282 | + $atts = shortcode_atts(array( |
|
| 1283 | 1283 | 'type' => 'audio', |
| 1284 | 1284 | 'order' => 'ASC', |
| 1285 | 1285 | 'orderby' => 'menu_order ID', |
@@ -1291,11 +1291,11 @@ discard block |
||
| 1291 | 1291 | 'tracknumbers' => true, |
| 1292 | 1292 | 'images' => true, |
| 1293 | 1293 | 'artists' => true |
| 1294 | - ), $attr, 'playlist' ); |
|
| 1294 | + ), $attr, 'playlist'); |
|
| 1295 | 1295 | |
| 1296 | - $id = intval( $atts['id'] ); |
|
| 1296 | + $id = intval($atts['id']); |
|
| 1297 | 1297 | |
| 1298 | - if ( $atts['type'] !== 'audio' ) { |
|
| 1298 | + if ($atts['type'] !== 'audio') { |
|
| 1299 | 1299 | $atts['type'] = 'video'; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1307,31 +1307,31 @@ discard block |
||
| 1307 | 1307 | 'orderby' => $atts['orderby'] |
| 1308 | 1308 | ); |
| 1309 | 1309 | |
| 1310 | - if ( ! empty( $atts['include'] ) ) { |
|
| 1310 | + if ( ! empty($atts['include'])) { |
|
| 1311 | 1311 | $args['include'] = $atts['include']; |
| 1312 | - $_attachments = get_posts( $args ); |
|
| 1312 | + $_attachments = get_posts($args); |
|
| 1313 | 1313 | |
| 1314 | 1314 | $attachments = array(); |
| 1315 | - foreach ( $_attachments as $key => $val ) { |
|
| 1315 | + foreach ($_attachments as $key => $val) { |
|
| 1316 | 1316 | $attachments[$val->ID] = $_attachments[$key]; |
| 1317 | 1317 | } |
| 1318 | - } elseif ( ! empty( $atts['exclude'] ) ) { |
|
| 1318 | + } elseif ( ! empty($atts['exclude'])) { |
|
| 1319 | 1319 | $args['post_parent'] = $id; |
| 1320 | 1320 | $args['exclude'] = $atts['exclude']; |
| 1321 | - $attachments = get_children( $args ); |
|
| 1321 | + $attachments = get_children($args); |
|
| 1322 | 1322 | } else { |
| 1323 | 1323 | $args['post_parent'] = $id; |
| 1324 | - $attachments = get_children( $args ); |
|
| 1324 | + $attachments = get_children($args); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - if ( empty( $attachments ) ) { |
|
| 1327 | + if (empty($attachments)) { |
|
| 1328 | 1328 | return ''; |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | - if ( is_feed() ) { |
|
| 1331 | + if (is_feed()) { |
|
| 1332 | 1332 | $output = "\n"; |
| 1333 | - foreach ( $attachments as $att_id => $attachment ) { |
|
| 1334 | - $output .= wp_get_attachment_link( $att_id ) . "\n"; |
|
| 1333 | + foreach ($attachments as $att_id => $attachment) { |
|
| 1334 | + $output .= wp_get_attachment_link($att_id)."\n"; |
|
| 1335 | 1335 | } |
| 1336 | 1336 | return $output; |
| 1337 | 1337 | } |
@@ -1341,22 +1341,22 @@ discard block |
||
| 1341 | 1341 | $default_width = 640; |
| 1342 | 1342 | $default_height = 360; |
| 1343 | 1343 | |
| 1344 | - $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer ); |
|
| 1345 | - $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width ); |
|
| 1344 | + $theme_width = empty($content_width) ? $default_width : ($content_width - $outer); |
|
| 1345 | + $theme_height = empty($content_width) ? $default_height : round(($default_height * $theme_width) / $default_width); |
|
| 1346 | 1346 | |
| 1347 | 1347 | $data = array( |
| 1348 | 1348 | 'type' => $atts['type'], |
| 1349 | 1349 | // don't pass strings to JSON, will be truthy in JS |
| 1350 | - 'tracklist' => wp_validate_boolean( $atts['tracklist'] ), |
|
| 1351 | - 'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ), |
|
| 1352 | - 'images' => wp_validate_boolean( $atts['images'] ), |
|
| 1353 | - 'artists' => wp_validate_boolean( $atts['artists'] ), |
|
| 1350 | + 'tracklist' => wp_validate_boolean($atts['tracklist']), |
|
| 1351 | + 'tracknumbers' => wp_validate_boolean($atts['tracknumbers']), |
|
| 1352 | + 'images' => wp_validate_boolean($atts['images']), |
|
| 1353 | + 'artists' => wp_validate_boolean($atts['artists']), |
|
| 1354 | 1354 | ); |
| 1355 | 1355 | |
| 1356 | 1356 | $tracks = array(); |
| 1357 | - foreach ( $attachments as $attachment ) { |
|
| 1358 | - $url = wp_get_attachment_url( $attachment->ID ); |
|
| 1359 | - $ftype = wp_check_filetype( $url, wp_get_mime_types() ); |
|
| 1357 | + foreach ($attachments as $attachment) { |
|
| 1358 | + $url = wp_get_attachment_url($attachment->ID); |
|
| 1359 | + $ftype = wp_check_filetype($url, wp_get_mime_types()); |
|
| 1360 | 1360 | $track = array( |
| 1361 | 1361 | 'src' => $url, |
| 1362 | 1362 | 'type' => $ftype['type'], |
@@ -1366,27 +1366,27 @@ discard block |
||
| 1366 | 1366 | ); |
| 1367 | 1367 | |
| 1368 | 1368 | $track['meta'] = array(); |
| 1369 | - $meta = wp_get_attachment_metadata( $attachment->ID ); |
|
| 1370 | - if ( ! empty( $meta ) ) { |
|
| 1369 | + $meta = wp_get_attachment_metadata($attachment->ID); |
|
| 1370 | + if ( ! empty($meta)) { |
|
| 1371 | 1371 | |
| 1372 | - foreach ( wp_get_attachment_id3_keys( $attachment ) as $key => $label ) { |
|
| 1373 | - if ( ! empty( $meta[ $key ] ) ) { |
|
| 1374 | - $track['meta'][ $key ] = $meta[ $key ]; |
|
| 1372 | + foreach (wp_get_attachment_id3_keys($attachment) as $key => $label) { |
|
| 1373 | + if ( ! empty($meta[$key])) { |
|
| 1374 | + $track['meta'][$key] = $meta[$key]; |
|
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | - if ( 'video' === $atts['type'] ) { |
|
| 1379 | - if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) { |
|
| 1378 | + if ('video' === $atts['type']) { |
|
| 1379 | + if ( ! empty($meta['width']) && ! empty($meta['height'])) { |
|
| 1380 | 1380 | $width = $meta['width']; |
| 1381 | 1381 | $height = $meta['height']; |
| 1382 | - $theme_height = round( ( $height * $theme_width ) / $width ); |
|
| 1382 | + $theme_height = round(($height * $theme_width) / $width); |
|
| 1383 | 1383 | } else { |
| 1384 | 1384 | $width = $default_width; |
| 1385 | 1385 | $height = $default_height; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | $track['dimensions'] = array( |
| 1389 | - 'original' => compact( 'width', 'height' ), |
|
| 1389 | + 'original' => compact('width', 'height'), |
|
| 1390 | 1390 | 'resized' => array( |
| 1391 | 1391 | 'width' => $theme_width, |
| 1392 | 1392 | 'height' => $theme_height |
@@ -1395,19 +1395,19 @@ discard block |
||
| 1395 | 1395 | } |
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | - if ( $atts['images'] ) { |
|
| 1399 | - $thumb_id = get_post_thumbnail_id( $attachment->ID ); |
|
| 1400 | - if ( ! empty( $thumb_id ) ) { |
|
| 1401 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' ); |
|
| 1402 | - $track['image'] = compact( 'src', 'width', 'height' ); |
|
| 1403 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' ); |
|
| 1404 | - $track['thumb'] = compact( 'src', 'width', 'height' ); |
|
| 1398 | + if ($atts['images']) { |
|
| 1399 | + $thumb_id = get_post_thumbnail_id($attachment->ID); |
|
| 1400 | + if ( ! empty($thumb_id)) { |
|
| 1401 | + list($src, $width, $height) = wp_get_attachment_image_src($thumb_id, 'full'); |
|
| 1402 | + $track['image'] = compact('src', 'width', 'height'); |
|
| 1403 | + list($src, $width, $height) = wp_get_attachment_image_src($thumb_id, 'thumbnail'); |
|
| 1404 | + $track['thumb'] = compact('src', 'width', 'height'); |
|
| 1405 | 1405 | } else { |
| 1406 | - $src = wp_mime_type_icon( $attachment->ID ); |
|
| 1406 | + $src = wp_mime_type_icon($attachment->ID); |
|
| 1407 | 1407 | $width = 48; |
| 1408 | 1408 | $height = 64; |
| 1409 | - $track['image'] = compact( 'src', 'width', 'height' ); |
|
| 1410 | - $track['thumb'] = compact( 'src', 'width', 'height' ); |
|
| 1409 | + $track['image'] = compact('src', 'width', 'height'); |
|
| 1410 | + $track['thumb'] = compact('src', 'width', 'height'); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | } |
| 1413 | 1413 | |
@@ -1415,12 +1415,12 @@ discard block |
||
| 1415 | 1415 | } |
| 1416 | 1416 | $data['tracks'] = $tracks; |
| 1417 | 1417 | |
| 1418 | - $safe_type = esc_attr( $atts['type'] ); |
|
| 1419 | - $safe_style = esc_attr( $atts['style'] ); |
|
| 1418 | + $safe_type = esc_attr($atts['type']); |
|
| 1419 | + $safe_style = esc_attr($atts['style']); |
|
| 1420 | 1420 | |
| 1421 | 1421 | ob_start(); |
| 1422 | 1422 | |
| 1423 | - if ( 1 === $instance ) { |
|
| 1423 | + if (1 === $instance) { |
|
| 1424 | 1424 | /** |
| 1425 | 1425 | * Print and enqueue playlist scripts, styles, and JavaScript templates. |
| 1426 | 1426 | * |
@@ -1429,15 +1429,15 @@ discard block |
||
| 1429 | 1429 | * @param string $type Type of playlist. Possible values are 'audio' or 'video'. |
| 1430 | 1430 | * @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'. |
| 1431 | 1431 | */ |
| 1432 | - do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] ); |
|
| 1432 | + do_action('wp_playlist_scripts', $atts['type'], $atts['style']); |
|
| 1433 | 1433 | } ?> |
| 1434 | 1434 | <div class="wp-playlist wp-<?php echo $safe_type ?>-playlist wp-playlist-<?php echo $safe_style ?>"> |
| 1435 | - <?php if ( 'audio' === $atts['type'] ): ?> |
|
| 1435 | + <?php if ('audio' === $atts['type']): ?> |
|
| 1436 | 1436 | <div class="wp-playlist-current-item"></div> |
| 1437 | 1437 | <?php endif ?> |
| 1438 | 1438 | <<?php echo $safe_type ?> controls="controls" preload="none" width="<?php |
| 1439 | 1439 | echo (int) $theme_width; |
| 1440 | - ?>"<?php if ( 'video' === $safe_type ): |
|
| 1440 | + ?>"<?php if ('video' === $safe_type): |
|
| 1441 | 1441 | echo ' height="', (int) $theme_height, '"'; |
| 1442 | 1442 | else: |
| 1443 | 1443 | echo ' style="visibility: hidden"'; |
@@ -1446,17 +1446,17 @@ discard block |
||
| 1446 | 1446 | <div class="wp-playlist-prev"></div> |
| 1447 | 1447 | <noscript> |
| 1448 | 1448 | <ol><?php |
| 1449 | - foreach ( $attachments as $att_id => $attachment ) { |
|
| 1450 | - printf( '<li>%s</li>', wp_get_attachment_link( $att_id ) ); |
|
| 1449 | + foreach ($attachments as $att_id => $attachment) { |
|
| 1450 | + printf('<li>%s</li>', wp_get_attachment_link($att_id)); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | ?></ol> |
| 1453 | 1453 | </noscript> |
| 1454 | - <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ) ?></script> |
|
| 1454 | + <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode($data) ?></script> |
|
| 1455 | 1455 | </div> |
| 1456 | 1456 | <?php |
| 1457 | 1457 | return ob_get_clean(); |
| 1458 | 1458 | } |
| 1459 | -add_shortcode( 'playlist', 'wp_playlist_shortcode' ); |
|
| 1459 | +add_shortcode('playlist', 'wp_playlist_shortcode'); |
|
| 1460 | 1460 | |
| 1461 | 1461 | /** |
| 1462 | 1462 | * Provides a No-JS Flash fallback as a last resort for audio / video. |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | * @param string $url The media element URL. |
| 1467 | 1467 | * @return string Fallback HTML. |
| 1468 | 1468 | */ |
| 1469 | -function wp_mediaelement_fallback( $url ) { |
|
| 1469 | +function wp_mediaelement_fallback($url) { |
|
| 1470 | 1470 | /** |
| 1471 | 1471 | * Filter the Mediaelement fallback output for no-JS. |
| 1472 | 1472 | * |
@@ -1475,7 +1475,7 @@ discard block |
||
| 1475 | 1475 | * @param string $output Fallback output for no-JS. |
| 1476 | 1476 | * @param string $url Media file URL. |
| 1477 | 1477 | */ |
| 1478 | - return apply_filters( 'wp_mediaelement_fallback', sprintf( '<a href="%1$s">%1$s</a>', esc_url( $url ) ), $url ); |
|
| 1478 | + return apply_filters('wp_mediaelement_fallback', sprintf('<a href="%1$s">%1$s</a>', esc_url($url)), $url); |
|
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | 1481 | /** |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | * @param array $extensions An array of support audio formats. Defaults are |
| 1495 | 1495 | * 'mp3', 'ogg', 'wma', 'm4a', 'wav'. |
| 1496 | 1496 | */ |
| 1497 | - return apply_filters( 'wp_audio_extensions', array( 'mp3', 'ogg', 'wma', 'm4a', 'wav' ) ); |
|
| 1497 | + return apply_filters('wp_audio_extensions', array('mp3', 'ogg', 'wma', 'm4a', 'wav')); |
|
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | /** |
@@ -1506,19 +1506,19 @@ discard block |
||
| 1506 | 1506 | * @param string $context Optional. The context. Accepts 'edit', 'display'. Default 'display'. |
| 1507 | 1507 | * @return array Key/value pairs of field keys to labels. |
| 1508 | 1508 | */ |
| 1509 | -function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) { |
|
| 1509 | +function wp_get_attachment_id3_keys($attachment, $context = 'display') { |
|
| 1510 | 1510 | $fields = array( |
| 1511 | - 'artist' => __( 'Artist' ), |
|
| 1512 | - 'album' => __( 'Album' ), |
|
| 1511 | + 'artist' => __('Artist'), |
|
| 1512 | + 'album' => __('Album'), |
|
| 1513 | 1513 | ); |
| 1514 | 1514 | |
| 1515 | - if ( 'display' === $context ) { |
|
| 1516 | - $fields['genre'] = __( 'Genre' ); |
|
| 1517 | - $fields['year'] = __( 'Year' ); |
|
| 1518 | - $fields['length_formatted'] = _x( 'Length', 'video or audio' ); |
|
| 1519 | - } elseif ( 'js' === $context ) { |
|
| 1520 | - $fields['bitrate'] = __( 'Bitrate' ); |
|
| 1521 | - $fields['bitrate_mode'] = __( 'Bitrate Mode' ); |
|
| 1515 | + if ('display' === $context) { |
|
| 1516 | + $fields['genre'] = __('Genre'); |
|
| 1517 | + $fields['year'] = __('Year'); |
|
| 1518 | + $fields['length_formatted'] = _x('Length', 'video or audio'); |
|
| 1519 | + } elseif ('js' === $context) { |
|
| 1520 | + $fields['bitrate'] = __('Bitrate'); |
|
| 1521 | + $fields['bitrate_mode'] = __('Bitrate Mode'); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | /** |
@@ -1530,7 +1530,7 @@ discard block |
||
| 1530 | 1530 | * @param WP_Post $attachment Attachment object. |
| 1531 | 1531 | * @param string $context The context. Accepts 'edit', 'display'. Default 'display'. |
| 1532 | 1532 | */ |
| 1533 | - return apply_filters( 'wp_get_attachment_id3_keys', $fields, $attachment, $context ); |
|
| 1533 | + return apply_filters('wp_get_attachment_id3_keys', $fields, $attachment, $context); |
|
| 1534 | 1534 | } |
| 1535 | 1535 | /** |
| 1536 | 1536 | * Builds the Audio shortcode output. |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | * @param string $content Shortcode content. |
| 1556 | 1556 | * @return string|void HTML content to display audio. |
| 1557 | 1557 | */ |
| 1558 | -function wp_audio_shortcode( $attr, $content = '' ) { |
|
| 1558 | +function wp_audio_shortcode($attr, $content = '') { |
|
| 1559 | 1559 | $post_id = get_post() ? get_the_ID() : 0; |
| 1560 | 1560 | |
| 1561 | 1561 | static $instance = 0; |
@@ -1573,8 +1573,8 @@ discard block |
||
| 1573 | 1573 | * @param string $content Shortcode content. |
| 1574 | 1574 | * @param int $instance Unique numeric ID of this audio shortcode instance. |
| 1575 | 1575 | */ |
| 1576 | - $override = apply_filters( 'wp_audio_shortcode_override', '', $attr, $content, $instance ); |
|
| 1577 | - if ( '' !== $override ) { |
|
| 1576 | + $override = apply_filters('wp_audio_shortcode_override', '', $attr, $content, $instance); |
|
| 1577 | + if ('' !== $override) { |
|
| 1578 | 1578 | return $override; |
| 1579 | 1579 | } |
| 1580 | 1580 | |
@@ -1587,44 +1587,44 @@ discard block |
||
| 1587 | 1587 | 'autoplay' => '', |
| 1588 | 1588 | 'preload' => 'none' |
| 1589 | 1589 | ); |
| 1590 | - foreach ( $default_types as $type ) { |
|
| 1590 | + foreach ($default_types as $type) { |
|
| 1591 | 1591 | $defaults_atts[$type] = ''; |
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | - $atts = shortcode_atts( $defaults_atts, $attr, 'audio' ); |
|
| 1594 | + $atts = shortcode_atts($defaults_atts, $attr, 'audio'); |
|
| 1595 | 1595 | |
| 1596 | 1596 | $primary = false; |
| 1597 | - if ( ! empty( $atts['src'] ) ) { |
|
| 1598 | - $type = wp_check_filetype( $atts['src'], wp_get_mime_types() ); |
|
| 1599 | - if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) { |
|
| 1600 | - return sprintf( '<a class="wp-embedded-audio" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) ); |
|
| 1597 | + if ( ! empty($atts['src'])) { |
|
| 1598 | + $type = wp_check_filetype($atts['src'], wp_get_mime_types()); |
|
| 1599 | + if ( ! in_array(strtolower($type['ext']), $default_types)) { |
|
| 1600 | + return sprintf('<a class="wp-embedded-audio" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); |
|
| 1601 | 1601 | } |
| 1602 | 1602 | $primary = true; |
| 1603 | - array_unshift( $default_types, 'src' ); |
|
| 1603 | + array_unshift($default_types, 'src'); |
|
| 1604 | 1604 | } else { |
| 1605 | - foreach ( $default_types as $ext ) { |
|
| 1606 | - if ( ! empty( $atts[ $ext ] ) ) { |
|
| 1607 | - $type = wp_check_filetype( $atts[ $ext ], wp_get_mime_types() ); |
|
| 1608 | - if ( strtolower( $type['ext'] ) === $ext ) { |
|
| 1605 | + foreach ($default_types as $ext) { |
|
| 1606 | + if ( ! empty($atts[$ext])) { |
|
| 1607 | + $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); |
|
| 1608 | + if (strtolower($type['ext']) === $ext) { |
|
| 1609 | 1609 | $primary = true; |
| 1610 | 1610 | } |
| 1611 | 1611 | } |
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | - if ( ! $primary ) { |
|
| 1616 | - $audios = get_attached_media( 'audio', $post_id ); |
|
| 1617 | - if ( empty( $audios ) ) { |
|
| 1615 | + if ( ! $primary) { |
|
| 1616 | + $audios = get_attached_media('audio', $post_id); |
|
| 1617 | + if (empty($audios)) { |
|
| 1618 | 1618 | return; |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | - $audio = reset( $audios ); |
|
| 1622 | - $atts['src'] = wp_get_attachment_url( $audio->ID ); |
|
| 1623 | - if ( empty( $atts['src'] ) ) { |
|
| 1621 | + $audio = reset($audios); |
|
| 1622 | + $atts['src'] = wp_get_attachment_url($audio->ID); |
|
| 1623 | + if (empty($atts['src'])) { |
|
| 1624 | 1624 | return; |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - array_unshift( $default_types, 'src' ); |
|
| 1627 | + array_unshift($default_types, 'src'); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | /** |
@@ -1634,10 +1634,10 @@ discard block |
||
| 1634 | 1634 | * |
| 1635 | 1635 | * @param string $library Media library used for the audio shortcode. |
| 1636 | 1636 | */ |
| 1637 | - $library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ); |
|
| 1638 | - if ( 'mediaelement' === $library && did_action( 'init' ) ) { |
|
| 1639 | - wp_enqueue_style( 'wp-mediaelement' ); |
|
| 1640 | - wp_enqueue_script( 'wp-mediaelement' ); |
|
| 1637 | + $library = apply_filters('wp_audio_shortcode_library', 'mediaelement'); |
|
| 1638 | + if ('mediaelement' === $library && did_action('init')) { |
|
| 1639 | + wp_enqueue_style('wp-mediaelement'); |
|
| 1640 | + wp_enqueue_script('wp-mediaelement'); |
|
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | /** |
@@ -1648,47 +1648,47 @@ discard block |
||
| 1648 | 1648 | * @param string $class CSS class or list of space-separated classes. |
| 1649 | 1649 | */ |
| 1650 | 1650 | $html_atts = array( |
| 1651 | - 'class' => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ), |
|
| 1652 | - 'id' => sprintf( 'audio-%d-%d', $post_id, $instance ), |
|
| 1653 | - 'loop' => wp_validate_boolean( $atts['loop'] ), |
|
| 1654 | - 'autoplay' => wp_validate_boolean( $atts['autoplay'] ), |
|
| 1651 | + 'class' => apply_filters('wp_audio_shortcode_class', 'wp-audio-shortcode'), |
|
| 1652 | + 'id' => sprintf('audio-%d-%d', $post_id, $instance), |
|
| 1653 | + 'loop' => wp_validate_boolean($atts['loop']), |
|
| 1654 | + 'autoplay' => wp_validate_boolean($atts['autoplay']), |
|
| 1655 | 1655 | 'preload' => $atts['preload'], |
| 1656 | 1656 | 'style' => 'width: 100%; visibility: hidden;', |
| 1657 | 1657 | ); |
| 1658 | 1658 | |
| 1659 | 1659 | // These ones should just be omitted altogether if they are blank |
| 1660 | - foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) { |
|
| 1661 | - if ( empty( $html_atts[$a] ) ) { |
|
| 1662 | - unset( $html_atts[$a] ); |
|
| 1660 | + foreach (array('loop', 'autoplay', 'preload') as $a) { |
|
| 1661 | + if (empty($html_atts[$a])) { |
|
| 1662 | + unset($html_atts[$a]); |
|
| 1663 | 1663 | } |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | $attr_strings = array(); |
| 1667 | - foreach ( $html_atts as $k => $v ) { |
|
| 1668 | - $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 1667 | + foreach ($html_atts as $k => $v) { |
|
| 1668 | + $attr_strings[] = $k.'="'.esc_attr($v).'"'; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | $html = ''; |
| 1672 | - if ( 'mediaelement' === $library && 1 === $instance ) { |
|
| 1672 | + if ('mediaelement' === $library && 1 === $instance) { |
|
| 1673 | 1673 | $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n"; |
| 1674 | 1674 | } |
| 1675 | - $html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) ); |
|
| 1675 | + $html .= sprintf('<audio %s controls="controls">', join(' ', $attr_strings)); |
|
| 1676 | 1676 | |
| 1677 | 1677 | $fileurl = ''; |
| 1678 | 1678 | $source = '<source type="%s" src="%s" />'; |
| 1679 | - foreach ( $default_types as $fallback ) { |
|
| 1680 | - if ( ! empty( $atts[ $fallback ] ) ) { |
|
| 1681 | - if ( empty( $fileurl ) ) { |
|
| 1682 | - $fileurl = $atts[ $fallback ]; |
|
| 1679 | + foreach ($default_types as $fallback) { |
|
| 1680 | + if ( ! empty($atts[$fallback])) { |
|
| 1681 | + if (empty($fileurl)) { |
|
| 1682 | + $fileurl = $atts[$fallback]; |
|
| 1683 | 1683 | } |
| 1684 | - $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() ); |
|
| 1685 | - $url = add_query_arg( '_', $instance, $atts[ $fallback ] ); |
|
| 1686 | - $html .= sprintf( $source, $type['type'], esc_url( $url ) ); |
|
| 1684 | + $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); |
|
| 1685 | + $url = add_query_arg('_', $instance, $atts[$fallback]); |
|
| 1686 | + $html .= sprintf($source, $type['type'], esc_url($url)); |
|
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - if ( 'mediaelement' === $library ) { |
|
| 1691 | - $html .= wp_mediaelement_fallback( $fileurl ); |
|
| 1690 | + if ('mediaelement' === $library) { |
|
| 1691 | + $html .= wp_mediaelement_fallback($fileurl); |
|
| 1692 | 1692 | } |
| 1693 | 1693 | $html .= '</audio>'; |
| 1694 | 1694 | |
@@ -1703,9 +1703,9 @@ discard block |
||
| 1703 | 1703 | * @param int $post_id Post ID. |
| 1704 | 1704 | * @param string $library Media library used for the audio shortcode. |
| 1705 | 1705 | */ |
| 1706 | - return apply_filters( 'wp_audio_shortcode', $html, $atts, $audio, $post_id, $library ); |
|
| 1706 | + return apply_filters('wp_audio_shortcode', $html, $atts, $audio, $post_id, $library); |
|
| 1707 | 1707 | } |
| 1708 | -add_shortcode( 'audio', 'wp_audio_shortcode' ); |
|
| 1708 | +add_shortcode('audio', 'wp_audio_shortcode'); |
|
| 1709 | 1709 | |
| 1710 | 1710 | /** |
| 1711 | 1711 | * Returns a filtered list of WP-supported video formats. |
@@ -1723,7 +1723,7 @@ discard block |
||
| 1723 | 1723 | * @param array $extensions An array of support video formats. Defaults are |
| 1724 | 1724 | * 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv'. |
| 1725 | 1725 | */ |
| 1726 | - return apply_filters( 'wp_video_extensions', array( 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv' ) ); |
|
| 1726 | + return apply_filters('wp_video_extensions', array('mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv')); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | /** |
@@ -1754,7 +1754,7 @@ discard block |
||
| 1754 | 1754 | * @param string $content Shortcode content. |
| 1755 | 1755 | * @return string|void HTML content to display video. |
| 1756 | 1756 | */ |
| 1757 | -function wp_video_shortcode( $attr, $content = '' ) { |
|
| 1757 | +function wp_video_shortcode($attr, $content = '') { |
|
| 1758 | 1758 | global $content_width; |
| 1759 | 1759 | $post_id = get_post() ? get_the_ID() : 0; |
| 1760 | 1760 | |
@@ -1776,8 +1776,8 @@ discard block |
||
| 1776 | 1776 | * @param string $content Video shortcode content. |
| 1777 | 1777 | * @param int $instance Unique numeric ID of this video shortcode instance. |
| 1778 | 1778 | */ |
| 1779 | - $override = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instance ); |
|
| 1780 | - if ( '' !== $override ) { |
|
| 1779 | + $override = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instance); |
|
| 1780 | + if ('' !== $override) { |
|
| 1781 | 1781 | return $override; |
| 1782 | 1782 | } |
| 1783 | 1783 | |
@@ -1794,22 +1794,22 @@ discard block |
||
| 1794 | 1794 | 'height' => 360, |
| 1795 | 1795 | ); |
| 1796 | 1796 | |
| 1797 | - foreach ( $default_types as $type ) { |
|
| 1797 | + foreach ($default_types as $type) { |
|
| 1798 | 1798 | $defaults_atts[$type] = ''; |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - $atts = shortcode_atts( $defaults_atts, $attr, 'video' ); |
|
| 1801 | + $atts = shortcode_atts($defaults_atts, $attr, 'video'); |
|
| 1802 | 1802 | |
| 1803 | - if ( is_admin() ) { |
|
| 1803 | + if (is_admin()) { |
|
| 1804 | 1804 | // shrink the video so it isn't huge in the admin |
| 1805 | - if ( $atts['width'] > $defaults_atts['width'] ) { |
|
| 1806 | - $atts['height'] = round( ( $atts['height'] * $defaults_atts['width'] ) / $atts['width'] ); |
|
| 1805 | + if ($atts['width'] > $defaults_atts['width']) { |
|
| 1806 | + $atts['height'] = round(($atts['height'] * $defaults_atts['width']) / $atts['width']); |
|
| 1807 | 1807 | $atts['width'] = $defaults_atts['width']; |
| 1808 | 1808 | } |
| 1809 | 1809 | } else { |
| 1810 | 1810 | // if the video is bigger than the theme |
| 1811 | - if ( ! empty( $content_width ) && $atts['width'] > $content_width ) { |
|
| 1812 | - $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] ); |
|
| 1811 | + if ( ! empty($content_width) && $atts['width'] > $content_width) { |
|
| 1812 | + $atts['height'] = round(($atts['height'] * $content_width) / $atts['width']); |
|
| 1813 | 1813 | $atts['width'] = $content_width; |
| 1814 | 1814 | } |
| 1815 | 1815 | } |
@@ -1819,46 +1819,46 @@ discard block |
||
| 1819 | 1819 | $vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#'; |
| 1820 | 1820 | |
| 1821 | 1821 | $primary = false; |
| 1822 | - if ( ! empty( $atts['src'] ) ) { |
|
| 1823 | - $is_vimeo = ( preg_match( $vimeo_pattern, $atts['src'] ) ); |
|
| 1824 | - $is_youtube = ( preg_match( $yt_pattern, $atts['src'] ) ); |
|
| 1825 | - if ( ! $is_youtube && ! $is_vimeo ) { |
|
| 1826 | - $type = wp_check_filetype( $atts['src'], wp_get_mime_types() ); |
|
| 1827 | - if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) { |
|
| 1828 | - return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) ); |
|
| 1822 | + if ( ! empty($atts['src'])) { |
|
| 1823 | + $is_vimeo = (preg_match($vimeo_pattern, $atts['src'])); |
|
| 1824 | + $is_youtube = (preg_match($yt_pattern, $atts['src'])); |
|
| 1825 | + if ( ! $is_youtube && ! $is_vimeo) { |
|
| 1826 | + $type = wp_check_filetype($atts['src'], wp_get_mime_types()); |
|
| 1827 | + if ( ! in_array(strtolower($type['ext']), $default_types)) { |
|
| 1828 | + return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); |
|
| 1829 | 1829 | } |
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | - if ( $is_vimeo ) { |
|
| 1833 | - wp_enqueue_script( 'froogaloop' ); |
|
| 1832 | + if ($is_vimeo) { |
|
| 1833 | + wp_enqueue_script('froogaloop'); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | $primary = true; |
| 1837 | - array_unshift( $default_types, 'src' ); |
|
| 1837 | + array_unshift($default_types, 'src'); |
|
| 1838 | 1838 | } else { |
| 1839 | - foreach ( $default_types as $ext ) { |
|
| 1840 | - if ( ! empty( $atts[ $ext ] ) ) { |
|
| 1841 | - $type = wp_check_filetype( $atts[ $ext ], wp_get_mime_types() ); |
|
| 1842 | - if ( strtolower( $type['ext'] ) === $ext ) { |
|
| 1839 | + foreach ($default_types as $ext) { |
|
| 1840 | + if ( ! empty($atts[$ext])) { |
|
| 1841 | + $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); |
|
| 1842 | + if (strtolower($type['ext']) === $ext) { |
|
| 1843 | 1843 | $primary = true; |
| 1844 | 1844 | } |
| 1845 | 1845 | } |
| 1846 | 1846 | } |
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | - if ( ! $primary ) { |
|
| 1850 | - $videos = get_attached_media( 'video', $post_id ); |
|
| 1851 | - if ( empty( $videos ) ) { |
|
| 1849 | + if ( ! $primary) { |
|
| 1850 | + $videos = get_attached_media('video', $post_id); |
|
| 1851 | + if (empty($videos)) { |
|
| 1852 | 1852 | return; |
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | - $video = reset( $videos ); |
|
| 1856 | - $atts['src'] = wp_get_attachment_url( $video->ID ); |
|
| 1857 | - if ( empty( $atts['src'] ) ) { |
|
| 1855 | + $video = reset($videos); |
|
| 1856 | + $atts['src'] = wp_get_attachment_url($video->ID); |
|
| 1857 | + if (empty($atts['src'])) { |
|
| 1858 | 1858 | return; |
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | - array_unshift( $default_types, 'src' ); |
|
| 1861 | + array_unshift($default_types, 'src'); |
|
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | /** |
@@ -1868,10 +1868,10 @@ discard block |
||
| 1868 | 1868 | * |
| 1869 | 1869 | * @param string $library Media library used for the video shortcode. |
| 1870 | 1870 | */ |
| 1871 | - $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' ); |
|
| 1872 | - if ( 'mediaelement' === $library && did_action( 'init' ) ) { |
|
| 1873 | - wp_enqueue_style( 'wp-mediaelement' ); |
|
| 1874 | - wp_enqueue_script( 'wp-mediaelement' ); |
|
| 1871 | + $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); |
|
| 1872 | + if ('mediaelement' === $library && did_action('init')) { |
|
| 1873 | + wp_enqueue_style('wp-mediaelement'); |
|
| 1874 | + wp_enqueue_script('wp-mediaelement'); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | /** |
@@ -1882,70 +1882,70 @@ discard block |
||
| 1882 | 1882 | * @param string $class CSS class or list of space-separated classes. |
| 1883 | 1883 | */ |
| 1884 | 1884 | $html_atts = array( |
| 1885 | - 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ), |
|
| 1886 | - 'id' => sprintf( 'video-%d-%d', $post_id, $instance ), |
|
| 1887 | - 'width' => absint( $atts['width'] ), |
|
| 1888 | - 'height' => absint( $atts['height'] ), |
|
| 1889 | - 'poster' => esc_url( $atts['poster'] ), |
|
| 1890 | - 'loop' => wp_validate_boolean( $atts['loop'] ), |
|
| 1891 | - 'autoplay' => wp_validate_boolean( $atts['autoplay'] ), |
|
| 1885 | + 'class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), |
|
| 1886 | + 'id' => sprintf('video-%d-%d', $post_id, $instance), |
|
| 1887 | + 'width' => absint($atts['width']), |
|
| 1888 | + 'height' => absint($atts['height']), |
|
| 1889 | + 'poster' => esc_url($atts['poster']), |
|
| 1890 | + 'loop' => wp_validate_boolean($atts['loop']), |
|
| 1891 | + 'autoplay' => wp_validate_boolean($atts['autoplay']), |
|
| 1892 | 1892 | 'preload' => $atts['preload'], |
| 1893 | 1893 | ); |
| 1894 | 1894 | |
| 1895 | 1895 | // These ones should just be omitted altogether if they are blank |
| 1896 | - foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) { |
|
| 1897 | - if ( empty( $html_atts[$a] ) ) { |
|
| 1898 | - unset( $html_atts[$a] ); |
|
| 1896 | + foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { |
|
| 1897 | + if (empty($html_atts[$a])) { |
|
| 1898 | + unset($html_atts[$a]); |
|
| 1899 | 1899 | } |
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | 1902 | $attr_strings = array(); |
| 1903 | - foreach ( $html_atts as $k => $v ) { |
|
| 1904 | - $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 1903 | + foreach ($html_atts as $k => $v) { |
|
| 1904 | + $attr_strings[] = $k.'="'.esc_attr($v).'"'; |
|
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | 1907 | $html = ''; |
| 1908 | - if ( 'mediaelement' === $library && 1 === $instance ) { |
|
| 1908 | + if ('mediaelement' === $library && 1 === $instance) { |
|
| 1909 | 1909 | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| 1910 | 1910 | } |
| 1911 | - $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) ); |
|
| 1911 | + $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); |
|
| 1912 | 1912 | |
| 1913 | 1913 | $fileurl = ''; |
| 1914 | 1914 | $source = '<source type="%s" src="%s" />'; |
| 1915 | - foreach ( $default_types as $fallback ) { |
|
| 1916 | - if ( ! empty( $atts[ $fallback ] ) ) { |
|
| 1917 | - if ( empty( $fileurl ) ) { |
|
| 1918 | - $fileurl = $atts[ $fallback ]; |
|
| 1915 | + foreach ($default_types as $fallback) { |
|
| 1916 | + if ( ! empty($atts[$fallback])) { |
|
| 1917 | + if (empty($fileurl)) { |
|
| 1918 | + $fileurl = $atts[$fallback]; |
|
| 1919 | 1919 | } |
| 1920 | - if ( 'src' === $fallback && $is_youtube ) { |
|
| 1921 | - $type = array( 'type' => 'video/youtube' ); |
|
| 1922 | - } elseif ( 'src' === $fallback && $is_vimeo ) { |
|
| 1923 | - $type = array( 'type' => 'video/vimeo' ); |
|
| 1920 | + if ('src' === $fallback && $is_youtube) { |
|
| 1921 | + $type = array('type' => 'video/youtube'); |
|
| 1922 | + } elseif ('src' === $fallback && $is_vimeo) { |
|
| 1923 | + $type = array('type' => 'video/vimeo'); |
|
| 1924 | 1924 | } else { |
| 1925 | - $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() ); |
|
| 1925 | + $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); |
|
| 1926 | 1926 | } |
| 1927 | - $url = add_query_arg( '_', $instance, $atts[ $fallback ] ); |
|
| 1928 | - $html .= sprintf( $source, $type['type'], esc_url( $url ) ); |
|
| 1927 | + $url = add_query_arg('_', $instance, $atts[$fallback]); |
|
| 1928 | + $html .= sprintf($source, $type['type'], esc_url($url)); |
|
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | - if ( ! empty( $content ) ) { |
|
| 1933 | - if ( false !== strpos( $content, "\n" ) ) { |
|
| 1934 | - $content = str_replace( array( "\r\n", "\n", "\t" ), '', $content ); |
|
| 1932 | + if ( ! empty($content)) { |
|
| 1933 | + if (false !== strpos($content, "\n")) { |
|
| 1934 | + $content = str_replace(array("\r\n", "\n", "\t"), '', $content); |
|
| 1935 | 1935 | } |
| 1936 | - $html .= trim( $content ); |
|
| 1936 | + $html .= trim($content); |
|
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | - if ( 'mediaelement' === $library ) { |
|
| 1940 | - $html .= wp_mediaelement_fallback( $fileurl ); |
|
| 1939 | + if ('mediaelement' === $library) { |
|
| 1940 | + $html .= wp_mediaelement_fallback($fileurl); |
|
| 1941 | 1941 | } |
| 1942 | 1942 | $html .= '</video>'; |
| 1943 | 1943 | |
| 1944 | 1944 | $width_rule = ''; |
| 1945 | - if ( ! empty( $atts['width'] ) ) { |
|
| 1946 | - $width_rule = sprintf( 'width: %dpx; ', $atts['width'] ); |
|
| 1945 | + if ( ! empty($atts['width'])) { |
|
| 1946 | + $width_rule = sprintf('width: %dpx; ', $atts['width']); |
|
| 1947 | 1947 | } |
| 1948 | - $output = sprintf( '<div style="%s" class="wp-video">%s</div>', $width_rule, $html ); |
|
| 1948 | + $output = sprintf('<div style="%s" class="wp-video">%s</div>', $width_rule, $html); |
|
| 1949 | 1949 | |
| 1950 | 1950 | /** |
| 1951 | 1951 | * Filter the output of the video shortcode. |
@@ -1958,9 +1958,9 @@ discard block |
||
| 1958 | 1958 | * @param int $post_id Post ID. |
| 1959 | 1959 | * @param string $library Media library used for the video shortcode. |
| 1960 | 1960 | */ |
| 1961 | - return apply_filters( 'wp_video_shortcode', $output, $atts, $video, $post_id, $library ); |
|
| 1961 | + return apply_filters('wp_video_shortcode', $output, $atts, $video, $post_id, $library); |
|
| 1962 | 1962 | } |
| 1963 | -add_shortcode( 'video', 'wp_video_shortcode' ); |
|
| 1963 | +add_shortcode('video', 'wp_video_shortcode'); |
|
| 1964 | 1964 | |
| 1965 | 1965 | /** |
| 1966 | 1966 | * Displays previous image link that has the same post parent. |
@@ -1973,7 +1973,7 @@ discard block |
||
| 1973 | 1973 | * 0 or 'none' will default to 'post_title' or `$text`. Default 'thumbnail'. |
| 1974 | 1974 | * @param string $text Optional. Link text. Default false. |
| 1975 | 1975 | */ |
| 1976 | -function previous_image_link( $size = 'thumbnail', $text = false ) { |
|
| 1976 | +function previous_image_link($size = 'thumbnail', $text = false) { |
|
| 1977 | 1977 | adjacent_image_link(true, $size, $text); |
| 1978 | 1978 | } |
| 1979 | 1979 | |
@@ -2004,12 +2004,12 @@ discard block |
||
| 2004 | 2004 | * Default 'thumbnail'. |
| 2005 | 2005 | * @param bool $text Optional. Link text. Default false. |
| 2006 | 2006 | */ |
| 2007 | -function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) { |
|
| 2007 | +function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { |
|
| 2008 | 2008 | $post = get_post(); |
| 2009 | - $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); |
|
| 2009 | + $attachments = array_values(get_children(array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'))); |
|
| 2010 | 2010 | |
| 2011 | - foreach ( $attachments as $k => $attachment ) { |
|
| 2012 | - if ( $attachment->ID == $post->ID ) { |
|
| 2011 | + foreach ($attachments as $k => $attachment) { |
|
| 2012 | + if ($attachment->ID == $post->ID) { |
|
| 2013 | 2013 | break; |
| 2014 | 2014 | } |
| 2015 | 2015 | } |
@@ -2017,12 +2017,12 @@ discard block |
||
| 2017 | 2017 | $output = ''; |
| 2018 | 2018 | $attachment_id = 0; |
| 2019 | 2019 | |
| 2020 | - if ( $attachments ) { |
|
| 2020 | + if ($attachments) { |
|
| 2021 | 2021 | $k = $prev ? $k - 1 : $k + 1; |
| 2022 | 2022 | |
| 2023 | - if ( isset( $attachments[ $k ] ) ) { |
|
| 2024 | - $attachment_id = $attachments[ $k ]->ID; |
|
| 2025 | - $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text ); |
|
| 2023 | + if (isset($attachments[$k])) { |
|
| 2024 | + $attachment_id = $attachments[$k]->ID; |
|
| 2025 | + $output = wp_get_attachment_link($attachment_id, $size, true, false, $text); |
|
| 2026 | 2026 | } |
| 2027 | 2027 | } |
| 2028 | 2028 | |
@@ -2041,7 +2041,7 @@ discard block |
||
| 2041 | 2041 | * @param string $size Image size. |
| 2042 | 2042 | * @param string $text Link text. |
| 2043 | 2043 | */ |
| 2044 | - echo apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text ); |
|
| 2044 | + echo apply_filters("{$adjacent}_image_link", $output, $attachment_id, $size, $text); |
|
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | /** |
@@ -2052,32 +2052,32 @@ discard block |
||
| 2052 | 2052 | * @param int|array|object $attachment Attachment ID, data array, or data object. |
| 2053 | 2053 | * @return array Empty array on failure. List of taxonomies on success. |
| 2054 | 2054 | */ |
| 2055 | -function get_attachment_taxonomies( $attachment ) { |
|
| 2056 | - if ( is_int( $attachment ) ) { |
|
| 2057 | - $attachment = get_post( $attachment ); |
|
| 2058 | - } elseif ( is_array( $attachment ) ) { |
|
| 2055 | +function get_attachment_taxonomies($attachment) { |
|
| 2056 | + if (is_int($attachment)) { |
|
| 2057 | + $attachment = get_post($attachment); |
|
| 2058 | + } elseif (is_array($attachment)) { |
|
| 2059 | 2059 | $attachment = (object) $attachment; |
| 2060 | 2060 | } |
| 2061 | - if ( ! is_object($attachment) ) |
|
| 2061 | + if ( ! is_object($attachment)) |
|
| 2062 | 2062 | return array(); |
| 2063 | 2063 | |
| 2064 | 2064 | $filename = basename($attachment->guid); |
| 2065 | 2065 | |
| 2066 | 2066 | $objects = array('attachment'); |
| 2067 | 2067 | |
| 2068 | - if ( false !== strpos($filename, '.') ) |
|
| 2069 | - $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); |
|
| 2070 | - if ( !empty($attachment->post_mime_type) ) { |
|
| 2071 | - $objects[] = 'attachment:' . $attachment->post_mime_type; |
|
| 2072 | - if ( false !== strpos($attachment->post_mime_type, '/') ) |
|
| 2073 | - foreach ( explode('/', $attachment->post_mime_type) as $token ) |
|
| 2074 | - if ( !empty($token) ) |
|
| 2068 | + if (false !== strpos($filename, '.')) |
|
| 2069 | + $objects[] = 'attachment:'.substr($filename, strrpos($filename, '.') + 1); |
|
| 2070 | + if ( ! empty($attachment->post_mime_type)) { |
|
| 2071 | + $objects[] = 'attachment:'.$attachment->post_mime_type; |
|
| 2072 | + if (false !== strpos($attachment->post_mime_type, '/')) |
|
| 2073 | + foreach (explode('/', $attachment->post_mime_type) as $token) |
|
| 2074 | + if ( ! empty($token)) |
|
| 2075 | 2075 | $objects[] = "attachment:$token"; |
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | $taxonomies = array(); |
| 2079 | - foreach ( $objects as $object ) |
|
| 2080 | - if ( $taxes = get_object_taxonomies($object) ) |
|
| 2079 | + foreach ($objects as $object) |
|
| 2080 | + if ($taxes = get_object_taxonomies($object)) |
|
| 2081 | 2081 | $taxonomies = array_merge($taxonomies, $taxes); |
| 2082 | 2082 | |
| 2083 | 2083 | return array_unique($taxonomies); |
@@ -2096,15 +2096,15 @@ discard block |
||
| 2096 | 2096 | * Default 'names'. |
| 2097 | 2097 | * @return array The names of all taxonomy of $object_type. |
| 2098 | 2098 | */ |
| 2099 | -function get_taxonomies_for_attachments( $output = 'names' ) { |
|
| 2099 | +function get_taxonomies_for_attachments($output = 'names') { |
|
| 2100 | 2100 | $taxonomies = array(); |
| 2101 | - foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) { |
|
| 2102 | - foreach ( $taxonomy->object_type as $object_type ) { |
|
| 2103 | - if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) { |
|
| 2104 | - if ( 'names' == $output ) |
|
| 2101 | + foreach (get_taxonomies(array(), 'objects') as $taxonomy) { |
|
| 2102 | + foreach ($taxonomy->object_type as $object_type) { |
|
| 2103 | + if ('attachment' == $object_type || 0 === strpos($object_type, 'attachment:')) { |
|
| 2104 | + if ('names' == $output) |
|
| 2105 | 2105 | $taxonomies[] = $taxonomy->name; |
| 2106 | 2106 | else |
| 2107 | - $taxonomies[ $taxonomy->name ] = $taxonomy; |
|
| 2107 | + $taxonomies[$taxonomy->name] = $taxonomy; |
|
| 2108 | 2108 | break; |
| 2109 | 2109 | } |
| 2110 | 2110 | } |
@@ -2126,7 +2126,7 @@ discard block |
||
| 2126 | 2126 | */ |
| 2127 | 2127 | function wp_imagecreatetruecolor($width, $height) { |
| 2128 | 2128 | $img = imagecreatetruecolor($width, $height); |
| 2129 | - if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) { |
|
| 2129 | + if (is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha')) { |
|
| 2130 | 2130 | imagealphablending($img, false); |
| 2131 | 2131 | imagesavealpha($img, true); |
| 2132 | 2132 | } |
@@ -2148,9 +2148,9 @@ discard block |
||
| 2148 | 2148 | * @param int $priority Optional. Used to specify the order in which the registered handlers will |
| 2149 | 2149 | * be tested. Default 10. |
| 2150 | 2150 | */ |
| 2151 | -function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) { |
|
| 2151 | +function wp_embed_register_handler($id, $regex, $callback, $priority = 10) { |
|
| 2152 | 2152 | global $wp_embed; |
| 2153 | - $wp_embed->register_handler( $id, $regex, $callback, $priority ); |
|
| 2153 | + $wp_embed->register_handler($id, $regex, $callback, $priority); |
|
| 2154 | 2154 | } |
| 2155 | 2155 | |
| 2156 | 2156 | /** |
@@ -2163,9 +2163,9 @@ discard block |
||
| 2163 | 2163 | * @param string $id The handler ID that should be removed. |
| 2164 | 2164 | * @param int $priority Optional. The priority of the handler to be removed. Default 10. |
| 2165 | 2165 | */ |
| 2166 | -function wp_embed_unregister_handler( $id, $priority = 10 ) { |
|
| 2166 | +function wp_embed_unregister_handler($id, $priority = 10) { |
|
| 2167 | 2167 | global $wp_embed; |
| 2168 | - $wp_embed->unregister_handler( $id, $priority ); |
|
| 2168 | + $wp_embed->unregister_handler($id, $priority); |
|
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | /** |
@@ -2186,14 +2186,14 @@ discard block |
||
| 2186 | 2186 | * |
| 2187 | 2187 | * @return array Default embed parameters. |
| 2188 | 2188 | */ |
| 2189 | -function wp_embed_defaults( $url = '' ) { |
|
| 2190 | - if ( ! empty( $GLOBALS['content_width'] ) ) |
|
| 2189 | +function wp_embed_defaults($url = '') { |
|
| 2190 | + if ( ! empty($GLOBALS['content_width'])) |
|
| 2191 | 2191 | $width = (int) $GLOBALS['content_width']; |
| 2192 | 2192 | |
| 2193 | - if ( empty( $width ) ) |
|
| 2193 | + if (empty($width)) |
|
| 2194 | 2194 | $width = 500; |
| 2195 | 2195 | |
| 2196 | - $height = min( ceil( $width * 1.5 ), 1000 ); |
|
| 2196 | + $height = min(ceil($width * 1.5), 1000); |
|
| 2197 | 2197 | |
| 2198 | 2198 | /** |
| 2199 | 2199 | * Filter the default array of embed dimensions. |
@@ -2204,7 +2204,7 @@ discard block |
||
| 2204 | 2204 | * @param int $height Height of the embed in pixels. |
| 2205 | 2205 | * @param string $url The URL that should be embedded. |
| 2206 | 2206 | */ |
| 2207 | - return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url ); |
|
| 2207 | + return apply_filters('embed_defaults', compact('width', 'height'), $url); |
|
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | 2210 | /** |
@@ -2220,13 +2220,13 @@ discard block |
||
| 2220 | 2220 | * @param int $max_height The maximum allowed height. |
| 2221 | 2221 | * @return array The maximum possible width and height based on the example ratio. |
| 2222 | 2222 | */ |
| 2223 | -function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) { |
|
| 2223 | +function wp_expand_dimensions($example_width, $example_height, $max_width, $max_height) { |
|
| 2224 | 2224 | $example_width = (int) $example_width; |
| 2225 | 2225 | $example_height = (int) $example_height; |
| 2226 | 2226 | $max_width = (int) $max_width; |
| 2227 | 2227 | $max_height = (int) $max_height; |
| 2228 | 2228 | |
| 2229 | - return wp_constrain_dimensions( $example_width * 1000000, $example_height * 1000000, $max_width, $max_height ); |
|
| 2229 | + return wp_constrain_dimensions($example_width * 1000000, $example_height * 1000000, $max_width, $max_height); |
|
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | /** |
@@ -2241,10 +2241,10 @@ discard block |
||
| 2241 | 2241 | * Default empty. |
| 2242 | 2242 | * @return false|string False on failure or the embed HTML on success. |
| 2243 | 2243 | */ |
| 2244 | -function wp_oembed_get( $url, $args = '' ) { |
|
| 2245 | - require_once( ABSPATH . WPINC . '/class-oembed.php' ); |
|
| 2244 | +function wp_oembed_get($url, $args = '') { |
|
| 2245 | + require_once(ABSPATH.WPINC.'/class-oembed.php'); |
|
| 2246 | 2246 | $oembed = _wp_oembed_get_object(); |
| 2247 | - return $oembed->get_html( $url, $args ); |
|
| 2247 | + return $oembed->get_html($url, $args); |
|
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | 2250 | /** |
@@ -2259,14 +2259,14 @@ discard block |
||
| 2259 | 2259 | * @param string $provider The URL to the oEmbed provider. |
| 2260 | 2260 | * @param boolean $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false. |
| 2261 | 2261 | */ |
| 2262 | -function wp_oembed_add_provider( $format, $provider, $regex = false ) { |
|
| 2263 | - require_once( ABSPATH . WPINC . '/class-oembed.php' ); |
|
| 2262 | +function wp_oembed_add_provider($format, $provider, $regex = false) { |
|
| 2263 | + require_once(ABSPATH.WPINC.'/class-oembed.php'); |
|
| 2264 | 2264 | |
| 2265 | - if ( did_action( 'plugins_loaded' ) ) { |
|
| 2265 | + if (did_action('plugins_loaded')) { |
|
| 2266 | 2266 | $oembed = _wp_oembed_get_object(); |
| 2267 | - $oembed->providers[$format] = array( $provider, $regex ); |
|
| 2267 | + $oembed->providers[$format] = array($provider, $regex); |
|
| 2268 | 2268 | } else { |
| 2269 | - WP_oEmbed::_add_provider_early( $format, $provider, $regex ); |
|
| 2269 | + WP_oEmbed::_add_provider_early($format, $provider, $regex); |
|
| 2270 | 2270 | } |
| 2271 | 2271 | } |
| 2272 | 2272 | |
@@ -2280,18 +2280,18 @@ discard block |
||
| 2280 | 2280 | * @param string $format The URL format for the oEmbed provider to remove. |
| 2281 | 2281 | * @return bool Was the provider removed successfully? |
| 2282 | 2282 | */ |
| 2283 | -function wp_oembed_remove_provider( $format ) { |
|
| 2284 | - require_once( ABSPATH . WPINC . '/class-oembed.php' ); |
|
| 2283 | +function wp_oembed_remove_provider($format) { |
|
| 2284 | + require_once(ABSPATH.WPINC.'/class-oembed.php'); |
|
| 2285 | 2285 | |
| 2286 | - if ( did_action( 'plugins_loaded' ) ) { |
|
| 2286 | + if (did_action('plugins_loaded')) { |
|
| 2287 | 2287 | $oembed = _wp_oembed_get_object(); |
| 2288 | 2288 | |
| 2289 | - if ( isset( $oembed->providers[ $format ] ) ) { |
|
| 2290 | - unset( $oembed->providers[ $format ] ); |
|
| 2289 | + if (isset($oembed->providers[$format])) { |
|
| 2290 | + unset($oembed->providers[$format]); |
|
| 2291 | 2291 | return true; |
| 2292 | 2292 | } |
| 2293 | 2293 | } else { |
| 2294 | - WP_oEmbed::_remove_provider_early( $format ); |
|
| 2294 | + WP_oEmbed::_remove_provider_early($format); |
|
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | return false; |
@@ -2317,13 +2317,13 @@ discard block |
||
| 2317 | 2317 | * |
| 2318 | 2318 | * @param bool $maybe_load_embeds Whether to load the embeds library. Default true. |
| 2319 | 2319 | */ |
| 2320 | - if ( ! apply_filters( 'load_default_embeds', true ) ) { |
|
| 2320 | + if ( ! apply_filters('load_default_embeds', true)) { |
|
| 2321 | 2321 | return; |
| 2322 | 2322 | } |
| 2323 | 2323 | |
| 2324 | - wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); |
|
| 2324 | + wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube'); |
|
| 2325 | 2325 | |
| 2326 | - wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); |
|
| 2326 | + wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo'); |
|
| 2327 | 2327 | |
| 2328 | 2328 | /** |
| 2329 | 2329 | * Filter the audio embed handler callback. |
@@ -2332,7 +2332,7 @@ discard block |
||
| 2332 | 2332 | * |
| 2333 | 2333 | * @param callback $handler Audio embed handler callback function. |
| 2334 | 2334 | */ |
| 2335 | - wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); |
|
| 2335 | + wp_embed_register_handler('audio', '#^https?://.+?\.('.join('|', wp_get_audio_extensions()).')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999); |
|
| 2336 | 2336 | |
| 2337 | 2337 | /** |
| 2338 | 2338 | * Filter the video embed handler callback. |
@@ -2341,7 +2341,7 @@ discard block |
||
| 2341 | 2341 | * |
| 2342 | 2342 | * @param callback $handler Video embed handler callback function. |
| 2343 | 2343 | */ |
| 2344 | - wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 ); |
|
| 2344 | + wp_embed_register_handler('video', '#^https?://.+?\.('.join('|', wp_get_video_extensions()).')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999); |
|
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | 2347 | /** |
@@ -2358,13 +2358,13 @@ discard block |
||
| 2358 | 2358 | * @param array $rawattr The original unmodified attributes. |
| 2359 | 2359 | * @return string The embed HTML. |
| 2360 | 2360 | */ |
| 2361 | -function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { |
|
| 2361 | +function wp_embed_handler_googlevideo($matches, $attr, $url, $rawattr) { |
|
| 2362 | 2362 | // If the user supplied a fixed width AND height, use it |
| 2363 | - if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) { |
|
| 2363 | + if ( ! empty($rawattr['width']) && ! empty($rawattr['height'])) { |
|
| 2364 | 2364 | $width = (int) $rawattr['width']; |
| 2365 | 2365 | $height = (int) $rawattr['height']; |
| 2366 | 2366 | } else { |
| 2367 | - list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] ); |
|
| 2367 | + list($width, $height) = wp_expand_dimensions(425, 344, $attr['width'], $attr['height']); |
|
| 2368 | 2368 | } |
| 2369 | 2369 | |
| 2370 | 2370 | /** |
@@ -2378,7 +2378,7 @@ discard block |
||
| 2378 | 2378 | * @param string $url The original URL that was matched by the regex. |
| 2379 | 2379 | * @param array $rawattr The original unmodified attributes. |
| 2380 | 2380 | */ |
| 2381 | - return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr ); |
|
| 2381 | + return apply_filters('embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid='.esc_attr($matches[2]).'&hl=en&fs=true" style="width:'.esc_attr($width).'px;height:'.esc_attr($height).'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr); |
|
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | 2384 | /** |
@@ -2397,9 +2397,9 @@ discard block |
||
| 2397 | 2397 | * @param array $rawattr The original unmodified attributes. |
| 2398 | 2398 | * @return string The embed HTML. |
| 2399 | 2399 | */ |
| 2400 | -function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { |
|
| 2400 | +function wp_embed_handler_youtube($matches, $attr, $url, $rawattr) { |
|
| 2401 | 2401 | global $wp_embed; |
| 2402 | - $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" ); |
|
| 2402 | + $embed = $wp_embed->autoembed("https://youtube.com/watch?v={$matches[2]}"); |
|
| 2403 | 2403 | |
| 2404 | 2404 | /** |
| 2405 | 2405 | * Filter the YoutTube embed output. |
@@ -2413,7 +2413,7 @@ discard block |
||
| 2413 | 2413 | * @param string $url The original URL that was matched by the regex. |
| 2414 | 2414 | * @param array $rawattr The original unmodified attributes. |
| 2415 | 2415 | */ |
| 2416 | - return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr ); |
|
| 2416 | + return apply_filters('wp_embed_handler_youtube', $embed, $attr, $url, $rawattr); |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | /** |
@@ -2427,8 +2427,8 @@ discard block |
||
| 2427 | 2427 | * @param array $rawattr The original unmodified attributes. |
| 2428 | 2428 | * @return string The embed HTML. |
| 2429 | 2429 | */ |
| 2430 | -function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { |
|
| 2431 | - $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) ); |
|
| 2430 | +function wp_embed_handler_audio($matches, $attr, $url, $rawattr) { |
|
| 2431 | + $audio = sprintf('[audio src="%s" /]', esc_url($url)); |
|
| 2432 | 2432 | |
| 2433 | 2433 | /** |
| 2434 | 2434 | * Filter the audio embed output. |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | * @param string $url The original URL that was matched by the regex. |
| 2441 | 2441 | * @param array $rawattr The original unmodified attributes. |
| 2442 | 2442 | */ |
| 2443 | - return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); |
|
| 2443 | + return apply_filters('wp_embed_handler_audio', $audio, $attr, $url, $rawattr); |
|
| 2444 | 2444 | } |
| 2445 | 2445 | |
| 2446 | 2446 | /** |
@@ -2454,13 +2454,13 @@ discard block |
||
| 2454 | 2454 | * @param array $rawattr The original unmodified attributes. |
| 2455 | 2455 | * @return string The embed HTML. |
| 2456 | 2456 | */ |
| 2457 | -function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { |
|
| 2457 | +function wp_embed_handler_video($matches, $attr, $url, $rawattr) { |
|
| 2458 | 2458 | $dimensions = ''; |
| 2459 | - if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { |
|
| 2460 | - $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); |
|
| 2461 | - $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); |
|
| 2459 | + if ( ! empty($rawattr['width']) && ! empty($rawattr['height'])) { |
|
| 2460 | + $dimensions .= sprintf('width="%d" ', (int) $rawattr['width']); |
|
| 2461 | + $dimensions .= sprintf('height="%d" ', (int) $rawattr['height']); |
|
| 2462 | 2462 | } |
| 2463 | - $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); |
|
| 2463 | + $video = sprintf('[video %s src="%s" /]', $dimensions, esc_url($url)); |
|
| 2464 | 2464 | |
| 2465 | 2465 | /** |
| 2466 | 2466 | * Filter the video embed output. |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | * @param string $url The original URL that was matched by the regex. |
| 2473 | 2473 | * @param array $rawattr The original unmodified attributes. |
| 2474 | 2474 | */ |
| 2475 | - return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); |
|
| 2475 | + return apply_filters('wp_embed_handler_video', $video, $attr, $url, $rawattr); |
|
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | 2478 | /** |
@@ -2483,15 +2483,15 @@ discard block |
||
| 2483 | 2483 | * @param string $size A shorthand byte value. |
| 2484 | 2484 | * @return int An integer byte value. |
| 2485 | 2485 | */ |
| 2486 | -function wp_convert_hr_to_bytes( $size ) { |
|
| 2487 | - $size = strtolower( $size ); |
|
| 2486 | +function wp_convert_hr_to_bytes($size) { |
|
| 2487 | + $size = strtolower($size); |
|
| 2488 | 2488 | $bytes = (int) $size; |
| 2489 | - if ( strpos( $size, 'k' ) !== false ) |
|
| 2490 | - $bytes = intval( $size ) * 1024; |
|
| 2491 | - elseif ( strpos( $size, 'm' ) !== false ) |
|
| 2489 | + if (strpos($size, 'k') !== false) |
|
| 2490 | + $bytes = intval($size) * 1024; |
|
| 2491 | + elseif (strpos($size, 'm') !== false) |
|
| 2492 | 2492 | $bytes = intval($size) * 1024 * 1024; |
| 2493 | - elseif ( strpos( $size, 'g' ) !== false ) |
|
| 2494 | - $bytes = intval( $size ) * 1024 * 1024 * 1024; |
|
| 2493 | + elseif (strpos($size, 'g') !== false) |
|
| 2494 | + $bytes = intval($size) * 1024 * 1024 * 1024; |
|
| 2495 | 2495 | return $bytes; |
| 2496 | 2496 | } |
| 2497 | 2497 | |
@@ -2503,8 +2503,8 @@ discard block |
||
| 2503 | 2503 | * @return int Allowed upload size. |
| 2504 | 2504 | */ |
| 2505 | 2505 | function wp_max_upload_size() { |
| 2506 | - $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
|
| 2507 | - $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); |
|
| 2506 | + $u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize')); |
|
| 2507 | + $p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size')); |
|
| 2508 | 2508 | |
| 2509 | 2509 | /** |
| 2510 | 2510 | * Filter the maximum upload size allowed in php.ini. |
@@ -2515,7 +2515,7 @@ discard block |
||
| 2515 | 2515 | * @param int $u_bytes Maximum upload filesize in bytes. |
| 2516 | 2516 | * @param int $p_bytes Maximum size of POST data in bytes. |
| 2517 | 2517 | */ |
| 2518 | - return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes ); |
|
| 2518 | + return apply_filters('upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes); |
|
| 2519 | 2519 | } |
| 2520 | 2520 | |
| 2521 | 2521 | /** |
@@ -2529,31 +2529,31 @@ discard block |
||
| 2529 | 2529 | * @return WP_Image_Editor|WP_Error The WP_Image_Editor object if successful, an WP_Error |
| 2530 | 2530 | * object otherwise. |
| 2531 | 2531 | */ |
| 2532 | -function wp_get_image_editor( $path, $args = array() ) { |
|
| 2532 | +function wp_get_image_editor($path, $args = array()) { |
|
| 2533 | 2533 | $args['path'] = $path; |
| 2534 | 2534 | |
| 2535 | - if ( ! isset( $args['mime_type'] ) ) { |
|
| 2536 | - $file_info = wp_check_filetype( $args['path'] ); |
|
| 2535 | + if ( ! isset($args['mime_type'])) { |
|
| 2536 | + $file_info = wp_check_filetype($args['path']); |
|
| 2537 | 2537 | |
| 2538 | 2538 | // If $file_info['type'] is false, then we let the editor attempt to |
| 2539 | 2539 | // figure out the file type, rather than forcing a failure based on extension. |
| 2540 | - if ( isset( $file_info ) && $file_info['type'] ) |
|
| 2540 | + if (isset($file_info) && $file_info['type']) |
|
| 2541 | 2541 | $args['mime_type'] = $file_info['type']; |
| 2542 | 2542 | } |
| 2543 | 2543 | |
| 2544 | - $implementation = _wp_image_editor_choose( $args ); |
|
| 2544 | + $implementation = _wp_image_editor_choose($args); |
|
| 2545 | 2545 | |
| 2546 | - if ( $implementation ) { |
|
| 2547 | - $editor = new $implementation( $path ); |
|
| 2546 | + if ($implementation) { |
|
| 2547 | + $editor = new $implementation($path); |
|
| 2548 | 2548 | $loaded = $editor->load(); |
| 2549 | 2549 | |
| 2550 | - if ( is_wp_error( $loaded ) ) |
|
| 2550 | + if (is_wp_error($loaded)) |
|
| 2551 | 2551 | return $loaded; |
| 2552 | 2552 | |
| 2553 | 2553 | return $editor; |
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | - return new WP_Error( 'image_no_editor', __('No editor could be selected.') ); |
|
| 2556 | + return new WP_Error('image_no_editor', __('No editor could be selected.')); |
|
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | 2559 | /** |
@@ -2565,8 +2565,8 @@ discard block |
||
| 2565 | 2565 | * Default empty array. |
| 2566 | 2566 | * @return bool True if an eligible editor is found; false otherwise. |
| 2567 | 2567 | */ |
| 2568 | -function wp_image_editor_supports( $args = array() ) { |
|
| 2569 | - return (bool) _wp_image_editor_choose( $args ); |
|
| 2568 | +function wp_image_editor_supports($args = array()) { |
|
| 2569 | + return (bool) _wp_image_editor_choose($args); |
|
| 2570 | 2570 | } |
| 2571 | 2571 | |
| 2572 | 2572 | /** |
@@ -2579,10 +2579,10 @@ discard block |
||
| 2579 | 2579 | * @return string|false Class name for the first editor that claims to support the request. False if no |
| 2580 | 2580 | * editor claims to support the request. |
| 2581 | 2581 | */ |
| 2582 | -function _wp_image_editor_choose( $args = array() ) { |
|
| 2583 | - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; |
|
| 2584 | - require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; |
|
| 2585 | - require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; |
|
| 2582 | +function _wp_image_editor_choose($args = array()) { |
|
| 2583 | + require_once ABSPATH.WPINC.'/class-wp-image-editor.php'; |
|
| 2584 | + require_once ABSPATH.WPINC.'/class-wp-image-editor-gd.php'; |
|
| 2585 | + require_once ABSPATH.WPINC.'/class-wp-image-editor-imagick.php'; |
|
| 2586 | 2586 | |
| 2587 | 2587 | /** |
| 2588 | 2588 | * Filter the list of image editing library classes. |
@@ -2592,21 +2592,21 @@ discard block |
||
| 2592 | 2592 | * @param array $image_editors List of available image editors. Defaults are |
| 2593 | 2593 | * 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'. |
| 2594 | 2594 | */ |
| 2595 | - $implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); |
|
| 2595 | + $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD')); |
|
| 2596 | 2596 | |
| 2597 | - foreach ( $implementations as $implementation ) { |
|
| 2598 | - if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) |
|
| 2597 | + foreach ($implementations as $implementation) { |
|
| 2598 | + if ( ! call_user_func(array($implementation, 'test'), $args)) |
|
| 2599 | 2599 | continue; |
| 2600 | 2600 | |
| 2601 | - if ( isset( $args['mime_type'] ) && |
|
| 2601 | + if (isset($args['mime_type']) && |
|
| 2602 | 2602 | ! call_user_func( |
| 2603 | - array( $implementation, 'supports_mime_type' ), |
|
| 2604 | - $args['mime_type'] ) ) { |
|
| 2603 | + array($implementation, 'supports_mime_type'), |
|
| 2604 | + $args['mime_type'] )) { |
|
| 2605 | 2605 | continue; |
| 2606 | 2606 | } |
| 2607 | 2607 | |
| 2608 | - if ( isset( $args['methods'] ) && |
|
| 2609 | - array_diff( $args['methods'], get_class_methods( $implementation ) ) ) { |
|
| 2608 | + if (isset($args['methods']) && |
|
| 2609 | + array_diff($args['methods'], get_class_methods($implementation))) { |
|
| 2610 | 2610 | continue; |
| 2611 | 2611 | } |
| 2612 | 2612 | |
@@ -2624,8 +2624,8 @@ discard block |
||
| 2624 | 2624 | function wp_plupload_default_settings() { |
| 2625 | 2625 | $wp_scripts = wp_scripts(); |
| 2626 | 2626 | |
| 2627 | - $data = $wp_scripts->get_data( 'wp-plupload', 'data' ); |
|
| 2628 | - if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) |
|
| 2627 | + $data = $wp_scripts->get_data('wp-plupload', 'data'); |
|
| 2628 | + if ($data && false !== strpos($data, '_wpPluploadSettings')) |
|
| 2629 | 2629 | return; |
| 2630 | 2630 | |
| 2631 | 2631 | $max_upload_size = wp_max_upload_size(); |
@@ -2633,18 +2633,18 @@ discard block |
||
| 2633 | 2633 | $defaults = array( |
| 2634 | 2634 | 'runtimes' => 'html5,flash,silverlight,html4', |
| 2635 | 2635 | 'file_data_name' => 'async-upload', // key passed to $_FILE. |
| 2636 | - 'url' => admin_url( 'async-upload.php', 'relative' ), |
|
| 2637 | - 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), |
|
| 2638 | - 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ), |
|
| 2636 | + 'url' => admin_url('async-upload.php', 'relative'), |
|
| 2637 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
| 2638 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
| 2639 | 2639 | 'filters' => array( |
| 2640 | - 'max_file_size' => $max_upload_size . 'b', |
|
| 2640 | + 'max_file_size' => $max_upload_size.'b', |
|
| 2641 | 2641 | ), |
| 2642 | 2642 | ); |
| 2643 | 2643 | |
| 2644 | 2644 | // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos |
| 2645 | 2645 | // when enabled. See #29602. |
| 2646 | - if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && |
|
| 2647 | - strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { |
|
| 2646 | + if (wp_is_mobile() && strpos($_SERVER['HTTP_USER_AGENT'], 'OS 7_') !== false && |
|
| 2647 | + strpos($_SERVER['HTTP_USER_AGENT'], 'like Mac OS X') !== false) { |
|
| 2648 | 2648 | |
| 2649 | 2649 | $defaults['multi_selection'] = false; |
| 2650 | 2650 | } |
@@ -2656,7 +2656,7 @@ discard block |
||
| 2656 | 2656 | * |
| 2657 | 2657 | * @param array $defaults Default Plupload settings array. |
| 2658 | 2658 | */ |
| 2659 | - $defaults = apply_filters( 'plupload_default_settings', $defaults ); |
|
| 2659 | + $defaults = apply_filters('plupload_default_settings', $defaults); |
|
| 2660 | 2660 | |
| 2661 | 2661 | $params = array( |
| 2662 | 2662 | 'action' => 'upload-attachment', |
@@ -2669,8 +2669,8 @@ discard block |
||
| 2669 | 2669 | * |
| 2670 | 2670 | * @param array $params Default Plupload parameters array. |
| 2671 | 2671 | */ |
| 2672 | - $params = apply_filters( 'plupload_default_params', $params ); |
|
| 2673 | - $params['_wpnonce'] = wp_create_nonce( 'media-form' ); |
|
| 2672 | + $params = apply_filters('plupload_default_params', $params); |
|
| 2673 | + $params['_wpnonce'] = wp_create_nonce('media-form'); |
|
| 2674 | 2674 | $defaults['multipart_params'] = $params; |
| 2675 | 2675 | |
| 2676 | 2676 | $settings = array( |
@@ -2682,12 +2682,12 @@ discard block |
||
| 2682 | 2682 | 'limitExceeded' => is_multisite() && ! is_upload_space_available() |
| 2683 | 2683 | ); |
| 2684 | 2684 | |
| 2685 | - $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';'; |
|
| 2685 | + $script = 'var _wpPluploadSettings = '.wp_json_encode($settings).';'; |
|
| 2686 | 2686 | |
| 2687 | - if ( $data ) |
|
| 2687 | + if ($data) |
|
| 2688 | 2688 | $script = "$data\n$script"; |
| 2689 | 2689 | |
| 2690 | - $wp_scripts->add_data( 'wp-plupload', 'data', $script ); |
|
| 2690 | + $wp_scripts->add_data('wp-plupload', 'data', $script); |
|
| 2691 | 2691 | } |
| 2692 | 2692 | |
| 2693 | 2693 | /** |
@@ -2699,42 +2699,42 @@ discard block |
||
| 2699 | 2699 | * @param mixed $attachment Attachment ID or object. |
| 2700 | 2700 | * @return array|void Array of attachment details. |
| 2701 | 2701 | */ |
| 2702 | -function wp_prepare_attachment_for_js( $attachment ) { |
|
| 2703 | - if ( ! $attachment = get_post( $attachment ) ) |
|
| 2702 | +function wp_prepare_attachment_for_js($attachment) { |
|
| 2703 | + if ( ! $attachment = get_post($attachment)) |
|
| 2704 | 2704 | return; |
| 2705 | 2705 | |
| 2706 | - if ( 'attachment' != $attachment->post_type ) |
|
| 2706 | + if ('attachment' != $attachment->post_type) |
|
| 2707 | 2707 | return; |
| 2708 | 2708 | |
| 2709 | - $meta = wp_get_attachment_metadata( $attachment->ID ); |
|
| 2710 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) |
|
| 2711 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 2709 | + $meta = wp_get_attachment_metadata($attachment->ID); |
|
| 2710 | + if (false !== strpos($attachment->post_mime_type, '/')) |
|
| 2711 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
| 2712 | 2712 | else |
| 2713 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 2713 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
| 2714 | 2714 | |
| 2715 | - $attachment_url = wp_get_attachment_url( $attachment->ID ); |
|
| 2715 | + $attachment_url = wp_get_attachment_url($attachment->ID); |
|
| 2716 | 2716 | |
| 2717 | 2717 | $response = array( |
| 2718 | 2718 | 'id' => $attachment->ID, |
| 2719 | 2719 | 'title' => $attachment->post_title, |
| 2720 | - 'filename' => wp_basename( get_attached_file( $attachment->ID ) ), |
|
| 2720 | + 'filename' => wp_basename(get_attached_file($attachment->ID)), |
|
| 2721 | 2721 | 'url' => $attachment_url, |
| 2722 | - 'link' => get_attachment_link( $attachment->ID ), |
|
| 2723 | - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), |
|
| 2722 | + 'link' => get_attachment_link($attachment->ID), |
|
| 2723 | + 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), |
|
| 2724 | 2724 | 'author' => $attachment->post_author, |
| 2725 | 2725 | 'description' => $attachment->post_content, |
| 2726 | 2726 | 'caption' => $attachment->post_excerpt, |
| 2727 | 2727 | 'name' => $attachment->post_name, |
| 2728 | 2728 | 'status' => $attachment->post_status, |
| 2729 | 2729 | 'uploadedTo' => $attachment->post_parent, |
| 2730 | - 'date' => strtotime( $attachment->post_date_gmt ) * 1000, |
|
| 2731 | - 'modified' => strtotime( $attachment->post_modified_gmt ) * 1000, |
|
| 2730 | + 'date' => strtotime($attachment->post_date_gmt) * 1000, |
|
| 2731 | + 'modified' => strtotime($attachment->post_modified_gmt) * 1000, |
|
| 2732 | 2732 | 'menuOrder' => $attachment->menu_order, |
| 2733 | 2733 | 'mime' => $attachment->post_mime_type, |
| 2734 | 2734 | 'type' => $type, |
| 2735 | 2735 | 'subtype' => $subtype, |
| 2736 | - 'icon' => wp_mime_type_icon( $attachment->ID ), |
|
| 2737 | - 'dateFormatted' => mysql2date( get_option('date_format'), $attachment->post_date ), |
|
| 2736 | + 'icon' => wp_mime_type_icon($attachment->ID), |
|
| 2737 | + 'dateFormatted' => mysql2date(get_option('date_format'), $attachment->post_date), |
|
| 2738 | 2738 | 'nonces' => array( |
| 2739 | 2739 | 'update' => false, |
| 2740 | 2740 | 'delete' => false, |
@@ -2744,133 +2744,133 @@ discard block |
||
| 2744 | 2744 | 'meta' => false, |
| 2745 | 2745 | ); |
| 2746 | 2746 | |
| 2747 | - $author = new WP_User( $attachment->post_author ); |
|
| 2747 | + $author = new WP_User($attachment->post_author); |
|
| 2748 | 2748 | $response['authorName'] = $author->display_name; |
| 2749 | 2749 | |
| 2750 | - if ( $attachment->post_parent ) { |
|
| 2751 | - $post_parent = get_post( $attachment->post_parent ); |
|
| 2750 | + if ($attachment->post_parent) { |
|
| 2751 | + $post_parent = get_post($attachment->post_parent); |
|
| 2752 | 2752 | } else { |
| 2753 | 2753 | $post_parent = false; |
| 2754 | 2754 | } |
| 2755 | 2755 | |
| 2756 | - if ( $post_parent ) { |
|
| 2757 | - $parent_type = get_post_type_object( $post_parent->post_type ); |
|
| 2758 | - if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) { |
|
| 2759 | - $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' ); |
|
| 2756 | + if ($post_parent) { |
|
| 2757 | + $parent_type = get_post_type_object($post_parent->post_type); |
|
| 2758 | + if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $attachment->post_parent)) { |
|
| 2759 | + $response['uploadedToLink'] = get_edit_post_link($attachment->post_parent, 'raw'); |
|
| 2760 | 2760 | } |
| 2761 | - $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' ); |
|
| 2761 | + $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __('(no title)'); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | |
| 2764 | - $attached_file = get_attached_file( $attachment->ID ); |
|
| 2765 | - if ( file_exists( $attached_file ) ) { |
|
| 2766 | - $bytes = filesize( $attached_file ); |
|
| 2764 | + $attached_file = get_attached_file($attachment->ID); |
|
| 2765 | + if (file_exists($attached_file)) { |
|
| 2766 | + $bytes = filesize($attached_file); |
|
| 2767 | 2767 | $response['filesizeInBytes'] = $bytes; |
| 2768 | - $response['filesizeHumanReadable'] = size_format( $bytes ); |
|
| 2768 | + $response['filesizeHumanReadable'] = size_format($bytes); |
|
| 2769 | 2769 | } |
| 2770 | 2770 | |
| 2771 | - if ( current_user_can( 'edit_post', $attachment->ID ) ) { |
|
| 2772 | - $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID ); |
|
| 2773 | - $response['nonces']['edit'] = wp_create_nonce( 'image_editor-' . $attachment->ID ); |
|
| 2774 | - $response['editLink'] = get_edit_post_link( $attachment->ID, 'raw' ); |
|
| 2771 | + if (current_user_can('edit_post', $attachment->ID)) { |
|
| 2772 | + $response['nonces']['update'] = wp_create_nonce('update-post_'.$attachment->ID); |
|
| 2773 | + $response['nonces']['edit'] = wp_create_nonce('image_editor-'.$attachment->ID); |
|
| 2774 | + $response['editLink'] = get_edit_post_link($attachment->ID, 'raw'); |
|
| 2775 | 2775 | } |
| 2776 | 2776 | |
| 2777 | - if ( current_user_can( 'delete_post', $attachment->ID ) ) |
|
| 2778 | - $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID ); |
|
| 2777 | + if (current_user_can('delete_post', $attachment->ID)) |
|
| 2778 | + $response['nonces']['delete'] = wp_create_nonce('delete-post_'.$attachment->ID); |
|
| 2779 | 2779 | |
| 2780 | - if ( $meta && 'image' === $type ) { |
|
| 2780 | + if ($meta && 'image' === $type) { |
|
| 2781 | 2781 | $sizes = array(); |
| 2782 | 2782 | |
| 2783 | 2783 | /** This filter is documented in wp-admin/includes/media.php */ |
| 2784 | - $possible_sizes = apply_filters( 'image_size_names_choose', array( |
|
| 2784 | + $possible_sizes = apply_filters('image_size_names_choose', array( |
|
| 2785 | 2785 | 'thumbnail' => __('Thumbnail'), |
| 2786 | 2786 | 'medium' => __('Medium'), |
| 2787 | 2787 | 'large' => __('Large'), |
| 2788 | 2788 | 'full' => __('Full Size'), |
| 2789 | - ) ); |
|
| 2790 | - unset( $possible_sizes['full'] ); |
|
| 2789 | + )); |
|
| 2790 | + unset($possible_sizes['full']); |
|
| 2791 | 2791 | |
| 2792 | 2792 | // Loop through all potential sizes that may be chosen. Try to do this with some efficiency. |
| 2793 | 2793 | // First: run the image_downsize filter. If it returns something, we can use its data. |
| 2794 | 2794 | // If the filter does not return something, then image_downsize() is just an expensive |
| 2795 | 2795 | // way to check the image metadata, which we do second. |
| 2796 | - foreach ( $possible_sizes as $size => $label ) { |
|
| 2796 | + foreach ($possible_sizes as $size => $label) { |
|
| 2797 | 2797 | |
| 2798 | 2798 | /** This filter is documented in wp-includes/media.php */ |
| 2799 | - if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) { |
|
| 2800 | - if ( ! $downsize[3] ) |
|
| 2799 | + if ($downsize = apply_filters('image_downsize', false, $attachment->ID, $size)) { |
|
| 2800 | + if ( ! $downsize[3]) |
|
| 2801 | 2801 | continue; |
| 2802 | - $sizes[ $size ] = array( |
|
| 2802 | + $sizes[$size] = array( |
|
| 2803 | 2803 | 'height' => $downsize[2], |
| 2804 | 2804 | 'width' => $downsize[1], |
| 2805 | 2805 | 'url' => $downsize[0], |
| 2806 | 2806 | 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape', |
| 2807 | 2807 | ); |
| 2808 | - } elseif ( isset( $meta['sizes'][ $size ] ) ) { |
|
| 2809 | - if ( ! isset( $base_url ) ) |
|
| 2810 | - $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
|
| 2808 | + } elseif (isset($meta['sizes'][$size])) { |
|
| 2809 | + if ( ! isset($base_url)) |
|
| 2810 | + $base_url = str_replace(wp_basename($attachment_url), '', $attachment_url); |
|
| 2811 | 2811 | |
| 2812 | 2812 | // Nothing from the filter, so consult image metadata if we have it. |
| 2813 | - $size_meta = $meta['sizes'][ $size ]; |
|
| 2813 | + $size_meta = $meta['sizes'][$size]; |
|
| 2814 | 2814 | |
| 2815 | 2815 | // We have the actual image size, but might need to further constrain it if content_width is narrower. |
| 2816 | 2816 | // Thumbnail, medium, and full sizes are also checked against the site's height/width options. |
| 2817 | - list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); |
|
| 2817 | + list($width, $height) = image_constrain_size_for_editor($size_meta['width'], $size_meta['height'], $size, 'edit'); |
|
| 2818 | 2818 | |
| 2819 | - $sizes[ $size ] = array( |
|
| 2819 | + $sizes[$size] = array( |
|
| 2820 | 2820 | 'height' => $height, |
| 2821 | 2821 | 'width' => $width, |
| 2822 | - 'url' => $base_url . $size_meta['file'], |
|
| 2822 | + 'url' => $base_url.$size_meta['file'], |
|
| 2823 | 2823 | 'orientation' => $height > $width ? 'portrait' : 'landscape', |
| 2824 | 2824 | ); |
| 2825 | 2825 | } |
| 2826 | 2826 | } |
| 2827 | 2827 | |
| 2828 | - $sizes['full'] = array( 'url' => $attachment_url ); |
|
| 2828 | + $sizes['full'] = array('url' => $attachment_url); |
|
| 2829 | 2829 | |
| 2830 | - if ( isset( $meta['height'], $meta['width'] ) ) { |
|
| 2830 | + if (isset($meta['height'], $meta['width'])) { |
|
| 2831 | 2831 | $sizes['full']['height'] = $meta['height']; |
| 2832 | 2832 | $sizes['full']['width'] = $meta['width']; |
| 2833 | 2833 | $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape'; |
| 2834 | 2834 | } |
| 2835 | 2835 | |
| 2836 | - $response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] ); |
|
| 2837 | - } elseif ( $meta && 'video' === $type ) { |
|
| 2838 | - if ( isset( $meta['width'] ) ) |
|
| 2836 | + $response = array_merge($response, array('sizes' => $sizes), $sizes['full']); |
|
| 2837 | + } elseif ($meta && 'video' === $type) { |
|
| 2838 | + if (isset($meta['width'])) |
|
| 2839 | 2839 | $response['width'] = (int) $meta['width']; |
| 2840 | - if ( isset( $meta['height'] ) ) |
|
| 2840 | + if (isset($meta['height'])) |
|
| 2841 | 2841 | $response['height'] = (int) $meta['height']; |
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | - if ( $meta && ( 'audio' === $type || 'video' === $type ) ) { |
|
| 2845 | - if ( isset( $meta['length_formatted'] ) ) |
|
| 2844 | + if ($meta && ('audio' === $type || 'video' === $type)) { |
|
| 2845 | + if (isset($meta['length_formatted'])) |
|
| 2846 | 2846 | $response['fileLength'] = $meta['length_formatted']; |
| 2847 | 2847 | |
| 2848 | 2848 | $response['meta'] = array(); |
| 2849 | - foreach ( wp_get_attachment_id3_keys( $attachment, 'js' ) as $key => $label ) { |
|
| 2850 | - $response['meta'][ $key ] = false; |
|
| 2849 | + foreach (wp_get_attachment_id3_keys($attachment, 'js') as $key => $label) { |
|
| 2850 | + $response['meta'][$key] = false; |
|
| 2851 | 2851 | |
| 2852 | - if ( ! empty( $meta[ $key ] ) ) { |
|
| 2853 | - $response['meta'][ $key ] = $meta[ $key ]; |
|
| 2852 | + if ( ! empty($meta[$key])) { |
|
| 2853 | + $response['meta'][$key] = $meta[$key]; |
|
| 2854 | 2854 | } |
| 2855 | 2855 | } |
| 2856 | 2856 | |
| 2857 | - $id = get_post_thumbnail_id( $attachment->ID ); |
|
| 2858 | - if ( ! empty( $id ) ) { |
|
| 2859 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'full' ); |
|
| 2860 | - $response['image'] = compact( 'src', 'width', 'height' ); |
|
| 2861 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'thumbnail' ); |
|
| 2862 | - $response['thumb'] = compact( 'src', 'width', 'height' ); |
|
| 2857 | + $id = get_post_thumbnail_id($attachment->ID); |
|
| 2858 | + if ( ! empty($id)) { |
|
| 2859 | + list($src, $width, $height) = wp_get_attachment_image_src($id, 'full'); |
|
| 2860 | + $response['image'] = compact('src', 'width', 'height'); |
|
| 2861 | + list($src, $width, $height) = wp_get_attachment_image_src($id, 'thumbnail'); |
|
| 2862 | + $response['thumb'] = compact('src', 'width', 'height'); |
|
| 2863 | 2863 | } else { |
| 2864 | - $src = wp_mime_type_icon( $attachment->ID ); |
|
| 2864 | + $src = wp_mime_type_icon($attachment->ID); |
|
| 2865 | 2865 | $width = 48; |
| 2866 | 2866 | $height = 64; |
| 2867 | - $response['image'] = compact( 'src', 'width', 'height' ); |
|
| 2868 | - $response['thumb'] = compact( 'src', 'width', 'height' ); |
|
| 2867 | + $response['image'] = compact('src', 'width', 'height'); |
|
| 2868 | + $response['thumb'] = compact('src', 'width', 'height'); |
|
| 2869 | 2869 | } |
| 2870 | 2870 | } |
| 2871 | 2871 | |
| 2872 | - if ( function_exists('get_compat_media_markup') ) |
|
| 2873 | - $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) ); |
|
| 2872 | + if (function_exists('get_compat_media_markup')) |
|
| 2873 | + $response['compat'] = get_compat_media_markup($attachment->ID, array('in_modal' => true)); |
|
| 2874 | 2874 | |
| 2875 | 2875 | /** |
| 2876 | 2876 | * Filter the attachment data prepared for JavaScript. |
@@ -2881,7 +2881,7 @@ discard block |
||
| 2881 | 2881 | * @param int|object $attachment Attachment ID or object. |
| 2882 | 2882 | * @param array $meta Array of attachment meta data. |
| 2883 | 2883 | */ |
| 2884 | - return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta ); |
|
| 2884 | + return apply_filters('wp_prepare_attachment_for_js', $response, $attachment, $meta); |
|
| 2885 | 2885 | } |
| 2886 | 2886 | |
| 2887 | 2887 | /** |
@@ -2900,9 +2900,9 @@ discard block |
||
| 2900 | 2900 | * @type int|WP_Post A post object or ID. |
| 2901 | 2901 | * } |
| 2902 | 2902 | */ |
| 2903 | -function wp_enqueue_media( $args = array() ) { |
|
| 2903 | +function wp_enqueue_media($args = array()) { |
|
| 2904 | 2904 | // Enqueue me just once per page, please. |
| 2905 | - if ( did_action( 'wp_enqueue_media' ) ) |
|
| 2905 | + if (did_action('wp_enqueue_media')) |
|
| 2906 | 2906 | return; |
| 2907 | 2907 | |
| 2908 | 2908 | global $content_width, $wpdb, $wp_locale; |
@@ -2910,7 +2910,7 @@ discard block |
||
| 2910 | 2910 | $defaults = array( |
| 2911 | 2911 | 'post' => null, |
| 2912 | 2912 | ); |
| 2913 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2913 | + $args = wp_parse_args($args, $defaults); |
|
| 2914 | 2914 | |
| 2915 | 2915 | // We're going to pass the old thickbox media tabs to `media_upload_tabs` |
| 2916 | 2916 | // to ensure plugins will work. We will then unset those tabs. |
@@ -2923,67 +2923,67 @@ discard block |
||
| 2923 | 2923 | ); |
| 2924 | 2924 | |
| 2925 | 2925 | /** This filter is documented in wp-admin/includes/media.php */ |
| 2926 | - $tabs = apply_filters( 'media_upload_tabs', $tabs ); |
|
| 2927 | - unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] ); |
|
| 2926 | + $tabs = apply_filters('media_upload_tabs', $tabs); |
|
| 2927 | + unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']); |
|
| 2928 | 2928 | |
| 2929 | 2929 | $props = array( |
| 2930 | - 'link' => get_option( 'image_default_link_type' ), // db default is 'file' |
|
| 2931 | - 'align' => get_option( 'image_default_align' ), // empty default |
|
| 2932 | - 'size' => get_option( 'image_default_size' ), // empty default |
|
| 2930 | + 'link' => get_option('image_default_link_type'), // db default is 'file' |
|
| 2931 | + 'align' => get_option('image_default_align'), // empty default |
|
| 2932 | + 'size' => get_option('image_default_size'), // empty default |
|
| 2933 | 2933 | ); |
| 2934 | 2934 | |
| 2935 | - $exts = array_merge( wp_get_audio_extensions(), wp_get_video_extensions() ); |
|
| 2935 | + $exts = array_merge(wp_get_audio_extensions(), wp_get_video_extensions()); |
|
| 2936 | 2936 | $mimes = get_allowed_mime_types(); |
| 2937 | 2937 | $ext_mimes = array(); |
| 2938 | - foreach ( $exts as $ext ) { |
|
| 2939 | - foreach ( $mimes as $ext_preg => $mime_match ) { |
|
| 2940 | - if ( preg_match( '#' . $ext . '#i', $ext_preg ) ) { |
|
| 2941 | - $ext_mimes[ $ext ] = $mime_match; |
|
| 2938 | + foreach ($exts as $ext) { |
|
| 2939 | + foreach ($mimes as $ext_preg => $mime_match) { |
|
| 2940 | + if (preg_match('#'.$ext.'#i', $ext_preg)) { |
|
| 2941 | + $ext_mimes[$ext] = $mime_match; |
|
| 2942 | 2942 | break; |
| 2943 | 2943 | } |
| 2944 | 2944 | } |
| 2945 | 2945 | } |
| 2946 | 2946 | |
| 2947 | - $has_audio = $wpdb->get_var( " |
|
| 2947 | + $has_audio = $wpdb->get_var(" |
|
| 2948 | 2948 | SELECT ID |
| 2949 | 2949 | FROM $wpdb->posts |
| 2950 | 2950 | WHERE post_type = 'attachment' |
| 2951 | 2951 | AND post_mime_type LIKE 'audio%' |
| 2952 | 2952 | LIMIT 1 |
| 2953 | - " ); |
|
| 2954 | - $has_video = $wpdb->get_var( " |
|
| 2953 | + "); |
|
| 2954 | + $has_video = $wpdb->get_var(" |
|
| 2955 | 2955 | SELECT ID |
| 2956 | 2956 | FROM $wpdb->posts |
| 2957 | 2957 | WHERE post_type = 'attachment' |
| 2958 | 2958 | AND post_mime_type LIKE 'video%' |
| 2959 | 2959 | LIMIT 1 |
| 2960 | - " ); |
|
| 2961 | - $months = $wpdb->get_results( $wpdb->prepare( " |
|
| 2960 | + "); |
|
| 2961 | + $months = $wpdb->get_results($wpdb->prepare(" |
|
| 2962 | 2962 | SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
| 2963 | 2963 | FROM $wpdb->posts |
| 2964 | 2964 | WHERE post_type = %s |
| 2965 | 2965 | ORDER BY post_date DESC |
| 2966 | - ", 'attachment' ) ); |
|
| 2967 | - foreach ( $months as $month_year ) { |
|
| 2968 | - $month_year->text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month_year->month ), $month_year->year ); |
|
| 2966 | + ", 'attachment')); |
|
| 2967 | + foreach ($months as $month_year) { |
|
| 2968 | + $month_year->text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($month_year->month), $month_year->year); |
|
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | $settings = array( |
| 2972 | 2972 | 'tabs' => $tabs, |
| 2973 | - 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ), |
|
| 2974 | - 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ), |
|
| 2973 | + 'tabUrl' => add_query_arg(array('chromeless' => true), admin_url('media-upload.php')), |
|
| 2974 | + 'mimeTypes' => wp_list_pluck(get_post_mime_types(), 0), |
|
| 2975 | 2975 | /** This filter is documented in wp-admin/includes/media.php */ |
| 2976 | - 'captions' => ! apply_filters( 'disable_captions', '' ), |
|
| 2976 | + 'captions' => ! apply_filters('disable_captions', ''), |
|
| 2977 | 2977 | 'nonce' => array( |
| 2978 | - 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ), |
|
| 2978 | + 'sendToEditor' => wp_create_nonce('media-send-to-editor'), |
|
| 2979 | 2979 | ), |
| 2980 | 2980 | 'post' => array( |
| 2981 | 2981 | 'id' => 0, |
| 2982 | 2982 | ), |
| 2983 | 2983 | 'defaultProps' => $props, |
| 2984 | 2984 | 'attachmentCounts' => array( |
| 2985 | - 'audio' => ( $has_audio ) ? 1 : 0, |
|
| 2986 | - 'video' => ( $has_video ) ? 1 : 0 |
|
| 2985 | + 'audio' => ($has_audio) ? 1 : 0, |
|
| 2986 | + 'video' => ($has_video) ? 1 : 0 |
|
| 2987 | 2987 | ), |
| 2988 | 2988 | 'embedExts' => $exts, |
| 2989 | 2989 | 'embedMimes' => $ext_mimes, |
@@ -2993,156 +2993,156 @@ discard block |
||
| 2993 | 2993 | ); |
| 2994 | 2994 | |
| 2995 | 2995 | $post = null; |
| 2996 | - if ( isset( $args['post'] ) ) { |
|
| 2997 | - $post = get_post( $args['post'] ); |
|
| 2996 | + if (isset($args['post'])) { |
|
| 2997 | + $post = get_post($args['post']); |
|
| 2998 | 2998 | $settings['post'] = array( |
| 2999 | 2999 | 'id' => $post->ID, |
| 3000 | - 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), |
|
| 3000 | + 'nonce' => wp_create_nonce('update-post_'.$post->ID), |
|
| 3001 | 3001 | ); |
| 3002 | 3002 | |
| 3003 | - $thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ); |
|
| 3004 | - if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) { |
|
| 3005 | - if ( wp_attachment_is( 'audio', $post ) ) { |
|
| 3006 | - $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); |
|
| 3007 | - } elseif ( wp_attachment_is( 'video', $post ) ) { |
|
| 3008 | - $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); |
|
| 3003 | + $thumbnail_support = current_theme_supports('post-thumbnails', $post->post_type) && post_type_supports($post->post_type, 'thumbnail'); |
|
| 3004 | + if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type) { |
|
| 3005 | + if (wp_attachment_is('audio', $post)) { |
|
| 3006 | + $thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio'); |
|
| 3007 | + } elseif (wp_attachment_is('video', $post)) { |
|
| 3008 | + $thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video'); |
|
| 3009 | 3009 | } |
| 3010 | 3010 | } |
| 3011 | 3011 | |
| 3012 | - if ( $thumbnail_support ) { |
|
| 3013 | - $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); |
|
| 3012 | + if ($thumbnail_support) { |
|
| 3013 | + $featured_image_id = get_post_meta($post->ID, '_thumbnail_id', true); |
|
| 3014 | 3014 | $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; |
| 3015 | 3015 | } |
| 3016 | 3016 | } |
| 3017 | 3017 | |
| 3018 | - $hier = $post && is_post_type_hierarchical( $post->post_type ); |
|
| 3018 | + $hier = $post && is_post_type_hierarchical($post->post_type); |
|
| 3019 | 3019 | |
| 3020 | - if ( $post ) { |
|
| 3021 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 3020 | + if ($post) { |
|
| 3021 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 3022 | 3022 | } else { |
| 3023 | - $post_type_object = get_post_type_object( 'post' ); |
|
| 3023 | + $post_type_object = get_post_type_object('post'); |
|
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | 3026 | $strings = array( |
| 3027 | 3027 | // Generic |
| 3028 | - 'url' => __( 'URL' ), |
|
| 3029 | - 'addMedia' => __( 'Add Media' ), |
|
| 3030 | - 'search' => __( 'Search' ), |
|
| 3031 | - 'select' => __( 'Select' ), |
|
| 3032 | - 'cancel' => __( 'Cancel' ), |
|
| 3033 | - 'update' => __( 'Update' ), |
|
| 3034 | - 'replace' => __( 'Replace' ), |
|
| 3035 | - 'remove' => __( 'Remove' ), |
|
| 3036 | - 'back' => __( 'Back' ), |
|
| 3028 | + 'url' => __('URL'), |
|
| 3029 | + 'addMedia' => __('Add Media'), |
|
| 3030 | + 'search' => __('Search'), |
|
| 3031 | + 'select' => __('Select'), |
|
| 3032 | + 'cancel' => __('Cancel'), |
|
| 3033 | + 'update' => __('Update'), |
|
| 3034 | + 'replace' => __('Replace'), |
|
| 3035 | + 'remove' => __('Remove'), |
|
| 3036 | + 'back' => __('Back'), |
|
| 3037 | 3037 | /* translators: This is a would-be plural string used in the media manager. |
| 3038 | 3038 | If there is not a word you can use in your language to avoid issues with the |
| 3039 | 3039 | lack of plural support here, turn it into "selected: %d" then translate it. |
| 3040 | 3040 | */ |
| 3041 | - 'selected' => __( '%d selected' ), |
|
| 3042 | - 'dragInfo' => __( 'Drag and drop to reorder media files.' ), |
|
| 3041 | + 'selected' => __('%d selected'), |
|
| 3042 | + 'dragInfo' => __('Drag and drop to reorder media files.'), |
|
| 3043 | 3043 | |
| 3044 | 3044 | // Upload |
| 3045 | - 'uploadFilesTitle' => __( 'Upload Files' ), |
|
| 3046 | - 'uploadImagesTitle' => __( 'Upload Images' ), |
|
| 3045 | + 'uploadFilesTitle' => __('Upload Files'), |
|
| 3046 | + 'uploadImagesTitle' => __('Upload Images'), |
|
| 3047 | 3047 | |
| 3048 | 3048 | // Library |
| 3049 | - 'mediaLibraryTitle' => __( 'Media Library' ), |
|
| 3050 | - 'insertMediaTitle' => __( 'Insert Media' ), |
|
| 3051 | - 'createNewGallery' => __( 'Create a new gallery' ), |
|
| 3052 | - 'createNewPlaylist' => __( 'Create a new playlist' ), |
|
| 3053 | - 'createNewVideoPlaylist' => __( 'Create a new video playlist' ), |
|
| 3054 | - 'returnToLibrary' => __( '← Return to library' ), |
|
| 3055 | - 'allMediaItems' => __( 'All media items' ), |
|
| 3056 | - 'allDates' => __( 'All dates' ), |
|
| 3057 | - 'noItemsFound' => __( 'No items found.' ), |
|
| 3058 | - 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ), |
|
| 3059 | - 'unattached' => __( 'Unattached' ), |
|
| 3060 | - 'trash' => _x( 'Trash', 'noun' ), |
|
| 3061 | - 'uploadedToThisPost' => $hier ? __( 'Uploaded to this page' ) : __( 'Uploaded to this post' ), |
|
| 3062 | - 'warnDelete' => __( "You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete." ), |
|
| 3063 | - 'warnBulkDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), |
|
| 3064 | - 'warnBulkTrash' => __( "You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete." ), |
|
| 3065 | - 'bulkSelect' => __( 'Bulk Select' ), |
|
| 3066 | - 'cancelSelection' => __( 'Cancel Selection' ), |
|
| 3067 | - 'trashSelected' => __( 'Trash Selected' ), |
|
| 3068 | - 'untrashSelected' => __( 'Untrash Selected' ), |
|
| 3069 | - 'deleteSelected' => __( 'Delete Selected' ), |
|
| 3070 | - 'deletePermanently' => __( 'Delete Permanently' ), |
|
| 3071 | - 'apply' => __( 'Apply' ), |
|
| 3072 | - 'filterByDate' => __( 'Filter by date' ), |
|
| 3073 | - 'filterByType' => __( 'Filter by type' ), |
|
| 3074 | - 'searchMediaLabel' => __( 'Search Media' ), |
|
| 3075 | - 'noMedia' => __( 'No media attachments found.' ), |
|
| 3049 | + 'mediaLibraryTitle' => __('Media Library'), |
|
| 3050 | + 'insertMediaTitle' => __('Insert Media'), |
|
| 3051 | + 'createNewGallery' => __('Create a new gallery'), |
|
| 3052 | + 'createNewPlaylist' => __('Create a new playlist'), |
|
| 3053 | + 'createNewVideoPlaylist' => __('Create a new video playlist'), |
|
| 3054 | + 'returnToLibrary' => __('← Return to library'), |
|
| 3055 | + 'allMediaItems' => __('All media items'), |
|
| 3056 | + 'allDates' => __('All dates'), |
|
| 3057 | + 'noItemsFound' => __('No items found.'), |
|
| 3058 | + 'insertIntoPost' => $hier ? __('Insert into page') : __('Insert into post'), |
|
| 3059 | + 'unattached' => __('Unattached'), |
|
| 3060 | + 'trash' => _x('Trash', 'noun'), |
|
| 3061 | + 'uploadedToThisPost' => $hier ? __('Uploaded to this page') : __('Uploaded to this post'), |
|
| 3062 | + 'warnDelete' => __("You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete."), |
|
| 3063 | + 'warnBulkDelete' => __("You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete."), |
|
| 3064 | + 'warnBulkTrash' => __("You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete."), |
|
| 3065 | + 'bulkSelect' => __('Bulk Select'), |
|
| 3066 | + 'cancelSelection' => __('Cancel Selection'), |
|
| 3067 | + 'trashSelected' => __('Trash Selected'), |
|
| 3068 | + 'untrashSelected' => __('Untrash Selected'), |
|
| 3069 | + 'deleteSelected' => __('Delete Selected'), |
|
| 3070 | + 'deletePermanently' => __('Delete Permanently'), |
|
| 3071 | + 'apply' => __('Apply'), |
|
| 3072 | + 'filterByDate' => __('Filter by date'), |
|
| 3073 | + 'filterByType' => __('Filter by type'), |
|
| 3074 | + 'searchMediaLabel' => __('Search Media'), |
|
| 3075 | + 'noMedia' => __('No media attachments found.'), |
|
| 3076 | 3076 | |
| 3077 | 3077 | // Library Details |
| 3078 | - 'attachmentDetails' => __( 'Attachment Details' ), |
|
| 3078 | + 'attachmentDetails' => __('Attachment Details'), |
|
| 3079 | 3079 | |
| 3080 | 3080 | // From URL |
| 3081 | - 'insertFromUrlTitle' => __( 'Insert from URL' ), |
|
| 3081 | + 'insertFromUrlTitle' => __('Insert from URL'), |
|
| 3082 | 3082 | |
| 3083 | 3083 | // Featured Images |
| 3084 | 3084 | 'setFeaturedImageTitle' => $post_type_object->labels->featured_image, |
| 3085 | 3085 | 'setFeaturedImage' => $post_type_object->labels->set_featured_image, |
| 3086 | 3086 | |
| 3087 | 3087 | // Gallery |
| 3088 | - 'createGalleryTitle' => __( 'Create Gallery' ), |
|
| 3089 | - 'editGalleryTitle' => __( 'Edit Gallery' ), |
|
| 3090 | - 'cancelGalleryTitle' => __( '← Cancel Gallery' ), |
|
| 3091 | - 'insertGallery' => __( 'Insert gallery' ), |
|
| 3092 | - 'updateGallery' => __( 'Update gallery' ), |
|
| 3093 | - 'addToGallery' => __( 'Add to gallery' ), |
|
| 3094 | - 'addToGalleryTitle' => __( 'Add to Gallery' ), |
|
| 3095 | - 'reverseOrder' => __( 'Reverse order' ), |
|
| 3088 | + 'createGalleryTitle' => __('Create Gallery'), |
|
| 3089 | + 'editGalleryTitle' => __('Edit Gallery'), |
|
| 3090 | + 'cancelGalleryTitle' => __('← Cancel Gallery'), |
|
| 3091 | + 'insertGallery' => __('Insert gallery'), |
|
| 3092 | + 'updateGallery' => __('Update gallery'), |
|
| 3093 | + 'addToGallery' => __('Add to gallery'), |
|
| 3094 | + 'addToGalleryTitle' => __('Add to Gallery'), |
|
| 3095 | + 'reverseOrder' => __('Reverse order'), |
|
| 3096 | 3096 | |
| 3097 | 3097 | // Edit Image |
| 3098 | - 'imageDetailsTitle' => __( 'Image Details' ), |
|
| 3099 | - 'imageReplaceTitle' => __( 'Replace Image' ), |
|
| 3100 | - 'imageDetailsCancel' => __( 'Cancel Edit' ), |
|
| 3101 | - 'editImage' => __( 'Edit Image' ), |
|
| 3098 | + 'imageDetailsTitle' => __('Image Details'), |
|
| 3099 | + 'imageReplaceTitle' => __('Replace Image'), |
|
| 3100 | + 'imageDetailsCancel' => __('Cancel Edit'), |
|
| 3101 | + 'editImage' => __('Edit Image'), |
|
| 3102 | 3102 | |
| 3103 | 3103 | // Crop Image |
| 3104 | - 'chooseImage' => __( 'Choose Image' ), |
|
| 3105 | - 'selectAndCrop' => __( 'Select and Crop' ), |
|
| 3106 | - 'skipCropping' => __( 'Skip Cropping' ), |
|
| 3107 | - 'cropImage' => __( 'Crop Image' ), |
|
| 3108 | - 'cropYourImage' => __( 'Crop your image' ), |
|
| 3109 | - 'cropping' => __( 'Cropping…' ), |
|
| 3110 | - 'suggestedDimensions' => __( 'Suggested image dimensions:' ), |
|
| 3111 | - 'cropError' => __( 'There has been an error cropping your image.' ), |
|
| 3104 | + 'chooseImage' => __('Choose Image'), |
|
| 3105 | + 'selectAndCrop' => __('Select and Crop'), |
|
| 3106 | + 'skipCropping' => __('Skip Cropping'), |
|
| 3107 | + 'cropImage' => __('Crop Image'), |
|
| 3108 | + 'cropYourImage' => __('Crop your image'), |
|
| 3109 | + 'cropping' => __('Cropping…'), |
|
| 3110 | + 'suggestedDimensions' => __('Suggested image dimensions:'), |
|
| 3111 | + 'cropError' => __('There has been an error cropping your image.'), |
|
| 3112 | 3112 | |
| 3113 | 3113 | // Edit Audio |
| 3114 | - 'audioDetailsTitle' => __( 'Audio Details' ), |
|
| 3115 | - 'audioReplaceTitle' => __( 'Replace Audio' ), |
|
| 3116 | - 'audioAddSourceTitle' => __( 'Add Audio Source' ), |
|
| 3117 | - 'audioDetailsCancel' => __( 'Cancel Edit' ), |
|
| 3114 | + 'audioDetailsTitle' => __('Audio Details'), |
|
| 3115 | + 'audioReplaceTitle' => __('Replace Audio'), |
|
| 3116 | + 'audioAddSourceTitle' => __('Add Audio Source'), |
|
| 3117 | + 'audioDetailsCancel' => __('Cancel Edit'), |
|
| 3118 | 3118 | |
| 3119 | 3119 | // Edit Video |
| 3120 | - 'videoDetailsTitle' => __( 'Video Details' ), |
|
| 3121 | - 'videoReplaceTitle' => __( 'Replace Video' ), |
|
| 3122 | - 'videoAddSourceTitle' => __( 'Add Video Source' ), |
|
| 3123 | - 'videoDetailsCancel' => __( 'Cancel Edit' ), |
|
| 3124 | - 'videoSelectPosterImageTitle' => __( 'Select Poster Image' ), |
|
| 3125 | - 'videoAddTrackTitle' => __( 'Add Subtitles' ), |
|
| 3120 | + 'videoDetailsTitle' => __('Video Details'), |
|
| 3121 | + 'videoReplaceTitle' => __('Replace Video'), |
|
| 3122 | + 'videoAddSourceTitle' => __('Add Video Source'), |
|
| 3123 | + 'videoDetailsCancel' => __('Cancel Edit'), |
|
| 3124 | + 'videoSelectPosterImageTitle' => __('Select Poster Image'), |
|
| 3125 | + 'videoAddTrackTitle' => __('Add Subtitles'), |
|
| 3126 | 3126 | |
| 3127 | 3127 | // Playlist |
| 3128 | - 'playlistDragInfo' => __( 'Drag and drop to reorder tracks.' ), |
|
| 3129 | - 'createPlaylistTitle' => __( 'Create Audio Playlist' ), |
|
| 3130 | - 'editPlaylistTitle' => __( 'Edit Audio Playlist' ), |
|
| 3131 | - 'cancelPlaylistTitle' => __( '← Cancel Audio Playlist' ), |
|
| 3132 | - 'insertPlaylist' => __( 'Insert audio playlist' ), |
|
| 3133 | - 'updatePlaylist' => __( 'Update audio playlist' ), |
|
| 3134 | - 'addToPlaylist' => __( 'Add to audio playlist' ), |
|
| 3135 | - 'addToPlaylistTitle' => __( 'Add to Audio Playlist' ), |
|
| 3128 | + 'playlistDragInfo' => __('Drag and drop to reorder tracks.'), |
|
| 3129 | + 'createPlaylistTitle' => __('Create Audio Playlist'), |
|
| 3130 | + 'editPlaylistTitle' => __('Edit Audio Playlist'), |
|
| 3131 | + 'cancelPlaylistTitle' => __('← Cancel Audio Playlist'), |
|
| 3132 | + 'insertPlaylist' => __('Insert audio playlist'), |
|
| 3133 | + 'updatePlaylist' => __('Update audio playlist'), |
|
| 3134 | + 'addToPlaylist' => __('Add to audio playlist'), |
|
| 3135 | + 'addToPlaylistTitle' => __('Add to Audio Playlist'), |
|
| 3136 | 3136 | |
| 3137 | 3137 | // Video Playlist |
| 3138 | - 'videoPlaylistDragInfo' => __( 'Drag and drop to reorder videos.' ), |
|
| 3139 | - 'createVideoPlaylistTitle' => __( 'Create Video Playlist' ), |
|
| 3140 | - 'editVideoPlaylistTitle' => __( 'Edit Video Playlist' ), |
|
| 3141 | - 'cancelVideoPlaylistTitle' => __( '← Cancel Video Playlist' ), |
|
| 3142 | - 'insertVideoPlaylist' => __( 'Insert video playlist' ), |
|
| 3143 | - 'updateVideoPlaylist' => __( 'Update video playlist' ), |
|
| 3144 | - 'addToVideoPlaylist' => __( 'Add to video playlist' ), |
|
| 3145 | - 'addToVideoPlaylistTitle' => __( 'Add to Video Playlist' ), |
|
| 3138 | + 'videoPlaylistDragInfo' => __('Drag and drop to reorder videos.'), |
|
| 3139 | + 'createVideoPlaylistTitle' => __('Create Video Playlist'), |
|
| 3140 | + 'editVideoPlaylistTitle' => __('Edit Video Playlist'), |
|
| 3141 | + 'cancelVideoPlaylistTitle' => __('← Cancel Video Playlist'), |
|
| 3142 | + 'insertVideoPlaylist' => __('Insert video playlist'), |
|
| 3143 | + 'updateVideoPlaylist' => __('Update video playlist'), |
|
| 3144 | + 'addToVideoPlaylist' => __('Add to video playlist'), |
|
| 3145 | + 'addToVideoPlaylistTitle' => __('Add to Video Playlist'), |
|
| 3146 | 3146 | ); |
| 3147 | 3147 | |
| 3148 | 3148 | /** |
@@ -3153,7 +3153,7 @@ discard block |
||
| 3153 | 3153 | * @param array $settings List of media view settings. |
| 3154 | 3154 | * @param WP_Post $post Post object. |
| 3155 | 3155 | */ |
| 3156 | - $settings = apply_filters( 'media_view_settings', $settings, $post ); |
|
| 3156 | + $settings = apply_filters('media_view_settings', $settings, $post); |
|
| 3157 | 3157 | |
| 3158 | 3158 | /** |
| 3159 | 3159 | * Filter the media view strings. |
@@ -3163,35 +3163,35 @@ discard block |
||
| 3163 | 3163 | * @param array $strings List of media view strings. |
| 3164 | 3164 | * @param WP_Post $post Post object. |
| 3165 | 3165 | */ |
| 3166 | - $strings = apply_filters( 'media_view_strings', $strings, $post ); |
|
| 3166 | + $strings = apply_filters('media_view_strings', $strings, $post); |
|
| 3167 | 3167 | |
| 3168 | 3168 | $strings['settings'] = $settings; |
| 3169 | 3169 | |
| 3170 | 3170 | // Ensure we enqueue media-editor first, that way media-views is |
| 3171 | 3171 | // registered internally before we try to localize it. see #24724. |
| 3172 | - wp_enqueue_script( 'media-editor' ); |
|
| 3173 | - wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); |
|
| 3172 | + wp_enqueue_script('media-editor'); |
|
| 3173 | + wp_localize_script('media-views', '_wpMediaViewsL10n', $strings); |
|
| 3174 | 3174 | |
| 3175 | - wp_enqueue_script( 'media-audiovideo' ); |
|
| 3176 | - wp_enqueue_style( 'media-views' ); |
|
| 3177 | - if ( is_admin() ) { |
|
| 3178 | - wp_enqueue_script( 'mce-view' ); |
|
| 3179 | - wp_enqueue_script( 'image-edit' ); |
|
| 3175 | + wp_enqueue_script('media-audiovideo'); |
|
| 3176 | + wp_enqueue_style('media-views'); |
|
| 3177 | + if (is_admin()) { |
|
| 3178 | + wp_enqueue_script('mce-view'); |
|
| 3179 | + wp_enqueue_script('image-edit'); |
|
| 3180 | 3180 | } |
| 3181 | - wp_enqueue_style( 'imgareaselect' ); |
|
| 3181 | + wp_enqueue_style('imgareaselect'); |
|
| 3182 | 3182 | wp_plupload_default_settings(); |
| 3183 | 3183 | |
| 3184 | - require_once ABSPATH . WPINC . '/media-template.php'; |
|
| 3185 | - add_action( 'admin_footer', 'wp_print_media_templates' ); |
|
| 3186 | - add_action( 'wp_footer', 'wp_print_media_templates' ); |
|
| 3187 | - add_action( 'customize_controls_print_footer_scripts', 'wp_print_media_templates' ); |
|
| 3184 | + require_once ABSPATH.WPINC.'/media-template.php'; |
|
| 3185 | + add_action('admin_footer', 'wp_print_media_templates'); |
|
| 3186 | + add_action('wp_footer', 'wp_print_media_templates'); |
|
| 3187 | + add_action('customize_controls_print_footer_scripts', 'wp_print_media_templates'); |
|
| 3188 | 3188 | |
| 3189 | 3189 | /** |
| 3190 | 3190 | * Fires at the conclusion of wp_enqueue_media(). |
| 3191 | 3191 | * |
| 3192 | 3192 | * @since 3.5.0 |
| 3193 | 3193 | */ |
| 3194 | - do_action( 'wp_enqueue_media' ); |
|
| 3194 | + do_action('wp_enqueue_media'); |
|
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | 3197 | /** |
@@ -3203,8 +3203,8 @@ discard block |
||
| 3203 | 3203 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
| 3204 | 3204 | * @return array Found attachments. |
| 3205 | 3205 | */ |
| 3206 | -function get_attached_media( $type, $post = 0 ) { |
|
| 3207 | - if ( ! $post = get_post( $post ) ) |
|
| 3206 | +function get_attached_media($type, $post = 0) { |
|
| 3207 | + if ( ! $post = get_post($post)) |
|
| 3208 | 3208 | return array(); |
| 3209 | 3209 | |
| 3210 | 3210 | $args = array( |
@@ -3225,9 +3225,9 @@ discard block |
||
| 3225 | 3225 | * @param string $type Mime type of the desired media. |
| 3226 | 3226 | * @param mixed $post Post ID or object. |
| 3227 | 3227 | */ |
| 3228 | - $args = apply_filters( 'get_attached_media_args', $args, $type, $post ); |
|
| 3228 | + $args = apply_filters('get_attached_media_args', $args, $type, $post); |
|
| 3229 | 3229 | |
| 3230 | - $children = get_children( $args ); |
|
| 3230 | + $children = get_children($args); |
|
| 3231 | 3231 | |
| 3232 | 3232 | /** |
| 3233 | 3233 | * Filter the list of media attached to the given post. |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | * @param string $type Mime type of the media desired. |
| 3239 | 3239 | * @param mixed $post Post ID or object. |
| 3240 | 3240 | */ |
| 3241 | - return (array) apply_filters( 'get_attached_media', $children, $type, $post ); |
|
| 3241 | + return (array) apply_filters('get_attached_media', $children, $type, $post); |
|
| 3242 | 3242 | } |
| 3243 | 3243 | |
| 3244 | 3244 | /** |
@@ -3250,7 +3250,7 @@ discard block |
||
| 3250 | 3250 | * @param array $types An array of media types: 'audio', 'video', 'object', 'embed', or 'iframe'. |
| 3251 | 3251 | * @return array A list of found HTML media embeds. |
| 3252 | 3252 | */ |
| 3253 | -function get_media_embedded_in_content( $content, $types = null ) { |
|
| 3253 | +function get_media_embedded_in_content($content, $types = null) { |
|
| 3254 | 3254 | $html = array(); |
| 3255 | 3255 | |
| 3256 | 3256 | /** |
@@ -3261,20 +3261,20 @@ discard block |
||
| 3261 | 3261 | * @param array $allowed_media_types An array of allowed media types. Default media types are |
| 3262 | 3262 | * 'audio', 'video', 'object', 'embed', and 'iframe'. |
| 3263 | 3263 | */ |
| 3264 | - $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe' ) ); |
|
| 3264 | + $allowed_media_types = apply_filters('media_embedded_in_content_allowed_types', array('audio', 'video', 'object', 'embed', 'iframe')); |
|
| 3265 | 3265 | |
| 3266 | - if ( ! empty( $types ) ) { |
|
| 3267 | - if ( ! is_array( $types ) ) { |
|
| 3268 | - $types = array( $types ); |
|
| 3266 | + if ( ! empty($types)) { |
|
| 3267 | + if ( ! is_array($types)) { |
|
| 3268 | + $types = array($types); |
|
| 3269 | 3269 | } |
| 3270 | 3270 | |
| 3271 | - $allowed_media_types = array_intersect( $allowed_media_types, $types ); |
|
| 3271 | + $allowed_media_types = array_intersect($allowed_media_types, $types); |
|
| 3272 | 3272 | } |
| 3273 | 3273 | |
| 3274 | - $tags = implode( '|', $allowed_media_types ); |
|
| 3274 | + $tags = implode('|', $allowed_media_types); |
|
| 3275 | 3275 | |
| 3276 | - if ( preg_match_all( '#<(?P<tag>' . $tags . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) { |
|
| 3277 | - foreach ( $matches[0] as $match ) { |
|
| 3276 | + if (preg_match_all('#<(?P<tag>'.$tags.')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches)) { |
|
| 3277 | + foreach ($matches[0] as $match) { |
|
| 3278 | 3278 | $html[] = $match; |
| 3279 | 3279 | } |
| 3280 | 3280 | } |
@@ -3292,31 +3292,31 @@ discard block |
||
| 3292 | 3292 | * @return array A list of arrays, each containing gallery data and srcs parsed |
| 3293 | 3293 | * from the expanded shortcode. |
| 3294 | 3294 | */ |
| 3295 | -function get_post_galleries( $post, $html = true ) { |
|
| 3296 | - if ( ! $post = get_post( $post ) ) |
|
| 3295 | +function get_post_galleries($post, $html = true) { |
|
| 3296 | + if ( ! $post = get_post($post)) |
|
| 3297 | 3297 | return array(); |
| 3298 | 3298 | |
| 3299 | - if ( ! has_shortcode( $post->post_content, 'gallery' ) ) |
|
| 3299 | + if ( ! has_shortcode($post->post_content, 'gallery')) |
|
| 3300 | 3300 | return array(); |
| 3301 | 3301 | |
| 3302 | 3302 | $galleries = array(); |
| 3303 | - if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) { |
|
| 3304 | - foreach ( $matches as $shortcode ) { |
|
| 3305 | - if ( 'gallery' === $shortcode[2] ) { |
|
| 3303 | + if (preg_match_all('/'.get_shortcode_regex().'/s', $post->post_content, $matches, PREG_SET_ORDER)) { |
|
| 3304 | + foreach ($matches as $shortcode) { |
|
| 3305 | + if ('gallery' === $shortcode[2]) { |
|
| 3306 | 3306 | $srcs = array(); |
| 3307 | 3307 | |
| 3308 | - $gallery = do_shortcode_tag( $shortcode ); |
|
| 3309 | - if ( $html ) { |
|
| 3308 | + $gallery = do_shortcode_tag($shortcode); |
|
| 3309 | + if ($html) { |
|
| 3310 | 3310 | $galleries[] = $gallery; |
| 3311 | 3311 | } else { |
| 3312 | - preg_match_all( '#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER ); |
|
| 3313 | - if ( ! empty( $src ) ) { |
|
| 3314 | - foreach ( $src as $s ) |
|
| 3312 | + preg_match_all('#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER); |
|
| 3313 | + if ( ! empty($src)) { |
|
| 3314 | + foreach ($src as $s) |
|
| 3315 | 3315 | $srcs[] = $s[2]; |
| 3316 | 3316 | } |
| 3317 | 3317 | |
| 3318 | - $data = shortcode_parse_atts( $shortcode[3] ); |
|
| 3319 | - $data['src'] = array_values( array_unique( $srcs ) ); |
|
| 3318 | + $data = shortcode_parse_atts($shortcode[3]); |
|
| 3319 | + $data['src'] = array_values(array_unique($srcs)); |
|
| 3320 | 3320 | $galleries[] = $data; |
| 3321 | 3321 | } |
| 3322 | 3322 | } |
@@ -3331,7 +3331,7 @@ discard block |
||
| 3331 | 3331 | * @param array $galleries Associative array of all found post galleries. |
| 3332 | 3332 | * @param WP_Post $post Post object. |
| 3333 | 3333 | */ |
| 3334 | - return apply_filters( 'get_post_galleries', $galleries, $post ); |
|
| 3334 | + return apply_filters('get_post_galleries', $galleries, $post); |
|
| 3335 | 3335 | } |
| 3336 | 3336 | |
| 3337 | 3337 | /** |
@@ -3343,9 +3343,9 @@ discard block |
||
| 3343 | 3343 | * @param bool $html Optional. Whether to return HTML or data. Default is true. |
| 3344 | 3344 | * @return string|array Gallery data and srcs parsed from the expanded shortcode. |
| 3345 | 3345 | */ |
| 3346 | -function get_post_gallery( $post = 0, $html = true ) { |
|
| 3347 | - $galleries = get_post_galleries( $post, $html ); |
|
| 3348 | - $gallery = reset( $galleries ); |
|
| 3346 | +function get_post_gallery($post = 0, $html = true) { |
|
| 3347 | + $galleries = get_post_galleries($post, $html); |
|
| 3348 | + $gallery = reset($galleries); |
|
| 3349 | 3349 | |
| 3350 | 3350 | /** |
| 3351 | 3351 | * Filter the first-found post gallery. |
@@ -3356,7 +3356,7 @@ discard block |
||
| 3356 | 3356 | * @param int|WP_Post $post Post ID or object. |
| 3357 | 3357 | * @param array $galleries Associative array of all found post galleries. |
| 3358 | 3358 | */ |
| 3359 | - return apply_filters( 'get_post_gallery', $gallery, $post, $galleries ); |
|
| 3359 | + return apply_filters('get_post_gallery', $gallery, $post, $galleries); |
|
| 3360 | 3360 | } |
| 3361 | 3361 | |
| 3362 | 3362 | /** |
@@ -3370,9 +3370,9 @@ discard block |
||
| 3370 | 3370 | * @return array A list of lists, each containing image srcs parsed. |
| 3371 | 3371 | * from an expanded shortcode |
| 3372 | 3372 | */ |
| 3373 | -function get_post_galleries_images( $post = 0 ) { |
|
| 3374 | - $galleries = get_post_galleries( $post, false ); |
|
| 3375 | - return wp_list_pluck( $galleries, 'src' ); |
|
| 3373 | +function get_post_galleries_images($post = 0) { |
|
| 3374 | + $galleries = get_post_galleries($post, false); |
|
| 3375 | + return wp_list_pluck($galleries, 'src'); |
|
| 3376 | 3376 | } |
| 3377 | 3377 | |
| 3378 | 3378 | /** |
@@ -3385,9 +3385,9 @@ discard block |
||
| 3385 | 3385 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. |
| 3386 | 3386 | * @return array A list of a gallery's image srcs in order. |
| 3387 | 3387 | */ |
| 3388 | -function get_post_gallery_images( $post = 0 ) { |
|
| 3389 | - $gallery = get_post_gallery( $post, false ); |
|
| 3390 | - return empty( $gallery['src'] ) ? array() : $gallery['src']; |
|
| 3388 | +function get_post_gallery_images($post = 0) { |
|
| 3389 | + $gallery = get_post_gallery($post, false); |
|
| 3390 | + return empty($gallery['src']) ? array() : $gallery['src']; |
|
| 3391 | 3391 | } |
| 3392 | 3392 | |
| 3393 | 3393 | /** |
@@ -3397,20 +3397,20 @@ discard block |
||
| 3397 | 3397 | * |
| 3398 | 3398 | * @param WP_Post $attachment Attachment object. |
| 3399 | 3399 | */ |
| 3400 | -function wp_maybe_generate_attachment_metadata( $attachment ) { |
|
| 3401 | - if ( empty( $attachment ) || ( empty( $attachment->ID ) || ! $attachment_id = (int) $attachment->ID ) ) { |
|
| 3400 | +function wp_maybe_generate_attachment_metadata($attachment) { |
|
| 3401 | + if (empty($attachment) || (empty($attachment->ID) || ! $attachment_id = (int) $attachment->ID)) { |
|
| 3402 | 3402 | return; |
| 3403 | 3403 | } |
| 3404 | 3404 | |
| 3405 | - $file = get_attached_file( $attachment_id ); |
|
| 3406 | - $meta = wp_get_attachment_metadata( $attachment_id ); |
|
| 3407 | - if ( empty( $meta ) && file_exists( $file ) ) { |
|
| 3408 | - $_meta = get_post_meta( $attachment_id ); |
|
| 3409 | - $regeneration_lock = 'wp_generating_att_' . $attachment_id; |
|
| 3410 | - if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) && ! get_transient( $regeneration_lock ) ) { |
|
| 3411 | - set_transient( $regeneration_lock, $file ); |
|
| 3412 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
| 3413 | - delete_transient( $regeneration_lock ); |
|
| 3405 | + $file = get_attached_file($attachment_id); |
|
| 3406 | + $meta = wp_get_attachment_metadata($attachment_id); |
|
| 3407 | + if (empty($meta) && file_exists($file)) { |
|
| 3408 | + $_meta = get_post_meta($attachment_id); |
|
| 3409 | + $regeneration_lock = 'wp_generating_att_'.$attachment_id; |
|
| 3410 | + if ( ! array_key_exists('_wp_attachment_metadata', $_meta) && ! get_transient($regeneration_lock)) { |
|
| 3411 | + set_transient($regeneration_lock, $file); |
|
| 3412 | + wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file)); |
|
| 3413 | + delete_transient($regeneration_lock); |
|
| 3414 | 3414 | } |
| 3415 | 3415 | } |
| 3416 | 3416 | } |
@@ -3425,21 +3425,21 @@ discard block |
||
| 3425 | 3425 | * @param string $url The URL to resolve. |
| 3426 | 3426 | * @return int The found post ID, or 0 on failure. |
| 3427 | 3427 | */ |
| 3428 | -function attachment_url_to_postid( $url ) { |
|
| 3428 | +function attachment_url_to_postid($url) { |
|
| 3429 | 3429 | global $wpdb; |
| 3430 | 3430 | |
| 3431 | 3431 | $dir = wp_upload_dir(); |
| 3432 | 3432 | $path = $url; |
| 3433 | 3433 | |
| 3434 | - if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) { |
|
| 3435 | - $path = substr( $path, strlen( $dir['baseurl'] . '/' ) ); |
|
| 3434 | + if (0 === strpos($path, $dir['baseurl'].'/')) { |
|
| 3435 | + $path = substr($path, strlen($dir['baseurl'].'/')); |
|
| 3436 | 3436 | } |
| 3437 | 3437 | |
| 3438 | 3438 | $sql = $wpdb->prepare( |
| 3439 | 3439 | "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s", |
| 3440 | 3440 | $path |
| 3441 | 3441 | ); |
| 3442 | - $post_id = $wpdb->get_var( $sql ); |
|
| 3442 | + $post_id = $wpdb->get_var($sql); |
|
| 3443 | 3443 | |
| 3444 | 3444 | /** |
| 3445 | 3445 | * Filter an attachment id found by URL. |
@@ -3449,7 +3449,7 @@ discard block |
||
| 3449 | 3449 | * @param int|null $post_id The post_id (if any) found by the function. |
| 3450 | 3450 | * @param string $url The URL being looked up. |
| 3451 | 3451 | */ |
| 3452 | - $post_id = apply_filters( 'attachment_url_to_postid', $post_id, $url ); |
|
| 3452 | + $post_id = apply_filters('attachment_url_to_postid', $post_id, $url); |
|
| 3453 | 3453 | |
| 3454 | 3454 | return (int) $post_id; |
| 3455 | 3455 | } |
@@ -3464,9 +3464,9 @@ discard block |
||
| 3464 | 3464 | * @return array The relevant CSS file URLs. |
| 3465 | 3465 | */ |
| 3466 | 3466 | function wpview_media_sandbox_styles() { |
| 3467 | - $version = 'ver=' . $GLOBALS['wp_version']; |
|
| 3468 | - $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" ); |
|
| 3469 | - $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" ); |
|
| 3467 | + $version = 'ver='.$GLOBALS['wp_version']; |
|
| 3468 | + $mediaelement = includes_url("js/mediaelement/mediaelementplayer.min.css?$version"); |
|
| 3469 | + $wpmediaelement = includes_url("js/mediaelement/wp-mediaelement.css?$version"); |
|
| 3470 | 3470 | |
| 3471 | - return array( $mediaelement, $wpmediaelement ); |
|
| 3471 | + return array($mediaelement, $wpmediaelement); |
|
| 3472 | 3472 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | function image_constrain_size_for_editor( $width, $height, $size = 'medium', $context = null ) { |
| 41 | 41 | global $content_width, $_wp_additional_image_sizes; |
| 42 | 42 | |
| 43 | - if ( ! $context ) |
|
| 44 | - $context = is_admin() ? 'edit' : 'display'; |
|
| 43 | + if ( ! $context ) { |
|
| 44 | + $context = is_admin() ? 'edit' : 'display'; |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | if ( is_array($size) ) { |
| 47 | 48 | $max_width = $size[0]; |
| 48 | 49 | $max_height = $size[1]; |
| 49 | - } |
|
| 50 | - elseif ( $size == 'thumb' || $size == 'thumbnail' ) { |
|
| 50 | + } elseif ( $size == 'thumb' || $size == 'thumbnail' ) { |
|
| 51 | 51 | $max_width = intval(get_option('thumbnail_size_w')); |
| 52 | 52 | $max_height = intval(get_option('thumbnail_size_h')); |
| 53 | 53 | // last chance thumbnail size defaults |
@@ -55,13 +55,11 @@ discard block |
||
| 55 | 55 | $max_width = 128; |
| 56 | 56 | $max_height = 96; |
| 57 | 57 | } |
| 58 | - } |
|
| 59 | - elseif ( $size == 'medium' ) { |
|
| 58 | + } elseif ( $size == 'medium' ) { |
|
| 60 | 59 | $max_width = intval(get_option('medium_size_w')); |
| 61 | 60 | $max_height = intval(get_option('medium_size_h')); |
| 62 | 61 | // if no width is set, default to the theme content width if available |
| 63 | - } |
|
| 64 | - elseif ( $size == 'large' ) { |
|
| 62 | + } elseif ( $size == 'large' ) { |
|
| 65 | 63 | /* |
| 66 | 64 | * We're inserting a large size image into the editor. If it's a really |
| 67 | 65 | * big image we'll scale it down to fit reasonably within the editor |
@@ -70,13 +68,16 @@ discard block |
||
| 70 | 68 | */ |
| 71 | 69 | $max_width = intval(get_option('large_size_w')); |
| 72 | 70 | $max_height = intval(get_option('large_size_h')); |
| 73 | - if ( intval($content_width) > 0 ) |
|
| 74 | - $max_width = min( intval($content_width), $max_width ); |
|
| 71 | + if ( intval($content_width) > 0 ) { |
|
| 72 | + $max_width = min( intval($content_width), $max_width ); |
|
| 73 | + } |
|
| 75 | 74 | } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) { |
| 76 | 75 | $max_width = intval( $_wp_additional_image_sizes[$size]['width'] ); |
| 77 | 76 | $max_height = intval( $_wp_additional_image_sizes[$size]['height'] ); |
| 78 | - if ( intval($content_width) > 0 && 'edit' == $context ) // Only in admin. Assume that theme authors know what they're doing. |
|
| 77 | + if ( intval($content_width) > 0 && 'edit' == $context ) { |
|
| 78 | + // Only in admin. Assume that theme authors know what they're doing. |
|
| 79 | 79 | $max_width = min( intval($content_width), $max_width ); |
| 80 | + } |
|
| 80 | 81 | } |
| 81 | 82 | // $size == 'full' has no constraint |
| 82 | 83 | else { |
@@ -120,10 +121,12 @@ discard block |
||
| 120 | 121 | */ |
| 121 | 122 | function image_hwstring( $width, $height ) { |
| 122 | 123 | $out = ''; |
| 123 | - if ($width) |
|
| 124 | - $out .= 'width="'.intval($width).'" '; |
|
| 125 | - if ($height) |
|
| 126 | - $out .= 'height="'.intval($height).'" '; |
|
| 124 | + if ($width) { |
|
| 125 | + $out .= 'width="'.intval($width).'" '; |
|
| 126 | + } |
|
| 127 | + if ($height) { |
|
| 128 | + $out .= 'height="'.intval($height).'" '; |
|
| 129 | + } |
|
| 127 | 130 | return $out; |
| 128 | 131 | } |
| 129 | 132 | |
@@ -152,8 +155,9 @@ discard block |
||
| 152 | 155 | */ |
| 153 | 156 | function image_downsize( $id, $size = 'medium' ) { |
| 154 | 157 | |
| 155 | - if ( !wp_attachment_is_image($id) ) |
|
| 156 | - return false; |
|
| 158 | + if ( !wp_attachment_is_image($id) ) { |
|
| 159 | + return false; |
|
| 160 | + } |
|
| 157 | 161 | |
| 158 | 162 | /** |
| 159 | 163 | * Filter whether to preempt the output of image_downsize(). |
@@ -183,8 +187,7 @@ discard block |
||
| 183 | 187 | $width = $intermediate['width']; |
| 184 | 188 | $height = $intermediate['height']; |
| 185 | 189 | $is_intermediate = true; |
| 186 | - } |
|
| 187 | - elseif ( $size == 'thumbnail' ) { |
|
| 190 | + } elseif ( $size == 'thumbnail' ) { |
|
| 188 | 191 | // fall back to the old thumbnail |
| 189 | 192 | if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) { |
| 190 | 193 | $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url); |
@@ -368,8 +371,9 @@ discard block |
||
| 368 | 371 | * @return array First item is the width, the second item is the height. |
| 369 | 372 | */ |
| 370 | 373 | function wp_constrain_dimensions( $current_width, $current_height, $max_width = 0, $max_height = 0 ) { |
| 371 | - if ( !$max_width && !$max_height ) |
|
| 372 | - return array( $current_width, $current_height ); |
|
| 374 | + if ( !$max_width && !$max_height ) { |
|
| 375 | + return array( $current_width, $current_height ); |
|
| 376 | + } |
|
| 373 | 377 | |
| 374 | 378 | $width_ratio = $height_ratio = 1.0; |
| 375 | 379 | $did_width = $did_height = false; |
@@ -454,11 +458,13 @@ discard block |
||
| 454 | 458 | */ |
| 455 | 459 | function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) { |
| 456 | 460 | |
| 457 | - if ($orig_w <= 0 || $orig_h <= 0) |
|
| 458 | - return false; |
|
| 461 | + if ($orig_w <= 0 || $orig_h <= 0) { |
|
| 462 | + return false; |
|
| 463 | + } |
|
| 459 | 464 | // at least one of dest_w or dest_h must be specific |
| 460 | - if ($dest_w <= 0 && $dest_h <= 0) |
|
| 461 | - return false; |
|
| 465 | + if ($dest_w <= 0 && $dest_h <= 0) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 462 | 468 | |
| 463 | 469 | /** |
| 464 | 470 | * Filter whether to preempt calculating the image resize dimensions. |
@@ -477,8 +483,9 @@ discard block |
||
| 477 | 483 | * An array can specify positioning of the crop area. Default false. |
| 478 | 484 | */ |
| 479 | 485 | $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop ); |
| 480 | - if ( null !== $output ) |
|
| 481 | - return $output; |
|
| 486 | + if ( null !== $output ) { |
|
| 487 | + return $output; |
|
| 488 | + } |
|
| 482 | 489 | |
| 483 | 490 | if ( $crop ) { |
| 484 | 491 | // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h |
@@ -562,8 +569,9 @@ discard block |
||
| 562 | 569 | if ( $width || $height ) { |
| 563 | 570 | $editor = wp_get_image_editor( $file ); |
| 564 | 571 | |
| 565 | - if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) |
|
| 566 | - return false; |
|
| 572 | + if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) { |
|
| 573 | + return false; |
|
| 574 | + } |
|
| 567 | 575 | |
| 568 | 576 | $resized_file = $editor->save(); |
| 569 | 577 | |
@@ -602,8 +610,9 @@ discard block |
||
| 602 | 610 | * @return false|array False on failure or array of file path, width, and height on success. |
| 603 | 611 | */ |
| 604 | 612 | function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) { |
| 605 | - if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) ) |
|
| 606 | - return false; |
|
| 613 | + if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) ) { |
|
| 614 | + return false; |
|
| 615 | + } |
|
| 607 | 616 | |
| 608 | 617 | // get the best one for a specified set of dimensions |
| 609 | 618 | if ( is_array($size) && !empty($imagedata['sizes']) ) { |
@@ -629,8 +638,9 @@ discard block |
||
| 629 | 638 | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| 630 | 639 | $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
| 631 | 640 | // If the size doesn't match within one pixel, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size |
| 632 | - if ( 'thumbnail' != $_size && ( !$maybe_cropped || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) ) ) |
|
| 633 | - continue; |
|
| 641 | + if ( 'thumbnail' != $_size && ( !$maybe_cropped || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) ) ) { |
|
| 642 | + continue; |
|
| 643 | + } |
|
| 634 | 644 | // If we're still here, then we're going to use this size |
| 635 | 645 | $file = $data['file']; |
| 636 | 646 | list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
@@ -640,8 +650,9 @@ discard block |
||
| 640 | 650 | } |
| 641 | 651 | } |
| 642 | 652 | |
| 643 | - if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) |
|
| 644 | - return false; |
|
| 653 | + if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) { |
|
| 654 | + return false; |
|
| 655 | + } |
|
| 645 | 656 | |
| 646 | 657 | $data = $imagedata['sizes'][$size]; |
| 647 | 658 | // include the full filesystem path of the intermediate file |
@@ -665,8 +676,9 @@ discard block |
||
| 665 | 676 | function get_intermediate_image_sizes() { |
| 666 | 677 | global $_wp_additional_image_sizes; |
| 667 | 678 | $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes |
| 668 | - if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) |
|
| 669 | - $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) ); |
|
| 679 | + if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { |
|
| 680 | + $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) ); |
|
| 681 | + } |
|
| 670 | 682 | |
| 671 | 683 | /** |
| 672 | 684 | * Filter the list of intermediate image sizes. |
@@ -757,10 +769,14 @@ discard block |
||
| 757 | 769 | 'class' => "attachment-$size_class", |
| 758 | 770 | 'alt' => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first |
| 759 | 771 | ); |
| 760 | - if ( empty($default_attr['alt']) ) |
|
| 761 | - $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption |
|
| 762 | - if ( empty($default_attr['alt']) ) |
|
| 763 | - $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title |
|
| 772 | + if ( empty($default_attr['alt']) ) { |
|
| 773 | + $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); |
|
| 774 | + } |
|
| 775 | + // If not, Use the Caption |
|
| 776 | + if ( empty($default_attr['alt']) ) { |
|
| 777 | + $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); |
|
| 778 | + } |
|
| 779 | + // Finally, use the title |
|
| 764 | 780 | |
| 765 | 781 | $attr = wp_parse_args($attr, $default_attr); |
| 766 | 782 | |
@@ -880,8 +896,9 @@ discard block |
||
| 880 | 896 | * @param string $content The image element, possibly wrapped in a hyperlink. |
| 881 | 897 | */ |
| 882 | 898 | $output = apply_filters( 'img_caption_shortcode', '', $attr, $content ); |
| 883 | - if ( $output != '' ) |
|
| 884 | - return $output; |
|
| 899 | + if ( $output != '' ) { |
|
| 900 | + return $output; |
|
| 901 | + } |
|
| 885 | 902 | |
| 886 | 903 | $atts = shortcode_atts( array( |
| 887 | 904 | 'id' => '', |
@@ -892,11 +909,13 @@ discard block |
||
| 892 | 909 | ), $attr, 'caption' ); |
| 893 | 910 | |
| 894 | 911 | $atts['width'] = (int) $atts['width']; |
| 895 | - if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) |
|
| 896 | - return $content; |
|
| 912 | + if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) { |
|
| 913 | + return $content; |
|
| 914 | + } |
|
| 897 | 915 | |
| 898 | - if ( ! empty( $atts['id'] ) ) |
|
| 899 | - $atts['id'] = 'id="' . esc_attr( sanitize_html_class( $atts['id'] ) ) . '" '; |
|
| 916 | + if ( ! empty( $atts['id'] ) ) { |
|
| 917 | + $atts['id'] = 'id="' . esc_attr( sanitize_html_class( $atts['id'] ) ) . '" '; |
|
| 918 | + } |
|
| 900 | 919 | |
| 901 | 920 | $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); |
| 902 | 921 | |
@@ -925,8 +944,9 @@ discard block |
||
| 925 | 944 | $caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content ); |
| 926 | 945 | |
| 927 | 946 | $style = ''; |
| 928 | - if ( $caption_width ) |
|
| 929 | - $style = 'style="width: ' . (int) $caption_width . 'px" '; |
|
| 947 | + if ( $caption_width ) { |
|
| 948 | + $style = 'style="width: ' . (int) $caption_width . 'px" '; |
|
| 949 | + } |
|
| 930 | 950 | |
| 931 | 951 | return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">' |
| 932 | 952 | . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>'; |
@@ -1439,8 +1459,10 @@ discard block |
||
| 1439 | 1459 | echo (int) $theme_width; |
| 1440 | 1460 | ?>"<?php if ( 'video' === $safe_type ): |
| 1441 | 1461 | echo ' height="', (int) $theme_height, '"'; |
| 1442 | - else: |
|
| 1462 | + else { |
|
| 1463 | + : |
|
| 1443 | 1464 | echo ' style="visibility: hidden"'; |
| 1465 | + } |
|
| 1444 | 1466 | endif; ?>></<?php echo $safe_type ?>> |
| 1445 | 1467 | <div class="wp-playlist-next"></div> |
| 1446 | 1468 | <div class="wp-playlist-prev"></div> |
@@ -2058,27 +2080,31 @@ discard block |
||
| 2058 | 2080 | } elseif ( is_array( $attachment ) ) { |
| 2059 | 2081 | $attachment = (object) $attachment; |
| 2060 | 2082 | } |
| 2061 | - if ( ! is_object($attachment) ) |
|
| 2062 | - return array(); |
|
| 2083 | + if ( ! is_object($attachment) ) { |
|
| 2084 | + return array(); |
|
| 2085 | + } |
|
| 2063 | 2086 | |
| 2064 | 2087 | $filename = basename($attachment->guid); |
| 2065 | 2088 | |
| 2066 | 2089 | $objects = array('attachment'); |
| 2067 | 2090 | |
| 2068 | - if ( false !== strpos($filename, '.') ) |
|
| 2069 | - $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); |
|
| 2091 | + if ( false !== strpos($filename, '.') ) { |
|
| 2092 | + $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); |
|
| 2093 | + } |
|
| 2070 | 2094 | if ( !empty($attachment->post_mime_type) ) { |
| 2071 | 2095 | $objects[] = 'attachment:' . $attachment->post_mime_type; |
| 2072 | - if ( false !== strpos($attachment->post_mime_type, '/') ) |
|
| 2073 | - foreach ( explode('/', $attachment->post_mime_type) as $token ) |
|
| 2096 | + if ( false !== strpos($attachment->post_mime_type, '/') ) { |
|
| 2097 | + foreach ( explode('/', $attachment->post_mime_type) as $token ) |
|
| 2074 | 2098 | if ( !empty($token) ) |
| 2075 | 2099 | $objects[] = "attachment:$token"; |
| 2100 | + } |
|
| 2076 | 2101 | } |
| 2077 | 2102 | |
| 2078 | 2103 | $taxonomies = array(); |
| 2079 | - foreach ( $objects as $object ) |
|
| 2080 | - if ( $taxes = get_object_taxonomies($object) ) |
|
| 2104 | + foreach ( $objects as $object ) { |
|
| 2105 | + if ( $taxes = get_object_taxonomies($object) ) |
|
| 2081 | 2106 | $taxonomies = array_merge($taxonomies, $taxes); |
| 2107 | + } |
|
| 2082 | 2108 | |
| 2083 | 2109 | return array_unique($taxonomies); |
| 2084 | 2110 | } |
@@ -2101,10 +2127,11 @@ discard block |
||
| 2101 | 2127 | foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) { |
| 2102 | 2128 | foreach ( $taxonomy->object_type as $object_type ) { |
| 2103 | 2129 | if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) { |
| 2104 | - if ( 'names' == $output ) |
|
| 2105 | - $taxonomies[] = $taxonomy->name; |
|
| 2106 | - else |
|
| 2107 | - $taxonomies[ $taxonomy->name ] = $taxonomy; |
|
| 2130 | + if ( 'names' == $output ) { |
|
| 2131 | + $taxonomies[] = $taxonomy->name; |
|
| 2132 | + } else { |
|
| 2133 | + $taxonomies[ $taxonomy->name ] = $taxonomy; |
|
| 2134 | + } |
|
| 2108 | 2135 | break; |
| 2109 | 2136 | } |
| 2110 | 2137 | } |
@@ -2187,11 +2214,13 @@ discard block |
||
| 2187 | 2214 | * @return array Default embed parameters. |
| 2188 | 2215 | */ |
| 2189 | 2216 | function wp_embed_defaults( $url = '' ) { |
| 2190 | - if ( ! empty( $GLOBALS['content_width'] ) ) |
|
| 2191 | - $width = (int) $GLOBALS['content_width']; |
|
| 2217 | + if ( ! empty( $GLOBALS['content_width'] ) ) { |
|
| 2218 | + $width = (int) $GLOBALS['content_width']; |
|
| 2219 | + } |
|
| 2192 | 2220 | |
| 2193 | - if ( empty( $width ) ) |
|
| 2194 | - $width = 500; |
|
| 2221 | + if ( empty( $width ) ) { |
|
| 2222 | + $width = 500; |
|
| 2223 | + } |
|
| 2195 | 2224 | |
| 2196 | 2225 | $height = min( ceil( $width * 1.5 ), 1000 ); |
| 2197 | 2226 | |
@@ -2486,12 +2515,13 @@ discard block |
||
| 2486 | 2515 | function wp_convert_hr_to_bytes( $size ) { |
| 2487 | 2516 | $size = strtolower( $size ); |
| 2488 | 2517 | $bytes = (int) $size; |
| 2489 | - if ( strpos( $size, 'k' ) !== false ) |
|
| 2490 | - $bytes = intval( $size ) * 1024; |
|
| 2491 | - elseif ( strpos( $size, 'm' ) !== false ) |
|
| 2492 | - $bytes = intval($size) * 1024 * 1024; |
|
| 2493 | - elseif ( strpos( $size, 'g' ) !== false ) |
|
| 2494 | - $bytes = intval( $size ) * 1024 * 1024 * 1024; |
|
| 2518 | + if ( strpos( $size, 'k' ) !== false ) { |
|
| 2519 | + $bytes = intval( $size ) * 1024; |
|
| 2520 | + } elseif ( strpos( $size, 'm' ) !== false ) { |
|
| 2521 | + $bytes = intval($size) * 1024 * 1024; |
|
| 2522 | + } elseif ( strpos( $size, 'g' ) !== false ) { |
|
| 2523 | + $bytes = intval( $size ) * 1024 * 1024 * 1024; |
|
| 2524 | + } |
|
| 2495 | 2525 | return $bytes; |
| 2496 | 2526 | } |
| 2497 | 2527 | |
@@ -2537,8 +2567,9 @@ discard block |
||
| 2537 | 2567 | |
| 2538 | 2568 | // If $file_info['type'] is false, then we let the editor attempt to |
| 2539 | 2569 | // figure out the file type, rather than forcing a failure based on extension. |
| 2540 | - if ( isset( $file_info ) && $file_info['type'] ) |
|
| 2541 | - $args['mime_type'] = $file_info['type']; |
|
| 2570 | + if ( isset( $file_info ) && $file_info['type'] ) { |
|
| 2571 | + $args['mime_type'] = $file_info['type']; |
|
| 2572 | + } |
|
| 2542 | 2573 | } |
| 2543 | 2574 | |
| 2544 | 2575 | $implementation = _wp_image_editor_choose( $args ); |
@@ -2547,8 +2578,9 @@ discard block |
||
| 2547 | 2578 | $editor = new $implementation( $path ); |
| 2548 | 2579 | $loaded = $editor->load(); |
| 2549 | 2580 | |
| 2550 | - if ( is_wp_error( $loaded ) ) |
|
| 2551 | - return $loaded; |
|
| 2581 | + if ( is_wp_error( $loaded ) ) { |
|
| 2582 | + return $loaded; |
|
| 2583 | + } |
|
| 2552 | 2584 | |
| 2553 | 2585 | return $editor; |
| 2554 | 2586 | } |
@@ -2595,8 +2627,9 @@ discard block |
||
| 2595 | 2627 | $implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); |
| 2596 | 2628 | |
| 2597 | 2629 | foreach ( $implementations as $implementation ) { |
| 2598 | - if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) |
|
| 2599 | - continue; |
|
| 2630 | + if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) { |
|
| 2631 | + continue; |
|
| 2632 | + } |
|
| 2600 | 2633 | |
| 2601 | 2634 | if ( isset( $args['mime_type'] ) && |
| 2602 | 2635 | ! call_user_func( |
@@ -2625,8 +2658,9 @@ discard block |
||
| 2625 | 2658 | $wp_scripts = wp_scripts(); |
| 2626 | 2659 | |
| 2627 | 2660 | $data = $wp_scripts->get_data( 'wp-plupload', 'data' ); |
| 2628 | - if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) |
|
| 2629 | - return; |
|
| 2661 | + if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) { |
|
| 2662 | + return; |
|
| 2663 | + } |
|
| 2630 | 2664 | |
| 2631 | 2665 | $max_upload_size = wp_max_upload_size(); |
| 2632 | 2666 | |
@@ -2684,8 +2718,9 @@ discard block |
||
| 2684 | 2718 | |
| 2685 | 2719 | $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';'; |
| 2686 | 2720 | |
| 2687 | - if ( $data ) |
|
| 2688 | - $script = "$data\n$script"; |
|
| 2721 | + if ( $data ) { |
|
| 2722 | + $script = "$data\n$script"; |
|
| 2723 | + } |
|
| 2689 | 2724 | |
| 2690 | 2725 | $wp_scripts->add_data( 'wp-plupload', 'data', $script ); |
| 2691 | 2726 | } |
@@ -2700,17 +2735,20 @@ discard block |
||
| 2700 | 2735 | * @return array|void Array of attachment details. |
| 2701 | 2736 | */ |
| 2702 | 2737 | function wp_prepare_attachment_for_js( $attachment ) { |
| 2703 | - if ( ! $attachment = get_post( $attachment ) ) |
|
| 2704 | - return; |
|
| 2738 | + if ( ! $attachment = get_post( $attachment ) ) { |
|
| 2739 | + return; |
|
| 2740 | + } |
|
| 2705 | 2741 | |
| 2706 | - if ( 'attachment' != $attachment->post_type ) |
|
| 2707 | - return; |
|
| 2742 | + if ( 'attachment' != $attachment->post_type ) { |
|
| 2743 | + return; |
|
| 2744 | + } |
|
| 2708 | 2745 | |
| 2709 | 2746 | $meta = wp_get_attachment_metadata( $attachment->ID ); |
| 2710 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) |
|
| 2711 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 2712 | - else |
|
| 2713 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 2747 | + if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
| 2748 | + list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 2749 | + } else { |
|
| 2750 | + list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 2751 | + } |
|
| 2714 | 2752 | |
| 2715 | 2753 | $attachment_url = wp_get_attachment_url( $attachment->ID ); |
| 2716 | 2754 | |
@@ -2774,8 +2812,9 @@ discard block |
||
| 2774 | 2812 | $response['editLink'] = get_edit_post_link( $attachment->ID, 'raw' ); |
| 2775 | 2813 | } |
| 2776 | 2814 | |
| 2777 | - if ( current_user_can( 'delete_post', $attachment->ID ) ) |
|
| 2778 | - $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID ); |
|
| 2815 | + if ( current_user_can( 'delete_post', $attachment->ID ) ) { |
|
| 2816 | + $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID ); |
|
| 2817 | + } |
|
| 2779 | 2818 | |
| 2780 | 2819 | if ( $meta && 'image' === $type ) { |
| 2781 | 2820 | $sizes = array(); |
@@ -2797,8 +2836,9 @@ discard block |
||
| 2797 | 2836 | |
| 2798 | 2837 | /** This filter is documented in wp-includes/media.php */ |
| 2799 | 2838 | if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) { |
| 2800 | - if ( ! $downsize[3] ) |
|
| 2801 | - continue; |
|
| 2839 | + if ( ! $downsize[3] ) { |
|
| 2840 | + continue; |
|
| 2841 | + } |
|
| 2802 | 2842 | $sizes[ $size ] = array( |
| 2803 | 2843 | 'height' => $downsize[2], |
| 2804 | 2844 | 'width' => $downsize[1], |
@@ -2806,8 +2846,9 @@ discard block |
||
| 2806 | 2846 | 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape', |
| 2807 | 2847 | ); |
| 2808 | 2848 | } elseif ( isset( $meta['sizes'][ $size ] ) ) { |
| 2809 | - if ( ! isset( $base_url ) ) |
|
| 2810 | - $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
|
| 2849 | + if ( ! isset( $base_url ) ) { |
|
| 2850 | + $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
|
| 2851 | + } |
|
| 2811 | 2852 | |
| 2812 | 2853 | // Nothing from the filter, so consult image metadata if we have it. |
| 2813 | 2854 | $size_meta = $meta['sizes'][ $size ]; |
@@ -2835,15 +2876,18 @@ discard block |
||
| 2835 | 2876 | |
| 2836 | 2877 | $response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] ); |
| 2837 | 2878 | } elseif ( $meta && 'video' === $type ) { |
| 2838 | - if ( isset( $meta['width'] ) ) |
|
| 2839 | - $response['width'] = (int) $meta['width']; |
|
| 2840 | - if ( isset( $meta['height'] ) ) |
|
| 2841 | - $response['height'] = (int) $meta['height']; |
|
| 2879 | + if ( isset( $meta['width'] ) ) { |
|
| 2880 | + $response['width'] = (int) $meta['width']; |
|
| 2881 | + } |
|
| 2882 | + if ( isset( $meta['height'] ) ) { |
|
| 2883 | + $response['height'] = (int) $meta['height']; |
|
| 2884 | + } |
|
| 2842 | 2885 | } |
| 2843 | 2886 | |
| 2844 | 2887 | if ( $meta && ( 'audio' === $type || 'video' === $type ) ) { |
| 2845 | - if ( isset( $meta['length_formatted'] ) ) |
|
| 2846 | - $response['fileLength'] = $meta['length_formatted']; |
|
| 2888 | + if ( isset( $meta['length_formatted'] ) ) { |
|
| 2889 | + $response['fileLength'] = $meta['length_formatted']; |
|
| 2890 | + } |
|
| 2847 | 2891 | |
| 2848 | 2892 | $response['meta'] = array(); |
| 2849 | 2893 | foreach ( wp_get_attachment_id3_keys( $attachment, 'js' ) as $key => $label ) { |
@@ -2869,8 +2913,9 @@ discard block |
||
| 2869 | 2913 | } |
| 2870 | 2914 | } |
| 2871 | 2915 | |
| 2872 | - if ( function_exists('get_compat_media_markup') ) |
|
| 2873 | - $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) ); |
|
| 2916 | + if ( function_exists('get_compat_media_markup') ) { |
|
| 2917 | + $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) ); |
|
| 2918 | + } |
|
| 2874 | 2919 | |
| 2875 | 2920 | /** |
| 2876 | 2921 | * Filter the attachment data prepared for JavaScript. |
@@ -2902,8 +2947,9 @@ discard block |
||
| 2902 | 2947 | */ |
| 2903 | 2948 | function wp_enqueue_media( $args = array() ) { |
| 2904 | 2949 | // Enqueue me just once per page, please. |
| 2905 | - if ( did_action( 'wp_enqueue_media' ) ) |
|
| 2906 | - return; |
|
| 2950 | + if ( did_action( 'wp_enqueue_media' ) ) { |
|
| 2951 | + return; |
|
| 2952 | + } |
|
| 2907 | 2953 | |
| 2908 | 2954 | global $content_width, $wpdb, $wp_locale; |
| 2909 | 2955 | |
@@ -3204,8 +3250,9 @@ discard block |
||
| 3204 | 3250 | * @return array Found attachments. |
| 3205 | 3251 | */ |
| 3206 | 3252 | function get_attached_media( $type, $post = 0 ) { |
| 3207 | - if ( ! $post = get_post( $post ) ) |
|
| 3208 | - return array(); |
|
| 3253 | + if ( ! $post = get_post( $post ) ) { |
|
| 3254 | + return array(); |
|
| 3255 | + } |
|
| 3209 | 3256 | |
| 3210 | 3257 | $args = array( |
| 3211 | 3258 | 'post_parent' => $post->ID, |
@@ -3293,11 +3340,13 @@ discard block |
||
| 3293 | 3340 | * from the expanded shortcode. |
| 3294 | 3341 | */ |
| 3295 | 3342 | function get_post_galleries( $post, $html = true ) { |
| 3296 | - if ( ! $post = get_post( $post ) ) |
|
| 3297 | - return array(); |
|
| 3343 | + if ( ! $post = get_post( $post ) ) { |
|
| 3344 | + return array(); |
|
| 3345 | + } |
|
| 3298 | 3346 | |
| 3299 | - if ( ! has_shortcode( $post->post_content, 'gallery' ) ) |
|
| 3300 | - return array(); |
|
| 3347 | + if ( ! has_shortcode( $post->post_content, 'gallery' ) ) { |
|
| 3348 | + return array(); |
|
| 3349 | + } |
|
| 3301 | 3350 | |
| 3302 | 3351 | $galleries = array(); |
| 3303 | 3352 | if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) { |
@@ -3311,8 +3360,9 @@ discard block |
||
| 3311 | 3360 | } else { |
| 3312 | 3361 | preg_match_all( '#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER ); |
| 3313 | 3362 | if ( ! empty( $src ) ) { |
| 3314 | - foreach ( $src as $s ) |
|
| 3315 | - $srcs[] = $s[2]; |
|
| 3363 | + foreach ( $src as $s ) { |
|
| 3364 | + $srcs[] = $s[2]; |
|
| 3365 | + } |
|
| 3316 | 3366 | } |
| 3317 | 3367 | |
| 3318 | 3368 | $data = shortcode_parse_atts( $shortcode[3] ); |